CMS 3D CMS Logo

CaloTowersCreationAlgo.h
Go to the documentation of this file.
1 #ifndef RECOLOCALCALO_CALOTOWERSCREATOR_CALOTOWERSCREATIONALGO_H
2 #define RECOLOCALCALO_CALOTOWERSCREATOR_CALOTOWERSCREATIONALGO_H 1
3 
9 
10 // channel status
13 
16 
17 // severity level assignment for HCAL
20 
21 // severity level assignment for ECAL
23 
24 // need if we want to store the handles
26 #include <tuple>
27 
28 #include <map>
29 class CaloTowerTopology;
30 class HcalTopology;
31 class CaloGeometry;
34 class CaloRecHit;
35 class DetId;
36 
42 //
43 // Modify MetaTower to save energy of rechits for use in tower 4-momentum assignment,
44 // added containers for timing assignment and for holding status information.
45 // Anton Anastassov (Northwestern)
46 //
47 
49 public:
50  int nalgo = -1;
51 
53 
54  CaloTowersCreationAlgo(double EBthreshold,
55  double EEthreshold,
56 
57  bool useEtEBTreshold,
58  bool useEtEETreshold,
59  bool useSymEBTreshold,
60  bool useSymEETreshold,
61 
62  double HcalThreshold,
63  double HBthreshold,
64  double HBthreshold1,
65  double HBthreshold2,
66  double HESthreshold,
67  double HESthreshold1,
68  double HEDthreshold,
69  double HEDthreshold1,
70  double HOthreshold0,
71  double HOthresholdPlus1,
72  double HOthresholdMinus1,
73  double HOthresholdPlus2,
74  double HOthresholdMinus2,
75  double HF1threshold,
76  double HF2threshold,
77  double EBweight,
78  double EEweight,
79  double HBweight,
80  double HESweight,
81  double HEDweight,
82  double HOweight,
83  double HF1weight,
84  double HF2weight,
85  double EcutTower,
86  double EBSumThreshold,
87  double EESumThreshold,
88  bool useHO,
89  // (for momentum reconstruction algorithm)
90  int momConstrMethod,
91  double momHBDepth,
92  double momHEDepth,
93  double momEBDepth,
94  double momEEDepth,
95  int hcalPhase = 0);
96 
97  CaloTowersCreationAlgo(double EBthreshold,
98  double EEthreshold,
99 
100  bool useEtEBTreshold,
101  bool useEtEETreshold,
102  bool useSymEBTreshold,
103  bool useSymEETreshold,
104 
105  double HcalThreshold,
106  double HBthreshold,
107  double HBthreshold1,
108  double HBthreshold2,
109  double HESthreshold,
110  double HESthreshold1,
111  double HEDthreshold,
112  double HEDthreshold1,
113  double HOthreshold0,
114  double HOthresholdPlus1,
115  double HOthresholdMinus1,
116  double HOthresholdPlus2,
117  double HOthresholdMinus2,
118  double HF1threshold,
119  double HF2threshold,
120  const std::vector<double>& EBGrid,
121  const std::vector<double>& EBWeights,
122  const std::vector<double>& EEGrid,
123  const std::vector<double>& EEWeights,
124  const std::vector<double>& HBGrid,
125  const std::vector<double>& HBWeights,
126  const std::vector<double>& HESGrid,
127  const std::vector<double>& HESWeights,
128  const std::vector<double>& HEDGrid,
129  const std::vector<double>& HEDWeights,
130  const std::vector<double>& HOGrid,
131  const std::vector<double>& HOWeights,
132  const std::vector<double>& HF1Grid,
133  const std::vector<double>& HF1Weights,
134  const std::vector<double>& HF2Grid,
135  const std::vector<double>& HF2Weights,
136  double EBweight,
137  double EEweight,
138  double HBweight,
139  double HESweight,
140  double HEDweight,
141  double HOweight,
142  double HF1weight,
143  double HF2weight,
144  double EcutTower,
145  double EBSumThreshold,
146  double EESumThreshold,
147  bool useHO,
148  // (for momentum reconstruction algorithm)
149  int momConstrMethod,
150  double momHBDepth,
151  double momHEDepth,
152  double momEBDepth,
153  double momEEDepth,
154  int hcalPhase = 0);
155 
156  void setGeometry(const CaloTowerTopology* cttopo,
157  const CaloTowerConstituentsMap* ctmap,
158  const HcalTopology* htopo,
159  const CaloGeometry* geo);
160 
161  // pass the containers of channels status from the event record (stored in DB)
162  // these are called in CaloTowersCreator
165 
166  // Kake a map of number of channels not used in RecHit production.
167  // The key is the calotower id.
168  void makeHcalDropChMap();
169 
170  void makeEcalBadChs();
171 
172  void begin();
173  void process(const HBHERecHitCollection& hbhe);
174  void process(const HORecHitCollection& ho);
175  void process(const HFRecHitCollection& hf);
176  void process(const EcalRecHitCollection& ecal);
177 
178  void process(const CaloTowerCollection& ctc);
179 
180  void finish(CaloTowerCollection& destCollection);
181 
182  // modified rescale method
183  void rescaleTowers(const CaloTowerCollection& ctInput, CaloTowerCollection& ctResult);
184 
185  void setEBEScale(double scale);
186  void setEEEScale(double scale);
187  void setHBEScale(double scale);
188  void setHESEScale(double scale);
189  void setHEDEScale(double scale);
190  void setHOEScale(double scale);
191  void setHF1EScale(double scale);
192  void setHF2EScale(double scale);
193 
194  // Assign to categories based on info from DB and RecHit status
195  // Called in assignHit to check if the energy should be added to
196  // calotower, and how to flag the channel
197  unsigned int hcalChanStatusForCaloTower(const CaloRecHit* hit);
198  std::tuple<unsigned int, bool> ecalChanStatusForCaloTower(const EcalRecHit* hit);
199 
200  // Channel flagging is based on acceptable severity levels specified in the
201  // configuration file. These methods are used to pass the values read in
202  // CaloTowersCreator
203  //
204  // from DB
206  void setEcalSeveritiesToBeExcluded(const std::vector<int>& ecalSev) { theEcalSeveritiesToBeExcluded = ecalSev; }
207 
208  // flag to use recovered hits
211 
212  // severety level calculator for HCAL
214 
215  // severity level calculator for ECAL
217 
218  // The following are needed for creating towers from rechits excluded from the ------------------------------------
219  // default reconstructions
220 
221  // NB! Controls if rejected hits shold be used instead of the default!!!
223 
226  }
227  // void setEcalAcceptSeverityLevelForRejectedHit(unsigned int level) {theEcalAcceptSeverityLevelForRejectedHit = level;}
228  void SetEcalSeveritiesToBeUsedInBadTowers(const std::vector<int>& ecalSev) {
230  }
231 
235 
236  //-------------------------------------------------------------------------------------------------------------------
237 
238  // set the EE EB handles
239 
242 
243  // Add methods to get the seperate positions for ECAL/HCAL
244  // used in constructing the 4-vectors using new methods
245  GlobalPoint emCrystalShwrPos(DetId detId, float fracDepth);
246  GlobalPoint hadSegmentShwrPos(DetId detId, float fracDepth);
247  // "effective" point for the EM/HAD shower in CaloTower
248  // position based on non-zero energy cells
249  GlobalPoint hadShwrPos(const std::vector<std::pair<DetId, float>>& metaContains, float fracDepth, double hadE);
250  GlobalPoint emShwrPos(const std::vector<std::pair<DetId, float>>& metaContains, float fracDepth, double totEmE);
251 
252  // overloaded function to get had position based on all had cells in the tower
253  GlobalPoint hadShwrPos(CaloTowerDetId id, float fracDepth);
254  GlobalPoint hadShwPosFromCells(DetId frontCell, DetId backCell, float fracDepth);
255 
256  // for Chris
257  GlobalPoint emShwrLogWeightPos(const std::vector<std::pair<DetId, float>>& metaContains,
258  float fracDepth,
259  double totEmE);
260 
261 private:
262  struct MetaTower {
264  bool empty() const { return metaConstituents.empty(); }
265  // contains also energy of RecHit
266  std::vector<std::pair<DetId, float>> metaConstituents;
268  float E = 0, E_em = 0, E_had = 0, E_outer = 0;
270  hadSumEForTime = 0; // Sum(Energy x Timing) : intermediate container
271 
272  // needed to set CaloTower status word
275  };
276 
278  void assignHitEcal(const EcalRecHit* recHit);
279  void assignHitHcal(const CaloRecHit* recHit);
280 
281  void rescale(const CaloTower* ct);
282 
284  MetaTower& find(const CaloTowerDetId& id);
285 
287  void getThresholdAndWeight(const DetId& detId, double& threshold, double& weight) const;
288 
292 
294 
300  std::vector<double> theEBGrid, theEBWeights;
301  std::vector<double> theEEGrid, theEEWeights;
302  std::vector<double> theHBGrid, theHBWeights;
303  std::vector<double> theHESGrid, theHESWeights;
304  std::vector<double> theHEDGrid, theHEDWeights;
305  std::vector<double> theHOGrid, theHOWeights;
306  std::vector<double> theHF1Grid, theHF1Weights;
307  std::vector<double> theHF2Grid, theHF2Weights;
311 
312  double theEBEScale;
313  double theEEEScale;
314  double theHBEScale;
315  double theHESEScale;
316  double theHEDEScale;
317  double theHOEScale;
318  double theHF1EScale;
319  double theHF2EScale;
325 
326  // for checking the status of ECAL and HCAL channels stored in the DB
329 
330  // calculator of severety level for HCAL
332 
333  // calculator for severity level for ECAL
335 
336  // fields that hold the information passed from the CaloTowersCreator configuration file:
337  // controll what is considered bad/recovered/problematic channel for CaloTower purposes
338  //
341  // flag to use recovered hits
344 
345  // controls the tower reconstruction from rejected hits
346 
350 
353 
354  // if Hcal is missing, fudge it scaling Ecal by this factor (if > 0)
356 
359 
360  // Switches and paramters for CaloTower 4-momentum assignment
361  // "depth" variables do not affect all algorithms
367 
368  // compactify timing info
369  int compactTime(float time);
370 
372 
373  // internal map
374  typedef std::vector<MetaTower> MetaTowerMap;
376  unsigned int theTowerMapSize = 0;
377 
378  // Number of channels in the tower that were not used in RecHit production (dead/off,...).
379  // These channels are added to the other "bad" channels found in the recHit collection.
380  typedef std::map<CaloTowerDetId, std::pair<short int, bool>> HcalDropChMap;
382 
383  // Number of bad Ecal channel in each tower
384  //unsigned short ecalBadChs[CaloTowerDetId::kSizeForDenseIndexing];
385  std::vector<unsigned short> ecalBadChs;
386 
387  // clasification of channels in tower construction: the category definition is
388  // affected by the setting in the configuration file
389  //
391 
392  // the EE and EB collections for ecal anomalous cell info
393 
396 
398 
399  std::vector<HcalDetId> ids_;
400 };
401 
402 #endif
std::vector< double > theHBGrid
const EcalChannelStatus * theEcalChStatus
const HcalChannelQuality * theHcalChStatus
void setEcalChStatusFromDB(const EcalChannelStatus *s)
std::vector< std::pair< DetId, float > > metaConstituents
void getThresholdAndWeight(const DetId &detId, double &threshold, double &weight) const
helper method to look up the appropriate threshold & weight
std::vector< double > theHESGrid
std::vector< double > theHEDGrid
GlobalPoint emCrystalShwrPos(DetId detId, float fracDepth)
void assignHitHcal(const CaloRecHit *recHit)
std::vector< int > theEcalSeveritiesToBeUsedInBadTowers
void setHcalChStatusFromDB(const HcalChannelQuality *s)
std::vector< HcalDetId > ids_
Definition: weight.py:1
void finish(CaloTowerCollection &destCollection)
void setEeHandle(const edm::Handle< EcalRecHitCollection > ee)
edm::Handle< EcalRecHitCollection > theEeHandle
std::vector< double > theHOWeights
MetaTower & find(const CaloTowerDetId &id)
looks for a given tower in the internal cache. If it can&#39;t find it, it makes it.
std::vector< double > theEEGrid
void rescale(const CaloTower *ct)
std::vector< double > theEEWeights
std::vector< double > theHESWeights
void setGeometry(const CaloTowerTopology *cttopo, const CaloTowerConstituentsMap *ctmap, const HcalTopology *htopo, const CaloGeometry *geo)
void setEbHandle(const edm::Handle< EcalRecHitCollection > eb)
const CaloSubdetectorGeometry * theTowerGeometry
void setUseRejectedRecoveredEcalHits(bool flag)
unsigned int hcalChanStatusForCaloTower(const CaloRecHit *hit)
std::vector< double > theHF2Grid
std::vector< double > theHEDWeights
void rescaleTowers(const CaloTowerCollection &ctInput, CaloTowerCollection &ctResult)
const CaloGeometry * theGeometry
void setEcalSeveritiesToBeExcluded(const std::vector< int > &ecalSev)
void setHcalAcceptSeverityLevelForRejectedHit(unsigned int level)
void setHcalSevLvlComputer(const HcalSeverityLevelComputer *c)
std::vector< double > theHOGrid
void assignHitEcal(const EcalRecHit *recHit)
adds a single hit to the tower
const CaloTowerConstituentsMap * theTowerConstituentsMap
void convert(const CaloTowerDetId &id, const MetaTower &mt, CaloTowerCollection &collection)
const CaloTowerTopology * theTowerTopology
void SetEcalSeveritiesToBeUsedInBadTowers(const std::vector< int > &ecalSev)
std::vector< double > theHF1Weights
void setRecoveredEcalHitsAreUsed(bool flag)
GlobalPoint hadSegmentShwrPos(DetId detId, float fracDepth)
bool theHOIsUsed
only affects energy and ET calculation. HO is still recorded in the tower
void process(const HBHERecHitCollection &hbhe)
std::vector< double > theHBWeights
const HcalSeverityLevelComputer * theHcalSevLvlComputer
Definition: DetId.h:17
GlobalPoint hadShwrPos(const std::vector< std::pair< DetId, float >> &metaContains, float fracDepth, double hadE)
std::vector< MetaTower > MetaTowerMap
GlobalPoint hadShwPosFromCells(DetId frontCell, DetId backCell, float fracDepth)
void setRecoveredHcalHitsAreUsed(bool flag)
void setUseRejectedHitsOnly(bool flag)
const HcalTopology * theHcalTopology
void setMissingHcalRescaleFactorForEcal(float factor)
std::vector< int > theEcalSeveritiesToBeExcluded
std::vector< unsigned short > ecalBadChs
std::map< CaloTowerDetId, std::pair< short int, bool > > HcalDropChMap
GlobalPoint emShwrPos(const std::vector< std::pair< DetId, float >> &metaContains, float fracDepth, double totEmE)
const EcalSeverityLevelAlgo * theEcalSevLvlAlgo
double a
Definition: hdecay.h:119
void setHcalAcceptSeverityLevel(unsigned int level)
std::vector< double > theHF1Grid
std::vector< double > theEBGrid
std::vector< double > theHF2Weights
void setEcalSevLvlAlgo(const EcalSeverityLevelAlgo *a)
void setUseRejectedRecoveredHcalHits(bool flag)
unsigned int theHcalAcceptSeverityLevelForRejectedHit
std::tuple< unsigned int, bool > ecalChanStatusForCaloTower(const EcalRecHit *hit)
std::vector< double > theEBWeights
edm::Handle< EcalRecHitCollection > theEbHandle
GlobalPoint emShwrLogWeightPos(const std::vector< std::pair< DetId, float >> &metaContains, float fracDepth, double totEmE)