NCBeam Class Reference

Contains events taken in a single beam configuration. More...

#include <NCBeam.h>

List of all members.

Public Member Functions

 NCBeam ()
 NCBeam (Detector::Detector_t detector, NCBeam::Info beamInfo, bool useCC, bool useNC, bool fillBins=true)
virtual ~NCBeam ()
BeamType::BeamType_t GetBeamType () const
Detector::Detector_t GetDetector () const
NC::RunUtil::ERunType GetRunType () const
double GetMaximumEnergy () const
int GetNumberEnergyBins (NCType::EEventType nccc) const
void GetEnergyBinBoundaries (double *bins) const
void AddEvent (ANtpHeaderInfo *headerInfo, ANtpBeamInfo *beamInfo, ANtpRecoInfo *recoInfo, ANtpAnalysisInfo *analysisInfo, ANtpTruthInfoBeam *truthInfo, bool useMCAsData, NCType::EFileType fileType=NCType::kBeamFile)
int FindEnergyBin (double energy)
void MakeResultPlots ()
TH1F * GetMCHistogram (NCType::EEventType nccc)
TH1F * GetMCTrueHistogram (NCType::EEventType nccc)
TH1F * GetMCFitHistogram (NCType::EEventType nccc)
TH1F * GetMCResidualHistogram (NCType::EEventType nccc)
TH1F * GetMCBackgroundHistogram (NCType::EEventType nccc)
TH1F * GetMCNoFitBackgroundHistogram (NCType::EEventType nccc)
TH1F * GetDataHistogram (NCType::EEventType nccc)
TH1F * GetMCFitNuMuToNuTauHistogram (NCType::EEventType nccc)
TH1F * GetMCNoFitNuMuToNuTauHistogram (NCType::EEventType nccc)
TH1F * GetMCFitNuMuToNuEHistogram (NCType::EEventType nccc)
TH1F * GetMCNoFitNuMuToNuEHistogram (NCType::EEventType nccc)
TH1F * GetMCFitNuEToNuEHistogram (NCType::EEventType nccc)
TH1F * GetMCNoFitNuEToNuEHistogram (NCType::EEventType nccc)
const TH1F * GetDefaultMCHistogram (NCType::EEventType nccc) const
TGraphAsymmErrors * GetDataGraph (NCType::EEventType nccc)
NCEnergyBinGetEnergyBin (int i, NCType::EEventType nccc) const
void WriteResources ()
void WritePredictionResources ()
void Reset (bool data, bool mc)
void SetRunType (NC::RunUtil::ERunType runType)
Info GetInfo () const
void FillResultHistograms (const NC::OscProb::OscPars *oscPars, const NC::SystPars *systPars)
 This function should only be called once.
void MarkHistogramsFilled ()

Private Member Functions

NCBeamoperator= (const NCBeam &)
 Don't make any provisions for doing this, so don't let anyone.
void InitNulls ()
 Internal function implementing common part of constructors.
void Init ()
 Internal function implementing common part of constructors.
void MakeMCHistogram (TH1F *mc, TH1F *mcTrue, TH1F *noFitBg, TH1F *noFitNuMuToNuTau, TH1F *noFitNuMuToNuE, TH1F *noFitNuEToNuE, TH1F *fit, TH1F *fitBg, TH1F *fitNuMuToNuTau, TH1F *fitNuMuToNuE, TH1F *fitNuEToNuE)
void MakeDataGraph ()
void MakeResidualHistogram (std::vector< NCEnergyBin * > &energyBins, TH1F *fit, TH1F *data, TH1F *resid)
void MakeDataHistogram (std::vector< NCEnergyBin * > &energyBins, TH1F *data)
void MakeGraphFromHistogram (TH1F *hist, TGraphAsymmErrors *graph) const
 Convert a histogram into a graph with correct poisson errors.
TH1F * NewVisEnergySpectrum (TString name, int colour, int fillcol=-1) const
 Helper function for Init.

Private Attributes

Info fInfo
Detector::Detector_t fDetector
int fNumEnergyBins
double fEnergyBinBoundaries [201]
bool fUseCC
bool fUseNC
bool fFillBins
 NCEnergyBin vectors take up a lot of space, sometimes want to suppress them
bool fResultHistogramsFilled
 Guard variable for FillResultHistograms.
TH1F * fDefaultMCHistogram [2]
 Every MC event given to us that is selected NC/CC and is truly $\nu_\mu$.
TH1F * fMCHistogram [2]
TH1F * fMCTrueHistogram [2]
TH1F * fMCFitHistogram [2]
TH1F * fMCResidualHistogram [2]
TH1F * fMCBackgroundHistogram [2]
TH1F * fMCNoFitNuMuToNuTau [2]
TH1F * fMCFitNuMuToNuTau [2]
TH1F * fMCNoFitNuMuToNuE [2]
TH1F * fMCFitNuMuToNuE [2]
TH1F * fMCNoFitNuEToNuE [2]
TH1F * fMCFitNuEToNuE [2]
TH1F * fDataHistogram [2]
TH1F * fMCNoFitBackgroundHistogram [2]
TGraphAsymmErrors * fDataGraph [2]
std::vector< NCEnergyBin * > fEnergyBins [2]

Classes

class  Info


Detailed Description

Contains events taken in a single beam configuration.

Definition at line 94 of file NCBeam.h.


Constructor & Destructor Documentation

NCBeam::NCBeam (  ) 

Definition at line 36 of file NCBeam.cxx.

00036                : fInfo(BeamType::BeamType_t(0), NC::RunUtil::ERunType(0))
00037 {
00038   InitNulls();
00039 }

NCBeam::NCBeam ( Detector::Detector_t  detector,
NCBeam::Info  beamInfo,
bool  useCC,
bool  useNC,
bool  fillBins = true 
)

Definition at line 43 of file NCBeam.cxx.

References Init().

00046                               :
00047   fInfo(beamInfo),
00048   fDetector(detector),
00049   fUseCC(useCC),
00050   fUseNC(useNC),
00051   fFillBins(fillBins)
00052 {
00053   Init();
00054 }

NCBeam::~NCBeam (  )  [virtual]

Definition at line 195 of file NCBeam.cxx.

References fDataGraph, fDataHistogram, fDefaultMCHistogram, fEnergyBins, fMCBackgroundHistogram, fMCFitHistogram, fMCFitNuEToNuE, fMCFitNuMuToNuE, fMCFitNuMuToNuTau, fMCHistogram, fMCNoFitBackgroundHistogram, fMCNoFitNuEToNuE, fMCNoFitNuMuToNuE, fMCNoFitNuMuToNuTau, fMCResidualHistogram, fMCTrueHistogram, NCType::kCC, Msg::kDebug, OscFit::kNC, and MSG.

00196 {
00197   MSG("NCBeam", Msg::kDebug) << "NCBeam::Destructor" << endl;
00198 
00199   for(int nccc = kNC; nccc <= kCC; ++nccc){
00200     delete fDefaultMCHistogram[nccc];
00201     delete fMCHistogram[nccc];
00202     delete fMCTrueHistogram[nccc];
00203     delete fMCFitHistogram[nccc];
00204     delete fMCResidualHistogram[nccc];
00205     delete fMCBackgroundHistogram[nccc];
00206     delete fMCNoFitNuMuToNuTau[nccc];
00207     delete fMCFitNuMuToNuTau[nccc];
00208     delete fMCNoFitNuMuToNuE[nccc];
00209     delete fMCFitNuMuToNuE[nccc];
00210     delete fMCNoFitNuEToNuE[nccc];
00211     delete fMCFitNuEToNuE[nccc];
00212     delete fDataHistogram[nccc];
00213     delete fMCNoFitBackgroundHistogram[nccc];
00214     delete fDataGraph[nccc];
00215 
00216     for(unsigned int n = 0; n < fEnergyBins[nccc].size(); ++n)
00217       delete fEnergyBins[nccc][n];
00218   }
00219 }


Member Function Documentation

void NCBeam::AddEvent ( ANtpHeaderInfo headerInfo,
ANtpBeamInfo beamInfo,
ANtpRecoInfo recoInfo,
ANtpAnalysisInfo analysisInfo,
ANtpTruthInfoBeam truthInfo,
bool  useMCAsData,
NCType::EFileType  fileType = NCType::kBeamFile 
)

Definition at line 467 of file NCBeam.cxx.

References NCBeam::Info::beamType, ANtpHeaderInfo::dataType, fDefaultMCHistogram, fDetector, fEnergyBins, fFillBins, FindEnergyBin(), fInfo, fUseCC, fUseNC, ANtpAnalysisInfo::isCC, ANtpAnalysisInfo::isNC, NCType::kCC, SimFlag::kData, Msg::kDebug, SimFlag::kMC, OscFit::kNC, Detector::kNear, MSG, ANtpRecoInfo::nuEnergy, ANtpTruthInfo::nuFlavor, and ANtpRecoInfo::weight.

