FitTree Class Reference

#include <FitTree.h>

Inheritance diagram for FitTree:
NuDSTAna NuBase

List of all members.

Public Member Functions

 FitTree (NuXMLConfig *xmlConfig)
virtual ~FitTree ()
virtual void MakeVectors ()

Private Member Functions

virtual NuInputEventsGetEventListForLooping ()
virtual void PrepareEvents (NuEvent &event) const
virtual void SetSystematics ()
virtual void FillCCVector (NuEvent &event)
virtual void FillNCVector (NuEvent &event)
double GetL (NuEvent event, bool IsTrue)

Private Attributes

NuCuts::NuAnaVersion_t fAnaVersionNC
NuCuts::NuAnaVersion_t fAnaVersionCC
NuCutterfNCCutter
NuCutterfCCCutter
NuLibraryfLib
NuSystematicfSyst
NuXMLConfigfxmlConfig
SterileEventsfCCEvts
SterileEventsfNCEvts

Detailed Description

Definition at line 52 of file FitTree.h.


Constructor & Destructor Documentation

FitTree::FitTree ( NuXMLConfig xmlConfig  )  [explicit]

Definition at line 24 of file FitTree.cxx.

References NuCutter::AnaVersion(), NuXMLConfig::AnaVersionString(), fAnaVersionCC, fAnaVersionNC, fCCCutter, fCCEvts, fLib, fNCCutter, fNCEvts, fxmlConfig, NuXMLConfig::GetUnknownKey(), NuLibrary::Instance(), Msg::kInfo, Msg::kWarning, MSG, and SetSystematics().

00025 {
00026   if (!xmlConfig){
00027     MSG("FitTree",Msg::kWarning)
00028       << "Event by event analysis object configured with a non-existent xml object."
00029       << endl
00030       << "Asserting now."
00031       << endl;
00032     assert(false);
00033   }
00034 
00035   fxmlConfig = xmlConfig;
00036 
00037   // Get the anaVersion and anaVersionNC from the XML config
00038   TString anaVer = fxmlConfig->AnaVersionString();
00039   TString anaVerNC = "";
00040 
00041   if (xmlConfig->GetUnknownKey("anaVersionNC").IsNull()) {
00042     MSG("NuDSTAna",Msg::kInfo) 
00043       << "Did not find anaVersionNC in configuration...cannot proceed" << endl;
00044     assert(false);
00045   } else {
00046     anaVerNC = xmlConfig->GetUnknownKey("anaVersionNC");
00047   }
00048 
00049   fCCCutter = new NuCutter(anaVer);
00050   fNCCutter = new NuCutter(anaVerNC);
00051 
00052   // Get NuAnaVersion_t from the cutter objects
00053   fAnaVersionNC = static_cast<NuCuts::NuAnaVersion_t>(fNCCutter->AnaVersion());
00054   fAnaVersionCC = static_cast<NuCuts::NuAnaVersion_t>(fCCCutter->AnaVersion());
00055 
00056   fLib = &NuLibrary::Instance();
00057 
00058   this->SetSystematics();
00059 
00060   fCCEvts = new SterileEvents();
00061   fNCEvts = new SterileEvents();
00062 
00063 }

FitTree::~FitTree (  )  [virtual]

Definition at line 67 of file FitTree.cxx.

References fCCCutter, fCCEvts, fLib, fNCCutter, fNCEvts, and fSyst.

00068 {
00069   if (fCCCutter) {
00070     delete fCCCutter;
00071     fCCCutter = 0;
00072   }
00073   if (fNCCutter) {
00074     delete fNCCutter;
00075     fNCCutter = 0;
00076   }
00077   if (fCCEvts) {
00078     delete fCCEvts;
00079     fCCEvts = 0;
00080   }
00081   if (fNCEvts) {
00082     delete fNCEvts;
00083     fNCEvts = 0;
00084   }
00085   if (fSyst) {
00086     delete fSyst;
00087     fSyst = 0;
00088   }
00089   fLib = 0; // I didn't create this, so don't have the right to delete it.
00090 
00091 }


Member Function Documentation

void FitTree::FillCCVector ( NuEvent event  )  [private, virtual]

Definition at line 194 of file FitTree.cxx.

