82 ah_ = std::make_shared<AnaHelpers>();
110 for (
unsigned int i_reg = 0;
114 std::cout<<
"Setting up region "<< regname<<std::endl;
120 reg_histos_[regname] = std::make_shared<TrackHistos>(regname);
122 reg_histos_[regname]->doTrackComparisonPlots(
false);
133 tree->SetBranchAddress(
"EventHeader", &
evth_ , &
bevth_);
144 if (!smearingFile.empty()) {
145 std::cout<<
"Loading smearing config from "<<smearingFile<<std::endl;
146 std::cout<<
"Smearing Tool Seed "<<
seed_<<std::endl;
148 std::cout<<
"doSmearing: "<<(
doSmearing_ ?
"true" :
"false")<<std::endl;
149 std::cout<<
"smearOmega: "<<(
smearOmega_ ?
"true" :
"false")<<std::endl;
165 "psmear_top_h",200,2,6);
167 "psmear_bot_h",200,2,6);
170 "psmear_vs_nHits_hh",
174 "psmear_vs_nHits_top_hh",
178 "psmear_vs_nHits_bot_hh",
184 "psmear_rel_h",200,0,6);
187 "psmear_vs_nHits_rel_hh",
191 "psmear_vs_nHits_top_rel_hh",
195 "psmear_vs_nHits_bot_rel_hh",
200 z0smear_h_ =
new TH1D(
"z0smear_h",
"z0smear_h", 100, -0.5, 0.5);
201 z0smear_top_h_ =
new TH1D(
"z0smear_top_h",
"z0smear_top_h", 100, -0.5, 0.5);
202 z0smear_bot_h_ =
new TH1D(
"z0smear_bot_h",
"z0smear_bot_h", 100, -0.5, 0.5);
205 omega_h_ =
new TH1D(
"omega_h",
"omega_h", 100, -0.00015, 0.00015);
206 omega_top_h_ =
new TH1D(
"omega_top_h",
"omega_top_h", 100, -0.00015, 0.00015);
207 omega_bot_h_ =
new TH1D(
"omega_bot_h",
"omega_bot_h", 100, -0.00015, 0.00015);
208 omegasmear_h_ =
new TH1D(
"omegasmear_h",
"omegasmear_h", 100, -0.00015, 0.00015);
209 omegasmear_top_h_ =
new TH1D(
"omegasmear_top_h",
"omegasmear_top_h", 100, -0.00015, 0.00015);
210 omegasmear_bot_h_ =
new TH1D(
"omegasmear_bot_h",
"omegasmear_bot_h", 100, -0.00015, 0.00015);
211 omega_vs_p_hh_ =
new TH2D(
"omega_vs_p_hh",
"omega_vs_p_hh", 100, 1.0, 4.5, 100, -0.00015, 0.00015);
214 omega_vs_tanL_hh_ =
new TH2D(
"omega_vs_tanL_hh",
"omega_vs_tanL_hh", 80, -0.08, 0.08, 100, -0.00015, 0.00015);
215 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);
216 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);
217 omegasmear_vs_tanL_hh_ =
new TH2D(
"omegasmear_vs_tanL_hh",
"omegasmear_vs_tanL_hh", 80, -0.08, 0.08, 100, -0.00015, 0.00015);
218 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);
219 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);
221 omega_vs_phi0_hh_ =
new TH2D(
"omega_vs_phi0_hh",
"omega_vs_phi0_hh", 80, -0.2, 0.2, 100, -0.00015, 0.00015);
222 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);
223 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);
224 omegasmear_vs_phi0_hh_ =
new TH2D(
"omegasmear_vs_phi0_hh",
"omegasmear_vs_phi0_hh", 80, -0.2, 0.2, 100, -0.00015, 0.00015);
225 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);
226 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);
237 int n_sel_tracks = 0;
252 std::cout <<
"[TrackingAna] --- new event isData=" <<
isData_
254 <<
" timeWindow=[" << minTime <<
"," << maxTime <<
"]"
255 <<
" nClusters=" <<
ecal_->size() << std::endl;
256 for (
unsigned int iclu = 0; iclu <
ecal_->size(); iclu++) {
257 std::cout <<
" cluster[" << iclu <<
"]"
258 <<
" E=" <<
ecal_->at(iclu)->getEnergy()
259 <<
" t=" <<
ecal_->at(iclu)->getTime() << std::endl;
263 bool foundFeeCluster =
false;
264 for (
unsigned int iclu = 0; iclu <
ecal_->size(); iclu++) {
266 foundFeeCluster =
true;
270 if (!foundFeeCluster) {
276 bool clusterInTime =
false;
277 for (
unsigned int iclu = 0; iclu <
ecal_->size(); iclu++) {
278 double t =
ecal_->at(iclu)->getTime();
279 if (t >= minTime && t <= maxTime) {
280 clusterInTime =
true;
284 if (!clusterInTime) {
285 if (
debug_ > 0) std::cout <<
"[TrackingAna] FAIL: no cluster in time window [" << minTime <<
"," << maxTime <<
"]" << std::endl;
289 for (
int itrack = 0; itrack <
tracks_->size(); ++itrack) {
295 int n2dhits_onTrack = !track->isKalmanTrack() ? track->getTrackerHitCount() * 2 : track->getTrackerHitCount();
298 trk_mom.SetX(track->getMomentum()[0]);
299 trk_mom.SetY(track->getMomentum()[1]);
300 trk_mom.SetZ(track->getMomentum()[2]);
303 bool isTop = track->getTanLambda() > 0;
304 auto layers =
ah_->GetTrackHitLayers(track);
308 bool L1_axial = isTop ? (layers.at(0) == 1) : (layers.at(1) == 1);
309 bool L1_stereo = isTop ? (layers.at(1) == 1) : (layers.at(0) == 1);
310 bool L2_axial = isTop ? (layers.at(2) == 1) : (layers.at(3) == 1);
311 bool L2_stereo = isTop ? (layers.at(3) == 1) : (layers.at(2) == 1);
312 bool L3_axial = isTop ? (layers.at(4) == 1) : (layers.at(5) == 1);
313 bool L3_stereo = isTop ? (layers.at(5) == 1) : (layers.at(4) == 1);
316 std::cout <<
"[TrackingAna] track[" << itrack <<
"]"
317 <<
" nHits=" << n2dhits_onTrack
318 <<
" chi2ndf=" << track->getChi2Ndf()
319 <<
" p=" << trk_mom.Mag()
320 <<
" tanL=" << track->getTanLambda()
321 <<
" ecalX=" << track->getPositionAtEcal()[0]
322 <<
" trkTime=" << track->getTrackTime()
323 <<
" trkTime-offset=" << track->getTrackTime() -
time_offset_
329 if (
debug_ > 0) std::cout <<
"[TrackingAna] FAIL n_hits_gt: " << n2dhits_onTrack << std::endl;
334 if (
debug_ > 0) std::cout <<
"[TrackingAna] FAIL chi2ndf_lt: " << track->getChi2Ndf() << std::endl;
339 if (
debug_ > 0) std::cout <<
"[TrackingAna] FAIL p_gt: " << trk_mom.Mag() << std::endl;
344 if (
debug_ > 0) std::cout <<
"[TrackingAna] FAIL p_lt: " << trk_mom.Mag() << std::endl;
349 if (
debug_ > 0) std::cout <<
"[TrackingAna] FAIL trk_ecal_lt: " << track->getPositionAtEcal()[0] << std::endl;
354 if (
debug_ > 0) std::cout <<
"[TrackingAna] FAIL trk_ecal_gt: " << track->getPositionAtEcal()[0] << std::endl;
359 if (
debug_ > 0) std::cout <<
"[TrackingAna] FAIL trk_time_gt: " << track->getTrackTime() -
time_offset_ << std::endl;
364 if (
debug_ > 0) std::cout <<
"[TrackingAna] FAIL trk_time_lt: " << track->getTrackTime() -
time_offset_ << std::endl;
368 if (
debug_ > 0) std::cout <<
"[TrackingAna] PASS all cuts" << std::endl;
370 Track* truth_track =
nullptr;
374 truth_track = (
Track*) track->getTruthLink().GetObject();
376 std::cout<<
"Warnings::TrackingAnaProcessor::Requested Truth track but couldn't find it in the ntuple"<<std::endl;
381 std::cout<<
"========================================="<<std::endl;
382 std::cout<<
"========================================="<<std::endl;
383 std::cout<<
"Track params: "<<std::endl;
405 track->getPositionAtEcal()[0],
406 track->getPositionAtEcal()[1]);
408 trkHistos_->Fill3DHisto(
"p_vs_TanLambda_Phi_hhh",
410 track->getTanLambda(),
414 track->getTrackerHitCount(),
417 if (track->getTanLambda() > 0 )
419 track->getTrackerHitCount(),
423 track->getTrackerHitCount(),
426 trkHistos_->Fill3DHisto(
"p_vs_TanLambda_nHits_hhh",
427 track->getTanLambda(),
428 track->getTrackerHitCount(),
435 Track trk_smeared = *track;
436 double omega_unsmeared = track->getOmega();
437 double omega_smeared = omega_unsmeared;
438 double p_smear_ratio = 1.0;
442 double nhits = track->getTrackerHitCount();
446 double scale =
smearingTool_->updateWithSmearOmega(trk_smeared);
448 omega_smeared = omega_unsmeared / scale;
449 p_smear_ratio = scale;
451 p_smear_ratio =
smearingTool_->updateWithSmearP(trk_smeared);
456 double pval = trk_smeared.
getP();
457 double z0val = trk_smeared.
getZ0();
491 double tanL = track->getTanLambda();
492 double phi0 = track->getPhi();
537 trkHistos_->Fill1DHisto(
"n_tracks_h",n_sel_tracks);