NCExtrapolationPID Class Reference

Extrapolation binning events by PID value. More...

#include <NCExtrapolationPID.h>

Inheritance diagram for NCExtrapolationPID:
NCExtrapolation

List of all members.

Public Types

typedef std::map< NCBeam::Info,
PIDSpectrum * > 
SpecMap

Public Member Functions

 NCExtrapolationPID ()
virtual ~NCExtrapolationPID ()
virtual void FindSpectraForPars (const NC::OscProb::OscPars *oscPars, const NC::SystPars &systPars, std::vector< NCBeam::Info > beamsToUse, std::vector< TH1 * > &exps, std::vector< TH1 * > &obss)
 Override this in the derived class.
virtual std::vector< const TH1 * > GetNearMCSpectra (std::vector< NCBeam::Info > beamsToUse)
virtual void CleanupSpectra (std::vector< TH1 * > exps, std::vector< TH1 * > obss)
 Called after FindSpectraForPars() to delete necessary spectra.
virtual void AddEvent (NCEventInfo eventInfo, bool useMCAsData, NCType::EFileType fileType, NCBeam::Info beamInfo)
void DoneFilling ()
virtual void WriteResources (const NC::OscProb::OscPars *trueOscPars)
virtual TString GetShortName () const
 This is the name used to name things in the output file etc.
virtual TString GetLongName () const
 This is the name the extrapolation is known under on plots and such.
virtual void Prepare (const Registry &r)
virtual void Reset (bool nearData, bool farData, bool nearMC, bool farMC)
 Causes the extrapolation to forget everything it knows about the requested spectra.
virtual bool EnableNearToFarExtrapolation (bool enable)
 Enable or disable corrections to FD spectra based on ND spectra.

Static Public Member Functions

static const RegistryDefaultConfig ()
 Return a default config that will be merged with the NCExtrapolationModule DefaultConfig.

Protected Member Functions

std::vector< TH1 * > GetExpHists (std::vector< NCBeam::Info > beamsToUse, const NC::OscProb::OscPars *coords, std::vector< TH1 * > ndSpectra=std::vector< TH1 * >()) const
 Get the expected histograms in the format required for NCUtils' log likelihood method.
std::vector< TH1 * > GetObsHists (std::vector< NCBeam::Info > beamsToUse) const
 Get the observed histograms in the format required for NCUtils' log likelihood method.
void WriteSpectra (const NC::OscProb::OscPars *coords, const NC::SystPars &s, std::string suffix="")
 Write the spectra, evaluated at the parameters coords, prettily to gDirectory.
void DoneFillingOneBeam (NCBeam::Info beamInfo)
void WriteMCSpectra (const char *filename)
 Save the unoscillated MC spectra to filename so they can be.
void ReadMCSpectra (const char *filename)
 Read the MC spectra from filename, replacing the existing spectra.

Protected Attributes

SpecMap fSpectra
 The 2D spectra, indexed by beam.
bool fUseCCEnergy
bool fUseSelectionEnergy
int fTrueBinFactor
 How much finer to make the true energy binning than the reco.
int fNumPIDBins
 How many bins in PID to use.
double fPIDmin
 The minimum value of PID to use.
double fPIDmax
 The maximum value of PID to use.
std::string fMCInFilename
 The filename to read the MC spectra from.
std::string fMCOutFilename
 The filename to write the MC spectra to.
bool fDoFarNearCorrection
 Whether to do the far/near correction.
bool fEmulateFarNear
 Whether to emulate the Far/Near method by having just two bins.
bool fDrawFDData
 Whether to instruct PIDSpectrum to draw FD data on plots (for blinding).

Private Member Functions

void PrintMap (POTMap &m, const char *name)
 Print out a POT map for debugging purposes.
void PrintSpectraMap ()
void CopyBinContents (TH1D *hFrom, TH1F *hTo) const
 Copy the bin contents of hFrom into hTo. Used by WriteResources.

Detailed Description

Extrapolation binning events by PID value.

Definition at line 23 of file NCExtrapolationPID.h.