Referenced by NCExtrapolation::AddEvent().

00474 {
00475 
00476   MSG("NCBeam", Msg::kDebug) << "In NCBeam::AddEvent" << endl;
00477 
00478   int mcCC = 0, mcNC = 0;
00479 
00480   //want to fill both nc and cc events in the near detector, but not necessarily
00481   //in the far detector
00482   const bool useNC = (fUseNC || fDetector == Detector::kNear);
00483   const bool useCC = (fUseCC || fDetector == Detector::kNear);
00484 
00485   //really no need to check on snarl or event quality as those events that don't pass
00486   //the cuts dont get put into the ntuples from the extraction code.
00487 
00488   //which reconstructed energy bin is the event in?
00489   int bin = FindEnergyBin(recoInfo->nuEnergy);
00490 
00491   if(bin < fNumEnergyBins && bin > -1){
00492     if(headerInfo->dataType == SimFlag::kData || (truthInfo && useMCAsData)){
00493 //       MAXMSG("NCBeam", Msg::kInfo, 20) << "DATA " << headerInfo->detector << "/"
00494 //                                     << (int)Detector::kNear << " "
00495 //                                     << headerInfo->dataType << "/"
00496 //                                     << (int)SimFlag::kData << " "
00497 //                                     << analysisInfo->isNC << " "
00498 //                                     << analysisInfo->isCC << " "
00499 //                                     << headerInfo->run << " "
00500 //                                     << headerInfo->snarl << " "
00501 //                                     << endl;
00502       if(analysisInfo->isNC > 0 && useNC){
00503         ++mcNC;
00504         if(fFillBins) fEnergyBins[kNC][bin]->AddEventToBin(recoInfo);
00505       }
00506       else if(analysisInfo->isCC > 0 && useCC){
00507         ++mcCC;
00508         if(fFillBins) fEnergyBins[kCC][bin]->AddEventToBin(recoInfo);
00509       }
00510     }//end if data
00511     else if(headerInfo->dataType == SimFlag::kMC){
00512 
00513 //       if(fileType == NCType::kElectronFile){
00514 //      MAXMSG("NCBeam", Msg::kInfo, 20)
00515 //        << "MC " << headerInfo->run << " " << headerInfo->snarl << " "
00516 //        << truthInfo->interactionType << " "
00517 //        << recoInfo->weight << " "
00518 //        << energy << " " << recoInfo->nuEnergy << " "
00519 //        << FindEnergyBin(energy) << endl;
00520 //       }
00521 
00522       if(analysisInfo->isNC > 0 && useNC){
00523         ++mcNC;
00524         if(fFillBins) fEnergyBins[kNC][bin]->AddEventToBin(recoInfo, truthInfo, fileType);
00525         if(truthInfo->nuFlavor == 14)
00526           fDefaultMCHistogram[kNC]->Fill(recoInfo->nuEnergy, recoInfo->weight);
00527       }
00528       else if(analysisInfo->isCC > 0 && useCC){
00529         ++mcCC;
00530         if(fFillBins) fEnergyBins[kCC][bin]->AddEventToBin(recoInfo, truthInfo, fileType);
00531         if(truthInfo->nuFlavor == 14)
00532           fDefaultMCHistogram[kCC]->Fill(recoInfo->nuEnergy, recoInfo->weight);
00533       }
00534 
00535     }//end if monte carlo
00536   }//end if acceptable value for energy bin
00537 
00538   MSG("NCBeam", Msg::kDebug) << fInfo.beamType << " mc cc = " << mcCC
00539                              << " nc = " << mcNC << endl;
00540 }

void NCBeam::FillResultHistograms ( const NC::OscProb::OscPars oscPars,
const NC::SystPars systPars 
)

This function should only be called once.

See also:
fResultHistogramsFilled

Definition at line 1124 of file NCBeam.cxx.

References det, MuELoss::e, fResultHistogramsFilled, fUseCC, fUseNC, NCBeam::Info::GetDescription(), GetDetector(), GetEnergyBin(), GetInfo(), GetMCBackgroundHistogram(), GetMCFitHistogram(), GetMCFitNuEToNuEHistogram(), GetMCFitNuMuToNuEHistogram(), GetMCFitNuMuToNuTauHistogram(), GetMCHistogram(), GetMCNoFitNuEToNuEHistogram(), GetMCNoFitNuMuToNuEHistogram(), GetMCNoFitNuMuToNuTauHistogram(), NCEnergyBin::GetMCSignalVectorSize(), GetMCTrueHistogram(), GetNumberEnergyBins(), NCType::kBaseLineFar, NCType::kBaseLineNear, NCType::kCC, Detector::kFar, OscFit::kNC, NCType::kNC, NCType::kNuEToNuE, NCType::kNuMuToNuE, NCType::kNuMuToNuMu, NCType::kNuMuToNuTau, Msg::kWarning, MSG, NC::SystPars::NormScale(), NC::SystPars::ShowerScale(), NC::SystPars::TrackScale(), and NC::OscProb::OscPars::TransitionProbability().

Referenced by NCExtrapolation::FillResultHistograms().

