NuReco Class Reference

#include <NuReco.h>

List of all members.

Public Member Functions

 NuReco ()
 ~NuReco ()
void ApplyReweights (NuEvent &nu) const
Double_t Run9TargetDecayWeight (const NuEvent &nu) const
Double_t Fin78WeightL010z185iFocusedComponent (const Double_t true_enu) const
Double_t Fin78WeightL010z185iDefocusedComponent (const Double_t true_enu) const
void CalcEvtVariables (NuEvent &nu) const
void CalcExtraTruthVariables (NuEvent &nu) const
void CalcKinematicVariables (NuEvent &nu) const
void CalcShwVariables (NuEvent &nu, bool includekNN) const
void CalcTrkReclamation (NuEvent &nu) const
void CalcTrkVariables (NuEvent &nu) const
void CalcResolution (NuEvent &nu) const
void CapTrackMomentum (Double_t &trkMom) const
void ChooseTruthIndexToUse (NuEvent &nu) const
TVector3 xyz2uvz (Float_t x, Float_t y, Float_t z, VldContext vc) const
TVector3 uvz2xyz (Float_t u, Float_t v, Float_t z, VldContext vc) const
Int_t FDRCBoundary (const NuEvent &nu) const
Float_t GetSmallestDeepDistToEdge (const NuEvent &nu) const
void TestGetSmallestDeepDistToEdge () const
Int_t GetBestShower (const NuEvent &nu) const
Int_t GetBestTrack (const NuEvent &nu) const
void GetBestTruthIndex (const NtpStRecord &ntp, const NtpSREvent &evt, NuEvent &nu) const
void GetPrimaryTruthIndex (const NtpStRecord &ntp, const NtpSREvent &evt, NuEvent &nu) const
void GetSecondaryTruthIndex (const NtpStRecord &ntp, const NtpSREvent &evt, NuEvent &nu) const
Int_t GetContainmentFlag (const NuEvent &nu) const
Int_t GetContainmentFlagCC0093Std (const NuEvent &nu) const
Int_t GetContainmentFlagCC0250Std (const NuEvent &nu) const
Int_t GetContainmentFlagNCPRL (const NuEvent &nu) const
Int_t GetContainmentFlagPitt (const NuEvent &nu) const
Int_t GetContainmentFlagStdReco (const NuEvent &nu) const
void GetDirCosNu (const NtpSRTrack &trk, NuEvent &nu) const
Float_t GetDirCosNu (const NuEvent &nu) const
Double_t GetCosBetweenPr_Theta (const NtpSRTrack &trk) const
 Retrieves the cos of the angle between the radial momentum and track vertex.
Double_t GetEvtMedianTime (const NtpStRecord &ntp, const NtpSREvent &evt) const
Double_t GetShwMedianTime (const NtpStRecord &ntp, const NtpSRShower &shw) const
Int_t GetShwMaxPlane (const NtpStRecord &ntp, const NtpSRShower &shw) const
 Which plane does shw have the most ph deposited in?
void GetEvtDeltaTs (const NtpStRecord &ntp, std::map< Int_t, Double_t > &deltaTs) const
Double_t GetEvtEnergy (NuEvent &nu, bool includekNN) const
void GetEvtsPerSlc (const NtpStRecord &ntp, std::map< Int_t, Int_t > &evtsPerSlc) const
Int_t GetHadronicFinalState (const NtpStRecord &ntp, const NuEvent &nu) const
void GetPreInukeFinalStateVars (const NtpStRecord &ntp, NuEvent &nu) const
Int_t GetInitialState (const NtpStRecord &ntp, const NuEvent &nu) const
const NtpSRTrackGetLongestTrack (const NtpStRecord &ntp, const NtpSREvent &evt) const
Int_t GetLongestTrack (const NuEvent &nu) const
const NtpSRTrackGetLongestPathLengthTrack (const NtpStRecord &ntp, const NtpSREvent &evt) const
Int_t GetLongestPathLengthTrack (const NuEvent &nu) const
const NtpSRTrackGetLongestTrackTLikePlanes (const NtpStRecord &ntp, const NtpSREvent &evt) const
Int_t GetNucleus (const NtpStRecord &ntp, const NuEvent &nu) const
Int_t GetPrimaryShowerCCStd (const NuEvent &nu) const
Int_t GetPrimaryShowerNCStd (const NuEvent &nu) const
Int_t GetPrimaryShowerStdReco (const NuEvent &nu) const
const NtpSRTrackGetTrackWithIndexX (const NtpStRecord &ntp, const NtpSREvent &evt, Int_t index) const
Int_t GetPrimaryTrack (const NuEvent &nu) const
Float_t GetRadiusFromBeamCentre (Float_t x, Float_t y, const NuEvent &nu) const
Float_t GetRadiusFromCoil (Float_t x, Float_t y) const
Double_t GetShowerEnergyCC (const NuEvent &nu) const
Double_t GetShowerEnergyNC (const NuEvent &nu) const
Double_t GetShowerEnergyCor (Double_t shwEn, const CandShowerHandle::ShowerType_t &st, const NuEvent &nu) const
bool InitializeShowerEnergykNN (NuKDTree< double, 3 > *kdTree, Detector::Detector_t det, bool hornReverse, std::vector< double > &C, double &cutoff_lo, double &cutoff_hi, int &neighbours) const
 Helper function for GetShowerEnergykNN.
Double_t GetShowerEnergykNN (const NuEvent &num, Float_t *shwEnkNNNoCor=0, Float_t *res=0) const
Double_t GetShowerEnergykNN (const NuEvent &nu, Float_t *shwEnkNNNoCor, Float_t *shwEnkNNPlus, Float_t *shwEnkNNPlusNoCor) const
 a function to calculate MINOS+ kNN shower energy it returns the retrained shwEnkNN calculated with MIONS+ training samples shwEnkNNPlus is also calculated with reselected 4 variables
Double_t GetShowerEnergyNearTrack (const NtpStRecord &ntp, const NtpSRTrack &trk, Float_t *nearShowerEnergyDW=0) const
 Calculates the shower energy 'near' the track vertex.
const NtpSRShowerGetShowerWithIndexX (const NtpStRecord &ntp, const NtpSREvent &evt, Int_t index) const
Int_t GetTrackCharge (const NtpSRTrack &trk, bool isReverse) const
Int_t GetTrackCharge (Double_t qp, bool isReverse) const
Double_t GetTrackEnergy (const NuEvent &nu) const
Double_t GetTrackEnergyFromRange (const NuEvent &nu) const
Double_t GetTrackEnergyFromRangeCor (Double_t trkMomentumRange, const NuEvent &nu) const
Double_t GetTrackEnergyFromCurv (const NuEvent &nu) const
Double_t GetTrackEnergyFromCurvCor (Double_t qp, const NuEvent &nu) const
Double_t GetTrkQPFraction (const NtpSRTrack &trk) const
void GetTruthInfo (const NtpStRecord &ntp, const NtpSREvent &evt, NuEvent &nu) const
void GetTruthInfo (const NtpStRecord &ntp, const NtpMCTruth &mc, NuEvent &nu) const
VldContext GetVldContext (const NuEvent &nu) const
Bool_t IsTrkWithDimuon (const NtpStRecord &ntp, const NtpSRTrack &trk) const
Bool_t IsTrkWithMuonFromKaonDecay (const NtpStRecord &ntp, const NtpSRTrack &trk) const
Bool_t IsTrkWithMuonFromPionDecay (const NtpStRecord &ntp, const NtpSRTrack &trk) const
Bool_t IsTrkWithMuonFromNotNuNotPiNotKaonNotCharm (const NtpStRecord &ntp, const NtpSRTrack &trk) const
Bool_t PrintCharm (const NtpStRecord &ntp, const NtpSREvent &evt) const
void PrintStdhep (const NtpStRecord &ntp, const NtpMCTruth &mc) const
void PrintTrueEnergy (const NtpStRecord &ntp, const NtpSREvent &evt, Double_t recoEn=0) const
void SetBestShw (NuEvent &nu) const
void SetBestTrk (NuEvent &nu) const
void SetBestTrkMajorityCurvature (NuEvent &nu) const
void SetBestTrkSAFit (NuEvent &nu) const
Bool_t UseCurvature (const NuEvent &nu) const
Bool_t UseRange (const NuEvent &nu) const
Int_t GetPrimaryMuonStdHepIndex (const NtpStRecord &ntp, const NtpMCTruth &mc) const
 Find the stdhep array entry that corresponds to the muon.
Double_t GetMuonFirstHitEnergy (const NtpStRecord &ntp, const NtpMCTruth &mc) const
 Retrieves the energy of muon on the first detector hit.
Double_t GetMuonLastHitEnergy (const NtpStRecord &ntp, const NtpMCTruth &mc) const
 Retrieves the energy of muon on the last detector hit.
Bool_t GetMuonContainmentMC (const NtpStRecord &ntp, const NtpMCTruth &mc) const
 Experimental: Attempts to calculate the 'containment truth'.
Int_t GetTrackFirstStrip (const NtpStRecord &ntp, const NtpSRTrack &trk) const
Int_t GetTrackFirstUStrip (const NtpStRecord &ntp, const NtpSRTrack &trk) const
Int_t GetTrackFirstVStrip (const NtpStRecord &ntp, const NtpSRTrack &trk) const
Bool_t GetTrackFirstStripIsU (const NtpStRecord &ntp, const NtpSRTrack &trk) const
Int_t GetTrackLastStrip (const NtpStRecord &ntp, const NtpSRTrack &trk) const
Bool_t GetTrackLastStripIsU (const NtpStRecord &ntp, const NtpSRTrack &trk) const
Int_t GetTrackLastUStrip (const NtpStRecord &ntp, const NtpSRTrack &trk) const
Int_t GetTrackLastVStrip (const NtpStRecord &ntp, const NtpSRTrack &trk) const
Float_t GetPhi (const NtpSRVertex &vtx) const
Int_t GetRegion (const NtpStRecord &rec, const NtpSRVertex &vtx) const
 Retrieves the (rock muon) detector region from SNTP.
Int_t GetRegion (Detector::Detector_t det, SimFlag::SimFlag_t simFlag, Float_t vtxX, Float_t vtxY, Float_t vtxZ, Int_t vtxPlane) const
Int_t GetEdgeRegion (const NtpStRecord &rec, const NtpSRVertex &vertex) const
 Retrieves the FD edge region from the SNTP.
Int_t GetEdgeRegion (Detector::Detector_t det, const Float_t phi) const
 Calculates the edge region based on direct variables.
void CalculateEdgeRegion (NuEvent &nu, Int_t track) const
Short_t GetParallelStripInset (Detector::Detector_t det, Short_t edgeRegion, Short_t stripBegU, Short_t stripBegV) const
 How many strips in, on a diagonal edge, is a hit?
void CalculateParallelStripInset (NuEvent &nu, Int_t track=0) const
 Given a NuEvent, calculates from existing variables the parallel strip inset.
Char_t GetPerpendicularStripFlag (Detector::Detector_t det, Short_t edgeRegion, Bool_t IsHitu) const
 Is the hit both on a diagonal edge and on the overhanging (perpendicular) strip?
void CalculatePerpendicularStripFlag (NuEvent &nu, Int_t track) const
 Given a NuEvent, calculates the Perpendicular strip flags.
Short_t GetHorizontalVerticalStripNumber (Detector::Detector_t det, Short_t edgeRegion, Short_t stripTrku, Short_t stripTrkv) const
void CalculateHorizontalVerticalStripNumber (NuEvent &nu, Int_t track) const
 Given a NuEvent, calculates the HOVE strip numbers.
void RecalculateDerivativeTrackGeometryVariables (NuEvent &nu) const
 Recalculates all of the base geometry variables it can, given only a NuEvent.
Int_t GetTrueTrackId (const NtpStRecord &ntp, const NtpSRTrack &trk) const
 Get the true track identity.

Detailed Description

Definition at line 35 of file NuReco.h.


Constructor & Destructor Documentation

NuReco::NuReco (  ) 

Definition at line 66 of file NuReco.cxx.

References Msg::kDebug, and MSG.

00067 {
00068   MSG("NuReco",Msg::kDebug)
00069     <<"Running NuReco Constructor..."<<endl;
00070 
00071   MSG("NuReco",Msg::kDebug)
00072     <<"Finished NuReco Constructor"<<endl;
00073 }

NuReco::~NuReco (  ) 

Definition at line 76 of file NuReco.cxx.

References Msg::kDebug, and MSG.

00077 {
00078   MSG("NuReco",Msg::kDebug)
00079     <<"Running NuReco Destructor..."<<endl;
00080 
00081 
00082   MSG("NuReco",Msg::kDebug)
00083     <<"Finished NuReco Destructor"<<endl;
00084 }


Member Function Documentation

void NuReco::ApplyReweights ( NuEvent nu  )  const

Definition at line 508 of file NuReco.cxx.

References NuEvent::anaVersion, NuEvent::apply1SigmaWeight, NuEvent::applyBeamWeight, NuEvent::applyDetectorWeight, NuEvent::applyEnergyShifts, NuEvent::applyGeneratorWeight, NuEvent::beamWeight, CalcResolution(), NuEvent::charge, NuEvent::coilCorrWeight, ReleaseType::DataMCMask, NuEvent::detector, NuEvent::detectorWeight, NuEvent::detectorWeightNM, NuEvent::detectorWeightNMB, NuEvent::energy, NuEvent::energyRw, NuEvent::fluxErr, NuEvent::generatorWeight, NuEvent::iresonance, SimFlag::kData, Msg::kError, Detector::kFar, NuCuts::kFullDST, ReleaseType::kGarlic, Msg::kInfo, NuCuts::kJJE1, NuCuts::kJJE2, NuCuts::kJJH1, NuCuts::kNMB0325Alpha, NuCuts::kNMB0325Bravo, NuCuts::kNMB0325BravoTwo, NuCuts::kNMB0325ChairSound, NuCuts::kNMB0325Charlie, NuCuts::kNMB0325Delta, NuCuts::kNMB0325Echo, NuCuts::kNMBFree, NuCuts::kRHC, NuCuts::kRM1, NuCuts::kRM2, MAXMSG, NuEvent::mcVersion, MSG, NuEvent::neuEnMC, NuEvent::rockxsecCorrWeight, NuEvent::run, Run9TargetDecayWeight(), NuEvent::rw, NuEvent::rwActual, ShiftHoveStrip(), NuEvent::shwEn, NuEvent::shwEnNoRw, NuEvent::shwEnRw, NuEvent::shwEnWeight, NuEvent::simFlag, NuEvent::trkEn, NuEvent::trkEnNoRw, NuEvent::trkEnRw, NuEvent::trkEnWeight, NuEvent::vtxxMC, NuEvent::vtxyMC, NuEvent::vtxzMC, and NuEvent::zMC.

Referenced by NuDSTAna::BRevAna(), NuDSTAna::Contamination(), NuDSTAna::ContaminationNQ(), NuDSTAna::DPSystematic(), NuAnalysis::ExtractPIDsAndWeights(), NuZBeamReweight::ExtractZBeamReweight(), NuDSTAna::FDTestAna(), NuDSTAna::FluxComponents(), NuDSTAna::JeffsTestAna(), NuAnalysis::LIRejectionTest(), NuAnalysis::LoopOverTruthInfo(), FoverNHistos::MakeDataPlots(), NuDSTAna::MakeFCTree(), NuDSTAna::MakekNNTrainTestSet(), NuDSTAna::MakeMicroDST(), NuDSTAna::MakeMicroDst2010(), NuDSTAna::MakeMicroDst2014(), NuDSTAna::MakeMicroDstFakeData(), NuDSTAna::MakeMicroDstForCSSSystematics(), NuDSTAna::MakeMicroDstHe(), NuDSTAna::MakeMicroDstJJEPresel(), NuDSTAna::MakeMicroDstNC2012(), NuDSTAna::MakeMicroDstWithStdCCRecoAndCuts(), NuDSTAna::MakeResolutionBins(), NuDSTAna::MakeSelMicroDST(), NuDSTAna::MMRereco(), NuDSTAna::MMTransition(), NuDSTAna::MMTransSME(), NuDSTAna::NDOsc(), NuDSTAna::NDQPRB(), NuDSTAna::NDTestAna(), NuDSTAna::NewFieldAna(), FoverNHistos::PrepareCCEventForPlotting(), TemplateAnalysisClass::PrepareEventForPlotting(), DataMCPlots::PrepareEventForPlotting(), ToFPlotter::PrepareEventForPlotting(), FitTree::PrepareEvents(), FoverNHistos::PrepareNCEventForPlotting(), NuDSTAna::QPStudy(), NuDSTAna::RHCTest(), NuDSTAna::StdCCAna(), NuDSTAna::StdNMBAna(), and NuDSTAna::YStudy().

00509 {
00510   if (nu.simFlag==SimFlag::kData) {
00511     MAXMSG("NuReco",Msg::kInfo,1)
00512       <<"Not doing ApplyReweights for simFlag="<<nu.simFlag<<endl;
00513 
00514     nu.trkEnRw=nu.trkEnNoRw;
00515     nu.shwEnRw=nu.shwEnNoRw;
00516     nu.energyRw=nu.trkEnRw+nu.shwEnRw;
00517     return;
00518   }
00519 
00520   //shift the energies
00521   nu.trkEnRw=nu.trkEnNoRw*nu.trkEnWeight;
00522   nu.shwEnRw=nu.shwEnNoRw*nu.shwEnWeight;
00523   nu.energyRw=nu.trkEnRw+nu.shwEnRw;
00524 
00525   //check whether to apply energy shifts
00526   if (nu.applyEnergyShifts) {
00527     MAXMSG("NuReco",Msg::kInfo,1)
00528       <<"Applying SKZP energy shifts"<<endl;
00529     nu.trkEn=nu.trkEnRw;
00530     nu.shwEn=nu.shwEnRw;
00531     nu.energy=nu.energyRw;
00532   }
00533   else {
00534     MAXMSG("NuReco",Msg::kInfo,1)
00535       <<"NOT applying SKZP energy shifts"<<endl;
00536   }
00537 
00538   //set the detector weight to be either the NuMu or NuMuBar weight
00539   //because of wc.SetSampleSelection("NuMuBar");
00540   if (nu.anaVersion==NuCuts::kJJH1 ||
00541       nu.anaVersion==NuCuts::kJJE1 ||
00542       nu.anaVersion==NuCuts::kFullDST ||
00543       (nu.charge==+1 &&
00544        (nu.anaVersion == NuCuts::kNMB0325Alpha ||
00545         nu.anaVersion == NuCuts::kNMB0325Bravo ||
00546         nu.anaVersion == NuCuts::kNMB0325BravoTwo ||
00547         nu.anaVersion == NuCuts::kNMB0325Charlie ||
00548         nu.anaVersion == NuCuts::kNMB0325Delta ||
00549         nu.anaVersion == NuCuts::kNMB0325Echo ||
00550         nu.anaVersion == NuCuts::kNMB0325ChairSound ||
00551         nu.anaVersion == NuCuts::kRM1 ||
00552         nu.anaVersion == NuCuts::kRM2 ||
00553         nu.anaVersion == NuCuts::kJJE2 ||
00554         nu.anaVersion == NuCuts::kNMBFree ||
00555         nu.anaVersion == NuCuts::kRHC))) {
00556     MAXMSG("NuReco",Msg::kInfo,1)
00557       <<"Setting the detector weight for NuMuBar selection"<<endl;
00558     nu.detectorWeight=nu.detectorWeightNMB;
00559   }
00560   else {
00561     MAXMSG("NuReco",Msg::kInfo,1)
00562       <<"Setting the detector weight for NuMu selection"<<endl;
00563     nu.detectorWeight=nu.detectorWeightNM;
00564   }
00565 
00566   //reset to 1 at start
00567   //shouldn't have to do this except when re-weighting summary trees
00568   nu.rw=1;
00569 
00570   //check whether to apply beam weight
00571   if (nu.applyBeamWeight) {
00572     MAXMSG("NuReco",Msg::kInfo,1)
00573       <<"Applying beam weight"<<endl;
00574     nu.rw*=nu.beamWeight;
00575     MAXMSG("NuReco",Msg::kInfo,1)
00576       <<"Beam weight is " << nu.rw <<endl;
00577   }
00578   else {
00579     MAXMSG("NuReco",Msg::kInfo,1)
00580       <<"NOT applying beam weight"<<endl;
00581   }
00582 
00583   //check whether to apply detector weight
00584   if (nu.applyDetectorWeight) {
00585     MAXMSG("NuReco",Msg::kInfo,1)
00586       <<"Applying detector weight"<<endl;
00587     nu.rw*=nu.detectorWeight;
00588   }
00589   else {
00590     MAXMSG("NuReco",Msg::kInfo,1)
00591       <<"NOT applying detector weight"<<endl;
00592   }
00593 
00594   //check whether to apply generator weight
00595   if (nu.applyGeneratorWeight) {
00596     MAXMSG("NuReco",Msg::kInfo,1)
00597       <<"Applying generator weight"<<endl;
00598     nu.rw*=nu.generatorWeight;
00599   }
00600   else {
00601     MAXMSG("NuReco",Msg::kInfo,1)
00602       <<"NOT applying generator weight"<<endl;
00603   }
00604 
00605   //check whether to apply 1-sigma weight
00606   if (nu.apply1SigmaWeight) {
00607     MAXMSG("NuReco",Msg::kInfo,1)
00608       <<"Applying 1-sigma weight"<<endl;
00609     nu.rw*=(nu.fluxErr-1.0)+1.0;     // WTF -- Check me out
00610   }
00611   else {
00612     MAXMSG("NuReco",Msg::kInfo,1)
00613       <<"NOT applying 1-sigma weight"<<endl;
00614   }
00615 
00616   // Correct cross sections in rock from Fermi gas model to spectral function
00617   // model. See doc-6946. A systematic error goes in later to account for model
00618   // uncertainty. Apply only to far detector rock, only to quasielastic,
00619   // resonance & coherent pion events, and only if the monte carlo uses neugen,
00620   // i.e. it is pre-garlic (i.e. it is daikon assuming this is a physics run)
00621   if(nu.detector == Detector::kFar &&
00622       (nu.mcVersion & ReleaseType::DataMCMask) < ReleaseType::kGarlic &&
00623       (nu.iresonance==1001 || nu.iresonance==1002 || nu.iresonance==1004)){
00624 
00625     unsigned int runcode = nu.run/1000000; // first 2 digits of run number
00626 
00627     // the 2 means far, the 3 means mixed rock+detector file
00628     if(runcode == 23){
00629       MSG("NuReco",Msg::kError)
00630         << "File containing both rock and detector events is in use.\nYou must "
00631         "rewrite NuReco::ApplyReweights to find rock events in a mixed file.\n";
00632     }
00633     else if(runcode == 22){ // 2 means rock (1 means detector, 0 means cosmic)
00634       // the farther the element struck is from iron, the bigger the correction
00635       double fraction_of_Fe_to_C = (26.0 - nu.zMC)/20.0;
00636 
00637       // Empirical fit to double ratio of models+elements has a discontinuity.
00638       // It's down where there aren't hardly any events, so just assign
00639       // events below 0.75 GeV (0.002% of events) the weight for 0.75 GeV
00640       double correction;
00641       if(nu.neuEnMC<0.75) correction = 0.9695;
00642       else                correction = 0.9801 - 0.001489/(nu.neuEnMC - 0.6096);
00643 
00644       // average correction when all is said and done (LE-10) is 1.37%
00645       nu.rockxsecCorrWeight = 1 - (1-correction)*fraction_of_Fe_to_C;
00646       nu.rw *= nu.rockxsecCorrWeight;
00647     }
00648   }
00649 
00650   // For purposes of neutrino interactions, daikon mismodels the coil as
00651   // steel+scint+air, but then propagates through coil material.
00652   // Reweight true coil events to fix this. See doc-6836, page 3. For most
00653   // people, this should only make a tiny modification to background events.
00654   if(nu.detector == Detector::kFar &&
00655      (nu.mcVersion & ReleaseType::DataMCMask) < ReleaseType::kGarlic &&
00656      nu.vtxxMC*nu.vtxxMC+nu.vtxyMC*nu.vtxyMC < 0.09 &&  // Coil is within 30 cm
00657      nu.vtxzMC >= 0 && nu.vtxzMC < 30 /* and only inside the detector */ ){
00658     
00659     nu.coilCorrWeight = 0.669;
00660     nu.rw *= nu.coilCorrWeight;
00661   }
00662 
00663   // Daikon has a perfect geometry, but in reality the outermost scintilator
00664   // strips in the far detector vary in position by up to ~4 cm.
00665   if(nu.detector == Detector::kFar &&
00666       (nu.mcVersion & ReleaseType::DataMCMask) < ReleaseType::kGarlic){
00667     MAXMSG("NuReco", Msg::kInfo, 1) <<  "Doing RAF strip shifts.\n";
00668     ShiftHoveStrip(nu);     // only affects horizontal/vertical edge events
00669   }
00670 
00671    Bool_t applyRun9TargetDecayWeight = false;
00672    if (applyRun9TargetDecayWeight){
00673      nu.rw *= this->Run9TargetDecayWeight(nu);
00674    }
00675 
00676   //this stores what was actually used
00677   nu.rwActual=nu.rw;
00678 
00679   //Recalculate resolution with reweighted/shifted variables
00680   this->CalcResolution(nu);
00681 
00682 }

void NuReco::CalcEvtVariables ( NuEvent nu  )  const

Definition at line 183 of file NuReco.cxx.

References NuEvent::detector, NuEvent::distToEdgeEvtVtx, NuEvent::evtVtxUVDiffPl, GetRadiusFromCoil(), GetSmallestDeepDistToEdge(), NuCutImps::CC0720Std::InFidVol(), NuCuts::IsGoodTrackFitPassReclamation(), NuEvent::isGoodTrackReclamation, NuEvent::isInFidVolCC, NuEvent::isNCClean, Detector::kFar, Detector::kNear, Msg::kWarning, NuCut::MakePreselectionCuts(), MSG, NuCut::Passed(), NuEvent::planeEvtBegu, NuEvent::planeEvtBegv, NuCut::ResetStatus(), NuEvent::rEvtEnd, NuEvent::rEvtVtx, NuEvent::trkfitpass, NuEvent::xEvtEnd, NuEvent::xEvtVtx, NuEvent::yEvtEnd, and NuEvent::yEvtVtx.

Referenced by GetEvtEnergy().

00184 {
00185   //calculate vtx/end positions
00186   nu.rEvtVtx=this->GetRadiusFromCoil(nu.xEvtVtx,nu.yEvtVtx);
00187   nu.rEvtEnd=this->GetRadiusFromCoil(nu.xEvtEnd,nu.yEvtEnd);
00188   nu.evtVtxUVDiffPl=nu.planeEvtBegu-nu.planeEvtBegv;
00189   nu.distToEdgeEvtVtx=this->GetSmallestDeepDistToEdge(nu);
00190 
00192   //this section below just calculate flags to be used for
00193   //convenience when playing with DSTs
00194   //these flags are ABSOLUTELY NOT TO BE USED FOR ANALYSIS
00196 
00197   static NuCutImps::CC0720Std cutterCC;
00198   nu.isInFidVolCC = cutterCC.InFidVol(nu);
00199 
00200   if (Detector::kNear == nu.detector){
00201     nu.isGoodTrackReclamation = NuCuts::IsGoodTrackFitPassReclamation(nu);
00202   }
00203   else if (Detector::kFar == nu.detector){
00204     nu.isGoodTrackReclamation = (nu.trkfitpass == 1);
00205   }
00206   else {
00207     MSG("NuReco", Msg::kWarning)
00208       << "Unrecognized detector!" << endl;
00209     assert(false);
00210   }
00211 
00212   static NuCutImps::NC0720Std cutterNC;
00213   cutterNC.ResetStatus();
00214   cutterNC.MakePreselectionCuts(nu);
00215   if (Detector::kNear == nu.detector){
00216     nu.isNCClean = (cutterNC.Passed("TimeSep")
00217                     && cutterNC.Passed("TotalStrips")
00218                     && cutterNC.Passed("Steep")
00219                     && cutterNC.Passed("Leakage")
00220                     && cutterNC.Passed("OppositeEdge")
00221                     && cutterNC.Passed("dz&dt"));
00222   }
00223   else if (Detector::kFar == nu.detector){
00224     nu.isNCClean = (cutterNC.Passed("NumEvents")
00225                     && cutterNC.Passed("PHfrac")
00226                     && cutterNC.Passed("FibreNoise"));
00227   }
00228   else {
00229     MSG("NuReco", Msg::kWarning)
00230       << "Unrecognized detector!" << endl;
00231     assert(false);
00232   }
00233 }

void NuReco::CalcExtraTruthVariables ( NuEvent nu  )  const

Definition at line 409 of file NuReco.cxx.

References PlexPlaneId::GetPlane(), UgliGeomHandle::GetPlaneIdFromZ(), GetRadiusFromCoil(), GetVldContext(), NuLibrary::Instance(), NuEvent::planeTrkVtxMC, NuLibrary::reco, NuEvent::rTrkVtxMC, NuEvent::vtxuMC, NuEvent::vtxvMC, NuEvent::vtxxMC, NuEvent::vtxyMC, NuEvent::vtxzMC, and xyz2uvz().

Referenced by GetTruthInfo().

00410 {
00411   //get ugh
00412   const VldContext& vc=this->GetVldContext(nu);
00413   UgliGeomHandle ugh(vc);
00414 
00415   //get an instance of the code library
00416   const NuLibrary& lib=NuLibrary::Instance();
00417 
00418   //calculate the positions in UVZ space
00419   TVector3 uvz=lib.reco.xyz2uvz(nu.vtxxMC,nu.vtxyMC,nu.vtxzMC,vc);
00420 
00421   //write out the variables
00422   nu.vtxuMC=uvz.X();
00423   nu.vtxvMC=uvz.Y();
00424 
00425   //calc the other variables
00426   nu.planeTrkVtxMC=ugh.GetPlaneIdFromZ(nu.vtxzMC).GetPlane();
00427   nu.rTrkVtxMC=lib.reco.GetRadiusFromCoil(nu.vtxxMC,nu.vtxyMC);
00428 }

void NuReco::CalcKinematicVariables ( NuEvent nu  )  const

Definition at line 159 of file NuReco.cxx.

References NuEvent::dirCosNu, NuEvent::energy, GetDirCosNu(), NuEvent::q2, NuEvent::shwEn, NuEvent::trkEn, NuEvent::w2, NuEvent::x, and NuEvent::y.

Referenced by GetEvtEnergy().

00160 {
00161   nu.dirCosNu=this->GetDirCosNu(nu);
00162 
00164   //if(reco_emu>0) reco_Q2 =
00165   //         2*reco_enu*reco_emu*(1.0 - reco_dircosneu);
00166   //reco_W2 = M*M - reco_Q2 + 2*M*reco_eshw;
00167   //if(reco_enu>0) reco_y = reco_eshw/reco_enu;
00168   //if(reco_eshw>0 && reco_Q2>0) reco_x =  reco_Q2/(2*M*reco_eshw);
00169 
00170   //calc kinematics
00171   const Double_t M=(0.93827 + 0.93957)/2.0; // <nucleon mass>
00172 
00173   //calc y, q2, w2 and x
00174   if (nu.trkEn+nu.shwEn) nu.y=nu.shwEn/(nu.trkEn+nu.shwEn);
00175   nu.q2=2*nu.energy*nu.trkEn*(1.0-nu.dirCosNu);
00176   nu.w2=M*M-nu.q2+2*M*nu.shwEn;
00177   if (nu.shwEn) nu.x=nu.q2/(2*M*nu.shwEn);
00178   //else nu.x=0;
00179 }

void NuReco::CalcResolution ( NuEvent nu  )  const

Definition at line 325 of file NuReco.cxx.

References NuEvent::detector, EnergyResolution::MuonResolution(), NuEvent::releaseType, NuEvent::resolution, EnergyResolution::ShowerResolution(), NuEvent::shwEnkNN, NuEvent::shwEnReskNN, NuEvent::shwResolution, NuEvent::sigqp, NuEvent::trkEn, NuEvent::trkResolution, and NuEvent::usedRange.

Referenced by ApplyReweights(), GetEvtEnergy(), FoverNHistos::MakeDataPlots(), NuDSTAna::MakeResolutionBins(), NuDSTAna::MMRereco(), NuDSTAna::MMTransSME(), FoverNHistos::PrepareCCEventForPlotting(), TemplateAnalysisClass::PrepareEventForPlotting(), DataMCPlots::PrepareEventForPlotting(), ToFPlotter::PrepareEventForPlotting(), FitTree::PrepareEvents(), and FoverNHistos::PrepareNCEventForPlotting().

00326 {
00327   //calc track resolution
00328   if(nu.sigqp>=0){ //Make sure there's a track
00329     nu.trkResolution=EnergyResolution::
00330       MuonResolution(nu.trkEn,(nu.trkEn*nu.trkEn)*nu.sigqp,
00331                      nu.usedRange,
00332                      true, //If it's passing fiducial cut then it has
00333                      //a contained vertex
00334                      static_cast<Detector::Detector_t>(nu.detector),
00335                      nu.releaseType);
00336   }
00337 
00338   //catch the cases with no good track
00339   if(nu.trkResolution==-1.) nu.trkResolution=0.0;
00340 
00341   //calc shw resolution. The parametrisation used by this function
00342   //is based on the kNN, so that has to be the energy passed in
00343   nu.shwResolution=EnergyResolution::
00344     ShowerResolution(nu.shwEnkNN,nu.shwEnReskNN,
00345                      true, // use energy for resolution calculation
00346                      static_cast<Detector::Detector_t>(nu.detector),
00347                      nu.releaseType);
00348 
00349   nu.resolution=sqrt(nu.trkResolution*nu.trkResolution +
00350                      nu.shwResolution*nu.shwResolution );
00351 }

void NuReco::CalcShwVariables ( NuEvent nu,
bool  includekNN 
) const

Definition at line 355 of file NuReco.cxx.

References NuEvent::beamType, GetShowerEnergyCC(), GetShowerEnergykNN(), GetShowerEnergyNC(), BeamType::kM000z200i_nova, NuEvent::nshw, NuEvent::shwEn, NuEvent::shwEnCC, NuEvent::shwEnCor, NuEvent::shwEnkNN, NuEvent::shwEnkNNNoCor, NuEvent::shwEnkNNPlus, NuEvent::shwEnkNNPlusNoCor, NuEvent::shwEnLinCCCor, NuEvent::shwEnLinCCNoCor, NuEvent::shwEnLinNCCor, NuEvent::shwEnLinNCNoCor, NuEvent::shwEnMip, NuEvent::shwEnNC, NuEvent::shwEnNoCor, NuEvent::shwEnNoRw, NuEvent::shwEnReskNN, NuEvent::shwEnWtCCCor, NuEvent::shwEnWtCCNoCor, NuEvent::shwEnWtNCCor, NuEvent::shwEnWtNCNoCor, and NuEvent::shwExists.

Referenced by GetEvtEnergy().

00356 {
00357   //calculate the kNN shower variables if requested
00358   if(includekNN){
00359     if(nu.nshw > 0) {
00360       // use MINOS+ kNN training set for NOvA beam
00361       // junting@physics.utexas.edu
00362       if(nu.beamType == BeamType::kM000z200i_nova) 
00363         nu.shwEnkNN = GetShowerEnergykNN(nu, &nu.shwEnkNNNoCor, &nu.shwEnkNNPlus, &nu.shwEnkNNPlusNoCor);
00364       else
00365         nu.shwEnkNN = GetShowerEnergykNN(nu, &nu.shwEnkNNNoCor, &nu.shwEnReskNN);
00366     }
00367     else {
00368       nu.shwEnkNN = 0;
00369       nu.shwEnkNNNoCor = 0;
00370       nu.shwEnReskNN = 0;
00371       nu.shwEnkNNPlus = 0;
00372       nu.shwEnkNNPlusNoCor = 0;
00373     }
00374   }
00375   else{
00376     // Otherwise reuse old values
00377   }
00378 
00379   // Do this regardless of shwExists. The check is performed, if necessary,
00380   // in the functions themselves.
00381   nu.shwEnCC=this->GetShowerEnergyCC(nu); //default is shwEnkNN for CC0720Std
00382   nu.shwEnNC=this->GetShowerEnergyNC(nu); //default is shwEnLinNCCor
00383   nu.shwEn=nu.shwEnCC;
00384   nu.shwEnNoRw=nu.shwEn;
00385 
00386   if(!nu.shwExists){
00387     // Have to set these to zero, otherwise they are -1
00388     nu.shwEnCor=0;
00389     nu.shwEnNoCor=0;
00390     nu.shwEnLinCCNoCor=0;
00391     nu.shwEnLinCCCor=0;
00392     nu.shwEnWtCCNoCor=0;
00393     nu.shwEnWtCCCor=0;
00394     nu.shwEnLinNCNoCor=0;
00395     nu.shwEnLinNCCor=0;
00396     nu.shwEnWtNCNoCor=0;
00397     nu.shwEnWtNCCor=0;
00398     nu.shwEnMip=0;
00399 
00400     // Don't reset these, they can be sensible even in the absence of a
00401     // primary shower.
00402     //nu.shwEnkNN
00403     //nu.shwEnReskNN
00404   }
00405 }

void NuReco::CalcTrkReclamation ( NuEvent nu  )  const

Definition at line 290 of file NuReco.cxx.

References NuEvent::charge, NuEvent::detector, NuEvent::hornIsReverse, Msg::kDebug, Detector::kFar, MAXMSG, NuEvent::trkEn, NuEvent::trkEnCurv, NuEvent::trkEnNoRw, NuEvent::trkEnRange, NuEvent::trkExists, NuEvent::trkfitpass, and NuEvent::usedCurv.

Referenced by GetEvtEnergy().

00291 {
00292   if (nu.trkfitpass == 0) {
00293     if (nu.hornIsReverse) nu.charge = 1;
00294     else                  nu.charge = -1;
00295   }
00296   if (nu.trkExists && nu.trkEnCurv==0) {
00297     //sanity check for the FD
00298     if (nu.detector==Detector::kFar) {
00299       MAXMSG("NuReco",Msg::kDebug,100)
00300         <<"Looks like track reclamation for the FD..."
00301         <<", usedCurv="<<nu.usedCurv<<", trkEnCurv="<<nu.trkEnCurv
00302         <<", trkEnRange="<<nu.trkEnRange
00303         <<", trkfitpass="<<nu.trkfitpass
00304         <<endl;
00305     }
00306 
00307     MAXMSG("NuReco",Msg::kDebug,10)
00308       <<endl<<"Setting curv=range"
00309       <<", usedCurv="<<nu.usedCurv<<", trkEnCurv="<<nu.trkEnCurv
00310       <<", trkEnRange="<<nu.trkEnRange<<", trkfitpass="<<nu.trkfitpass
00311       <<endl;
00312     nu.trkEnCurv=nu.trkEnRange;
00313     nu.trkEn=nu.trkEnRange;
00314     nu.trkEnNoRw=nu.trkEn;
00315   }
00316   else if (!nu.trkExists && nu.trkEnCurv==0) {
00317     MAXMSG("NuReco",Msg::kDebug,10)
00318       <<"nu.trkExists="<<nu.trkExists<<", nu.trkEnCurv="<<nu.trkEnCurv
00319       <<endl;
00320   }
00321 }