Member Typedef Documentation

Definition at line 27 of file NCExtrapolationPID.h.


Constructor & Destructor Documentation

NCExtrapolationPID::NCExtrapolationPID (  ) 

Definition at line 34 of file NCExtrapolationPID.cxx.

00035 :  fUseCCEnergy(true), fUseSelectionEnergy(true), fTrueBinFactor(5), fNumPIDBins(20),
00036   fPIDmin(0.2), fPIDmax(1.1),
00037   fMCInFilename(""), fMCOutFilename(""),
00038   fDoFarNearCorrection(true), fEmulateFarNear(false),
00039   fDrawFDData(true)
00040 {
00041 }

NCExtrapolationPID::~NCExtrapolationPID (  )  [virtual]

Definition at line 45 of file NCExtrapolationPID.cxx.

References fSpectra, and it.

00046 {
00047   for (SpecMap::iterator it=fSpectra.begin(); it!=fSpectra.end(); ++it)
00048     delete it->second;
00049 }


Member Function Documentation

void NCExtrapolationPID::AddEvent ( NCEventInfo  eventInfo,
bool  useMCAsData,
NCType::EFileType  fileType,
NCBeam::Info  beamInfo 
) [virtual]

Reimplemented from NCExtrapolation.

Definition at line 54 of file NCExtrapolationPID.cxx.

References NCEventInfo::analysis, ANtpHeaderInfo::dataType, det, ANtpHeaderInfo::detector, fDrawFDData, fEmulateFarNear, NCExtrapolation::fEnergyThreshold, fMCInFilename, fNumPIDBins, fPIDmax, fPIDmin, fSpectra, fTrueBinFactor, NCExtrapolation::fUseCC, fUseCCEnergy, NCExtrapolation::fUseNC, fUseSelectionEnergy, NCBeam::Info::GetDescription(), NCEventInfo::header, ANtpRecoInfo::inFiducialVolume, ANtpAnalysisInfo::isCC, ANtpAnalysisInfo::isNC, ANtpRecoInfo::isSimpleCutsClean, SimFlag::kData, SimFlag::kMC, Detector::kNear, ANtpRecoInfo::nuEnergy, ANtpRecoInfo::nuEnergyCC, ANtpRecoInfo::nuEnergyNC, NCEventInfo::reco, ANtpAnalysisInfo::separationParameterCut, NCEventInfo::truth, and ANtpRecoInfo::weight.

00058 {
00059   // This call fills the NCBeam objects with the event. We don't need it
00060   // for the fit, but it does make some pretty plots at the end.
00061   NCExtrapolation::AddEvent(info, useMCAsData, fileType, beamInfo);
00062 
00063   // Some events don't get into the NC or the CC spectrum - exclude
00064   // them if we're emulating the FarNear method
00065   if (fEmulateFarNear &&
00066       !(info.analysis->isNC || info.analysis->isCC)) return;
00067 
00068   // Add the necessary spectrum for this beam if it's not already there
00069   if (fSpectra.find(beamInfo)==fSpectra.end()) {
00070     // If this happened when we got our MC spectra from disk,
00071     // something is probably wrong
00072     assert(fMCInFilename=="");
00073 
00074     string name = string("PID_") + beamInfo.GetDescription().Data();
00075     fSpectra[beamInfo]=new PIDSpectrum(name, "title",
00076                                        fNumPIDBins, fPIDmin, fPIDmax, // PID bins
00077                                        // fNumPIDBins will be -1 if emulating FarNear
00078                                        fTrueBinFactor, beamInfo,
00079                                        info.analysis->separationParameterCut,
00080                                        fDrawFDData);
00081   }
00082 
00083   // If we loaded the spectra from file, we don't need to add any MC
00084   // events.  But add fake data events in the far detector - this
00085   // isn't the main use case, but it is useful for testing
00086   if (fMCInFilename!="" &&
00087       (info.header->detector==Detector::kNear ||
00088        (info.header->dataType==SimFlag::kMC && !useMCAsData))) return;
00089 
00090   if(!fUseNC && info.analysis->isNC) return;
00091   if(!fUseCC && info.analysis->isCC) return;
00092 
00093   if (!info.reco->inFiducialVolume) return;
00094 
00095   Detector::Detector_t det=Detector::Detector_t(info.header->detector);
00096   if (det==Detector::kNear && !info.reco->isSimpleCutsClean) return;
00097 
00098   double energy;
00099   if (fUseSelectionEnergy) {
00100     energy=info.reco->nuEnergy;
00101   } else {
00102     energy=fUseCCEnergy ? info.reco->nuEnergyCC : info.reco->nuEnergyNC;
00103   }
00104 
00105   // Don't use events with energy<0: this happens for NC energy for
00106   // events with no shower. Also obey energy threshold option.
00107   if (energy<0 || energy<fEnergyThreshold) return;
00108 
00109   if (info.header->dataType==SimFlag::kData || useMCAsData) {
00110     // For fake data, reco->weight contains all the scaling we need (including POT)
00111     fSpectra[beamInfo]->FillData(det,
00112                                 info.truth, info.reco, info.analysis, energy,
00113                                 info.reco->weight);
00114   } else {
00115     fSpectra[beamInfo]->FillMC(det,
00116                               info.truth, info.reco, info.analysis, energy,
00117                               info.reco->weight);
00118   }
00119 
00120 }