01126 {
01127   if(fResultHistogramsFilled){
01128     MSG("NCBeam", Msg::kWarning) << "Calling FillResultHistograms again on "
01129                                  << "the same beam "
01130                                  << GetInfo().GetDescription()
01131                                  << GetDetector()
01132                                  << ". Call ignored." << endl;
01133     return;
01134   }
01135   fResultHistogramsFilled = true;
01136 
01137   using NCType::EEventType;
01138   using NCType::kNC;
01139   using NCType::kCC;
01140 
01141   // These are the variables we load the event information into
01142   double trueEnergy, recoShowerE, recoMuonE, weight;
01143   int flavor;
01144 
01145   const Detector::Detector_t det = GetDetector();
01146   const double baseLine = (det == Detector::kFar) ? NCType::kBaseLineFar
01147                                                   : NCType::kBaseLineNear;
01148 
01149   //loop over NC/CC energy bins in beam
01150   for(EEventType nccc = kNC; nccc <= kCC; nccc = EEventType(int(nccc)+1)){
01151 
01152     if(nccc == kNC && det == Detector::kFar && !fUseNC) continue;
01153     if(nccc == kCC && det == Detector::kFar && !fUseCC) continue;
01154 
01155     const EEventType sigType = EEventType(nccc);
01156     const EEventType bkgType = (nccc == kNC) ? kCC : kNC;
01157 
01158     const int I = GetNumberEnergyBins(nccc);
01159     for(int i = 0; i < I; ++i){
01160       NCEnergyBin* bin = GetEnergyBin(i, nccc);
01161 
01162       const int mcSize             = bin->GetMCSignalVectorSize();
01163       const int mcSize_bkg         = bin->GetMCBackgroundVectorSize();
01164       const int mcSize_NuMuToNuTau = bin->GetMCNuTauVectorSize();
01165       const int mcSize_NuEToNuE    = bin->GetMCBeamNuEVectorSize();
01166       const int mcSize_NuMuToNuE   = bin->GetMCOscNuEVectorSize();
01167 
01168       for(int e = 0; e < mcSize; ++e){
01169         bin->GetMCInformation(trueEnergy, recoShowerE, recoMuonE, weight, flavor, e);
01170         double survivalProb = oscPars->TransitionProbability(NCType::kNuMuToNuMu,
01171                                                              sigType,
01172                                                              baseLine,
01173                                                              trueEnergy);
01174 
01175         GetMCHistogram(sigType)->
01176           Fill(recoShowerE*systPars->ShowerScale(det)
01177                + recoMuonE*systPars->TrackScale(),
01178                weight*systPars->NormScale());
01179 
01180         GetMCTrueHistogram(sigType)->Fill(trueEnergy,weight);
01181 
01182         GetMCFitHistogram(sigType)->
01183           Fill(recoShowerE*systPars->ShowerScale(det)
01184                + recoMuonE*systPars->TrackScale(),
01185                weight*survivalProb*systPars->NormScale());
01186       }//end loop over signal
01187 
01188       for(int e = 0; e < mcSize_bkg; ++e){
01189         bin->GetMCBackgroundInformation(trueEnergy, recoShowerE, recoMuonE, weight, flavor, e);
01190 
01191         double survivalProb = oscPars->TransitionProbability(NCType::kNuMuToNuMu,
01192                                                              bkgType,
01193                                                              baseLine,
01194                                                              trueEnergy);
01195 
01196         GetMCBackgroundHistogram(sigType)->
01197           Fill(recoShowerE*systPars->ShowerScale(det)
01198                + recoMuonE*systPars->TrackScale(),
01199                weight*survivalProb*systPars->NormScale());
01200 
01201         GetMCHistogram(sigType)->
01202           Fill(recoShowerE*systPars->ShowerScale(det)
01203                + recoMuonE*systPars->TrackScale(),
01204                weight*systPars->NormScale());
01205 
01206         GetMCFitHistogram(sigType)->
01207           Fill(recoShowerE*systPars->ShowerScale(det)
01208                + recoMuonE*systPars->TrackScale(),
01209                weight*survivalProb*systPars->NormScale());
01210       }//end loop over background
01211 
01212       //nutau
01213       for(int e = 0; e < mcSize_NuMuToNuTau; ++e){
01214         bin->GetMCNuTauInformation(trueEnergy, recoShowerE, recoMuonE, weight, flavor, e);
01215 
01216         double survivalProb = oscPars->TransitionProbability(NCType::kNuMuToNuTau,
01217                                                              kCC,
01218                                                              baseLine,
01219                                                              trueEnergy);
01220 
01221         GetMCFitNuMuToNuTauHistogram(sigType)->
01222           Fill(recoShowerE*systPars->ShowerScale(det)
01223                + recoMuonE*systPars->TrackScale(),
01224                weight*survivalProb*systPars->NormScale());
01225 
01226         GetMCFitHistogram(sigType)->
01227           Fill(recoShowerE*systPars->ShowerScale(det)
01228                + recoMuonE*systPars->TrackScale(),
01229                weight*survivalProb*systPars->NormScale());
01230 
01231         GetMCNoFitNuMuToNuTauHistogram(sigType)->
01232           Fill(recoShowerE*systPars->ShowerScale(det)
01233                + recoMuonE*systPars->TrackScale(),
01234                weight*systPars->NormScale());
01235       }//end loop over taus
01236 
01237       //nue
01238       for(int e = 0; e < mcSize_NuEToNuE; ++e){
01239         bin->GetMCBeamNuEInformation(trueEnergy, recoShowerE, recoMuonE, weight, flavor, e);
01240 
01241         double survivalProb = oscPars->TransitionProbability(NCType::kNuEToNuE,
01242                                                              kCC,
01243                                                              baseLine,
01244                                                              trueEnergy);
01245         GetMCHistogram(sigType)->
01246           Fill(recoShowerE*systPars->ShowerScale(det)
01247                + recoMuonE*systPars->TrackScale(),
01248                weight*systPars->NormScale());
01249 
01250         GetMCFitHistogram(sigType)->
01251           Fill(recoShowerE*systPars->ShowerScale(det)
01252                + recoMuonE*systPars->TrackScale(),
01253                weight*systPars->NormScale()
01254                *survivalProb);
01255 
01256         GetMCNoFitNuEToNuEHistogram(sigType)->
01257           Fill(recoShowerE*systPars->ShowerScale(det)
01258                + recoMuonE*systPars->TrackScale(),
01259                weight*systPars->NormScale());
01260 
01261         GetMCFitNuEToNuEHistogram(sigType)->
01262           Fill(recoShowerE*systPars->ShowerScale(det)
01263                + recoMuonE*systPars->TrackScale(),
01264                weight*systPars->NormScale()
01265                *survivalProb);
01266       }//end loop over electrons
01267 
01268       //nue appearance
01269       for(int e = 0; e < mcSize_NuMuToNuE; ++e){
01270         bin->GetMCOscNuEInformation(trueEnergy, recoShowerE,
01271                                     recoMuonE, weight, flavor, e);
01272 
01273         double survivalProb = oscPars->TransitionProbability(NCType::kNuMuToNuE,
01274                                                              kCC,
01275                                                              baseLine,
01276                                                              trueEnergy);
01277 
01278         GetMCFitHistogram(sigType)->
01279           Fill(recoShowerE*systPars->ShowerScale(det)
01280                + recoMuonE*systPars->TrackScale(),
01281                weight*survivalProb*systPars->NormScale());
01282 
01283         GetMCNoFitNuMuToNuEHistogram(sigType)->
01284           Fill(recoShowerE*systPars->ShowerScale(det)
01285                + recoMuonE*systPars->TrackScale(),
01286                weight*systPars->NormScale());
01287 
01288         GetMCFitNuMuToNuEHistogram(sigType)->
01289           Fill(recoShowerE*systPars->ShowerScale(det)
01290                + recoMuonE*systPars->TrackScale(),
01291                weight*survivalProb*systPars->NormScale());
01292       }//end loop over electron appearance
01293 
01294     }//end loop over energy bins
01295 
01296   }//end loop over nc/cc
01297 }

int NCBeam::FindEnergyBin ( double  energy  ) 

Definition at line 543 of file NCBeam.cxx.

References fEnergyBinBoundaries, fNumEnergyBins, and kMaxEnergy.

Referenced by AddEvent().

00544 {
00545   //do a binary search to find the appropriate bin - the first entry in binBoundaries
00546   //is 0. as the binary search returns the nearest element smaller than the
00547   //desired value
00548   if(energy > kMaxEnergy) return fNumEnergyBins;
00549 
00550   return TMath::BinarySearch(fNumEnergyBins, fEnergyBinBoundaries, energy);
00551 }

BeamType::BeamType_t NCBeam::GetBeamType (  )  const

Definition at line 440 of file NCBeam.cxx.

References NCBeam::Info::beamType, and fInfo.

Referenced by NCExtrapolationBeamMatrix::FillNDHistsForXSectionFit(), and NCExtrapolationBeamMatrix::GetEfficiencyHistograms().

00441 {
00442   return fInfo.beamType;
00443 }

TGraphAsymmErrors * NCBeam::GetDataGraph ( NCType::EEventType  nccc  ) 

Definition at line 995 of file NCBeam.cxx.

References fDataGraph.

00996 {
00997   return fDataGraph[nccc];
00998 }

TH1F * NCBeam::GetDataHistogram ( NCType::EEventType  nccc  ) 

Definition at line 929 of file NCBeam.cxx.

References fDataHistogram.

00930 {
00931   return fDataHistogram[nccc];
00932 }

const TH1F * NCBeam::GetDefaultMCHistogram ( NCType::EEventType  nccc  )  const

Return the MC as given to NCBeam by AddEvent. This is filled in NCBeam::AddEvent

See also:
fDefaultMCHistogramNC fDefaultMCHistogramCC

Definition at line 911 of file NCBeam.cxx.

References fDefaultMCHistogram.

00912 {
00913   return fDefaultMCHistogram[nccc];
00914 }

Detector::Detector_t NCBeam::GetDetector (  )  const

Definition at line 434 of file NCBeam.cxx.

References fDetector.

Referenced by FillResultHistograms().

00435 {
00436   return fDetector;
00437 }

NCEnergyBin * NCBeam::GetEnergyBin ( int  i,
NCType::EEventType  nccc 
) const

Definition at line 401 of file NCBeam.cxx.

References fEnergyBins, Msg::kWarning, and MSG.

Referenced by NCExtrapolationFarNear::FillDataMCHistogramsFar(), NCExtrapolationBeamMatrix::FillDataMCHistogramsFar(), NCExtrapolationFarNear::FillDataMCHistogramsNear(), NCExtrapolationBeamMatrix::FillDataMCHistogramsNear(), NCExtrapolationBeamMatrix::FillNDHistsForXSectionFit(), and FillResultHistograms().

00402 {
00403   if(int(fEnergyBins[nccc].size()) > i)
00404     return fEnergyBins[nccc][i];
00405   else
00406     MSG("NCBeam", Msg::kWarning) << "cant find requested bin "
00407                                  << "object - returning null "
00408                                  << "pointer" << endl;
00409 
00410   return 0;
00411 }

void NCBeam::GetEnergyBinBoundaries ( double *  bins  )  const

Definition at line 427 of file NCBeam.cxx.

References fEnergyBinBoundaries, and fNumEnergyBins.

00428 {
00429   for(int i = 0; i < fNumEnergyBins; ++i)
00430     bins[i] = fEnergyBinBoundaries[i];
00431 }

NCBeam::Info NCBeam::GetInfo (  )  const

Definition at line 452 of file NCBeam.cxx.

References fInfo.

Referenced by NCExtrapolationBeamMatrix::doNDXsectionFit(), NCExtrapolationBeamMatrix::FillDataMCHistogramsNear(), FillResultHistograms(), NCExtrapolationBeamMatrix::GetEfficiencyHistograms(), and Init().

00453 {
00454   return fInfo;
00455 }

double NCBeam::GetMaximumEnergy (  )  const

Definition at line 415 of file NCBeam.cxx.

References kMaxEnergy.

00416 {
00417   return kMaxEnergy;
00418 }

TH1F * NCBeam::GetMCBackgroundHistogram ( NCType::EEventType  nccc  ) 