void NuReco::CalcTrkVariables ( NuEvent nu  )  const

Definition at line 237 of file NuReco.cxx.

References NuEvent::chi2, NuEvent::chi2PerNdof, NuEvent::containmentFlag, NuEvent::containmentFlagCC0093Std, NuEvent::containmentFlagCC0250Std, NuEvent::containmentFlagPitt, GetContainmentFlag(), GetContainmentFlagCC0093Std(), GetContainmentFlagCC0250Std(), GetContainmentFlagPitt(), GetRadiusFromCoil(), GetTrackEnergy(), GetTrackEnergyFromCurv(), GetTrackEnergyFromRange(), Msg::kDebug, MAXMSG, NuEvent::ndof, NuEvent::primtrk, NuEvent::prob, NuEvent::qp, NuEvent::rTrkEnd, NuEvent::rTrkVtx, NuEvent::sigqp, NuEvent::sigqp_qp, NuEvent::trkEn, NuEvent::trkEnCurv, NuEvent::trkEnNoRw, NuEvent::trkEnRange, NuEvent::trkExists, UseCurvature(), NuEvent::usedCurv, NuEvent::usedRange, UseRange(), NuEvent::xTrkEnd, NuEvent::xTrkVtx, NuEvent::yTrkEnd, and NuEvent::yTrkVtx.

Referenced by GetEvtEnergy().

00238 {
00239   if (nu.trkExists) {
00240     nu.rTrkVtx=this->GetRadiusFromCoil(nu.xTrkVtx,nu.yTrkVtx);
00241     nu.rTrkEnd=this->GetRadiusFromCoil(nu.xTrkEnd,nu.yTrkEnd);
00242 
00243     //calculate track fit variables
00244     if (nu.qp) nu.sigqp_qp=nu.sigqp/nu.qp;
00245     if (nu.ndof) {
00246       nu.chi2PerNdof=nu.chi2/nu.ndof;
00247       nu.prob=TMath::Prob(nu.chi2,static_cast<Int_t>(nu.ndof));
00248     }
00249 
00250     //get containment flags
00251     nu.containmentFlagCC0093Std=this->GetContainmentFlagCC0093Std(nu);
00252     nu.containmentFlagCC0250Std=this->GetContainmentFlagCC0250Std(nu);
00253     nu.containmentFlagPitt=this->GetContainmentFlagPitt(nu);
00254     nu.containmentFlag=this->GetContainmentFlag(nu);
00255 
00256     //get the track energies
00257     nu.trkEnRange=this->GetTrackEnergyFromRange(nu);
00258     nu.trkEnCurv=this->GetTrackEnergyFromCurv(nu);
00259     nu.usedRange=this->UseRange(nu);
00260     nu.usedCurv=this->UseCurvature(nu);
00261     nu.trkEn=this->GetTrackEnergy(nu);
00262     nu.trkEnNoRw=nu.trkEn;
00263   }
00264   else {
00265     MAXMSG("NuReco",Msg::kDebug,10)
00266       <<"No track, nu.primtrk="<<nu.primtrk<<endl;
00267     nu.rTrkVtx=-999;
00268     nu.rTrkEnd=-999;
00269 
00270     nu.sigqp_qp=-999;
00271     nu.chi2PerNdof=-1;
00272     nu.prob=-1;
00273 
00274     nu.containmentFlagCC0093Std=-1;
00275     nu.containmentFlagCC0250Std=-1;
00276     nu.containmentFlagPitt=-1;
00277     nu.containmentFlag=-1;
00278 
00279     nu.trkEnRange=0;
00280     nu.trkEnCurv=0;
00281     nu.usedRange=0;
00282     nu.usedCurv=0;
00283     nu.trkEn=0;
00284     nu.trkEnNoRw=nu.trkEn;
00285   }
00286 }

void NuReco::CalculateEdgeRegion ( NuEvent nu,
Int_t  track 
) const

Recalculates a NuEvents edgeRegion from NuEvent variables This is for a given track, with 0 being the 'best track'

Definition at line 5561 of file NuReco.cxx.

References NuEvent::detector, NuEvent::edgeRegionTrkEnd, NuEvent::edgeRegionTrkVtx, GetEdgeRegion(), Msg::kError, MSG, NuEvent::phiTrkEnd, and NuEvent::phiTrkVtx.

Referenced by RecalculateDerivativeTrackGeometryVariables().

05562 {
05563   Detector::Detector_t det = static_cast<Detector::Detector_t>(nu.detector);
05564 
05565   if(track >= 1 && track <= 3){
05566     get_edgeRegionTrkVtx(nu, track) = GetEdgeRegion
05567       (det, get_phiTrkVtx(nu, track));
05568   } else if (track == 0){
05569     // Special case: Recalcuate the best track
05570     nu.edgeRegionTrkVtx = GetEdgeRegion(det, nu.phiTrkVtx);
05571     nu.edgeRegionTrkEnd = GetEdgeRegion(det, nu.phiTrkEnd);
05572   } else {
05573     MSG("NuReco",Msg::kError) << "Unrecognised track id " << track << endl;
05574   }
05575 }

void NuReco::CalculateHorizontalVerticalStripNumber ( NuEvent nu,
Int_t  track 
) const

Given a NuEvent, calculates the HOVE strip numbers.

Definition at line 5679 of file NuReco.cxx.

References NuEvent::detector, NuEvent::edgeRegionTrkVtx, GetHorizontalVerticalStripNumber(), Msg::kError, MSG, NuEvent::stripHoveNumTrkEnd, NuEvent::stripHoveNumTrkVtx, NuEvent::stripTrkBegu, and NuEvent::stripTrkBegv.

Referenced by NuExtraction::ExtractNthTrkInfo(), and RecalculateDerivativeTrackGeometryVariables().

05680 {
05681   Detector::Detector_t det = static_cast<Detector::Detector_t>(nu.detector);
05682 
05683   if(track >= 1 && track <= 3){
05684     get_stripHoveNumTrkVtx(nu, track) =
05685       GetHorizontalVerticalStripNumber(det,
05686                                        get_edgeRegionTrkVtx(nu, track),
05687                                        get_stripTrkBegu(nu, track),
05688                                        get_stripTrkBegv(nu, track));
05689     get_stripHoveNumTrkEnd(nu, track) =
05690       GetHorizontalVerticalStripNumber(det,
05691                                        get_edgeRegionTrkVtx(nu, track),
05692                                        get_stripTrkBegu(nu, track),
05693                                        get_stripTrkBegv(nu, track));
05694 
05695   } else if (track == 0){
05696     // Special case: Recalcuate the best track
05697     nu.stripHoveNumTrkVtx = GetHorizontalVerticalStripNumber(det, nu.edgeRegionTrkVtx, nu.stripTrkBegu, nu.stripTrkBegv);
05698     nu.stripHoveNumTrkEnd = GetHorizontalVerticalStripNumber(det, nu.edgeRegionTrkVtx, nu.stripTrkBegu, nu.stripTrkBegv);
05699   } else {
05700     MSG("NuReco",Msg::kError) << "Unrecognised track id " << track << endl;
05701   }
05702 }

void NuReco::CalculateParallelStripInset ( NuEvent nu,
Int_t  track = 0 
) const

Given a NuEvent, calculates from existing variables the parallel strip inset.

Definition at line 5597 of file NuReco.cxx.

References NuEvent::detector, NuEvent::edgeRegionTrkEnd, NuEvent::edgeRegionTrkVtx, GetParallelStripInset(), Msg::kError, MSG, NuEvent::parallelStripTrkEnd, NuEvent::parallelStripTrkVtx, NuEvent::stripTrkBegu, NuEvent::stripTrkBegv, NuEvent::stripTrkEndu, and NuEvent::stripTrkEndv.

Referenced by NuExtraction::ExtractNthTrkInfo(), and RecalculateDerivativeTrackGeometryVariables().

05598 {
05599   Detector::Detector_t det = static_cast<Detector::Detector_t>(nu.detector);
05600 
05601   if(track >= 1 && track <= 3){
05602     get_parallelStripTrkVtx(nu, track) =
05603       GetParallelStripInset(det,
05604                             get_edgeRegionTrkVtx(nu, track),
05605                             get_stripTrkBegu(nu, track),
05606                             get_stripTrkBegv(nu, track));
05607     get_parallelStripTrkEnd(nu, track) =
05608       GetParallelStripInset(det,
05609                             get_edgeRegionTrkEnd(nu, track),
05610                             get_stripTrkEndu(nu, track),
05611                             get_stripTrkEndv(nu, track));
05612   } else if (track == 0){
05613     // Special case: Recalcuate the best track
05614     nu.parallelStripTrkVtx = GetParallelStripInset(det, nu.edgeRegionTrkVtx, nu.stripTrkBegu, nu.stripTrkBegv);
05615     nu.parallelStripTrkEnd = GetParallelStripInset(det, nu.edgeRegionTrkEnd, nu.stripTrkEndu, nu.stripTrkEndv);
05616   } else {
05617     MSG("NuReco",Msg::kError) << "Unrecognised track id " << track << endl;
05618   }
05619 }

void NuReco::CalculatePerpendicularStripFlag ( NuEvent nu,
Int_t  track 
) const

Given a NuEvent, calculates the Perpendicular strip flags.

Definition at line 5642 of file NuReco.cxx.

References NuEvent::detector, NuEvent::edgeRegionTrkEnd, NuEvent::edgeRegionTrkVtx, GetPerpendicularStripFlag(), Msg::kError, MSG, NuEvent::stripTrkBegIsu, NuEvent::stripTrkBegPerpFlag, NuEvent::stripTrkEndIsu, and NuEvent::stripTrkEndPerpFlag.

Referenced by NuExtraction::ExtractNthTrkInfo(), and RecalculateDerivativeTrackGeometryVariables().

05643 {
05644   Detector::Detector_t det = static_cast<Detector::Detector_t>(nu.detector);
05645 
05646   if(track >= 1 && track <= 3){
05647     get_stripTrkBegPerpFlag(nu, track) = GetPerpendicularStripFlag
05648       (det, get_edgeRegionTrkVtx(nu, track), get_stripTrkBegIsu(nu, track));
05649     get_stripTrkEndPerpFlag(nu, track) = GetPerpendicularStripFlag
05650       (det, get_edgeRegionTrkEnd(nu, track), get_stripTrkEndIsu(nu, track));
05651   } else if (track == 0){
05652     // Special case: Recalcuate the best track
05653     nu.stripTrkBegPerpFlag = GetPerpendicularStripFlag(det, nu.edgeRegionTrkVtx, nu.stripTrkBegIsu);
05654     nu.stripTrkEndPerpFlag = GetPerpendicularStripFlag(det, nu.edgeRegionTrkEnd, nu.stripTrkEndIsu);
05655   } else {
05656     MSG("NuReco",Msg::kError) << "Unrecognised track id " << track << endl;
05657   }
05658 }

void NuReco::CapTrackMomentum ( Double_t &  trkMom  )  const

Definition at line 863 of file NuReco.cxx.

References Munits::GeV.

Referenced by GetTrackEnergyFromCurvCor(), and GetTrackEnergyFromRangeCor().

00864 {
00865   //cap the trkMom to avoid crazy values e.g. 1e19 causing fpes)
00866   if (trkMom>(1000*Munits::GeV)) trkMom=1000*Munits::GeV;
00867   else if (trkMom<(-1000*Munits::GeV)) trkMom=-1000*Munits::GeV;
00868 }

void NuReco::ChooseTruthIndexToUse ( NuEvent nu  )  const

Definition at line 3401 of file NuReco.cxx.

References NuEvent::mc, NuEvent::mcShw, and NuEvent::mcTrk.

Referenced by GetBestTruthIndex(), and GetPrimaryTruthIndex().

03402 {
03403   //use the track as the primary determination
03404   //else use the event
03405   //this can be changed for particular anaVersion as required
03406   //if (mcTrk>=0) nu.mc=nu.mcTrk;
03407   //else nu.mc=nu.mcEvt;
03408 
03409   //UPDATE 2007/12/10: use the mcEvt as the best guess for the mc index
03410   //this is what the generator reweighting example uses
03411   //nu.mc=nu.mcEvt;
03412 
03413   //UPDATE 2008/02/20: use trk or shw like the PANs do
03414   if (nu.mcTrk>=0) nu.mc=nu.mcTrk;
03415   else nu.mc=nu.mcShw;
03416 }

Int_t NuReco::FDRCBoundary ( const NuEvent nu  )  const

litag takes the value of 0,1,10,11, usually cut all >0

Definition at line 793 of file NuReco.cxx.

References NuEvent::detector, Detector::kFar, NuEvent::nshw, NuEvent::planeEvtHdrBeg, NuEvent::planeEvtHdrEnd, and NuEvent::rawPhEvt.

Referenced by NuExtraction::ExtractLITags(), and NuAnalysis::LIRejectionTest().

00794 {
00796   Int_t litag=0;
00797 
00798   if(nu.detector!=Detector::kFar) return litag;
00799 
00800   //Int_t numshower=eventSummary->nshower;
00801   //Float_t allph=eventSummary->ph.raw;
00802   //Int_t plbeg=eventSummary->plane.beg;
00803   //Int_t plend=eventSummary->plane.end;
00804   Int_t numshower=nu.nshw;
00805   Float_t allph=nu.rawPhEvt;
00806   //Int_t plbeg=nu.planeEvtBeg;
00807   //Int_t plend=nu.planeEvtEnd;
00808   Int_t plbeg=nu.planeEvtHdrBeg;//evthdr.plane.beg (diff. to above)
00809   Int_t plend=nu.planeEvtHdrEnd;//evthdr.plane.end
00810 
00811   if (numshower) {
00812     if (allph>1e6) litag+=10;
00813 
00814     if (((plbeg==1 || plbeg==2) && (plend==63 || plend==64)) ||
00815         ((plbeg==65 || plbeg==66) && (plend==127 || plend==128)) ||
00816         ((plbeg==129 || plbeg==130) && (plend==191 || plend==192)) ||
00817         ((plbeg==193 || plbeg==194) && (plend==247 || plend==248))) litag++;
00818     if (((plbeg==250 || plbeg==251) && (plend==312 || plend==313)) ||
00819         ((plbeg==314 || plbeg==315) && (plend==376 || plend==377)) ||
00820         ((plbeg==378 || plbeg==379) && (plend==440 || plend==441)) ||
00821         ((plbeg==442 || plbeg==443) && (plend==484 || plend==485))) litag++;
00822   }
00823   return litag;
00824 }

Double_t NuReco::Fin78WeightL010z185iDefocusedComponent ( const Double_t  true_enu  )  const

Definition at line 759 of file NuReco.cxx.

Referenced by Run9TargetDecayWeight().

00760 {
00761   //For reweighting FHC numubars or RHC numus
00762   double weight78;
00763 
00764   double decayPar[11];
00765 
00766   decayPar[0] = 1.01079;
00767   decayPar[1] = 0.0163014;
00768   decayPar[2] = -0.00951575;
00769   decayPar[3] = 0.00189497;
00770   decayPar[4] = -0.000114420;
00771   decayPar[5] = 0.745891;
00772   decayPar[6] = 0.0198691;
00773   decayPar[7] = -0.000440386;
00774   decayPar[8] = 1.22518;
00775   decayPar[9] = 1.04;
00776   decayPar[10] = -0.2;
00777 
00778   if(true_enu<8.6){
00779     weight78 = decayPar[0]+decayPar[1]*true_enu+decayPar[2]*true_enu*true_enu+decayPar[3]*true_enu*true_enu*true_enu+decayPar[4]*true_enu*true_enu*true_enu*true_enu;
00780   }
00781   else if(true_enu<15.5){
00782     weight78 = decayPar[5]+decayPar[6]*true_enu+decayPar[7]*true_enu*true_enu+decayPar[8]*(1./true_enu);
00783   }
00784   else {
00785     weight78 = decayPar[9]+decayPar[10]*(1./true_enu);
00786   }
00787 
00788   return weight78;
00789 }

Double_t NuReco::Fin78WeightL010z185iFocusedComponent ( const Double_t  true_enu  )  const

Definition at line 711 of file NuReco.cxx.

Referenced by Run9TargetDecayWeight().

00712 {
00713   //For reweighting FHC numus or RHC numubars
00714   double weight78;
00715 
00716   double decayPar[20];
00717 
00718   decayPar[0] =  9.91823e-01;
00719   decayPar[1] =  8.14956e-02;
00720   decayPar[2] = -1.44191e-01;
00721   decayPar[3] =  7.80651e-02;
00722   decayPar[4] = -1.29277e-02;
00723   decayPar[5] = -1.41734e-04;
00724   decayPar[6] =  3.62036e+00;
00725   decayPar[7] = -8.98865e-01;
00726   decayPar[8] =  9.61367e-02;
00727   decayPar[9] = -2.44885e+00;
00728   decayPar[10] =  6.81085e-01;
00729   decayPar[11] =  9.40087e-02;
00730   decayPar[12] = -6.50227e-03;
00731   decayPar[13] = -2.86720e+00;
00732   decayPar[14] = -1.14010e-01;
00733   decayPar[15] =  1.06866e-03;
00734   decayPar[16] =  1.77433e+00;
00735   decayPar[17] =  8.30457e+00;
00736   decayPar[18] =  1.018;
00737   decayPar[19] =  0.005;
00738 
00739   if(true_enu<2.875){
00740     weight78 = decayPar[0]+decayPar[1]*true_enu+decayPar[2]*true_enu*true_enu+decayPar[3]*true_enu*true_enu*true_enu+decayPar[4]*true_enu*true_enu*true_enu*true_enu+decayPar[5]*true_enu*true_enu*true_enu*true_enu*true_enu;
00741   }
00742   else if(true_enu<4.375){
00743     weight78 = decayPar[6]+decayPar[7]*true_enu+decayPar[8]*true_enu*true_enu+decayPar[9]*(1./true_enu);
00744   }
00745   else if(true_enu<7.460){
00746     weight78 = decayPar[10]+decayPar[11]*true_enu+decayPar[12]*true_enu*true_enu;
00747   }
00748   else if(true_enu<15.15){
00749     weight78 = decayPar[13]+decayPar[14]*true_enu+decayPar[15]*true_enu*true_enu+decayPar[16]*TMath::Log(true_enu)+decayPar[17]*(1./true_enu);
00750   }
00751   else{
00752     weight78 = decayPar[18]+decayPar[19]*(1./(true_enu-13.8));
00753   }
00754 
00755   return weight78;
00756 }

Int_t NuReco::GetBestShower ( const NuEvent nu  )  const

work out the best shower to use in the case that there is more than one

Definition at line 2204 of file NuReco.cxx.

References NuEvent::anaVersion, NuEvent::charge, GetPrimaryShowerCCStd(), GetPrimaryShowerNCStd(), GetPrimaryShowerStdReco(), NuCuts::kCC0093Std, NuCuts::kCC0250Std, NuCuts::kCC0325Std, NuCuts::kCC0720Std, NuCuts::kCC0720Test, NuCuts::kCC1070Std, NuCuts::kCC2014, NuCuts::kCC2014NewCoilCut, Msg::kInfo, NuCuts::kJJE1, NuCuts::kJJE2, NuCuts::kJJH1, NuCuts::kNCPRLCC, NuCuts::kNCPRLNC, NuCuts::kNMB0325Alpha, NuCuts::kNMB0325Bravo, NuCuts::kNMB0325BravoTwo, NuCuts::kNMB0325ChairSound, NuCuts::kNMB0325Charlie, NuCuts::kNMB0325Delta, NuCuts::kNMB0325Echo, NuCuts::kNMB0720Bravo, NuCuts::kNMB0720Charlie, NuCuts::kNMB0720RM, NuCuts::kNMBFree, NuCuts::kNSI2011Fhc, NuCuts::kNSI2011Rhc, NuCuts::kPreselectionNC2012, NuCuts::kRHC, NuCuts::kRHC0150Std, NuCuts::kRHC0350Std, NuCuts::kRM1, NuCuts::kRM2, and MAXMSG.

Referenced by NuCounter::CountTrkStdhepId(), NuAnalysis::DemoInfidSRInterface(), NuPlots::FillShwHistos(), GetBestTruthIndex(), and SetBestShw().

02205 {
02208 
02209   if (nu.anaVersion==NuCuts::kJJH1 ||
02210       nu.anaVersion==NuCuts::kJJE1 ||
02211       (nu.charge==+1 &&
02212        (nu.anaVersion == NuCuts::kNMB0325Alpha ||
02213         nu.anaVersion == NuCuts::kNMB0325Bravo ||
02214         nu.anaVersion == NuCuts::kNMB0325BravoTwo ||
02215         nu.anaVersion == NuCuts::kNMB0325Charlie ||
02216         nu.anaVersion == NuCuts::kNMB0325Delta ||
02217         nu.anaVersion == NuCuts::kNMB0325Echo ||
02218         nu.anaVersion == NuCuts::kNMB0325ChairSound ||
02219         nu.anaVersion == NuCuts::kRM1 ||
02220         nu.anaVersion == NuCuts::kRM2 ||
02221         nu.anaVersion == NuCuts::kJJE2 ||
02222         nu.anaVersion == NuCuts::kNMBFree ||
02223         nu.anaVersion == NuCuts::kRHC))) {
02224     MAXMSG("NuReco",Msg::kInfo,1)
02225       <<"Setting best shower as primary shower (from reconstruction)"
02226       <<endl;
02227     return this->GetPrimaryShowerStdReco(nu);
02228   }
02229   else if (nu.anaVersion==NuCuts::kCC0093Std) {
02230     MAXMSG("NuReco",Msg::kInfo,1)
02231       <<"Setting best shower according to CC std"<<endl;
02232     return this->GetPrimaryShowerCCStd(nu);
02233   }
02234   else if (nu.anaVersion==NuCuts::kCC0250Std ||
02235            nu.anaVersion==NuCuts::kCC0325Std ||
02236            nu.anaVersion==NuCuts::kCC0720Test ||
02237            (nu.charge==-1 &&
02238             (nu.anaVersion == NuCuts::kNMB0325Alpha ||
02239              nu.anaVersion == NuCuts::kNMB0325Bravo ||
02240              nu.anaVersion == NuCuts::kNMB0325BravoTwo ||
02241              nu.anaVersion == NuCuts::kNMB0325Charlie ||
02242              nu.anaVersion == NuCuts::kNMB0325Delta ||
02243              nu.anaVersion == NuCuts::kNMB0325Echo ||
02244              nu.anaVersion == NuCuts::kNMB0325ChairSound ||
02245              nu.anaVersion == NuCuts::kRM1 ||
02246              nu.anaVersion == NuCuts::kRM2 ||
02247              nu.anaVersion == NuCuts::kJJE2 ||
02248              nu.anaVersion == NuCuts::kNMBFree ||
02249              nu.anaVersion == NuCuts::kRHC))) {
02250     MAXMSG("NuReco",Msg::kInfo,1)
02251       <<"Setting best shower according to CC std"<<endl;
02252     return this->GetPrimaryShowerCCStd(nu);
02253   }
02254   else if (nu.anaVersion==NuCuts::kCC0720Std ||
02255            nu.anaVersion==NuCuts::kCC2014||
02256            nu.anaVersion==NuCuts::kCC2014NewCoilCut||
02257            nu.anaVersion==NuCuts::kCC1070Std ||
02258            nu.anaVersion==NuCuts::kRHC0150Std ||
02259            nu.anaVersion==NuCuts::kRHC0350Std ||
02260            nu.anaVersion==NuCuts::kNSI2011Fhc ||
02261            nu.anaVersion==NuCuts::kNSI2011Rhc ||
02262            nu.anaVersion==NuCuts::kNMB0720Bravo ||
02263            nu.anaVersion==NuCuts::kNMB0720RM ||
02264            nu.anaVersion==NuCuts::kNMB0720Charlie) {
02265     MAXMSG("NuReco",Msg::kInfo,1)
02266       <<"Setting best shower as primary shower (from reconstruction)"
02267       <<endl;
02268     return this->GetPrimaryShowerStdReco(nu);
02269   }
02270   else if (nu.anaVersion == NuCuts::kPreselectionNC2012 ||
02271            nu.anaVersion == NuCuts::kNCPRLNC ||
02272            nu.anaVersion == NuCuts::kNCPRLCC) {
02273     MAXMSG("NuReco",Msg::kInfo,1)
02274       <<"Setting best shower as first shower"
02275       <<endl;
02276     return this->GetPrimaryShowerNCStd(nu);
02277   }
02278   else {
02279     MAXMSG("NuReco",Msg::kInfo,1)
02280       <<"Setting best shower as primary shower (from reconstruction)"
02281       <<endl;
02282     return this->GetPrimaryShowerStdReco(nu);
02283   }
02284 }

Int_t NuReco::GetBestTrack ( const NuEvent nu  )  const

can be either the longest track or the one defined as the primary track by the reconstruction (evt.trk[0])

Definition at line 2096 of file NuReco.cxx.

References NuEvent::anaVersion, GetLongestPathLengthTrack(), GetLongestTrack(), GetPrimaryTrack(), NuCuts::kCC0093Std, NuCuts::kCC0250Std, NuCuts::kCC0325Std, NuCuts::kCC0720Std, NuCuts::kCC0720Test, NuCuts::kCC1070Std, NuCuts::kCC2014, NuCuts::kCC2014NewCoilCut, Msg::kInfo, NuCuts::kJJE1, NuCuts::kJJE2, NuCuts::kJJH1, NuCuts::kNCPRLCC, NuCuts::kNCPRLNC, NuCuts::kNMB0325Alpha, NuCuts::kNMB0325Bravo, NuCuts::kNMB0325BravoTwo, NuCuts::kNMB0325ChairSound, NuCuts::kNMB0325Charlie, NuCuts::kNMB0325Delta, NuCuts::kNMB0325Echo, NuCuts::kNMB0720Bravo, NuCuts::kNMB0720Charlie, NuCuts::kNMB0720RM, NuCuts::kNMBFree, NuCuts::kNSI2011Fhc, NuCuts::kNSI2011Rhc, NuCuts::kPreselectionNC2012, NuCuts::kRHC, NuCuts::kRHC0150Std, NuCuts::kRHC0350Std, NuCuts::kRM1, NuCuts::kRM2, and MAXMSG.

Referenced by NuDemoModule::Ana(), NuAnalysis::ChargeSeparationOneSnarl(), NuAnalysis::DemoInfidSRInterface(), NuAnalysis::EnergySpect(), NuPlots::FillShwHistos(), GetBestTruthIndex(), NuAnalysis::N_1(), SetBestTrk(), SetBestTrkMajorityCurvature(), and SetBestTrkSAFit().

02097 {
02098   //work out the best track to use in the case that there is
02099   //more than one
02102 
02103   if (nu.anaVersion==NuCuts::kJJH1 ||
02104       nu.anaVersion==NuCuts::kJJE1 ||
02105       nu.anaVersion == NuCuts::kNMB0325Alpha ||
02106       nu.anaVersion == NuCuts::kNMB0325Bravo ||
02107       nu.anaVersion == NuCuts::kNMB0325BravoTwo ||
02108       nu.anaVersion == NuCuts::kNMB0325Charlie ||
02109       nu.anaVersion == NuCuts::kNMB0325Delta ||
02110       nu.anaVersion == NuCuts::kNMB0325Echo ||
02111       nu.anaVersion == NuCuts::kNMB0325ChairSound ||
02112       nu.anaVersion == NuCuts::kRM1 ||
02113       nu.anaVersion == NuCuts::kRM2 ||
02114       nu.anaVersion == NuCuts::kJJE2 ||
02115       nu.anaVersion == NuCuts::kNMBFree ||
02116       nu.anaVersion == NuCuts::kRHC) {
02117     MAXMSG("NuReco",Msg::kInfo,1)
02118       <<"Setting best track as longest track"<<endl;
02119     return this->GetLongestTrack(nu);
02120   }
02121   else if (nu.anaVersion == NuCuts::kPreselectionNC2012 ||
02122            nu.anaVersion == NuCuts::kNCPRLNC ||
02123            nu.anaVersion == NuCuts::kNCPRLCC) {
02124     // MJM Fixed to use path length
02125     // for 2012 sterile analysis
02126     MAXMSG("NuReco",Msg::kInfo,1)
02127       << "Setting best track as longest path-length track" << endl;
02128     return this->GetLongestPathLengthTrack(nu);
02129   }
02130   else if (nu.anaVersion==NuCuts::kCC0093Std) {
02131     MAXMSG("NuReco",Msg::kInfo,1)
02132       <<"Setting best track as longest track"<<endl;
02133     return this->GetLongestTrack(nu);
02134   }
02135   else if (nu.anaVersion==NuCuts::kCC0250Std ||
02136            nu.anaVersion==NuCuts::kCC0325Std ||
02137            nu.anaVersion==NuCuts::kCC0720Test) {
02138     MAXMSG("NuReco",Msg::kInfo,1)
02139       <<"Setting best track as longest track"<<endl;
02140     return this->GetLongestTrack(nu);
02141   }
02142   else if (nu.anaVersion==NuCuts::kCC0720Std ||
02143            nu.anaVersion==NuCuts::kCC2014||
02144            nu.anaVersion==NuCuts::kCC2014NewCoilCut||
02145            nu.anaVersion==NuCuts::kCC1070Std ||
02146            nu.anaVersion==NuCuts::kRHC0150Std ||
02147            nu.anaVersion==NuCuts::kRHC0350Std ||
02148            nu.anaVersion==NuCuts::kNSI2011Fhc ||
02149            nu.anaVersion==NuCuts::kNSI2011Rhc ||
02150            nu.anaVersion==NuCuts::kNMB0720Bravo ||
02151            nu.anaVersion==NuCuts::kNMB0720RM ||
02152            nu.anaVersion==NuCuts::kNMB0720Charlie) {
02153     MAXMSG("NuReco",Msg::kInfo,1)
02154       <<"Setting best track as primary track (from reconstruction)"
02155       <<endl;
02156     return this->GetPrimaryTrack(nu);
02157   }
02158   else {
02159     MAXMSG("NuReco",Msg::kInfo,1)
02160       <<"Setting best track as primary track (from reconstruction)"
02161       <<endl;
02162     return this->GetPrimaryTrack(nu);
02163   }
02164 }

void NuReco::GetBestTruthIndex ( const NtpStRecord ntp,
const NtpSREvent evt,
NuEvent nu 
) const

Definition at line 3235 of file NuReco.cxx.

References ChooseTruthIndexToUse(), GetBestShower(), GetBestTrack(), GetShowerWithIndexX(), GetTrackWithIndexX(), NtpSRTrack::index, NtpSRShower::index, NtpSREvent::index, Msg::kDebug, MAXMSG, NuEvent::mcEvt, NuEvent::mcShw, NuEvent::mcTrk, NtpTHEvent::neumc, NtpTHShower::neumc, NtpTHTrack::neumc, NtpStRecord::thevt, NtpStRecord::thshw, and NtpStRecord::thtrk.

03237 {
03238   TClonesArray& thevtTca=(*ntp.thevt);//TruthHelper Event TCA
03239   const Int_t numthevts=thevtTca.GetEntriesFast();
03240   if (numthevts<=0) {
03241     MAXMSG("NuReco",Msg::kDebug,1)
03242       <<"No THEvents, so can't GetBestTruthIndex..."<<endl;
03243     return;
03244   }
03245   MAXMSG("NuReco",Msg::kDebug,1)
03246     <<"Found THEvent, GetBestTruthIndex..."<<endl;
03247 
03248   Int_t mcTrk=-1;//track mc index
03249   Int_t mcShw=-1;//shower mc index
03250   Int_t mcEvt=-1;//event mc index
03251 
03252   const NtpTHEvent& thevt=
03253     *dynamic_cast<NtpTHEvent*>(thevtTca[evt.index]);
03254   mcEvt=thevt.neumc;
03255 
03256   //get an instance of the code library
03257   //const NuLibrary& lib=NuLibrary::Instance();
03258 
03259   //get the shower mc
03260   TClonesArray& thshwTca=(*ntp.thshw);//TruthHelper Shower TCA
03261   const Int_t numthshws=thshwTca.GetEntriesFast();
03262   if (numthshws>0) {
03263     Int_t bestShower=this->GetBestShower(nu);
03264     const NtpSRShower* pshw=this->GetShowerWithIndexX(ntp,evt,
03265                                                       bestShower-1);
03266     if (pshw) {
03267       const NtpSRShower& shw=*pshw;
03268       const NtpTHShower& thshw=
03269         *dynamic_cast<NtpTHShower*>(thshwTca[shw.index]);
03270       mcShw=thshw.neumc;
03271     }
03272   }
03273 
03274   //get the track mc
03275   TClonesArray& thtrkTca=(*ntp.thtrk);//TruthHelper Track TCA
03276   const Int_t numthtrks=thtrkTca.GetEntriesFast();
03277   if (numthtrks>0) {
03278     Int_t bestTrack=this->GetBestTrack(nu);
03279     const NtpSRTrack* ptrk=this->GetTrackWithIndexX(ntp,evt,
03280                                                     bestTrack-1);
03281     if (ptrk) {
03282       const NtpSRTrack& trk=*ptrk;
03283       const NtpTHTrack& thtrk=
03284         *dynamic_cast<NtpTHTrack*>(thtrkTca[trk.index]);
03285       mcTrk=thtrk.neumc;
03286     }
03287   }
03288 
03289   //set the variables in the object
03290   nu.mcTrk=mcTrk;
03291   nu.mcShw=mcShw;
03292   nu.mcEvt=mcEvt;
03293   this->ChooseTruthIndexToUse(nu);
03294 }

Int_t NuReco::GetContainmentFlag ( const NuEvent nu  )  const

Definition at line 3722 of file NuReco.cxx.

References NuEvent::anaVersion, NuEvent::charge, NuEvent::containmentFlagCC0093Std, NuEvent::containmentFlagCC0250Std, NuEvent::containmentFlagPitt, NuEvent::detector, GetContainmentFlagNCPRL(), GetContainmentFlagStdReco(), ReleaseType::IsBirch(), NuCuts::kCC0093Std, NuCuts::kCC0250Std, NuCuts::kCC0325Std, NuCuts::kCC0720Std, NuCuts::kCC0720Test, NuCuts::kCC1070Std, NuCuts::kCC2014, NuCuts::kCC2014NewCoilCut, Detector::kFar, Msg::kInfo, NuCuts::kJJE2, NuCuts::kNCPRLCC, NuCuts::kNCPRLNC, Detector::kNear, NuCuts::kNMB0325Alpha, NuCuts::kNMB0325Bravo, NuCuts::kNMB0325BravoTwo, NuCuts::kNMB0325ChairSound, NuCuts::kNMB0325Charlie, NuCuts::kNMB0325Delta, NuCuts::kNMB0325Echo, NuCuts::kNMBFree, NuCuts::kNSI2011Fhc, NuCuts::kNSI2011Rhc, NuCuts::kRHC, NuCuts::kRHC0150Std, NuCuts::kRHC0350Std, NuCuts::kRM1, NuCuts::kRM2, Msg::kWarning, Munits::m, MAXMSG, MSG, NuEvent::planeTrkEnd, NuEvent::recoVersion, NuEvent::rTrkEnd, and NuEvent::xTrkEnd.

Referenced by CalcTrkVariables().