virtual void NCExtrapolationPID::CleanupSpectra ( std::vector< TH1 * >  exps,
std::vector< TH1 * >  obss 
) [virtual]

Called after FindSpectraForPars() to delete necessary spectra.

Parameters:
exps The expected spectra just returned from FindSpectraForPars()
obss The observed spectra just returned from FindSpectraForPars()

Reimplemented from NCExtrapolation.

void NCExtrapolationPID::CopyBinContents ( TH1D *  hFrom,
TH1F *  hTo 
) const [private]

Copy the bin contents of hFrom into hTo. Used by WriteResources.

Definition at line 649 of file NCExtrapolationPID.cxx.

References kNumEnergyBinsFar.

00650 {
00651   for(int i = 0; i < kNumEnergyBinsFar; ++i)
00652     hTo->SetBinContent(i+1, hFrom->GetBinContent(i+1));
00653 }

const Registry & NCExtrapolationPID::DefaultConfig ( void   )  [static]

Return a default config that will be merged with the NCExtrapolationModule DefaultConfig.

Reimplemented from NCExtrapolation.

Definition at line 484 of file NCExtrapolationPID.cxx.

References Registry::LockValues(), Registry::Set(), and Registry::UnLockValues().

Referenced by Prepare().

00485 {
00486   static Registry r;
00487 
00488   r.UnLockValues();
00489 
00490   // Energy measure to use. Can be "CC", "NC" or "Selection" (which
00491   // uses NC or CC based on the event type given by the selection)
00492   r.Set("PIDFitEnergyType",   "CC");
00493 
00494   // Number of bins in PID to use
00495   r.Set("PIDFitPIDNbins",          20);
00496   // Minimum, maximum value of PID
00497   r.Set("PIDFitPIDmin",          0.2);
00498   r.Set("PIDFitPIDmax",          1.1);
00499 
00500   // How much finer to make the true energy binning than the reco
00501   // energy binning in the PIDSpectrum objects
00502   r.Set("PIDFitTrueBinFactor",   5);
00503 
00504   // The file to read the MC spectra from/write them to
00505   r.Set("PIDFitWriteMCToFile", "");
00506   r.Set("PIDFitReadMCFromFile", "");
00507 
00508   // Whether to do the far/near correction
00509   r.Set("PIDFitDoFarNearCorrection", true);
00510 
00511   // Emulate the FarNear method - overrides the number of bins setting
00512   // and the energy type if set to true
00513   r.Set("PIDFitEmulateFarNear", false);
00514   
00515   // Draw FD data on plots
00516   r.Set("PIDFitDrawFDData", true);
00517 
00518   r.LockValues();
00519   return r;
00520 
00521 }