Definition at line 947 of file NCBeam.cxx.

References fMCBackgroundHistogram.

Referenced by FillResultHistograms().

00948 {
00949   return fMCBackgroundHistogram[nccc];
00950 }

TH1F * NCBeam::GetMCFitHistogram ( NCType::EEventType  nccc  ) 

Definition at line 935 of file NCBeam.cxx.

References fMCFitHistogram.

Referenced by FillResultHistograms().

00936 {
00937   return fMCFitHistogram[nccc];
00938 }

TH1F * NCBeam::GetMCFitNuEToNuEHistogram ( NCType::EEventType  nccc  ) 

Definition at line 983 of file NCBeam.cxx.

References fMCFitNuEToNuE.

Referenced by FillResultHistograms().

00984 {
00985   return fMCFitNuEToNuE[nccc];
00986 }

TH1F * NCBeam::GetMCFitNuMuToNuEHistogram ( NCType::EEventType  nccc  ) 

Definition at line 971 of file NCBeam.cxx.

References fMCFitNuMuToNuE.

Referenced by FillResultHistograms().

00972 {
00973   return fMCFitNuMuToNuE[nccc];
00974 }

TH1F * NCBeam::GetMCFitNuMuToNuTauHistogram ( NCType::EEventType  nccc  ) 

Definition at line 959 of file NCBeam.cxx.

References fMCFitNuMuToNuTau.

Referenced by FillResultHistograms().

00960 {
00961   return fMCFitNuMuToNuTau[nccc];
00962 }

TH1F * NCBeam::GetMCHistogram ( NCType::EEventType  nccc  ) 

Return the histogram for unoscillated MC. Like the other histograms (except the default MC), this is filled by FillResultHistograms

Definition at line 917 of file NCBeam.cxx.

References fMCHistogram.

Referenced by FillResultHistograms().

00918 {
00919   return fMCHistogram[nccc];
00920 }

TH1F * NCBeam::GetMCNoFitBackgroundHistogram ( NCType::EEventType  nccc  ) 

Definition at line 953 of file NCBeam.cxx.

References fMCNoFitBackgroundHistogram.

00954 {
00955   return fMCNoFitBackgroundHistogram[nccc];
00956 }

TH1F * NCBeam::GetMCNoFitNuEToNuEHistogram ( NCType::EEventType  nccc  ) 

Definition at line 989 of file NCBeam.cxx.

References fMCNoFitNuEToNuE.

Referenced by FillResultHistograms().

00990 {
00991   return fMCNoFitNuEToNuE[nccc];
00992 }

TH1F * NCBeam::GetMCNoFitNuMuToNuEHistogram ( NCType::EEventType  nccc  ) 

Definition at line 977 of file NCBeam.cxx.

References fMCNoFitNuMuToNuE.

Referenced by FillResultHistograms().

00978 {
00979   return fMCNoFitNuMuToNuE[nccc];
00980 }

TH1F * NCBeam::GetMCNoFitNuMuToNuTauHistogram ( NCType::EEventType  nccc  ) 

Definition at line 965 of file NCBeam.cxx.

References fMCNoFitNuMuToNuTau.

Referenced by FillResultHistograms().

00966 {
00967   return fMCNoFitNuMuToNuTau[nccc];
00968 }

TH1F * NCBeam::GetMCResidualHistogram ( NCType::EEventType  nccc  ) 

Definition at line 941 of file NCBeam.cxx.

References fMCResidualHistogram.

00942 {
00943   return fMCResidualHistogram[nccc];
00944 }

TH1F * NCBeam::GetMCTrueHistogram ( NCType::EEventType  nccc  ) 

Definition at line 923 of file NCBeam.cxx.

References fMCTrueHistogram.

Referenced by FillResultHistograms().

00924 {
00925   return fMCTrueHistogram[nccc];
00926 }

int NCBeam::GetNumberEnergyBins ( NCType::EEventType  nccc  )  const

Definition at line 421 of file NCBeam.cxx.

References fEnergyBins.

Referenced by NCExtrapolationFarNear::FillDataMCHistogramsFar(), NCExtrapolationBeamMatrix::FillDataMCHistogramsFar(), NCExtrapolationFarNear::FillDataMCHistogramsNear(), NCExtrapolationBeamMatrix::FillDataMCHistogramsNear(), NCExtrapolationBeamMatrix::FillNDHistsForXSectionFit(), and FillResultHistograms().

00422 {
00423   return int(fEnergyBins[nccc].size());
00424 }

NC::RunUtil::ERunType NCBeam::GetRunType (  )  const

Definition at line 446 of file NCBeam.cxx.

References fInfo, and NCBeam::Info::GetRunType().

Referenced by NCExtrapolationBeamMatrix::doNDXsectionFit(), NCExtrapolationBeamMatrix::FillDataMCHistogramsNear(), NCExtrapolationBeamMatrix::GetBeamMatrix(), and NCExtrapolationBeamMatrix::GetEfficiencyHistograms().

00447 {
00448   return fInfo.GetRunType();
00449 }

void NCBeam::Init (  )  [private]

Internal function implementing common part of constructors.

Definition at line 82 of file NCBeam.cxx.

References Detector::AsString(), fDataGraph, fDataHistogram, fDefaultMCHistogram, fDetector, fEnergyBinBoundaries, fEnergyBins, fMCBackgroundHistogram, fMCFitHistogram, fMCFitNuEToNuE, fMCFitNuMuToNuE, fMCFitNuMuToNuTau, fMCHistogram, fMCNoFitBackgroundHistogram, fMCNoFitNuEToNuE, fMCNoFitNuMuToNuE, fMCNoFitNuMuToNuTau, fMCResidualHistogram, fMCTrueHistogram, fNumEnergyBins, fResultHistogramsFilled, fUseCC, fUseNC, NCBeam::Info::GetDescription(), GetInfo(), InitNulls(), NCType::kCC, Msg::kDebug, kEnergyBinsFar, kEnergyBinsNear, kEnergyBinWidthNear, Detector::kFar, kMaxEnergy, OscFit::kNC, Detector::kNear, kNumEnergyBinsFar, kNumEnergyBinsNear, MSG, and NewVisEnergySpectrum().

Referenced by NCBeam().