03723 {
03724   Int_t flag=-1;
03725 
03726   //now set the containment flag
03727   if (nu.anaVersion==NuCuts::kCC0093Std) {
03728     MAXMSG("NuReco",Msg::kInfo,1)
03729       <<"Using CC0093Std containment criteria"<<endl;
03730     flag=nu.containmentFlagCC0093Std;
03731   }
03732   else if (nu.anaVersion==NuCuts::kCC0250Std) {
03733     MAXMSG("NuReco",Msg::kInfo,1)
03734       <<"Using CC0250Std containment criteria"<<endl;
03735     flag=nu.containmentFlagCC0250Std;
03736   }
03737   else if (nu.anaVersion==NuCuts::kCC0325Std ||
03738            nu.anaVersion==NuCuts::kCC0720Test||
03739            (nu.charge==-1 &&
03740             (nu.anaVersion == NuCuts::kNMB0325Alpha ||
03741              nu.anaVersion == NuCuts::kNMB0325Bravo ||
03742              nu.anaVersion == NuCuts::kNMB0325BravoTwo ||
03743              nu.anaVersion == NuCuts::kNMB0325Charlie ||
03744              nu.anaVersion == NuCuts::kNMB0325Delta ||
03745              nu.anaVersion == NuCuts::kNMB0325Echo ||
03746              nu.anaVersion == NuCuts::kNMB0325ChairSound ||
03747              nu.anaVersion == NuCuts::kRM1 ||
03748              nu.anaVersion == NuCuts::kRM2 ||
03749              nu.anaVersion == NuCuts::kJJE2 ||
03750              nu.anaVersion == NuCuts::kNMBFree ||
03751              nu.anaVersion == NuCuts::kRHC))) {
03752     MAXMSG("NuReco",Msg::kInfo,1)
03753       <<"Using CC0325Std hybrid containment criteria"<<endl;
03754     flag=nu.containmentFlagCC0250Std;
03755     //in ND use the hybrid approach to reduce the bias that occurs for
03756     //events exiting the side of the detector and being reco'd by range
03757     if (nu.detector==Detector::kNear) {
03758       if (nu.xTrkEnd>1.3*Munits::m) {
03759         flag=this->GetContainmentFlagStdReco(nu);
03760       }
03761     }
03762   }
03763   else if (nu.anaVersion==NuCuts::kCC0720Std ||
03764            nu.anaVersion==NuCuts::kCC1070Std ||
03765            nu.anaVersion==NuCuts::kRHC0150Std ||
03766            nu.anaVersion==NuCuts::kRHC0350Std ||
03767            nu.anaVersion==NuCuts::kNSI2011Fhc ||
03768            nu.anaVersion==NuCuts::kNSI2011Rhc) {
03769     MAXMSG("NuReco",Msg::kInfo,1)
03770       <<"Using CC0325Std hybrid containment criteria"<<endl;
03771     flag=nu.containmentFlagCC0250Std;
03772     //in ND use the hybrid approach to reduce the bias that occurs for
03773     //events exiting the side of the detector and being reco'd by range
03774     if (nu.detector==Detector::kNear) {
03775       if (nu.xTrkEnd>1.3*Munits::m) {
03776         flag=this->GetContainmentFlagStdReco(nu);
03777       }
03778     }
03779     //In the FD, events that end near the coil hole should have
03780     //energy taken from curvature, not range
03781     if (nu.detector==Detector::kFar) {
03782       if (nu.rTrkEnd<0.4*Munits::m) {
03783         flag=2;
03784       }
03785     }
03786   }
03787   else if (nu.anaVersion==NuCuts::kCC2014||nu.anaVersion==NuCuts::kCC2014NewCoilCut) {
03788     MAXMSG("NuReco",Msg::kInfo,1)
03789       <<"Using CC0325Std hybrid containment criteria"<<endl;
03790     flag=nu.containmentFlagCC0250Std;
03791     //in ND use the hybrid approach to reduce the bias that occurs for
03792     //events exiting the side of the detector and being reco'd by range
03793     if (nu.detector==Detector::kNear) {
03794       if (nu.xTrkEnd>1.3*Munits::m) {
03795         flag=this->GetContainmentFlagStdReco(nu);
03796       }
03797       //In the ND events ending in planes 119-120 should have energy
03798       //taken from curvature not range
03799       if(nu.planeTrkEnd==119||nu.planeTrkEnd==120){
03800         flag=4;
03801       }
03802       // Need to use curvature for tracks ending near the coil hole in the spectrometer
03803       if(nu.anaVersion==NuCuts::kCC2014NewCoilCut && nu.planeTrkEnd > 120){
03804         if(nu.rTrkEnd < 0.8){
03805           flag = 4;
03806         }
03807       }
03808     }
03809     //In the FD, events that end near the coil hole should have
03810     //energy taken from curvature, not range
03811     if (nu.detector==Detector::kFar) {
03812       if (nu.rTrkEnd<0.4*Munits::m) {
03813         flag=2;
03814       }
03815     }
03816   }
03817   else if (nu.anaVersion == NuCuts::kNCPRLNC ||
03818            nu.anaVersion == NuCuts::kNCPRLCC) {
03819     MAXMSG("NuReco",Msg::kInfo,1)
03820       <<"Using NC PRL containment criteria"<<endl;
03821     flag = this->GetContainmentFlagNCPRL(nu);
03822   }
03823   else {
03824     if (ReleaseType::IsBirch(nu.recoVersion)) {
03825       MAXMSG("NuReco",Msg::kInfo,1)
03826         <<"Using Pitt containment criteria"<<endl;
03827       //note that trk.contained is not available before Cedar
03828       flag=nu.containmentFlagPitt;
03829     }
03830     else {
03831       MAXMSG("NuReco",Msg::kInfo,1)
03832         <<"Using std reco containment criteria"<<endl;
03833       flag=this->GetContainmentFlagStdReco(nu);
03834     }
03835   }
03836 
03837   //sanity check
03838   if (!(flag==1 || flag==2 || flag==3 || flag==4)) {
03839     MSG("NuReco",Msg::kWarning)<<"flag="<<flag<<endl;
03840   }
03841 
03842   //return the containment flag
03843   return flag;
03844 }

Int_t NuReco::GetContainmentFlagCC0093Std ( const NuEvent nu  )  const

Definition at line 3946 of file NuReco.cxx.

References NuEvent::detector, NuEvent::drTrkFidall, NuEvent::dzTrkFidall, Detector::kFar, Detector::kNear, NuEvent::xTrkEnd, NuEvent::yTrkEnd, and NuEvent::zTrkEnd.

Referenced by CalcTrkVariables().

03947 {
03948   const Float_t x=nu.xTrkEnd;
03949   const Float_t y=nu.yTrkEnd;
03950   const Float_t z=nu.zTrkEnd;
03951   const Float_t r=sqrt(x*x+y*y);
03952 
03953   const Float_t xMin=-1.65;
03954   const Float_t xMax=+2.7;
03955   const Float_t yMin=-1.65;
03956   const Float_t yMax=+1.65;
03957   const Float_t zMax=+16;
03958   const Float_t rMin=+0.4;
03959   const Float_t rMinFD=+0.5;
03960 
03961   Bool_t contained=false;
03962   Int_t flag=-1;
03963 
03964   //taken from the code below
03965   /*
03966     Bool_t MadQuantities::IsFidAll(Int_t itrk){
03967     if (!(ntpTrack->end.z<16 && sqrt(pow(ntpTrack->end.x,2)+
03968     pow(ntpTrack->end.y,2))>0.4 &&
03969     ntpTrack->end.x<2.7 && ntpTrack->end.x>-1.65 &&
03970     ntpTrack->end.y<1.65 && ntpTrack->end.y>-1.65 &&
03971 
03972     ntpTrack->end.y>(-ntpTrack->end.x)-1.65 &&
03973     ntpTrack->end.y<ntpTrack->end.x+1.65 &&
03974     ntpTrack->end.y<(-ntpTrack->end.x)+3.55 &&
03975     ntpTrack->end.y>ntpTrack->end.x-3.55)) {return false;}
03976 
03977 
03978     }
03979     else if(ntpTrack->fidall.dr<0.5 ||
03980     ntpTrack->fidall.dz<0.5) return false;
03981   */
03982 
03983   if (nu.detector==Detector::kNear) {
03984     //calculate if contained
03985     //don't understand the last 4 lines... ND shape?
03986     contained=z<zMax && r>rMin &&
03987       x>xMin && x<xMax &&
03988       y>yMin && y<yMax &&
03989       y>-x+xMin &&
03990       y<+x-xMin &&
03991       y<-x+3.55 &&
03992       y>+x-3.55;
03993 
03994     if (contained) {
03995       //117=~6.95 m
03996       //118=~7.01 m
03997       //119=~7.07 m
03998       //120=~7.13 m (partial)
03999       //121=~7.18 m (full)
04000       //122=~7.24 m
04001       if (z<7) flag=1;//planes 1->117 inclusive
04002       else if (z>=7) flag=3;//planes 118 onwards
04003     }
04004     else {
04005       if (z<7) flag=2;
04006       else if (z>=7) flag=4;
04007     }
04008   }
04009   else if (nu.detector==Detector::kFar) {
04010     contained=!(nu.drTrkFidall<rMinFD || nu.dzTrkFidall<rMinFD);
04011     if (contained) flag=1;
04012     else flag=2;
04013   }
04014   else cout<<"Ahh, detector="<<nu.detector<<endl;
04015 
04016   return flag;
04017 }

Int_t NuReco::GetContainmentFlagCC0250Std ( const NuEvent nu  )  const

Definition at line 3881 of file NuReco.cxx.

References NuEvent::detector, Detector::kFar, Detector::kNear, Munits::m, NuEvent::planeTrkEnd, NuEvent::xTrkEnd, NuEvent::yTrkEnd, and NuEvent::zTrkEnd.

Referenced by CalcTrkVariables().

03882 {
03883   const Float_t x=nu.xTrkEnd;
03884   const Float_t y=nu.yTrkEnd;
03885   const Float_t z=nu.zTrkEnd;
03886   const Float_t r=sqrt(x*x+y*y);//FD only
03887 
03888   //minos-doc-3156 has these values:
03889   //ND cuts:
03890   const Float_t xMin=-1.65*(Munits::m);
03891   const Float_t xMax=+2.7*(Munits::m);
03892   const Float_t yMin=-1.65*(Munits::m);
03893   const Float_t yMax=+1.65*(Munits::m);
03894   //const Float_t uMin=-1.65*(Munits::m);
03895   const Float_t uMax=+3.55*(Munits::m);
03896   //const Float_t vMin=-3.55*(Munits::m);
03897   //const Float_t vMax=+1.65*(Munits::m);
03898   const Float_t zMax=+15*(Munits::m);
03899 
03900   //FD cuts
03901   const Float_t planeMin=4;
03902   const Float_t planeMax=475;
03903   const Float_t rMax=TMath::Sqrt(14)*(Munits::m);
03904 
03905   Bool_t contained=false;
03906   Int_t flag=-1;
03907 
03908   if (nu.detector==Detector::kNear) {
03909     contained=z<zMax &&
03910       x>xMin && x<xMax &&
03911       y>yMin && y<yMax &&
03912       y>-x+xMin &&
03913       y<+x-xMin &&
03914       y<-x+uMax &&
03915       y>+x-uMax;
03916 
03917     if (contained) {
03918       //117=~6.95 m
03919       //118=~7.01 m
03920       //119=~7.07 m
03921       //120=~7.13 m (partial)
03922       //121=~7.18 m (full)
03923       //122=~7.24 m
03924       if (z<7) flag=1;//planes 1->117 inclusive
03925       else if (z>=7) flag=3;//planes 118 onwards
03926     }
03927     else {
03928       if (z<7) flag=2;
03929       else if (z>=7) flag=4;
03930     }
03931   }
03932   else if (nu.detector==Detector::kFar) {
03933     contained=nu.planeTrkEnd>=planeMin &&
03934       nu.planeTrkEnd<=planeMax &&
03935       r<rMax;
03936     if (contained) flag=1;
03937     else flag=2;
03938   }
03939   else cout<<"Ahh, detector="<<nu.detector<<endl;
03940 
03941   return flag;
03942 }

Int_t NuReco::GetContainmentFlagNCPRL ( const NuEvent nu  )  const

Definition at line 4021 of file NuReco.cxx.

References NuEvent::detector, Detector::kFar, Detector::kNear, Munits::m, NuEvent::xTrkEnd, NuEvent::yTrkEnd, NuEvent::zTrkEnd, and NuEvent::zTrkVtx.

Referenced by GetContainmentFlag().

04021                                                              {
04022   const Float_t x = nu.xTrkEnd;
04023   const Float_t y = nu.yTrkEnd;
04024   const Float_t z = nu.zTrkEnd;
04025   const Float_t r = sqrt(x * x + y * y); //FD only
04026   const Float_t u = sqrt(0.5) * (x + y);
04027   const Float_t v = sqrt(0.5) * (y - x);
04028 
04029   const Float_t zSM1Min = 0.5  * (Munits::m);
04030   const Float_t zSM1Max = 12.0 * (Munits::m);
04031   const Float_t zSM2Min = 16.5 * (Munits::m);
04032   const Float_t zSM2Max = 28.0 * (Munits::m);
04033 
04034   // Calculate deltaZ from track end to projected point of exit
04035   // Simplify it to be distance from track end to edge of detector
04036   // Use far edge for forward-going tracks (zSM2Max), and near edge
04037   // for backward-going tracks (z = 0)
04038   Float_t deltaZ = 0.0;
04039   bool posDir = nu.zTrkEnd - nu.zTrkVtx > 0;
04040   if (posDir) {
04041     deltaZ = TMath::Abs(zSM2Max - z); // MJM need to check this
04042   } else {
04043     deltaZ = z;
04044   }
04045 
04046   Int_t flag = -1;
04047 
04048   // need to add traceEndZ > 0.5 to FD cut
04049   if (nu.detector == Detector::kFar) {
04050     if (r < 3.5 && (zSM1Min < z < zSM1Max) ||
04051         (zSM2Min < z < zSM2Max) && (deltaZ < 0.5)) {
04052       flag = 1;
04053     } else {
04054       flag = 3;
04055     } 
04056 
04057   } else if (nu.detector == Detector::kNear) {
04058     if (0.3 < u && u < 1.8
04059         && -1.8 < v && v < -0.3
04060         && x < 2.4
04061         && TMath::Sqrt(u * u + v * v) > 0.8
04062         && z < 15.0 ) {
04063       if (z < 7) {
04064         flag = 1;
04065       } else if (z >= 7) {
04066         flag = 3;
04067       }
04068     } else {
04069       if (z < 7) {
04070         flag = 2;
04071       } else if (z >= 7) {
04072         flag = 4;
04073       }
04074     }
04075   } else {
04076     cout << "Ahh, detector=" << nu.detector << endl;
04077   }
04078 
04079   return flag;
04080 }

Int_t NuReco::GetContainmentFlagPitt ( const NuEvent nu  )  const

Calc Pittsburgh (Donna/Debdatta) containment flag

containmentFlagPitt for ND: 1 = track is fully contained in the upstream region 2 = track is partially contained in the upstream region 3 = track is fully contained in the downstream region 4 = track is partially contained in the downstream region

containmentFlagPitt for FD: 1 = track is fully contained 2 = track is partially contained

Definition at line 4085 of file NuReco.cxx.

References NuEvent::detector, NuEvent::drTrkFidall, NuEvent::dzTrkFidall, Detector::kFar, Detector::kNear, Msg::kWarning, Munits::m, MSG, Munits::rad, NuEvent::uTrkEnd, NuEvent::vTrkEnd, NuEvent::xTrkEnd, NuEvent::yTrkEnd, and NuEvent::zTrkEnd.

Referenced by CalcTrkVariables().

04086 {
04088 
04094 
04098 
04099   Int_t containmentFlagPitt=0;
04100 
04101   const Float_t x=nu.xTrkEnd;
04102   const Float_t y=nu.yTrkEnd;
04103   const Float_t z=nu.zTrkEnd;
04104   const Float_t u=nu.uTrkEnd;
04105   const Float_t v=nu.vTrkEnd;
04106   const Float_t rad=sqrt(x*x + y*y);
04107 
04108   //the total number of instrumented planes will be 153 since
04109   //0 is a bookend and 32*4=128 are uninstrumented in the spectrometer
04110 
04111   //Different regions in the ND:
04112   //Breakdown of number of planes:
04113   // Veto=21 planes numbered 0-20 (1st is steel bookend)
04114   // Target=40 planes numbered 21-60
04115   // Shower=60 planes numbered 61-120
04116   // Spectrometer=161 planes 121-281
04117   //   First and last are instrumented
04118   //   33 have scintillator, 128 are steel
04119   //   4 steel planes for each one with scintillator,
04120   //   Altogether: 5*32=160, 160+1 at end=161
04121 
04122   //Number of strips:
04123   //Forward section:
04124   //96 planes with 64 strips
04125   //24 planes with 96 strips
04126   //Spectrometer section:
04127   //33 planes with 96 strips
04128   //96+24+33=153 instrumented in total
04129 
04130   //strips TPos:
04131   //plane 6 (full) goes -2.64 -> 1.32 m
04132   //plane 11 (full) goes -1.32 -> 2.64 m
04133   //plane 4,8,10 (partial) goes -2.40 -> 0.24 m (V-view)
04134   //plane 5,7,9 (partial) goes -0.24 -> 2.40 m (U-view)
04135   //2.64 - 2.40 = 24 cm = 5.85 strips
04136   //the FI planes "stick out" by ~6 strips
04137 
04138   //Tobi's code snippet:
04139   // in the near detector, a further check is needed:
04140   // partial U planes have strips 0-63
04141   // partial V planes have strips 4-67
04142   //if (det==static_cast<Detector::Detector_t>(s.Detector)) {
04143   //  if (((pl-1)%5) && (pl%2)    && st>63) continue;
04144   //  if (((pl-1)%5) && (pl%2)==0 && st<4 ) continue;
04145   //}
04146 
04147   //scintillator plane positions:
04148   //first full plane has z=~??? (plane 1)
04149   //last partial plane has z=~7.13 m (plane 120)
04150   //first full spect plane has z=~7.18 m (plane 121)
04151   //last spect plane z=~16.62 m (plane 281)
04152   //117=~6.95 m
04153   //118=~7.01 m
04154   //119=~7.07 m
04155   //120=~7.13 m (partial)
04156   //121=~7.18 m (full)
04157   //122=~7.24 m
04158 
04159   if (nu.detector==Detector::kNear) {
04160     Float_t calZ=7*(Munits::m);
04161     Float_t specZ=15.6*(Munits::m);//same as Mad
04162     Float_t minR=0.8*(Munits::m);
04163 
04164     Bool_t down_stop=false;
04165     Bool_t down_exit=false;
04166     Bool_t up_stop=false;
04167     Bool_t up_exit=false;
04168 
04169     // downstream
04170     if (z>calZ) {
04171       if (u>-0.85 && u<2.1 &&
04172           v>-2.1 && v<0.85 &&
04173           x>-1.5 && x<2.4 &&
04174           y>-1.4 && y<1.4  &&
04175           rad>minR &&
04176           z>calZ && z<=specZ) down_stop=true;
04177       else down_exit=true;
04178     }
04179     //ustream
04180     else if (z<=calZ && z>=0) {
04181       if (u>0.3 && u<1.8 &&
04182           v>-1.8 && v<-0.3 &&
04183           x<2.4 &&
04184           rad>minR &&
04185           z<calZ && z>=0) up_stop=true;
04186       else up_exit=true;
04187     }
04188     else cout<<"Ahhh, z="<<z<<endl;
04189 
04190     // set the track's pitt flag
04191     if (down_stop) containmentFlagPitt = 3;
04192     if (up_stop  ) containmentFlagPitt = 1;
04193     if (down_exit) containmentFlagPitt = 4;
04194     if (up_exit  ) containmentFlagPitt = 2;
04195   }
04196   else if (nu.detector==Detector::kFar) {
04197     //just use CC one for now...
04198     const Float_t rMinFD=+0.5;
04199     Bool_t contained=!(nu.drTrkFidall<rMinFD || nu.dzTrkFidall<rMinFD);
04200     if (contained) containmentFlagPitt=1;
04201     else containmentFlagPitt=2;
04202   }
04203   else cout<<"Ahhh, detector="<<nu.detector<<endl;
04204 
04205   //sanity check
04206   if (!(containmentFlagPitt==1 || containmentFlagPitt==2 ||
04207         containmentFlagPitt==3 || containmentFlagPitt==4)) {
04208     MSG("NuReco",Msg::kWarning)
04209       <<"containmentFlagPitt="<<containmentFlagPitt<<endl;
04210   }
04211 
04212   return containmentFlagPitt;
04213 }

Int_t NuReco::GetContainmentFlagStdReco ( const NuEvent nu  )  const

Definition at line 3848 of file NuReco.cxx.

References NuEvent::containedTrk, NuEvent::detector, Detector::kFar, Detector::kNear, and NuEvent::zTrkEnd.

Referenced by GetContainmentFlag().

03849 {
03850   Int_t flag=-1;
03851 
03852   //117=~6.95 m
03853   //118=~7.01 m
03854   //119=~7.07 m
03855   //120=~7.13 m (partial)
03856   //121=~7.18 m (full)
03857   if (nu.detector==Detector::kNear) {
03858     if (nu.containedTrk) {
03859       //if (nu.zTrkEnd<7.15) flag=1;
03860       if (nu.zTrkEnd<7.0) flag=1;//make consistent with others
03861       else flag=3;
03862     }
03863     else {
03864       //if (nu.zTrkEnd<7.15) flag=2;
03865       if (nu.zTrkEnd<7.0) flag=2;//make consistent with others
03866       else flag=4;
03867     }
03868   }
03869   else if (nu.detector==Detector::kFar) {
03870     //either contained or not: no spectrometer in FD
03871     if (nu.containedTrk) flag=1;
03872     else flag=2;
03873   }
03874   else cout<<"Ahh, detector="<<nu.detector<<endl;
03875 
03876   return flag;
03877 }

Double_t NuReco::GetCosBetweenPr_Theta ( const NtpSRTrack trk  )  const

Retrieves the cos of the angle between the radial momentum and track vertex.

Definition at line 5078 of file NuReco.cxx.

References NtpSRMomentum::best, NtpSRVertex::dcosx, NtpSRVertex::dcosy, NtpSRTrack::momentum, NtpSRTrack::vtx, NtpSRVertex::x, and NtpSRVertex::y.

Referenced by NuExtraction::ExtractNthTrkInfo().

05079 {
05080   Double_t  x = trk.vtx.x,
05081     y = trk.vtx.y,
05082     // Need to reconsider this 'best' momentum - is this the right thing to do?
05083     px = trk.momentum.best * trk.vtx.dcosx,
05084     py = trk.momentum.best * trk.vtx.dcosy;
05085 
05086   // Calculate |a||b|
05087   Double_t  magxmagp = sqrt((x*x + y*y)*(px*px + py*py));
05088 
05089   // Return the cosine value, or zero if the magnitudes are zero
05090   if(magxmagp != 0) return (x*px + y*py)/magxmagp;
05091   else return 0; // yes, this does happen!
05092 }

Float_t NuReco::GetDirCosNu ( const NuEvent nu  )  const

Code from MadMKAnalysis

Definition at line 4796 of file NuReco.cxx.

References NuEvent::detector, Detector::kFar, Detector::kNear, NuEvent::trkvtxdcosy, and NuEvent::trkvtxdcosz.

04797 {
04799 
04800   Float_t dirCosNu=-999;
04801   if (nu.detector==Detector::kFar) {
04802     const Float_t bl_z = TMath::Cos(TMath::Pi()*3./180.); //3degree beam
04803     const Float_t bl_y = sqrt(1. - bl_z*bl_z);
04804     dirCosNu=nu.trkvtxdcosz*bl_z+nu.trkvtxdcosy*bl_y;
04805   }
04806   else if (nu.detector==Detector::kNear) {
04807     const Float_t nu_cos = -5.799E-2;
04808     const Float_t nu_sin = sqrt(1 -nu_cos*nu_cos);
04809     dirCosNu=nu.trkvtxdcosz*nu_sin + nu.trkvtxdcosy*nu_cos;
04810   }
04811   else cout<<"Ahhh, detector="<<nu.detector<<endl;
04812 
04813   //return dirCosNu
04814   return dirCosNu;
04815 }

void NuReco::GetDirCosNu ( const NtpSRTrack trk,
NuEvent nu 
) const

Definition at line 4819 of file NuReco.cxx.

References NtpSRVertex::dcosy, NtpSRVertex::dcosz, NuEvent::detector, NuEvent::dirCosNu, Detector::kFar, Detector::kNear, and NtpSRTrack::vtx.

Referenced by CalcKinematicVariables().

04820 {
04821   // Returns the cosine of the angle between the beam and the track
04822 
04823   // Original Code from MadMKAnalysis
04824 
04825   // Reworked 19th Aug 2009by Nick Devenish
04826   // Matt Strait and I discovered that the definition of beam
04827   // angle to the detectors is inconsistent between PANS, DSTs and
04828   // others. Matt did some research and got the 'Authoritative'
04829   // answers from Wes Smart at Fermilab. These are now in here.
04830   //   Far:   57.184957 millirad
04831   //  Near:  -58.297760 millirad
04832   // If we get a good, more citable source for these, they should go in
04833 
04834   if (nu.detector==Detector::kFar) {
04835     const Float_t bl_y = 0.057184957; // Sin approximation
04836     const Float_t bl_z = sqrt(1 - bl_y*bl_y);
04837     nu.dirCosNu=trk.vtx.dcosz*bl_z+trk.vtx.dcosy*bl_y;
04838   }
04839   else if (nu.detector==Detector::kNear) {
04840     /*
04841     // simple correction based on the vertical position
04842     float vtxy=0;
04843     if(vtx) vtxy=vtx[1]; // in meters
04844     // cosine of the typical neutrino angle in the yz plane
04845     // calculated as py / sqrt( py^2 + pz^2)
04846     float nu_cos = -5.799E-2;
04847     if(vtxy>-2.0 && vtxy<2.0){ //prevents further nuttyness if vtxy is silly
04848     nu_cos += vtxy*1.23304E-3
04849     + vtxy*vtxy*1.08212E-5
04850     + vtxy*vtxy*vtxy*(-4.634E-5);
04851     }
04852     */
04853     const Float_t bl_y = -0.058297760; // Sin approximation
04854     const Float_t bl_z = sqrt(1 - bl_y*bl_y);
04855     nu.dirCosNu=trk.vtx.dcosz*bl_z+trk.vtx.dcosy*bl_y;
04856   }
04857   else cout<<"Ahhh, detector="<<nu.detector<<endl;
04858 }

Int_t NuReco::GetEdgeRegion ( Detector::Detector_t  det,
const Float_t  phi 
) const

Calculates the edge region based on direct variables.

Definition at line 5525 of file NuReco.cxx.

References Detector::kFar.

05526 {
05527   /* Description of edge regions:
05528            2
05529        3  ____  1
05530          / +y \
05531       4 |   L+x| 0
05532          \____/
05533        5        7
05534            6
05535   */
05536 
05537   // Cannot currently define this for the near detector
05538   if (det != Detector::kFar) return -1;
05539 
05540   Float_t positiveangle = phi;
05541   // Force angle to range [0, 2pi] and convert to radians
05542   if(positiveangle < 0) positiveangle += 2*M_PI;
05543   const Float_t torad = M_PI/180;
05544 
05545   Float_t theoneang = atan(1.625/3.975); // points at corners
05546   if(positiveangle < theoneang) return 0;
05547   if(positiveangle < 90*torad - theoneang) return 1;
05548   if(positiveangle < 90*torad + theoneang) return 2;
05549   if(positiveangle < 180*torad - theoneang) return 3;
05550   if(positiveangle < 180*torad + theoneang) return 4;
05551   if(positiveangle < 270*torad - theoneang) return 5;
05552   if(positiveangle < 270*torad + theoneang) return 6;
05553   if(positiveangle < 360*torad - theoneang) return 7;
05554 
05555   // back around to the bottom half of the first side!
05556   return 0;
05557 }

Int_t NuReco::GetEdgeRegion ( const NtpStRecord rec,
const NtpSRVertex vertex 
) const

Retrieves the FD edge region from the SNTP.

Definition at line 5512 of file NuReco.cxx.

References VldContext::GetDetector(), RecRecordImp< T >::GetHeader(), GetPhi(), and RecHeader::GetVldContext().

Referenced by CalculateEdgeRegion(), and NuExtraction::ExtractNthTrkInfo().

05513 {
05514   // Get the detector
05515   Detector::Detector_t det = rec.GetHeader().GetVldContext().GetDetector();
05516   // SimFlag::SimFlag_t simFlag = rec.GetHeader().GetVldContext().GetSimFlag();
05517 
05518   // Technically shouldn't recalculate phi here, but no simple and consistent
05519   // way to get the already calculated value without passing in NuEvent, or
05520   return GetEdgeRegion(det, GetPhi(vtx));
05521 }

void NuReco::GetEvtDeltaTs ( const NtpStRecord ntp,
std::map< Int_t, Double_t > &  deltaTs 
) const
Double_t NuReco::GetEvtEnergy ( NuEvent nu,
bool  includekNN 
) const

Definition at line 88 of file NuReco.cxx.

References CalcEvtVariables(), CalcKinematicVariables(), CalcResolution(), CalcShwVariables(), CalcTrkReclamation(), CalcTrkVariables(), NuEvent::energy, NuEvent::energyCC, NuEvent::energyNC, NuEvent::energyNoRw, NuEvent::energyRM, Msg::kError, Msg::kWarning, MAXMSG, NuEvent::nshw, NuEvent::ntrk, NuEvent::primshw, NuEvent::primtrk, SetBestShw(), SetBestTrk(), NuEvent::shwEn, NuEvent::shwEnCC, NuEvent::shwEnCor1, NuEvent::shwEnCor2, NuEvent::shwEnCor3, NuEvent::shwEnCor4, NuEvent::shwEnCor5, NuEvent::shwEnNC, NuEvent::trkEn, NuEvent::trkEnCorCurv1, NuEvent::trkEnCorCurv2, NuEvent::trkEnCorCurv3, NuEvent::trkEnCorRange1, NuEvent::trkEnCorRange2, and NuEvent::trkEnCorRange3.

Referenced by NuDemoModule::Ana(), NuDSTAna::BRevAna(), NuAnalysis::ChargeSeparationOneSnarl(), NuDSTAna::Contamination(), NuDSTAna::ContaminationNQ(), NuDSTAna::DPSystematic(), NuAnalysis::EnergySpect(), NuAnalysis::EnergySpectMC(), NuDSTAna::FDTestAna(), NuUtilities::FixDogwoodQP(), NuDSTAna::FluxComponents(), NuCutImps::Preselection2014::InFidVol(), NuDSTAna::JeffsTestAna(), NuAnalysis::LIRejectionTest(), NuDSTAna::MakeCuts(), FoverNHistos::MakeDataPlots(), NuDSTAna::MakeFCTree(), NuAnalysis::MakeFullDST(), NuDSTAna::MakeMicroDST(), NuDSTAna::MakeMicroDst2010(), NuDSTAna::MakeMicroDst2014(), NuDSTAna::MakeMicroDstFakeData(), NuDSTAna::MakeMicroDstForCSSSystematics(), NuDSTAna::MakeMicroDstHe(), NuDSTAna::MakeMicroDstJJEPresel(), NuDSTAna::MakeMicroDstNC2012(), NuDSTAna::MakeMicroDstWithStdCCRecoAndCuts(), NuDSTAna::MakeResolutionBins(), NuDSTAna::MakeSelMicroDST(), NuDSTAna::MMRereco(), NuDSTAna::MMTransition(), NuDSTAna::MMTransSME(), NuAnalysis::N_1(), NuDSTAna::NDOsc(), NuDSTAna::NDQPRB(), NuDSTAna::NDTestAna(), NuDSTAna::NewFieldAna(), FoverNHistos::PrepareCCEventForPlotting(), TemplateAnalysisClass::PrepareEventForPlotting(), DataMCPlots::PrepareEventForPlotting(), FitTree::PrepareEvents(), FoverNHistos::PrepareNCEventForPlotting(), NuDSTAna::QPStudy(), NuDSTAna::RHCTest(), NuDSTAna::StdCCAna(), NuDSTAna::StdNMBAna(), and NuDSTAna::YStudy().

00089 {
00090   //copy trk/shw-1,-2,-3 across to trk/shw
00091   this->SetBestTrk(nu);
00092   this->SetBestShw(nu);
00093 
00094   //calc various variables once trk/shw decision is made
00095   this->CalcEvtVariables(nu);
00096   this->CalcTrkVariables(nu);
00097   this->CalcTrkReclamation(nu);
00098   this->CalcShwVariables(nu,includekNN);
00099 
00100   //the final calculations
00101   nu.energyCC=nu.trkEn+nu.shwEnCC;
00102   nu.energyNC=nu.shwEnNC;
00103   nu.energyRM=nu.trkEn;
00104 
00105   //set as CC by default, analysis user should change this if necessary
00106   nu.energy=nu.energyCC;
00107 
00108   //keep a record of the non-reweighted energy
00109   nu.energyNoRw=nu.energy;
00110 
00111   //calc y, w2, etc based on the final values of trk/shw energy
00112   this->CalcKinematicVariables(nu);
00113 
00114   //calc Cambridge event energy resolution
00115   //this has to be done after trk/shw energy is finalised
00116   this->CalcResolution(nu);
00117 
00118   //sanity check on numbers of trks/shws
00119   if (nu.ntrk>3 || nu.nshw>7) {
00120     MAXMSG("NuReco",Msg::kWarning,3)
00121       <<endl<<"Lots of trks/shws"
00122       <<", ntrk="<<nu.ntrk<<", nshw="<<nu.nshw
00123       <<", primtrk="<<nu.primtrk<<", primshw="<<nu.primshw
00124       <<", trkEn="<<nu.trkEn<<", shwEn="<<nu.shwEn
00125       <<endl
00126       <<"shwEn1="<<nu.shwEnCor1<<", shw2="<<nu.shwEnCor2
00127       <<", shw3="<<nu.shwEnCor3<<", shw4="<<nu.shwEnCor4
00128       <<", shw5="<<nu.shwEnCor5
00129       //<<", shw6="<<nu.shwEnCor6<<", shw7="<<nu.shwEnCor7
00130       <<endl
00131       <<"trkCv1="<<nu.trkEnCorCurv1<<", trkCv2="<<nu.trkEnCorCurv2
00132       <<", trkCv3="<<nu.trkEnCorCurv3<<endl
00133       <<"trkRg1="<<nu.trkEnCorRange1<<", trkRg2="<<nu.trkEnCorRange2
00134       <<", trkRg3="<<nu.trkEnCorRange3<<endl;
00135     if (nu.ntrk>3) {
00136       MAXMSG("NuReco",Msg::kError,300)
00137         <<endl<<"Lots of trks/shws"
00138         <<", ntrk="<<nu.ntrk<<", nshw="<<nu.nshw
00139         <<", primtrk="<<nu.primtrk<<", primshw="<<nu.primshw
00140         <<", trkEn="<<nu.trkEn<<", shwEn="<<nu.shwEn
00141         <<endl
00142         <<"shwEn1="<<nu.shwEnCor1<<", shw2="<<nu.shwEnCor2
00143         <<", shw3="<<nu.shwEnCor3<<", shw4="<<nu.shwEnCor4
00144         <<", shw5="<<nu.shwEnCor5
00145         //<<", shw6="<<nu.shwEnCor6<<", shw7="<<nu.shwEnCor7
00146         <<endl
00147         <<"trkCv1="<<nu.trkEnCorCurv1<<", trkCv2="<<nu.trkEnCorCurv2
00148         <<", trkCv3="<<nu.trkEnCorCurv3<<endl
00149         <<"trkRg1="<<nu.trkEnCorRange1<<", trkRg2="<<nu.trkEnCorRange2
00150         <<", trkRg3="<<nu.trkEnCorRange3<<endl;
00151     }
00152   }
00153 
00154   return nu.energy;
00155 }

Double_t NuReco::GetEvtMedianTime ( const NtpStRecord ntp,
const NtpSREvent evt 
) const

Definition at line 3193 of file NuReco.cxx.

References NtpSRStrip::index, it, Msg::kDebug, MAXMSG, NtpSREvent::nstrip, NtpSRStrip::ph1, NtpSRStrip::plane, NtpSRPulseHeight::sigcor, NtpSREvent::stp, NtpStRecord::stp, NtpSRStrip::strip, NtpSRStrip::time0, NtpSRStrip::time1, and NtpSRStrip::tpos.

Referenced by NuAnalysis::EnergySpectMC().

03195 {
03196   //Msg::LogLevel_t logLevel=Msg::kDebug;
03197 
03198   multiset<Double_t> times;
03199   const TClonesArray& stpTca=(*ntp.stp);
03200   //const Int_t numStps=stpTca.GetEntriesFast();
03201 
03202   MAXMSG("NuReco",Msg::kDebug,200)
03203     <<"evt.nstrip="<<evt.nstrip<<endl;
03204   for (Int_t i=0;i<evt.nstrip;i++) {
03205     const NtpSRStrip& stp=
03206       *(dynamic_cast<NtpSRStrip*>(stpTca[evt.stp[i]]));
03207 
03208     Double_t time=stp.time0;
03209     if (time<0 || time>1) time=stp.time1;
03210 
03211     if (time>0 && time<=1) {
03212       times.insert(time);
03213     }
03214     //else just don't put the time in the map - clearly rubbish
03215 
03216     MAXMSG("NuReco",Msg::kDebug,500)
03217       <<"  Strip index="<<stp.index<<", stp="<<stp.strip
03218       <<", t="<<time
03219       <<", pl="<<stp.plane
03220       <<", sigCor="<<stp.ph1.sigcor<<", tpos="<<stp.tpos<<endl;
03221   }
03222 
03223   //get the median time from the map
03224   multiset<Double_t>::const_iterator it=times.begin();
03225   advance(it,times.size()/2);
03226   Double_t medianTime=*it;
03227   MAXMSG("NuReco",Msg::kDebug,100)
03228     <<"Median time="<<medianTime<<endl;
03229 
03230   return medianTime;
03231 }

void NuReco::GetEvtsPerSlc ( const NtpStRecord ntp,
std::map< Int_t, Int_t > &  evtsPerSlc 
) const
Int_t NuReco::GetHadronicFinalState ( const NtpStRecord ntp,
const NuEvent nu 
) const

This is a rewrite of the code in Mad/MadQuantities

Definition at line 4751 of file NuReco.cxx.

References NtpMCStdHep::IdHEP, NuEvent::iresonance, NtpMCStdHep::IstHEP, NuEvent::mc, NtpMCStdHep::mc, and NtpStRecord::stdhep.

Referenced by GetTruthInfo().

04753 {
04755 
04756   Int_t hfs=0;
04757   Int_t proc=nu.iresonance;
04758   TClonesArray* pointStdhepArray = NULL;
04759   pointStdhepArray=ntp.stdhep;
04760   TClonesArray& stdhepArray = *pointStdhepArray;
04761   Int_t nStdHep = stdhepArray.GetEntries();
04762 
04763   Int_t itr=nu.mc;
04764 
04765   if(proc==1002){
04766     for(int i=0;i<nStdHep;i++){
04767       //LoadStdHep(i);
04768       const NtpMCStdHep* ntpStdHep=
04769         dynamic_cast<NtpMCStdHep*>(stdhepArray[i]);
04770 
04771       if(ntpStdHep->mc==itr && ntpStdHep->IstHEP==3 &&
04772          !(abs(ntpStdHep->IdHEP)==15)){  //not a tau lepton
04773         hfs = ntpStdHep->IdHEP;
04774         break;
04775       }
04776     }
04777     hfs = hfs%1000;
04778   }
04779   else {
04780     for(int i=0;i<nStdHep;i++){
04781       //LoadStdHep(i);
04782       const NtpMCStdHep* ntpStdHep=
04783         dynamic_cast<NtpMCStdHep*>(stdhepArray[i]);
04784       if(ntpStdHep->mc==itr && ntpStdHep->IstHEP==3){
04785         hfs = ntpStdHep->IdHEP;
04786         break;
04787       }
04788     }
04789     hfs = hfs%1000;
04790   }
04791   return hfs;
04792 }

Short_t NuReco::GetHorizontalVerticalStripNumber ( Detector::Detector_t  det,
Short_t  edgeRegion,
Short_t  stripTrku,
Short_t  stripTrkv 
) const

Calculates the 'One Horizontal/Vertical strip number'. This number (referred to as HOVE) gives a single number for how far form the edge of the detector a given horizontal or vertical strip.

Definition at line 5662 of file NuReco.cxx.

References Detector::kFar.

Referenced by CalculateHorizontalVerticalStripNumber().

05663 {
05664   Short_t hoveNum = -999;
05665 
05666   // This variable is not defined for the near detector
05667   if (det != Detector::kFar) return hoveNum;
05668 
05669   if     (edgeRegion == 0) hoveNum = 192 - stripTrku + stripTrkv;
05670   else if(edgeRegion == 2) hoveNum = 383 - stripTrku - stripTrkv;
05671   else if(edgeRegion == 4) hoveNum = 192 + stripTrku - stripTrkv;
05672   else if(edgeRegion == 6) hoveNum = 1   + stripTrku + stripTrkv;
05673 
05674   return hoveNum;
05675 }