void NCExtrapolationPID::DoneFilling (  )  [virtual]

Call this when done with filling the MC and data: normalizes the true-to-reco maps, along with anything else that needs doing. This calls DoneFillingOneBeam() for each beam

Reimplemented from NCExtrapolation.

Definition at line 459 of file NCExtrapolationPID.cxx.

References DoneFillingOneBeam(), fMCInFilename, and fSpectra.

00460 {
00461   cout << "NCExtrapolationPID::DoneFilling()" << endl;
00462   // Only need to do this if we didn't load the spectra from file
00463   if(fMCInFilename == ""){
00464     for (SpecMap::iterator sit=fSpectra.begin(); sit!=fSpectra.end(); ++sit) {
00465       DoneFillingOneBeam(sit->first);
00466     }
00467   }
00468 }

void NCExtrapolationPID::DoneFillingOneBeam ( NCBeam::Info  beamInfo  )  [protected]
See also:
DoneFilling()

Definition at line 472 of file NCExtrapolationPID.cxx.

References fSpectra, and NCBeam::Info::GetDescription().

Referenced by DoneFilling().

00473 {
00474   cout << "NCExtrapolationPID::DoneFillingOneBeam("
00475        << beamInfo.GetDescription() << ")" << endl;
00476 
00477   cout << "Normalizing true-to-recos" << endl;
00478   fSpectra[beamInfo]->NormalizeTrueToRecos();
00479 
00480 }

bool NCExtrapolationPID::EnableNearToFarExtrapolation ( bool  enable  )  [virtual]

Enable or disable corrections to FD spectra based on ND spectra.

Parameters:
enable true to perform extrapolation. false to give produce unextrapolated spectra
Returns:
The previous value of this setting

The default value of this setting should be to true

Reimplemented from NCExtrapolation.

Definition at line 599 of file NCExtrapolationPID.cxx.

References fDoFarNearCorrection.

00600 {
00601   const bool ret = fDoFarNearCorrection;
00602   fDoFarNearCorrection = enable;
00603   return ret;
00604 }

virtual void NCExtrapolationPID::FindSpectraForPars ( const NC::OscProb::OscPars oscPars,
const NC::SystPars systPars,
std::vector< NCBeam::Info beamsToUse,
std::vector< TH1 * > &  exps,
std::vector< TH1 * > &  obss 
) [virtual]

Override this in the derived class.

Parameters:
oscPars Oscillation parameters
systPars Systematic shifts
beamsToUse Only fill exps and obss with spectra from beams with these indices
[out] exps To be filled with expected spectra
[out] obss To be filled with the corresponding observed spectra

Implements NCExtrapolation.

std::vector<TH1*> NCExtrapolationPID::GetExpHists ( std::vector< NCBeam::Info beamsToUse,
const NC::OscProb::OscPars coords,
std::vector< TH1 * >  ndSpectra = std::vector< TH1 * >() 
) const [protected]

Get the expected histograms in the format required for NCUtils' log likelihood method.

virtual TString NCExtrapolationPID::GetLongName (  )  const [inline, virtual]

This is the name the extrapolation is known under on plots and such.

Implements NCExtrapolation.

Definition at line 60 of file NCExtrapolationPID.h.

00060 { return "2d PID fit"; }

virtual std::vector<const TH1*> NCExtrapolationPID::GetNearMCSpectra ( std::vector< NCBeam::Info beamsToUse  )  [virtual]

Reimplemented from NCExtrapolation.

std::vector<TH1*> NCExtrapolationPID::GetObsHists ( std::vector< NCBeam::Info beamsToUse  )  const [protected]

Get the observed histograms in the format required for NCUtils' log likelihood method.

virtual TString NCExtrapolationPID::GetShortName (  )  const [inline, virtual]

This is the name used to name things in the output file etc.

Implements NCExtrapolation.

Definition at line 59 of file NCExtrapolationPID.h.

00059 { return "PID"; }

