141 ah_ = std::make_shared<AnaHelpers>();
169 for (
unsigned int i_reg = 0;
173 std::cout<<
"Setting up region "<< regname<<std::endl;
179 reg_histos_[regname] = std::make_shared<TrackHistos>(regname);
181 reg_histos_[regname]->doTrackComparisonPlots(
false);
189 tree->SetBranchAddress(
"EventHeader", &
evth_ , &
bevth_);
221 "psmear_top_h",200,2,6);
223 "psmear_bot_h",200,2,6);
226 "psmear_vs_nHits_hh",
230 "psmear_vs_nHits_top_hh",
234 "psmear_vs_nHits_bot_hh",
240 "psmear_rel_h",200,0,6);
243 "psmear_vs_nHits_rel_hh",
247 "psmear_vs_nHits_top_rel_hh",
251 "psmear_vs_nHits_bot_rel_hh",
256 z0smear_h_ =
new TH1D(
"z0smear_h",
"z0smear_h", 100, -0.5, 0.5);
257 z0smear_top_h_ =
new TH1D(
"z0smear_top_h",
"z0smear_top_h", 100, -0.5, 0.5);
258 z0smear_bot_h_ =
new TH1D(
"z0smear_bot_h",
"z0smear_bot_h", 100, -0.5, 0.5);
261 omega_h_ =
new TH1D(
"omega_h",
"omega_h", 100, -0.00015, 0.00015);
262 omega_top_h_ =
new TH1D(
"omega_top_h",
"omega_top_h", 100, -0.00015, 0.00015);
263 omega_bot_h_ =
new TH1D(
"omega_bot_h",
"omega_bot_h", 100, -0.00015, 0.00015);
264 omegasmear_h_ =
new TH1D(
"omegasmear_h",
"omegasmear_h", 100, -0.00015, 0.00015);
265 omegasmear_top_h_ =
new TH1D(
"omegasmear_top_h",
"omegasmear_top_h", 100, -0.00015, 0.00015);
266 omegasmear_bot_h_ =
new TH1D(
"omegasmear_bot_h",
"omegasmear_bot_h", 100, -0.00015, 0.00015);
267 omega_vs_p_hh_ =
new TH2D(
"omega_vs_p_hh",
"omega_vs_p_hh", 100, 1.0, 4.5, 100, -0.00015, 0.00015);
270 omega_vs_tanL_hh_ =
new TH2D(
"omega_vs_tanL_hh",
"omega_vs_tanL_hh", 80, -0.08, 0.08, 100, -0.00015, 0.00015);
271 omega_vs_tanL_top_hh_ =
new TH2D(
"omega_vs_tanL_top_hh",
"omega_vs_tanL_top_hh", 40, 0.00, 0.08, 100, -0.00015, 0.00015);
272 omega_vs_tanL_bot_hh_ =
new TH2D(
"omega_vs_tanL_bot_hh",
"omega_vs_tanL_bot_hh", 40, -0.08, 0.00, 100, -0.00015, 0.00015);
273 omegasmear_vs_tanL_hh_ =
new TH2D(
"omegasmear_vs_tanL_hh",
"omegasmear_vs_tanL_hh", 80, -0.08, 0.08, 100, -0.00015, 0.00015);
274 omegasmear_vs_tanL_top_hh_ =
new TH2D(
"omegasmear_vs_tanL_top_hh",
"omegasmear_vs_tanL_top_hh", 40, 0.00, 0.08, 100, -0.00015, 0.00015);
275 omegasmear_vs_tanL_bot_hh_ =
new TH2D(
"omegasmear_vs_tanL_bot_hh",
"omegasmear_vs_tanL_bot_hh", 40, -0.08, 0.00, 100, -0.00015, 0.00015);
277 omega_vs_phi0_hh_ =
new TH2D(
"omega_vs_phi0_hh",
"omega_vs_phi0_hh", 80, -0.2, 0.2, 100, -0.00015, 0.00015);
278 omega_vs_phi0_top_hh_ =
new TH2D(
"omega_vs_phi0_top_hh",
"omega_vs_phi0_top_hh", 80, -0.2, 0.2, 100, -0.00015, 0.00015);
279 omega_vs_phi0_bot_hh_ =
new TH2D(
"omega_vs_phi0_bot_hh",
"omega_vs_phi0_bot_hh", 80, -0.2, 0.2, 100, -0.00015, 0.00015);
280 omegasmear_vs_phi0_hh_ =
new TH2D(
"omegasmear_vs_phi0_hh",
"omegasmear_vs_phi0_hh", 80, -0.2, 0.2, 100, -0.00015, 0.00015);
281 omegasmear_vs_phi0_top_hh_ =
new TH2D(
"omegasmear_vs_phi0_top_hh",
"omegasmear_vs_phi0_top_hh", 80, -0.2, 0.2, 100, -0.00015, 0.00015);
282 omegasmear_vs_phi0_bot_hh_ =
new TH2D(
"omegasmear_vs_phi0_bot_hh",
"omegasmear_vs_phi0_bot_hh", 80, -0.2, 0.2, 100, -0.00015, 0.00015);
292 int n_sel_tracks = 0;
301 std::cout <<
"[FeeAna] --- new event isData=" <<
isData_
303 <<
" timeWindow=[" << minTime <<
"," << maxTime <<
"]"
304 <<
" nFSPs=" <<
fsps_->size() << std::endl;
312 if (
debug_ > 0) std::cout <<
"[FeeAna] FAIL FEE trigger" << std::endl;
321 for (
unsigned int ipart = 0; ipart <
fsps_->size(); ++ipart) {
329 if (
debug_ > 0) std::cout <<
"[FeeAna] FAIL not an electron: charge=" << part->
getCharge() << std::endl;
337 double clu_traw = clu.
getTime();
338 double clu_t = clu_traw - calOffset;
343 std::cout <<
"[FeeAna][cluTime] rawCluTime=" << clu_traw
344 <<
" corrCluTime=" << clu_t
355 if (clu_t < minTime || clu_t > maxTime) {
356 if (
debug_ > 0) std::cout <<
"[FeeAna] FAIL cluster time (corrected): " << clu_t <<
" not in [" << minTime <<
"," << maxTime <<
"]" << std::endl;
363 Track* track = &track_obj;
364 int n2dhits_onTrack = !track->isKalmanTrack() ? track->getTrackerHitCount() * 2 : track->getTrackerHitCount();
367 double eop = track->getP() > 0 ? clu_E / track->getP() : -1.0;
369 if (
debug_ > 0) std::cout <<
"[FeeAna] FAIL E/p: " << eop <<
" not in [" <<
eopMin_ <<
"," <<
eopMax_ <<
"]" << std::endl;
374 trk_mom.SetX(track->getMomentum()[0]);
375 trk_mom.SetY(track->getMomentum()[1]);
376 trk_mom.SetZ(track->getMomentum()[2]);
379 bool isTop = track->getTanLambda() > 0;
386 Track* layerTrack = track;
389 if (t && t->getID() == track->getID()) { layerTrack = t;
break; }
392 std::vector<int> layers =
ah_->GetTrackHitLayers(layerTrack);
393 if (std::none_of(layers.begin(), layers.end(), [](
int v){ return v == 1; })) {
395 TRefArray hits = track->getSvtHits();
396 for (
int ih = 0; ih < hits.GetEntries(); ++ih) {
404 for (
int i = 0; i < (int) layers.size(); ++i)
405 if (layers.at(i) == 1) hit_pattern |= (1 << i);
409 double hitPatternScale = 1.0;
410 bool hitPatternScaleIsDefault =
false;
414 hitPatternScale = it->second;
417 hitPatternScaleIsDefault =
true;
422 Track trk_corr = *track;
423 if (hitPatternScale != 1.0) {
425 for (
double& c : mom) c *= hitPatternScale;
433 bool L1_axial = isTop ? (layers.at(0) == 1) : (layers.at(1) == 1);
434 bool L1_stereo = isTop ? (layers.at(1) == 1) : (layers.at(0) == 1);
435 bool L2_axial = isTop ? (layers.at(2) == 1) : (layers.at(3) == 1);
436 bool L2_stereo = isTop ? (layers.at(3) == 1) : (layers.at(2) == 1);
437 bool L3_axial = isTop ? (layers.at(4) == 1) : (layers.at(5) == 1);
438 bool L3_stereo = isTop ? (layers.at(5) == 1) : (layers.at(4) == 1);
439 bool L4_axial = isTop ? (layers.at(6) == 1) : (layers.at(7) == 1);
440 bool L4_stereo = isTop ? (layers.at(7) == 1) : (layers.at(6) == 1);
444 bool L1 = (layers.at(0) == 1 && layers.at(1) == 1);
445 bool L2 = (layers.at(2) == 1 && layers.at(3) == 1);
446 bool L3 = (layers.at(4) == 1 && layers.at(5) == 1);
447 bool L4 = (layers.at(6) == 1 && layers.at(7) == 1);
453 bool is_L1 = L1 && L2 && L3;
454 bool is_L2 = !L1 && L2 && L3;
455 bool is_L3 = !L1 && !L2 && L3;
458 std::cout <<
"[FeeAna] fsp[" << ipart <<
"]"
460 <<
" nHits=" << n2dhits_onTrack
461 <<
" chi2ndf=" << track->getChi2Ndf()
462 <<
" p=" << trk_mom.Mag()
465 <<
" tanL=" << track->getTanLambda()
466 <<
" ecalX=" << track->getPositionAtEcal()[0]
467 <<
" trkTime=" << track->getTrackTime()
468 <<
" trkTime-offset=" << track->getTrackTime() -
time_offset_
474 if (
debug_ > 0) std::cout <<
"[FeeAna] FAIL n_hits_gt: " << n2dhits_onTrack << std::endl;
479 if (
debug_ > 0) std::cout <<
"[FeeAna] FAIL chi2ndf_lt: " << track->getChi2Ndf() << std::endl;
484 if (
debug_ > 0) std::cout <<
"[FeeAna] FAIL p_gt: " << trk_mom.Mag() << std::endl;
489 if (
debug_ > 0) std::cout <<
"[FeeAna] FAIL p_lt: " << trk_mom.Mag() << std::endl;
494 if (
debug_ > 0) std::cout <<
"[FeeAna] FAIL trk_ecal_lt: " << track->getPositionAtEcal()[0] << std::endl;
499 if (
debug_ > 0) std::cout <<
"[FeeAna] FAIL trk_ecal_gt: " << track->getPositionAtEcal()[0] << std::endl;
504 if (
debug_ > 0) std::cout <<
"[FeeAna] FAIL trk_time_gt: " << track->getTrackTime() -
time_offset_ << std::endl;
509 if (
debug_ > 0) std::cout <<
"[FeeAna] FAIL trk_time_lt: " << track->getTrackTime() -
time_offset_ << std::endl;
520 int n_clusters_intime = 0;
521 int n_tracks_intime = 0;
540 if (
debug_ > 0) std::cout <<
"[FeeAna] FAIL extra in-time clusters: " << n_clusters_intime << std::endl;
544 if (
debug_ > 0) std::cout <<
"[FeeAna] FAIL extra in-time tracks: " << n_tracks_intime << std::endl;
548 if (
debug_ > 0) std::cout <<
"[FeeAna] PASS all cuts" << std::endl;
550 Track* truth_track =
nullptr;
558 bool has_truth_link = (track->getTruthLink().GetObject() !=
nullptr);
562 truth_track = (
Track*) track->getTruthLink().GetObject();
564 std::cout<<
"Warnings::FeeAnaProcessor::Requested Truth track but couldn't find it in the ntuple"<<std::endl;
569 std::cout<<
"========================================="<<std::endl;
570 std::cout<<
"========================================="<<std::endl;
571 std::cout<<
"Track params: "<<std::endl;
588 track->getPositionAtEcal()[0],
589 track->getPositionAtEcal()[1]);
591 trkHistos_->Fill3DHisto(
"p_vs_TanLambda_Phi_hhh",
593 track->getTanLambda(),
597 track->getTrackerHitCount(),
600 if (track->getTanLambda() > 0 )
602 track->getTrackerHitCount(),
606 track->getTrackerHitCount(),
609 trkHistos_->Fill3DHisto(
"p_vs_TanLambda_nHits_hhh",
610 track->getTanLambda(),
611 track->getTrackerHitCount(),
618 Track trk_smeared = *track;
623 double omega_unsmeared = track->getOmega();
624 double omega_smeared = omega_unsmeared;
625 double p_smear_ratio = 1.0;
630 p_smear_ratio = corr.
pSmear;
632 if (
corrector_->smearsOmega()) omega_smeared = omega_unsmeared / corr.
pSmear;
637 double nhits = track->getTrackerHitCount();
639 double pval = trk_smeared.
getP();
640 double z0val = trk_smeared.
getZ0();
674 double tanL = track->getTanLambda();
675 double phi0 = track->getPhi();
739 trkHistos_->Fill1DHisto(
"n_tracks_h",n_sel_tracks);