Int_t NuReco::GetInitialState ( const NtpStRecord ntp,
const NuEvent nu 
) const

This is a rewrite of the code in Mad/MadQuantities

Definition at line 4339 of file NuReco.cxx.

References NtpMCStdHep::IdHEP, NtpMCStdHep::IstHEP, NuEvent::mc, NtpMCStdHep::mc, and NtpStRecord::stdhep.

Referenced by GetTruthInfo().

04341 {
04343 
04344   //get the index of the true MC interaction
04345   //use the track one for now - have to be carefull if no track
04346   //in event
04347   Int_t itr=nu.mc;
04348 
04349   Int_t initial_state=0;
04350   TClonesArray* pointStdhepArray = NULL;
04351   pointStdhepArray=ntp.stdhep;
04352   TClonesArray& stdhepArray = *pointStdhepArray;
04353   Int_t nStdHep = stdhepArray.GetEntries();
04354 
04355   int protneut = -1;  // 0 = neutron, 1 = proton, 2 = N, 3 = A
04356   int nubarnu = 0;    // +1 = neutrino, -1 = antineutrino
04357 
04358   for(int i=0;i<nStdHep;i++){
04359     //LoadStdHep(i);
04360     const NtpMCStdHep* ntpStdHep=
04361       dynamic_cast<NtpMCStdHep*>(stdhepArray[i]);
04362     if(ntpStdHep->mc==itr){
04363 
04364       if(ntpStdHep->IstHEP==0){  //initial state particle
04365         if(abs(ntpStdHep->IdHEP)==12 ||
04366            abs(ntpStdHep->IdHEP)==14 ||
04367            abs(ntpStdHep->IdHEP)==16){   //(anti)neutrino
04368           nubarnu = ntpStdHep->IdHEP/abs(ntpStdHep->IdHEP);  //get sign
04369         }
04370       }
04371       if(ntpStdHep->IstHEP==11){    //target nucleon
04372         if(ntpStdHep->IdHEP==2212) protneut = 1;  //proton
04373         else if(ntpStdHep->IdHEP==2112) protneut = 0;  //neutron
04374         else if(abs(ntpStdHep->IdHEP)>1000000000) protneut = 2;  //nucleus
04375         else protneut = 3; //atom - probably never get here since IdHEP A>N?
04376       }
04377     }
04378   }
04379 
04380   if(protneut==1 && nubarnu==1)  initial_state=1;  //p + v
04381   if(protneut==0 && nubarnu==1)  initial_state=2;  //n + v
04382   if(protneut==1 && nubarnu==-1) initial_state=3;  //p + vbar
04383   if(protneut==0 && nubarnu==-1) initial_state=4;  //n + vbar
04384   if(protneut==2 && nubarnu==1)  initial_state=5;  //N + v
04385   if(protneut==3 && nubarnu==1)  initial_state=6;  //A + v
04386   if(protneut==2 && nubarnu==-1) initial_state=7;  //N + vbar
04387   if(protneut==3 && nubarnu==-1) initial_state=8;  //A + vbar
04388 
04389   return initial_state;
04390 }

Int_t NuReco::GetLongestPathLengthTrack ( const NuEvent nu  )  const

Definition at line 1470 of file NuReco.cxx.

References NuEvent::ntrk, NuEvent::trkds1, NuEvent::trkds2, NuEvent::trkds3, and NuEvent::trkLength2.

01471 {
01472   if (nu.ntrk <= 0) return -1;
01473   else if (nu.ntrk == 1) return 1;
01474   else if (nu.ntrk == 2) {
01475     Int_t trkIndex = 1;
01476     Double_t longestTrack = nu.trkds1;
01477     if (nu.trkds2 > longestTrack) {
01478       trkIndex = 2;
01479       longestTrack = nu.trkds2;
01480     }
01481     return trkIndex;
01482   } else {
01483     Int_t trkIndex = 1;
01484     Double_t longestTrack = nu.trkds1;
01485     if (nu.trkLength2 > longestTrack) {
01486       trkIndex = 2;
01487       longestTrack = nu.trkds2;
01488     }
01489     if (nu.trkds3 > longestTrack) {
01490       trkIndex = 3;
01491       longestTrack = nu.trkds3;
01492     }
01493     return trkIndex;
01494   }
01495 } // GetLongestPathLengthTrack

const NtpSRTrack * NuReco::GetLongestPathLengthTrack ( const NtpStRecord ntp,
const NtpSREvent evt 
) const

Definition at line 1499 of file NuReco.cxx.

References NtpSRTrack::ds, NtpSRTrack::fit, Msg::kDebug, Msg::kInfo, MAXMSG, NtpSREvent::ntrack, NtpSRTrackPlane::ntrklike, NtpSRFitTrack::pass, NtpSRTrack::plane, NtpStRecord::trk, and NtpSREvent::trk.

Referenced by GetBestTrack().

01501 {
01502   TClonesArray& trkTca=(*ntp.trk);
01503 
01504   MAXMSG("NuReco",Msg::kInfo,1)
01505     <<"Setting best track as longest path length track"<<endl;
01506   Int_t trkToUse = 0;
01507   Double_t trkLength = 0;
01508   if (evt.ntrack > 1) {
01509     for(Int_t itrk = 0; itrk < evt.ntrack; ++itrk) {
01510       const NtpSRTrack& trk =
01511         *dynamic_cast<NtpSRTrack*>(trkTca[evt.trk[itrk]]);
01512 
01513       Double_t absLength = trk.ds;
01514 
01515       //select the longest trk
01516       if (absLength > trkLength) {
01517         trkLength = absLength;
01518         trkToUse = itrk;
01519       }
01520 
01521       MAXMSG("NuReco", Msg::kDebug, 200)
01522         << "itrk = " << itrk << " of " << evt.ntrack
01523         << ", trkToUse = " << trkToUse
01524         << ", pass = " << trk.fit.pass
01525         << ", ntrklike = " << trk.plane.ntrklike
01526         << ", absLength = " << absLength
01527         << ", longest = " << trkLength
01528         << endl;
01529     } // for
01530     MAXMSG("NuReco", Msg::kDebug, 200)
01531       <<"Finished loop, selected trkToUse = " << trkToUse << endl;
01532     const NtpSRTrack& trk =
01533       *dynamic_cast<NtpSRTrack*>(trkTca[evt.trk[trkToUse]]);
01534     return &trk;
01535   }
01536   else if (evt.ntrack == 1) {
01537     const NtpSRTrack& trk =
01538       *dynamic_cast<NtpSRTrack*>(trkTca[evt.trk[0]]);
01539     return &trk;
01540   }
01541   else return 0;
01542 } // GetLongestPathLengthTrack

Int_t NuReco::GetLongestTrack ( const NuEvent nu  )  const

Definition at line 1392 of file NuReco.cxx.

References NuEvent::ntrk, NuEvent::trkLength1, NuEvent::trkLength2, and NuEvent::trkLength3.

01393 {
01394   if (nu.ntrk<=0) return -1;
01395   else if (nu.ntrk==1) return 1;
01396   else if (nu.ntrk==2) {
01397     Int_t trkIndex=1;
01398     Int_t longestTrack=nu.trkLength1;
01399     if (nu.trkLength2>longestTrack) {
01400       trkIndex=2;
01401       longestTrack=nu.trkLength2;
01402     }
01403     return trkIndex;
01404   }
01405   else {
01406     Int_t trkIndex=1;
01407     Int_t longestTrack=nu.trkLength1;
01408     if (nu.trkLength2>longestTrack) {
01409       trkIndex=2;
01410       longestTrack=nu.trkLength2;
01411     }
01412     if (nu.trkLength3>longestTrack) {
01413       trkIndex=3;
01414       longestTrack=nu.trkLength3;
01415     }
01416     return trkIndex;
01417   }
01418 }

const NtpSRTrack * NuReco::GetLongestTrack ( const NtpStRecord ntp,
const NtpSREvent evt 
) const

Definition at line 1422 of file NuReco.cxx.

References NtpSRPlane::beg, NtpSRPlane::end, NtpSRTrack::fit, Msg::kDebug, Msg::kInfo, MAXMSG, NtpSREvent::ntrack, NtpSRTrackPlane::ntrklike, NtpSRFitTrack::pass, NtpSRTrack::plane, NtpStRecord::trk, and NtpSREvent::trk.

Referenced by GetBestTrack().

01424 {
01425   TClonesArray& trkTca=(*ntp.trk);
01426   //const Int_t numTrks=trkTca.GetEntriesFast();
01427 
01428   MAXMSG("NuReco",Msg::kInfo,1)
01429     <<"Setting best track as longest track (end-beg+1)"<<endl;
01430   Int_t trkToUse=0;
01431   Double_t trkLength=0;
01432   if (evt.ntrack>1){
01433     for(Int_t itrk=0;itrk<evt.ntrack;itrk++){
01434       const NtpSRTrack& trk=
01435         *dynamic_cast<NtpSRTrack*>(trkTca[evt.trk[itrk]]);
01436 
01437       Int_t absLength=abs(trk.plane.end-trk.plane.beg+1);
01438 
01439       //select the longest trk
01440       if (absLength>trkLength) {
01441         trkLength=absLength;
01442         trkToUse=itrk;
01443       }
01444 
01445       MAXMSG("NuReco",Msg::kDebug,200)
01446         <<"itrk="<<itrk<<" of "<<evt.ntrack
01447         <<", trkToUse="<<trkToUse
01448         <<", pass="<<trk.fit.pass
01449         <<", ntrklike="<<trk.plane.ntrklike
01450         <<", absLength="<<absLength
01451         <<", longest="<<trkLength
01452         <<endl;
01453     }
01454     MAXMSG("NuReco",Msg::kDebug,200)
01455       <<"Finished loop, selected trkToUse="<<trkToUse<<endl;
01456     const NtpSRTrack& trk=
01457       *dynamic_cast<NtpSRTrack*>(trkTca[evt.trk[trkToUse]]);
01458     return &trk;
01459   }
01460   else if (evt.ntrack==1){
01461     const NtpSRTrack& trk=
01462       *dynamic_cast<NtpSRTrack*>(trkTca[evt.trk[0]]);
01463     return &trk;
01464   }
01465   else return 0;
01466 }

const NtpSRTrack * NuReco::GetLongestTrackTLikePlanes ( const NtpStRecord ntp,
const NtpSREvent evt 
) const

Definition at line 1350 of file NuReco.cxx.

References NtpSRTrack::fit, Msg::kDebug, Msg::kInfo, MAXMSG, NtpSREvent::ntrack, NtpSRTrackPlane::ntrklike, NtpSRFitTrack::pass, NtpSRTrack::plane, NtpStRecord::trk, and NtpSREvent::trk.

01351 {
01352   TClonesArray& trkTca=(*ntp.trk);
01353   //const Int_t numTrks=trkTca.GetEntriesFast();
01354 
01355   MAXMSG("NuReco",Msg::kInfo,1)
01356     <<"Setting best track as longest track (track-like planes)"<<endl;
01357   Int_t trkToUse=0;
01358   Double_t trkLength=0;
01359   if (evt.ntrack>1){
01360     for(Int_t itrk=0;itrk<evt.ntrack;itrk++){
01361       const NtpSRTrack& trk=
01362         *dynamic_cast<NtpSRTrack*>(trkTca[evt.trk[itrk]]);
01363 
01364       MAXMSG("NuReco",Msg::kDebug,200)
01365         <<"trk="<<itrk<<"/"<<evt.ntrack
01366         <<", pass="<<trk.fit.pass
01367         <<", ntrklike="<<trk.plane.ntrklike
01368         <<endl;
01369 
01370       //select the longest trk (in track-like planes)
01371       if (trk.plane.ntrklike>trkLength) {
01372         trkLength=trk.plane.ntrklike;
01373         trkToUse=itrk;
01374       }
01375     }
01376     MAXMSG("NuReco",Msg::kDebug,200)
01377       <<"selected trkToUse="<<trkToUse<<endl;
01378     const NtpSRTrack& trk=
01379       *dynamic_cast<NtpSRTrack*>(trkTca[evt.trk[trkToUse]]);
01380     return &trk;
01381   }
01382   else if (evt.ntrack==1){
01383     const NtpSRTrack& trk=
01384       *dynamic_cast<NtpSRTrack*>(trkTca[evt.trk[0]]);
01385     return &trk;
01386   }
01387   else return 0;
01388 }

Bool_t NuReco::GetMuonContainmentMC ( const NtpStRecord ntp,
const NtpMCTruth mc 
) const

Experimental: Attempts to calculate the 'containment truth'.

Definition at line 5435 of file NuReco.cxx.

References NtpMCStdHep::child, GetPrimaryMuonStdHepIndex(), NtpMCStdHep::IdHEP, and NtpStRecord::stdhep.

Referenced by GetTruthInfo().

05436 {
05437   Int_t muonindex = this->GetPrimaryMuonStdHepIndex(ntp, mc);
05438   // If there is no muon, then we have no containment....
05439   if (muonindex == -1) return false;
05440 
05441   // Pull out the TCA from the sntp record
05442   TClonesArray& hepTca=(*ntp.stdhep);
05443 
05444   // Grab ahold of this muon
05445   NtpMCStdHep* muon = dynamic_cast<NtpMCStdHep*>(hepTca[muonindex]);
05446 
05447   // Trace down the children tree. Since it appears that exiting muons do not
05448   // have their decays simulated in the MC, check for decay products and if
05449   // there are none, then assume that it decayed outside the detector i.e.
05450   // it exited
05451 
05452   // What is our calculated containment?
05453   Bool_t containment = false;
05454 
05455   // Loop until we have a result
05456   while (true) {
05457     // Pointer to the muon 'child'
05458     NtpMCStdHep* child = 0;
05459 
05460     // If we have children....
05461     if (muon->child[0] != -1) {
05462 
05463       // Loop over all children (may just be one)
05464       for (Int_t i = muon->child[0]; i <= muon->child[1]; ++i) {
05465         // Grab the child object
05466         NtpMCStdHep* childcand = dynamic_cast<NtpMCStdHep*>(hepTca[i]);
05467 
05468         // If this child is a muon....
05469         if (childcand->IdHEP == 13 || childcand->IdHEP == -13) {
05470           // there is a muon child!
05471           child = childcand;
05472         }
05473       } // Loop over children
05474 
05475       // We have now looped over all children. If none of them were muons,
05476       // then assume that this is because the muon has decayed in the detector!
05477       if (child == 0) {
05478         // No muon children found. Must have decayed
05479         containment = true;
05480         break;
05481       } else {
05482         // We have a muon child. This is now the muon for the next loop.
05483         muon = child;
05484       }
05485     } else {
05486       // We have no children. This must mean we have exited the detector!
05487       containment = false;
05488       break;
05489     }
05490   } // End of infinite loop
05491 
05492   // We should have now resolved the containment.
05493   /*  this->PrintStdhep(ntp, mc);
05494       if (containment) {
05495       MSG("NuReco", Msg::kInfo) << "==== CONTAINED ====" << endl;
05496       } else {
05497       MSG("NuReco", Msg::kInfo) << "~~~~~ ESCAPED ~~~~~" << endl;
05498       }*/
05499   // Finally, return.
05500   return containment;
05501 }

Double_t NuReco::GetMuonFirstHitEnergy ( const NtpStRecord ntp,
const NtpMCTruth mc 
) const

Retrieves the energy of muon on the first detector hit.

Definition at line 5405 of file NuReco.cxx.

References NtpMCStdHep::dethit, GetPrimaryMuonStdHepIndex(), NtpMCStdHepHit::mom, and NtpStRecord::stdhep.

Referenced by GetTruthInfo().

05406 {
05407   Int_t stdindex = this->GetPrimaryMuonStdHepIndex(ntp, mc);
05408   if (stdindex == -1) return -1;
05409 
05410   // Get the muon hit object
05411   TClonesArray& hepTca=(*ntp.stdhep);
05412   const NtpMCStdHep& muon = *dynamic_cast<NtpMCStdHep*>(hepTca[stdindex]);
05413 
05414   // return the energy
05415   return muon.dethit[0].mom[3];
05416 }

Double_t NuReco::GetMuonLastHitEnergy ( const NtpStRecord ntp,
const NtpMCTruth mc 
) const

Retrieves the energy of muon on the last detector hit.

Definition at line 5420 of file NuReco.cxx.

References NtpMCStdHep::dethit, GetPrimaryMuonStdHepIndex(), NtpMCStdHepHit::mom, and NtpStRecord::stdhep.

Referenced by GetTruthInfo().

05421 {
05422   Int_t stdindex = this->GetPrimaryMuonStdHepIndex(ntp, mc);
05423   if (stdindex == -1) return -1;
05424 
05425   // Get the muon hit object
05426   TClonesArray& hepTca=(*ntp.stdhep);
05427   const NtpMCStdHep& muon = *dynamic_cast<NtpMCStdHep*>(hepTca[stdindex]);
05428 
05429   // return the energy
05430   return muon.dethit[1].mom[3];
05431 }

Int_t NuReco::GetNucleus ( const NtpStRecord ntp,
const NuEvent nu 
) const

This is a rewrite of the code in Mad/MadQuantities

Definition at line 4394 of file NuReco.cxx.

References MuELoss::a, NuEvent::aMC, and NuEvent::zMC.

Referenced by GetTruthInfo().

04396 {
04398 
04399 
04400   Int_t z=nu.zMC;//int(ntpTruth->z);
04401   Int_t a=nu.aMC;//int(ntpTruth->a);
04402   Int_t nucleus=1;
04403 
04404   switch (z) {
04405     //  case 1:
04406     //nucleus=0;   // free nucleon
04407     //break;
04408   case 1:
04409     switch (a) {
04410     case 1:
04411       nucleus=256;   // hydrogen1
04412       break;
04413     case 2:
04414       nucleus=257;   // hydrogen2
04415       break;
04416     case 3:
04417       nucleus=258;   // hydrogen2
04418       break;
04419     default:
04420       nucleus=256;   // hydrogen1
04421       break;
04422     }
04423     break;
04424   case 6:
04425     switch (a) {
04426     case 11:
04427       nucleus=274; // carbon11
04428       break;
04429     case 12:
04430       nucleus=275; // carbon12
04431       break;
04432     case 13:
04433       nucleus=276; // carbon13
04434       break;
04435     case 14:
04436       nucleus=277; // carbon14
04437       break;
04438     default:
04439       nucleus=275; // carbon12
04440       break;
04441     }
04442     break;
04443   case 7:
04444     switch (a) {
04445     case 13:
04446       nucleus=278; // nitrogen13
04447       break;
04448     case 14:
04449       nucleus=279; // nitrogen14
04450       break;
04451     case 15:
04452       nucleus=280; // nitrogen15
04453       break;
04454     case 16:
04455       nucleus=281; // nitrogen16
04456       break;
04457     case 17:
04458       nucleus=282; // nitrogen17
04459       break;
04460     default:
04461       nucleus=279; // nitrogen14
04462       break;
04463     }
04464     break;
04465   case 8:
04466     switch (a) {
04467     case 15:
04468       nucleus=283;   // oxygen15
04469       break;
04470     case 16:
04471       nucleus=284;   // oxygen16
04472       break;
04473     case 17:
04474       nucleus=285;   // oxygen17
04475       break;
04476     case 18:
04477       nucleus=286;   // oxygen18
04478       break;
04479     default:
04480       nucleus=284;   // oxygen16
04481       break;
04482     }
04483     break;
04484   case 13:
04485     switch (a) {
04486     case 26:
04487       nucleus=303;   // aluminium26
04488       break;
04489     case 27:
04490       nucleus=304;   // aluminium27
04491       break;
04492     case 28:
04493       nucleus=305;   // aluminium28
04494       break;
04495     case 29:
04496       nucleus=306;   // aluminium29
04497       break;
04498     default:
04499       nucleus=304;   // aluminium27
04500       break;
04501     }
04502     break;
04503   case 14:
04504     switch (a) {
04505     case 27:
04506       nucleus=307;   // silicon27
04507       break;
04508     case 28:
04509       nucleus=308;   // silicon28
04510       break;
04511     case 29:
04512       nucleus=309;   // silicon29
04513       break;
04514     case 30:
04515       nucleus=310;   // silicon30
04516       break;
04517     default:
04518       nucleus=308;   // silicon28
04519       break;
04520     }
04521     break;
04522   case 15:
04523     switch (a) {
04524     case 30:
04525       nucleus=311;   //phosphorus30
04526       break;
04527     case 31:
04528       nucleus=312;   //phosphorus31
04529       break;
04530     case 32:
04531       nucleus=313;   //phosphorus32
04532       break;
04533     case 33:
04534       nucleus=314;   //phosphorus33
04535       break;
04536     default:
04537       nucleus=312;   //phosphorus31
04538       break;
04539     }
04540     break;
04541   case 16:
04542     switch (a) {
04543     case 31:
04544       nucleus=315;   //sulphur31
04545       break;
04546     case 32:
04547       nucleus=316;   //sulphur32
04548       break;
04549     case 33:
04550       nucleus=317;   //sulphur33
04551       break;
04552     case 34:
04553       nucleus=318;   //sulphur34
04554       break;
04555     case 35:
04556       nucleus=319;   //sulphur35
04557       break;
04558     case 36:
04559       nucleus=320;   //sulphur36
04560       break;
04561     default:
04562       nucleus=316;   //sulphur32
04563       break;
04564     }
04565     break;
04566   case 22:
04567     switch (a) {
04568     case 45:
04569       nucleus=347;   //titanium45
04570       break;
04571     case 46:
04572       nucleus=348;   //titanium46
04573       break;
04574     case 47:
04575       nucleus=349;   //titanium47
04576       break;
04577     case 48:
04578       nucleus=350;   //titanium48
04579       break;
04580     case 49:
04581       nucleus=351;   //titanium49
04582       break;
04583     case 50:
04584       nucleus=352;   //titanium50
04585       break;
04586     default:
04587       nucleus=350;   //titanium48
04588       break;
04589     }
04590     break;
04591   case 23:
04592     switch (a) {
04593     case 49:
04594       nucleus=353;   //vanadium49
04595       break;
04596     case 50:
04597       nucleus=354;   //vanadium50
04598       break;
04599     case 51:
04600       nucleus=355;   //vanadium51
04601       break;
04602     case 52:
04603       nucleus=356;   //vanadium52
04604       break;
04605     case 53:
04606       nucleus=357;   //vanadium53
04607       break;
04608     default:
04609       nucleus=355;   //vanadium51
04610       break;
04611     }
04612     break;
04613   case 24:
04614     switch (a) {
04615     case 49:
04616       nucleus=358;   //chromium49
04617       break;
04618     case 50:
04619       nucleus=359;   //chromium50
04620       break;
04621     case 51:
04622       nucleus=360;   //chromium51
04623       break;
04624     case 52:
04625       nucleus=361;   //chromium52
04626       break;
04627     case 53:
04628       nucleus=362;   //chromium53
04629       break;
04630     case 54:
04631       nucleus=363;   //chromium54
04632       break;
04633     default:
04634       nucleus=361;   //chromium52
04635       break;
04636     }
04637     break;
04638   case 25:
04639     switch (a) {
04640     case 53:
04641       nucleus=364;   //manganese53
04642       break;
04643     case 54:
04644       nucleus=365;   //manganese54
04645       break;
04646     case 55:
04647       nucleus=366;   //manganese55
04648       break;
04649     case 56:
04650       nucleus=367;   //manganese56
04651       break;
04652     case 57:
04653       nucleus=368;   //manganese57
04654       break;
04655     default:
04656       nucleus=366;   //manganese55
04657       break;
04658     }
04659     break;
04660   case 26:
04661     switch (a) {
04662     case 53:
04663       nucleus=369;   //iron53
04664       break;
04665     case 54:
04666       nucleus=370;   //iron54
04667       break;
04668     case 55:
04669       nucleus=371;   //iron55
04670       break;
04671     case 56:
04672       nucleus=372;   //iron56
04673       break;
04674     case 57:
04675       nucleus=373;   //iron57
04676       break;
04677     case 58:
04678       nucleus=374;   //iron58
04679       break;
04680     default:
04681       nucleus=372;   //iron56
04682       break;
04683     }
04684     break;
04685   case 28:
04686     switch (a) {
04687     case 57:
04688       nucleus=382;   //nickel57
04689       break;
04690     case 58:
04691       nucleus=383;   //nickel58
04692       break;
04693     case 59:
04694       nucleus=384;   //nickel59
04695       break;
04696     case 60:
04697       nucleus=385;   //nickel60
04698       break;
04699     case 61:
04700       nucleus=386;   //nickel61
04701       break;
04702     case 62:
04703       nucleus=387;   //nickel62
04704       break;
04705     case 63:
04706       nucleus=388;   //nickel63
04707       break;
04708     case 64:
04709       nucleus=389;   //nickel64
04710       break;
04711     default:
04712       nucleus=383;   //nickel58
04713       break;
04714     }
04715     break;
04716   case 29:
04717     switch (a) {
04718     case 62:
04719       nucleus=390;   //copper62
04720       break;
04721     case 63:
04722       nucleus=391;   //copper63
04723       break;
04724     case 64:
04725       nucleus=392;   //copper64
04726       break;
04727     case 65:
04728       nucleus=393;   //copper65
04729       break;
04730     case 66:
04731       nucleus=394;   //copper66
04732       break;
04733     case 67:
04734       nucleus=395;   //copper67
04735       break;
04736     default:
04737       nucleus=392;   //copper64
04738       break;
04739     }
04740     break;
04741   default:
04742     nucleus=1;   // unknown
04743     break;
04744   }
04745 
04746   return nucleus;
04747 }

Short_t NuReco::GetParallelStripInset ( Detector::Detector_t  det,
Short_t  edgeRegion,
Short_t  stripBegU,
Short_t  stripBegV 
) const

How many strips in, on a diagonal edge, is a hit?

Definition at line 5579 of file NuReco.cxx.

References Detector::kFar.

Referenced by CalculateParallelStripInset().

05580 {
05581   Short_t parallelStripVtx = -10;
05582 
05583   // Don't calculate this value for the near detector, for now
05584   if (det != Detector::kFar) return parallelStripVtx;
05585 
05586   if     (edgeRegion == 1) parallelStripVtx = 191-stripBegU;
05587   else if(edgeRegion == 3) parallelStripVtx = 191-stripBegV;
05588   else if(edgeRegion == 5) parallelStripVtx =     stripBegU;
05589   else if(edgeRegion == 7) parallelStripVtx =     stripBegV;
05590   else parallelStripVtx = -10;
05591 
05592   return parallelStripVtx;
05593 }

Char_t NuReco::GetPerpendicularStripFlag ( Detector::Detector_t  det,
Short_t  edgeRegion,
Bool_t  IsHitu 
) const

Is the hit both on a diagonal edge and on the overhanging (perpendicular) strip?

Definition at line 5623 of file NuReco.cxx.

References Detector::kFar.

Referenced by CalculatePerpendicularStripFlag().

05624 {
05625   // Convenience variables
05626   const Bool_t Isu = IsHitu;
05627   const Bool_t Isv = !Isu;
05628 
05629   Char_t flag = -10;
05630 
05631   // We don't have this defined for the near detector
05632   if (det != Detector::kFar) return flag;
05633 
05634   if(edgeRegion == 1 || edgeRegion == 5)        flag = Isv;
05635   else if(edgeRegion == 3 || edgeRegion == 7)   flag = Isu;
05636 
05637   return flag;
05638 }

Float_t NuReco::GetPhi ( const NtpSRVertex vtx  )  const

Definition at line 5505 of file NuReco.cxx.

References NtpSRVertex::x, and NtpSRVertex::y.

Referenced by NuExtraction::ExtractNthTrkInfo(), and GetEdgeRegion().

05506 {
05507   return TMath::ATan2(vtx.y, vtx.x);
05508 }

void NuReco::GetPreInukeFinalStateVars ( const NtpStRecord ntp,
NuEvent nu 
) const

Definition at line 4269 of file NuReco.cxx.

References NtpMCStdHep::child, NtpMCStdHep::IdHEP, NtpMCStdHep::IstHEP, NtpMCStdHep::mass, NuEvent::maxMomPreInukeFSneutMC, NuEvent::maxMomPreInukeFSprotMC, NuEvent::mc, NtpMCStdHep::mc, NuEvent::numPreInukeFSneutMC, NuEvent::numPreInukeFSprotMC, NtpMCStdHep::p4, and NtpStRecord::stdhep.

Referenced by GetTruthInfo().

04271 {
04272   Int_t itr=nu.mc;
04273 
04274   TClonesArray* pointStdhepArray = NULL;
04275   pointStdhepArray=ntp.stdhep;
04276   TClonesArray& stdhepArray = *pointStdhepArray;
04277   Int_t nStdHep = stdhepArray.GetEntries();
04278 
04279   vector<Int_t> vChildIndices;
04280 
04281   for(int i=0;i<nStdHep;i++){
04282     //LoadStdHep(i);
04283     const NtpMCStdHep* ntpStdHep=
04284       dynamic_cast<NtpMCStdHep*>(stdhepArray[i]);
04285     if(ntpStdHep->mc==itr){
04286 
04287       if (ntpStdHep->IstHEP==3){
04288         Int_t childStart = ntpStdHep->child[0];
04289         Int_t childEnd = ntpStdHep->child[1];
04290         for (Int_t goodChild = childStart; goodChild<=childEnd; ++goodChild){
04291           vChildIndices.push_back(goodChild);
04292         }
04293       }
04294     }
04295   }
04296 
04297   Int_t numPreInukeFSprot = 0;
04298   Int_t numPreInukeFSneut = 0;
04299   Float_t maxMomPreInukeFSprot = 0.;
04300   Float_t maxMomPreInukeFSneut = 0.;
04301 
04302   for (UInt_t i=0;i<vChildIndices.size();i++){
04303     //LoadStdHep(i);
04304     const NtpMCStdHep* ntpStdHep=
04305       dynamic_cast<NtpMCStdHep*>(stdhepArray[vChildIndices[i]]);
04306     if(ntpStdHep->mc==itr){
04307       Float_t energy = ntpStdHep->p4[3];
04308       Float_t mass = ntpStdHep->mass;
04309       Float_t mom = 0.0;
04310       if (energy*energy - mass*mass > 0.0){
04311         mom = TMath::Sqrt(energy*energy - mass*mass);
04312       }
04313       if (ntpStdHep->IdHEP==2212){
04314         //I am a proton
04315         numPreInukeFSprot++;
04316         if (mom>maxMomPreInukeFSprot){
04317           maxMomPreInukeFSprot = mom;
04318         }
04319       }
04320       else if (ntpStdHep->IdHEP==2112){
04321         //I am a neutron
04322         numPreInukeFSneut++;
04323         if (mom>maxMomPreInukeFSneut){
04324           maxMomPreInukeFSneut = mom;
04325         }
04326       }
04327     }
04328   }
04329 
04330   nu.numPreInukeFSprotMC = numPreInukeFSprot;
04331   nu.numPreInukeFSneutMC = numPreInukeFSneut;
04332   nu.maxMomPreInukeFSprotMC = maxMomPreInukeFSprot;
04333   nu.maxMomPreInukeFSneutMC = maxMomPreInukeFSneut;
04334 
04335 }

Int_t NuReco::GetPrimaryMuonStdHepIndex ( const NtpStRecord ntp,
const NtpMCTruth mc 
) const

Find the stdhep array entry that corresponds to the muon.

Definition at line 5329 of file NuReco.cxx.

References NtpMCStdHep::child, NtpMCTruth::iaction, NtpMCStdHep::IdHEP, NtpMCTruth::inu, Msg::kFatal, MSG, PrintStdhep(), NtpMCTruth::stdhep, and NtpStRecord::stdhep.

Referenced by GetMuonContainmentMC(), GetMuonFirstHitEnergy(), and GetMuonLastHitEnergy().

05330 {
05331   // Ignore NC interactions
05332   if (mc.iaction == 0) return -1;
05333 
05334   // Ignore non-muon interactions
05335   if (mc.inu != 14 && mc.inu != -14) return -1;
05336 
05337   // Pull out the TCA from the sntp record
05338   TClonesArray& hepTca=(*ntp.stdhep);
05339 
05340   // Read the first item in the array to find the incident neutrino
05341   const NtpMCStdHep& neutrino = *dynamic_cast<NtpMCStdHep*>(hepTca[mc.stdhep[0]]);
05342   // Read the first child into the array. All relevant numus should have only one
05343   const NtpMCStdHep& child = *dynamic_cast<NtpMCStdHep*>(hepTca[neutrino.child[0]]);
05344 
05345   // Ensure we only had one child
05346   Int_t childcount = neutrino.child[1] - neutrino.child[0];
05347   if (childcount > 0) {
05348     // Display debugging information and die
05349     this->PrintStdhep(ntp, mc);
05350     MSG("NuReco",Msg::kFatal) << "More than one primary child in interaction" << endl;
05351     return 0;
05352   }
05353 
05354   // // // Print out the array
05355   // this->PrintStdhep(ntp, mc);
05356   // //
05357   // // // Print out the incident particle information
05358   // MSG("NuReco",Msg::kInfo) << "Incident particle: " << neutrino.IdHEP << endl;
05359   // MSG("NuReco",Msg::kInfo) << "Primary Child: " << child.IdHEP << endl;
05360 
05361   // If the child is not a muon
05362   if (child.IdHEP != 13 && child.IdHEP != -13) {
05363     MSG("NuReco", Msg::kFatal) << "Not a muon child" << endl;
05364   }
05365 
05366   // We believe this child is the muon
05367   return neutrino.child[0];
05368 
05369   // // At this point, we know that that child is an only child, and a muon.
05370   // // This is good enough to decide we have found our primary muon
05371   //
05372   // // Print out the momentum 4-vector, to ensure we know which is the energy
05373   // // ->dethit[1].mom[3];
05374   // MSG("NuReco", Msg::kInfo) << "Momentum at start: "
05375   //     << child.dethit[0].mom[0] << ", "
05376   //     << child.dethit[0].mom[1] << ", "
05377   //     << child.dethit[0].mom[2] << ", "
05378   //     << child.dethit[0].mom[3] << endl;
05379   // MSG("NuReco", Msg::kInfo) << "Momentum at end:   "
05380   //     << child.dethit[1].mom[0] << ", "
05381   //     << child.dethit[1].mom[1] << ", "
05382   //     << child.dethit[1].mom[2] << ", "
05383   //     << child.dethit[1].mom[3] << endl;
05384   //
05385   // MSG("NuReco", Msg::kInfo) << "Muon Vertex:   "
05386   //     << child.vtx[0] << ", "
05387   //     << child.vtx[1] << ", "
05388   //     << child.vtx[2] << ", "
05389   //     << child.vtx[3] << endl;
05390   //
05391   // const NtpMCStdHep& childer = *dynamic_cast<NtpMCStdHep*>(hepTca[child.child[0]]);
05392   // MSG("NuReco", Msg::kInfo) << "Muon's Childs Vertex:   "
05393   //     << childer.vtx[0] << ", "
05394   //     << childer.vtx[1] << ", "
05395   //     << childer.vtx[2] << ", "
05396   //     << childer.vtx[3] << endl;
05397   //
05398   //
05399   // cout << endl << endl;
05400   // return 0;
05401 }

Int_t NuReco::GetPrimaryShowerCCStd ( const NuEvent nu  )  const

if a track exists this algorithm relies on the best track having been set - so must set best track first

Definition at line 2017 of file NuReco.cxx.

References Munits::GeV, Msg::kDebug, Msg::kInfo, Munits::m, MAXMSG, NuEvent::nshw, NuEvent::primshw, NuEvent::shwEnCor1, NuEvent::trkExists, NuEvent::zShwVtx1, and NuEvent::zTrkVtx.

Referenced by GetBestShower().

02018 {
02021   if (nu.nshw<=0) {
02022     MAXMSG("NuReco",Msg::kDebug,3)
02023       <<"GetPrimaryShower: No showers so return 0"<<endl;
02024     return 0;
02025   }
02026 
02027   if (nu.primshw<0) {
02028     // CC only uses a shower if primshw is set, so return here
02029     return 0;
02030   }
02031   //if no track then just return the shw
02032   //doesn't matter about proximity to a non-existant track
02033   if (!nu.trkExists) return 1;
02034 
02035   MAXMSG("NuReco",Msg::kInfo,1)
02036     <<"GetPrimaryShw: require trk vtx within 0.5 m || >2 GeV"<<endl;
02037 
02038   //in the case of 1 shower you don't know if it
02039   //is actually declared as the primary shower in Birch
02040   //use vtx1 for shower since don't know if primary yet
02041   if (fabs(nu.zTrkVtx-nu.zShwVtx1)<(0.5*Munits::m) ||
02042       (fabs(nu.zTrkVtx-nu.zShwVtx1)>=(0.5*Munits::m) &&
02043        nu.shwEnCor1>(2*Munits::GeV))) {
02044     return 1;
02045   }
02046   else {
02047     return 0;
02048   }
02049 }

Int_t NuReco::GetPrimaryShowerNCStd ( const NuEvent nu  )  const

Definition at line 2052 of file NuReco.cxx.

References Msg::kInfo, MAXMSG, and NuEvent::nshw.

Referenced by GetBestShower().

02052                                                            {
02053   Int_t result = 1;
02054   if (nu.nshw <= 0) {
02055     MAXMSG("NuReco", Msg::kInfo, 3)
02056       << "GetPrimaryShowerNCStd: No showers so return 0" << endl;
02057     result = 0;
02058   } 
02059 
02060   return result;
02061 }

Int_t NuReco::GetPrimaryShowerStdReco ( const NuEvent nu  )  const

Definition at line 2064 of file NuReco.cxx.

References Msg::kInfo, Msg::kWarning, MAXMSG, NuEvent::nshw, NuEvent::primshw, NuEvent::shwExists1, NuEvent::shwExists2, and NuEvent::shwExists3.

Referenced by GetBestShower().