void NCExtrapolationPID::Prepare ( const Registry r  )  [virtual]

Read whatever values you need out of the registry to initialize yourself. Please remember to chain up to the NCExtrapolation implementation too.

Reimplemented from NCExtrapolation.

Definition at line 525 of file NCExtrapolationPID.cxx.

References DefaultConfig(), fDoFarNearCorrection, fDrawFDData, fEmulateFarNear, fMCInFilename, fMCOutFilename, fNumPIDBins, fPIDmax, fPIDmin, fSpectra, fTrueBinFactor, fUseCCEnergy, fUseSelectionEnergy, Registry::Get(), Registry::GetInt(), and ReadMCSpectra().

00526 {
00527   NCExtrapolation::Prepare(r);
00528 
00529   cout << "NCExtrapolationPID::Prepare" << endl;
00530   const char* tmps;
00531   int tmpi;
00532   double tmpd;
00533 
00534   if (r.Get("PIDFitEnergyType", tmps)) {
00535     string energyType(tmps);
00536     assert(energyType=="NC" || energyType=="CC" || energyType=="Selection");
00537     fUseSelectionEnergy = (energyType=="Selection");
00538     fUseCCEnergy = (energyType=="CC");
00539   }
00540 
00541   if (r.Get("PIDFitPIDNbins", tmpi)) fNumPIDBins=tmpi;
00542 
00543   if (r.Get("PIDFitDrawFDData", tmpi)) fDrawFDData=tmpi;
00544 
00545   // Minimum, maximum value of PID
00546   if (r.Get("PIDFitPIDmin", tmpd)) fPIDmin=tmpd;
00547   if (r.Get("PIDFitPIDmax", tmpd)) fPIDmax=tmpd;
00548 
00549   cout << "fNumPIDBins=" << fNumPIDBins
00550        << " PID range=[" << fPIDmin << ", " << fPIDmax << "]" << endl;
00551 
00552   if (r.Get("PIDFitTrueBinFactor", tmpi))       fTrueBinFactor=tmpi;
00553   if (r.Get("PIDFitDoFarNearCorrection", tmpi)) fDoFarNearCorrection=tmpi;
00554 
00555   if (r.Get("PIDFitEmulateFarNear", tmpi)) fEmulateFarNear=tmpi;
00556 
00557   if (fEmulateFarNear) {
00558     // If we're emulating the FarNear method, we just have two PID
00559     // bins, but we use fNumPIDBins=-1 to signal to PIDSpectrum that it
00560     // should put the separation point where the cut value is
00561     fNumPIDBins=-1;
00562     fUseSelectionEnergy=true;
00563 
00564     if (r.Get("PIDFitPIDNbins", tmpi) &&
00565         tmpi!=DefaultConfig().GetInt("PIDFitPIDNbins"))
00566       cout << "WARNING: PIDFitPIDNbins was set, but overridden by PIDFitEmulateFarNear"
00567            << endl;
00568   }
00569 
00570   // Files to read the MC spectra from/write them to
00571   if (r.Get("PIDFitReadMCFromFile", tmps)) fMCInFilename=tmps;
00572   if (r.Get("PIDFitWriteMCToFile", tmps))  fMCOutFilename=tmps;
00573 
00574   if (fMCInFilename!="") {
00575     ReadMCSpectra(fMCInFilename.c_str());
00576     // reset the observed spectra - if we got the PIDSpectrum's from file, we'll be
00577     // filling them with mock data presumably anyway
00578     for (SpecMap::iterator sit=fSpectra.begin(); sit!=fSpectra.end(); ++sit) {
00579       TH2F* h=sit->second->GetDataHist();
00580       h->Reset();
00581     }
00582   }
00583 
00584 }

void NCExtrapolationPID::PrintMap ( POTMap m,
const char *  name 
) [private]

Print out a POT map for debugging purposes.

Definition at line 310 of file NCExtrapolationPID.cxx.

References it.

