13 #ifndef NeutrinoTrackingEff_Module 14 #define NeutrinoTrackingEff_Module 45 #include "TDirectory.h" 47 #include "TEfficiency.h" 48 #include "TGraphAsymmErrors.h" 53 #define MAX_TRACKS 1000 73 void processEff(
const art::Event& evt,
bool &isFiducial);
76 bool insideFV(
double vertex[4]);
77 void doEfficiencies();
92 double MC_incoming_P[4];
94 double MC_lepton_startMomentum[4];
145 TEfficiency* h_Eff_Ev = 0;
146 TEfficiency* h_Eff_Pmu = 0;
147 TEfficiency* h_Eff_theta = 0;
148 TEfficiency* h_Eff_Pproton = 0;
149 TEfficiency* h_Eff_Ppion_plus = 0;
150 TEfficiency* h_Eff_Ppion_minus = 0;
152 TEfficiency* h_Eff_Lmuon = 0;
153 TEfficiency* h_Eff_Lproton = 0;
154 TEfficiency* h_Eff_Lpion_plus = 0;
155 TEfficiency* h_Eff_Lpion_minus = 0;
173 TEfficiency* h_Eff_Pkaon =0;
174 TEfficiency* h_Eff_Pmichel =0;
175 TEfficiency* h_Eff_Lkaon = 0;
176 TEfficiency* h_Eff_Lmichel =0;
201 : EDAnalyzer(parameterSet)
212 fMCTruthModuleLabel = p.
get<std::string>(
"MCTruthModuleLabel");
213 fTrackModuleLabel = p.
get<std::string>(
"TrackModuleLabel");
214 fisNeutrinoInt = p.
get<
bool>(
"isNeutrinoInt");
215 fLeptonPDGcode = p.
get<
int>(
"LeptonPDGcode");
216 fNeutrinoPDGcode = p.
get<
int>(
"NeutrinoPDGcode");
217 fMaxNeutrinoE = p.
get<
double>(
"MaxNeutrinoE");
218 fMaxLeptonP = p.
get<
double>(
"MaxLeptonP");
219 fFidVolCutX = p.
get<
float>(
"FidVolCutX");
220 fFidVolCutY = p.
get<
float>(
"FidVolCutY");
221 fFidVolCutZ = p.
get<
float>(
"FidVolCutZ");
225 std::cout<<
"job begin..."<<std::endl;
227 auto const*
geo = lar::providerFrom<geo::Geometry>();
236 for (
size_t i = 0; i<
geo->NTPC(); ++i){
237 double local[3] = {0.,0.,0.};
238 double world[3] = {0.,0.,0.};
241 if (minx>world[0]-
geo->DetHalfWidth(i))
242 minx = world[0]-
geo->DetHalfWidth(i);
243 if (maxx<world[0]+
geo->DetHalfWidth(i))
244 maxx = world[0]+
geo->DetHalfWidth(i);
245 if (miny>world[1]-
geo->DetHalfHeight(i))
246 miny = world[1]-
geo->DetHalfHeight(i);
247 if (maxy<world[1]+
geo->DetHalfHeight(i))
248 maxy = world[1]+
geo->DetHalfHeight(i);
249 if (minz>world[2]-
geo->DetLength(i)/2.)
250 minz = world[2]-
geo->DetLength(i)/2.;
251 if (maxz<world[2]+
geo->DetLength(i)/2.)
252 maxz = world[2]+
geo->DetLength(i)/2.;
262 std::cout<<
"Fiducial volume:"<<
"\n" 263 <<fFidVolXmin<<
"\t< x <\t"<<fFidVolXmax<<
"\n" 264 <<fFidVolYmin<<
"\t< y <\t"<<fFidVolYmax<<
"\n" 265 <<fFidVolZmin<<
"\t< z <\t"<<fFidVolZmax<<
"\n";
269 double E_bins[21] ={0,0.5,1.0,1.5,2.0,2.5,3.0,3.5,4,4.5,5.0,5.5,6.0,7.0,8.0,10.0,12.0,14.0,17.0,20.0,25.0};
270 double theta_bin[44]= { 0.,1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.,17.,18.,19.,20.,22.,24.,26.,28.,30.,32.,34.,36.,38.,40.,42.,44.,46.,48.,50.,55.,60.,65.,70.,75.,80.,85.,90.};
271 double Pbins[18] ={0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.2,1.4,1.6,1.8,2.0,2.5,3.0};
273 for (
int i = 0; i<21; ++i) E_bins[i] *= fMaxNeutrinoE/25.;
274 for (
int i = 0; i<18; ++i) Pbins[i] *= fMaxLeptonP/3.0;
276 h_Ev_den = tfs->
make<TH1D>(
"h_Ev_den",
"Neutrino Energy; Neutrino Energy (GeV); Tracking Efficiency",20,E_bins);
277 h_Ev_num = tfs->
make<TH1D>(
"h_Ev_num",
"Neutrino Energy; Neutrino Energy (GeV); Tracking Efficiency",20,E_bins);
278 h_Pmu_den = tfs->
make<TH1D>(
"h_Pmu_den",
"Muon Momentum; Muon Momentum (GeV); Tracking Efficiency",20,E_bins);
279 h_Pmu_num = tfs->
make<TH1D>(
"h_Pmu_num",
"Muon Momentum; Muon Momentum (GeV); Tracking Efficiency",20,E_bins);
280 h_theta_den = tfs->
make<TH1D>(
"h_theta_den",
"Theta; Theta w.r.t beam direction (Degrees); Tracking Efficiency",43,theta_bin);
281 h_theta_num = tfs->
make<TH1D>(
"h_theta_num",
"Theta; Theta w.r.t beam direction (Degrees); Tracking Efficiency",43,theta_bin);
282 h_Pproton_den = tfs->
make<TH1D>(
"h_Pproton_den",
"Protons; Proton Momentum (GeV); Tracking Efficiency", 17, Pbins);
283 h_Pproton_num = tfs->
make<TH1D>(
"h_Pproton_num",
"Protons; Proton Momentum (GeV); Tracking Efficiency", 17, Pbins);
284 h_Ppion_plus_den = tfs->
make<TH1D>(
"h_Ppion_plus_den",
"Pions Plus; Pion Momentum (GeV); Tracking Efficiency", 17, Pbins);
285 h_Ppion_plus_num = tfs->
make<TH1D>(
"h_Ppion_plus_num",
"Pions Plus; Pion Momentum (GeV); Tracking Efficiency", 17, Pbins);
286 h_Ppion_minus_den = tfs->
make<TH1D>(
"h_Ppion_minus_den",
"Pions Minus; Pion Momentum (GeV); Tracking Efficiency", 17, Pbins);
287 h_Ppion_minus_num = tfs->
make<TH1D>(
"h_Ppion_minus_num",
"Pions Minus; Pion Momentum (GeV); Tracking Efficiency", 17, Pbins);
292 h_theta_den->Sumw2();
293 h_theta_num->Sumw2();
294 h_Pproton_den->Sumw2();
295 h_Pproton_num->Sumw2();
296 h_Ppion_plus_den->Sumw2();
297 h_Ppion_plus_num->Sumw2();
298 h_Ppion_minus_den->Sumw2();
299 h_Ppion_minus_num->Sumw2();
301 h_Efrac_lepton = tfs->
make<TH1D>(
"h_Efrac_lepton",
"Efrac Lepton; Track Purity;",60,0,1.2);
302 h_Ecomplet_lepton = tfs->
make<TH1D>(
"h_Ecomplet_lepton",
"Ecomplet Lepton; Track Completeness;",60,0,1.2);
303 h_Efrac_proton = tfs->
make<TH1D>(
"h_Efrac_proton",
"Efrac Proton; Track Purity;",60,0,1.2);
304 h_Ecomplet_proton = tfs->
make<TH1D>(
"h_Ecomplet_proton",
"Ecomplet Proton; Track Completeness;",60,0,1.2);
305 h_Efrac_pion_plus = tfs->
make<TH1D>(
"h_Efrac_pion_plus",
"Efrac Pion +; Track Purity;",60,0,1.2);
306 h_Ecomplet_pion_plus = tfs->
make<TH1D>(
"h_Ecomplet_pion_plus",
"Ecomplet Pion +; Track Completeness;",60,0,1.2);
307 h_Efrac_pion_minus = tfs->
make<TH1D>(
"h_Efrac_pion_minus",
"Efrac Pion -; Track Purity;",60,0,1.2);
308 h_Ecomplet_pion_minus = tfs->
make<TH1D>(
"h_Ecomplet_pion_minus",
"Ecomplet Pion -; Track Completeness;",60,0,1.2);
309 h_trackRes_lepton = tfs->
make<TH1D>(
"h_trackRes_lepton",
"Muon Residual; Truth length - Reco length (cm);",200,-100,100);
310 h_trackRes_proton = tfs->
make<TH1D>(
"h_trackRes_proton",
"Proton Residual; Truth length - Reco length (cm);",200,-100,100);
311 h_trackRes_pion_plus = tfs->
make<TH1D>(
"h_trackRes_pion_plus",
"Pion + Residual; Truth length - Reco length (cm);",200,-100,100);
312 h_trackRes_pion_minus = tfs->
make<TH1D>(
"h_trackRes_pion_minus",
"Pion - Residual; Truth length - Reco length (cm);",200,-100,100);
313 h_Efrac_lepton->Sumw2();
314 h_Ecomplet_lepton->Sumw2();
315 h_Efrac_proton->Sumw2();
316 h_Ecomplet_proton->Sumw2();
317 h_Efrac_pion_plus->Sumw2();
318 h_Ecomplet_pion_plus->Sumw2();
319 h_Efrac_pion_minus->Sumw2();
320 h_Ecomplet_pion_minus->Sumw2();
321 h_trackRes_lepton->Sumw2();
322 h_trackRes_proton->Sumw2();
323 h_trackRes_pion_plus->Sumw2();
324 h_trackRes_pion_minus->Sumw2();
326 h_muon_length = tfs->
make<TH1D>(
"h_muon_length",
"Muon Length; Muon Truth Length (cm)",40,0,100);
327 h_proton_length = tfs->
make<TH1D>(
"h_proton_length",
"Proton Length; Proton Truth Length (cm)",40,0,100);
328 h_pionp_length = tfs->
make<TH1D>(
"h_pionp_length",
"Pion + Length; Pion^{+} Truth Length (cm)",40,0,100);
329 h_pionm_length = tfs->
make<TH1D>(
"h_pionm_length",
"Pion - Length; Pion^{-} Truth Length (cm)",40,0,100);
331 h_muonwtrk_length = tfs->
make<TH1D>(
"h_muonwtrk_length",
"Muon Length; Muon Truth Length (cm)",40,0,100);
332 h_protonwtrk_length = tfs->
make<TH1D>(
"h_protonwtrk_length",
"Proton Length; Proton Truth Length (cm)",40,0,100);
333 h_pionpwtrk_length = tfs->
make<TH1D>(
"h_pionpwtrk_length",
"Pion + Length; Pion^{+} Truth Length (cm)",40,0,100);
334 h_pionmwtrk_length = tfs->
make<TH1D>(
"h_pionmwtrk_length",
"Pion - Length; Pion^{-} Truth Length (cm)",40,0,100);
336 h_muon_length->Sumw2();
337 h_muonwtrk_length->Sumw2();
338 h_proton_length->Sumw2();
339 h_protonwtrk_length->Sumw2();
340 h_pionp_length->Sumw2();
341 h_pionpwtrk_length->Sumw2();
342 h_pionm_length->Sumw2();
343 h_pionmwtrk_length->Sumw2();
345 h_Pkaon_den = tfs->
make<TH1D>(
"h_Pkaon_den",
"Kaon; Kaon Momentum (GeV); Tracking Efficiency", 17, Pbins);
346 h_Pkaon_num = tfs->
make<TH1D>(
"h_Pkaon_num",
"Kaon; Kaon Momentum (GeV); Tracking Efficiency", 17, Pbins);
347 h_Pmichel_e_den = tfs->
make<TH1D>(
"h_Pmichel_e_den",
"Michel Electron; Michele e Momentum (GeV); Tracking Efficiency", 17, Pbins);
348 h_Pmichel_e_num = tfs->
make<TH1D>(
"h_Pmichel_e_num",
"Michel Electron; Michele e Momentum (GeV); Tracking Efficiency", 17, Pbins);
349 h_Pkaon_den->Sumw2();
350 h_Pkaon_num->Sumw2();
351 h_Pmichel_e_den->Sumw2();
352 h_Pmichel_e_num->Sumw2();
353 h_Efrac_kaon = tfs->
make<TH1D>(
"h_Efrac_kaon",
"Efrac Kaon; Track Purity;",60,0,1.2);
354 h_Ecomplet_kaon = tfs->
make<TH1D>(
"h_Ecomplet_kaon",
"Ecomplet Kaon; Track Completeness;",60,0,1.2);
355 h_trackRes_kaon = tfs->
make<TH1D>(
"h_trackRes_kaon",
"Kaon Residual; Truth length - Reco length (cm);",200,-100,100);
356 h_Efrac_michel = tfs->
make<TH1D>(
"h_Efrac_michel",
"Efrac Michel; Track Energy fraction;",60,0,1.2);
357 h_Ecomplet_michel = tfs->
make<TH1D>(
"h_Ecomplet_michel",
"Ecomplet Michel; Track Completeness;",60,0,1.2);
358 h_trackRes_michel = tfs->
make<TH1D>(
"h_trackRes_michel",
"Michel Residual; Truth length - Reco length (cm);",200,-100,100);
359 h_kaon_length = tfs->
make<TH1D>(
"h_kaon_length",
"Kaon Length; Kaon Truth Length (cm)",40,0,100);
360 h_kaonwtrk_length = tfs->
make<TH1D>(
"h_kaonwtrk_length",
"Kaon Length; Kaon Truth Length (cm)",40,0,100);
361 h_michel_length = tfs->
make<TH1D>(
"h_michel_length",
"Michel Length; Michel e Truth Length (cm)",40,0,100);
362 h_michelwtrk_length = tfs->
make<TH1D>(
"h_michelwtrk_length",
"Michel Length; Michel e Truth Length (cm)",40,0,100);
364 h_Efrac_kaon->Sumw2();
365 h_Ecomplet_kaon->Sumw2();
366 h_trackRes_kaon->Sumw2();
367 h_Efrac_michel->Sumw2();
368 h_Ecomplet_michel->Sumw2();
369 h_trackRes_michel->Sumw2();
370 h_kaon_length->Sumw2();
371 h_kaonwtrk_length->Sumw2();
372 h_michel_length->Sumw2();
373 h_michelwtrk_length->Sumw2();
384 mf::LogInfo(
"NeutrinoTrackingEff")<<
"begin run..."<<std::endl;
390 bool isFiducial =
false;
398 event.getByLabel(fMCTruthModuleLabel, MCtruthHandle);
399 std::vector<art::Ptr<simb::MCTruth>> MCtruthlist;
404 MCtruth = MCtruthlist[0];
407 if( nu.
CCNC() == 0 ) MC_isCC = 1;
408 else if ( nu.
CCNC() == 1 ) MC_isCC = 0;
411 const TLorentzVector& nu_momentum = nu.
Nu().
Momentum(0);
412 nu_momentum.GetXYZT(MC_incoming_P);
413 const TLorentzVector& vertex =neutrino.
Position(0);
414 vertex.GetXYZT(MC_vertex);
419 double tmp_leadingPionPlusE = 0.0;
420 double tmp_leadingPionMinusE = 0.0;
421 double tmp_leadingProtonE = 0.0;
436 particle = ipar->second;
437 if( particle->
PdgCode() == fLeptonPDGcode && particle->
Mother() == 0 ){
438 const TLorentzVector& lepton_momentum =particle->
Momentum(0);
439 lepton_momentum.GetXYZT(MC_lepton_startMomentum);
440 MC_leptonID = particle->
TrackId();
441 MC_leptonP = sqrt(pow(particle->
Momentum().Px(),2)+pow(particle->
Momentum().Py(),2)+pow(particle->
Momentum().Pz(),2));
444 if( particle->
Mother() == 0 ){
446 if( particle->
PdgCode() == 2212 ){
447 if(particle->
Momentum().E() > tmp_leadingProtonE){
448 tmp_leadingProtonE = particle->
Momentum().E();
449 MC_leading_protonID = particle->
TrackId();
450 MC_leading_ProtonP = sqrt(pow(particle->
Momentum().Px(),2)+pow(particle->
Momentum().Py(),2)+pow(particle->
Momentum().Pz(),2));
454 else if( particle->
PdgCode() == 211 ){
455 if(particle->
Momentum().E() > tmp_leadingPionPlusE){
456 tmp_leadingPionPlusE = particle->
Momentum().E();
457 MC_leading_PionPlusID = particle->
TrackId();
458 MC_leading_PionPlusP = sqrt(pow(particle->
Momentum().Px(),2)+pow(particle->
Momentum().Py(),2)+pow(particle->
Momentum().Pz(),2));
459 MCpion_plus = particle;
462 else if( particle->
PdgCode() == -211 ){
463 if(particle->
Momentum().E() > tmp_leadingPionMinusE){
464 tmp_leadingPionMinusE = particle->
Momentum().E();
465 MC_leading_PionMinusID = particle->
TrackId();
466 MC_leading_PionMinusP = sqrt(pow(particle->
Momentum().Px(),2)+pow(particle->
Momentum().Py(),2)+pow(particle->
Momentum().Pz(),2));
467 MCpion_minus = particle;
476 if(!fisNeutrinoInt ){
477 if( particle->
Mother() == 0 ){
478 const TLorentzVector& positionStart = particle->
Position(0);
479 positionStart.GetXYZT(MC_vertex);
481 if( particle->
PdgCode() == 321 ){
482 MC_kaonID = particle->
TrackId();
483 MC_kaonP = sqrt(pow(particle->
Momentum().Px(),2)+pow(particle->
Momentum().Py(),2)+pow(particle->
Momentum().Pz(),2));
487 MC_leptonID = particle->
TrackId();
488 MC_leptonP = sqrt(pow(particle->
Momentum().Px(),2)+pow(particle->
Momentum().Py(),2)+pow(particle->
Momentum().Pz(),2));
491 else if( particle->
PdgCode() == 2212 ){
492 if(particle->
Momentum().E() > tmp_leadingProtonE){
493 tmp_leadingProtonE = particle->
Momentum().E();
494 MC_leading_protonID = particle->
TrackId();
495 MC_leading_ProtonP = sqrt(pow(particle->
Momentum().Px(),2)+pow(particle->
Momentum().Py(),2)+pow(particle->
Momentum().Pz(),2));
499 else if( particle->
PdgCode() == 211 ){
500 if(particle->
Momentum().E() > tmp_leadingPionPlusE){
501 tmp_leadingPionPlusE = particle->
Momentum().E();
502 MC_leading_PionPlusID = particle->
TrackId();
503 MC_leading_PionPlusP = sqrt(pow(particle->
Momentum().Px(),2)+pow(particle->
Momentum().Py(),2)+pow(particle->
Momentum().Pz(),2));
504 MCpion_plus = particle;
507 else if( particle->
PdgCode() == -211 ){
508 if(particle->
Momentum().E() > tmp_leadingPionMinusE){
509 tmp_leadingPionMinusE = particle->
Momentum().E();
510 MC_leading_PionMinusID = particle->
TrackId();
511 MC_leading_PionMinusP = sqrt(pow(particle->
Momentum().Px(),2)+pow(particle->
Momentum().Py(),2)+pow(particle->
Momentum().Pz(),2));
512 MCpion_minus = particle;
515 else if( particle->
Process() ==
"Decay" && particle->
PdgCode() == -11){
516 MC_michelID = particle->
TrackId();
517 MC_michelP = sqrt(pow(particle->
Momentum().Px(),2)+pow(particle->
Momentum().Py(),2)+pow(particle->
Momentum().Pz(),2));
520 else if( TMath::Abs(particle->
PdgCode() == 321) ){
521 MC_kaonID = particle->
TrackId();
522 MC_kaonP = sqrt(pow(particle->
Momentum().Px(),2)+pow(particle->
Momentum().Py(),2)+pow(particle->
Momentum().Pz(),2));
531 if( !isFiducial )
return;
532 double Pv = sqrt(pow(MC_incoming_P[0],2)+pow(MC_incoming_P[1],2)+pow(MC_incoming_P[2],2));
533 double theta_mu = acos((MC_incoming_P[0]*MC_lepton_startMomentum[0] + MC_incoming_P[1]*MC_lepton_startMomentum[1] +MC_incoming_P[2]*MC_lepton_startMomentum[2])/(Pv*MC_leptonP) );
534 theta_mu *= (180.0/3.14159);
537 double pion_plus_length =
truthLength(MCpion_plus);
538 double pion_minus_length =
truthLength(MCpion_minus);
543 if( MC_isCC && (fNeutrinoPDGcode == MC_incoming_PDG) && (MC_incoming_P[3] <= fMaxNeutrinoE) ){
545 h_Ev_den->Fill(MC_incoming_P[3]);
546 h_Pmu_den->Fill(MC_leptonP);
547 h_theta_den->Fill(theta_mu);
548 h_muon_length->Fill(truth_lengthLepton);
551 h_Pproton_den->Fill(MC_leading_ProtonP);
552 h_proton_length->Fill(proton_length);
555 h_Ppion_plus_den->Fill( MC_leading_PionPlusP);
556 h_pionp_length->Fill(pion_plus_length);
559 h_Ppion_minus_den->Fill( MC_leading_PionMinusP);
560 h_pionm_length->Fill(pion_minus_length);
563 h_Pkaon_den->Fill(MC_kaonP);
564 h_kaon_length->Fill(kaonLength);
569 if(!fisNeutrinoInt ){
571 h_Pmu_den->Fill(MC_leptonP);
572 h_muon_length->Fill(truth_lengthLepton);
575 h_Pkaon_den->Fill(MC_kaonP);
576 h_kaon_length->Fill(kaonLength);
579 h_Pproton_den->Fill(MC_leading_ProtonP);
580 h_proton_length->Fill(proton_length);
583 h_Ppion_plus_den->Fill( MC_leading_PionPlusP);
584 h_pionp_length->Fill(pion_plus_length);
587 h_Ppion_minus_den->Fill( MC_leading_PionMinusP);
588 h_pionm_length->Fill(pion_minus_length);
591 h_Pmichel_e_den->Fill(MC_michelP);
592 h_michel_length->Fill(michelLength);
600 if(! event.
getByLabel(fTrackModuleLabel, trackListHandle))
return;
601 std::vector<art::Ptr<recob::Track> > tracklist;
603 int n_recoTrack = tracklist.size();
606 if( n_recoTrack == 0 ){
607 LOG_DEBUG(
"NeutrinoTrackingEff")<<
"There are no reco tracks... bye";
610 LOG_DEBUG(
"NeutrinoTrackingEff")<<
"Found this many reco tracks "<<n_recoTrack;
613 double Efrac_lepton =0.0;
614 double Ecomplet_lepton =0.0;
615 double Efrac_proton =0.0;
616 double Ecomplet_proton =0.0;
617 double Efrac_pionplus =0.0;
618 double Ecomplet_pionplus =0.0;
619 double Efrac_pionminus =0.0;
620 double Ecomplet_pionminus =0.0;
621 double Efrac_kaon =0.0;
622 double Ecomplet_kaon =0.0;
623 double Efrac_michel =0.0;
624 double Ecomplet_michel =0.0;
625 double trackLength_lepton =0.0;
626 double trackLength_proton =0.0;
627 double trackLength_pion_plus =0.0;
628 double trackLength_pion_minus =0.0;
629 double trackLength_kaon =0.0;
630 double trackLength_michel =0.0;
638 std::vector<art::Ptr<recob::Hit>> tmp_all_trackHits = track_hits.at(0);
639 std::vector<art::Ptr<recob::Hit>> all_hits;
643 for(
int i=0; i<n_recoTrack; i++) {
645 std::vector<art::Ptr<recob::Hit>> all_trackHits = track_hits.at(i);
647 double tmpEcomplet =0;
649 truthMatcher( all_hits, all_trackHits, particle, tmpEfrac, tmpEcomplet );
650 if (!particle)
continue;
655 if( tmpEcomplet > Ecomplet_lepton ){
656 Ecomplet_lepton = tmpEcomplet;
657 Efrac_lepton = tmpEfrac;
658 trackLength_lepton = track->
Length();
659 MClepton_reco = particle;
664 if( tmpEcomplet > Ecomplet_proton ){
665 Ecomplet_proton = tmpEcomplet;
666 Efrac_proton = tmpEfrac;
667 trackLength_proton = track->
Length();
668 MCproton_reco = particle;
673 if( tmpEcomplet > Ecomplet_pionplus ){
674 Ecomplet_pionplus = tmpEcomplet;
675 Efrac_pionplus = tmpEfrac;
676 trackLength_pion_plus = track->
Length();
677 MCpion_plus_reco = particle;
682 if( tmpEcomplet > Ecomplet_pionminus ){
683 Ecomplet_pionminus = tmpEcomplet;
684 Efrac_pionminus = tmpEfrac;
685 trackLength_pion_minus = track->
Length();
686 MCpion_minus_reco = particle;
692 if( tmpEcomplet > Ecomplet_kaon ){
693 Ecomplet_kaon = tmpEcomplet;
694 Efrac_kaon = tmpEfrac;
695 trackLength_kaon = track->
Length();
696 MCkaon_reco = particle;
702 if( tmpEcomplet > Ecomplet_michel ){
703 Ecomplet_michel = tmpEcomplet;
704 Efrac_michel = tmpEfrac;
705 trackLength_michel = track->
Length();
706 MCmichel_reco = particle;
712 double Reco_LengthRes = truth_lengthLepton-trackLength_lepton;
713 double Reco_LengthResProton = proton_length-trackLength_proton;
714 double Reco_LengthResPionPlus = pion_plus_length-trackLength_pion_plus;
715 double Reco_LengthResPionMinus = pion_minus_length-trackLength_pion_minus;
717 if( MClepton_reco && MClepton ){
718 if( MC_isCC && (fNeutrinoPDGcode == MC_incoming_PDG) && (MC_incoming_P[3] <= fMaxNeutrinoE) ){
719 h_Pmu_num->Fill(MC_leptonP);
720 h_Ev_num->Fill(MC_incoming_P[3]);
721 h_theta_num->Fill(theta_mu);
722 h_Efrac_lepton->Fill(Efrac_lepton);
723 h_Ecomplet_lepton->Fill(Ecomplet_lepton);
724 h_trackRes_lepton->Fill(Reco_LengthRes);
725 h_muonwtrk_length->Fill(truth_lengthLepton);
728 if( MCproton_reco && MCproton ){
729 if( MC_isCC && (fNeutrinoPDGcode == MC_incoming_PDG) && (MC_incoming_P[3] <= fMaxNeutrinoE) ){
730 h_Pproton_num->Fill(MC_leading_ProtonP);
731 h_Efrac_proton->Fill(Efrac_proton);
732 h_Ecomplet_proton->Fill(Ecomplet_proton);
733 h_trackRes_proton->Fill(Reco_LengthResProton);
734 h_protonwtrk_length->Fill(proton_length);
737 if( MCpion_plus_reco && MCpion_plus ){
738 if( MC_isCC && (fNeutrinoPDGcode == MC_incoming_PDG) && (MC_incoming_P[3] <= fMaxNeutrinoE) ){
739 h_Ppion_plus_num->Fill(MC_leading_PionPlusP);
740 h_Efrac_pion_plus->Fill(Efrac_pionplus);
741 h_Ecomplet_pion_plus->Fill(Ecomplet_pionplus);
742 h_trackRes_pion_plus->Fill(Reco_LengthResPionPlus);
743 h_pionpwtrk_length->Fill(pion_plus_length);
746 if( MCpion_minus_reco && MCpion_minus ){
747 if( MC_isCC && (fNeutrinoPDGcode == MC_incoming_PDG) && (MC_incoming_P[3] <= fMaxNeutrinoE) ) {
748 h_Ppion_minus_num->Fill(MC_leading_PionMinusP);
749 h_Efrac_pion_minus->Fill(Efrac_pionminus);
750 h_Ecomplet_pion_minus->Fill(Ecomplet_pionminus);
751 h_trackRes_pion_minus->Fill(Reco_LengthResPionMinus);
752 h_pionmwtrk_length->Fill(pion_minus_length);
755 if( MCkaon_reco && MCkaon ){
756 if( MC_isCC && (fNeutrinoPDGcode == MC_incoming_PDG) && (MC_incoming_P[3] <= fMaxNeutrinoE) ) {
757 h_Pkaon_num->Fill(MC_kaonP);
758 h_Efrac_kaon->Fill(Efrac_kaon);
759 h_Ecomplet_kaon->Fill(Ecomplet_kaon);
760 h_trackRes_kaon->Fill(kaonLength-trackLength_kaon);
761 h_kaonwtrk_length->Fill(kaonLength);
766 if(!fisNeutrinoInt ){
767 if( MClepton_reco && MClepton ){
768 h_Pmu_num->Fill(MC_leptonP);
769 h_Efrac_lepton->Fill(Efrac_lepton);
770 h_Ecomplet_lepton->Fill(Ecomplet_lepton);
771 h_trackRes_lepton->Fill(Reco_LengthRes);
772 h_muonwtrk_length->Fill(truth_lengthLepton);
774 if( MCkaon_reco && MCkaon ){
775 h_Pkaon_num->Fill(MC_kaonP);
776 h_Efrac_kaon->Fill(Efrac_kaon);
777 h_Ecomplet_kaon->Fill(Ecomplet_kaon);
778 h_trackRes_kaon->Fill(kaonLength-trackLength_kaon);
779 h_kaonwtrk_length->Fill(kaonLength);
781 if( MCproton_reco && MCproton ){
782 h_Pproton_num->Fill(MC_leading_ProtonP);
783 h_Efrac_proton->Fill(Efrac_proton);
784 h_Ecomplet_proton->Fill(Ecomplet_proton);
785 h_trackRes_proton->Fill(Reco_LengthResProton);
786 h_protonwtrk_length->Fill(proton_length);
788 if( MCpion_plus_reco && MCpion_plus ){
789 h_Ppion_plus_num->Fill(MC_leading_PionPlusP);
790 h_Efrac_pion_plus->Fill(Efrac_pionplus);
791 h_Ecomplet_pion_plus->Fill(Ecomplet_pionplus);
792 h_trackRes_pion_plus->Fill(Reco_LengthResPionPlus);
793 h_pionpwtrk_length->Fill(pion_plus_length);
795 if( MCpion_minus_reco && MCpion_minus ){
796 h_Ppion_minus_num->Fill(MC_leading_PionMinusP);
797 h_Efrac_pion_minus->Fill(Efrac_pionminus);
798 h_Ecomplet_pion_minus->Fill(Ecomplet_pionminus);
799 h_trackRes_pion_minus->Fill(Reco_LengthResPionMinus);
800 h_pionmwtrk_length->Fill(pion_minus_length);
802 if( MCmichel_reco && MCmichel ){
803 h_Pmichel_e_num->Fill(MC_michelP);
804 h_Efrac_michel->Fill(Efrac_michel);
805 h_Ecomplet_michel->Fill(Ecomplet_michel);
806 h_trackRes_michel->Fill(michelLength-trackLength_michel);
807 h_michelwtrk_length->Fill(michelLength);
819 std::map<int,double> trkID_E;
820 for(
size_t j = 0; j < track_hits.size(); ++j){
823 for(
size_t k = 0; k < TrackIDs.size(); k++){
824 trkID_E[TrackIDs[k].trackID] += TrackIDs[k].energy;
828 double max_E = -999.0;
829 double total_E = 0.0;
831 double partial_E =0.0;
834 if( !trkID_E.size() ) {
839 total_E += ii->second;
840 if((ii->second)>max_E){
841 partial_E = ii->second;
844 if( TrackID < 0 ) E_em += ii->second;
852 if( TrackID < 0 )
return;
855 Efrac = (partial_E)/total_E;
859 for(
size_t k = 0; k < all_hits.size(); ++k){
862 for(
size_t l = 0; l < TrackIDs.size(); ++l){
863 if(TrackIDs[l].trackID==TrackID) totenergy += TrackIDs[l].energy;
866 Ecomplet = partial_E/totenergy;
873 if( !MCparticle )
return -999.0;
875 std::vector<double> TPCLengthHits(numberTrajectoryPoints, 0.0);
876 int FirstHit=0, LastHit=0;
877 double TPCLength = 0.0;
878 bool BeenInVolume =
false;
880 for(
unsigned int MCHit=0; MCHit < TPCLengthHits.size(); ++MCHit) {
881 const TLorentzVector& tmpPosition= MCparticle->
Position(MCHit);
882 double const tmpPosArray[]={tmpPosition[0],tmpPosition[1],tmpPosition[2]};
883 if (MCHit!=0) TPCLengthHits[MCHit] = sqrt( pow( (MCparticle->
Vx(MCHit-1)-MCparticle->
Vx(MCHit)),2)+ pow( (MCparticle->
Vy(MCHit-1)-MCparticle->
Vy(MCHit)),2)+ pow( (MCparticle->
Vz(MCHit-1)-MCparticle->
Vz(MCHit)),2));
890 double DriftTimeCorrection = fabs( tmpPosition[0] - XPlanePosition ) /
XDriftVelocity;
891 double TimeAtPlane = MCparticle->
T() + DriftTimeCorrection;
894 if( !BeenInVolume ) {
900 for (
int Hit = FirstHit+1; Hit <= LastHit; ++Hit ) TPCLength += TPCLengthHits[Hit];
906 double x = vertex[0];
907 double y = vertex[1];
908 double z = vertex[2];
910 if (x>fFidVolXmin && x<fFidVolXmax&&
911 y>fFidVolYmin && y<fFidVolYmax&&
912 z>fFidVolZmin && z<fFidVolZmax)
922 if(TEfficiency::CheckConsistency(*h_Ev_num,*h_Ev_den)){
924 TGraphAsymmErrors *grEff_Ev = h_Eff_Ev->CreateGraph();
925 grEff_Ev->Write(
"grEff_Ev");
926 h_Eff_Ev->Write(
"h_Eff_Ev");
928 if(TEfficiency::CheckConsistency(*h_Pmu_num,*h_Pmu_den)){
930 TGraphAsymmErrors *grEff_Pmu = h_Eff_Pmu->CreateGraph();
931 grEff_Pmu->Write(
"grEff_Pmu");
932 h_Eff_Pmu->Write(
"h_Eff_Pmu");
934 if(TEfficiency::CheckConsistency(*h_theta_num,*h_theta_den)){
936 TGraphAsymmErrors *grEff_theta = h_Eff_theta->CreateGraph();
937 grEff_theta->Write(
"grEff_theta");
938 h_Eff_theta->Write(
"h_Eff_theta");
940 if(TEfficiency::CheckConsistency(*h_Pproton_num,*h_Pproton_den)){
942 TGraphAsymmErrors *grEff_Pproton = h_Eff_Pproton->CreateGraph();
943 grEff_Pproton->Write(
"grEff_Pproton");
944 h_Eff_Pproton->Write(
"h_Eff_Pproton");
946 if(TEfficiency::CheckConsistency(*h_Ppion_plus_num,*h_Ppion_plus_den)){
948 TGraphAsymmErrors *grEff_Ppion_plus = h_Eff_Ppion_plus->CreateGraph();
949 grEff_Ppion_plus->Write(
"grEff_Ppion_plus");
950 h_Eff_Ppion_plus->Write(
"h_Eff_Ppion_plus");
952 if(TEfficiency::CheckConsistency(*h_Ppion_minus_num,*h_Ppion_minus_den)){
954 TGraphAsymmErrors *grEff_Ppion_minus = h_Eff_Ppion_minus->CreateGraph();
955 grEff_Ppion_minus->Write(
"grEff_Ppion_minus");
956 h_Eff_Ppion_minus->Write(
"h_Eff_Ppion_minus");
958 if(TEfficiency::CheckConsistency(*h_muonwtrk_length,*h_muon_length)){
960 TGraphAsymmErrors *grEff_Lmuon = h_Eff_Lmuon->CreateGraph();
961 grEff_Lmuon->Write(
"grEff_Lmuon");
962 h_Eff_Lmuon->Write(
"h_Eff_Lmuon");
964 if(TEfficiency::CheckConsistency(*h_protonwtrk_length,*h_proton_length)){
966 TGraphAsymmErrors *grEff_Lproton = h_Eff_Lproton->CreateGraph();
967 grEff_Lproton->Write(
"grEff_Lproton");
968 h_Eff_Lproton->Write(
"h_Eff_Lproton");
970 if(TEfficiency::CheckConsistency(*h_pionpwtrk_length,*h_pionp_length)){
972 TGraphAsymmErrors *grEff_Lpion_plus = h_Eff_Lpion_plus->CreateGraph();
973 grEff_Lpion_plus->Write(
"grEff_Lpion_plus");
974 h_Eff_Lpion_plus->Write(
"h_Eff_Lpion_plus");
976 if(TEfficiency::CheckConsistency(*h_pionpwtrk_length,*h_pionp_length)){
978 TGraphAsymmErrors *grEff_Lpion_minus = h_Eff_Lpion_minus->CreateGraph();
979 grEff_Lpion_minus->Write(
"grEff_Lpion_minus");
980 h_Eff_Lpion_minus->Write(
"h_Eff_Lpion_minus");
982 if(TEfficiency::CheckConsistency(*h_Pkaon_num,*h_Pkaon_den)){
984 TGraphAsymmErrors *grEff_Pkaon = h_Eff_Pkaon->CreateGraph();
985 grEff_Pkaon->Write(
"grEff_Pkaon");
986 h_Eff_Pkaon->Write(
"h_Eff_Pkaon");
988 if(TEfficiency::CheckConsistency(*h_kaonwtrk_length,*h_kaon_length)){
990 TGraphAsymmErrors *grEff_Lkaon = h_Eff_Lkaon->CreateGraph();
991 grEff_Lkaon->Write(
"grEff_Lkaon");
992 h_Eff_Lkaon->Write(
"h_Eff_Lkaon");
994 if(TEfficiency::CheckConsistency(*h_Pmichel_e_num,*h_Pmichel_e_den)){
996 TGraphAsymmErrors *grEff_Pmichel = h_Eff_Pmichel->CreateGraph();
997 grEff_Pmichel->Write(
"grEff_Pmichel");
998 h_Eff_Pmichel->Write(
"h_Eff_Pmichel");
1000 if(TEfficiency::CheckConsistency(*h_michelwtrk_length,*h_michel_length)){
1002 TGraphAsymmErrors *grEff_Lmichel = h_Eff_Lmichel->CreateGraph();
1003 grEff_Lmichel->Write(
"grEff_Lmichel");
1004 h_Eff_Lmichel->Write(
"h_Eff_Lmichel");
1013 #endif // NeutrinoTrackingEff_Module double truthLength(const simb::MCParticle *MCparticle)
Store parameters for running LArG4.
const simb::MCParticle * TrackIdToParticle_P(int const &id)
unsigned int NumberTrajectoryPoints() const
const TLorentzVector & Position(const int i=0) const
const simb::MCNeutrino & GetNeutrino() const
virtual const ::detinfo::ElecClock & TPCClock() const =0
Lends a constant TPC clock with time set to trigger time.
virtual int TriggerOffset() const =0
std::string fTrackModuleLabel
const std::vector< sim::TrackIDE > HitToTrackIDEs(recob::Hit const &hit)
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::vector< TrackID > TrackIDs
std::string fMCTruthModuleLabel
TH1D * h_michelwtrk_length
const simb::MCParticle & Nu() const
list_type::const_iterator const_iterator
Geometry information for a single TPC.
bool get(SelectorBase const &, Handle< PROD > &result) const
Geometry information for a single cryostat.
std::string Process() const
TH1D * h_protonwtrk_length
TH1D * h_trackRes_pion_plus
void reconfigure(fhicl::ParameterSet const &pset)
geo::TPCID FindTPCAtPosition(double const worldLoc[3]) const
Returns the ID of the TPC at specified location.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
void truthMatcher(std::vector< art::Ptr< recob::Hit >> all_hits, std::vector< art::Ptr< recob::Hit >> track_hits, const simb::MCParticle *&MCparticle, double &Efrac, double &Ecomplet)
double Length(size_t p=0) const
Access to various track properties.
#define DEFINE_ART_MODULE(klass)
void analyze(const art::Event &evt)
T get(std::string const &key) const
double T(const int i=0) const
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
void processEff(const art::Event &evt, bool &isFiducial)
virtual ~NeutrinoTrackingEff()
TH1D * h_Efrac_pion_minus
virtual unsigned int NumberTimeSamples() const =0
void beginRun(const art::Run &run)
The data type to uniquely identify a TPC.
Provides recob::Track data product.
Definition of data types for geometry description.
Detector simulation of raw signals on wires.
Conversion of times between different formats and references.
double MC_leading_PionPlusP
art::ServiceHandle< geo::Geometry > geom
double Vx(const int i=0) const
T * make(ARGS...args) const
TH1D * h_Ecomplet_pion_plus
double TickPeriod() const
A single tick period in microseconds.
int MC_leading_PionMinusID
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc'th TPC in the cryostat.
virtual double DriftVelocity(double efield=0., double temperature=0.) const =0
TH1D * h_trackRes_pion_minus
int MC_leading_PionPlusID
const TLorentzVector & Momentum(const int i=0) const
TH1D * h_pionmwtrk_length
double Vz(const int i=0) const
const sim::ParticleList & ParticleList()
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
double MC_leading_ProtonP
Event generator information.
Namespace collecting geometry-related classes utilities.
TH1D * h_pionpwtrk_length
double MC_leading_PionMinusP
TH1D * h_Ecomplet_pion_minus
void LocalToWorld(const double *tpc, double *world) const
Transform point from local TPC frame to world frame.
const double * PlaneLocation(unsigned int p) const
Returns the coordinates of the center of the specified plane [cm].
bool insideFV(double vertex[4])
double Vy(const int i=0) const
Event finding and building.