00083 {
00084   MSG("NCBeam", Msg::kDebug) << "NCBeam::Constructor" << endl;
00085 
00086   fResultHistogramsFilled = false;
00087 
00088   InitNulls();
00089 
00090   //make the energy bin objects for cc and nc events
00091   double binCentralValue = 0.;
00092   double binWidth = kEnergyBinWidthNear; //0.5;
00093   fNumEnergyBins = kNumEnergyBinsNear; //200;
00094   if(fDetector == Detector::kFar){
00095     fNumEnergyBins = kNumEnergyBinsFar; //23;
00096   }
00097 
00098   for(int i = 0; i < fNumEnergyBins; ++i){
00099 
00100     fEnergyBinBoundaries[i] = kEnergyBinsNear[i];
00101     binCentralValue = binWidth*(i*1. + 0.5);
00102 
00103     if(fDetector == Detector::kFar){
00104       fEnergyBinBoundaries[i] = kEnergyBinsFar[i];
00105       binWidth = kEnergyBinsFar[i+1] - kEnergyBinsFar[i];
00106       binCentralValue = binWidth*(0.5) + fEnergyBinBoundaries[i];
00107     }
00108 
00109     MSG("NCBeam", Msg::kDebug) << "energy bin " << i << " " << binCentralValue
00110                               << " " << binWidth << " " << fEnergyBinBoundaries[i]
00111                               << " " << fNumEnergyBins << endl;
00112 
00113     if(fUseCC || fDetector == Detector::kNear)
00114       fEnergyBins[kCC].push_back(new NCEnergyBin(binCentralValue, binWidth,
00115                                                  kCC));
00116     if(fUseNC || fDetector == Detector::kNear)
00117       fEnergyBins[kNC].push_back(new NCEnergyBin(binCentralValue, binWidth,
00118                                                  kNC));
00119   } // end for i
00120 
00121   fEnergyBinBoundaries[fNumEnergyBins] = kMaxEnergy;
00122 
00123   //make the fit result histograms
00124   TString name = "monteCarlo";
00125   TString nc = "NC";
00126   TString cc = "CC";
00127   TString fit = "Fit";
00128   TString residual = "Residual";
00129   TString noFit = "Nominal";
00130   TString bg = "Background";
00131   TString y = "Y";
00132   TString truth = "true";
00133 
00134   TString type = Detector::AsString(fDetector);
00135   type += GetInfo().GetDescription();
00136 
00137   for(int nccc = kNC; nccc <= kCC; ++nccc){
00138     TString ncccStr = nccc == kNC ? nc : cc;
00139 
00140     fMCHistogram[nccc] =
00141       NewVisEnergySpectrum(name+type+noFit+ncccStr, kRed);
00142 
00143     fMCTrueHistogram[nccc] =
00144       NewVisEnergySpectrum(name+type+truth+ncccStr, kBlack);
00145     fMCTrueHistogram[nccc]->SetXTitle("E_{Truth} (GeV)");
00146 
00147     fDefaultMCHistogram[nccc] =
00148       NewVisEnergySpectrum(name+"Default"+type+noFit+ncccStr, kBlack);
00149 
00150     fDataHistogram[nccc] =
00151       NewVisEnergySpectrum("Data_"+type+ncccStr, kBlack);
00152     fDataHistogram[nccc]->SetMarkerStyle(kFullSquare);
00153 
00154     fMCFitHistogram[nccc] =
00155       NewVisEnergySpectrum(name+type+fit+ncccStr, kBlue);
00156 
00157     fMCResidualHistogram[nccc] =
00158       NewVisEnergySpectrum(name+type+residual+ncccStr, kBlue);
00159     fMCResidualHistogram[nccc]->SetYTitle("Residual/GeV");
00160     fMCResidualHistogram[nccc]->SetLineStyle(9);
00161 
00162     fMCBackgroundHistogram[nccc] =
00163       NewVisEnergySpectrum(name+type+bg+ncccStr, kBlack, kBlack);
00164 
00165     fMCNoFitBackgroundHistogram[nccc] =
00166       NewVisEnergySpectrum(name+type+noFit+bg+ncccStr, kBlack, kBlack);
00167 
00168     fMCFitNuMuToNuTau[nccc] =
00169       NewVisEnergySpectrum(name+type+"NuMuToNuTauFit"+ncccStr, kBlack, kMagenta+2);
00170 
00171     fMCNoFitNuMuToNuTau[nccc] =
00172       NewVisEnergySpectrum(name+type+"NuMuToNuTauNoFit"+ncccStr, kBlack, kMagenta+2);
00173 
00174     fMCFitNuMuToNuE[nccc] =
00175       NewVisEnergySpectrum(name+type+"NuMuToNuEFit"+ncccStr, kBlack, kOrange-3);
00176 
00177     fMCNoFitNuMuToNuE[nccc] =
00178       NewVisEnergySpectrum(name+type+"NuMuToNuENoFit"+ncccStr, kBlack, kOrange-3);
00179 
00180     fMCFitNuEToNuE[nccc] =
00181       NewVisEnergySpectrum(name+type+"NuEToNuEFit"+ncccStr, kBlack, kGreen+2);
00182 
00183     fMCNoFitNuEToNuE[nccc] =
00184       NewVisEnergySpectrum(name+type+"NuEToNuENoFit"+ncccStr, kBlack, kGreen+2);
00185 
00186     TString data = "data";
00187     fDataGraph[nccc] = new TGraphAsymmErrors(fNumEnergyBins);
00188     fDataGraph[nccc]->SetName(data+type+ncccStr);
00189     fDataGraph[nccc]->SetTitle("");
00190     fDataGraph[nccc]->SetMarkerStyle(kFullCircle);
00191   } // end for nccc
00192 }

void NCBeam::InitNulls (  )  [private]

Internal function implementing common part of constructors.

Definition at line 58 of file NCBeam.cxx.

References fDataGraph, fDataHistogram, fDefaultMCHistogram, fMCBackgroundHistogram, fMCFitHistogram, fMCFitNuEToNuE, fMCFitNuMuToNuE, fMCFitNuMuToNuTau, fMCHistogram, fMCNoFitBackgroundHistogram, fMCNoFitNuEToNuE, fMCNoFitNuMuToNuE, fMCNoFitNuMuToNuTau, fMCResidualHistogram, fMCTrueHistogram, NCType::kCC, and OscFit::kNC.

Referenced by Init().

00059 {
00060   for(int nccc = kNC; nccc <= kCC; ++nccc){
00061     fDefaultMCHistogram[nccc] = 0;
00062     fMCHistogram[nccc] = 0;
00063     fMCTrueHistogram[nccc] = 0;
00064     fMCFitHistogram[nccc] = 0;
00065     fMCBackgroundHistogram[nccc] = 0;
00066     fDataGraph[nccc] = 0;
00067     fMCBackgroundHistogram[nccc] = 0;
00068     fMCNoFitNuMuToNuTau[nccc] = 0;
00069     fMCFitNuMuToNuTau[nccc] = 0;
00070     fMCNoFitNuMuToNuE[nccc] = 0;
00071     fMCFitNuMuToNuE[nccc] = 0;
00072     fMCNoFitNuEToNuE[nccc] = 0;
00073     fMCFitNuEToNuE[nccc] = 0;
00074     fDataHistogram[nccc] = 0;
00075     fMCNoFitBackgroundHistogram[nccc] = 0;
00076     fMCResidualHistogram[nccc] = 0;
00077   }
00078 }

void NCBeam::MakeDataGraph (  )  [private]

Definition at line 827 of file NCBeam.cxx.

References fDataGraph, fDataHistogram, fEnergyBins, NCType::kCC, OscFit::kNC, MakeDataHistogram(), and MakeGraphFromHistogram().

Referenced by MakeResultPlots().

00828 {
00829   //MSG("NCBeam", Msg::kInfo) << "   NCBeam::MakeDataGraph()" << endl;
00830 
00831   for(int nccc = kNC; nccc <= kCC; ++nccc){
00832     if(fDataHistogram[nccc]->Integral() < 1.)
00833       MakeDataHistogram(fEnergyBins[nccc], fDataHistogram[nccc]);
00834 
00835     MakeGraphFromHistogram(fDataHistogram[nccc], fDataGraph[nccc]);
00836   }
00837 }

void NCBeam::MakeDataHistogram ( std::vector< NCEnergyBin * > &  energyBins,
TH1F *  data 
) [private]

Definition at line 749 of file NCBeam.cxx.

References fDetector, fNumEnergyBins, and Detector::kNear.

Referenced by MakeDataGraph().

00751 {
00752   //MSG("NCBeam", Msg::kInfo) << "   NCBeam::MakeDataHistogram()" << endl;
00753 
00754   //make a histogram to hold the data
00755   double totalEvents = 0.;
00756   TString yTitle = "Events/GeV";
00757 
00758   //for the near detector scale the events down by 1.e3 so the axis
00759   //label looks reasonable
00760   if(fDetector == (int)Detector::kNear){
00761     yTitle = "10^{3} Events/GeV";
00762   }
00763 
00764   //assume if the data histogram has some entries it is
00765   //already filled and just needs to be scaled
00766 
00767   //scale the size of the entries by the inverse of the
00768   //bin width in the graph making stage
00769   if(data->Integral() > 0.){
00770     data->SetYTitle(yTitle);
00771     return;
00772   }
00773 
00774   double binCenter = 0.;
00775   for(int i = 0; i < fNumEnergyBins; ++i){
00776     if(energyBins.size() > 0){
00777       binCenter = energyBins[i]->GetBinCentralValue();
00778       totalEvents = energyBins[i]->GetSignal();
00779 
00780       //BJR - 7/18/07 - dont divide by the bin width here.
00781       //that happens in MakeGraphFromHistogram()
00782 
00783       data->Fill(binCenter, (totalEvents));
00784       data->SetBinError(i+1,TMath::Sqrt(totalEvents));
00785     }
00786   }
00787 
00788   data->SetYTitle(yTitle);
00789 }

void NCBeam::MakeGraphFromHistogram ( TH1F *  hist,
TGraphAsymmErrors *  graph 
) const [private]

Convert a histogram into a graph with correct poisson errors.

Parameters:
hist Must be a histogram with fNumEnergyBins bins
graph Will be filled with the corresponding graph
Asymmetric poison errors are calculated correctly, not just $\sqrt n$

Quirk: If fDetector is ND then graph is scaled down by $10^3$

Definition at line 840 of file NCBeam.cxx.

References fDetector, fNumEnergyBins, Msg::kDebug, Detector::kNear, and MSG.

Referenced by MakeDataGraph().