00311 {
00312   cout << "Map " << name << endl;
00313   for (POTMap::const_iterator it=m.begin();
00314        it!=m.end(); ++it) {
00315     cout << it->first.GetDescription() << "\t" << it->second << endl;
00316   }
00317 }

void NCExtrapolationPID::PrintSpectraMap (  )  [private]

Definition at line 321 of file NCExtrapolationPID.cxx.

References fSpectra, and it.

00322 {
00323   cout << "fSpectra:" << endl;
00324   for (SpecMap::const_iterator it=fSpectra.begin();
00325        it!=fSpectra.end(); ++it) {
00326     cout << it->first.GetDescription() << "\t" << hex << it->second << dec
00327          << "\t" << it->second->GetBeamInfo().GetTitle() << endl;
00328   }
00329 }

void NCExtrapolationPID::ReadMCSpectra ( const char *  filename  )  [protected]

Read the MC spectra from filename, replacing the existing spectra.

Definition at line 618 of file NCExtrapolationPID.cxx.

References exit(), fEmulateFarNear, fNumPIDBins, fSpectra, PIDSpectrum::GetBeamInfo(), PIDSpectrum::GetNPIDBins(), and it.

Referenced by Prepare().

00619 {
00620 
00621   cout << "Reading MC spectra from file " << filename << endl;
00622   TFile f(filename);
00623 
00624   TList *l = f.GetListOfKeys();
00625   TIter it(l);
00626   TObject *obj;
00627   TKey* k;
00628   while (( k=(TKey*)it() )) {
00629     obj=f.Get(k->GetName());
00630     cout << "Trying object " << obj->GetName() << endl;
00631     if (! (obj->IsA() == PIDSpectrum::Class()) ) {
00632       cerr << "Object with name " << obj->GetName() << " not a PIDSpectrum. Bailing" << endl;
00633       exit(1);
00634     }
00635     cout << "...object is a PIDSpectrum. Adding to list" << endl;
00636     PIDSpectrum* p=(PIDSpectrum*)obj;
00637 
00638     // fNumPIDBins is mangled when using fEmulateFarNear, so need this branch
00639     if (fEmulateFarNear) assert(p->GetNPIDBins()==2);
00640     else                 assert(p->GetNPIDBins()==fNumPIDBins);
00641 
00642     fSpectra[p->GetBeamInfo()]=p;
00643   }
00644 
00645 }

void NCExtrapolationPID::Reset ( bool  nearData,
bool  farData,
bool  nearMC,
bool  farMC 
) [virtual]

Causes the extrapolation to forget everything it knows about the requested spectra.

This implementation clears the relevant NCBeam objects

Derived classes please override if you handle spectra yourself

Reimplemented from NCExtrapolation.

Definition at line 587 of file NCExtrapolationPID.cxx.

References fSpectra.

00589 {
00590   for (SpecMap::iterator sit=fSpectra.begin(); sit!=fSpectra.end(); ++sit) {
00591     if(nearData) sit->second->ResetNearData();
00592     if(farData) sit->second->ResetData();
00593     if(nearMC) sit->second->ResetNearMC();
00594     if(farMC) sit->second->ResetMC();
00595   }
00596 }

void NCExtrapolationPID::WriteMCSpectra ( const char *  filename  )  [protected]

Save the unoscillated MC spectra to filename so they can be.

Definition at line 608 of file NCExtrapolationPID.cxx.

References fSpectra.

Referenced by WriteResources().

00609 {
00610   TFile f(filename, "RECREATE");
00611   for (SpecMap::iterator sit=fSpectra.begin(); sit!=fSpectra.end(); ++sit) {
00612     sit->second->Write();
00613   }
00614 }

void NCExtrapolationPID::WriteResources ( const NC::OscProb::OscPars trueOscPars  )  [virtual]

gDirectory will point to the output file. Please remember to chain up to the NCExtrapolation implementation.

trueOscPars may be zero (eg obviously in case of fit to real data)

Reimplemented from NCExtrapolation.

Definition at line 208 of file NCExtrapolationPID.cxx.