02065 {
02066   if (nu.nshw<=0) {
02067     MAXMSG("NuReco",Msg::kInfo,3)
02068       <<"GetPrimaryShower: No showers so return 0"<<endl;
02069     return 0;
02070   }
02071 
02072   MAXMSG("NuReco",Msg::kInfo,1)
02073     <<"GetPrimaryShw: using evt.primshw"<<endl;
02074   if (nu.primshw<0) return 0;
02075   else {
02076     if (nu.primshw==0 && nu.shwExists1) return 1;
02077     else if (nu.primshw==1 && nu.shwExists2) {
02078       MAXMSG("NuReco",Msg::kWarning,300)
02079         <<"nu.primshw="<<nu.primshw<<endl;
02080       return 2;
02081     }
02082     else if (nu.primshw==2 && nu.shwExists3) {
02083       MAXMSG("NuReco",Msg::kWarning,300)
02084         <<"nu.primshw="<<nu.primshw<<endl;
02085       return 3;
02086     }
02087     else {
02088       cout<<"ahhhhhhhh nu.primshw="<<nu.primshw<<endl;
02089       return 0;
02090     }
02091   }
02092 }

Int_t NuReco::GetPrimaryTrack ( const NuEvent nu  )  const

Definition at line 1997 of file NuReco.cxx.

References Msg::kError, MSG, NuEvent::primtrk, and NuEvent::trkExists1.

Referenced by GetBestTrack().

01998 {
01999   if (nu.trkExists1) {
02000     //it is believed that the primary trk is always the first
02001     //in the array, check this
02002     if (nu.primtrk!=0) {
02003       MSG("NuReco",Msg::kError)
02004         <<"Inconsistency about primary track"
02005         <<", nu.trkExists1="<<nu.trkExists1
02006         <<", nu.primtrk="<<nu.primtrk
02007         <<endl;
02008     }
02009     assert(nu.primtrk==0);
02010     return 1;
02011   }
02012   else return 0;
02013 }

void NuReco::GetPrimaryTruthIndex ( const NtpStRecord ntp,
const NtpSREvent evt,
NuEvent nu 
) const

Definition at line 3298 of file NuReco.cxx.

References ChooseTruthIndexToUse(), GetShowerWithIndexX(), GetTrackWithIndexX(), NtpSRTrack::index, NtpSRShower::index, NtpSREvent::index, Msg::kDebug, MAXMSG, NuEvent::mcEvt, NuEvent::mcShw, NuEvent::mcTrk, NtpTHEvent::neumc, NtpTHShower::neumc, NtpTHTrack::neumc, NtpStRecord::thevt, NtpStRecord::thshw, and NtpStRecord::thtrk.

Referenced by GetTruthInfo().

03300 {
03301   TClonesArray& thevtTca=(*ntp.thevt);//TruthHelper Event TCA
03302   const Int_t numthevts=thevtTca.GetEntriesFast();
03303   if (numthevts<=0) {
03304     MAXMSG("NuReco",Msg::kDebug,1)
03305       <<"No THEvents, so can't GetPrimaryTruthIndex..."<<endl;
03306     return;
03307   }
03308   MAXMSG("NuReco",Msg::kDebug,1)
03309     <<"Found THEvent, GetPrimaryTruthIndex..."<<endl;
03310 
03311   Int_t mcTrk=-1;//track mc index
03312   Int_t mcShw=-1;//shower mc index
03313   Int_t mcEvt=-1;//event mc index
03314 
03315   const NtpTHEvent& thevt=
03316     *dynamic_cast<NtpTHEvent*>(thevtTca[evt.index]);
03317   mcEvt=thevt.neumc;
03318 
03319   //get an instance of the code library
03320   //const NuLibrary& lib=NuLibrary::Instance();
03321 
03322   //get the shower mc
03323   TClonesArray& thshwTca=(*ntp.thshw);//TruthHelper Shower TCA
03324   const Int_t numthshws=thshwTca.GetEntriesFast();
03325   if (numthshws>0) {
03326     Int_t bestShower=1;//primary shower
03327     const NtpSRShower* pshw=this->GetShowerWithIndexX(ntp,evt,
03328                                                       bestShower-1);
03329     if (pshw) {
03330       const NtpSRShower& shw=*pshw;
03331       const NtpTHShower& thshw=
03332         *dynamic_cast<NtpTHShower*>(thshwTca[shw.index]);
03333       mcShw=thshw.neumc;
03334     }
03335   }
03336 
03337   //get the track mc
03338   TClonesArray& thtrkTca=(*ntp.thtrk);//TruthHelper Track TCA
03339   const Int_t numthtrks=thtrkTca.GetEntriesFast();
03340   if (numthtrks>0) {
03341     Int_t bestTrack=1;//primary trk
03342     const NtpSRTrack* ptrk=this->GetTrackWithIndexX(ntp,evt,
03343                                                     bestTrack-1);
03344     if (ptrk) {
03345       const NtpSRTrack& trk=*ptrk;
03346       const NtpTHTrack& thtrk=
03347         *dynamic_cast<NtpTHTrack*>(thtrkTca[trk.index]);
03348       mcTrk=thtrk.neumc;
03349     }
03350   }
03351 
03352   //set the variables in the object
03353   nu.mcTrk=mcTrk;
03354   nu.mcShw=mcShw;
03355   nu.mcEvt=mcEvt;
03356   this->ChooseTruthIndexToUse(nu);
03357 }

Float_t NuReco::GetRadiusFromBeamCentre ( Float_t  x,
Float_t  y,
const NuEvent nu 
) const

Definition at line 4862 of file NuReco.cxx.

References NuEvent::anaVersion, NuEvent::detector, NuCuts::kCC0093Std, Detector::kNear, Munits::m, and SQR.

Referenced by NuPlots::FillContainmentHistos().

04863 {
04864   Float_t zerox=0;
04865   Float_t zeroy=0;
04866   if (nu.detector==Detector::kNear) {
04867     //use beam spot centre
04868     if (nu.anaVersion==NuCuts::kCC0093Std) {
04869       zerox=1.4885*(Munits::m);
04870       zeroy=0.1397*(Munits::m);
04871     }
04872     else {
04873       zerox=1.4828*(Munits::m);//new for 2.5 analysis
04874       zeroy=0.2384*(Munits::m);//new for 2.5 analysis
04875     }
04876   }
04877   //return the radius
04878   return sqrt(SQR(x-zerox)+SQR(y-zeroy));
04879 }

Float_t NuReco::GetRadiusFromCoil ( Float_t  x,
Float_t  y 
) const

Definition at line 4883 of file NuReco.cxx.

References SQR.

Referenced by CalcEvtVariables(), CalcExtraTruthVariables(), and CalcTrkVariables().

04884 {
04885   Float_t zerox=0;
04886   Float_t zeroy=0;
04887   //return the radius
04888   return sqrt(SQR(x-zerox)+SQR(y-zeroy));
04889 }

Int_t NuReco::GetRegion ( Detector::Detector_t  det,
SimFlag::SimFlag_t  simFlag,
Float_t  vtxX,
Float_t  vtxY,
Float_t  vtxZ,
Int_t  vtxPlane 
) const

Calculates the detector region from direct variables. Currently needs plane - shouldn't this be calculable from the z?

Getregion returns a 'region' of the detector. This version should run independant of the SNTPs because it accepts the required variables directly. It seems like plane should be calculable from the vtxZ, though....

Definition at line 5205 of file NuReco.cxx.

References FidVol::getEvtVtxZOffset(), FidVol::getFarRinner(), FidVol::getFarRouter(), FidVol::getFarZData(), FidVol::getFarZMC(), FidVol::getTrkVtxZOffset(), SimFlag::kData, Detector::kFar, and kUnknown.

05206 {
05207   // Region of the detector where this track vertex is.
05208   // (Do not call this for shower or event vertices)
05209   //
05210   // -1 if there is no track
05211   // -2 if we don't know how to answer (i.e. this isn't the far detector)
05212   //
05213   // If there is a track, then for the highest energy one's vertex, returns
05214   // the sum of:
05215   //
05216   // 1 if it's near the edge
05217   // 2 if it's near the coil hole
05218   //
05219   // 4 if it's near the front
05220   // 8 if it's near the south side of the supermodule gap
05221   // 12 if it's near the north side of the supermodule gap
05222   // 16 if it's near the back
05223   //
05224   // Or to put it another way, it uses the bit format:
05225   //
05226   //  0                   1                   2                   3
05227   //  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
05228   // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
05229   // |                        reserved                     |  L  | T |
05230   // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
05231   //
05232   // T: Transverse position:
05233   //    0 if transversely fiducial
05234   //    1 if near the edge
05235   //    2 if near the coil hole
05236   //
05237   // L: Longitudinal position:
05238   //    0 if longitudinally fiducial
05239   //    1 if near the front
05240   //    2 if near the south side of the supermodule gap
05241   //    3 if near the north side of the supermodule gap
05242   //    4 if near the back
05243   //
05244   // Exhaustively listing the possibilities:
05245   //
05246   // 0: Fiducial
05247   // 1: Near the edge and not near any corner
05248   // 2: Near the coil hole and not near any corner
05249   //
05250   // 4: Near the front and not near any corner
05251   // 5: Near the front and the edge
05252   // 6: Near the front and the coil hole
05253   //
05254   // 8: Near the south side of the supermodule gap and not near any corner
05255   // 9: Near the south side of the supermodule gap and the edge
05256   // 10: Near the south side of the supermodule gap and the coil hole
05257   //
05258   // 12: Near the north side of the supermodule gap and not near any corner
05259   // 13: Near the north side of the supermodule gap and the edge
05260   // 14: Near the north side of the supermodule gap and the coil hole
05261   //
05262   // 16: Near the back and not near any corner
05263   // 17: Near the back and the edge
05264   // 18: Near the back and the coil hole
05265   // An enum for the rock detector region - this probably shouldn't go here,
05266   // but for now it will have to do (would rather use an enum than plain numbers
05267   enum Rock_DetectorRegion {
05268     kUnknown   = -2,
05269     kNoTrack   = -1,
05270     kFiducial  = 0,
05271     kEdge      = 1,  // radial
05272     kCoilHole  = 2,  // radial
05273     kFront     = 4,  // longidudinal
05274     kGapSouth  = 8,  // longidudinal
05275     kGapNorth  = 12, // longidudinal
05276     kBack      = 16  // longidudinal
05277   };
05278 
05279   // Placeholder to avoid nesting if's in this function
05280   // Bool_t inFid = false; // Don't use this variable now
05281   Bool_t nearFront = false, nearEdge = false;
05282   Bool_t nearGapSouth = false, nearGapNorth = false;
05283   Bool_t nearCoil = false, nearBack = false;
05284   Double_t radius2 = vtxX*vtxX + vtxY*vtxY;
05285   Double_t z = vtxZ - FidVol::getTrkVtxZOffset();
05286 
05287   // If we are the near detector, we can't calculate the region - return unknown
05288   if (det != Detector::kFar) return kUnknown;
05289 
05290   // Get the fiducial volume Z boundaries correctly.
05291   // Read them out into a placeholder array, as this is easier than
05292   // switching every time we call it, and clearer than using a function
05293   // pointer to do the same thing.
05294   Double_t getFarZ[4] = {};
05295   if (simFlag == SimFlag::kData) {
05296     getFarZ[0] = FidVol::getFarZData(0);
05297     getFarZ[1] = FidVol::getFarZData(1);
05298     getFarZ[2] = FidVol::getFarZData(2);
05299     getFarZ[3] = FidVol::getFarZData(3);
05300   } else {
05301     getFarZ[0] = FidVol::getFarZMC(0);
05302     getFarZ[1] = FidVol::getFarZMC(1);
05303     getFarZ[2] = FidVol::getFarZMC(2);
05304     getFarZ[3] = FidVol::getFarZMC(3);
05305   }
05306 
05307   // Now - examine each of the regions and determine if the vertex is in there
05308 
05309   const int GAPPLANE = 249; // plane at the SM gap, without scintillator
05310 
05311   nearEdge = radius2 >= (FidVol::getFarRouter()*FidVol::getFarRouter());
05312   nearCoil = radius2 < FidVol::getFarRinner()*FidVol::getFarRinner();
05313   nearFront = z < getFarZ[0];
05314   nearGapSouth = z > getFarZ[1] && vtxPlane < GAPPLANE;
05315   nearGapNorth = vtxPlane > GAPPLANE && z < getFarZ[2];
05316   nearBack = vtxZ - FidVol::getEvtVtxZOffset() > getFarZ[3];
05317 
05318   return kEdge     * nearEdge +
05319     kCoilHole * nearCoil +
05320     kFront    * nearFront +
05321     kGapSouth * nearGapSouth +
05322     kGapNorth * nearGapNorth +
05323     kBack     * nearBack;
05324 }

Int_t NuReco::GetRegion ( const NtpStRecord rec,
const NtpSRVertex vtx 
) const

Retrieves the (rock muon) detector region from SNTP.

Getregion returns a 'region' of the detector. This is for the antifiducial analysis.

Definition at line 5192 of file NuReco.cxx.

References VldContext::GetDetector(), RecRecordImp< T >::GetHeader(), VldContext::GetSimFlag(), RecHeader::GetVldContext(), NtpSRVertex::plane, NtpSRVertex::x, NtpSRVertex::y, and NtpSRVertex::z.

Referenced by NuExtraction::ExtractNthTrkInfo().

05193 {
05194   // Get the detector and simFlag
05195   Detector::Detector_t det = rec.GetHeader().GetVldContext().GetDetector();
05196   SimFlag::SimFlag_t simFlag = rec.GetHeader().GetVldContext().GetSimFlag();
05197 
05198   return GetRegion(det, simFlag, vtx.x, vtx.y, vtx.z, vtx.plane);
05199 }

void NuReco::GetSecondaryTruthIndex ( const NtpStRecord ntp,
const NtpSREvent evt,
NuEvent nu 
) const

Definition at line 3360 of file NuReco.cxx.

References GetShowerWithIndexX(), GetTrackWithIndexX(), NtpSRTrack::index, NtpSRShower::index, NtpTHShower::neumc, NtpTHTrack::neumc, NtpStRecord::thshw, and NtpStRecord::thtrk.

Referenced by GetTruthInfo().

03363 {
03364   //get the shower mc
03365   TClonesArray& thshwTca = (*ntp.thshw);//TruthHelper Shower TCA
03366   const Int_t numthshws=thshwTca.GetEntriesFast();
03367   for(int idx = 1; idx <= 5; ++idx){
03368     get_mcShw(nu, idx) = -1;
03369     if (numthshws>0){
03370       if(get_shwExists(nu, idx)){
03371         const NtpSRShower* pshw = this->GetShowerWithIndexX(ntp, evt, idx-1);
03372         if(pshw){
03373           const NtpTHShower& thshw =
03374             *dynamic_cast<NtpTHShower*>(thshwTca[pshw->index]);
03375           get_mcShw(nu, idx) = thshw.neumc;
03376         }
03377       }
03378     }
03379   } // end for idx
03380 
03381   //get the track mc
03382   TClonesArray& thtrkTca = (*ntp.thtrk);//TruthHelper Track TCA
03383   const Int_t numthtrks=thtrkTca.GetEntriesFast();
03384   for(int idx = 1; idx <= 3; ++idx){
03385     get_mcTrk(nu, idx) = -1;
03386     if (numthtrks>0) {
03387       if(get_trkExists(nu, idx)){
03388         const NtpSRTrack* ptrk = this->GetTrackWithIndexX(ntp, evt, idx-1);
03389         if(ptrk){
03390           const NtpTHTrack& thtrk=
03391             *dynamic_cast<NtpTHTrack*>(thtrkTca[ptrk->index]);
03392           get_mcTrk(nu, idx) = thtrk.neumc;
03393         }
03394       }
03395     }
03396   } // end for idx
03397 }

Double_t NuReco::GetShowerEnergyCC ( const NuEvent nu  )  const

Definition at line 922 of file NuReco.cxx.

References NuEvent::anaVersion, GetShowerEnergyCor(), ReleaseType::IsElm(), ReleaseType::IsFir(), ReleaseType::IsGinkgo(), ReleaseType::IsHickory(), ReleaseType::IsIvy(), ReleaseType::IsJuniper(), CandShowerHandle::kCC, NuCuts::kCC0720Std, NuCuts::kCC1070Std, NuCuts::kCC2014, NuCuts::kCC2014NewCoilCut, Msg::kDebug, Msg::kError, Msg::kInfo, NuCuts::kNSI2011Fhc, NuCuts::kNSI2011Rhc, NuCuts::kRHC0150Std, NuCuts::kRHC0350Std, MAXMSG, NuEvent::ntrk, NuEvent::releaseType, NuEvent::shwEnkNN, NuEvent::shwEnLinCCCor, NuEvent::shwEnLinCCNoCor, NuEvent::shwEnNoCor, and NuEvent::shwExists.

Referenced by CalcShwVariables(), and NuDSTAna::FDTestAna().

00923 {
00924   //this function adds a level of indirection
00925   //to allow flexibility
00926 
00927   // All modern CC/NuBar analyses now use kNN shower energy.
00928   // Use it whenever we have a track because "Using kNN energy
00929   // for no-track events doesn't go so well, so don't do that"
00930   if (nu.ntrk>0 && (nu.anaVersion==NuCuts::kCC0720Std ||
00931                     nu.anaVersion==NuCuts::kCC2014||
00932                     nu.anaVersion==NuCuts::kCC2014NewCoilCut||
00933                     nu.anaVersion==NuCuts::kCC1070Std ||
00934                     nu.anaVersion==NuCuts::kRHC0150Std ||
00935                     nu.anaVersion==NuCuts::kRHC0350Std ||
00936                     nu.anaVersion==NuCuts::kNSI2011Fhc ||
00937                     nu.anaVersion==NuCuts::kNSI2011Rhc
00938                     )) {
00939     MAXMSG("NuReco",Msg::kInfo,1) << "Using kNN Shower Energy with anaVersion "
00940                                   << nu.anaVersion << endl;
00941     //note: the energy corrections are built into shwEnkNN
00942     return nu.shwEnkNN;
00943   }
00944   else {
00945     // If there's no primary shower then there can't be a shower energy.
00946     // Except for the case of the kNN above - which doesn't require a
00947     // primary shower.
00948     if(!nu.shwExists) return 0;
00949 
00950     //get the corrected linCC energy
00951     MAXMSG("NuReco",Msg::kInfo,1)
00952       <<"GetShowerEnergyCC: (re)doing EnergyCorrection"<<endl;
00953 
00954     // for Elm and beyond, shwEnLinCCCor is already 
00955     // the final corrected calorimetric energy (done in sntp level)
00956     // no more correcion by this->GetShowerEnergyCor() is needed.
00957     // junting@physics.utexas.edu 
00958     Double_t shwEnCor;
00959     if(ReleaseType::IsElm(nu.releaseType)     || 
00960        ReleaseType::IsFir(nu.releaseType)     ||
00961        ReleaseType::IsGinkgo(nu.releaseType)  ||
00962        ReleaseType::IsHickory(nu.releaseType) ||
00963        ReleaseType::IsIvy(nu.releaseType)     ||
00964        ReleaseType::IsJuniper(nu.releaseType) )
00965       shwEnCor = nu.shwEnLinCCCor;
00966     else
00967       shwEnCor = this->GetShowerEnergyCor(nu.shwEnLinCCNoCor, CandShowerHandle::kCC, nu);
00968 
00969     MAXMSG("NuReco",Msg::kDebug,300)
00970       <<"Redo energy cor: shwEnNoCor="<<nu.shwEnNoCor
00971       <<", shwEnCor="<<shwEnCor<<endl;
00972 
00973     //sanity check the corrected shower energy
00974     if (shwEnCor<0) {
00975       MAXMSG("NuReco",Msg::kError,10)
00976         <<"Negative energy! GetShowerEnergyCC: shwEnCor="<<shwEnCor<<endl;
00977       assert(shwEnCor>=0);
00978     }
00979 
00980     //return the value
00981     return shwEnCor;
00982   }
00983 //  else {
00984 //    MAXMSG("NuReco",Msg::kInfo,1)
00985 //      <<"GetShowerEnergyCC: NOT (re)doing EnergyCorrection"<<endl;
00986 //    return nu.shwEnLinCCCor;
00987 //  }
00988 }

Double_t NuReco::GetShowerEnergyCor ( Double_t  shwEn,
const CandShowerHandle::ShowerType_t st,
const NuEvent nu 
) const

Definition at line 1023 of file NuReco.cxx.

References EnergyCorrections::FullyCorrectShowerEnergy(), GetVldContext(), and NuEvent::releaseType.

Referenced by NuExtraction::ExtractShwInfo(), NuDSTAna::FDTestAna(), NuPlots::FillShwHistos(), GetShowerEnergyCC(), GetShowerEnergyNC(), and NuDSTAna::NDTestAna().

01026 {
01027   //check if shower exists
01028   if (shwEn<0) return -1;
01029 
01030   //calc energy correction
01031   VldContext vc=this->GetVldContext(nu);
01032   return EnergyCorrections::FullyCorrectShowerEnergy(shwEn,st,vc,nu.releaseType);
01033 }

Double_t NuReco::GetShowerEnergykNN ( const NuEvent nu,
Float_t *  shwEnkNNNoCor,
Float_t *  shwEnkNNPlus,
Float_t *  shwEnkNNPlusNoCor 
) const

a function to calculate MINOS+ kNN shower energy it returns the retrained shwEnkNN calculated with MIONS+ training samples shwEnkNNPlus is also calculated with reselected 4 variables

junting@physics.utexas.edu

Definition at line 1215 of file NuReco.cxx.

References NukNN::AddPars(), NuEvent::detector, NuLibrary::general, NuGeneral::GetReleaseDirToUse(), NukNN::GetShwEnergy(), NukNN::Initialize(), NukNN::initialized, NuLibrary::Instance(), Detector::kFar, SimFlag::kMC, Detector::kNear, kNN, NukNN::MasakiCorrectionFactorNthOrder(), MAX, MM, NuEvent::nplaneAllShws, NuEvent::nplaneShw, NuEvent::nshw, NuEvent::nstripShw1, NuEvent::nstripShw2, NuEvent::nstripShw3, NuEvent::nstripShw4, NuEvent::nstripShw5, NukNN::pars, NukNN::PrintMMatrix(), NukNN::PrintWeights(), NukNN::shwEnkNNCorFD1, NukNN::shwEnkNNCorFD2, NukNN::shwEnkNNCorFD3, NukNN::shwEnkNNCorND1, NukNN::shwEnkNNCorND2, NukNN::shwEnkNNCorND3, NukNN::shwEnkNNPlusCorFD1, NukNN::shwEnkNNPlusCorFD2, NukNN::shwEnkNNPlusCorFD3, NukNN::shwEnkNNPlusCorND1, NukNN::shwEnkNNPlusCorND2, NuEvent::shwEnLinCCCor, NuEvent::shwEnLinCCCor1, NuEvent::shwEnLinCCCor2, NuEvent::shwEnLinCCCor3, NuEvent::shwEnLinCCCor4, NuEvent::shwEnLinCCCor5, NuEvent::shwEnMC, NuEvent::shwExists1, NuEvent::shwExists2, NuEvent::shwExists3, NuEvent::shwExists4, NuEvent::shwExists5, NuEvent::shwSumHitLengthAllShws, NuEvent::simFlag, NukNN::testPoint, NuEvent::trkShwEnNearDW, and NukNN::wts.

01218                                                                       {
01219 
01220   // retrain shwEnkNN with MINOS+ MC samples
01221   static NukNN kNN;
01222 
01223   if(!kNN.initialized){
01224     cout << "Retraining MINOS+ kNN shower energy" << endl;
01225 
01226     kNN.AddPars("trkShwEnNearDW", 1.);
01227     kNN.AddPars("sum2Shw",        1.);
01228     kNN.AddPars("nplaneShw",      1.);
01229     kNN.PrintWeights();
01230     int numNN = 440;
01231 
01232     const NuGeneral& gen = NuLibrary::Instance().general;
01233     const TString releaseDir = gen.GetReleaseDirToUse("NtupleUtils");
01234     TString fname;
01235     if(Detector::Detector_t(nu.detector) == Detector::kNear)
01236       fname = "MinosPlus_shwEnkNNTrain_ND.root";
01237     else if(Detector::Detector_t(nu.detector) == Detector::kFar)
01238       fname = "MinosPlus_shwEnkNNTrain_FD.root";
01239     const TString fullPath = releaseDir+"/NtupleUtils/data/"+fname;
01240 
01241     kNN.Initialize(fullPath, numNN);
01242   }
01243 
01244   vector<double> testPt;
01245   double sum2Shw = (nu.nshw > 1) ? (nu.shwEnLinCCCor + nu.shwEnLinCCCor2) : nu.shwEnLinCCCor;
01246   testPt.push_back(nu.trkShwEnNearDW);
01247   testPt.push_back(sum2Shw);
01248   testPt.push_back(nu.nplaneShw);
01249 
01250   kNN.testPoint.par.clear();
01251   kNN.testPoint.shwEnMC = nu.shwEnMC;
01252   for(unsigned int i = 0; i < kNN.pars.size(); i++)
01253     kNN.testPoint.par.push_back(testPt[i] * kNN.wts[i]);
01254 
01255   double shwEn = kNN.GetShwEnergy((nu.simFlag == SimFlag::kMC), "Euclidean", false);
01256   if(shwEnkNNNoCor) *shwEnkNNNoCor = shwEn; 
01257 
01258   if(Detector::Detector_t(nu.detector) == Detector::kNear){
01259     shwEn /= kNN.MasakiCorrectionFactorNthOrder(shwEn, kNN.shwEnkNNCorND1);
01260     shwEn /= kNN.MasakiCorrectionFactorNthOrder(shwEn, kNN.shwEnkNNCorND2);
01261     shwEn /= kNN.MasakiCorrectionFactorNthOrder(shwEn, kNN.shwEnkNNCorND3);
01262   }
01263   else if(Detector::Detector_t(nu.detector) == Detector::kFar){
01264     shwEn /= kNN.MasakiCorrectionFactorNthOrder(shwEn, kNN.shwEnkNNCorFD1);
01265     shwEn /= kNN.MasakiCorrectionFactorNthOrder(shwEn, kNN.shwEnkNNCorFD2);
01266     shwEn /= kNN.MasakiCorrectionFactorNthOrder(shwEn, kNN.shwEnkNNCorFD3);
01267   }
01268   else 
01269     abort();
01270 
01271   // calculates shwEnkNNPlus which uses 4 reselected variables
01272   static NukNN kNNPlus;
01273   if(!kNNPlus.initialized){
01274     cout << "Calculate four-variable kNN shower energy shwEnkNNPlus" << endl;
01275 
01276     kNNPlus.AddPars("sumShws",                -1.);
01277     kNNPlus.AddPars("nplaneAllShws",          -1.);
01278     kNNPlus.AddPars("nstripAllShws",          -1.);
01279     kNNPlus.AddPars("shwSumHitLengthAllShws", -1.);
01280     kNNPlus.PrintWeights();
01281     MAX = kNNPlus.pars.size();
01282     MM.resize(MAX);
01283     for (int i = 0; i < MAX; i++)
01284       MM[i].resize(MAX);
01285     for (int i = 0; i < MAX; i++)
01286       MM[i][i] = 1.;
01287     kNNPlus.PrintMMatrix();
01288     int numNN = 400;
01289 
01290     const NuGeneral& gen = NuLibrary::Instance().general;
01291     const TString releaseDir = gen.GetReleaseDirToUse("NtupleUtils");
01292     TString fname;
01293     if(Detector::Detector_t(nu.detector) == Detector::kNear)
01294       fname = "MinosPlus_shwEnkNNTrain_ND.root";
01295     else if(Detector::Detector_t(nu.detector) == Detector::kFar)
01296       fname = "MinosPlus_shwEnkNNTrain_FD.root";
01297     const TString fullPath = releaseDir+"/NtupleUtils/data/"+fname;
01298 
01299     kNNPlus.Initialize(fullPath, numNN);
01300   }
01301 
01302   vector<double> testPtPlus;
01303   double sumShws = 
01304     (nu.shwExists1) ? nu.shwEnLinCCCor1 : 0. + 
01305     (nu.shwExists2) ? nu.shwEnLinCCCor2 : 0. + 
01306     (nu.shwExists3) ? nu.shwEnLinCCCor3 : 0. + 
01307     (nu.shwExists4) ? nu.shwEnLinCCCor4 : 0. + 
01308     (nu.shwExists5) ? nu.shwEnLinCCCor5 : 0.;
01309   double nstripAllShws = 
01310     (nu.shwExists1) ? nu.nstripShw1 : 0. + 
01311     (nu.shwExists2) ? nu.nstripShw2 : 0. + 
01312     (nu.shwExists3) ? nu.nstripShw3 : 0. + 
01313     (nu.shwExists4) ? nu.nstripShw4 : 0. + 
01314     (nu.shwExists5) ? nu.nstripShw5 : 0.;
01315   
01316   testPtPlus.push_back(sumShws);
01317   testPtPlus.push_back(nu.nplaneAllShws);
01318   testPtPlus.push_back(nstripAllShws);
01319   testPtPlus.push_back(nu.shwSumHitLengthAllShws);
01320 
01321   kNNPlus.testPoint.par.clear();
01322   kNNPlus.testPoint.shwEnMC = nu.shwEnMC;
01323   for(unsigned int i = 0; i < kNNPlus.pars.size(); i++)
01324     kNNPlus.testPoint.par.push_back(testPtPlus[i] * kNNPlus.wts[i]);
01325 
01326   double shwEnPlus;
01327   shwEnPlus = kNNPlus.GetShwEnergy((nu.simFlag == SimFlag::kMC), "Mahalanobis", true);
01328   *shwEnkNNPlusNoCor = shwEnPlus; 
01329 
01330   if(Detector::Detector_t(nu.detector) == Detector::kNear){
01331     shwEnPlus /= kNN.MasakiCorrectionFactorNthOrder(shwEnPlus, kNN.shwEnkNNPlusCorND1);
01332     shwEnPlus /= kNN.MasakiCorrectionFactorNthOrder(shwEnPlus, kNN.shwEnkNNPlusCorND2);
01333   }
01334   else if(Detector::Detector_t(nu.detector) == Detector::kFar){
01335     shwEnPlus /= kNN.MasakiCorrectionFactorNthOrder(shwEnPlus, kNN.shwEnkNNPlusCorFD1);
01336     shwEnPlus /= kNN.MasakiCorrectionFactorNthOrder(shwEnPlus, kNN.shwEnkNNPlusCorFD2);
01337     shwEnPlus /= kNN.MasakiCorrectionFactorNthOrder(shwEnPlus, kNN.shwEnkNNPlusCorFD3);
01338   }
01339   else 
01340     abort();
01341 
01342   *shwEnkNNPlus = shwEnPlus;
01343 
01344   // return retrained corrected kNN shower energy
01345   return shwEn;
01346 }

Double_t NuReco::GetShowerEnergykNN ( const NuEvent num,
Float_t *  shwEnkNNNoCor = 0,
Float_t *  res = 0 
) const

res will be filled with an energy resolution estimate and shwEnkNNNoCor with the value as calculated before energy corrections

Definition at line 1116 of file NuReco.cxx.

References NuKDTree< T, D >::Committed(), NuEvent::detector, MuELoss::e, NuEvent::energyMC, NuKDTree< T, D >::FindNearestPts(), NuEvent::hornIsReverse, InitializeShowerEnergykNN(), n, NuEvent::nplaneShw, NuEvent::nshw, NuEvent::shwEnCor2, NuEvent::shwEnLinCCCor, and NuEvent::trkShwEnNearDW.

Referenced by CalcShwVariables().

01119 {
01120   // If something went wrong with the kNN initialization, then bail out
01121   // early on subsequent attempts
01122   static bool treeOK = true;
01123   if(!treeOK){
01124     if(res) *res = -1;
01125     if(shwEnkNNNoCor) *shwEnkNNNoCor = -1;
01126     return -1;
01127   }
01128 
01129   // Initialize the tree the first time we are called
01130   static NuKDTree<double, 3> kdTree;
01131   // Energy correction constants
01132   static vector<double> C;
01133   static double cutoff_lo;
01134   static double cutoff_hi;
01135 
01136   static int num_neighbours;
01137 
01138   if(!kdTree.Committed()){
01139     const Detector::Detector_t det = Detector::Detector_t(nu.detector);
01140     const bool hornReverse = nu.hornIsReverse;//newadd
01141     const bool success = InitializeShowerEnergykNN(&kdTree, det,hornReverse,//newadd
01142                                                    C, cutoff_lo, cutoff_hi,
01143                                                    num_neighbours);
01144     
01145     if(!success){
01146       treeOK = false;
01147       if(res) *res = -1;
01148       return -1;
01149     }
01150   } // end if not committed
01151 
01152   double sum2Shw = nu.shwEnLinCCCor;
01153   if(nu.nshw > 1) sum2Shw += nu.shwEnCor2;
01154 
01155   const NuKDPt<3> pt(nu.trkShwEnNearDW, double(nu.nplaneShw), sum2Shw);
01156 
01157   // Sometimes need extra neighbours for MC because results will be this
01158   // same event. This can happen more than once because the same true event
01159   // gets split by the reconstruction. Also can happen because rock overlays
01160   // appear to be reused - although these should fail fiducial and PID cuts.
01161   vector<NuKDPtWithPayload<double, 3> > nearest =
01162     kdTree.FindNearestPts(pt, num_neighbours + 10);
01163 
01164   // Calculate the average true energy of all the nearby events
01165   double tot = 0;
01166   double sqrTot = 0;
01167   unsigned int N = num_neighbours;
01168   for(unsigned int n = 0; n < N; ++n){
01169     const double pl = nearest[n].payload;
01170 
01171     // We found ourself in the list of neighbours, should ignore this point
01172     // as it can't happen for data
01173     if(nu.energyMC > 0 && fabs(pl-nu.energyMC) < 1e-5){
01174       ++N; // Do one more neighbour to make up for missing this one
01175       // If this assertion fails it means we found more than 10 events with
01176       // the same energyMC as this one. That's probably worth investigating.
01177       assert(N <= nearest.size());
01178       continue;
01179     }
01180 
01181     tot += pl;
01182     sqrTot += pl*pl;
01183   }
01184 
01185   const double sd = sqrt(N*sqrTot-tot*tot)/num_neighbours;
01186   if(res) *res = sd;
01187 
01188   double ret = tot/num_neighbours;
01189   
01190   // Save the uncorrected value before we correct it
01191   if(shwEnkNNNoCor) *shwEnkNNNoCor = ret;
01192 
01193   // Apply energy correction - polynomial in log(E)
01194   // NB - the resolution estimate isn't scaled
01195   double clampedE = ret;
01196   if(clampedE < cutoff_lo) clampedE = cutoff_lo;
01197   if(clampedE > cutoff_hi) clampedE = cutoff_hi;
01198   const double y = TMath::Log(clampedE);
01199   const double y2 = y*y;  const double y3 = y2*y;
01200   const double y4 = y3*y; const double y5 = y4*y;
01201   const double y6 = y5*y; const double y7 = y6*y;
01202   const double corrFactor = C[0]+C[1]*y+C[2]*y2+C[3]*y3+
01203     C[4]*y4+C[5]*y5+C[6]*y6+C[7]*y7;
01204 
01205   ret *= corrFactor;
01206 
01207   return ret;
01208 }

Double_t NuReco::GetShowerEnergyNC ( const NuEvent nu  )  const

Definition at line 991 of file NuReco.cxx.

References GetShowerEnergyCor(), Msg::kDebug, Msg::kError, Msg::kInfo, CandShowerHandle::kNC, MAXMSG, NuEvent::shwEnLinNCNoCor, NuEvent::shwEnNoCor, and NuEvent::shwExists.

Referenced by CalcShwVariables().

00992 {
00993   //this function adds a level of indirection
00994   //to allow flexibility
00995   //could sum up all the shower energies here for example
00996   //or just return the primary shower
00997 
00998   // If there's no primary shower then can't return an energy.
00999   if(!nu.shwExists) return 0;
01000 
01001   MAXMSG("NuReco",Msg::kInfo,1)
01002     <<"GetShowerEnergyNC: (re)doing EnergyCorrection"<<endl;
01003   Double_t shwEnCor=this->GetShowerEnergyCor
01004     (nu.shwEnLinNCNoCor, CandShowerHandle::kNC,nu);
01005 
01006   MAXMSG("NuReco",Msg::kDebug,300)
01007     <<"Redo energy cor: shwEnNoCor="<<nu.shwEnNoCor
01008     <<", shwEnCor="<<shwEnCor<<endl;
01009 
01010   //sanity check the corrected shower energy
01011   if (shwEnCor<0) {
01012     MAXMSG("NuReco",Msg::kError,10)
01013       <<"GetShowerEnergyNC: shwEnCor="<<shwEnCor<<endl;
01014     assert(shwEnCor>=0);
01015   }
01016 
01017   //return the value
01018   return shwEnCor;
01019 }

Double_t NuReco::GetShowerEnergyNearTrack ( const NtpStRecord ntp,
const NtpSRTrack trk,
Float_t *  nearShowerEnergyDW = 0 
) const

Calculates the shower energy 'near' the track vertex.

Retrieves the shower energy 'near' the track vertex.

nearShowerEnergyDW is the old version of this value, which used the (broken) deweighted shower energy.

Returns zero if there are no showers near enough

Definition at line 5029 of file NuReco.cxx.

References VldContext::GetDetector(), RecRecordImp< T >::GetHeader(), GetShwMedianTime(), RecHeader::GetVldContext(), it, Detector::kNear, NtpSRShowerPulseHeight::linCCgev, NtpStRecord::shw, NtpSRShower::shwph, NtpSRVertex::t, NtpSRShower::vtx, NtpSRTrack::vtx, NtpSRShowerPulseHeight::wtCCgev, NtpSRVertex::x, NtpSRVertex::y, and NtpSRVertex::z.

Referenced by NuExtraction::ExtractNthTrkInfo().

05032 {
05033   Double_t nearshowere = 0;
05034   // Sum of deweighted shower energies. This is probably not a good idea - but
05035   // we used to define this this way before so someone might want the old value
05036   if(nearshowereDW) *nearshowereDW = 0;
05037 
05038   bool hasgoodshower = false;
05039 
05040   const double trkTime = trk.vtx.t;
05041 
05042   const Detector::Detector_t det = ntp.GetHeader().GetVldContext().GetDetector();
05043 
05044   // Loop over all shower entries
05045   for(Int_t it = 0; it < ntp.shw->GetEntries(); it++){
05046     // Grab the shower
05047     const NtpSRShower *shw = dynamic_cast<NtpSRShower *>(ntp.shw->At(it));
05048 
05049     // Apply +75ns, -25ns cut in near detector only - see docdb 6667-v1 p4
05050     if(det == Detector::kNear){
05051       const double shwTime = GetShwMedianTime(ntp, *shw);
05052       const double dt = (shwTime-trkTime)*1e9; // nanoseconds
05053       if(dt > +75 || dt < -25) continue;
05054     }
05055 
05056     // Calculate the vertex seperation
05057     Double_t vertex_sep_sqr = (trk.vtx.x-shw->vtx.x)*(trk.vtx.x-shw->vtx.x) +
05058       (trk.vtx.y-shw->vtx.y)*(trk.vtx.y-shw->vtx.y) +
05059       (trk.vtx.z-shw->vtx.z)*(trk.vtx.z-shw->vtx.z);
05060 
05061     // If the shower vertex is 'near' the track vertex (<1m away)
05062     if(vertex_sep_sqr < 1.0){
05063       nearshowere += shw->shwph.linCCgev;
05064       if(nearshowereDW) *nearshowereDW += shw->shwph.wtCCgev;
05065       hasgoodshower = true;
05066     }
05067   }
05068 
05069   // Match old definition
05070   if(!hasgoodshower && nearshowereDW) *nearshowereDW = -1;
05071 
05072   return nearshowere;
05073 }