00842 {
00843   //MSG("NCBeam", Msg::kInfo) << "   NCBeam::MakeGraphFromHistogram()" << endl;
00844 
00845   //make a histogram to hold the baseline monte carlo
00846   double normalization = 1.;
00847   TString yTitle = "Events/GeV";
00848 
00849   //for the near detector scale the events down by 1.e3 so the axis
00850   //label looks reasonable
00851   if(fDetector == Detector::kNear){
00852     normalization = 1.e3;
00853     yTitle = "10^{3} Events/GeV";
00854   }
00855 
00856   const double poissonErrorsUp[] = { 1.29,  2.75,  4.25,  5.30,  6.78,
00857                                      7.81,  9.28, 10.30, 11.32, 12.79,
00858                                      13.81, 14.82, 16.29, 17.30, 18.32,
00859                                      19.32, 20.80, 21.81, 22.82, 23.82};
00860   const double poissonErrorsDown[] = { 0.00,  0.37,  0.74,  1.10,  2.34,
00861                                        2.75,  3.82,  4.25,  5.30,  6.33,
00862                                        6.78,  7.81,  8.83,  9.28, 10.30,
00863                                        11.32, 12.33, 12.79, 13.81, 14.82};
00864 
00865   for(int i = 0; i < fNumEnergyBins; ++i){
00866     const double norm = normalization*hist->GetBinWidth(i+1);
00867     const double x = hist->GetBinCenter(i+1);
00868     double y = hist->GetBinContent(i+1);
00869 
00870     MSG("NCBeam", Msg::kDebug) << hist->GetName() << " "
00871                                << x << " " << y << endl;
00872 
00873     double errorYLow, errorYHigh;
00874 
00875     if(y < 1.){
00876       errorYLow = y - poissonErrorsDown[0];
00877       errorYHigh = poissonErrorsUp[0] - y;
00878     }
00879     else if(y < 19.){
00880       errorYLow = y - poissonErrorsDown[TMath::Nint(y)];
00881       errorYHigh = poissonErrorsUp[TMath::Nint(y)] - y;
00882     }
00883     else{
00884       errorYLow = TMath::Sqrt(y);
00885       errorYHigh = errorYLow;
00886     }
00887 
00888     y /= norm;
00889     errorYLow /= norm;
00890     errorYHigh /= norm;
00891 
00892     graph->SetPoint(i, x, y);
00893     graph->SetPointEYhigh(i, errorYHigh);
00894     graph->SetPointEYlow(i, errorYLow);
00895 
00896     MSG("NCBeam", Msg::kDebug) << y << " " << TMath::Nint(y)
00897                                << " " << poissonErrorsDown[TMath::Nint(y)]
00898                                << " " << poissonErrorsUp[TMath::Nint(y)]
00899                                << " " << errorYLow << " " << errorYHigh
00900                                << endl;
00901 
00902   }//end loop over energy bins
00903 
00904   graph->GetHistogram()->SetXTitle("E_{vis} (GeV)");
00905   graph->GetHistogram()->SetYTitle(yTitle);
00906   graph->GetHistogram()->GetXaxis()->CenterTitle();
00907   graph->GetHistogram()->GetYaxis()->CenterTitle();
00908 }

void NCBeam::MakeMCHistogram ( TH1F *  mc,
TH1F *  mcTrue,
TH1F *  noFitBg,
TH1F *  noFitNuMuToNuTau,
TH1F *  noFitNuMuToNuE,
TH1F *  noFitNuEToNuE,
TH1F *  fit,
TH1F *  fitBg,
TH1F *  fitNuMuToNuTau,
TH1F *  fitNuMuToNuE,
TH1F *  fitNuEToNuE 
) [private]

Definition at line 582 of file NCBeam.cxx.

References fDetector, Msg::kDebug, Detector::kNear, and MSG.

Referenced by MakeResultPlots().

00593 {
00594   //MSG("NCBeam", Msg::kInfo) << "   NCBeam::MakeMCHistogram()" << endl;
00595 
00596   //make a histogram to hold the baseline monte carlo
00597 
00598   double normalization = 1.;
00599   TString yTitle = "Events/ GeV";
00600   double width = 1.;
00601 
00602   //for the near detector scale the events down by 1.e3 so the axis
00603   //label looks reasonable
00604   if(fDetector == (int)Detector::kNear){
00605     normalization = 1.e3;
00606     yTitle = "10^{3} Events/GeV";
00607   }
00608 
00609   if(mc->Integral() > 0. || fit->Integral() > 0.){
00610 //     MSG("NCBeam", Msg::kInfo) << "nominal or fit histograms already filled"
00611 //                            << " do scaling" << endl;
00612     //assume if the mc histogram has some entries it is
00613     //already filled and just needs to be scaled
00614     if(mc->Integral() > 0.){
00615       mc->Scale(1./normalization);
00616       mcTrue->Scale(1./normalization);
00617       noFitBg->Scale(1./normalization);
00618 
00619       mc->SetYTitle(yTitle);
00620       mcTrue->SetYTitle(yTitle);
00621       noFitBg->SetYTitle(yTitle);
00622 
00623       //loop over the bins and divide each by the width
00624       //to put the scale in terms of events/GeV
00625       double events = 0.;
00626       for(int i = 0; i < mc->GetNbinsX(); ++i){
00627         events = mc->GetBinContent(i+1);
00628         width = mc->GetBinWidth(i+1);
00629         mc->SetBinContent(i+1, events/width);
00630 
00631         MSG("NCBeam", Msg::kDebug) << "mc histogram bin " << i+1 << "/" << mc->GetNbinsX()
00632                                    << " events " << events << " width " << width
00633                                    << " " << mc->GetBinContent(i+1) << endl;
00634       }
00635 
00636       for(int i = 0; i < mcTrue->GetNbinsX(); ++i){
00637         events = mcTrue->GetBinContent(i+1);
00638         width = mcTrue->GetBinWidth(i+1);
00639         mcTrue->SetBinContent(i+1, events/width);
00640 
00641         MSG("NCBeam", Msg::kDebug) << "mc true histogram bin " << i+1 << "/" << mcTrue->GetNbinsX()
00642                                    << " events " << events << " width " << width
00643                                    << " " << mcTrue->GetBinContent(i+1) << endl;
00644       }
00645 
00646       for(int i = 0; i < noFitBg->GetNbinsX(); ++i){
00647         events = noFitBg->GetBinContent(i+1);
00648         width = noFitBg->GetBinWidth(i+1);
00649         noFitBg->SetBinContent(i+1, events/width);
00650       }
00651 
00652       if(noFitNuMuToNuTau){
00653         noFitNuMuToNuTau->Scale(1./normalization);
00654         noFitNuMuToNuTau->SetYTitle(yTitle);
00655 
00656         for(int i = 0; i < noFitNuMuToNuTau->GetNbinsX(); ++i){
00657           events = noFitNuMuToNuTau->GetBinContent(i+1);
00658           width = noFitNuMuToNuTau->GetBinWidth(i+1);
00659           noFitNuMuToNuTau->SetBinContent(i+1, events/width);
00660         }
00661       }//end if no fit tau
00662 
00663       if(noFitNuMuToNuE){
00664         noFitNuMuToNuE->Scale(1./normalization);
00665         noFitNuMuToNuE->SetYTitle(yTitle);
00666 
00667         for(int i = 0; i < noFitNuMuToNuE->GetNbinsX(); ++i){
00668           events = noFitNuMuToNuE->GetBinContent(i+1);
00669           width = noFitNuMuToNuE->GetBinWidth(i+1);
00670           noFitNuMuToNuE->SetBinContent(i+1, events/width);
00671         }
00672       }//end if no fit electron
00673 
00674       if(noFitNuEToNuE){
00675         noFitNuEToNuE->Scale(1./normalization);
00676         noFitNuEToNuE->SetYTitle(yTitle);
00677 
00678         for(int i = 0; i < noFitNuEToNuE->GetNbinsX(); ++i){
00679           events = noFitNuEToNuE->GetBinContent(i+1);
00680           width = noFitNuEToNuE->GetBinWidth(i+1);
00681           noFitNuEToNuE->SetBinContent(i+1, events/width);
00682         }
00683       }//end if no fit electron
00684     }//end if mc->Integral > 0.
00685 
00686     //assume if the mc histogram has some entries it is
00687     //already filled and just needs to be scaled
00688     if(fit->Integral() > 0.){
00689       fit->Scale(1./normalization);
00690       fitBg->Scale(1./normalization);
00691 
00692       fit->SetYTitle(yTitle);
00693       fitBg->SetYTitle(yTitle);
00694 
00695       //loop over the bins and divide each by the width
00696       //to put the scale in terms of events/GeV
00697       double events = 0.;
00698       double width = 1.;
00699       for(int i = 0; i < fit->GetNbinsX(); ++i){
00700         events = fit->GetBinContent(i+1);
00701         width = fit->GetBinWidth(i+1);
00702         fit->SetBinContent(i+1, events/width);
00703       }
00704       for(int i = 0; i < fitBg->GetNbinsX(); ++i){
00705         events = fitBg->GetBinContent(i+1);
00706         width = fitBg->GetBinWidth(i+1);
00707         fitBg->SetBinContent(i+1, events/width);
00708       }
00709 
00710       if(fitNuMuToNuTau){
00711         fitNuMuToNuTau->Scale(1./normalization);
00712         fitNuMuToNuTau->SetYTitle(yTitle);
00713 
00714         for(int i = 0; i < fitNuMuToNuTau->GetNbinsX(); ++i){
00715           events = fitNuMuToNuTau->GetBinContent(i+1);
00716           width = fitNuMuToNuTau->GetBinWidth(i+1);
00717           fitNuMuToNuTau->SetBinContent(i+1, events/width);
00718         }
00719       }//end if fitNuMuToNuTau
00720 
00721       if(fitNuMuToNuE){
00722         fitNuMuToNuE->Scale(1./normalization);
00723         fitNuMuToNuE->SetYTitle(yTitle);
00724 
00725         for(int i = 0; i < fitNuMuToNuE->GetNbinsX(); ++i){
00726           events = fitNuMuToNuE->GetBinContent(i+1);
00727           width = fitNuMuToNuE->GetBinWidth(i+1);
00728           fitNuMuToNuE->SetBinContent(i+1, events/width);
00729         }
00730       }//end if fitNuMuToNuE
00731 
00732       if(fitNuEToNuE){
00733         fitNuEToNuE->Scale(1./normalization);
00734         fitNuEToNuE->SetYTitle(yTitle);
00735 
00736         for(int i = 0; i < fitNuEToNuE->GetNbinsX(); ++i){
00737           events = fitNuEToNuE->GetBinContent(i+1);
00738           width = fitNuEToNuE->GetBinWidth(i+1);
00739           fitNuEToNuE->SetBinContent(i+1, events/width);
00740         }
00741       }//end if no fit electron
00742 
00743     }//end if fit->Integral > 0.
00744 
00745   }//end if fit or nominal histograms have values
00746 }