References COPYBINS, det, NCExtrapolation::fBeams, fMCOutFilename, fSpectra, NCExtrapolation::GetBestFitOscPars(), NCExtrapolation::GetBestFitSysts(), it, PIDSpectrum::kAll, PIDSpectrum::kBeamNue, NCType::kCC, Detector::kFar, NCType::kNC, PIDSpectrum::kNumu, PIDSpectrum::kNutau, PIDSpectrum::kOscNue, NCBeam::MarkHistogramsFilled(), WriteMCSpectra(), and WriteSpectra().

00209 {
00210 
00211   NC::OscProb::OscPars* bestFit=GetBestFitOscPars();
00212   NC::OscProb::OscPars* oscParsNoOsc = new NC::OscProb::NoOscillations;
00213 
00214   // Hack to fill NCBeam's histograms with something semi-reasonable
00215   // that includes the F/N ratio, for ease of comparison with other
00216   // methods
00217   
00218   // Loop over all of the beams
00219   for(fBeams_t::iterator it=fBeams.begin(); it!=fBeams.end(); ++it){
00220     NCBeam::Info beamInfo=it->first.first;
00221     NCBeam* beam=it->second;
00222     assert(fSpectra.find(beamInfo)!=fSpectra.end());
00223     PIDSpectrum* spectrum=fSpectra[beamInfo];
00224     
00225     for(int inccc=NCType::kNC; inccc<=NCType::kCC; ++inccc){
00226       // Gah, I still don't understand int <-> enum implicit casting rules
00227       NCType::EEventType nccc=NCType::EEventType(inccc);
00228 
00229       Detector::Detector_t det=it->first.second;
00230 
00231       TH1D* pseudoNoOsc=spectrum->GetPseudoNCCCSpectrum(det, nccc, PIDSpectrum::kAll, 
00232                                                         oscParsNoOsc);
00233       TH1D* pseudoFit=spectrum->GetPseudoNCCCSpectrum(det, nccc, PIDSpectrum::kAll, 
00234                                                       bestFit);
00235       TH1D* pseudoCC=spectrum->GetPseudoNCCCSpectrum(det, nccc, PIDSpectrum::kNumu, 
00236                                                      bestFit);
00237       TH1D* pseudoBeamNue=spectrum->GetPseudoNCCCSpectrum(det, nccc, PIDSpectrum::kBeamNue, 
00238                                                           bestFit);
00239       TH1D* pseudoOscNue=spectrum->GetPseudoNCCCSpectrum(det, nccc, PIDSpectrum::kOscNue, 
00240                                                          bestFit);
00241       TH1D* pseudoNutau=spectrum->GetPseudoNCCCSpectrum(det, nccc, PIDSpectrum::kNutau, 
00242                                                         bestFit);
00243       
00244       TH1D* pseudoData=spectrum->GetPseudoNCCCComponent(
00245          det==Detector::kFar ? spectrum->GetDataHist() : spectrum->GetNearDataHist(), 
00246          nccc);
00247       
00248       // The NCBeam plots want background for both spectra (ie, CC in
00249       // the NC spectrum, and NC in the CC spectrum), but we don't
00250       // have the NC component alone, so we have to form it here
00251       TH1D* pseudoBG;
00252       if(nccc==NCType::kNC) pseudoBG=pseudoCC;
00253       else{
00254         // Form the NC BG in the CC spectrum as the difference between
00255         // the total and the various CC parts
00256         pseudoBG=(TH1D*)pseudoFit->Clone("pseudoBG");
00257         pseudoBG->SetDirectory(0);
00258         
00259         pseudoBG->Add(pseudoCC, -1);
00260         // These are going to be tiny and not matter, but may as well
00261         // subtract them anyway
00262         pseudoBG->Add(pseudoBeamNue, -1);
00263         pseudoBG->Add(pseudoOscNue, -1);
00264         pseudoBG->Add(pseudoNutau, -1);
00265       }
00266       
00267 #define COPYBINS(from, to) CopyBinContents(from,                        \
00268                                            beam->Get##to##Histogram(nccc)) 
00269       
00270       COPYBINS(pseudoData,    Data);
00271       COPYBINS(pseudoNoOsc,   MC);
00272       COPYBINS(pseudoFit,     MCFit);
00273       COPYBINS(pseudoBG,      MCBackground);
00274       COPYBINS(pseudoBeamNue, MCFitNuEToNuE);
00275       COPYBINS(pseudoOscNue,  MCFitNuMuToNuE);
00276       COPYBINS(pseudoNutau,   MCFitNuMuToNuTau);
00277 
00278 #undef COPYBINS
00279 
00280     }      
00281     // We filled the histograms manually, and don't need NCBeam's automatic stuff
00282     // to happen. So inform it of that fact.
00283     beam->MarkHistogramsFilled();
00284   }
00285 
00286   delete oscParsNoOsc;
00287 
00288   NCExtrapolation::WriteResources(trueOscPars);
00289 
00290   // Done with the NCBeam stuff, so now we can get on with making my plots
00291     
00292   // Store my plots in a debug directory
00293   gDirectory->mkdir("debug", "debug")->cd();
00294     
00295   if(bestFit){
00296     NC::SystPars systs=GetBestFitSysts();
00297     
00298     WriteSpectra(bestFit, systs, "bestFit");
00299     
00300     if(trueOscPars) WriteSpectra(trueOscPars, systs, "truePars");
00301     
00302   }
00303     
00304   // If requested, save the PIDSpectrum objects out to file
00305   if (fMCOutFilename!="") WriteMCSpectra(fMCOutFilename.c_str());
00306 }

