1 #include "tutorialAnalysis.hxx" 2 #include "FiducialVolumeDefinition.hxx" 3 #include "Parameters.hxx" 4 #include "tutorialSelection.hxx" 5 #include "tutorialBranchesSelection.hxx" 6 #include "tutorialCorrection.hxx" 7 #include "tutorialWeightSystematics.hxx" 8 #include "tutorialVariationSystematics.hxx" 9 #include "CategoriesUtils.hxx" 10 #include "BasicUtils.hxx" 11 #include "baseToyMaker.hxx" 12 #include "NuDirUtils.hxx" 13 #include "KinematicsUtils.hxx" 119 SetMinAccumCutLevelToSave(ND::params().GetParameterI(
"tutorialAnalysis.MinAccumLevelToSave"));
147 sel().AddSelection(
"kTrackerTutorial",
"tutorial selection",
new tutorialSelection(
false));
150 sel().AddSelection(
"kTrackerTutorialBranches",
"tutorial selection with branches",
new tutorialBranchesSelection(
false));
153 if (!ND::params().GetParameterI(
"tutorialAnalysis.Selections.RunSelectionWithoutBranches"))
154 sel().DisableSelection(
"kTrackerTutorial");
156 if (!ND::params().GetParameterI(
"tutorialAnalysis.Selections.RunSelectionWithBranches"))
157 sel().DisableSelection(
"kTrackerTutorialBranches");
177 baseTrackerAnalysis::DefineCorrections();
247 Int_t ntoys = ND::params().
GetParameterI(
"baseAnalysis.Systematics.NumberOfToys");
248 Int_t randomSeed = ND::params().
GetParameterI(
"baseAnalysis.Systematics.RandomSeed");
257 AddConfiguration(conf(), tutorial_syst, ntoys, randomSeed,
new baseToyMaker(randomSeed));
258 conf().EnableSystematic(kTutorialWeight, tutorial_syst);
259 conf().EnableSystematic(kTutorialVariation, tutorial_syst);
262 if (!ND::params().GetParameterI(
"tutorialAnalysis.Systematics.EnableTutorialSystematics"))
263 conf().DisableConfiguration(tutorial_syst);
283 if (addBase) baseTrackerAnalysis::DefineMicroTrees(addBase);
286 AddVarD( output(), selmu_costheta,
"muon candidate reconstructed cos(theta) w.r.t. to neutrino direction");
287 AddVarF( output(), selmu_truemom,
"muon candidate true momentum");
288 AddVarI( output(), selmu_detectors,
"muon candidate detectors");
289 AddVarC( output(), selmu_sense,
"muon candidate sense");
291 AddVarF( output(), selmu_deltaPhi,
"angle between muon candidate and the proton candidate (HMP track)");
292 AddVarF( output(), selmu_pT,
"muon candidate reconstructed transverse momentum w.r.t to neutrino direction");
294 AddVarI( output(), nLongTPCTracks,
"number of long TPC tracks");
298 AddVarVI(output(), selmu_tpc_det,
"muon candidate TPC number", selmu_ntpcs);
299 AddVarVI(output(), selmu_tpc_nnodes,
"muon candidate #nodes in each TPC", selmu_ntpcs);
300 AddVarVF(output(), selmu_tpc_mom,
"muon candidate reconstructed momentum in each TPC", selmu_ntpcs);
301 AddVarVD(output(), selmu_tpc_truemom,
"muon candidate true momentum in each TPC", selmu_ntpcs);
304 AddVar4VF(output(), selmu_pos,
"muon candidate reconstructed position");
305 AddVar3VF(output(), selmu_dir,
"muon candidate reconstructed direction");
311 AddVar4MF(output(), selmu_tpc_pos,
"muon candidate true position in each tpc", selmu_ntpcs);
312 AddVar3MF(output(), selmu_tpc_dir,
"muon candidate true direction in each tpc", selmu_ntpcs);
321 AddToyVarF(output(), selmu_mom,
"muon candidate reconstructed momentum");
324 AddToyVarVF(output(), selmu_tpc_dedx,
"muon candidate dEdx (CT) in each TPC", NMAXTPCS);
344 The main trees in the output file are the
"default" and
"truth" trees. The
"default" tree contains all selected events (the ones that passed a given cut, ussualy
345 specified in the parameters file). This is the tree used to optimise the selection cuts, to make selection plots and to compute or plot the purity of the selection.
346 The main reason
for having a separate tree, call
"truth", is to allow the efficiency computation. The
"default" tree does not contain all
true signal events,
347 because it will be too big. The preselection
for that tree is only based in reconstructed quantities (selection cuts). Instead, to compute
true signal efficiencies
348 we need all
true signal events to be present in the output tree. The
"truth" tree fullfils
this condition. Since, in general,
this tree will contain many events, only a
349 reduced
set of variables (the ones needed to compute the efficiency) is stored in that tree.
351 SUMMARY: The
"truth" tree also appears in the output file. It contains all interactions in which we are interested in regardless on whether
352 the selection was passed or not. This is the tree that should be used to compute signal efficiencies
358 baseTrackerAnalysis::DefineTruthTree();
361 AddVarI( output(), truelepton_pdg,
"true lepton PDG");
362 AddVar4VF(output(), truelepton_pos,
"true lepton position");
381 if (addBase) baseTrackerAnalysis::FillMicroTreesBase(addBase);
384 output().FillVar(nLongTPCTracks, static_cast<const ToyBoxTutorial*>(&box())->nLongTPCTracks);
387 if (box().MainTrack){
391 output().FillVar(selmu_detectors, static_cast<AnaTrack*>(box().MainTrack)->Detectors);
395 TVector3 nuDirVec = anaUtils::GetNuDirRec(box().MainTrack->PositionStart);
396 TVector3 muDirVec = anaUtils::ArrayToTVector3(box().MainTrack->DirectionStart);
397 double costheta_mu_nu = nuDirVec.Dot(muDirVec);
401 output().FillVar(selmu_costheta, costheta_mu_nu);
405 nuDirVec.GetXYZ(nuDirArr);
407 output().FillVar(selmu_pT, pT);
412 deltaPhi =
anaUtils::GetDPhi(nuDirArr,box().MainTrack->DirectionStart,box().HMPtrack->DirectionStart);
413 output().FillVar(selmu_deltaPhi, deltaPhi);
416 if (box().MainTrack->DirectionStart[2]>0)
417 output().FillVar(selmu_sense,
"forward");
419 output().FillVar(selmu_sense,
"backward");
422 output().FillVectorVarFromArray(selmu_pos, box().MainTrack->PositionStart, 4);
423 output().FillVectorVarFromArray(selmu_dir, box().MainTrack->DirectionStart, 3);
428 if( box().MainTrack->GetTrueParticle() ) {
429 output().FillVar(selmu_truemom, box().MainTrack->GetTrueParticle()->Momentum);
433 for (Int_t subdet = 0; subdet<3; subdet++) {
436 if (!TPCSegment)
continue;
437 output().FillVectorVar(selmu_tpc_det, subdet);
438 output().FillVectorVar(selmu_tpc_mom, TPCSegment->
Momentum);
439 output().FillVectorVar(selmu_tpc_nnodes, TPCSegment->
NNodes);
442 output().FillMatrixVarFromArray(selmu_tpc_pos, TPCSegment->
PositionStart, 4);
443 output().FillMatrixVarFromArray(selmu_tpc_dir, TPCSegment->
DirectionStart, 3);
453 output().IncrementCounterForVar(selmu_tpc_det);
475 if (addBase) baseTrackerAnalysis::FillToyVarsInMicroTreesBase(addBase);
478 if (box().MainTrack){
480 output().FillToyVar(selmu_mom, box().MainTrack->Momentum);
483 for (Int_t subdet = 0; subdet<3; subdet++) {
486 if (!TPCSegment)
continue;
488 output().FillToyVectorVar(selmu_tpc_dedx, TPCSegment->
dEdxMeas, subdet);
508 void tutorialAnalysis::FillTruthTree(
const AnaTrueVertex& vtx){
512 baseTrackerAnalysis::FillTruthTreeBase(vtx);
515 output().FillVar(truelepton_pdg,vtx.
LeptonPDG);
516 output().FillVectorVarFromArray(truelepton_pos, vtx.
Position, 4);
524 void tutorialAnalysis::FillCategories(){
544 void tutorialAnalysis::FillConfigTree(){
556 AddVarD(output(), nNucleonsFGD1,
"number of targets in FGD1");
557 AddVarD(output(), nNucleonsFGD2scint,
"number of targets in FGD2 scintillator");
558 AddVarD(output(), nNucleonsFGD2water,
"number of targets in FGD2 water");
560 output().FillVar(nNucleonsFGD1, anaUtils::GetNTargets(anaUtils::kFGD1));
561 output().FillVar(nNucleonsFGD2scint, anaUtils::GetNTargets(anaUtils::kFGD2xymodules));
562 output().FillVar(nNucleonsFGD2water, anaUtils::GetNTargets(anaUtils::kFGD2watermodules));
void FillMicroTrees(bool addBase=true)
[tutorialAnalysis_DefineTruthTree]
Float_t PositionStart[4]
The reconstructed start position of the particle.
Int_t NuPDG
The PDG code of the incoming neutrino.
Int_t LeptonPDG
The PDG code of the primary outgoing electron/muon.
int GetParameterI(std::string)
Get parameter. Value is returned as integer.
void AddPackage(const std::string &name, const std::string &version)
Add a package.
Int_t NNodes
The number of nodes in the reconstructed object.
static bool GetDetectorUsed(unsigned long BitField, SubDetId::SubDetEnum det)
Method to see if a certain subdetector or subdetector system is used.
bool Initialize()
[AnalysisAlgorithm_mandatory]
Float_t Momentum
The initial momentum of the true particle.
AnaParticleB * GetSegmentInDet(const AnaTrackB &track, SubDetId::SubDetEnum det)
virtual void DefineSystematics()
std::string GetSoftwareVersionFromPath(const std::string &path)
Get The software version from the path of the package.
Float_t Momentum
The reconstructed momentum of the particle, at the start position.
Representation of a true Monte Carlo vertex.
Float_t Position[4]
The position the true interaction happened at.
void DefineMicroTrees(bool addBase=true)
[tutorialAnalysis_DefineConfigurations]
void FillToyVarsInMicroTrees(bool addBase=true)
[tutorialAnalysis_FillMicroTrees]
Float_t GetTransverseMom(const Float_t *nudir, const Float_t *thisdir, Float_t thismom)
Get the transverse momentum.
void DefineTruthTree()
[tutorialAnalysis_DefineMicroTrees]
void FillCategories(AnaEventB *event, AnaTrack *track, const std::string &prefix, const SubDetId::SubDetEnum det=SubDetId::kFGD1, bool IsAntinu=false, bool useCATSAND=true)
Fill the track categories for color drawing.
Float_t dEdxMeas
dE/dx as measured by the TPC.
virtual bool Initialize()
[AnalysisAlgorithm_mandatory]
void DefineConfigurations()
[tutorialAnalysis_DefineSystematics]
Float_t DirectionStart[3]
The reconstructed start direction of the particle.
void DefineCorrections()
[tutorialAnalysis_DefineSelections]
void DefineSelections()
Add to the selection manager the selections for this analysis.
void AddStandardCategories(const std::string &prefix="")
Add the standard categories only, given a prefix for their name.
Representation of a TPC segment of a global track.
This is a normalization systematic. It takes into account the uncertainty on the FGD mass introduced ...
AnaTrueParticleB * GetTrueParticle() const
Return a casted version of the AnaTrueObject associated.
bool InFiducialVolume(SubDetId::SubDetEnum det, const Float_t *pos, const Float_t *FVdefmin, const Float_t *FVdefmax)
bool CheckFillTruthTree(const AnaTrueVertex &vtx)
[tutorialAnalysis_FillToyVarsInMicroTrees]
Float_t GetDPhi(const Float_t *nudir, const Float_t *mudir, const Float_t *pdir)
Returns pi-(the angle between muon and proton). Should be delta-fn in ideal back2back.
void DefineSystematics()
[tutorialAnalysis_DefineCorrections]
virtual void DefineConfigurations()