References SterileEvent::absShwdE, NuEvent::energy, SterileEvent::evtW, fAnaVersionCC, fCCEvts, SterileEvent::fdCleanW, SterileEvent::fdCosmicW, fSyst, GetL(), SterileEvent::iaction, SterileEvent::icharge, SterileEvent::inu, SterileEvent::inunoosc, SterileEvent::ndCleanW, PrepareEvents(), SterileEvent::recoE, SterileEvent::recoL, SterileEvent::relShwdE, NuSystematic::ShowerEnergyFunction(), SterileEvent::shwdE, NuSystematic::TrackEnergyOverall(), SterileEvent::trkdE, SterileEvent::trueE, SterileEvent::trueL, and SterileEvents::Vec.

Referenced by MakeVectors().

00194                                          {
00195 
00196   event.anaVersion = fAnaVersionCC;
00197 
00198   this->PrepareEvents(event);
00199 
00200   SterileEvent evtStruct;
00201 
00202   evtStruct.trueE = event.neuEnMC;
00203   evtStruct.trueL = this->GetL(event,true);
00204   evtStruct.recoL = this->GetL(event,false);
00205   evtStruct.recoE = event.energy;
00206   evtStruct.evtW = event.rw;
00207   evtStruct.iaction = event.iaction;
00208   evtStruct.inu = event.inu;
00209   evtStruct.inunoosc = event.inunoosc;
00210   evtStruct.icharge = event.charge;
00211 
00212   NuEvent shiftEvt = event;
00213   fSyst->ShowerEnergyFunction(shiftEvt);
00214   evtStruct.shwdE =  shiftEvt.energy - event.energy;
00215 
00216   shiftEvt = event;
00217   fSyst->TrackEnergyOverall(shiftEvt);
00218   evtStruct.trkdE =  shiftEvt.energy - event.energy;
00219 
00220   evtStruct.absShwdE = 0;
00221   evtStruct.relShwdE = 0;
00222   evtStruct.ndCleanW = 1;
00223   evtStruct.fdCleanW = 1;
00224   evtStruct.fdCosmicW = 1;
00225 
00226   fCCEvts->Vec.push_back(evtStruct);
00227 
00228 }

void FitTree::FillNCVector ( NuEvent event  )  [private, virtual]

Definition at line 231 of file FitTree.cxx.

References NuSystematic::AbsoluteHadronicCalibrationSterile(), SterileEvent::absShwdE, SterileEvent::evtW, fAnaVersionNC, NuSystematic::FDCleaningCosmicsShiftSterile(), NuSystematic::FDCleaningShiftSterile(), SterileEvent::fdCleanW, SterileEvent::fdCosmicW, fNCEvts, fSyst, GetL(), SterileEvent::iaction, SterileEvent::icharge, SterileEvent::inu, SterileEvent::inunoosc, NuSystematic::NDCleaningShiftSterile(), SterileEvent::ndCleanW, PrepareEvents(), SterileEvent::recoE, SterileEvent::recoL, NuSystematic::RelativeHadronicCalibrationSterile(), SterileEvent::relShwdE, NuEvent::rw, SterileEvent::shwdE, NuEvent::shwEnLinNCCor, SterileEvent::trkdE, SterileEvent::trueE, SterileEvent::trueL, and SterileEvents::Vec.

Referenced by MakeVectors().

00231                                          {
00232 
00233   event.anaVersion = fAnaVersionNC;
00234 
00235   this->PrepareEvents(event);
00236   
00237   SterileEvent evtStruct;
00238 
00239   evtStruct.trueE = event.neuEnMC;
00240   evtStruct.trueL = this->GetL(event,true);
00241   evtStruct.recoL = this->GetL(event,false);
00242   evtStruct.recoE = event.shwEnLinNCCor;
00243   evtStruct.evtW = event.rw;
00244   evtStruct.iaction = event.iaction;
00245   evtStruct.inu = event.inu;
00246   evtStruct.inunoosc = event.inunoosc;
00247   evtStruct.icharge = event.charge;
00248 
00249   NuEvent shiftEvt = event;
00250   fSyst->AbsoluteHadronicCalibrationSterile(shiftEvt);
00251   evtStruct.absShwdE =  shiftEvt.shwEnLinNCCor - event.shwEnLinNCCor;
00252 
00253   shiftEvt = event;
00254   fSyst->RelativeHadronicCalibrationSterile(shiftEvt);
00255   evtStruct.relShwdE =  shiftEvt.shwEnLinNCCor - event.shwEnLinNCCor;
00256 
00257   shiftEvt = event;
00258   fSyst->NDCleaningShiftSterile(shiftEvt);
00259   evtStruct.ndCleanW =  shiftEvt.rw / event.rw;
00260 
00261   shiftEvt = event;
00262   fSyst->FDCleaningShiftSterile(shiftEvt);
00263   evtStruct.fdCleanW =  shiftEvt.rw / event.rw;
00264 
00265   shiftEvt = event;
00266   fSyst->FDCleaningCosmicsShiftSterile(shiftEvt);
00267   evtStruct.fdCosmicW =  shiftEvt.rw / event.rw;
00268 
00269   evtStruct.shwdE = 0;
00270   evtStruct.trkdE = 0;
00271 
00272   fNCEvts->Vec.push_back(evtStruct);
00273 
00274 }