const NtpSRShower * NuReco::GetShowerWithIndexX ( const NtpStRecord ntp,
const NtpSREvent evt,
Int_t  index 
) const

Definition at line 2186 of file NuReco.cxx.

References NtpSREvent::nshower, NtpSREvent::shw, and NtpStRecord::shw.

Referenced by NuCounter::CountTrkStdhepId(), NuAnalysis::DemoInfidSRInterface(), NuExtraction::ExtractShwInfo(), NuPlots::FillShwHistos(), GetBestTruthIndex(), GetPrimaryTruthIndex(), and GetSecondaryTruthIndex().

02189 {
02190   TClonesArray& shwTca=(*ntp.shw);
02191 
02192   if (evt.nshower>=index+1 && index>=0){
02193     const NtpSRShower* shw=
02194       dynamic_cast<NtpSRShower*>(shwTca[evt.shw[index]]);
02195     return shw;
02196   }
02197   else {
02198     return 0;
02199   }
02200 }

Int_t NuReco::GetShwMaxPlane ( const NtpStRecord ntp,
const NtpSRShower shw 
) const

Which plane does shw have the most ph deposited in?

Definition at line 3164 of file NuReco.cxx.

References it, Msg::kDebug, MAXMSG, NtpSRShower::nstrip, NtpSRPulseHeight::pe, NtpSRStrip::ph0, NtpSRStrip::ph1, NtpSRStrip::plane, NtpSRShower::stp, and NtpStRecord::stp.

Referenced by NuExtraction::ExtractShwInfo().

03166 {
03167   typedef map<UShort_t, Float_t> planePH_t;
03168   planePH_t planePH;
03169 
03170   for(int i = 0; i < shw.nstrip; ++i){
03171     const NtpSRStrip* stp = (NtpSRStrip*)ntp.stp->At(shw.stp[i]);
03172 
03173     planePH[stp->plane] += stp->ph0.pe+stp->ph1.pe;
03174   }
03175 
03176   Float_t maxPH = 0;
03177   Int_t maxPlane = -1;
03178 
03179   for(planePH_t::iterator it = planePH.begin(); it != planePH.end(); ++it){
03180     if(it->second > maxPH){
03181       maxPH = it->second;
03182       maxPlane = it->first;
03183     }
03184   }
03185 
03186   MAXMSG("NuReco", Msg::kDebug, 100) << "Max plane=" << maxPlane << endl;
03187 
03188   return maxPlane;
03189 }

Double_t NuReco::GetShwMedianTime ( const NtpStRecord ntp,
const NtpSRShower shw 
) const

Definition at line 3122 of file NuReco.cxx.

References NtpSRStrip::index, it, Msg::kDebug, MAXMSG, NtpSRShower::nstrip, NtpSRStrip::ph1, NtpSRStrip::plane, NtpSRPulseHeight::sigcor, NtpSRShower::stp, NtpStRecord::stp, NtpSRStrip::strip, NtpSRStrip::time0, NtpSRStrip::time1, and NtpSRStrip::tpos.

Referenced by GetShowerEnergyNearTrack().

03124 {
03125   //Msg::LogLevel_t logLevel=Msg::kDebug;
03126 
03127   multiset<Double_t> times;
03128   const TClonesArray& stpTca=(*ntp.stp);
03129   //const Int_t numStps=stpTca.GetEntriesFast();
03130 
03131   MAXMSG("NuReco",Msg::kDebug,200)
03132     <<"shw.nstrip="<<shw.nstrip<<endl;
03133   for (Int_t i=0;i<shw.nstrip;i++) {
03134     const NtpSRStrip& stp=
03135       *(dynamic_cast<NtpSRStrip*>(stpTca[shw.stp[i]]));
03136 
03137     Double_t time=stp.time0;
03138     if (time<0 || time>1) time=stp.time1;
03139 
03140     if (time>0 && time<=1) {
03141       times.insert(time);
03142     }
03143     //else just don't put the time in the map - clearly rubbish
03144 
03145     MAXMSG("NuReco",Msg::kDebug,500)
03146       <<"  Strip index="<<stp.index<<", stp="<<stp.strip
03147       <<", t="<<time
03148       <<", pl="<<stp.plane
03149       <<", sigCor="<<stp.ph1.sigcor<<", tpos="<<stp.tpos<<endl;
03150   }
03151 
03152   //get the median time from the map
03153   multiset<Double_t>::const_iterator it=times.begin();
03154   advance(it,times.size()/2);
03155   Double_t medianTime=*it;
03156   MAXMSG("NuReco",Msg::kDebug,100)
03157     <<"Median time="<<medianTime<<endl;
03158 
03159   return medianTime;
03160 }

Float_t NuReco::GetSmallestDeepDistToEdge ( const NuEvent nu  )  const

Definition at line 4893 of file NuReco.cxx.

References PlaneOutline::DistanceToEdge(), PlaneOutline::IsInside(), Msg::kDebug, PlaneCoverage::kNearFull, PlaneCoverage::kNearPartial, PlaneView::kU, PlaneView::kV, MAXMSG, NuEvent::xEvtVtx, and NuEvent::yEvtVtx.

Referenced by CalcEvtVariables(), and TestGetSmallestDeepDistToEdge().

04894 {
04895   //Deep containment is defined as being within the overlap of
04896   //all different plane coverages
04897 
04898   Float_t distUPI=0;
04899   Float_t distVPI=0;
04900   Float_t distUFI=0;
04901   Float_t distVFI=0;
04902   Float_t xedge=0;
04903   Float_t yedge=0;
04904 
04905   PlaneOutline po;
04906 
04907   //calc for U-view partial
04908   po.DistanceToEdge(nu.xEvtVtx,nu.yEvtVtx,PlaneView::kU,
04909                     PlaneCoverage::kNearPartial,
04910                     distUPI,xedge,yedge);
04911   Bool_t isInsideUPI=po.IsInside(nu.xEvtVtx,nu.yEvtVtx,PlaneView::kU,
04912                                  PlaneCoverage::kNearPartial);
04913 
04914   //calc for U-view full
04915   po.DistanceToEdge(nu.xEvtVtx,nu.yEvtVtx,PlaneView::kU,
04916                     PlaneCoverage::kNearFull,
04917                     distUFI,xedge,yedge);
04918   Bool_t isInsideUFI=po.IsInside(nu.xEvtVtx,nu.yEvtVtx,PlaneView::kU,
04919                                  PlaneCoverage::kNearFull);
04920 
04921   //calc for V-view partial
04922   po.DistanceToEdge(nu.xEvtVtx,nu.yEvtVtx,PlaneView::kV,
04923                     PlaneCoverage::kNearPartial,
04924                     distVPI,xedge,yedge);
04925   Bool_t isInsideVPI=po.IsInside(nu.xEvtVtx,nu.yEvtVtx,PlaneView::kV,
04926                                  PlaneCoverage::kNearPartial);
04927 
04928   //calc for V-view full
04929   po.DistanceToEdge(nu.xEvtVtx,nu.yEvtVtx,PlaneView::kV,
04930                     PlaneCoverage::kNearFull,
04931                     distVFI,xedge,yedge);
04932   Bool_t isInsideVFI=po.IsInside(nu.xEvtVtx,nu.yEvtVtx,PlaneView::kV,
04933                                  PlaneCoverage::kNearFull);
04934 
04935   //check that hit has "deep" containment and find
04936   //the closest distance to the edge of the combined overlap region
04937   Float_t smallestDist=999;
04938   if (isInsideUPI && isInsideUFI && isInsideVPI && isInsideVFI){
04939     if (smallestDist>distUPI) smallestDist=distUPI;
04940     if (smallestDist>distUFI) smallestDist=distUFI;
04941     if (smallestDist>distVPI) smallestDist=distVPI;
04942     if (smallestDist>distVFI) smallestDist=distVFI;
04943   }
04944 
04945   //if not deeply contained then find the closest distance
04946   //to the combined overlap region
04947   //this is actually the furthest distance!
04948   if (smallestDist==999) {
04949     smallestDist=0;
04950     if (smallestDist<distUPI && !isInsideUPI) smallestDist=distUPI;
04951     if (smallestDist<distUFI && !isInsideUFI) smallestDist=distUFI;
04952     if (smallestDist<distVPI && !isInsideVPI) smallestDist=distVPI;
04953     if (smallestDist<distVFI && !isInsideVFI) smallestDist=distVFI;
04954 
04955     //make the distance negative for hits outside deep containment
04956     smallestDist*=-1;
04957   }
04958 
04959   if (smallestDist==999) cout<<"Ahhhhhhh"<<endl;
04960 
04961   MAXMSG("NuReco",Msg::kDebug,500)
04962     <<"smallestDist="<<smallestDist
04963     <<", UPI="<<distUPI<<" (in="<<isInsideUPI<<")"
04964     <<", UFI="<<distUFI<<" (in="<<isInsideUFI<<")"
04965     <<", VPI="<<distVPI<<" (in="<<isInsideVPI<<")"
04966     <<", VFI="<<distVFI<<" (in="<<isInsideVFI<<")"<<endl;
04967 
04968   return smallestDist;
04969 }

Int_t NuReco::GetTrackCharge ( Double_t  qp,
bool  isReverse 
) const

Definition at line 1984 of file NuReco.cxx.

01985 {
01986   Int_t charge=qp<0 ? -1 : 1;
01987   if (qp==0) {
01988     if (isReverse) charge=+1;//assume numubar!!!
01989     else           charge=-1;//assume numu!!!
01990   }
01991 
01992   return charge;
01993 }

Int_t NuReco::GetTrackCharge ( const NtpSRTrack trk,
bool  isReverse 
) const

Definition at line 1962 of file NuReco.cxx.

References NtpSRTrack::fit, Msg::kInfo, MAXMSG, NtpSRTrack::momentum, NtpSRFitTrack::pass, and NtpSRMomentum::qp.

Referenced by NuExtraction::ExtractNthTrkInfo(), and NuExtraction::ExtractSAFitInfo().

01963 {
01964   Int_t charge=this->GetTrackCharge(trk.momentum.qp, isReverse);
01965   if (trk.momentum.qp==0) {
01966     if (isReverse) {
01967       MAXMSG("NuReco",Msg::kInfo,3)
01968         <<"Note: assigning charge to be +1 since trk.momentum.qp="
01969         <<trk.momentum.qp<<", trkfitpass="<<trk.fit.pass
01970         <<" and this is RHC" << endl;
01971     }
01972     else {
01973       MAXMSG("NuReco",Msg::kInfo,3)
01974         <<"Note: assigning charge to be -1 since trk.momentum.qp="
01975         <<trk.momentum.qp<<", trkfitpass="<<trk.fit.pass
01976         <<" and this is FHC" << endl;
01977     }
01978   }
01979   return charge;
01980 }

Double_t NuReco::GetTrackEnergy ( const NuEvent nu  )  const

Definition at line 828 of file NuReco.cxx.

References GetTrackEnergyFromCurv(), GetTrackEnergyFromRange(), UseCurvature(), and UseRange().

Referenced by CalcTrkVariables().

00829 {
00830   //get the track energy
00831   //FC
00832   if (this->UseRange(nu)) {
00833     return this->GetTrackEnergyFromRange(nu);
00834   }
00835   //PC
00836   else if (this->UseCurvature(nu)){
00837     return this->GetTrackEnergyFromCurv(nu);
00838   }
00839   else {
00840     cout<<"Ahhhh, can't use range or curvature"<<endl;
00841     return -1;
00842   }
00843 }

Double_t NuReco::GetTrackEnergyFromCurv ( const NuEvent nu  )  const

Definition at line 890 of file NuReco.cxx.

References GetTrackEnergyFromCurvCor(), Msg::kDebug, Msg::kInfo, MAXMSG, NuEvent::qp, and NuEvent::trkEnCorCurv.

Referenced by CalcTrkVariables(), and GetTrackEnergy().

00891 {
00892   MAXMSG("NuReco",Msg::kInfo,1)
00893     <<"GetTrackEnergyFromCurv: (re)doing EnergyCorrection"<<endl;
00894   Double_t trkEn=this->GetTrackEnergyFromCurvCor(nu.qp,nu);
00895   Double_t p=-1;
00896   if (nu.qp) p=1./nu.qp;
00897   MAXMSG("NuReco",Msg::kDebug,3000)
00898     <<"Curv: trkEn="<<trkEn<<", trkEnCorCurv="<<nu.trkEnCorCurv
00899     <<", 1/qp="<<p<<endl;
00900   return trkEn;
00901 }

Double_t NuReco::GetTrackEnergyFromCurvCor ( Double_t  qp,
const NuEvent nu 
) const

this function should only ever be called if the track exists there is no protection against value being initialised to -1 since it is a perfectly valid value for qp

Definition at line 908 of file NuReco.cxx.

References CapTrackMomentum(), EnergyCorrections::FullyCorrectSignedMomentumFromCurvature(), GetVldContext(), kMuonMassSquared, NuEvent::releaseType, and SQR.

Referenced by NuExtraction::ExtractNthTrkInfo(), and GetTrackEnergyFromCurv().

00910 {
00911   if(qp == 0) return 0;
00912 
00913   Double_t p=1./qp;
00914   this->CapTrackMomentum(p);
00915   VldContext vc=this->GetVldContext(nu);
00916   p=EnergyCorrections::FullyCorrectSignedMomentumFromCurvature(p,vc,nu.releaseType);
00917   return sqrt(SQR(p)+kMuonMassSquared);
00918 }

Double_t NuReco::GetTrackEnergyFromRange ( const NuEvent nu  )  const

Definition at line 847 of file NuReco.cxx.

References GetTrackEnergyFromRangeCor(), Msg::kDebug, Msg::kInfo, MAXMSG, NuEvent::trkEnCorRange, and NuEvent::trkMomentumRange.

Referenced by CalcTrkVariables(), and GetTrackEnergy().

00848 {
00849   MAXMSG("NuReco",Msg::kInfo,1) <<
00850     "GetTrackEnergyFromRange: (re)doing EnergyCorrection" << endl;
00851   Double_t trkEn=this->GetTrackEnergyFromRangeCor(nu.trkMomentumRange, nu);
00852   MAXMSG("NuReco",Msg::kDebug,3000) << "Range: trkEn="
00853                                     << trkEn
00854                                     << ", trkEnCorRange="
00855                                     << nu.trkEnCorRange
00856                                     << ", trkMomentumRange="
00857                                     << nu.trkMomentumRange << endl;
00858   return trkEn;
00859 }

Double_t NuReco::GetTrackEnergyFromRangeCor ( Double_t  trkMomentumRange,
const NuEvent nu 
) const

Definition at line 872 of file NuReco.cxx.

References CapTrackMomentum(), EnergyCorrections::FullyCorrectMomentumFromRange(), GetVldContext(), kMuonMassSquared, NuEvent::releaseType, and SQR.

Referenced by NuExtraction::ExtractNthTrkInfo(), and GetTrackEnergyFromRange().

00874 {
00875   //check if the track exists
00876   if (trkMomentumRange<0) return -1;
00877 
00878   this->CapTrackMomentum(trkMomentumRange);
00879   //calc the corrected momentum from range
00880   Double_t mr=0;
00881   VldContext vc=this->GetVldContext(nu);
00882   mr=EnergyCorrections::FullyCorrectMomentumFromRange
00883     (trkMomentumRange,vc,nu.releaseType);
00884 
00885   return sqrt(SQR(mr)+kMuonMassSquared);
00886 }

Int_t NuReco::GetTrackFirstStrip ( const NtpStRecord ntp,
const NtpSRTrack trk 
) const

Definition at line 5096 of file NuReco.cxx.

References NtpStRecord::stp, NtpSRTrack::stp, and NtpSRStrip::strip.

Referenced by NuExtraction::ExtractNthTrkInfo().

05097 {
05098   NtpSRStrip * firststrip =
05099     dynamic_cast<NtpSRStrip *>(ntp.stp->At(trk.stp[0]));
05100   return firststrip->strip;
05101 }

Bool_t NuReco::GetTrackFirstStripIsU ( const NtpStRecord ntp,
const NtpSRTrack trk 
) const

Definition at line 5133 of file NuReco.cxx.

References PlaneView::kU, NtpSRStrip::planeview, NtpStRecord::stp, and NtpSRTrack::stp.

Referenced by NuExtraction::ExtractNthTrkInfo().

05134 {
05135   NtpSRStrip * firststrip =
05136     dynamic_cast<NtpSRStrip *>(ntp.stp->At(trk.stp[0]));
05137   if(firststrip->planeview == PlaneView::kU) return true;
05138   else return false;
05139 }

Int_t NuReco::GetTrackFirstUStrip ( const NtpStRecord ntp,
const NtpSRTrack trk 
) const

Definition at line 5105 of file NuReco.cxx.

References PlaneView::kU, NtpSRTrack::nstrip, NtpSRStrip::planeview, NtpStRecord::stp, NtpSRTrack::stp, and NtpSRStrip::strip.

Referenced by NuExtraction::ExtractNthTrkInfo().

05106 {
05107   // Look for the first U strip in the track
05108   for(int i = 0; i < trk.nstrip; i++) {
05109     NtpSRStrip * firststrip =
05110       dynamic_cast<NtpSRStrip *>(ntp.stp->At(trk.stp[i]));
05111     if(firststrip->planeview == PlaneView::kU) return firststrip->strip;
05112   }
05113   // There is no U strip (unlikely)
05114   return -1;
05115 }

Int_t NuReco::GetTrackFirstVStrip ( const NtpStRecord ntp,
const NtpSRTrack trk 
) const

Definition at line 5119 of file NuReco.cxx.

References PlaneView::kV, NtpSRTrack::nstrip, NtpSRStrip::planeview, NtpStRecord::stp, NtpSRTrack::stp, and NtpSRStrip::strip.

Referenced by NuExtraction::ExtractNthTrkInfo().

05120 {
05121   // Look for the first U strip in the track
05122   for(int i = 0; i < trk.nstrip; i++) {
05123     NtpSRStrip * firststrip =
05124       dynamic_cast<NtpSRStrip *>(ntp.stp->At(trk.stp[i]));
05125     if(firststrip->planeview == PlaneView::kV) return firststrip->strip;
05126   }
05127   // There is no V strip (unlikely)
05128   return -1;
05129 }

Int_t NuReco::GetTrackLastStrip ( const NtpStRecord ntp,
const NtpSRTrack trk 
) const

Definition at line 5143 of file NuReco.cxx.

References NtpSRTrack::nstrip, NtpStRecord::stp, NtpSRTrack::stp, and NtpSRStrip::strip.

Referenced by NuExtraction::ExtractNthTrkInfo().

05144 {
05145   NtpSRStrip * laststrip =
05146     dynamic_cast<NtpSRStrip *>(ntp.stp->At(trk.stp[trk.nstrip-1]));
05147   return laststrip->strip;
05148 }

Bool_t NuReco::GetTrackLastStripIsU ( const NtpStRecord ntp,
const NtpSRTrack trk 
) const

Definition at line 5180 of file NuReco.cxx.

References PlaneView::kU, NtpSRTrack::nstrip, NtpSRStrip::planeview, NtpStRecord::stp, and NtpSRTrack::stp.

Referenced by NuExtraction::ExtractNthTrkInfo().

05181 {
05182   NtpSRStrip * laststrip =
05183     dynamic_cast<NtpSRStrip *>(ntp.stp->At(trk.stp[trk.nstrip-1]));
05184   if(laststrip->planeview == PlaneView::kU) return true;
05185   else return false;
05186 }

Int_t NuReco::GetTrackLastUStrip ( const NtpStRecord ntp,
const NtpSRTrack trk 
) const

Definition at line 5152 of file NuReco.cxx.

References PlaneView::kU, NtpSRTrack::nstrip, NtpSRStrip::planeview, NtpStRecord::stp, NtpSRTrack::stp, and NtpSRStrip::strip.

Referenced by NuExtraction::ExtractNthTrkInfo().

05153 {
05154   // Loop backwards for the first u strip
05155   for(Int_t i = trk.nstrip-1; i >= 0; i--) {
05156     NtpSRStrip * laststrip =
05157       dynamic_cast<NtpSRStrip *>(ntp.stp->At(trk.stp[i]));
05158     if(laststrip->planeview == PlaneView::kU) return laststrip->strip;
05159   }
05160   // There is no U strip (unlikely)
05161   return -1;
05162 }

Int_t NuReco::GetTrackLastVStrip ( const NtpStRecord ntp,
const NtpSRTrack trk 
) const

Definition at line 5166 of file NuReco.cxx.

References PlaneView::kV, NtpSRTrack::nstrip, NtpSRStrip::planeview, NtpStRecord::stp, NtpSRTrack::stp, and NtpSRStrip::strip.

Referenced by NuExtraction::ExtractNthTrkInfo().

05167 {
05168   // Loop backwards for the first v strip
05169   for(Int_t i = trk.nstrip-1; i >= 0; i--) {
05170     NtpSRStrip * laststrip =
05171       dynamic_cast<NtpSRStrip *>(ntp.stp->At(trk.stp[i]));
05172     if(laststrip->planeview == PlaneView::kV) return laststrip->strip;
05173   }
05174   // There is no U strip (unlikely)
05175   return -1;
05176 }

const NtpSRTrack * NuReco::GetTrackWithIndexX ( const NtpStRecord ntp,
const NtpSREvent evt,
Int_t  index 
) const

Definition at line 2168 of file NuReco.cxx.

References NtpSREvent::ntrack, NtpStRecord::trk, and NtpSREvent::trk.

Referenced by NuDemoModule::Ana(), NuAnalysis::ChargeSeparationOneSnarl(), NuAnalysis::DemoInfidSRInterface(), NuAnalysis::EnergySpect(), NuExtraction::ExtractMajorityCurvature(), NuExtraction::ExtractNthTrkInfo(), NuPlots::FillShwHistos(), GetBestTruthIndex(), NuPIDInterface::GetJmIDNthTrk(), GetPrimaryTruthIndex(), NuPIDInterface::GetRoIDNthTrk(), GetSecondaryTruthIndex(), and NuAnalysis::N_1().

02171 {
02172   TClonesArray& trkTca=(*ntp.trk);
02173 
02174   if (evt.ntrack>=index+1 && index>=0){
02175     const NtpSRTrack* trk=
02176       dynamic_cast<NtpSRTrack*>(trkTca[evt.trk[index]]);
02177     return trk;
02178   }
02179   else {
02180     return 0;
02181   }
02182 }

Double_t NuReco::GetTrkQPFraction ( const NtpSRTrack trk  )  const

Definition at line 2413 of file NuReco.cxx.

References Msg::kDebug, MAXMSG, NtpSRTrack::nstrip, and NtpSRTrack::stpfitqp.

Referenced by NuExtraction::ExtractNthTrkInfo().

02414 {
02415   Int_t nPositive=0;
02416   Int_t nNegative=0;
02417   Int_t nZero=0;
02418 
02419   for (Int_t i=0;i<trk.nstrip;i++){
02420     //Double_t x=trk.stpx[i];
02421     Double_t stpfitqp=trk.stpfitqp[i];
02422 
02423     //count number of strips with positive and negative qp
02424     if (stpfitqp>0) nPositive++;
02425     else if (stpfitqp<0) nNegative++;
02426     else nZero++;
02427 
02428     MAXMSG("NuReco",Msg::kDebug,1000)
02429       <<"stpfitqp="<<stpfitqp<<endl;
02430   }
02431 
02432   Double_t qpFraction=-1;
02433   if (trk.nstrip>0) qpFraction=1.*nPositive/trk.nstrip;
02434 
02435   if (trk.nstrip!=nPositive+nNegative) {
02436     MAXMSG("NuReco",Msg::kDebug,100)
02437       <<"??? stpfitqp: nPos="<<nPositive<<", nNeg="<<nNegative
02438       <<", nZero="<<nZero<<", sumN+P="<<nPositive+nNegative
02439       <<", trkn="<<trk.nstrip
02440       <<", qpFraction="<<qpFraction
02441       <<endl;
02442   }
02443   else {
02444     MAXMSG("NuReco",Msg::kDebug,100)
02445       <<"stpfitqp: nPos="<<nPositive<<", nNeg="<<nNegative
02446       <<", nZero="<<nZero<<", sumN+P="<<nPositive+nNegative
02447       <<", trkn="<<trk.nstrip
02448       <<", qpFraction="<<qpFraction
02449       <<endl;
02450   }
02451 
02452   return qpFraction;
02453 }

Int_t NuReco::GetTrueTrackId ( const NtpStRecord ntp,
const NtpSRTrack trk 
) const

Get the true track identity.

Definition at line 5706 of file NuReco.cxx.

References NtpMCStdHep::IdHEP, NtpSRTrack::index, Msg::kError, MSG, NtpStRecord::stdhep, NtpStRecord::thtrk, and NtpTHTrack::trkstdhep.

Referenced by NuExtraction::ExtractNthTrkInfo().

05707 {
05708   // Firstly, find the THTrack object by searching the MC info
05709   //get the track mc
05710   TClonesArray& thtrkTca=(*ntp.thtrk);//TruthHelper Track TCA
05711   // Are there any entries?
05712   if (thtrkTca.GetEntriesFast() <= 0) return 0;
05713 
05714   // Get the THTrack object
05715   const NtpTHTrack* thtrk= dynamic_cast<NtpTHTrack*>(thtrkTca[trk.index]);
05716 
05717   if(!thtrk) {
05718     MSG("NuReco",Msg::kError) << "Truth track information available but track "
05719                               << trk.index << " not found!" << endl;
05720     return 0;
05721   }
05722 
05723   // Grab the Stdhep entry
05724   NtpMCStdHep * stdhep =
05725     dynamic_cast<NtpMCStdHep *>(ntp.stdhep->At(thtrk->trkstdhep));
05726 
05727   if(!stdhep) {
05728     MSG("NuReco",Msg::kError) << "Truth Helper, but no stdhep!\n";
05729     return 0;
05730   }
05731 
05732   return stdhep->IdHEP;
05733 }

void NuReco::GetTruthInfo ( const NtpStRecord ntp,
const NtpMCTruth mc,
NuEvent nu 
) const

Definition at line 3473 of file NuReco.cxx.

References NtpMCTruth::a, NuEvent::aMC, CalcExtraTruthVariables(), NuEvent::energyMC, NtpMCTruth::flux, NuCutter::GetCut(), GetHadronicFinalState(), GetInitialState(), GetMuonContainmentMC(), GetMuonFirstHitEnergy(), GetMuonLastHitEnergy(), GetNucleus(), NuIntranuke::GetNucrad(), NuIntranuke::GetNwts(), GetPreInukeFinalStateVars(), NuIntranuke::GetWeight(), NuIntranuke::GetWrad(), NuEvent::hadronicFinalStateMC, NuEvent::iaction, NtpMCTruth::iaction, NuCut::InFidVolTrueEvt(), NuEvent::initialStateMC, NuEvent::inu, NtpMCTruth::inu, NuEvent::InukeFormTN, NuEvent::InukeFormTP, NuEvent::InukeNknockN, NuEvent::InukeNknockP, NuEvent::InukeNNPiN, NuEvent::InukeNNPiP, NuEvent::InukeNucrad, NuEvent::InukeNwts, NuEvent::InukeNXsecN, NuEvent::InukeNXsecP, NuEvent::InukePi2PiN, NuEvent::InukePi2PiP, NuEvent::InukePiAbsorbN, NuEvent::InukePiAbsorbP, NuEvent::InukePiCExchgN, NuEvent::InukePiCExchgP, NuEvent::InukePiEScatN, NuEvent::InukePiEScatP, NuEvent::InukePiInEScatN, NuEvent::InukePiInEScatP, NuEvent::InukePiXsecN, NuEvent::InukePiXsecP, NuEvent::InukeWrad, NtpMCTruth::inunoosc, NuEvent::inunoosc, NuEvent::iresonance, NtpMCTruth::iresonance, NuEvent::isInFidVolCCMC, NuEvent::itg, NtpMCTruth::itg, NuEvent::mu1EnMC, NuEvent::mu1PxMC, NuEvent::mu1PyMC, NuEvent::mu1PzMC, NtpMCFluxInfo::ndecay, NuEvent::Ndecay, NtpMCFluxInfo::ndxdzfar, NuEvent::NdxdzFar, NuEvent::NdxdzNea, NtpMCFluxInfo::ndxdznear, NtpMCFluxInfo::ndydzfar, NuEvent::NdydzFar, NuEvent::NdydzNea, NtpMCFluxInfo::ndydznear, NtpMCFluxInfo::necm, NuEvent::Necm, NuEvent::NenergyF, NtpMCFluxInfo::nenergyfar, NuEvent::NenergyN, NtpMCFluxInfo::nenergynear, NuEvent::neuEnMC, NuEvent::neuPxMC, NuEvent::neuPyMC, NuEvent::neuPzMC, NtpMCFluxInfo::nimpwt, NuEvent::Nimpwt, NuEvent::Npz, NtpMCFluxInfo::npz, NuEvent::nucleusMC, NtpMCFluxInfo::nwtfar, NuEvent::NWtFar, NtpMCFluxInfo::nwtnear, NuEvent::NWtNear, NtpMCTruth::p4mu1, NtpMCTruth::p4neu, NtpMCTruth::p4shw, NtpMCTruth::p4tgt, NtpMCFluxInfo::pdpx, NuEvent::pdPx, NtpMCFluxInfo::pdpy, NuEvent::pdPy, NtpMCFluxInfo::pdpz, NuEvent::pdPz, NtpMCFluxInfo::ppdxdz, NuEvent::ppdxdz, NtpMCFluxInfo::ppdydz, NuEvent::ppdydz, NtpMCFluxInfo::ppenergy, NuEvent::ppenergy, NtpMCFluxInfo::ppmedium, NuEvent::ppmedium, NuEvent::pppz, NtpMCFluxInfo::pppz, NtpMCFluxInfo::ppvx, NuEvent::ppvx, NtpMCFluxInfo::ppvy, NuEvent::ppvy, NtpMCFluxInfo::ppvz, NuEvent::ppvz, NuEvent::ptype, NtpMCFluxInfo::ptype, NtpMCTruth::q2, NuEvent::q2MC, NuIntranuke::Reweight(), NuEvent::shwEn2MC, NuEvent::shwEnMC, NtpMCFluxInfo::tgen, NuEvent::tgen, NuEvent::tgtEnMC, NuEvent::tgtPxMC, NuEvent::tgtPyMC, NuEvent::tgtPzMC, NuEvent::tptype, NtpMCFluxInfo::tptype, NtpMCFluxInfo::tpx, NuEvent::tpx, NtpMCFluxInfo::tpy, NuEvent::tpy, NtpMCFluxInfo::tpz, NuEvent::tpz, NuEvent::trkContainmentMC, NuEvent::trkEn2MC, NuEvent::trkEndEnMC, NuEvent::trkEnMC, NuEvent::trkStartEnMC, NtpMCFluxInfo::tvx, NuEvent::tvx, NtpMCFluxInfo::tvy, NuEvent::tvy, NtpMCFluxInfo::tvz, NuEvent::tvz, NtpMCTruth::vtxx, NuEvent::vtxxMC, NtpMCTruth::vtxy, NuEvent::vtxyMC, NtpMCTruth::vtxz, NuEvent::vtxzMC, NtpMCFluxInfo::vx, NuEvent::Vx, NtpMCFluxInfo::vy, NuEvent::Vy, NtpMCFluxInfo::vz, NuEvent::Vz, NtpMCTruth::w2, NuEvent::w2MC, NtpMCTruth::x, NuEvent::xMC, NtpMCTruth::y, NuEvent::y2MC, NuEvent::yMC, NtpMCTruth::z, and NuEvent::zMC.

03475 {
03476   //get the true energy not carried away by interacting neutrino
03477   Double_t trueEn=mc.y*mc.p4neu[3];//NC
03478   if (mc.iaction==1) trueEn=mc.p4neu[3];//CC
03479 
03480   Double_t muEn=(1-mc.y)*mc.p4neu[3];
03481   if (mc.iaction==0) muEn=0;//NC
03482   Double_t hadEn=mc.y*mc.p4neu[3];
03483 
03484   nu.energyMC=trueEn;//y*nuEn for NC
03485   nu.neuEnMC=mc.p4neu[3];
03486   nu.neuPxMC=mc.p4neu[0];
03487   nu.neuPyMC=mc.p4neu[1];
03488   nu.neuPzMC=mc.p4neu[2];
03489   nu.mu1EnMC=fabs(mc.p4mu1[3]); // remove the sign on the muon energy!
03490   nu.mu1PxMC=mc.p4mu1[0];
03491   nu.mu1PyMC=mc.p4mu1[1];
03492   nu.mu1PzMC=mc.p4mu1[2];
03493   nu.tgtEnMC=mc.p4tgt[3];
03494   nu.tgtPxMC=mc.p4tgt[0];
03495   nu.tgtPyMC=mc.p4tgt[1];
03496   nu.tgtPzMC=mc.p4tgt[2];
03497   nu.zMC=static_cast<Int_t>(mc.z);
03498   nu.aMC=static_cast<Int_t>(mc.a);
03499   nu.yMC=mc.y;
03500   nu.y2MC=mc.p4shw[3]/(fabs(mc.p4mu1[3])+mc.p4shw[3]);
03501   nu.xMC=mc.x;
03502   nu.q2MC=mc.q2;
03503   nu.w2MC=mc.w2;
03504   nu.trkEnMC=mc.p4mu1[3];
03505   nu.trkEn2MC=muEn;
03506   nu.shwEnMC=mc.p4shw[3];
03507   nu.shwEn2MC=hadEn;
03508   nu.iaction=mc.iaction;
03509   nu.iresonance=mc.iresonance;
03510   nu.inu=mc.inu;
03511   nu.inunoosc=mc.inunoosc;
03512   nu.itg=mc.itg;
03513 
03514   // Get the energy of the last and first track hit
03515   nu.trkStartEnMC = this->GetMuonFirstHitEnergy(ntp, mc);
03516   nu.trkEndEnMC   = this->GetMuonLastHitEnergy(ntp, mc);
03517   // Get the 'true containment' value
03518   nu.trkContainmentMC = this->GetMuonContainmentMC(ntp, mc);
03519 
03520   nu.vtxxMC=mc.vtxx;
03521   nu.vtxyMC=mc.vtxy;
03522   nu.vtxzMC=mc.vtxz;
03523 
03524   nu.Npz=mc.flux.npz;
03525   nu.NdxdzNea=mc.flux.ndxdznear;
03526   nu.NdydzNea=mc.flux.ndydznear;
03527   nu.NenergyN=mc.flux.nenergynear;
03528   nu.NWtNear=mc.flux.nwtnear;
03529   nu.NdxdzFar=mc.flux.ndxdzfar;
03530   nu.NdydzFar=mc.flux.ndydzfar;
03531   nu.NenergyF=mc.flux.nenergyfar;
03532   nu.NWtFar=mc.flux.nwtfar;
03533   nu.Ndecay=mc.flux.ndecay;
03534   nu.Vx=mc.flux.vx;
03535   nu.Vy=mc.flux.vy;
03536   nu.Vz=mc.flux.vz;
03537   nu.pdPx=mc.flux.pdpx;
03538   nu.pdPy=mc.flux.pdpy;
03539   nu.pdPz=mc.flux.pdpz;
03540   nu.ppdxdz=mc.flux.ppdxdz;
03541   nu.ppdydz=mc.flux.ppdydz;
03542   nu.pppz=mc.flux.pppz;
03543   nu.ppenergy=mc.flux.ppenergy;
03544   nu.ppmedium=mc.flux.ppmedium;
03545   nu.ppvx=mc.flux.ppvx;
03546   nu.ppvy=mc.flux.ppvy;
03547   nu.ppvz=mc.flux.ppvz;
03548   nu.ptype=mc.flux.ptype;
03549   nu.Necm=mc.flux.necm;
03550   nu.Nimpwt=mc.flux.nimpwt;
03551   nu.tvx=mc.flux.tvx;
03552   nu.tvy=mc.flux.tvy;
03553   nu.tvz=mc.flux.tvz;
03554   nu.tpx=mc.flux.tpx;
03555   nu.tpy=mc.flux.tpy;
03556   nu.tpz=mc.flux.tpz;
03557   nu.tptype=mc.flux.tptype;
03558   nu.tgen=mc.flux.tgen;
03559 
03560   //
03561   // These are the 10 intranuke weights
03562   //
03563 
03564   static NuIntranuke inuke;
03565   if(inuke.Reweight(&ntp,&mc))
03566     {
03567       nu.InukeNwts        =  inuke.GetNwts()   ;
03568       nu.InukePiCExchgP   =  inuke.GetWeight(0) ;
03569       nu.InukePiCExchgN   =  inuke.GetWeight(1) ;
03570       nu.InukePiEScatP    =  inuke.GetWeight(2) ;
03571       nu.InukePiEScatN    =  inuke.GetWeight(3) ;
03572       nu.InukePiInEScatP  =  inuke.GetWeight(4) ;
03573       nu.InukePiInEScatN  =  inuke.GetWeight(5) ;
03574       nu.InukePiAbsorbP   =  inuke.GetWeight(6) ;
03575       nu.InukePiAbsorbN   =  inuke.GetWeight(7) ;
03576       nu.InukePi2PiP      =  inuke.GetWeight(8) ;
03577       nu.InukePi2PiN      =  inuke.GetWeight(9) ;
03578       nu.InukeNknockP     =  inuke.GetWeight(10) ;
03579       nu.InukeNknockN     =  inuke.GetWeight(11) ;
03580       nu.InukeNNPiP       =  inuke.GetWeight(12) ;
03581       nu.InukeNNPiN       =  inuke.GetWeight(13) ;
03582       nu.InukeFormTP      =  inuke.GetWeight(14) ;
03583       nu.InukeFormTN      =  inuke.GetWeight(15) ;
03584       nu.InukePiXsecP     =  inuke.GetWeight(16) ;
03585       nu.InukePiXsecN     =  inuke.GetWeight(17) ;
03586       nu.InukeNXsecP      =  inuke.GetWeight(18) ;
03587       nu.InukeNXsecN      =  inuke.GetWeight(19) ;
03588       nu.InukeNucrad      =  inuke.GetNucrad() ;
03589       nu.InukeWrad        =  inuke.GetWrad();
03590     }
03591 
03592   //these are custom values so calculate last since they depend on
03593   //the values stored in the NuEvent
03594 
03595   this->CalcExtraTruthVariables(nu);
03596 
03597   nu.nucleusMC=this->GetNucleus(ntp,nu);
03598   nu.initialStateMC=this->GetInitialState(ntp,nu);
03599   nu.hadronicFinalStateMC=this->GetHadronicFinalState(ntp,nu);
03600   this->GetPreInukeFinalStateVars(ntp,nu);
03601 
03602   NuCutter cutter("CC0720Std");
03603   nu.isInFidVolCCMC = cutter.GetCut()->InFidVolTrueEvt(nu);
03604 
03605 }

