hpstr
The Heavy Photon Search Toolkit for Reconstruction (hpstr) provides an interface to physics data from the HPS experiment saved in the LCIO format and converts it into an ROOT based format.
Loading...
Searching...
No Matches
FeeAnaProcessor.h
Go to the documentation of this file.
1#ifndef __FEE_ANAPROCESSOR_H__
2#define __FEE_ANAPROCESSOR_H__
3
4//-----------------//
5// C++ StdLib //
6//-----------------//
7#include <iostream>
8#include <string>
9
10//----------//
11// ROOT //
12//----------//
13#include "TClonesArray.h"
14#include "TFile.h"
15#include "TH1D.h"
16#include "TH2D.h"
17#include "TTree.h"
18
19//-----------//
20// hpstr //
21//-----------//
22#include "Processor.h"
23#include "BaseSelector.h"
24#include "Track.h"
25#include "Particle.h"
26#include "Event.h"
27#include "CalCluster.h"
28#include "TrackerHit.h"
29#include "EventHeader.h"
30#include "TSData.h"
31#include "TrackHistos.h"
32#include "TrackCorrector.h"
33#include "AnaHelpers.h"
34#include "MCParticle.h"
35#include "TruthMatchingUtils.h"
36
46class FeeAnaProcessor : public Processor {
47
48 public:
56 FeeAnaProcessor(const std::string& name, Process& process);
57
60
66 virtual void configure(const ParameterSet& parameters);
67
73 virtual bool process(IEvent* ievent);
74
81 virtual void initialize(TTree* tree);
82
87 virtual void finalize();
88
92 virtual void setFile(TFile* outFile);
93
94 private:
95
97 std::vector<Particle*>* fsps_{};
98 TBranch* bfsps_{nullptr};
99
101 TBranch* bevth_{nullptr};
102
103 // Event Header
104 EventHeader* evth_{nullptr};
105
106 // 2021 trigger-scaler bank (TSBank), used to require the FEE trigger.
107 TSData* tsdata_{nullptr};
108 TBranch* btsdata_{nullptr};
109
110 // Full event collections, used to veto additional in-time tracks/clusters.
111 std::vector<CalCluster*>* ecalClusters_{nullptr};
112 TBranch* becalClusters_{nullptr};
113 std::vector<Track*>* allTracks_{nullptr};
114 TBranch* ballTracks_{nullptr};
115
116 // MCParticle collection, used for hit-based truth matching (MC only).
117 std::string mcColl_{"MCParticle"};
118 std::vector<MCParticle*>* mcParticles_{nullptr};
119 TBranch* bmcParticles_{nullptr};
120
121 std::string trkCollName_;
122 std::string fspCollName_{"FinalStateParticles_KF"};
123
124 // Track Selector configuration
125 std::string selectionCfg_;
126 std::shared_ptr<BaseSelector> trkSelector_;
127 std::vector<std::string> regionSelections_;
128 std::map<std::string, std::shared_ptr<BaseSelector>> reg_selectors_;
129 std::map<std::string, std::shared_ptr<TrackHistos>> reg_histos_;
130 typedef std::map<std::string, std::shared_ptr<TrackHistos>>::iterator reg_it;
131
132 // Containers to hold histogrammer info
133 std::string histCfgFilename_;
137
138 std::vector<std::string> regions_;
139
140 bool doTruth_{false};
141 int isData_{1};
142 int debug_{0};
143 int seed_{0};
144 float time_offset_{0};
145
146 // FEE selection
148 // Cluster-time window is applied to the OFFSET-CORRECTED time
149 // (cluster.getTime() - calTimeOffset), which is centered near 0.
150 double clusterTimeMin_{-6.0};
151 double clusterTimeMax_{ 6.0};
152 double clusterTimeMinMC_{-6.0};
153 double clusterTimeMaxMC_{ 6.0};
154 double calTimeOffset_{0.0};
155 double calTimeOffsetMC_{0.0};
156 double mcTimeOffset_{5.0};
157 bool requireElectron_{true};
158 bool requireCluster_{true};
159 bool requireFeeTrigger_{false};
160 double eopMin_{0.0};
161 double eopMax_{99.0};
162
163 // In-time isolation veto: a clean FEE has a single track and a single cluster.
164 // When enabled, a candidate is vetoed if any *additional* cluster/track is
165 // in-time with the primary FEE cluster (i.e. >1 in-time object of that type).
166 bool vetoExtraClusters_{false};
167 bool vetoExtraTracks_{false};
171
172 // Track corrections: data scale corrections and MC smearing, configured by one JSON
173 // and applied to track_smeared, so track stays raw.
174 std::string trackCorrectionsCfg_{""};
175 std::shared_ptr<TrackCorrector> corrector_;
176 bool doSmearing_{false};
178 double run_scale_out_{1.0};
179
180 // Per-hit_pattern momentum scale correction (data momentum -> beam energy).
181 // Loaded from a JSON with a "pattern_to_scale" map (hit_pattern -> scale) plus a
182 // "default_scale" fallback. p_corr = p * scale. Applied on data only by default.
183 std::string hitPatternScaleFile_{""};
184 bool doHitPatternScale_{false};
186 std::map<int,double> hitPatternScale_;
188
189 // AnaHelpers for decoding per-sensor hit layers
190 std::shared_ptr<AnaHelpers> ah_{nullptr};
191
192 // Output TTree
193 std::unique_ptr<TTree> output_tree_{nullptr};
196 double p_smear_ratio_out_{1.0};
197 // associated FEE cluster (from the FinalStateParticle)
198 double clu_E_out_{-9999.0};
199 double clu_time_out_{-9999.0};
200 double eop_out_{-1.0};
201 // in-time isolation counts (include the primary FEE object; clean FEE => 1)
204 // per-layer axial/stereo hit flags (L1-L4)
205 bool L1_axial_out_{false};
206 bool L1_stereo_out_{false};
207 bool L2_axial_out_{false};
208 bool L2_stereo_out_{false};
209 bool L3_axial_out_{false};
210 bool L3_stereo_out_{false};
211 bool L4_axial_out_{false};
212 bool L4_stereo_out_{false};
213 // per-layer "both axial+stereo hit" flags (eleLN/posLN analog, top/bottom independent)
214 bool L1_out_{false};
215 bool L2_out_{false};
216 bool L3_out_{false};
217 bool L4_out_{false};
218 // earliest-layer category with outward hit requirement (single-track isL1L1/isL2L2/isL3L3 analog)
219 bool is_L1_out_{false};
220 bool is_L2_out_{false};
221 bool is_L3_out_{false};
222 // full per-sensor hit pattern encoded as a bitmask: bit i (i=0..13) set if sensor
223 // slot i has a hit. Slots follow the GetTrackHitLayers convention (0/1 = L1
224 // axial/stereo, 2/3 = L2, ...). Use this to bin resolution by exact hit pattern.
226 int n_hits_out_{0};
227 // per-hit_pattern momentum scale correction (data->beam). track_corr_out_ is the
228 // original track with its momentum scaled by hit_pattern_scale_out_ (omega scaled by
229 // 1/scale to stay consistent). hit_pattern_scale_isdefault_out_ is true when the
230 // track's hit_pattern was not in the JSON map and the default_scale was used.
234 // truth matching (MC only; false on data)
235 // truth_matched_out_ : hit-based majority match to an e^-/e^+ (utils::hasTruthMatch),
236 // identical definition to ele/pos_has_truth_link in the 2021 preselection.
237 // has_truth_link_out_: raw Track TRef truth link resolves to an object (no PDG requirement).
246
251
252 // z0 smearing validation histograms
256
257 // omega smearing validation histograms
258 TH1D* omega_h_; // unsmeared omega
261 TH1D* omegasmear_h_; // smeared omega (when omega smearing enabled)
264 TH2D* omega_vs_p_hh_; // omega vs momentum
265
266 // omega vs track parameters (unsmeared and smeared)
273
280
281}; // FeeAnaProcessor
282
283#endif // __FEE_ANAPROCESSOR_H__
Helper class for hipster analysis.
Class used to encapsulate event information.
Class defining methods used to access event information and data collections.
Class used to encapsulate information about a mc particle.
Class used to encapsulate information about a particle.
Base classes for all user event processing components to extend.
Class used to decode TS words.
Class used to encapsulate track information.
Class used to encapsulate tracker hit information.
bool vetoExtraClusters_
veto if extra clusters are in-time with the FEE cluster
TBranch * becalClusters_
TH2D * omegasmear_vs_phi0_bot_hh_
double run_scale_out_
data momentum scale applied to this track (1 if none); raw p = p / scale
TBranch * bfsps_
description
virtual bool process(IEvent *ievent)
Process the event and put new data products into it.
bool hitPatternScaleDataOnly_
only apply the scale on data (MC left untouched)
std::vector< CalCluster * > * ecalClusters_
std::map< int, double > hitPatternScale_
hit_pattern -> scale factor
std::string trkCollName_
Track Collection name (histo/smearing naming).
double hit_pattern_scale_out_
scale factor applied to this track's momentum
std::string selectionCfg_
std::string truthHistCfgFilename_
description
int n_tracks_intime_out_
tracks in-time with the FEE cluster
bool requireCluster_
require an associated FEE cluster passing E/time/(E/p)
double calTimeOffsetMC_
cluster-time offset subtracted before the cut (MC)
TH2D * omegasmear_vs_tanL_top_hh_
virtual void configure(const ParameterSet &parameters)
Configure the Ana Processor.
bool doTruth_
description
Track track_out_
original (unsmeared) track
double clusterTimeMax_
maximum corrected cluster time (data)
TH2D * psmear_vs_nHits_rel_hh_
virtual void finalize()
Callback for the Processor to take any necessary action when the processing of events finishes.
TH2D * omegasmear_vs_tanL_bot_hh_
std::vector< Track * > * allTracks_
TH2D * omegasmear_vs_phi0_hh_
std::map< std::string, std::shared_ptr< TrackHistos > > reg_histos_
description
bool doSmearing_
MC smearing on/off for this job.
std::vector< std::string > regionSelections_
track selections
double clusterTimeMinMC_
minimum corrected cluster time (MC)
std::vector< Particle * > * fsps_
virtual void initialize(TTree *tree)
Callback for the Processor to take any necessary action when the processing of events starts.
virtual void setFile(TFile *outFile)
Set output TFile and create the output TTree.
std::string fspCollName_
FinalStateParticle collection name.
double hitPatternDefaultScale_
fallback scale for unlisted patterns
double vetoClusterEnergyMin_
only clusters above this energy count toward the cluster veto (GeV)
std::string mcColl_
MCParticle collection name.
std::vector< MCParticle * > * mcParticles_
TH2D * omegasmear_vs_tanL_hh_
Track track_smeared_out_
smeared track (identical to track_out_ if no smearing)
bool vetoExtraTracks_
veto if extra tracks are in-time with the FEE cluster
std::string hitPatternScaleFile_
JSON of per-hit_pattern scale factors.
std::map< std::string, std::shared_ptr< TrackHistos > >::iterator reg_it
description
bool doHitPatternScale_
master switch for the hit-pattern scale correction
TBranch * bmcParticles_
EventHeader * evth_
double eop_out_
associated cluster E / track p
double clu_E_out_
associated cluster energy
double vetoTrackTimeWindow_
|t_trk - t_FEEclu(corrected)| window for the track veto (ns)
std::string histCfgFilename_
description
TrackHistos * trkHistos_
description
std::shared_ptr< TrackCorrector > corrector_
int n_hits_out_
number of tracker hits on the FEE track
FeeAnaProcessor(const std::string &name, Process &process)
Class constructor.
std::map< std::string, std::shared_ptr< BaseSelector > > reg_selectors_
description
int n_clusters_intime_out_
clusters in-time with the FEE cluster (>energy threshold)
TH2D * omegasmear_vs_phi0_top_hh_
double p_smear_ratio_out_
smeared_p / original_p (1 if no smearing)
bool hit_pattern_scale_isdefault_out_
true if the default (fallback) scale was used
double clusterTimeMin_
minimum corrected cluster time (data)
double calTimeOffset_
cluster-time offset subtracted before the cut (data)
double clu_time_out_
associated cluster time
double feeClusterEnergyMin_
time offset
double clusterTimeMaxMC_
maximum corrected cluster time (MC)
TH2D * psmear_vs_nHits_bot_rel_hh_
bool requireElectron_
require the FSP to be an electron (charge < 0)
double eopMax_
maximum cluster-energy / track-momentum (E/p)
TrackHistos * truthHistos_
description
Track track_corr_out_
momentum-scale-corrected track
int requireTruthMatch_
-1: use the JSON value; 0/1: override it
TH2D * psmear_vs_nHits_bot_hh_
std::shared_ptr< AnaHelpers > ah_
double eopMin_
minimum cluster-energy / track-momentum (E/p)
TH2D * psmear_vs_nHits_top_hh_
std::string trackCorrectionsCfg_
TrackCorrector JSON ("" = no corrections).
double vetoClusterTimeWindow_
|t_clu - t_FEEclu| window for the cluster veto (ns)
TH2D * psmear_vs_nHits_top_rel_hh_
bool requireFeeTrigger_
require the FEE trigger (TSBank FEE_Top||FEE_Bot); data only
std::vector< std::string > regions_
double mcTimeOffset_
time offset applied to MC tracks
std::shared_ptr< BaseSelector > trkSelector_
description
std::unique_ptr< TTree > output_tree_
Definition IEvent.h:7
description
Processor(const std::string &name, Process &process)
Class constructor.
Definition Processor.cxx:10
virtual bool process()
Process the histograms and generate analysis output.
Definition Processor.h:95
description
Definition TrackHistos.h:17
Definition Track.h:32