NuInputEvents & FitTree::GetEventListForLooping (  )  [private, virtual]

Definition at line 95 of file FitTree.cxx.

References NuDSTAna::DoIO(), fxmlConfig, and NuInputEvents::ResetNuEventLoopPositionToStart().

Referenced by MakeVectors().

00096 {
00097   NuInputEvents& input = this->DoIO(0, "", "null");
00098   fxmlConfig->Write();
00099   input.ResetNuEventLoopPositionToStart();
00100   return input;
00101 }

double FitTree::GetL ( NuEvent  event,
bool  IsTrue 
) [private]

Definition at line 278 of file FitTree.cxx.

References NuEvent::detector, FidVol::getBeamAngleRad(), FidVol::getNearX0Beam(), FidVol::getNearY0Beam(), and Detector::kFar.

Referenced by FillCCVector(), and FillNCVector().

00278                                                {
00279 
00280   double vtxBeam[3]; double vtxDet[3]; double vtxProd[3];
00281   double meanZ = 14.87; double beamAngle = FidVol::getBeamAngleRad();
00282 
00283   if(IsTrue){
00284     vtxDet[0]  = event.vtxxMC;
00285     vtxDet[1]  = event.vtxyMC;
00286     vtxDet[2]  = event.vtxzMC;
00287     vtxProd[0] = event.Vx/100;
00288     vtxProd[1] = event.Vy/100;
00289     vtxProd[2] = event.Vz/100;
00290   }
00291   else{
00292     vtxDet[0] = event.xEvtVtx;
00293     vtxDet[1] = event.yEvtVtx;
00294     vtxDet[2] = event.zEvtVtx;
00295     vtxProd[0] = 0;
00296     vtxProd[1] = 0;
00297     vtxProd[2] = 240.5;
00298   }
00299 
00300   if(event.detector == Detector::kFar){
00301     vtxBeam[0] = vtxDet[0];
00302     vtxBeam[1] = vtxDet[1]*cos(beamAngle) - (vtxDet[2]-meanZ)*sin(beamAngle);
00303     vtxBeam[2] = vtxDet[1]*sin(beamAngle) + (vtxDet[2]-meanZ)*cos(beamAngle) + 735000;
00304   }
00305   else{
00306     vtxBeam[0] =   vtxDet[0] - FidVol::getNearX0Beam();
00307     vtxBeam[1] =  (vtxDet[1] - FidVol::getNearY0Beam())*cos(beamAngle) + vtxDet[2]*sin(beamAngle);
00308     vtxBeam[2] = -(vtxDet[1] - FidVol::getNearY0Beam())*sin(beamAngle) + vtxDet[2]*cos(beamAngle) + 1040;
00309   }
00310 
00311   return sqrt(pow(vtxBeam[0] - vtxProd[0],2)+pow(vtxBeam[1] - vtxProd[1],2)+pow(vtxBeam[2] - vtxProd[2],2));
00312 
00313 }

void FitTree::MakeVectors (  )  [virtual]

Definition at line 128 of file FitTree.cxx.

References NuCutter::Failed(), fAnaVersionCC, fAnaVersionNC, fCCCutter, fCCEvts, FillCCVector(), FillNCVector(), fNCCutter, fNCEvts, fxmlConfig, NuInputEvents::GetEntriesNuEvent(), GetEventListForLooping(), NuInputEvents::GetNextNuEvent(), Msg::kDebug, NuCutter::MakeCuts(), MSG, NuCutter::Passed(), PrepareEvents(), NuXMLConfig::PrintAll(), NuCutter::PrintNMinusOneSummary(), NuCutter::PrintSummary(), and NuUtilities::ProgressBar().