void NCBeam::MakeResidualHistogram ( std::vector< NCEnergyBin * > &  energyBins,
TH1F *  fit,
TH1F *  data,
TH1F *  resid 
) [private]

Definition at line 792 of file NCBeam.cxx.

References err(), fDetector, fNumEnergyBins, and Detector::kNear.

Referenced by MakeResultPlots().

00796 {
00797   TString yTitle = "Residual/0.5 GeV";
00798 
00799   double mcFit = 0.;
00800   double d = 0.;
00801   double err = 1.;
00802 
00803   //for the near detector scale the events down by 1.e3 so the axis
00804   //label looks reasonable
00805   if(fDetector == (int)Detector::kNear){
00806     yTitle = "10^{3} Residual/0.5 GeV";
00807   }
00808 
00809   //assume if the mc histogram has some entries it is
00810   //already filled and just needs to be scaled
00811   if(resid->Integral() > 0.) return;
00812 
00813   for(int i = 0; i < fNumEnergyBins; ++i){
00814     err = 1.;
00815     if(energyBins.size() > 0){
00816       mcFit = fit->GetBinContent(i+1);
00817       d = data->GetBinContent(i+1);
00818       if(mcFit>0.) err = TMath::Sqrt(mcFit);
00819       resid->Fill(data->GetBinCenter(i+1),(d-mcFit)/err);
00820     }
00821   }
00822 
00823   resid->SetYTitle(yTitle);
00824 }

void NCBeam::MakeResultPlots (  ) 

Definition at line 554 of file NCBeam.cxx.

References fDataHistogram, fEnergyBins, fMCBackgroundHistogram, fMCFitHistogram, fMCFitNuEToNuE, fMCFitNuMuToNuE, fMCFitNuMuToNuTau, fMCHistogram, fMCNoFitBackgroundHistogram, fMCNoFitNuEToNuE, fMCNoFitNuMuToNuE, fMCNoFitNuMuToNuTau, fMCResidualHistogram, fMCTrueHistogram, NCType::kCC, OscFit::kNC, MakeDataGraph(), MakeMCHistogram(), and MakeResidualHistogram().

00555 {
00556 //   MSG("NCBeam", Msg::kInfo) << "NCBeam::MakeResultPlots() "
00557 //                          << " " << Detector::AsString(fDetector)
00558 //                          << " " << BeamType::AsString(fInfo.beamType)
00559 //                          << " " << fInfo.runType << endl;
00560 
00561   for(int nccc = kNC; nccc <= kCC; ++nccc){
00562     MakeMCHistogram(fMCHistogram[nccc],
00563                     fMCTrueHistogram[nccc],
00564                     fMCNoFitBackgroundHistogram[nccc],
00565                     fMCNoFitNuMuToNuTau[nccc],
00566                     fMCNoFitNuMuToNuE[nccc],
00567                     fMCNoFitNuEToNuE[nccc],
00568                     fMCFitHistogram[nccc],
00569                     fMCBackgroundHistogram[nccc],
00570                     fMCFitNuMuToNuTau[nccc],
00571                     fMCFitNuMuToNuE[nccc],
00572                     fMCFitNuEToNuE[nccc]);
00573 
00574     MakeResidualHistogram(fEnergyBins[nccc], fMCFitHistogram[nccc],
00575                           fDataHistogram[nccc], fMCResidualHistogram[nccc]);
00576   }
00577 
00578   MakeDataGraph();
00579 }

void NCBeam::MarkHistogramsFilled (  )  [inline]

Call this function to signal that you have manually filled the histograms and don't need FillResultHistograms to take any action.

Definition at line 201 of file NCBeam.h.

References fResultHistogramsFilled.

00202   {
00203     fResultHistogramsFilled = true;
00204   }

TH1F * NCBeam::NewVisEnergySpectrum ( TString  name,
int  colour,
int  fillcol = -1 
) const [private]

Helper function for Init.

If fillCol is passed then the plot is drawn with "///" hatching (3004)

Definition at line 1105 of file NCBeam.cxx.

References fEnergyBinBoundaries, and fNumEnergyBins.

Referenced by Init().

01106 {
01107   TH1F* ret = new TH1F(name, "", fNumEnergyBins, fEnergyBinBoundaries);
01108   ret->SetXTitle("E_{vis} (GeV)");
01109   ret->SetYTitle("Events/GeV");
01110   ret->GetXaxis()->CenterTitle();
01111   ret->GetYaxis()->CenterTitle();
01112   ret->SetLineColor(col);
01113 
01114   if(fillcol >= 0){
01115     ret->SetFillColor(fillcol);
01116     ret->SetFillStyle(3004);
01117   }
01118 
01119   return ret;
01120 }

NCBeam& NCBeam::operator= ( const NCBeam  )  [private]

Don't make any provisions for doing this, so don't let anyone.

void NCBeam::Reset ( bool  data,
bool  mc 
)

Definition at line 1001 of file NCBeam.cxx.

References fDataGraph, fDataHistogram, fDefaultMCHistogram, fEnergyBins, fMCBackgroundHistogram, fMCFitHistogram, fMCFitNuEToNuE, fMCFitNuMuToNuE, fMCFitNuMuToNuTau, fMCHistogram, fMCNoFitBackgroundHistogram, fMCNoFitNuEToNuE, fMCNoFitNuMuToNuE, fMCNoFitNuMuToNuTau, fMCResidualHistogram, fMCTrueHistogram, NCType::kCC, and OscFit::kNC.

01002 {
01003   for(int nccc = kNC; nccc <= kCC; ++nccc){
01004     if(data){
01005       fDataHistogram[nccc]->Reset("ICE");
01006       delete fDataGraph[nccc];
01007       fDataGraph[nccc] = new TGraphAsymmErrors;
01008     }
01009     if(mc){
01010       fDefaultMCHistogram[nccc]->Reset("ICE");
01011       fMCHistogram[nccc]->Reset("ICE");
01012       fMCTrueHistogram[nccc]->Reset("ICE");
01013       fMCFitHistogram[nccc]->Reset("ICE");
01014       fMCResidualHistogram[nccc]->Reset("ICE");
01015       fMCBackgroundHistogram[nccc]->Reset("ICE");
01016       fMCNoFitNuMuToNuTau[nccc]->Reset("ICE");
01017       fMCFitNuMuToNuTau[nccc]->Reset("ICE");
01018       fMCNoFitNuMuToNuE[nccc]->Reset("ICE");
01019       fMCFitNuMuToNuE[nccc]->Reset("ICE");
01020       fMCNoFitNuEToNuE[nccc]->Reset("ICE");
01021       fMCFitNuEToNuE[nccc]->Reset("ICE");
01022       fMCNoFitBackgroundHistogram[nccc]->Reset("ICE");
01023     }
01024 
01025     for(unsigned int n = 0; n < fEnergyBins[nccc].size(); ++n)
01026       fEnergyBins[nccc][n]->Reset(data, mc);
01027   }
01028 }

void NCBeam::SetRunType ( NC::RunUtil::ERunType  runType  ) 

Definition at line 458 of file NCBeam.cxx.

