1 #include "nueCCAnalysis.hxx" 2 #include "nueCCSelection.hxx" 3 #include "nueCCFGD2Selection.hxx" 5 #include "CutUtils.hxx" 6 #include "nueCCUtils.hxx" 7 #include "CategToolsNueCC.hxx" 9 #include "FiducialVolumeDefinition.hxx" 10 #include "Parameters.hxx" 11 #include "UseGlobalAltMomCorrection.hxx" 12 #include "CategoriesUtils.hxx" 13 #include "BasicUtils.hxx" 14 #include "baseToyMaker.hxx" 16 #include "NuDirUtils.hxx" 34 SetMinAccumCutLevelToSave(ND::params().GetParameterI(
"nueCCAnalysis.MinAccumLevelToSave"));
37 _whichFGD = ND::params().
GetParameterI(
"nueCCAnalysis.Analysis.Sample.whichFGD");
40 _savesecondaries = ND::params().
GetParameterI(
"nueCCAnalysis.Analysis.SaveSecondaries");
43 _p5 = ND::params().
GetParameterI(
"nueCCAnalysis.Corrections.p5michel");
46 _addmoretoyvariables = ND::params().
GetParameterI(
"nueCCAnalysis.MicroTrees.AdditionalToyVars");
49 nue_categs::AddCategories(
"",
false);
50 nue_categs::AddCategories(
"fgd2",
false);
59 void nueCCAnalysis::DefineSelections(){
65 else if (_whichFGD==2)
67 else if (_whichFGD==3) {
74 void nueCCAnalysis::DefineCorrections(){
78 baseTrackerAnalysis::DefineCorrections();
83 #if !VERSION_HAS_EQUIVALENT_MAIN_AND_ALT_FITS 84 if (ND::params().GetParameterI(
"nueCCAnalysis.Corrections.UseGlobalEleMom.Enable") == 1) {
92 void nueCCAnalysis::DefineTruthTree(){
96 baseTrackerAnalysis::DefineTruthTree();
98 AddVarF(output(), truelepton_costheta_z,
"True Cos(Theta) of the true electron w.r.t z-axis");
99 AddVarF(output(), truelepton_costheta_offaxis,
"True Cos(Theta) of the true electron w.r.t off-axis direction");
100 AddVarF(output(), truelepton_costheta_nuDir,
"True Cos(Theta) of the true electron w.r.t. nu direction");
101 AddVar4VF(output(), truelepton_pos,
"True position of the true electron");
102 AddVarI(output(), truelepton_det,
"FGD where the true electron start position is");
105 AddVarI(output(), truevtx_mass_component,
"mass component enum related to the true vtx position (FGD1 / FGD2_scint / FGD2_water");
106 AddVarF(output(), Q2_true,
"true Q2");
107 AddVarI(output(), InitiatorPDG,
"Gamma comes from what particle");
108 AddVarI(output(), InitiatorParentPDG,
"Initiator parentpdg");
109 AddVarF(output(), InitiatorMom,
"initiator momentum");
110 AddVar3VF(output(), InitiatorDir,
"initiator direction");
115 void nueCCAnalysis::DefineMicroTrees(
bool addBase){
120 if (addBase) baseTrackerAnalysis::DefineMicroTrees(addBase);
124 AddToyVarI(output(), truevtx_mass_component,
"mass component enum related to the true vtx position (FGD1 / FGD2_scint / FGD2_water");
127 AddToyVarF(output(),selelec_mom,
"Recon momentum of the selected track");
128 AddToyVarF(output(),selelec_costheta,
"Electron candidate reconstructed polar angle wrt neutrino direction");
129 AddToyVarF(output(),selelec_ENuRec,
"The reconstructed neutrino energy, assuming CCQE kinematics");
130 AddToyVarF(output(),selelec_Q2Rec,
"The reconstructed Momentum Transfer, assuming CCQE kinematics");
132 if(_addmoretoyvariables){
134 AddToyVarF(output(), selelec_tpcdedx,
"First TPC dEdx");
135 AddToyVarF(output(), selelec_pullmuon,
"Muon pull in the most upstream TPC");
136 AddToyVarF(output(), selelec_pullelec,
"Electron pull in the most upstream TPC");
137 AddToyVarF(output(), selelec_pullpion,
"Pion pull in the most upstream TPC");
138 AddToyVarF(output(), selelec_pullprot,
"Proton pull in the most upstream TPC");
141 AddToyVarF(output(), selelec_pullmuon2nd,
"Muon pull of the second TPC segment, if the track uses more than 1 TPC");
142 AddToyVarF(output(), selelec_pullelec2nd,
"Electron pull of the second TPC segment, if the track uses more than 1 TPC");
145 AddToyVarF(output(), selelec_ecalemene,
"Reconstructed EM energy deposit (in MeV) of the selected track's ECal segment");
149 AddVarF(output(), selelec_tpcdedx,
"First TPC dEdx");
150 AddVarF(output(), selelec_pullmuon,
"Muon pull in the most upstream TPC");
151 AddVarF(output(), selelec_pullelec,
"Electron pull in the most upstream TPC");
152 AddVarF(output(), selelec_pullpion,
"Pion pull in the most upstream TPC");
153 AddVarF(output(), selelec_pullprot,
"Proton pull in the most upstream TPC");
156 AddVarF(output(), selelec_pullmuon2nd,
"Muon pull of the second TPC segment, if the track uses more than 1 TPC");
157 AddVarF(output(), selelec_pullelec2nd,
"Electron pull of the second TPC segment, if the track uses more than 1 TPC");
160 AddVarF(output(), selelec_ecalemene,
"Reconstructed EM energy deposit (in MeV) of the selected track's ECal segment");
164 AddVarF(output(), selelec_costheta_z,
"Recon Cos(Theta) of the selected track w.r.t z-axis");
165 AddVarF(output(), selelec_costheta_offaxis,
"Recon Cos(Theta) of the selected track w.r.t. off-axis direction");
166 AddVarF(output(), selelec_phi,
"Recon Phi of the selected track");
167 AddVarF(output(), selelec_pt,
"Pt of the selected track");
168 AddVar4VF(output(), selelec_startpos,
"Recon position of the selected track");
169 AddVar4VF(output(), selelec_startdir,
"Recon direction of the selected track");
170 AddVarF(output(), selelec_momErr,
"Uncertainty on the reconstructed momentum of the selected track");
171 AddVarF(output(), selelec_momEleFit,
"Reconstructed momentum of selected track, assuming the electron hypothesis");
172 AddVarF(output(), selelec_momMuonFit,
"Reconstructed momentum of selected track, assuming the muon hypothesis");
173 AddVarF(output(), selelec_ElemomECalEntrance,
"Reconstructed momentum of selected track, at the entrance to the ECal");
174 AddVarI(output(), selelec_tpcNNodes,
"The number of nodes in the most upstream TPC segment of the selected track");
175 AddVarI(output(), selelec_FGD,
"The FGD in which the selected track starts (either 0 or 1)");
176 AddVarF(output(), selelec_ElemomTPCBack,
"The momentum of the selected track at the back of the most downstream TPC segment");
177 AddVar4VF(output(), selelec_tpcBackPos,
"The position of the selected track at the back of the most downstream TPC segment");
178 AddVar3VF(output(), selelec_tpcBackDir,
"The direction of the selected track at the back of the most downstream TPC segment");
179 AddVarI(output(), selelec_inp0d,
"Is the main track goes in the P0D");
182 AddVarVI(output(), selelec_fgd_det,
"Electron candidate FGD number", selelec_nfgds);
183 AddVarVF(output(), selelec_fgd_x,
"Electron candidate track length in each FGD", selelec_nfgds);
184 AddVarVF(output(), selelec_fgd_E,
"Electron candidate energy deposit in each FGD", selelec_nfgds);
185 AddVarVF(output(), selelec_fgd_V11,
"Electron candidate V11 vertex activity in each FGD", selelec_nfgds);
186 AddVarVF(output(), selelec_fgd_V33,
"Electron candidate V33 vertex activity in each FGD", selelec_nfgds);
187 AddVarVF(output(), selelec_fgd_V55,
"Electron candidate V55 vertex activity in each FGD", selelec_nfgds);
188 AddVarVF(output(), selelec_fgd_V77,
"Electron candidate V77 vertex activity in each FGD", selelec_nfgds);
189 AddVarVF(output(), selelec_fgd_VLayer,
"Electron candidate VLayer vertex activity in each FGD", selelec_nfgds);
190 AddVarVF(output(), selelec_fgd_pullmu,
"Electron candidate muon pull in each FGD", selelec_nfgds);
191 AddVarVF(output(), selelec_fgd_pullpi,
"Electron candidate pion pull in each FGD", selelec_nfgds);
192 AddVarVF(output(), selelec_fgd_pullprot,
"Electron candidate protn pull in each FGD", selelec_nfgds);
193 AddVarVI(output(), selelec_fgd_containment,
"Electron candidate containment in each FGD", selelec_nfgds);
196 AddVarI(output(), selelec_nECALs,
"Number of Ecal clusters found");
197 AddVarI(output(), selelec_ecaldetector,
"The detector in which the selected track's ECal segment was found, DsECal is 6. Barrel ECal: 7- top, 8-bottom, 9-left, 10-right ");
198 AddVarI(output(), selelec_ecalnhits,
"The number of hits in the selected track's ECal segment");
199 AddVarI(output(), selelec_ecalMostUpStreamLayerHit,
"The first layer hit in the selected track's ECal segment");
200 AddVarF(output(), selelec_ecalmipem,
"MipEm value of the selected track's ECal segment, if it uses the DSECal. Negative means more MIP-like, positive means more EM shower-like.");
201 AddVarF(output(), selelec_ecalmippion,
"MipPion value of the selected track's ECal segment");
202 AddVarF(output(), selelec_ecalemhip,
"EmHip value of the selected track's ECal segment");
203 AddVarI(output(), selelec_ecalcontained,
"Whether the selected track's ECal segment is 'contained' or not, according to the definition used in the analysis");
204 AddVar3VF(output(), selelec_ecalshowerpos,
"The reconstructed position of the selected track's ECal segment (according to the shower-based reconstruction)");
205 AddVarF(output(), selelec_ecallength,
"Length of the ECal segment");
208 AddVarF(output(), selelec_ToF_P0D_FGD1,
"ToF between P0D and FGD1");
209 AddVarF(output(), selelec_ToF_ECal_FGD1,
"ToF between BrEcal and FGD1");
210 AddVarF(output(), selelec_ToF_ECal_FGD2,
"ToF between BrEcal and FGD2");
211 AddVarF(output(), selelec_ToF_FGD1_FGD2,
"ToF between FGD1 and FGD2");
212 AddVarF(output(), selelec_ToF_DsECal_FGD1,
"ToF between DsEcal and FGD1");
213 AddVarF(output(), selelec_ToF_DsECal_FGD2,
"ToF between DsEcal and FGD2");
216 AddVarI(output(), selelec_true_pdg,
"PDG code of true particle");
217 AddVarF(output(), selelec_true_mom,
"True momentum of the selected track");
218 AddVar4VF(output(), selelec_true_pos,
"True position of the selected track");
219 AddVar4VF(output(), selelec_true_endpos,
"True endposition of the selected track");
220 AddVar3VF(output(), selelec_true_dir,
"True directionof the selected track");
221 AddVarF(output(), selelec_true_costheta_z,
"True Cos(Theta) of the selected track w.r.t z-axis");
222 AddVarF(output(), selelec_true_costheta_offaxis,
"True Cos(Theta) of the selected track w.r.t off-axis direction");
223 AddVarF(output(), selelec_true_costheta_nuDir,
"True Cos(Theta) of the selected track w.r.t nu direction");
226 AddVarI(output(), truelepton_pdg,
"Pdg of the true lepton");
227 AddVarI(output(), truelepton_det,
"Detector where the true lepton start position is");
228 AddVarF(output(), truelepton_mom,
"True momentum of the true lepton");
229 AddVarF(output(), truelepton_costheta_z,
"True Cos(Theta) of the true lepton w.r.t. z-axis");
230 AddVarF(output(), truelepton_costheta_nuDir,
"True Cos(Theta) of the true lepton w.r.t. nu direction");
231 AddVarF(output(), truelepton_costheta_offaxis,
"True Cos(Theta) of the true lepton w.r.t off-axis direction");
232 AddVar4VF(output(), truelepton_pos,
"True position of the true lepton");
233 AddVar3VF(output(), truelepton_dir,
"True direction of the true lepton");
234 AddVarF(output(), truelepton_nuErecQE,
"Neutrino reconstructed energy with true lepton kinematics in ccqe formula");
235 AddVarI(output(), InitiatorPDG,
"Gamma comes from what particle");
236 AddVarI(output(), InitiatorParentPDG,
"Initiator parentpdg");
237 AddVarF(output(), InitiatorMom,
"initiator momentum");
238 AddVar3VF(output(), InitiatorDir,
"initiator direction");
241 AddVarF(output(), TPCVetoDeltaz,
"Z difference between the selected track and the track used in the TPC1 veto");
242 AddVarF(output(), TPCVetoMomentum,
"Momentum of the track used in the TPC1 veto");
243 AddVarI(output(), TPCVetoCharge,
"Charge (+1/-1) of the track used in the TPC1 veto.");
244 AddVarI(output(), TPCVetoNNearP0DTracks,
"Number of FGD-TPC tracks near the vertex entering the P0D");
245 AddVarI(output(), TPCVetoNNearTracks,
"Number of FGD-TPC tracks near the vertex");
246 AddVarI(output(), TPCVetoNFarTracks,
"Number of FGD-TPC tracks far from vertex");
247 AddVarF(output(), SecMomFGDDeltaZ,
"DZ between the selected track and the second most energetic track in the same FGD");
250 AddVarI(output(), NP0DVetoP0DTracks,
"Number of reconstructed objects in the P0D FV");
251 AddVarI(output(), NP0DVetoFGD1Tracks,
"Number of reconstructed objects in the FGD1 FV");
252 AddVarI(output(), NP0DVetoP0DEcalTracks,
"Number of P0DEcal objects");
253 AddVarI(output(), FGD2ShowerNFGD1TPC2Tracks,
"Number of FGD1-TPC2 tracks used in the FGD2 shower cut");
254 AddVarI(output(), FGD2ShowerNFGD2TPC3Tracks,
"Number of FGD2-TPC3 tracks used in the FGD2 shower cut");
255 AddVarI(output(), FGDOOFVActivity,
"Check for OOFV FGD Iso");
256 AddVarI(output(), NFGDOOFVTracksReqTPC,
"Number of OOFV FGD-TPC tracks");
259 AddVarF(output(), ECALMinZ,
"Z distance between the selected track and the most upstream ECal segment");
260 AddVarF(output(), ECALNCMinZ,
"Z distance between the selected track and the most upstream ECal neutral cluster segment");
261 AddVarF(output(), TPCECALdist,
"Distance between the end of the most downstream TPC segment of the selected track and the nearest ECal track");
262 AddVar3VF(output(), ECALPosECALSegment,
"Position of the ECal segment of the closest ECal track to the selected track");
263 AddVar3VF(output(), ECALPosGlobalTrack,
"Start position of the closest ECal track to the selected track");
264 AddVar3VF(output(), ECALTrueVertexPos,
"True vertex position of the closest ECal track to the selected track");
267 AddVarF(output(), PairTrack_mom,
"Momentum of the matched e-/e+ pair");
268 AddVarF(output(), PairTrack_costheta,
"Angle of the matched e-/e+ pair");
269 AddVarI(output(), PairTrack_pdg,
"Pdg of the matched e-/e+ pair");
270 AddVarF(output(), PairTrack_InvMass,
"Invariant mass of the matched e-/e+ pair");
271 AddVar4VF(output(), PairTrack_startdir,
"Recon direction of the matched e-/e+ paired track");
272 AddVar4VF(output(), PairTrack_startpos,
"Recon position of the matched e-/e+ paired track");
273 AddVar4VF(output(), PairTrack_true_startdir,
"True direction of the matched e-/e+ paired track");
274 AddVar4VF(output(), PairTrack_true_startpos,
"True position of the matched e-/e+ paired track");
275 AddVarI(output(), PairTrack_tpcNNodes,
"Number of TPC hits of the matched e-/e+ pair");
277 AddVarF(output(), TruePairTrack_true_mom,
"Momentum of the true paired track from gamma background");
278 AddVarI(output(), TruePairTrack_pdg,
"PDG of the true paired track from gamma background");
279 AddVarF(output(), selelec_parent_true_mom,
"Momentum of the selected track's parent - only for background events");
280 AddVarI(output(), selelec_parent_pdg,
"PDG of the selected track's parent - only for background events");
281 AddVarF(output(), selelec_gparent_true_mom,
"Momentum of the selected tracks's grandparent - only for background events");
282 AddVarI(output(), selelec_gparent_pdg,
"PDG of the selected tracks's grandparent - only for background events");
285 AddVarI(output(), NuParentPDGRaw,
"True parent that decayed to create the neutrino");
286 AddVarI(output(), TargetPDG,
"True target of the neutrino Int_teraction (oxygen, carbon etc.)");
287 AddVar4VF(output(), NuParentDecPoint,
"True position at which the neutrino was created");
288 AddVarI(output(), NTruePions,
"Number of true pions ejected from the nucleus");
289 AddVarI(output(), NTruePi0,
"Number of true pi0 ejected from the nucleus");
290 AddVarI(output(), NTrueKaonRhoEta,
"Number of true kaons-rhos-etas ejected from the nucleus");
291 AddVarF(output(), Q2_true,
"true Q2");
294 if(_savesecondaries){
295 AddVarVI(output(), FGDTPCTrack_det,
"FGD detector of the FGD-TPC track", Nfgdtpc);
296 AddVarVF(output(), FGDTPCTrack_mom,
"Recon momentum FGD-TPC track", Nfgdtpc);
297 AddVarVF(output(), FGDTPCTrack_charge,
"Charge FGD-TPC track", Nfgdtpc);
298 AddVarVF(output(), FGDTPCTrack_costheta,
"Recon cos(theta) FGD-TPC track", Nfgdtpc);
299 AddVarMF(output(), FGDTPCTrack_startpos,
"Recon position FGD-TPC track", Nfgdtpc, -40 ,4);
300 AddVarMF(output(), FGDTPCTrack_startdir,
"Recon direction FGD-TPC track", Nfgdtpc, -40, 3);
301 AddVarVF(output(), FGDTPCTrack_pullmuon,
"Muon pull FGD-TPC track", Nfgdtpc);
302 AddVarVF(output(), FGDTPCTrack_pullelec,
"Electron pullFGD-TPC track", Nfgdtpc);
303 AddVarVF(output(), FGDTPCTrack_pullpion,
"Pion pull FGD-TPC track", Nfgdtpc);
304 AddVarVF(output(), FGDTPCTrack_pullprot,
"Proton pull FGD-TPC track", Nfgdtpc);
305 AddVarVI(output(), FGDTPCTrack_tpcNNodes,
"TPC nodes FGD-TPC track", Nfgdtpc);
306 AddVarVI(output(), FGDTPCTrack_pdg,
"PDG FGD-TPC track", Nfgdtpc);
308 AddVarVF(output(), FGDTPCTrack_MomECalEntrance,
"Momentum at the entrance of the Ecal", Nfgdtpc);
309 AddVarVF(output(), FGDTPCTrack_EMEnergy,
"Ecal EM Energy", Nfgdtpc);
310 AddVarVF(output(), FGDTPCTrack_MipEm,
"Ecal MipEm", Nfgdtpc);
311 AddVarVF(output(), FGDTPCTrack_MipPion,
"Ecal MipPion", Nfgdtpc);
312 AddVarVF(output(), FGDTPCTrack_EmHip,
"Ecal EmHip", Nfgdtpc);
313 AddVarMF(output(), FGDTPCTrack_ShowerPosition,
"Ecal Shower Position", Nfgdtpc, -40 ,4);
314 AddVarVI(output(), FGDTPCTrack_ECALdet,
"Ecal detector", Nfgdtpc);
315 AddVarVI(output(), FGDTPCTrack_NHits,
"Ecal number of shower hits", Nfgdtpc);
316 AddVarVI(output(), FGDTPCTrack_MostUpStreamLayerHit,
"Ecal first layer", Nfgdtpc);
317 AddVarVI(output(), FGDTPCTrack_IsEcalContained,
"Ecal containtment", Nfgdtpc);
319 AddVarVI(output(), fgdiso_det,
"In which FGD is the FGD-iso selected", NisoFgds);
320 AddVarVF(output(), fgdiso_x,
"Length of the FGD-iso tracks", NisoFgds);
321 AddVarVF(output(), fgdiso_E,
"Energy deposit of the FGD-iso tracks", NisoFgds);
322 AddVarVF(output(), fgdiso_pullmu,
"Muon pull of the FGD-iso tracks", NisoFgds);
323 AddVarVF(output(), fgdiso_pullpi,
"Pion pull of the FGD-iso tracks", NisoFgds);
324 AddVarVF(output(), fgdiso_pullprot,
"Proton pull of the FGD-iso tracks", NisoFgds);
325 AddVarMF(output(), fgdiso_position,
"Recon position of the the FGD-iso tracks",NisoFgds,-40,4);
326 AddVarVI(output(), fgdiso_containment,
"Containment of the FGD-iso tracks", NisoFgds);
327 AddVarVF(output(), fgdiso_costheta,
"Cos(theta) of the FGD-iso tracks", NisoFgds);
328 AddVarVI(output(), fgdiso_pdg,
"PDG of the FGD-iso tracks", NisoFgds);
331 AddVarI(output(), NME,
"Number of Michel electrons in the event FGD. (For P5 this only applies to FGD1 events)");
333 AddVarI(output(), NFGDTracksReqTPC,
"Number of FGD-TPC tracks in the same FGD as the selected track");
334 AddVarI(output(), NFGD1TracksReqTPC1,
"Number of FGD1-TPC1 tracks");
335 AddVarI(output(), NFGD1TracksReqTPC2,
"Number of FGD1-TPC2 tracks");
336 AddVarI(output(), NFGD2TracksReqTPC2,
"Number of FGD2-TPC2 tracks");
337 AddVarI(output(), NFGD2TracksReqTPC3,
"Number of FGD2-TPC3 tracks");
338 AddVarI(output(), NFGD1TracksReqEcal,
"Number of FGD1-Ecal tracks");
339 AddVarI(output(), NFGD2TracksReqEcal,
"Number of FGD2-Ecal tracks");
340 AddVarF(output(), FGDDistanceReqTpc,
"Distance between the selected track and the nearest FGD-TPC track");
341 AddVarF(output(), FGDMaxDistanceReqTpc,
"Distance between the selected track and the most far away FGD-TPC track");
342 AddVarF(output(), FGDDistanceNoReqTpc,
"Distance between the selected track and the nearest FGD-TPC or FGD-only track");
343 AddVarF(output(), FGDMaxDistanceNoReqTpc,
"Distance between the selected track and the most far away FGD-TPC or FGD-only track");
344 AddVarF(output(), FGD2XYMaxTrackDist,
"Maximum XY distance of any tracks in FGD2");
347 AddVarI(output(), NECalTracks,
"Number of ECal tracks that aren't attached to the selected track");
348 AddVarI(output(), NDsEcalNeutralClusters,
"Number of DsEcal neutral cluster");
349 AddVarI(output(), NBrEcalNeutralClusters,
"Number of BrEcal neutral cluster");
350 AddVarF(output(), MostEnergeticEcalNeutralCluster,
"Most energetic ecal neutral cluster");
351 AddVarF(output(), EcalNeutralClusterEnergySum,
"The energy sum of the all the ecal neutral clusters");
352 AddVarI(output(), EcalClusterMostEnergeticThanHMT,
"Number of Tracker-ECal tracks that aren't the HM track and have EMEnergy larger than the momentum of the HM track");
353 AddVarI(output(), BremNeutralClusters,
"Number of ECal neutral cluster selected as Brem candidates associated with the HM track");
354 AddVarF(output(), BremNeutralClustersEnergy,
"Energy of the ECal neutral cluster selected as Brem candidates associated with the HM track");
355 AddVarF(output(), BremNeutralClustersMinTheta,
"Minimum theta of the ECal neutral cluster selected as Brem candidates associated with the HM track");
356 AddVarF(output(), BremNeutralClustersMinPhi,
"Minimum phi of the ECal neutral cluster selected as Brem candidates associated with the HM track");
357 AddVarI(output(), FragmentsNeutralClusters,
"Number of ECal neutral cluster classified as shower fragments from the main shower");
358 AddVarF(output(), FragmentsDistanceToShower,
"Distance of the fragment ecal shower to electron shower");
359 AddVarI(output(), NTPCTracksReqEcal,
"Number of TPC-Ecal tracks");
365 void nueCCAnalysis::FillMicroTrees(
bool addBase){
369 if (addBase) baseTrackerAnalysis::FillMicroTreesBase(addBase);
371 if (!box().MainTrack)
return;
378 FillPairFinderVars();
382 if(_savesecondaries){
384 FillEcalNeutralClusterVars();
390 void nueCCAnalysis::FillTruthVars() {
402 output().FillVar(selelec_true_pdg, truth->
PDG);
403 output().FillVar(selelec_true_mom, truth->
Momentum);
404 output().FillVectorVarFromArray(selelec_true_pos, truth->
Position, 4);
405 output().FillVectorVarFromArray(selelec_true_endpos, truth->
PositionEnd, 4);
406 output().FillVectorVarFromArray(selelec_true_dir, truth->
Direction, 3);
408 Float_t selelec_true_cosT_z = truth->
Direction[2];
409 output().FillVar(selelec_true_costheta_z, selelec_true_cosT_z);
412 Float_t _nd280_pos[3] = {-3.221999, -8.14599, 280.10};
414 Float_t selelec_true_cosT_offaxis = (Float_t)cos(anaUtils::ArrayToTVector3(truth->
Direction).Angle(_nd280_pos));
415 output().FillVar(selelec_true_costheta_offaxis, selelec_true_cosT_offaxis);
421 Float_t selelec_true_cosT_nuDir = (Float_t)cos(anaUtils::ArrayToTVector3(truth->
Direction).Angle(anaUtils::ArrayToTVector3(vtx->
NuDir)));
422 output().FillVar(selelec_true_costheta_nuDir, selelec_true_cosT_nuDir);
424 output().FillVar(NuParentPDGRaw, vtx->
NuParentPDG);
425 output().FillVar(TargetPDG, vtx->
TargetPDG);
426 output().FillVectorVarFromArray(NuParentDecPoint, vtx->
NuParentDecPoint, 4);
430 output().FillVar(truelepton_pdg, vtx->
LeptonPDG);
431 output().FillVar(truelepton_mom, vtx->
LeptonMom);
433 Float_t trueelec_true_cosT_z = anaUtils::ArrayToTLorentzVector(vtx->
LeptonDir).CosTheta();
434 output().FillVar(truelepton_costheta_z, trueelec_true_cosT_z);
436 Float_t trueelec_true_cosT_offaxis = (Float_t)cos( anaUtils::ArrayToTVector3(vtx->
LeptonDir).Angle(_nd280_pos) ) ;
437 output().FillVar(truelepton_costheta_offaxis, trueelec_true_cosT_offaxis);
439 Float_t trueelec_true_cosT_nuDir = (Float_t)cos( anaUtils::ArrayToTVector3(vtx->
LeptonDir).Angle(anaUtils::ArrayToTVector3(vtx->
NuDir) ) );
440 output().FillVar(truelepton_costheta_nuDir, trueelec_true_cosT_nuDir);
443 output().FillVar(truelepton_nuErecQE, Erec);
447 output().FillVectorVarFromArray(truelepton_dir, vtx->
LeptonDir,3);
448 output().FillVectorVarFromArray(truelepton_pos, vtx->
Position, 4);
451 output().FillVar(NTruePions, nue_categs::NpiC(*vtx));
452 output().FillVar(NTruePi0, nue_categs::Npi0(*vtx));
453 output().FillVar(NTrueKaonRhoEta, nue_categs::NKaonRhoEta(*vtx));
459 Init = GoBackToPrimaryParticle(box().MainTrack->GetTrueParticle(), vtx1);
462 output().FillVar(InitiatorPDG, (Int_t) Init->
PDG);
463 output().FillVar(InitiatorParentPDG, (Int_t) Init->
ParentPDG);
464 output().FillVar(InitiatorMom, (Float_t)Init->
Momentum);
465 output().FillVectorVarFromArray(InitiatorDir, Init->
Direction, 3);
472 output().FillVar(selelec_parent_true_mom, parent->
Momentum);
473 output().FillVar(selelec_parent_pdg, parent->
PDG);
477 output().FillVar(selelec_gparent_true_mom, gparent->
Momentum);
478 output().FillVar(selelec_gparent_pdg, gparent->
PDG);
484 if(ttruth == truth)
continue;
486 output().FillVar(TruePairTrack_true_mom, ttruth->
Momentum);
487 output().FillVar(TruePairTrack_pdg, ttruth->
PDG);
496 void nueCCAnalysis::FillTrackVars() {
503 output().FillVar(selelec_costheta_z, selelec_cosT_z);
506 Float_t _nd280_pos[3] = {-3.221999, -8.14599, 280.10};
508 Float_t selelec_cosT_offaxis = (Float_t)cos(anaUtils::ArrayToTVector3(track->
DirectionStart).Angle(_nd280_pos));
509 output().FillVar(selelec_costheta_offaxis, selelec_cosT_offaxis);
511 Float_t cosT = selelec_cosT_z;
512 Float_t phia = anaUtils::ArrayToTLorentzVector(track->
DirectionStart).Phi();
514 Float_t invpt = (track->
Momentum)*sqrt((1-cosT*cosT));
516 output().FillVar(selelec_phi, phia);
517 output().FillVar(selelec_pt, invpt);
518 output().FillVectorVarFromArray(selelec_startpos, track->
PositionStart, 4);
519 output().FillVectorVarFromArray(selelec_startdir, track->
DirectionStart, 4);
522 output().FillVar(selelec_momEleFit, track->
MomentumEle);
523 output().FillVar(selelec_momMuonFit, track->
MomentumMuon);
530 output().FillVar(selelec_ElemomTPCBack, backTpc->
MomentumEnd);
531 output().FillVectorVarFromArray(selelec_tpcBackPos, backTpc->
PositionEnd, 4);
532 output().FillVectorVarFromArray(selelec_tpcBackDir, track->
DirectionEnd, 3);
537 output().FillVar(selelec_tpcNNodes, TpcSegment->
NNodes);
546 void nueCCAnalysis::FillFirstTPCVars() {
549 if(!_addmoretoyvariables){
554 if(!longCloseTPC )
return;
556 output().FillVar(selelec_tpcdedx, longCloseTPC->
dEdxMeas);
565 void nueCCAnalysis::FillSecondTPCVars() {
568 if(!_addmoretoyvariables){
575 if(!longestTPC3)
return;
577 if(!cutUtils::TPCTrackQualityCut(*longestTPC3))
return;
585 void nueCCAnalysis::FillECalVars() {
594 if(nECAL >=1 && nueCCUtils::UseEcal(box().MainTrack) ){
598 if(!EcalSegment)
return;
601 Int_t detector = ECALdet;
604 output().FillVar(selelec_ElemomECalEntrance, backTPC->
Momentum);
606 if(!_addmoretoyvariables)
607 output().FillVar(selelec_ecalemene, EcalSegment->
EMEnergy);
609 output().FillVar(selelec_ecalmipem, EcalSegment->
PIDMipEm);
610 output().FillVar(selelec_ecalmippion, EcalSegment->PIDMipPion);
611 output().FillVar(selelec_ecalemhip, EcalSegment->PIDEmHip);
612 output().FillVectorVarFromArray(selelec_ecalshowerpos, EcalSegment->
ShowerPosition, 3 );
613 output().FillVar(selelec_ecallength,EcalSegment->
Length);
614 output().FillVar(selelec_ecalnhits, EcalSegment->
NHits);
616 output().FillVar(selelec_ecalcontained, nueCCUtils::IsEcalContained(EcalSegment));
617 output().FillVar(selelec_ecaldetector, detector);
620 output().FillVar(selelec_nECALs, nECAL);
624 void nueCCAnalysis::FillTPCVetoVars() {
627 if(!box().MainTrack)
return;
629 output().FillVar(TPCVetoNNearTracks, nuebox().TPCVetoNearTracks);
630 output().FillVar(TPCVetoNFarTracks, nuebox().TPCVetoFarTracks);
631 output().FillVar(TPCVetoNNearP0DTracks, nuebox().TPCVetoP0DNearTracks);
634 AnaTrackB* SecFGCTPCTrack = nuebox().SecondMostEnergeticFGDTPCTrack;
640 output().FillVar(SecMomFGDDeltaZ, DZ);
644 if(nuebox().OOFVtrack)
647 output().FillVar(FGDOOFVActivity, fgdoofv);
648 output().FillVar(NFGDOOFVTracksReqTPC, nuebox().NOOFVTracks);
651 AnaTrackB* VetoTrack = nuebox().VetoTrack;
652 if(!VetoTrack)
return;
656 Float_t deltaZ = vetoZ - hmnZstart;
659 Int_t charge = VetoTrack->
Charge;
661 output().FillVar(TPCVetoDeltaz, deltaZ);
662 output().FillVar(TPCVetoMomentum, mom);
663 output().FillVar(TPCVetoCharge, charge);
667 void nueCCAnalysis::FillPairFinderVars() {
674 AnaTrackB* pairtrack = nuebox().PairTrack;
675 if (!pairtrack )
return;
680 output().FillVar(PairTrack_mom, pairtrack->
Momentum);
681 output().FillVar(PairTrack_costheta, pairtrack->
DirectionStart[2]);
683 Float_t mass = 0.511;
684 TLorentzVector secondary_PE = nueCCUtils::GetMomLorentzVector(*pairtrack, mass);
685 TLorentzVector primary_PE = nueCCUtils::GetMomLorentzVector(*track, mass);
686 Float_t minv = 2. * mass * mass + 2. * (secondary_PE.Dot(primary_PE));
691 output().FillVar(PairTrack_InvMass, minv);
694 output().FillVectorVarFromArray(PairTrack_startdir, pairtrack->
DirectionStart, 4);
695 output().FillVectorVarFromArray(PairTrack_startpos, pairtrack->
PositionStart, 4);
699 output().FillVar(PairTrack_tpcNNodes, TpcSegment->
NNodes);
702 output().FillVectorVarFromArray(PairTrack_true_startdir, pair_truth->
Direction, 4);
703 output().FillVectorVarFromArray(PairTrack_true_startpos, pair_truth->
Position, 4);
704 output().FillVar(PairTrack_pdg, pair_truth->
PDG);
709 void nueCCAnalysis::FillP0DVetoVars() {
712 output().FillVar(NP0DVetoP0DTracks, nuebox().P0DVetoP0DTracks);
713 output().FillVar(NP0DVetoFGD1Tracks, nuebox().P0DVetoFGD1Tracks);
714 output().FillVar(NP0DVetoP0DEcalTracks, nuebox().P0DVetoP0DEcalTracks);
717 output().FillVar(FGD2ShowerNFGD1TPC2Tracks, nuebox().FGD2ShowerNFGD1TPC2Tracks);
718 output().FillVar(FGD2ShowerNFGD2TPC3Tracks, nuebox().FGD2ShowerNFGD2TPC3Tracks);
726 void nueCCAnalysis::FillECalVetoVars() {
730 AnaTrackB* ecal = nuebox().ECalVetoTrack;
732 if (!track || !ecal)
return;
746 output().FillVectorVarFromArray(ECALPosECALSegment, ecal_pos, 3);
750 output().FillVar(ECALMinZ, ecal_z - start_z);
754 output().FillVar(TPCECALdist, ecaldist);
756 output().FillVectorVarFromArray(ECALPosGlobalTrack, ecal->
PositionStart, 3);
762 AnaTrackB* ecalB = nuebox().ECalNCVetoTrack;
764 AnaECALParticleB* ecaltrackB = nueCCUtils::GetMostUpstreamECalNCSegment(ecalB);
771 output().FillVar(ECALNCMinZ, ecal_z - start_z);
778 void nueCCAnalysis::FillMichelVars() {
781 if(!box().MainTrack)
return;
792 if(det==SubDetId::kFGD2) fgd_nMichels =0;
798 output().FillVar(NME, fgd_nMichels);
802 void nueCCAnalysis::FillFGDVars() {
806 if (!HMTrack)
return;
808 for (Int_t subdet = 0; subdet<2; subdet++) {
811 if (!FGDSegment)
continue;
813 output().FillVectorVar(selelec_fgd_det, subdet);
814 output().FillVectorVar(selelec_fgd_x, FGDSegment->
X);
815 output().FillVectorVar(selelec_fgd_E, FGDSegment->
E);
816 output().FillVectorVar(selelec_fgd_V11, FGDSegment->
Vertex1x1);
817 output().FillVectorVar(selelec_fgd_V33, FGDSegment->Vertex3x3);
818 output().FillVectorVar(selelec_fgd_V55, FGDSegment->Vertex5x5);
819 output().FillVectorVar(selelec_fgd_V77, FGDSegment->Vertex7x7);
820 output().FillVectorVar(selelec_fgd_VLayer, FGDSegment->VertexLayer);
821 output().FillVectorVar(selelec_fgd_pullmu, FGDSegment->
Pullmu);
822 output().FillVectorVar(selelec_fgd_pullpi, FGDSegment->
Pullpi);
823 output().FillVectorVar(selelec_fgd_pullprot, FGDSegment->
Pullp);
824 output().FillVectorVar(selelec_fgd_containment, FGDSegment->
Containment);
826 output().IncrementCounterForVar(selelec_fgd_det);
831 void nueCCAnalysis::FillEcalNeutralClusterVars() {
834 if(!box().MainTrack)
return;
837 Float_t _thetacut = 15.0;
838 Float_t _phicut = 15.0;
839 Int_t _firstlayercut = 7;
840 Float_t _ecalfrag = 0.15;
841 Float_t _ecalfragdist = 400.0;
845 output().FillVar(NECalTracks, ntracks);
853 Int_t nDSEcalNC = 0, nBREcalNC = 0, nBremEcalNC = 0, nFragmentEcalNC = 0;
854 Float_t mostenenc = 0.0, allenenc = 0.0, neutclustenergy = 0.0, fragmentdist = 0.0;
855 Float_t mintheta = 10000.0, minphi = 10000.0;
857 Float_t track_theta = anaUtils::ArrayToTLorentzVector(box().MainTrack->DirectionStart).Theta()*180/3.14159;
858 Float_t track_phi = anaUtils::ArrayToTLorentzVector(box().MainTrack->DirectionStart).Phi()*180/3.14159;
862 Int_t ecaldetector = 0;
863 TVector3 showerposition;
865 Float_t emenergy = 0.0;
869 showerposition = anaUtils::ArrayToTVector3(EcalSegment->
ShowerPosition);
873 for (Int_t i=0; i<nDSEcal; i++) {
877 for(Int_t j=0; j<nseg; j++){
882 Float_t theta = anaUtils::ArrayToTVector3(ecaltrack->
DirectionStart).Theta()*180/3.14159;
883 Float_t phia = anaUtils::ArrayToTVector3(ecaltrack->
DirectionStart).Phi()*180/3.14159;
885 if(fabs(theta-track_theta) < mintheta)
886 mintheta = fabs(theta-track_theta);
887 if(fabs(phia-track_phi) < minphi)
888 minphi = fabs(phia-track_phi);
890 if(fabs(theta-track_theta) < _thetacut && fabs(phia-track_phi) < _phicut && ecaltrack->
MostUpStreamLayerHit < _firstlayercut){
892 neutclustenergy += ecaltrack->
EMEnergy;
896 TVector3 fragmentposition = anaUtils::ArrayToTVector3(ecaltrack->
ShowerPosition);
897 Float_t tempdist = (fragmentposition-showerposition).Mag();
898 if(tempdist > fragmentdist)
899 fragmentdist = tempdist;
901 if(tempdist < _ecalfragdist)
912 for (Int_t i=0; i<nBREcal; i++) {
916 for(Int_t j=0; j<nseg; j++){
921 Float_t theta = anaUtils::ArrayToTVector3(ecaltrack->
DirectionStart).Theta()*180/3.14159;
922 Float_t phia = anaUtils::ArrayToTVector3(ecaltrack->
DirectionStart).Phi()*180/3.14159;
924 if(fabs(theta-track_theta) < mintheta)
925 mintheta = fabs(theta-track_theta);
926 if(fabs(phia-track_phi) < minphi)
927 minphi = fabs(phia-track_phi);
929 if(fabs(theta-track_theta) < _thetacut && fabs(phia-track_phi) < _phicut && ecaltrack->
MostUpStreamLayerHit < _firstlayercut){
931 neutclustenergy += ecaltrack->
EMEnergy;
935 TVector3 fragmentposition = anaUtils::ArrayToTVector3(ecaltrack->
ShowerPosition);
936 Float_t tempdist = (fragmentposition-showerposition).Mag();
937 if(tempdist > fragmentdist)
938 fragmentdist = tempdist;
940 if(tempdist < _ecalfragdist)
951 output().FillVar(NDsEcalNeutralClusters, nDSEcalNC);
952 output().FillVar(NBrEcalNeutralClusters, nBREcalNC);
953 output().FillVar(MostEnergeticEcalNeutralCluster, mostenenc);
954 output().FillVar(EcalNeutralClusterEnergySum, allenenc);
955 output().FillVar(BremNeutralClusters, nBremEcalNC);
956 output().FillVar(BremNeutralClustersEnergy, neutclustenergy);
957 output().FillVar(BremNeutralClustersMinTheta, mintheta);
958 output().FillVar(BremNeutralClustersMinPhi, minphi);
959 output().FillVar(FragmentsNeutralClusters, nFragmentEcalNC);
960 output().FillVar(FragmentsDistanceToShower, fragmentdist);
964 for(Int_t i=0; i<ntracks; i++) {
967 if(track == box().MainTrack){
continue;}
971 if(EcalSegment->
EMEnergy > box().MainTrack->Momentum)
977 output().FillVar(EcalClusterMostEnergeticThanHMT, nfound);
982 void nueCCAnalysis::FillAllTracksVars() {
991 for(Int_t i=0; i<nFGDOnly; i++){
999 if (!FGDSegment)
continue;
1001 output().FillVectorVar(fgdiso_det, subdet);
1002 output().FillVectorVar(fgdiso_x, FGDSegment->
X);
1003 output().FillVectorVar(fgdiso_E, FGDSegment->
E);
1004 output().FillVectorVar(fgdiso_pullmu, FGDSegment->
Pullmu);
1005 output().FillVectorVar(fgdiso_pullpi, FGDSegment->
Pullpi);
1006 output().FillVectorVar(fgdiso_pullprot, FGDSegment->
Pullp);
1007 output().FillVectorVar(fgdiso_containment, FGDSegment->
Containment);
1008 output().FillMatrixVarFromArray(fgdiso_position, static_cast<AnaTrack*> (fgdonlytracks[i])->PositionStart, 4);
1009 Float_t cosT = anaUtils::ArrayToTLorentzVector(static_cast<AnaTrack*> (fgdonlytracks[i])->DirectionStart).CosTheta();
1010 output().FillVectorVar(fgdiso_costheta, cosT);
1011 if(static_cast<AnaTrueParticle*> (fgdonlytracks[i]->TrueObject))
1012 output().FillVectorVar(fgdiso_pdg, fgdonlytracks[i]->GetTrueParticle()->PDG);
1014 output().IncrementCounterForVar(fgdiso_det);
1021 Int_t nFGD1TPC1 = 0, nFGD1TPC2 = 0, nFGD1Ecal = 0;
1022 Int_t nFGD2TPC2 = 0, nFGD2TPC3 = 0, nFGD2Ecal = 0;
1023 Float_t xymaxdist = -10.0, xinit = -999.0, yinit = -999.0;
1024 for(Int_t i=0; i<nFGDs; i++) {
1025 if(fgdtpctracks[i] == track){
continue;}
1040 if(xinit == -999.0 && yinit == -999.0){
1045 Float_t temp = sqrt( (fgdtpctracks[i]->PositionStart[0] - xinit)*(fgdtpctracks[i]->PositionStart[0] - xinit) + (fgdtpctracks[i]->PositionStart[1] - yinit)*(fgdtpctracks[i]->PositionStart[1] - yinit));
1046 if(temp > xymaxdist)
1059 output().FillVar(NFGD1TracksReqTPC1, nFGD1TPC1);
1060 output().FillVar(NFGD1TracksReqTPC2, nFGD1TPC2);
1061 output().FillVar(NFGD1TracksReqEcal, nFGD1Ecal);
1062 output().FillVar(NFGD2TracksReqTPC2, nFGD2TPC2);
1063 output().FillVar(NFGD2TracksReqTPC3, nFGD2TPC3);
1064 output().FillVar(NFGD2TracksReqEcal, nFGD2Ecal);
1065 output().FillVar(FGD2XYMaxTrackDist, xymaxdist);
1071 for (Int_t i=0; i<ntpctracks; i++) {
1072 if(tpctracks[i] == track) {
continue;}
1083 Float_t cosT = anaUtils::ArrayToTLorentzVector(tpctracks[i]->DirectionStart).CosTheta();
1093 if(!longCloseTPC) {
continue;}
1095 output().FillVectorVar(FGDTPCTrack_det, tpcdet );
1100 output().FillVectorVar(FGDTPCTrack_tpcNNodes,longCloseTPC->
NNodes);
1102 output().FillVectorVar(FGDTPCTrack_mom, tpctracks[i]->Momentum);
1104 output().FillVectorVar(FGDTPCTrack_costheta, cosT);
1105 output().FillVectorVar(FGDTPCTrack_charge, tpctracks[i]->Charge);
1106 output().FillMatrixVarFromArray(FGDTPCTrack_startpos, tpctracks[i]->PositionStart, 4);
1107 output().FillMatrixVarFromArray(FGDTPCTrack_startdir, tpctracks[i]->DirectionStart, 3);
1111 output().FillVectorVar(FGDTPCTrack_pdg, truth->
PDG);
1123 output().FillVectorVar(FGDTPCTrack_MomECalEntrance, backTPC->
MomentumEnd);
1125 output().FillVectorVar(FGDTPCTrack_EMEnergy, EcalSegment->
EMEnergy);
1126 output().FillVectorVar(FGDTPCTrack_MipEm, EcalSegment->
PIDMipEm);
1127 output().FillVectorVar(FGDTPCTrack_MipPion, EcalSegment->PIDMipPion);
1128 output().FillVectorVar(FGDTPCTrack_EmHip, EcalSegment->PIDEmHip);
1129 output().FillMatrixVarFromArray(FGDTPCTrack_ShowerPosition, EcalSegment->
ShowerPosition, 3 );
1130 output().FillVectorVar(FGDTPCTrack_ECALdet, ECALdet);
1131 output().FillVectorVar(FGDTPCTrack_NHits, EcalSegment->
NHits);
1133 output().FillVectorVar(FGDTPCTrack_IsEcalContained, nueCCUtils::IsEcalContained(EcalSegment));
1136 output().IncrementCounterForVar(FGDTPCTrack_det);
1139 output().FillVar(NTPCTracksReqEcal, nTPCECAL);
1150 Float_t min_reqtpc = 1e6, max_reqtpc = -1e6;
1151 Float_t min = 1e6, max = -1e6;
1153 for (Int_t i=0; i<nFGD; i++) {
1154 if(fgdtracks[i] == track) {
continue;}
1156 Float_t diff = (anaUtils::ArrayToTVector3(track->
PositionStart) - anaUtils::ArrayToTVector3(fgdtracks[i]->PositionStart)).Mag();
1157 min = std::min(min, diff);
1158 max = std::max(max, diff);
1162 min_reqtpc = std::min(min_reqtpc, diff);
1163 max_reqtpc = std::max(max_reqtpc, diff);
1167 output().FillVar(NFGDTracksReqTPC, nFGDTPC);
1168 output().FillVar(FGDDistanceReqTpc, min_reqtpc);
1169 output().FillVar(FGDDistanceNoReqTpc, min);
1170 output().FillVar(FGDMaxDistanceReqTpc, max_reqtpc);
1171 output().FillVar(FGDMaxDistanceNoReqTpc, max);
1175 void nueCCAnalysis::FillToFVars() {
1179 if (!track )
return;
1182 if( track->
ToF.Flag_P0D_FGD1 )
1183 output().FillVar(selelec_ToF_P0D_FGD1, track->
ToF.P0D_FGD1);
1184 else if(track->
ToF.Flag_ECal_FGD1)
1185 output().FillVar(selelec_ToF_ECal_FGD1, track->
ToF.ECal_FGD1);
1186 else if( track->
ToF.Flag_FGD1_FGD2 )
1187 output().FillVar(selelec_ToF_FGD1_FGD2, track->
ToF.FGD1_FGD2);
1190 if(track->
ToF.Flag_ECal_FGD2)
1191 output().FillVar(selelec_ToF_ECal_FGD2, track->
ToF.ECal_FGD2);
1192 else if( track->
ToF.Flag_FGD1_FGD2 )
1193 output().FillVar(selelec_ToF_FGD1_FGD2, track->
ToF.FGD1_FGD2);
1196 #if VERSION_HAS_TIME_FITS 1199 if (!atrack )
return;
1200 bool fgd1 =
false, fgd2 =
false, ecal =
false;
1201 Float_t tfgd1 = 0, tfgd2 = 0, tdsecal = 0;
1202 std::vector<AnaTimeNode*> timenodes = atrack->TimeNodes;
1203 for (
unsigned int i=0;i<timenodes.size();i++){
1209 if(!fgd1) tfgd1 = t;
1213 if(!fgd2) tfgd2 = t;
1217 if(!ecal) tdsecal = t;
1223 output().FillVar(selelec_ToF_DsECal_FGD1, tdsecal-tfgd1);
1224 else if(fgd2 && ecal)
1225 output().FillVar(selelec_ToF_DsECal_FGD2, tdsecal-tfgd2);
1231 void nueCCAnalysis::FillToyVarsInMicroTrees(
bool addBase){
1234 if(addBase) baseTrackerAnalysis::FillToyVarsInMicroTreesBase(addBase);
1236 if(box().MainTrack){
1237 output().FillToyVar(selelec_mom, box().MainTrack->Momentum);
1241 TVector3 nuDirVec = anaUtils::GetNuDirRec(box().MainTrack->PositionStart);
1242 TVector3 elDirVec = anaUtils::ArrayToTVector3(box().MainTrack->DirectionStart);
1244 double costheta_el_nu = nuDirVec.Dot(elDirVec);
1245 output().FillToyVar(selelec_costheta, (Float_t)costheta_el_nu);
1249 output().FillToyVar(selelec_ENuRec, Erec);
1250 Float_t Q2 =
anaUtils::ComputeQ2(box().MainTrack->Momentum, units::mass_electron, costheta_el_nu, Erec);
1251 output().FillToyVar(selelec_Q2Rec, Q2);
1253 if(_addmoretoyvariables){
1257 output().FillToyVar(selelec_tpcdedx, longCloseTPC->
dEdxMeas);
1268 if(longestTPC3 && cutUtils::TPCTrackQualityCut(*longestTPC3)){
1278 if(nECAL >=1 && nueCCUtils::UseEcal(box().MainTrack) ){
1282 output().FillToyVar(selelec_ecalemene, EcalSegment->
EMEnergy);
1287 if(box().MainTrack->TrueObject) {
1292 output().FillToyVar(truevtx_mass_component, massComponent);
1294 bool AntiNu =
false;
1296 if (nue_categs::IsNuESignal(*vtx, SubDetId::kFGD1, AntiNu))
1297 output().FillToyVar(true_signal, 1);
1298 else if (nue_categs::IsNuESignal(*vtx, SubDetId::kFGD2, AntiNu))
1299 output().FillToyVar(true_signal, 2);
1301 output().FillToyVar(true_signal, 0);
1311 bool nueCCAnalysis::CheckFillTruthTree(
const AnaTrueVertex& vtx){
1315 if (_whichFGD == 1) fgdID = SubDetId::kFGD1;
1316 if (_whichFGD == 2) fgdID = SubDetId::kFGD2;
1317 if (_whichFGD > 2) fgdID = SubDetId::kFGD;
1319 bool AntiNu =
false;
1320 return (nue_categs::IsNuESignal(vtx, fgdID, AntiNu) ||
1321 nue_categs::ThereWasGammaInFGD(static_cast<const AnaTrueVertexB&> (vtx)));
1325 void nueCCAnalysis::FillTruthTree(
const AnaTrueVertex& vtx){
1328 bool AntiNu =
false;
1329 return FillTruthTreeBase(vtx, AntiNu);
1333 void nueCCAnalysis::FillTruthTreeBase(
const AnaTrueVertex& vtx,
bool IsAntinu){
1338 baseTrackerAnalysis::FillTruthTreeBase(vtx, SubDetId::kFGD1, IsAntinu);
1341 output().FillVectorVarFromArray(truelepton_pos, vtx.
Position, 4);
1344 Float_t trueelec_true_cosT_z = anaUtils::ArrayToTLorentzVector(vtx.
LeptonDir).CosTheta();
1345 output().FillVar(truelepton_costheta_z, trueelec_true_cosT_z);
1348 Float_t _nd280_pos[3] = {-3.221999, -8.14599, 280.10};
1350 Float_t trueelec_true_cosT_offaxis = (Float_t)cos( anaUtils::ArrayToTVector3(vtx.
LeptonDir).Angle(_nd280_pos) ) ;
1351 output().FillVar(truelepton_costheta_offaxis, trueelec_true_cosT_offaxis);
1353 Float_t trueelec_true_cosT_nuDir = (Float_t)cos( anaUtils::ArrayToTVector3(vtx.
LeptonDir).Angle(anaUtils::ArrayToTVector3(vtx.
NuDir) ) );
1354 output().FillVar(truelepton_costheta_nuDir, trueelec_true_cosT_nuDir);
1357 if (nue_categs::IsNuESignal(vtx, SubDetId::kFGD1, IsAntinu))
1358 output().FillVar(true_signal, 1);
1359 else if (nue_categs::IsNuESignal(vtx, SubDetId::kFGD2, IsAntinu))
1360 output().FillVar(true_signal, 2);
1362 output().FillVar(true_signal, 0);
1366 output().FillVar(truevtx_mass_component, massComponent);
1382 Float_t selelec_true_cosT_nuDir = (Float_t)cos(anaUtils::ArrayToTVector3(Main->
Direction).Angle(anaUtils::ArrayToTVector3(vtx.
NuDir)));
1387 Init = GoBackToPrimaryParticle(Main, vtx1);
1390 output().FillVar(InitiatorPDG, (Int_t) Init->
PDG);
1391 output().FillVar(InitiatorParentPDG, (Int_t) Init->
ParentPDG);
1392 output().FillVar(InitiatorMom, (Float_t)Init->
Momentum);
1393 output().FillVectorVarFromArray(InitiatorDir, Init->
Direction, 3);
1399 void nueCCAnalysis::FillCategories(){
1402 bool IsAntinu =
false;
1407 nue_categs::FillCategories(&GetEvent(), box().MainTrack,
"", SubDetId::kFGD1, IsAntinu);
1408 nue_categs::FillCategories(&GetEvent(), box().MainTrack,
"fgd2", SubDetId::kFGD2, IsAntinu);
1412 void nueCCAnalysis::FillConfigTree(){
1417 AddVarD(output(), nNucleonsFGD1,
"number of targets in FGD1");
1418 AddVarD(output(), nNucleonsFGD2scint,
"number of targets in FGD2 scintillator");
1419 AddVarD(output(), nNucleonsFGD2water,
"number of targets in FGD2 water");
1421 output().FillVar(nNucleonsFGD1, anaUtils::GetNTargets(anaUtils::kFGD1));
1422 output().FillVar(nNucleonsFGD2scint, anaUtils::GetNTargets(anaUtils::kFGD2xymodules));
1423 output().FillVar(nNucleonsFGD2water, anaUtils::GetNTargets(anaUtils::kFGD2watermodules));
1443 std::vector<AnaTrueParticleB*> EMParticle;
1444 std::vector<AnaTrueParticleB*> Pi0;
1445 std::vector<AnaTrueParticleB*> PiPM;
1451 EMParticle.reserve(200);
1456 for(
int i = 0; i < imax; i++){
1460 if(!trueTrack)
continue;
1462 if(trueTrack->
PDG == 111) Pi0.push_back(trueTrack);
1463 if(abs(trueTrack->
PDG) == 211) PiPM.push_back(trueTrack);
1465 if(trueTrack->
PDG == 22 || abs(trueTrack->
PDG) == 11){
1466 EMParticle.push_back(trueTrack);
1477 while(abs(ParentPDG) == 11 || ParentPDG == 22){
1480 while(i < vtx->nTrueParticles){
1487 if(ParentID == trueTrack->
ID){
1488 gammaID = trueTrack->
ID;
1508 if(!trueTrack)
continue;
1509 if(trueTrack->
ID == ParentID)
return trueTrack;
Float_t dEdxexpMuon
Expected dE/dx for a muon, based on the reconstructed momentum.
int GetAllTracksUsingECAL(const AnaEventB &event, AnaTrackB *selTracks[])
AnaTrueVertexB * TrueVertex
Pointer to the AnaTrueVertexB of the interaction that created this AnaTrueParticleB.
Float_t PositionStart[4]
The reconstructed start position of the particle.
int GetAllTracksUsingOnlyDet(const AnaBunchB &bunch, SubDetId::SubDetEnum det, AnaTrackB *selTracks[])
Representation of a global track.
Int_t LeptonPDG
The PDG code of the primary outgoing electron/muon.
int GetParameterI(std::string)
Get parameter. Value is returned as integer.
Float_t MomentumEle
Momentum from refitting the track assuming the electron hypothesis.
int nTrueParticles
How many true particles are associated with this vertex.
int GetFGDMichelElectrons(const AnaEventB &event, const SubDetId::SubDetEnum det, AnaFgdTimeBinB **arr, bool prod5Cut=0)
Get all delayed time bins as Michel Electron candidates.
Float_t dEdxexpProton
Expected dE/dx for a proton, based on the reconstructed momentum.
Int_t NuParentPDG
Neutrino parent PDG code.
AnaECALParticleB * ECALSegments[NMAXECALS]
The ECAL segments that contributed to this global track.
int nECALSegments
How many ECAL tracks are associated with this track.
Float_t LeptonDir[3]
The direction of the primary outgoing electron/muon.
Float_t ComputeQ2(Float_t mom_lepton, Float_t mass_lepton, Float_t costheta_lepton, Float_t energy_neutrino)
Float_t Pullp
Proton pull, according to FGD information.
void AddCorrection(Int_t index, const std::string &name, CorrectionBase *corr)
Float_t NuParentDecPoint[4]
Decay point of the neutrino parent.
Float_t DirectionEnd[3]
The reconstructed end direction of the particle.
void AddPackage(const std::string &name, const std::string &version)
Add a package.
Float_t E
Input to the pull calculations. Needs to be documented properly in oaAnalysis.
Int_t NNodes
The number of nodes in the reconstructed object.
Representation of an ECAL segment of a global track.
Float_t Pullpi
Pion pull, according to FGD information.
Float_t Vertex1x1
Vertex activity variables.
Float_t dEdxSigmaProton
Expected error on the dE/dx measurement, for the proton hypothesis.
Float_t ComputeRecNuEnergyCCQE(Float_t mom_lepton, Float_t mass_lepton, Float_t costheta_lepton, Float_t bindingEnergy=25.)
AnaTrueObjectC * TrueObject
The link to the true oject that most likely generated this reconstructed object.
AnaToF ToF
Times of flight between pairs of detectors.
static bool GetDetectorUsed(unsigned long BitField, SubDetId::SubDetEnum det)
Method to see if a certain subdetector or subdetector system is used.
massComponentEnum GetMassComponent(bool IsMC, const Float_t *pos)
Get the detector component in which the position is.
Float_t Momentum
The initial momentum of the true particle.
AnaTrueParticleB ** TrueParticles
The true particles associated with this vertex.
SubDetId::SubDetEnum GetDetector(const Float_t *pos)
Return the detector in which the position is.
AnaParticleB * GetSegmentInDet(const AnaTrackB &track, SubDetId::SubDetEnum det)
Int_t TargetPDG
The PDG code of the target nucleus.
bool TrackUsesDet(const AnaTrackB &track, SubDetId::SubDetEnum det)
Float_t dEdxexpPion
Expected dE/dx for a pion, based on the reconstructed momentum.
Float_t dEdxexpEle
Expected dE/dx for an electron, based on the reconstructed momentum.
Float_t Pullmu
Muon pull, according to FGD information.
Float_t Charge
The reconstructed charge of the particle.
Int_t ID
The ID of the trueObj, which corresponds to the ID of the TTruthParticle that created it...
AnaECALParticleB * GetMostUpstreamECalSegment(AnaTrackB *track)
std::string GetSoftwareVersionFromPath(const std::string &path)
Get The software version from the path of the package.
Representation of detector time info.
Float_t ShowerPosition[3]
The position of the shower-fit to this object by ecalRecon.
Float_t LeptonMom
The momentum of the primary outgoing electron/muon.
Float_t Momentum
The reconstructed momentum of the particle, at the start position.
Representation of a true Monte Carlo vertex.
int nTPCSegments
How many TPC tracks are associated with this track.
Representation of a true Monte Carlo trajectory/particle.
Float_t NuEnergy
The true energy of the incoming neutrino.
const AnaParticleB * Original
bool Initialize()
[AnalysisAlgorithm_mandatory]
Float_t Position[4]
The position the true interaction happened at.
Float_t dEdxSigmaEle
Expected error on the dE/dx measurement, for the electron hypothesis.
SubDetEnum
Enumeration of all detector systems and subdetectors.
Int_t PDG
The PDG code of this particle.
Int_t NHits
The number of hits in the particle.
Int_t ParentPDG
The PDG code of this particle's immediate parent, or 0 if there is no parent.
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.
Representation of a global track.
static SubDetId::SubDetEnum GetSubdetectorEnum(unsigned long BitField)
Get the single subdetector that this track is from.
Float_t MomentumEnd
The reconstructed momentum of the particle, at the end position.
virtual bool Initialize()
[AnalysisAlgorithm_mandatory]
Representation of a TPC segment of a global track.
bool InDetVolume(SubDetId::SubDetEnum det, const Float_t *pos)
Float_t Length
The length of the ECal segment.
Float_t MomentumError
The error on the reconstructed momentum.
Float_t DirectionStart[3]
The reconstructed start direction of the particle.
void AddSelection(const std::string &name, const std::string &title, SelectionBase *sel, Int_t presel=-1)
Add a user selection to the selection manager.
AnaTrueParticleB * GetTrueParticleByID(const AnaEventB &event, int ID)
Get the AnaTrueParticleB in the current spill with the given ID. Return NULL if it can't be found...
int nFGDSegments
How many FGD tracks are associated with this track.
Float_t dEdxSigmaMuon
Expected error on the dE/dx measurement, for the muon hypothesis.
Int_t ParentID
The ID of this particle's immediate parent, or 0 if there is no parent.
Float_t PositionEnd[4]
The end position of the true particle.
AnaTPCParticleB * GetTPCBackSegment(const AnaTrackB *track)
Get the most dowstream TPC segment of the track.
void AddStandardCategories(const std::string &prefix="")
Add the standard categories only, given a prefix for their name.
Float_t Position[4]
The initial position of the true particle.
Int_t Containment
Containment flag required for proper PID analysis.
Int_t MostUpStreamLayerHit
Innermost layer hit of the ecal object (used in ecal pi0 veto)
Representation of a TPC segment of a global track.
Float_t TimeStart
Start time.
AnaParticleB * GetSegmentWithMostNodesInClosestTpc(const AnaTrackB &track)
Combined function to address NuMu selection needs as efficiently as possible - gets the TPC segment w...
Float_t NuDir[3]
The true (unit) direction of the incoming neutrino.
Float_t dEdxSigmaPion
Expected error on the dE/dx measurement, for the pion hypothesis.
int GetAllTracksUsingDet(const AnaBunchB &bunch, SubDetId::SubDetEnum det, AnaTrackB *selTracks[])
AnaTrueParticleB * GetTrueParticle() const
Return a casted version of the AnaTrueObject associated.
AnaParticleB * GetSegmentWithMostNodesInDet(const AnaTrackB &track, SubDetId::SubDetEnum det)
Method to get the subtrack with most nodes in a given detector.
Representation of a reconstructed particle (track or shower).
Float_t Direction[3]
The initial direction of the true particle.
Representation of a true Monte Carlo trajectory/particle.
Float_t MomentumMuon
Momentum from refitting the track assuming the muon hypothesis.
int GetTrackerDsEcals(AnaTrackB *track, AnaECALParticleB *selTracks[])
Float_t PositionEnd[4]
The reconstructed end position of the particle.