00129 {
00130   fxmlConfig->PrintAll(cout);
00131 
00132   NuInputEvents& input = this->GetEventListForLooping();
00133 
00134   for (Int_t i = 0; i < input.GetEntriesNuEvent(); ++i){
00135     NuUtilities::ProgressBar(i, input.GetEntriesNuEvent(), 5);
00136     NuEvent& nu = const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
00137 
00138     // Configuring weights, etc is a hack until DSTs are fixed
00139     nu.anaVersion = fAnaVersionCC;
00140     this->PrepareEvents(nu);
00141 
00142     //std::cout << "applying this shift rw = " << nu.rw << std::endl;
00143 
00144     fCCCutter->MakeCuts(nu);
00145 
00146     // Configuring weights, etc is a hack until DSTs are fixed
00147     nu.anaVersion = fAnaVersionNC;
00148     this->PrepareEvents(nu);
00149 
00150     fNCCutter->MakeCuts(nu);
00151 
00152     // If both cuts failed, continue
00153     if (fCCCutter->Failed() && fNCCutter->Failed()) {
00154       continue;
00155     }
00156 
00157     // Explicitly not allow events to be filled twice
00158 
00159     if (fNCCutter->Passed()) {
00160       this->FillNCVector(nu);
00161     }
00162     if (fCCCutter->Passed() && fNCCutter->Failed()) {
00163       this->FillCCVector(nu);
00164     } else {
00165       MSG("FitTree", Msg::kDebug)
00166         << "The event didn't pass either selection. Run " << nu.run << "/" << nu.subRun 
00167         << " snarl " << nu.snarl << endl;
00168     }
00169   } // for
00170 
00171   fCCEvts->Write("fCCEvts");
00172   fNCEvts->Write("fNCEvts");
00173 
00174   fNCCutter->PrintSummary();
00175   fNCCutter->PrintNMinusOneSummary();
00176 
00177   fCCCutter->PrintSummary();
00178   fCCCutter->PrintNMinusOneSummary();
00179 }

void FitTree::PrepareEvents ( NuEvent event  )  const [private, virtual]

Definition at line 182 of file FitTree.cxx.

References NuReco::ApplyReweights(), NuReco::CalcResolution(), NuXMLConfig::ConfigureWeights(), fLib, fxmlConfig, NuReco::GetEvtEnergy(), and NuLibrary::reco.

Referenced by FillCCVector(), FillNCVector(), and MakeVectors().

00183 {
00184     fxmlConfig->ConfigureWeights(event);
00185 
00186     // RE-RECONSTRUCT the neutrino energy
00187     fLib->reco.GetEvtEnergy(event, false);
00188     fLib->reco.ApplyReweights(event);
00189     fLib->reco.CalcResolution(event);
00190 }

void FitTree::SetSystematics (  )  [private, virtual]

Member Data Documentation

Definition at line 63 of file FitTree.h.

Referenced by FillCCVector(), FitTree(), and MakeVectors().

Definition at line 62 of file FitTree.h.

Referenced by FillNCVector(), FitTree(), and MakeVectors().

Definition at line 65 of file FitTree.h.

Referenced by FitTree(), MakeVectors(), SetSystematics(), and ~FitTree().

Definition at line 70 of file FitTree.h.

Referenced by FillCCVector(), FitTree(), MakeVectors(), and ~FitTree().

Definition at line 66 of file FitTree.h.

Referenced by FitTree(), PrepareEvents(), and ~FitTree().

Definition at line 64 of file FitTree.h.

Referenced by FitTree(), MakeVectors(), SetSystematics(), and ~FitTree().

Definition at line 71 of file FitTree.h.

Referenced by FillNCVector(), FitTree(), MakeVectors(), and ~FitTree().

Definition at line 67 of file FitTree.h.

Referenced by FillCCVector(), FillNCVector(), SetSystematics(), and ~FitTree().

Definition at line 68 of file FitTree.h.

Referenced by FitTree(), GetEventListForLooping(), MakeVectors(), PrepareEvents(), and SetSystematics().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1