void NCExtrapolationPID::WriteSpectra ( const NC::OscProb::OscPars coords,
const NC::SystPars s,
std::string  suffix = "" 
) [protected]

Write the spectra, evaluated at the parameters coords, prettily to gDirectory.

Referenced by WriteResources().


Member Data Documentation

Whether to do the far/near correction.

Definition at line 137 of file NCExtrapolationPID.h.

Referenced by EnableNearToFarExtrapolation(), and Prepare().

Whether to instruct PIDSpectrum to draw FD data on plots (for blinding).

Definition at line 146 of file NCExtrapolationPID.h.

Referenced by AddEvent(), and Prepare().

Whether to emulate the Far/Near method by having just two bins.

Definition at line 143 of file NCExtrapolationPID.h.

Referenced by AddEvent(), Prepare(), and ReadMCSpectra().

std::string NCExtrapolationPID::fMCInFilename [protected]

The filename to read the MC spectra from.

Definition at line 131 of file NCExtrapolationPID.h.

Referenced by AddEvent(), DoneFilling(), and Prepare().

std::string NCExtrapolationPID::fMCOutFilename [protected]

The filename to write the MC spectra to.

Definition at line 134 of file NCExtrapolationPID.h.

Referenced by Prepare(), and WriteResources().

How many bins in PID to use.

Definition at line 122 of file NCExtrapolationPID.h.

Referenced by AddEvent(), Prepare(), and ReadMCSpectra().

double NCExtrapolationPID::fPIDmax [protected]

The maximum value of PID to use.

Definition at line 128 of file NCExtrapolationPID.h.

Referenced by AddEvent(), and Prepare().

double NCExtrapolationPID::fPIDmin [protected]

The minimum value of PID to use.

Definition at line 125 of file NCExtrapolationPID.h.

Referenced by AddEvent(), and Prepare().

How much finer to make the true energy binning than the reco.

Definition at line 119 of file NCExtrapolationPID.h.

Referenced by AddEvent(), and Prepare().

Whether to use the CC energy estimator. If false, use NC energy estimator. useSelectionEnergy overrides this

Definition at line 108 of file NCExtrapolationPID.h.

Referenced by AddEvent(), and Prepare().

Whether to use the event energy as defined by NCUtils - ie CC energy if event is selected CC and NC energy if event is selected NC. Overrides fUseCCEnergy

Definition at line 115 of file NCExtrapolationPID.h.

Referenced by AddEvent(), and Prepare().


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1