References fInfo, and NCBeam::Info::runType.

00459 {
00460   fInfo.runType = runType;
00461 }

void NCBeam::WritePredictionResources (  ) 

Definition at line 1044 of file NCBeam.cxx.

References fDefaultMCHistogram, fMCBackgroundHistogram, fMCFitHistogram, fMCFitNuEToNuE, fMCFitNuMuToNuE, fMCFitNuMuToNuTau, fMCHistogram, fMCNoFitBackgroundHistogram, fMCNoFitNuEToNuE, fMCNoFitNuMuToNuE, fMCNoFitNuMuToNuTau, fMCResidualHistogram, fMCTrueHistogram, NCType::kCC, and OscFit::kNC.

Referenced by WriteResources().

01045 {
01046   for(int nccc = kNC; nccc <= kCC; ++nccc){
01047     fMCHistogram[nccc]->Write();
01048     fMCTrueHistogram[nccc]->Write();
01049     fDefaultMCHistogram[nccc]->Write();
01050     fMCFitHistogram[nccc]->Write();
01051     fMCResidualHistogram[nccc]->Write();
01052     fMCBackgroundHistogram[nccc]->Write();
01053     fMCNoFitNuMuToNuTau[nccc]->Write();
01054     fMCFitNuMuToNuTau[nccc]->Write();
01055     fMCNoFitNuMuToNuE[nccc]->Write();
01056     fMCFitNuMuToNuE[nccc]->Write();
01057     fMCNoFitNuEToNuE[nccc]->Write();
01058     fMCFitNuEToNuE[nccc]->Write();
01059     fMCNoFitBackgroundHistogram[nccc]->Write();
01060   }
01061 }

void NCBeam::WriteResources (  ) 

Definition at line 1032 of file NCBeam.cxx.

References fDataGraph, fDataHistogram, NCType::kCC, OscFit::kNC, and WritePredictionResources().

01033 {
01034   WritePredictionResources();
01035 
01036   for(int nccc = kNC; nccc <= kCC; ++nccc){
01037     fDataHistogram[nccc]->Write();
01038     fDataGraph[nccc]->Write();
01039   }
01040 }


Member Data Documentation

TGraphAsymmErrors* NCBeam::fDataGraph[2] [private]

Definition at line 278 of file NCBeam.h.

Referenced by GetDataGraph(), Init(), InitNulls(), MakeDataGraph(), Reset(), WriteResources(), and ~NCBeam().

TH1F* NCBeam::fDataHistogram[2] [private]

Definition at line 276 of file NCBeam.h.

Referenced by GetDataHistogram(), Init(), InitNulls(), MakeDataGraph(), MakeResultPlots(), Reset(), WriteResources(), and ~NCBeam().

TH1F* NCBeam::fDefaultMCHistogram[2] [private]

Every MC event given to us that is selected NC/CC and is truly $\nu_\mu$.

Definition at line 264 of file NCBeam.h.

Referenced by AddEvent(), GetDefaultMCHistogram(), Init(), InitNulls(), Reset(), WritePredictionResources(), and ~NCBeam().

Detector::Detector_t NCBeam::fDetector [private]

Definition at line 251 of file NCBeam.h.

Referenced by AddEvent(), GetDetector(), Init(), MakeDataHistogram(), MakeGraphFromHistogram(), MakeMCHistogram(), and MakeResidualHistogram().

double NCBeam::fEnergyBinBoundaries[201] [private]

Definition at line 254 of file NCBeam.h.

Referenced by FindEnergyBin(), GetEnergyBinBoundaries(), Init(), and NewVisEnergySpectrum().

std::vector<NCEnergyBin*> NCBeam::fEnergyBins[2] [private]

Definition at line 280 of file NCBeam.h.

Referenced by AddEvent(), GetEnergyBin(), GetNumberEnergyBins(), Init(), MakeDataGraph(), MakeResultPlots(), Reset(), and ~NCBeam().

bool NCBeam::fFillBins [private]

NCEnergyBin vectors take up a lot of space, sometimes want to suppress them

Definition at line 258 of file NCBeam.h.

Referenced by AddEvent().

Info NCBeam::fInfo [private]

Definition at line 249 of file NCBeam.h.

Referenced by AddEvent(), GetBeamType(), GetInfo(), GetRunType(), and SetRunType().

TH1F* NCBeam::fMCBackgroundHistogram[2] [private]

Definition at line 269 of file NCBeam.h.

Referenced by GetMCBackgroundHistogram(), Init(), InitNulls(), MakeResultPlots(), Reset(), WritePredictionResources(), and ~NCBeam().

TH1F* NCBeam::fMCFitHistogram[2] [private]

Definition at line 267 of file NCBeam.h.

Referenced by GetMCFitHistogram(), Init(), InitNulls(), MakeResultPlots(), Reset(), WritePredictionResources(), and ~NCBeam().

TH1F* NCBeam::fMCFitNuEToNuE[2] [private]

Definition at line 275 of file NCBeam.h.

Referenced by GetMCFitNuEToNuEHistogram(), Init(), InitNulls(), MakeResultPlots(), Reset(), WritePredictionResources(), and ~NCBeam().

TH1F* NCBeam::fMCFitNuMuToNuE[2] [private]

Definition at line 273 of file NCBeam.h.

Referenced by GetMCFitNuMuToNuEHistogram(), Init(), InitNulls(), MakeResultPlots(), Reset(), WritePredictionResources(), and ~NCBeam().

TH1F* NCBeam::fMCFitNuMuToNuTau[2] [private]

Definition at line 271 of file NCBeam.h.

Referenced by GetMCFitNuMuToNuTauHistogram(), Init(), InitNulls(), MakeResultPlots(), Reset(), WritePredictionResources(), and ~NCBeam().

TH1F* NCBeam::fMCHistogram[2] [private]

Definition at line 265 of file NCBeam.h.

Referenced by GetMCHistogram(), Init(), InitNulls(), MakeResultPlots(), Reset(), WritePredictionResources(), and ~NCBeam().

TH1F* NCBeam::fMCNoFitBackgroundHistogram[2] [private]

Definition at line 277 of file NCBeam.h.

Referenced by GetMCNoFitBackgroundHistogram(), Init(), InitNulls(), MakeResultPlots(), Reset(), WritePredictionResources(), and ~NCBeam().

TH1F* NCBeam::fMCNoFitNuEToNuE[2] [private]

Definition at line 274 of file NCBeam.h.

Referenced by GetMCNoFitNuEToNuEHistogram(), Init(), InitNulls(), MakeResultPlots(), Reset(), WritePredictionResources(), and ~NCBeam().

TH1F* NCBeam::fMCNoFitNuMuToNuE[2] [private]

Definition at line 272 of file NCBeam.h.

Referenced by GetMCNoFitNuMuToNuEHistogram(), Init(), InitNulls(), MakeResultPlots(), Reset(), WritePredictionResources(), and ~NCBeam().

TH1F* NCBeam::fMCNoFitNuMuToNuTau[2] [private]

Definition at line 270 of file NCBeam.h.

Referenced by GetMCNoFitNuMuToNuTauHistogram(), Init(), InitNulls(), MakeResultPlots(), Reset(), WritePredictionResources(), and ~NCBeam().

TH1F* NCBeam::fMCResidualHistogram[2] [private]

Definition at line 268 of file NCBeam.h.

Referenced by GetMCResidualHistogram(), Init(), InitNulls(), MakeResultPlots(), Reset(), WritePredictionResources(), and ~NCBeam().

TH1F* NCBeam::fMCTrueHistogram[2] [private]

Definition at line 266 of file NCBeam.h.

Referenced by GetMCTrueHistogram(), Init(), InitNulls(), MakeResultPlots(), Reset(), WritePredictionResources(), and ~NCBeam().

int NCBeam::fNumEnergyBins [private]

Definition at line 253 of file NCBeam.h.

Referenced by FindEnergyBin(), GetEnergyBinBoundaries(), Init(), MakeDataHistogram(), MakeGraphFromHistogram(), MakeResidualHistogram(), and NewVisEnergySpectrum().

bool NCBeam::fResultHistogramsFilled [private]

Guard variable for FillResultHistograms.

Definition at line 261 of file NCBeam.h.

Referenced by FillResultHistograms(), Init(), and MarkHistogramsFilled().

bool NCBeam::fUseCC [private]

Definition at line 255 of file NCBeam.h.

Referenced by AddEvent(), FillResultHistograms(), and Init().

bool NCBeam::fUseNC [private]

Definition at line 256 of file NCBeam.h.

Referenced by AddEvent(), FillResultHistograms(), and Init().


The documentation for this class was generated from the following files:
Generated on Mon Sep 1 00:51:59 2014 for loon by  doxygen 1.4.7