void NuReco::GetTruthInfo ( const NtpStRecord ntp,
const NtpSREvent evt,
NuEvent nu 
) const

Definition at line 3420 of file NuReco.cxx.

References GetPrimaryTruthIndex(), GetSecondaryTruthIndex(), NtpMCTruth::iaction, Msg::kDebug, Msg::kInfo, MAXMSG, NtpStRecord::mc, NuEvent::mc, NtpMCTruth::p4mu1, NtpMCTruth::p4neu, NtpMCTruth::p4shw, NtpMCTruth::p4tgt, NuEvent::simFlag, and NtpMCTruth::y.

Referenced by NuDemoModule::Ana(), NuAnalysis::ChargeSignCut(), NuAnalysis::DoExtractions(), NuAnalysis::Efficiencies(), NuAnalysis::EnergySpect(), NuAnalysis::LIRejectionTest(), and NuAnalysis::LoopOverTruthInfo().

03422 {
03423   //get the index of the mc neutrino interaction
03424   //Mad uses the primary track, so use that here
03425   this->GetPrimaryTruthIndex(ntp,evt,nu);
03426   this->GetSecondaryTruthIndex(ntp,evt,nu);
03427 
03428   //MadBase::LoadTruthForRecoTH does not use the "best" trk/shw
03429   //this->GetBestTruthIndex(ntp,evt,nu);
03430 
03431   //use the index
03432   if (nu.mc<0) {
03433     MAXMSG("NuReco",Msg::kInfo,1)
03434       <<"Not Getting TruthInfo for simFlag="<<nu.simFlag<<endl;
03435     return;
03436   }
03437   MAXMSG("NuReco",Msg::kInfo,1)
03438     <<"Getting TruthInfo for simFlag="<<nu.simFlag<<endl;
03439 
03440   //now get the mc object (neutrino interaction) that
03441   //corresponds to the trk using the nu.mc index
03442   TClonesArray& mcTca=(*ntp.mc);//TruthHelper Track TCA
03443   const NtpMCTruth& mc=
03444     *(dynamic_cast<NtpMCTruth*>(mcTca[nu.mc]));
03445 
03446   //extract the info from this mc object
03447   this->GetTruthInfo(ntp,mc,nu);
03448 
03449   if (mc.iaction==1){
03450     MAXMSG("NuReco",Msg::kDebug,300)
03451       <<"y="<<mc.y<<endl
03452       <<"p4neu[3]="<<mc.p4neu[3]<<", p4tgt[3]="<<mc.p4tgt[3]
03453       <<", sum="<<mc.p4neu[3]+mc.p4tgt[3]
03454       <<endl
03455       <<"p4mu1[3]="<<mc.p4mu1[3]<<", mc.p4shw[3]="<<mc.p4shw[3]
03456       <<", sum="<<fabs(mc.p4mu1[3])+mc.p4shw[3]
03457       <<", labY="<<mc.p4shw[3]/(fabs(mc.p4mu1[3])+mc.p4shw[3])
03458       <<endl;
03459   }
03460   else if (mc.iaction==0){
03461     MAXMSG("NuReco",Msg::kDebug,300)
03462       <<"NC: y="<<mc.y<<endl
03463       <<"p4neu[3]="<<mc.p4neu[3]
03464       <<", p4tgt[3]="<<mc.p4tgt[3]
03465       <<endl
03466       <<"p4mu1[3]="<<mc.p4mu1[3]<<", p4shw[3]="<<mc.p4shw[3]
03467       <<endl;
03468   }
03469 }

VldContext NuReco::GetVldContext ( const NuEvent nu  )  const

Definition at line 2302 of file NuReco.cxx.

References NuEvent::detector, NuEvent::simFlag, NuEvent::timeNanoSec, and NuEvent::timeSec.

Referenced by CalcExtraTruthVariables(), NuExtraction::ExtractBeamInfoDB(), NuExtraction::ExtractCoilCurrent(), NuExtraction::ExtractCoilInfo(), NuExtraction::ExtractDataQuality(), NuExtraction::ExtractSAFitInfo(), NuExtraction::ExtractTimeToNearestSpill(), NuPlots::FillDetectorEdge(), GetShowerEnergyCor(), GetTrackEnergyFromCurvCor(), and GetTrackEnergyFromRangeCor().

02303 {
02304   //build the vc from the NuEvent
02305   VldTimeStamp time(nu.timeSec,nu.timeNanoSec);
02306   //VldContext (const Detector::Detector_t &detector, const SimFlag::SimFlag_t mcflag, const VldTimeStamp &time)
02307 
02308   VldContext vc(static_cast<Detector::Detector_t>(nu.detector),
02309                 static_cast<SimFlag::SimFlag_t>(nu.simFlag),time);
02310   return vc;
02311 }

bool NuReco::InitializeShowerEnergykNN ( NuKDTree< double, 3 > *  kdTree,
Detector::Detector_t  det,
bool  hornReverse,
std::vector< double > &  C,
double &  cutoff_lo,
double &  cutoff_hi,
int &  neighbours 
) const

Helper function for GetShowerEnergykNN.

C, cutoff_lo and cutoff_hi are the constants to use in kNN energy corrections. Will be called automatically on first call to GetShowerEnergykNN Returns false if we fail to find the training file

Referenced by GetShowerEnergykNN().

Bool_t NuReco::IsTrkWithDimuon ( const NtpStRecord ntp,
const NtpSRTrack trk 
) const

Definition at line 2916 of file NuReco.cxx.

References NtpMCStdHep::child, NtpMCStdHep::IdHEP, NtpSRTrack::index, NtpMCStdHep::index, Msg::kDebug, Msg::kInfo, NtpMCStdHep::mass, MAXMSG, NtpStRecord::mc, NtpMCStdHep::mc, NtpTHTrack::neumc, NtpMCStdHep::p4, NtpMCStdHep::parent, NtpMCTruth::stdhep, NtpStRecord::stdhep, and NtpStRecord::thtrk.

Referenced by NuCounter::CountTrkStdhepId().

02918 {
02919   TClonesArray& thtrkTca=(*ntp.thtrk);//TruthHelper Event TCA
02920   const Int_t numthtrks=thtrkTca.GetEntriesFast();
02921   if (numthtrks<=0) {
02922     MAXMSG("NuReco",Msg::kDebug,1)
02923       <<"No THTracks, so can't do IsDimuon..."<<endl;
02924     return false;
02925   }
02926   MAXMSG("NuReco",Msg::kDebug,1)
02927     <<"Found THTrack, IsDimuon..."<<endl;
02928   const NtpTHTrack& thtrk=
02929     *dynamic_cast<NtpTHTrack*>(thtrkTca[trk.index]);
02930 
02931   //now get the mc object (neutrino interaction) that
02932   //corresponds to the trk using the thtrk.neumc index
02933   TClonesArray& mcTca=(*ntp.mc);
02934   const NtpMCTruth& mc=
02935     *(dynamic_cast<NtpMCTruth*>(mcTca[thtrk.neumc]));
02936 
02937   TClonesArray& hepTca=(*ntp.stdhep);
02938   //const Int_t numHeps=hepTca.GetEntriesFast();
02939 
02940   Int_t charmEvent=-1;
02941   Bool_t isDimuon=false;
02942 
02943   Int_t child0=-999;
02944   Int_t child1=-999;
02945 
02946   //loop over stdhep
02947   for (Int_t ihep=mc.stdhep[0];ihep<=mc.stdhep[1];++ihep) {
02948     const NtpMCStdHep& stdhep=
02949       *dynamic_cast<NtpMCStdHep*>(hepTca[ihep]);
02950 
02951     if (abs(stdhep.IdHEP)==411 || abs(stdhep.IdHEP)==421 ||
02952         abs(stdhep.IdHEP)==431 || abs(stdhep.IdHEP)==4122){
02953       charmEvent=stdhep.mc;
02954       MAXMSG("NuReco",Msg::kDebug,3000)
02955         <<"Found Charm particle, mc="<<charmEvent
02956         <<", ihep="<<ihep
02957         <<", id="<<stdhep.IdHEP
02958         <<", child=["<<stdhep.child[0]<<","<<stdhep.child[1]<<"]"
02959         <<endl;
02960 
02961       child0=stdhep.child[0];
02962       child1=stdhep.child[1];
02963     }
02964     else if ((abs(stdhep.IdHEP)>4000 && abs(stdhep.IdHEP)<5000) ||
02965              (abs(stdhep.IdHEP)>400 && abs(stdhep.IdHEP)<500)) {
02966       MAXMSG("NuReco",Msg::kInfo,3000)
02967         <<endl<<endl
02968         <<"What is this particle??? Charm?, mc="<<charmEvent
02969         <<", ihep="<<ihep
02970         <<", id="<<stdhep.IdHEP
02971         <<", child=["<<stdhep.child[0]<<","<<stdhep.child[1]<<"]"
02972         <<endl<<endl<<endl;
02973     }
02974 
02975     if ((Int_t) stdhep.index>=child0 && (Int_t) stdhep.index<=child1){
02976       MAXMSG("NuReco",Msg::kDebug,3000)
02977         <<"Found Charm child..."
02978         <<", i="<<stdhep.index
02979         <<", child0="<<child0
02980         <<", child1="<<child1
02981         <<", id="<<stdhep.IdHEP
02982         <<", parent=["<<stdhep.parent[0]<<","<<stdhep.parent[1]<<"]"
02983         <<endl;
02984       if (abs(stdhep.IdHEP)==13){
02985         isDimuon=true;
02986         MAXMSG("NuReco",Msg::kDebug,3000)
02987           <<"It's a muon!!!"
02988           <<" m="<<stdhep.mass
02989           <<", E="<<stdhep.p4[3]<<endl<<endl;
02990         break;
02991       }
02992     }
02993   }
02994 
02995   if (isDimuon) return true;
02996   else return false;
02997 }

Bool_t NuReco::IsTrkWithMuonFromKaonDecay ( const NtpStRecord ntp,
const NtpSRTrack trk 
) const

this doesn't actually check that the tracked hits are from a muon it just checks that there was a muon in the THTrack neumc event

Definition at line 2775 of file NuReco.cxx.

References NtpMCStdHep::child, NtpMCStdHep::IdHEP, NtpSRTrack::index, NtpMCStdHep::index, Msg::kDebug, Msg::kWarning, NtpMCStdHep::mass, MAXMSG, NtpStRecord::mc, NtpMCStdHep::mc, MSG, NtpTHTrack::neumc, NtpMCStdHep::p4, NtpMCStdHep::parent, PrintStdhep(), NtpMCTruth::stdhep, NtpStRecord::stdhep, and NtpStRecord::thtrk.

Referenced by NuCounter::CountTrkStdhepId().

02777 {
02780 
02781   TClonesArray& thtrkTca=(*ntp.thtrk);//TruthHelper Event TCA
02782   const Int_t numthtrks=thtrkTca.GetEntriesFast();
02783   if (numthtrks<=0) {
02784     MAXMSG("NuReco",Msg::kDebug,1)
02785       <<"No THTracks, so can't do IsTrkWithMuonFromKaonDecay..."<<endl;
02786     return false;
02787   }
02788   MAXMSG("NuReco",Msg::kDebug,1)
02789     <<"Found THTrack, IsTrkWithMuonFromKaonDecay..."<<endl;
02790   const NtpTHTrack& thtrk=
02791     *dynamic_cast<NtpTHTrack*>(thtrkTca[trk.index]);
02792 
02793   //now get the mc object (neutrino interaction) that
02794   //corresponds to the trk using the thtrk.neumc index
02795   TClonesArray& mcTca=(*ntp.mc);
02796   const NtpMCTruth& mc=
02797     *(dynamic_cast<NtpMCTruth*>(mcTca[thtrk.neumc]));
02798 
02799   TClonesArray& hepTca=(*ntp.stdhep);
02800   //const Int_t numHeps=hepTca.GetEntriesFast();
02801 
02802   Int_t muonEvent=-1;
02803   Bool_t isFromKaon=false;
02804 
02805   Int_t parent0=-999;
02806   Int_t parent1=-999;
02807 
02808   Int_t parent0b=-999;
02809   Int_t parent1b=-999;
02810 
02811   Int_t parent0c=-999;
02812   Int_t parent1c=-999;
02813 
02814   //loop over stdhep
02815   for (Int_t ihep=mc.stdhep[0];ihep<=mc.stdhep[1];++ihep) {
02816     const NtpMCStdHep& stdhep=
02817       *dynamic_cast<NtpMCStdHep*>(hepTca[ihep]);
02818 
02819     if (abs(stdhep.IdHEP)==13){
02820       muonEvent=stdhep.mc;
02821       MAXMSG("NuReco",Msg::kDebug,3000)
02822         <<"Found muon, mc="<<muonEvent
02823         <<", ihep="<<ihep
02824         <<", id="<<stdhep.IdHEP
02825         <<", child=["<<stdhep.child[0]<<","<<stdhep.child[1]<<"]"
02826         <<", parent=["<<stdhep.parent[0]
02827         <<","<<stdhep.parent[1]<<"]"
02828         <<", E="<<stdhep.p4[3]
02829         <<endl;
02830 
02831       if (stdhep.parent[0]-stdhep.parent[1]!=0) {
02832         MSG("NuReco",Msg::kWarning)
02833           <<"Ahhhhhhhh, multiple parents of a muon"
02834           <<", parent=["<<parent0<<","<<parent1<<"]"<<endl;
02835         this->PrintStdhep(ntp,mc);
02836       }
02837 
02838       if (parent0==-999) {
02839         parent0=stdhep.parent[0];
02840         parent1=stdhep.parent[1];
02841       }
02842       else if (parent0!=-999 && parent0b==-999) {//check for second muon
02843         MAXMSG("NuReco",Msg::kDebug,3000)
02844           <<"Found second muon, 1st parent=["
02845           <<parent0<<","<<parent1<<"]"
02846           <<", 2nd parent=["<<stdhep.parent[0]
02847           <<","<<stdhep.parent[1]<<"]"
02848           <<endl;
02849         parent0b=stdhep.parent[0];
02850         parent1b=stdhep.parent[1];
02851       }
02852       else if (parent0b!=-999 && parent0c==-999) {//check for third muon
02853         MAXMSG("NuReco",Msg::kDebug,3000)
02854           <<endl
02855           <<"Found third muon, parentb=["
02856           <<parent0b<<","<<parent1b<<"]"
02857           <<", new parent=["<<stdhep.parent[0]
02858           <<","<<stdhep.parent[1]<<"]"
02859           <<endl;
02860         parent0c=stdhep.parent[0];
02861         parent1c=stdhep.parent[1];
02862       }
02863       else if (parent0c!=-999) {//check for fourth muon
02864         MAXMSG("NuReco",Msg::kDebug,3000)
02865           <<endl
02866           <<"Ahhh, already found >=3 muons, parentb=["
02867           <<parent0b<<","<<parent1b<<"]"
02868           <<", new parent=["<<stdhep.parent[0]
02869           <<","<<stdhep.parent[1]<<"]"
02870           <<endl;
02871         //this->PrintStdhep(ntp,mc);
02872       }
02873     }
02874   }
02875 
02876   //have to have a second loop since the parents will be before muon!
02877   //loop over stdhep (again)
02878   //don't have to do this - could jump about within stdhep in above loop
02879   for (Int_t ihep=mc.stdhep[0];ihep<=mc.stdhep[1];++ihep) {
02880     const NtpMCStdHep& stdhep=
02881       *dynamic_cast<NtpMCStdHep*>(hepTca[ihep]);
02882 
02883     if (parent0 ==(Int_t)stdhep.index || parent1 ==(Int_t)stdhep.index ||
02884         parent0b==(Int_t)stdhep.index || parent1b==(Int_t)stdhep.index) {
02885 
02886       if (abs(stdhep.IdHEP)!=14) {
02887         MAXMSG("NuReco",Msg::kDebug,3000)
02888           <<endl
02889           <<"**** Found non-nu muon parent..."
02890           <<", i="<<stdhep.index
02891           <<", id="<<stdhep.IdHEP
02892           <<", parent0="<<parent0
02893           <<", parent1="<<parent1
02894           <<", parent0b="<<parent0b
02895           <<", parent1b="<<parent1b
02896           <<", child=["<<stdhep.child[0]<<","<<stdhep.child[1]<<"]"
02897           <<endl;
02898         if (abs(stdhep.IdHEP)>300 && abs(stdhep.IdHEP)<400){
02899           isFromKaon=true;
02900           MAXMSG("NuReco",Msg::kDebug,3000)
02901             <<"From a kaon!!!"
02902             <<" m="<<stdhep.mass
02903             <<", E="<<stdhep.p4[3]<<endl<<endl;
02904           break;
02905         }
02906       }
02907     }
02908   }
02909 
02910   if (isFromKaon) return true;
02911   else return false;
02912 }

Bool_t NuReco::IsTrkWithMuonFromNotNuNotPiNotKaonNotCharm ( const NtpStRecord ntp,
const NtpSRTrack trk 
) const

NOT IMPLEMENTED YET!!!

Definition at line 2458 of file NuReco.cxx.

References NtpMCStdHep::child, NtpMCStdHep::IdHEP, NtpSRTrack::index, NtpMCStdHep::index, Msg::kDebug, Msg::kInfo, Msg::kWarning, NtpMCStdHep::mass, MAXMSG, NtpStRecord::mc, NtpMCStdHep::mc, MSG, NtpTHTrack::neumc, NtpMCStdHep::p4, NtpMCStdHep::parent, NtpMCTruth::stdhep, NtpStRecord::stdhep, and NtpStRecord::thtrk.

Referenced by NuCounter::CountTrkStdhepId().

02459 {
02461   return false;
02462 
02463   TClonesArray& thtrkTca=(*ntp.thtrk);//TruthHelper Event TCA
02464   const Int_t numthtrks=thtrkTca.GetEntriesFast();
02465   if (numthtrks<=0) {
02466     MAXMSG("NuReco",Msg::kDebug,1)
02467       <<"No THTracks, so can't do IsMuonFromNotNuNotPiNotCharm..."
02468       <<endl;
02469     return false;
02470   }
02471   MAXMSG("NuReco",Msg::kDebug,1)
02472     <<"Found THTrack, IsMuonFromNotNuNotPiNotCharm..."<<endl;
02473   const NtpTHTrack& thtrk=
02474     *dynamic_cast<NtpTHTrack*>(thtrkTca[trk.index]);
02475 
02476   //now get the mc object (neutrino interaction) that
02477   //corresponds to the trk using the thtrk.neumc index
02478   TClonesArray& mcTca=(*ntp.mc);
02479   const NtpMCTruth& mc=
02480     *(dynamic_cast<NtpMCTruth*>(mcTca[thtrk.neumc]));
02481 
02482   TClonesArray& hepTca=(*ntp.stdhep);
02483   //const Int_t numHeps=hepTca.GetEntriesFast();
02484 
02485   Int_t muonEvent=-1;
02486   Bool_t isFromOther=false;
02487 
02488   Int_t parent0=-999;
02489   Int_t parent1=-999;
02490 
02491   Int_t parent0b=-999;
02492   Int_t parent1b=-999;
02493 
02494   Int_t parent0c=-999;
02495   Int_t parent1c=-999;
02496 
02497   //loop over stdhep
02498   for (Int_t ihep=mc.stdhep[0];ihep<=mc.stdhep[1];++ihep) {
02499     const NtpMCStdHep& stdhep=
02500       *dynamic_cast<NtpMCStdHep*>(hepTca[ihep]);
02501 
02502     if (abs(stdhep.IdHEP)==13){
02503       muonEvent=stdhep.mc;
02504       MAXMSG("NuReco",Msg::kDebug,3000)
02505         <<"Found muon, mc="<<muonEvent
02506         <<", ihep="<<ihep
02507         <<", id="<<stdhep.IdHEP
02508         <<", child=["<<stdhep.child[0]<<","<<stdhep.child[1]<<"]"
02509         <<", parent=["<<stdhep.parent[0]
02510         <<","<<stdhep.parent[1]<<"]"
02511         <<", E="<<stdhep.p4[3]
02512         <<endl;
02513 
02514       if (stdhep.parent[0]-stdhep.parent[1]!=0) {
02515         MSG("NuReco",Msg::kWarning)
02516           <<"Ahhhhhhhh, multiple parents of a muon"
02517           <<", parent=["<<parent0<<","<<parent1<<"]"<<endl;
02518         this->PrintStdhep(ntp,mc);
02519       }
02520 
02521       if (parent0==-999) {
02522         parent0=stdhep.parent[0];
02523         parent1=stdhep.parent[1];
02524       }
02525       else if (parent0!=-999 && parent0b==-999) {//check for second muon
02526         MAXMSG("NuReco",Msg::kDebug,3000)
02527           <<"Found second muon, 1st parent=["
02528           <<parent0<<","<<parent1<<"]"
02529           <<", 2nd parent=["<<stdhep.parent[0]
02530           <<","<<stdhep.parent[1]<<"]"
02531           <<endl;
02532         parent0b=stdhep.parent[0];
02533         parent1b=stdhep.parent[1];
02534       }
02535       else if (parent0b!=-999 && parent0c==-999) {//check for third muon
02536         MAXMSG("NuReco",Msg::kDebug,3000)
02537           <<endl
02538           <<"Found third muon, parentb=["
02539           <<parent0b<<","<<parent1b<<"]"
02540           <<", new parent=["<<stdhep.parent[0]
02541           <<","<<stdhep.parent[1]<<"]"
02542           <<endl;
02543         parent0c=stdhep.parent[0];
02544         parent1c=stdhep.parent[1];
02545         //this->PrintStdhep(ntp,mc);
02546       }
02547       else if (parent0c!=-999) {//check for fourth muon
02548         MAXMSG("NuReco",Msg::kDebug,3000)
02549           <<endl
02550           <<"Ahhh, already found >=3 muons, parentb=["
02551           <<parent0b<<","<<parent1b<<"]"
02552           <<", new parent=["<<stdhep.parent[0]
02553           <<","<<stdhep.parent[1]<<"]"
02554           <<endl;
02555         //this->PrintStdhep(ntp,mc);
02556       }
02557     }
02558   }
02559 
02560   //have to have a second loop since the parents will be before muon!
02561   //loop over stdhep (again)
02562   //don't have to do this - could jump about within stdhep in above loop
02563   for (Int_t ihep=mc.stdhep[0];ihep<=mc.stdhep[1];++ihep) {
02564     const NtpMCStdHep& stdhep=
02565       *dynamic_cast<NtpMCStdHep*>(hepTca[ihep]);
02566 
02567     if (parent0 ==(Int_t)stdhep.index || parent1 ==(Int_t)stdhep.index ||
02568         parent0b==(Int_t)stdhep.index || parent1b==(Int_t)stdhep.index) {
02569 
02570       if (abs(stdhep.IdHEP)!=14) {
02571         MAXMSG("NuReco",Msg::kDebug,3000)
02572           <<endl<<endl<<endl
02573           <<"**** Found non-nu muon parent..."
02574           <<", i="<<stdhep.index
02575           <<", id="<<stdhep.IdHEP
02576           <<", parent0="<<parent0
02577           <<", parent1="<<parent1
02578           <<", parent0b="<<parent0b
02579           <<", parent1b="<<parent1b
02580           <<", child=["<<stdhep.child[0]<<","<<stdhep.child[1]<<"]"
02581           <<endl<<endl<<endl;
02582         if (!((abs(stdhep.IdHEP)>200 && abs(stdhep.IdHEP)<400) ||
02583               (abs(stdhep.IdHEP)==411 || abs(stdhep.IdHEP)==421 ||
02584                abs(stdhep.IdHEP)==431 || abs(stdhep.IdHEP)==4122))){
02585           isFromOther=true;
02586           MAXMSG("NuReco",Msg::kInfo,3000)
02587             <<"From a ?? ?? !!!"
02588             <<" m="<<stdhep.mass
02589             <<", E="<<stdhep.p4[3]
02590             <<", id="<<stdhep.IdHEP
02591             <<endl<<endl;
02592 
02593           this->PrintStdhep(ntp,mc);
02594           break;
02595         }
02596       }
02597     }
02598   }
02599 
02600   if (isFromOther) return true;
02601   else return false;
02602 }

Bool_t NuReco::IsTrkWithMuonFromPionDecay ( const NtpStRecord ntp,
const NtpSRTrack trk 
) const

this doesn't actually check that the tracked hits are from a muon it just checks that there was a muon in the THTrack neumc event

Definition at line 2606 of file NuReco.cxx.

References NtpMCStdHep::child, NtpMCStdHep::IdHEP, NtpSRTrack::index, NtpMCStdHep::index, Msg::kDebug, Msg::kWarning, NtpMCStdHep::mass, MAXMSG, NtpStRecord::mc, NtpMCStdHep::mc, MSG, NtpTHTrack::neumc, NtpMCStdHep::p4, NtpMCStdHep::parent, PrintStdhep(), NtpMCTruth::stdhep, NtpStRecord::stdhep, and NtpStRecord::thtrk.

Referenced by NuCounter::CountTrkStdhepId().

02608 {
02611 
02612   TClonesArray& thtrkTca=(*ntp.thtrk);//TruthHelper Event TCA
02613   const Int_t numthtrks=thtrkTca.GetEntriesFast();
02614   if (numthtrks<=0) {
02615     MAXMSG("NuReco",Msg::kDebug,1)
02616       <<"No THTracks, so can't do IsTrkWithMuonFromPionDecay..."<<endl;
02617     return false;
02618   }
02619   MAXMSG("NuReco",Msg::kDebug,1)
02620     <<"Found THTrack, IsTrkWithMuonFromPionDecay..."<<endl;
02621   const NtpTHTrack& thtrk=
02622     *dynamic_cast<NtpTHTrack*>(thtrkTca[trk.index]);
02623 
02624   //now get the mc object (neutrino interaction) that
02625   //corresponds to the trk using the thtrk.neumc index
02626   TClonesArray& mcTca=(*ntp.mc);
02627   const NtpMCTruth& mc=
02628     *(dynamic_cast<NtpMCTruth*>(mcTca[thtrk.neumc]));
02629 
02630   TClonesArray& hepTca=(*ntp.stdhep);
02631   //const Int_t numHeps=hepTca.GetEntriesFast();
02632 
02633   Int_t muonEvent=-1;
02634   Bool_t isFromPion=false;
02635 
02636   Int_t parent0=-999;
02637   Int_t parent1=-999;
02638 
02639   Int_t parent0b=-999;
02640   Int_t parent1b=-999;
02641 
02642   Int_t parent0c=-999;
02643   Int_t parent1c=-999;
02644 
02645   //loop over stdhep
02646   for (Int_t ihep=mc.stdhep[0];ihep<=mc.stdhep[1];++ihep) {
02647     const NtpMCStdHep& stdhep=
02648       *dynamic_cast<NtpMCStdHep*>(hepTca[ihep]);
02649 
02650     if (abs(stdhep.IdHEP)==13){
02651       muonEvent=stdhep.mc;
02652       MAXMSG("NuReco",Msg::kDebug,3000)
02653         <<"Found muon, mc="<<muonEvent
02654         <<", ihep="<<ihep
02655         <<", id="<<stdhep.IdHEP
02656         <<", child=["<<stdhep.child[0]<<","<<stdhep.child[1]<<"]"
02657         <<", parent=["<<stdhep.parent[0]
02658         <<","<<stdhep.parent[1]<<"]"
02659         <<", E="<<stdhep.p4[3]
02660         <<endl;
02661 
02662       if (stdhep.parent[0]-stdhep.parent[1]!=0) {
02663         MSG("NuReco",Msg::kWarning)
02664           <<"Ahhhhhhhh, multiple parents of a muon"
02665           <<", parent=["<<parent0<<","<<parent1<<"]"<<endl;
02666         this->PrintStdhep(ntp,mc);
02667       }
02668 
02669       if (parent0==-999) {
02670         parent0=stdhep.parent[0];
02671         parent1=stdhep.parent[1];
02672       }
02673       else if (parent0!=-999 && parent0b==-999) {//check for second muon
02674         MAXMSG("NuReco",Msg::kDebug,3000)
02675           <<"Found second muon, 1st parent=["
02676           <<parent0<<","<<parent1<<"]"
02677           <<", 2nd parent=["<<stdhep.parent[0]
02678           <<","<<stdhep.parent[1]<<"]"
02679           <<endl;
02680         parent0b=stdhep.parent[0];
02681         parent1b=stdhep.parent[1];
02682       }
02683       else if (parent0b!=-999 && parent0c==-999) {//check for third muon
02684         MAXMSG("NuReco",Msg::kDebug,3000)
02685           <<endl
02686           <<"Found third muon, parentb=["
02687           <<parent0b<<","<<parent1b<<"]"
02688           <<", new parent=["<<stdhep.parent[0]
02689           <<","<<stdhep.parent[1]<<"]"
02690           <<endl;
02691         parent0c=stdhep.parent[0];
02692         parent1c=stdhep.parent[1];
02693       }
02694       else if (parent0c!=-999) {//check for fourth muon
02695         MAXMSG("NuReco",Msg::kDebug,3000)
02696           <<endl
02697           <<"Ahhh, already found >=3 muons, parentb=["
02698           <<parent0b<<","<<parent1b<<"]"
02699           <<", new parent=["<<stdhep.parent[0]
02700           <<","<<stdhep.parent[1]<<"]"
02701           <<endl;
02702         //this->PrintStdhep(ntp,mc);
02703       }
02704     }
02705   }
02706 
02707   //have to have a second loop since the parents will be before muon!
02708   //loop over stdhep (again)
02709   //don't have to do this - could jump about within stdhep in above loop
02710   for (Int_t ihep=mc.stdhep[0];ihep<=mc.stdhep[1];++ihep) {
02711     const NtpMCStdHep& stdhep=
02712       *dynamic_cast<NtpMCStdHep*>(hepTca[ihep]);
02713 
02714     if (parent0 ==(Int_t)stdhep.index || parent1 ==(Int_t)stdhep.index ||
02715         parent0b==(Int_t)stdhep.index || parent1b==(Int_t)stdhep.index) {
02716 
02717       if (abs(stdhep.IdHEP)!=14) {
02718         MAXMSG("NuReco",Msg::kDebug,3000)
02719           <<endl
02720           <<"**** Found non-nu muon parent..."
02721           <<", i="<<stdhep.index
02722           <<", id="<<stdhep.IdHEP
02723           <<", parent0="<<parent0
02724           <<", parent1="<<parent1
02725           <<", parent0b="<<parent0b
02726           <<", parent1b="<<parent1b
02727           <<", child=["<<stdhep.child[0]<<","<<stdhep.child[1]<<"]"
02728           <<endl;
02729         if (abs(stdhep.IdHEP)>200 && abs(stdhep.IdHEP)<300){
02730           isFromPion=true;
02731           MAXMSG("NuReco",Msg::kDebug,3000)
02732             <<"From a pion!!!"
02733             <<" m="<<stdhep.mass
02734             <<", E="<<stdhep.p4[3]<<endl<<endl;
02735           break;
02736         }
02737       }
02738     }
02739 
02740     /* //this doesn't work since the decay child of the pion is not set
02741     //need to check the other way round too - event may be associated
02742     //with a pion which actually decayed to a muon fairly quickly
02743     if (abs(stdhep.IdHEP)>200 && abs(stdhep.IdHEP)<400){
02744 
02745     if (stdhep.child[0]>0 && stdhep.child[1]>0) {
02746     const NtpMCStdHep& stdhepChild0=
02747     *dynamic_cast<NtpMCStdHep*>(hepTca[stdhep.child[0]]);
02748     const NtpMCStdHep& stdhepChild1=
02749     *dynamic_cast<NtpMCStdHep*>(hepTca[stdhep.child[1]]);
02750 
02751     if (abs(stdhepChild0.IdHEP)==13 ||
02752     abs(stdhepChild1.IdHEP)==13) {
02753     MAXMSG("NuReco",Msg::kDebug,3000)
02754     <<endl
02755     <<"Found pion/kaon with muon child..."
02756     <<", i="<<stdhep.index
02757     <<", id="<<stdhep.IdHEP
02758     <<", child=["<<stdhep.child[0]<<","<<stdhep.child[1]<<"]"
02759     <<", child.IdHEP=["<<stdhepChild0.IdHEP
02760     <<","<<stdhepChild1.IdHEP<<"]"
02761     <<endl;
02762     }
02763     }
02764     }
02765     */
02766 
02767   }
02768 
02769   if (isFromPion) return true;
02770   else return false;
02771 }

Bool_t NuReco::PrintCharm ( const NtpStRecord ntp,
const NtpSREvent evt 
) const

Definition at line 3001 of file NuReco.cxx.

References NtpMCStdHep::child, NtpMCStdHep::IdHEP, NtpMCStdHep::index, NtpSREvent::index, NtpMCStdHep::IstHEP, Msg::kDebug, Msg::kInfo, NtpMCStdHep::mass, MAXMSG, NtpStRecord::mc, NtpMCStdHep::mc, NtpTHEvent::neumc, NtpMCStdHep::p4, NtpMCStdHep::parent, NtpStRecord::stdhep, NtpMCTruth::stdhep, and NtpStRecord::thevt.

03003 {
03004   TClonesArray& thevtTca=(*ntp.thevt);//TruthHelper Event TCA
03005   const Int_t numthevts=thevtTca.GetEntriesFast();
03006   if (numthevts<=0) {
03007     MAXMSG("NuReco",Msg::kDebug,1)
03008       <<"No THEvents, so can't GetTruthInfo..."<<endl;
03009     return false;
03010   }
03011   MAXMSG("NuReco",Msg::kDebug,1)
03012     <<"Found THEvent, GetTruthInfo..."<<endl;
03013   const NtpTHEvent& thevt=
03014     *dynamic_cast<NtpTHEvent*>(thevtTca[evt.index]);
03015 
03016   //now get the mc object (neutrino interaction) that
03017   //corresponds to the trk using the thtrk.neumc index
03018   TClonesArray& mcTca=(*ntp.mc);
03019   const NtpMCTruth& mc=
03020     *(dynamic_cast<NtpMCTruth*>(mcTca[thevt.neumc]));
03021 
03022   TClonesArray& hepTca=(*ntp.stdhep);
03023   //const Int_t numHeps=hepTca.GetEntriesFast();
03024 
03025   Int_t charmEvent=-1;
03026 
03027   Int_t child0=-999;
03028   Int_t child1=-999;
03029 
03030   //loop over stdhep
03031   for (Int_t ihep=mc.stdhep[0];ihep<=mc.stdhep[1];++ihep) {
03032     const NtpMCStdHep& stdhep=
03033       *dynamic_cast<NtpMCStdHep*>(hepTca[ihep]);
03034 
03035     if (abs(stdhep.IdHEP)==411 || abs(stdhep.IdHEP)==421 ||
03036         abs(stdhep.IdHEP)==431 || abs(stdhep.IdHEP)==4122){
03037       charmEvent=stdhep.mc;
03038       MAXMSG("NuReco",Msg::kDebug,3000)
03039         <<"Found Charm particle, mc="<<charmEvent
03040         <<", ihep="<<ihep
03041         <<", id="<<stdhep.IdHEP
03042         <<", child=["<<stdhep.child[0]<<","<<stdhep.child[1]<<"]"
03043         <<endl;
03044 
03045       child0=stdhep.child[0];
03046       child1=stdhep.child[1];
03047     }
03048 
03049     if (child0==(Int_t)stdhep.index || child1==(Int_t)stdhep.index) {
03050       MAXMSG("NuReco",Msg::kDebug,3000)
03051         <<"Found Charm child..."
03052         <<", i="<<stdhep.index
03053         <<", child0="<<child0
03054         <<", child1="<<child1
03055         <<", id="<<stdhep.IdHEP
03056         <<", parent=["<<stdhep.parent[0]<<","<<stdhep.parent[1]<<"]"
03057         <<endl;
03058       if (abs(stdhep.IdHEP)==13){
03059         MAXMSG("NuReco",Msg::kDebug,3000)
03060           <<"It's a muon!!!"
03061           <<" m="<<stdhep.mass
03062           <<", E="<<stdhep.p4[3]<<endl<<endl;
03063       }
03064     }
03065 
03066   }
03067 
03068   //loop over stdhep
03069   if (charmEvent!=-1){
03070     for (Int_t ihep=mc.stdhep[0];ihep<=mc.stdhep[1];++ihep) {
03071       const NtpMCStdHep& stdhep=
03072         *dynamic_cast<NtpMCStdHep*>(hepTca[ihep]);
03073 
03074       MAXMSG("NuReco",Msg::kInfo,3000)
03075         <<"ihep="<<ihep
03076         <<", mc="<<stdhep.mc
03077         <<", id="<<stdhep.IdHEP
03078         <<", Ist="<<stdhep.IstHEP
03079         <<", parent=["<<stdhep.parent[0]<<","<<stdhep.parent[1]<<"]"
03080         <<", child=["<<stdhep.child[0]<<","<<stdhep.child[1]<<"]"
03081         <<", m="<<stdhep.mass
03082         <<", E="<<stdhep.p4[3]
03083         <<endl;
03084     }
03085     return true;
03086   }
03087   else return false;
03088 }

void NuReco::PrintStdhep ( const NtpStRecord ntp,
const NtpMCTruth mc 
) const

Definition at line 3092 of file NuReco.cxx.

References NtpMCStdHep::child, NtpMCStdHep::IdHEP, NtpMCStdHep::IstHEP, Msg::kInfo, NtpMCStdHep::mass, MAXMSG, NtpMCStdHep::mc, NtpMCStdHep::p4, NtpMCStdHep::parent, NtpStRecord::stdhep, and NtpMCTruth::stdhep.

Referenced by NuCounter::CountTrkStdhepId(), GetPrimaryMuonStdHepIndex(), IsTrkWithMuonFromKaonDecay(), and IsTrkWithMuonFromPionDecay().

03094 {
03095   TClonesArray& hepTca=(*ntp.stdhep);
03096   //const Int_t numHeps=hepTca.GetEntriesFast();
03097 
03098   MAXMSG("NuReco",Msg::kInfo,3000)
03099     <<"PrintStdhep: mc.stdhep=["<<mc.stdhep[0]
03100     <<","<<mc.stdhep[1]<<"]"<<endl;
03101 
03102   //loop over stdhep
03103   for (Int_t ihep=mc.stdhep[0];ihep<=mc.stdhep[1];++ihep) {
03104     const NtpMCStdHep& stdhep=
03105       *dynamic_cast<NtpMCStdHep*>(hepTca[ihep]);
03106 
03107     MAXMSG("NuReco",Msg::kInfo,3000)
03108       <<"ihep="<<ihep
03109       <<", mc="<<stdhep.mc
03110       <<", id="<<stdhep.IdHEP
03111       <<", Ist="<<stdhep.IstHEP//Interaction status code, from Geant+200
03112       <<", parent=["<<stdhep.parent[0]<<","<<stdhep.parent[1]<<"]"
03113       <<", child=["<<stdhep.child[0]<<","<<stdhep.child[1]<<"]"
03114       <<", m="<<stdhep.mass
03115       <<", E="<<stdhep.p4[3]
03116       <<endl;
03117   }
03118 }

void NuReco::PrintTrueEnergy ( const NtpStRecord ntp,
const NtpSREvent evt,
Double_t  recoEn = 0 
) const

Definition at line 3609 of file NuReco.cxx.

References NtpMCTruth::iaction, NtpTHEvent::index, NtpSREvent::index, NtpMCTruth::index, Msg::kDebug, Msg::kInfo, MAXMSG, NtpStRecord::mc, NtpTHEvent::neumc, NtpMCTruth::p4neu, NtpStRecord::thevt, and NtpMCTruth::y.

03611 {
03612   TClonesArray& thevtTca=(*ntp.thevt);//TruthHelper Event TCA
03613   const Int_t numthevts=thevtTca.GetEntriesFast();
03614   if (numthevts<=0) {
03615     MAXMSG("NuReco",Msg::kInfo,1)
03616       <<"No THEvents, so can't print truth information..."<<endl;
03617     MAXMSG("NuReco",Msg::kInfo,20)
03618       <<"recoEn="<<recoEn<<endl;
03619     return;
03620   }
03621   MAXMSG("NuReco",Msg::kInfo,1)
03622     <<"Found THEvent, printing info..."<<endl;
03623   const NtpTHEvent& thevt=
03624     *dynamic_cast<NtpTHEvent*>(thevtTca[evt.index]);
03625 
03626   //now get the mc object (neutrino interaction)
03627   TClonesArray& mcTca=(*ntp.mc);
03628   const NtpMCTruth& mc=
03629     *(dynamic_cast<NtpMCTruth*>(mcTca[thevt.neumc]));
03630   MAXMSG("NuReco",Msg::kDebug,100)
03631     <<"Found mc="<<mc.index<<", thevt.index="<<thevt.index<<endl;
03632 
03633   Double_t nuEn=mc.p4neu[3];
03634 
03635   Double_t trueEn=mc.y*mc.p4neu[3];//NC
03636   if (mc.iaction==1) trueEn=mc.p4neu[3];//CC
03637 
03638   Double_t muEn=(1-mc.y)*mc.p4neu[3];
03639   Double_t hadEn=mc.y*mc.p4neu[3];
03640 
03641   string siaction="NC";
03642   if (mc.iaction==1) siaction="CC";
03643 
03644   if (mc.iaction==1) {
03645     MAXMSG("NuReco",Msg::kInfo,100)
03646       <<"RecoEn="<<recoEn
03647       <<", "<<siaction
03648       <<" truth: En="<<trueEn<<", mu="<<muEn<<", had="<<hadEn
03649       <<", (y="<<mc.y<<")"
03650       <<endl;
03651   }
03652   else {
03653     MAXMSG("NuReco",Msg::kInfo,20)
03654       <<"RecoEn="<<recoEn
03655       <<", "<<siaction
03656       <<" truth: had="<<hadEn
03657       <<", (Nu="<<nuEn<<", y="<<mc.y<<")"
03658       <<endl;
03659   }
03660 }

void NuReco::RecalculateDerivativeTrackGeometryVariables ( NuEvent nu  )  const

Recalculates all of the base geometry variables it can, given only a NuEvent.

Definition at line 5737 of file NuReco.cxx.

References CalculateEdgeRegion(), CalculateHorizontalVerticalStripNumber(), CalculateParallelStripInset(), and CalculatePerpendicularStripFlag().

05738 {
05739   for(int trkIdx = 0; trkIdx <= 3; ++trkIdx){
05740     // Edge region
05741     CalculateEdgeRegion(nu, trkIdx);
05742 
05743     // Parallel strip insets
05744     CalculateParallelStripInset(nu, trkIdx);
05745 
05746     // Calculate the overhanging strip flags
05747     CalculatePerpendicularStripFlag(nu, trkIdx);
05748 
05749     // Calculate the Horizontal/Vertical strip number
05750     CalculateHorizontalVerticalStripNumber(nu, trkIdx);
05751   }
05752 }

Double_t NuReco::Run9TargetDecayWeight ( const NuEvent nu  )  const

Definition at line 685 of file NuReco.cxx.

References Fin78WeightL010z185iDefocusedComponent(), Fin78WeightL010z185iFocusedComponent(), NuEvent::inu, SimFlag::kData, NuEvent::neuEnMC, and NuEvent::simFlag.

Referenced by ApplyReweights().

00686 {
00687   //Cut on truth? Do this only for CC antineutrinos?
00688   //Also, make sure it's RHC MC: don't do this to FHC.
00689 
00690   if (SimFlag::kData == nu.simFlag){return 1.0;}
00691 
00692   Double_t scaleFactor = 2.81;
00693   Double_t weight = 1.0;
00694 
00695   if (-14 == nu.inu){
00696     weight = this->Fin78WeightL010z185iFocusedComponent(nu.neuEnMC);
00697   }
00698   else if (14 == nu.inu){
00699     weight = this->Fin78WeightL010z185iDefocusedComponent(nu.neuEnMC);
00700   }
00701   else{
00702     weight = 1.0;
00703   }
00704   weight -= 1.0;
00705   weight *= scaleFactor;
00706   weight += 1.0;
00707   return weight;
00708 }

void NuReco::SetBestShw ( NuEvent nu  )  const

Definition at line 1546 of file NuReco.cxx.

References GetBestShower(), Msg::kDebug, MAXMSG, NuEvent::ndigitShw, NuEvent::nplaneShw, NuEvent::nshw, NuEvent::nstripShw, NuEvent::planeShwBeg, NuEvent::planeShwEnd, NuEvent::planeShwMax, NuEvent::primshw, NuEvent::run, NuEvent::shwEnCC, NuEvent::shwEnCor, NuEvent::shwEnLinCCCor, NuEvent::shwEnLinCCNoCor, NuEvent::shwEnLinNCCor, NuEvent::shwEnLinNCNoCor, NuEvent::shwEnMip, NuEvent::shwEnNC, NuEvent::shwEnNoCor, NuEvent::shwEnWtCCCor, NuEvent::shwEnWtCCNoCor, NuEvent::shwEnWtNCCor, NuEvent::shwEnWtNCNoCor, NuEvent::shwExists, NuEvent::shwExists1, NuEvent::shwExists2, NuEvent::shwExists3, NuEvent::snarl, NuEvent::xShwVtx, NuEvent::yShwVtx, and NuEvent::zShwVtx.

Referenced by NuExtraction::ExtractShwInfo(), and GetEvtEnergy().

01547 {
01548   //check if a shower exists
01549   if (nu.nshw<=0) {
01550     nu.shwExists=false;
01551     return;
01552   }
01553 
01554   //get the best shower
01555   Int_t bestShower=this->GetBestShower(nu);
01556 
01557   //copy the best shower across
01558   if (bestShower<1) {
01559     MAXMSG("NuReco",Msg::kDebug,3) 
01560       <<"No best shower, run="<<nu.run<<", snarl="<<nu.snarl
01561       <<", primshw="<<nu.primshw
01562       <<", nshw="<<nu.nshw
01563       <<", shwExists1,2,3="<<nu.shwExists1<<","
01564       <<nu.shwExists2<<","<<nu.shwExists3<<endl;
01565 
01566     //very imporant to reset variables (for re-reconstruction)
01567     nu.shwExists=false;
01568     nu.ndigitShw=-1;
01569     nu.nstripShw=-1;
01570     nu.nplaneShw=-1;
01571     nu.shwEnCor=-1;
01572     nu.shwEnNoCor=-1;
01573     nu.shwEnCC=-1;
01574     nu.shwEnNC=-1;
01575     nu.shwEnLinCCNoCor=-1;
01576     nu.shwEnLinCCCor=-1;
01577     nu.shwEnLinNCNoCor=-1;
01578     nu.shwEnLinNCCor=-1;
01579     nu.shwEnWtCCNoCor=-1;
01580     nu.shwEnWtCCCor=-1;
01581     nu.shwEnWtNCNoCor=-1;
01582     nu.shwEnWtNCCor=-1;
01583 
01584     nu.shwEnMip=-1;
01585     nu.planeShwBeg=-1;
01586     nu.planeShwEnd=-1;
01587     nu.planeShwMax=-1;
01588     nu.xShwVtx=-999;
01589     nu.yShwVtx=-999;
01590     nu.zShwVtx=-999;
01591     return;
01592   }
01593 
01594   // TODO - why didn't this go to 5 in the old code?
01595   if(bestShower >= 1 && bestShower <= 3) {
01596     MAXMSG("NuReco",Msg::kDebug,100)
01597       <<"Best shower=" << bestShower << ", primshw="<<nu.primshw
01598       <<", nshw="<<nu.nshw
01599       <<", shwExists1,2,3="<<nu.shwExists1<<","
01600       <<nu.shwExists2<<","<<nu.shwExists3<<endl;
01601 
01602     nu.shwExists = get_shwExists(nu, bestShower);
01603     nu.ndigitShw = get_ndigitShw(nu, bestShower);
01604     nu.nstripShw = get_nstripShw(nu, bestShower);
01605     nu.nplaneShw = get_nplaneShw(nu, bestShower);
01606     nu.shwEnCor = get_shwEnCor(nu, bestShower);
01607     nu.shwEnMip = get_shwEnMip(nu, bestShower);
01608     nu.shwEnNoCor = get_shwEnNoCor(nu, bestShower);
01609     nu.shwEnLinCCNoCor = get_shwEnLinCCNoCor(nu, bestShower);
01610     nu.shwEnLinCCCor = get_shwEnLinCCCor(nu, bestShower);
01611     nu.shwEnLinNCNoCor = get_shwEnLinNCNoCor(nu, bestShower);
01612     nu.shwEnLinNCCor = get_shwEnLinNCCor(nu, bestShower);
01613     nu.shwEnWtCCNoCor = get_shwEnWtCCNoCor(nu, bestShower);
01614     nu.shwEnWtCCCor = get_shwEnWtCCCor(nu, bestShower);
01615     nu.shwEnWtNCNoCor = get_shwEnWtNCNoCor(nu, bestShower);
01616     nu.shwEnWtNCCor = get_shwEnWtNCCor(nu, bestShower);
01617 
01618     nu.planeShwBeg = get_planeShwBeg(nu, bestShower);
01619     nu.planeShwEnd = get_planeShwEnd(nu, bestShower);
01620     nu.planeShwMax = get_planeShwMax(nu, bestShower);
01621     nu.xShwVtx = get_xShwVtx(nu, bestShower);
01622     nu.yShwVtx = get_yShwVtx(nu, bestShower);
01623     nu.zShwVtx = get_zShwVtx(nu, bestShower);
01624   }
01625   else cout<<"Ahhhhhhhhhhhh"<<endl;
01626 }

void NuReco::SetBestTrk ( NuEvent nu  )  const

Definition at line 1630 of file NuReco.cxx.

References NuEvent::charge, NuEvent::chi2, NuEvent::chi2TimeTrk, NuEvent::containedTrk, NuEvent::cosPrTrkVtx, NuEvent::drTrkFidall, NuEvent::drTrkFidend, NuEvent::drTrkFidvtx, NuEvent::dzTrkFidall, NuEvent::dzTrkFidend, NuEvent::dzTrkFidvtx, NuEvent::edgeRegionTrkEnd, NuEvent::edgeRegionTrkVtx, NuEvent::forwardNDOFTrk, NuEvent::forwardRMSTrk, GetBestTrack(), NuEvent::inverseBetaTrk, NuEvent::jitter, NuEvent::jPID, Msg::kDebug, Msg::kInfo, Msg::kWarning, NuEvent::majC, MAXMSG, MSG, NuEvent::ndigitTimeTrk, NuEvent::ndigitTrk, NuEvent::ndof, NuEvent::nstripTrk, NuEvent::ntrk, NuEvent::ntrklike, NuEvent::parallelStripTrkEnd, NuEvent::parallelStripTrkVtx, NuEvent::parallelStripTrkVtxNoShift, NuEvent::phiTrkEnd, NuEvent::phiTrkVtx, NuEvent::planeTrkBeg, NuEvent::planeTrkBegu, NuEvent::planeTrkBegv, NuEvent::planeTrkEnd, NuEvent::planeTrkEndu, NuEvent::planeTrkEndv, NuEvent::planeTrkNu, NuEvent::planeTrkNv, NuEvent::planeTrkVtx, NuEvent::primtrk, NuEvent::qp, NuEvent::qp_rangebiased, NuEvent::qp_sigqp, NuEvent::qpFraction, NuEvent::regionTrkVtx, SetBestTrkMajorityCurvature(), SetBestTrkSAFit(), NuEvent::sigqp, NuEvent::smoothMajC, NuEvent::stripHoveNumTrkEnd, NuEvent::stripHoveNumTrkVtx, NuEvent::stripHoveNumTrkVtxNoShift, NuEvent::stripTrkBeg, NuEvent::stripTrkBegIsu, NuEvent::stripTrkBegPerpFlag, NuEvent::stripTrkBegu, NuEvent::stripTrkBegv, NuEvent::stripTrkEnd, NuEvent::stripTrkEndIsu, NuEvent::stripTrkEndPerpFlag, NuEvent::stripTrkEndu, NuEvent::stripTrkEndv, NuEvent::t0Trk, NuEvent::traceTrkFidall, NuEvent::traceTrkFidend, NuEvent::traceTrkFidvtx, NuEvent::trkds, NuEvent::trkEnCorCurv, NuEvent::trkEnCorRange, NuEvent::trkExists, NuEvent::trkExists1, NuEvent::trkExists2, NuEvent::trkExists3, NuEvent::trkfitpass, NuEvent::trkIdMC, NuEvent::trkIndex, NuEvent::trkLength, NuEvent::trkMomentumRange, NuEvent::trknplane, NuEvent::trkphsigcor, NuEvent::trkphsigmap, NuEvent::trkShwEnNear, NuEvent::trkShwEnNearDW, NuEvent::trkvtxdcosy, NuEvent::trkvtxdcosz, NuEvent::trkVtxUVDiffPl, NuEvent::tTrkVtx, NuEvent::uTrkEnd, NuEvent::uTrkVtx, NuEvent::vTrkEnd, NuEvent::vTrkVtx, NuEvent::xTrkEnd, NuEvent::xTrkVtx, NuEvent::yTrkEnd, NuEvent::yTrkVtx, NuEvent::zTrkEnd, and NuEvent::zTrkVtx.

Referenced by GetEvtEnergy().

01631 {
01632   //check if a track exists
01633   if (nu.ntrk<=0) {
01634     nu.trkExists=false;
01635     return;
01636   }
01637 
01638   //get the best track
01639   Int_t bestTrack=this->GetBestTrack(nu);
01640 
01641   //copy the best track across
01642   if (bestTrack<1) {
01643     MAXMSG("NuReco",Msg::kInfo,3)
01644       <<"No best trk, primtrk="<<nu.primtrk
01645       <<", ntrk="<<nu.ntrk
01646       <<", trkExists1,2,3="<<nu.trkExists1<<","
01647       <<nu.trkExists2<<","<<nu.trkExists3<<endl;
01648 
01649     //very important to reset ALL trk variables (for re-reconstruction)
01650     nu.trkExists=false;
01651     nu.trkIndex=-1;
01652     nu.ndigitTrk=-1;
01653     nu.nstripTrk=-1;
01654     nu.trkEnCorRange=-1;
01655     nu.trkEnCorCurv=-1;
01656     nu.trkShwEnNear=-1;
01657     nu.trkShwEnNearDW=-1;
01658     nu.trkMomentumRange=-1;
01659     nu.containedTrk=0;
01660     nu.trkfitpass=-1;
01661     nu.trkvtxdcosz=-999;
01662     nu.trkvtxdcosy=-999;
01663     nu.trknplane=-999;
01664     nu.charge=0;
01665     nu.qp=-999;
01666     nu.qp_rangebiased=-999;
01667     nu.sigqp=-1;
01668     nu.qp_sigqp=-999;
01669     nu.chi2=-1;
01670     nu.ndof=0;
01671     nu.qpFraction=-1;
01672     nu.trkVtxUVDiffPl=-999;
01673     nu.trkLength=-1;
01674     nu.planeTrkNu=-1;
01675     nu.planeTrkNv=-1;
01676     nu.ntrklike=-1;
01677     nu.trkphsigcor=-1;
01678     nu.trkphsigmap=-1;
01679     nu.trkIdMC=0;
01680     nu.trkds=-1;
01681 
01682     nu.jitter=-1;//keep majCurv here because of return below
01683     nu.jPID=-999;
01684     nu.majC=0;
01685     //nu.majCRatio=-999;
01686     //nu.rms=-1;
01687     //nu.simpleMajC=-999;
01688     nu.smoothMajC=-999;
01689     //nu.sqJitter=-1;
01690     //nu.totWidth=-999;
01691 
01692     nu.xTrkVtx=-999;
01693     nu.yTrkVtx=-999;
01694     nu.zTrkVtx=-999;
01695     nu.uTrkVtx=-999;
01696     nu.vTrkVtx=-999;
01697     nu.tTrkVtx=-999;
01698     nu.planeTrkVtx=-1;
01699     nu.planeTrkBeg=-1;
01700     nu.planeTrkBegu=-1;
01701     nu.planeTrkBegv=-1;
01702     nu.inverseBetaTrk=-999;
01703     nu.t0Trk=-999;
01704     nu.chi2TimeTrk=-999;
01705     nu.ndigitTimeTrk=0;
01706     nu.forwardRMSTrk=-999;
01707     nu.forwardNDOFTrk=-999;
01708     nu.stripTrkBeg = -1;
01709     nu.stripTrkBegu = -1;
01710     nu.stripTrkBegv = -1;
01711     nu.stripTrkEnd = -1;
01712     nu.stripTrkEndu = -1;
01713     nu.stripTrkEndv = -1;
01714     nu.stripTrkBegIsu = false;
01715     nu.stripTrkEndIsu = false;
01716     nu.regionTrkVtx=-1;
01717     nu.edgeRegionTrkVtx=-1;
01718     nu.edgeRegionTrkEnd=-1;
01719     nu.phiTrkVtx=-999;
01720     nu.phiTrkEnd=-999;
01721     nu.parallelStripTrkVtx=-999;
01722     nu.parallelStripTrkEnd=-999;
01723     nu.stripTrkBegPerpFlag = false;
01724     nu.stripTrkEndPerpFlag = false;
01725     nu.stripHoveNumTrkVtx = -999;
01726     nu.stripHoveNumTrkEnd = -999;
01727 
01728 
01729     nu.xTrkEnd=-999;
01730     nu.yTrkEnd=-999;
01731     nu.zTrkEnd=-999;
01732     nu.uTrkEnd=-999;
01733     nu.vTrkEnd=-999;
01734     nu.planeTrkEnd=-1;
01735     nu.planeTrkEndu=-1;
01736     nu.planeTrkEndv=-1;
01737 
01738     nu.drTrkFidall=-999;
01739     nu.dzTrkFidall=-999;
01740     nu.drTrkFidvtx=-999;
01741     nu.dzTrkFidvtx=-999;
01742     nu.drTrkFidend=-999;
01743     nu.dzTrkFidend=-999;
01744     nu.traceTrkFidall = -999;
01745     nu.traceTrkFidvtx = -999;
01746     nu.traceTrkFidend = -999;
01747 
01748     nu.cosPrTrkVtx = -999;
01749     return;
01750   }
01751 
01752   if(bestTrack >= 1 && bestTrack <= 3){
01753     MAXMSG("NuReco",Msg::kDebug,3)
01754       <<"Best trk=" << bestTrack << ", primtrk="<<nu.primtrk
01755       <<", ntrk="<<nu.ntrk
01756       <<", trkExists1,2,3="<<nu.trkExists1<<","
01757       <<nu.trkExists2<<","<<nu.trkExists3<<endl;
01758 
01759     nu.trkExists = get_trkExists(nu, bestTrack);
01760     nu.trkIndex = get_trkIndex(nu, bestTrack);
01761     nu.ndigitTrk = get_ndigitTrk(nu, bestTrack);
01762     nu.nstripTrk = get_nstripTrk(nu, bestTrack);
01763     nu.trkEnCorRange = get_trkEnCorRange(nu, bestTrack);
01764     nu.trkEnCorCurv = get_trkEnCorCurv(nu, bestTrack);
01765     nu.trkShwEnNear = get_trkShwEnNear(nu, bestTrack);
01766     nu.trkShwEnNearDW = get_trkShwEnNearDW(nu, bestTrack);
01767     nu.trkMomentumRange = get_trkMomentumRange(nu, bestTrack);
01768     nu.containedTrk = get_containedTrk(nu, bestTrack);
01769     nu.trkfitpass = get_trkfitpass(nu, bestTrack);
01770     nu.trkvtxdcosz = get_trkvtxdcosz(nu, bestTrack);
01771     nu.trkvtxdcosy = get_trkvtxdcosy(nu, bestTrack);
01772     nu.trknplane = get_trknplane(nu, bestTrack);
01773     nu.charge = get_charge(nu, bestTrack);
01774     nu.qp = get_qp(nu, bestTrack);
01775     nu.qp_rangebiased = get_qp_rangebiased(nu, bestTrack);
01776     nu.sigqp = get_sigqp(nu, bestTrack);
01777     nu.qp_sigqp = get_qp_sigqp(nu, bestTrack);
01778     nu.chi2 = get_chi2(nu, bestTrack);
01779     nu.ndof = get_ndof(nu, bestTrack);
01780     nu.qpFraction = get_qpFraction(nu, bestTrack);
01781     nu.trkVtxUVDiffPl = get_trkVtxUVDiffPl(nu, bestTrack);
01782     nu.trkLength = get_trkLength(nu, bestTrack);
01783     nu.planeTrkNu = get_planeTrkNu(nu, bestTrack);
01784     nu.planeTrkNv = get_planeTrkNv(nu, bestTrack);
01785     nu.ntrklike = get_ntrklike(nu, bestTrack);
01786     nu.trkphsigcor = get_trkphsigcor(nu, bestTrack);
01787     nu.trkphsigmap = get_trkphsigmap(nu, bestTrack);
01788     nu.trkIdMC = get_trkIdMC(nu, bestTrack);
01789     nu.trkds = get_trkds(nu, bestTrack);
01790 
01791     //majority curvature is done in its own function below
01792 
01793     nu.xTrkVtx = get_xTrkVtx(nu, bestTrack);
01794     nu.yTrkVtx = get_yTrkVtx(nu, bestTrack);
01795     nu.zTrkVtx = get_zTrkVtx(nu, bestTrack);
01796     nu.uTrkVtx = get_uTrkVtx(nu, bestTrack);
01797     nu.vTrkVtx = get_vTrkVtx(nu, bestTrack);
01798     nu.tTrkVtx = get_tTrkVtx(nu, bestTrack);
01799     nu.planeTrkVtx = get_planeTrkVtx(nu, bestTrack);
01800     nu.planeTrkBeg = get_planeTrkBeg(nu, bestTrack);
01801     nu.planeTrkBegu = get_planeTrkBegu(nu, bestTrack);
01802     nu.planeTrkBegv = get_planeTrkBegv(nu, bestTrack);
01803     nu.inverseBetaTrk = get_inverseBetaTrk(nu, bestTrack);
01804     nu.t0Trk = get_t0Trk(nu, bestTrack);
01805     nu.chi2TimeTrk = get_chi2TimeTrk(nu, bestTrack);
01806     nu.ndigitTimeTrk = get_ndigitTimeTrk(nu, bestTrack);
01807     nu.forwardRMSTrk = get_forwardRMSTrk(nu, bestTrack);
01808     nu.forwardNDOFTrk = get_forwardNDOFTrk(nu, bestTrack);
01809     nu.stripTrkBeg = get_stripTrkBeg(nu, bestTrack);
01810     nu.stripTrkBegu = get_stripTrkBegu(nu, bestTrack);
01811     nu.stripTrkBegv = get_stripTrkBegv(nu, bestTrack);
01812     nu.stripTrkEnd = get_stripTrkEnd(nu, bestTrack);
01813     nu.stripTrkEndu = get_stripTrkEndu(nu, bestTrack);
01814     nu.stripTrkEndv = get_stripTrkEndv(nu, bestTrack);
01815 
01816     nu.stripTrkBegIsu = get_stripTrkBegIsu(nu, bestTrack);
01817     nu.stripTrkEndIsu = get_stripTrkEndIsu(nu, bestTrack);
01818     nu.regionTrkVtx = get_regionTrkVtx(nu, bestTrack);
01819     nu.edgeRegionTrkVtx = get_edgeRegionTrkVtx(nu, bestTrack);
01820     nu.edgeRegionTrkEnd = get_edgeRegionTrkEnd(nu, bestTrack);
01821 
01822     nu.phiTrkVtx = get_phiTrkVtx(nu, bestTrack);
01823     nu.phiTrkEnd = get_phiTrkEnd(nu, bestTrack);;
01824     nu.parallelStripTrkVtx = get_parallelStripTrkVtx(nu, bestTrack);
01825     nu.parallelStripTrkVtxNoShift=nu.parallelStripTrkVtx;
01826     nu.parallelStripTrkEnd = get_parallelStripTrkEnd(nu, bestTrack);
01827     nu.stripTrkBegPerpFlag = get_stripTrkBegPerpFlag(nu, bestTrack);
01828     nu.stripTrkEndPerpFlag = get_stripTrkEndPerpFlag(nu, bestTrack);
01829     nu.stripHoveNumTrkVtx = get_stripHoveNumTrkVtx(nu, bestTrack);
01830     nu.stripHoveNumTrkVtxNoShift = nu.stripHoveNumTrkVtx;
01831     nu.stripHoveNumTrkEnd = get_stripHoveNumTrkEnd(nu, bestTrack);
01832 
01833     nu.xTrkEnd = get_xTrkEnd(nu, bestTrack);
01834     nu.yTrkEnd = get_yTrkEnd(nu, bestTrack);
01835     nu.zTrkEnd = get_zTrkEnd(nu, bestTrack);
01836     nu.uTrkEnd = get_uTrkEnd(nu, bestTrack);
01837     nu.vTrkEnd = get_vTrkEnd(nu, bestTrack);
01838     nu.planeTrkEnd = get_planeTrkEnd(nu, bestTrack);
01839     nu.planeTrkEndu = get_planeTrkEndu(nu, bestTrack);
01840     nu.planeTrkEndv = get_planeTrkEndv(nu, bestTrack);
01841 
01842     nu.drTrkFidall = get_drTrkFidall(nu, bestTrack);
01843     nu.dzTrkFidall = get_dzTrkFidall(nu, bestTrack);
01844     nu.drTrkFidvtx = get_drTrkFidvtx(nu, bestTrack);
01845     nu.dzTrkFidvtx = get_dzTrkFidvtx(nu, bestTrack);
01846     nu.drTrkFidend = get_drTrkFidend(nu, bestTrack);
01847     nu.dzTrkFidend = get_dzTrkFidend(nu, bestTrack);
01848     nu.traceTrkFidall = get_traceTrkFidall(nu, bestTrack);
01849     nu.traceTrkFidvtx = get_traceTrkFidvtx(nu, bestTrack);
01850     nu.traceTrkFidend = get_traceTrkFidend(nu, bestTrack);
01851 
01852     nu.cosPrTrkVtx = get_cosPrTrkVtx(nu, bestTrack);
01853   }
01854   else {
01855     // Give a more informative warning than just a scream, but leave
01856     // in the old message for 'legacy'
01857     MSG("NuReco", Msg::kWarning) << "Ahhhhhhhhhhhh"
01858                                  << ": Trying to set a best track higher than stored" << endl;
01859   }
01860 
01861   //set the majority curvature variables
01862   //this would normally be done above
01863   //but majCurv is CPU intensive so it is moved to it's own separate
01864   //function (so it can also be called elsewhere as required)
01865   //if MajC hasn't yet been calculated this will just copy defaults
01866   //across, but that is the safest thing to do
01867   this->SetBestTrkMajorityCurvature(nu);
01868   //set SA variables in the same way too
01869   this->SetBestTrkSAFit(nu);
01870 }

void NuReco::SetBestTrkMajorityCurvature ( NuEvent nu  )  const

Definition at line 1874 of file NuReco.cxx.

References GetBestTrack(), NuLibrary::Instance(), NuEvent::jitter, NuEvent::jPID, Msg::kDebug, Msg::kInfo, NuEvent::majC, MAXMSG, NuEvent::ntrk, NuEvent::primtrk, NuLibrary::reco, NuEvent::smoothMajC, NuEvent::trkExists1, NuEvent::trkExists2, and NuEvent::trkExists3.

Referenced by NuExtraction::ExtractMajorityCurvature(), and SetBestTrk().

01875 {
01876   //get an instance of the code library
01877   const NuLibrary& lib=NuLibrary::Instance();
01878 
01879   //get the best track
01880   Int_t bestTrack=lib.reco.GetBestTrack(nu);
01881 
01882   //copy the best track across
01883   if (bestTrack<1) {
01884     MAXMSG("NuReco",Msg::kInfo,3)
01885       <<"SetBestTrkMajorityCurvature: No best trk, primtrk="
01886       <<nu.primtrk
01887       <<", ntrk="<<nu.ntrk
01888       <<", trkExists1,2,3="<<nu.trkExists1<<","
01889       <<nu.trkExists2<<","<<nu.trkExists3<<endl;
01890     return;
01891   }
01892 
01893   if(bestTrack >= 1 && bestTrack <= 3){
01894     MAXMSG("NuReco",Msg::kDebug,3)
01895       <<"SetBestTrkMajorityCurvature: Best trk=" << bestTrack << ", primtrk="
01896       <<nu.primtrk
01897       <<", ntrk="<<nu.ntrk
01898       <<", trkExists1,2,3="<<nu.trkExists1<<","
01899       <<nu.trkExists2<<","<<nu.trkExists3<<endl;
01900 
01901     nu.jitter = get_jitter(nu, bestTrack);
01902     nu.jPID = get_jPID(nu, bestTrack);
01903     nu.majC = get_majC(nu, bestTrack);
01904     //nu.majCRatio = get_majCRatio(nu, bestTrack);
01905     //nu.rms = get_rms(nu, bestTrack);
01906     //nu.simpleMajC = get_simpleMajC(nu, bestTrack);
01907     nu.smoothMajC = get_smoothMajC(nu, bestTrack);
01908     //nu.sqJitter = get_sqJitter(nu, bestTrack);
01909     //nu.totWidth = get_totWidth(nu, bestTrack);
01910   }
01911   else cout<<"Ahhhhhhhhhhhh"<<endl;
01912 }

void NuReco::SetBestTrkSAFit ( NuEvent nu  )  const

Definition at line 1916 of file NuReco.cxx.

References NuEvent::chargeSA, NuEvent::chi2SA, GetBestTrack(), NuLibrary::Instance(), Msg::kDebug, Msg::kInfo, MAXMSG, NuEvent::ndofSA, NuEvent::ntrk, NuEvent::primtrk, NuEvent::probSA, NuEvent::qpSA, NuLibrary::reco, NuEvent::sigqpSA, NuEvent::trkExists1, NuEvent::trkExists2, NuEvent::trkExists3, NuEvent::trkfitpassSA, NuEvent::trkvtxdcoszSA, NuEvent::uTrkVtxSA, NuEvent::vTrkVtxSA, NuEvent::xTrkVtxSA, NuEvent::yTrkVtxSA, and NuEvent::zTrkVtxSA.

Referenced by NuExtraction::ExtractSAFitInfo(), and SetBestTrk().

01917 {
01918   //get an instance of the code library
01919   const NuLibrary& lib=NuLibrary::Instance();
01920 
01921   //get the best track
01922   Int_t bestTrack=lib.reco.GetBestTrack(nu);
01923 
01924   //copy the best track across
01925   if (bestTrack<1) {
01926     MAXMSG("NuReco",Msg::kInfo,3)
01927       <<"SetBestTrkSAFit: No best trk, primtrk="
01928       <<nu.primtrk
01929       <<", ntrk="<<nu.ntrk
01930       <<", trkExists1,2,3="<<nu.trkExists1<<","
01931       <<nu.trkExists2<<","<<nu.trkExists3<<endl;
01932     return;
01933   }
01934 
01935   if(bestTrack >= 1 && bestTrack <= 3){
01936     MAXMSG("NuReco",Msg::kDebug,3)
01937       <<"SetBestTrkSAFit: Best trk=" << bestTrack << ", primtrk="
01938       <<nu.primtrk
01939       <<", ntrk="<<nu.ntrk
01940       <<", trkExists1,2,3="<<nu.trkExists1<<","
01941       <<nu.trkExists2<<","<<nu.trkExists3<<endl;
01942 
01943     nu.trkfitpassSA = get_trkfitpassSA(nu, bestTrack);
01944     nu.trkvtxdcoszSA = get_trkvtxdcoszSA(nu, bestTrack);
01945     nu.chargeSA = get_chargeSA(nu, bestTrack);
01946     nu.qpSA = get_qpSA(nu, bestTrack);
01947     nu.sigqpSA = get_sigqpSA(nu, bestTrack);
01948     nu.chi2SA = get_chi2SA(nu, bestTrack);
01949     nu.ndofSA = get_ndofSA(nu, bestTrack);
01950     nu.probSA = get_probSA(nu, bestTrack);
01951     nu.xTrkVtxSA = get_xTrkVtxSA(nu, bestTrack);
01952     nu.yTrkVtxSA = get_yTrkVtxSA(nu, bestTrack);
01953     nu.zTrkVtxSA = get_zTrkVtxSA(nu, bestTrack);
01954     nu.uTrkVtxSA = get_uTrkVtxSA(nu, bestTrack);
01955     nu.vTrkVtxSA = get_vTrkVtxSA(nu, bestTrack);
01956   }
01957   else cout<<"Ahhhhhhhhhhhh"<<endl;
01958 }

void NuReco::TestGetSmallestDeepDistToEdge (  )  const

Definition at line 4973 of file NuReco.cxx.

References GetSmallestDeepDistToEdge(), NuEvent::xEvtVtx, and NuEvent::yEvtVtx.

04974 {
04975   NuEvent nu;
04976 
04977   TH2F* hYvsXDistToEdge=new TH2F
04978     ("hYvsXDistToEdge","hYvsXDistToEdge",
04979      600,-3,3,  600,-3,3);
04980   hYvsXDistToEdge->SetTitle("SmallestDeepDistToEdge");
04981   hYvsXDistToEdge->GetXaxis()->SetTitle("X (m)");
04982   hYvsXDistToEdge->GetXaxis()->CenterTitle();
04983   hYvsXDistToEdge->GetYaxis()->SetTitle("Y (m)");
04984   hYvsXDistToEdge->GetYaxis()->CenterTitle();
04985 
04986   for (Float_t x=-3;x<3;x+=0.01) {
04987     for (Float_t y=-3;y<3;y+=0.01) {
04988 
04989       nu.xEvtVtx=x;
04990       nu.yEvtVtx=y;
04991       Float_t dist=this->GetSmallestDeepDistToEdge(nu);
04992       //cout<<"x,y="<<x<<","<<y<<", dist="<<dist<<endl;
04993       hYvsXDistToEdge->Fill(x,y,dist);
04994     }
04995   }
04996 }

Bool_t NuReco::UseCurvature ( const NuEvent nu  )  const

Definition at line 2295 of file NuReco.cxx.

References NuEvent::containmentFlag.

Referenced by CalcTrkVariables(), and GetTrackEnergy().

02296 {
02297   return (nu.containmentFlag == 2 || nu.containmentFlag == 4);
02298 }

Bool_t NuReco::UseRange ( const NuEvent nu  )  const

Definition at line 2288 of file NuReco.cxx.

References NuEvent::containmentFlag.

Referenced by CalcTrkVariables(), and GetTrackEnergy().

02289 {
02290   return (nu.containmentFlag == 1 || nu.containmentFlag == 3);
02291 }

TVector3 NuReco::uvz2xyz ( Float_t  u,
Float_t  v,
Float_t  z,
VldContext  vc 
) const

Definition at line 5014 of file NuReco.cxx.

References UgliGeomHandle::uvz2xyz().

Referenced by NuExtraction::ExtractSAFitInfo(), and NuPlots::FillDetectorEdge().

05016 {
05017   //get an ugh
05018   UgliGeomHandle ugh(vc);
05019 
05020   //calculate the positions in XYZ system
05021   TVector3 uvz(u,v,z);
05022   TVector3 xyz=ugh.uvz2xyz(uvz);
05023   return xyz;
05024 }

TVector3 NuReco::xyz2uvz ( Float_t  x,
Float_t  y,
Float_t  z,
VldContext  vc 
) const

Definition at line 5000 of file NuReco.cxx.

References UgliGeomHandle::xyz2uvz().

Referenced by CalcExtraTruthVariables().

05002 {
05003   //get an ugh
05004   UgliGeomHandle ugh(vc);
05005 
05006   //calculate the positions in UVZ system
05007   TVector3 xyz(x,y,z);
05008   TVector3 uvz=ugh.xyz2uvz(xyz);
05009   return uvz;
05010 }


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1