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 
32 
34 
35 class CaloTowerTopology;
36 class HcalTopology;
37 class CaloGeometry;
40 class CaloRecHit;
41 class DetId;
42 
48 //
49 // Modify MetaTower to save energy of rechits for use in tower 4-momentum assignment,
50 // added containers for timing assignment and for holding status information.
51 // Anton Anastassov (Northwestern)
52 //
53 
55 public:
56  int nalgo = -1;
57 
59 
60  CaloTowersCreationAlgo(double EBthreshold,
61  double EEthreshold,
62 
63  bool useEtEBTreshold,
64  bool useEtEETreshold,
65  bool useSymEBTreshold,
66  bool useSymEETreshold,
67 
68  double HcalThreshold,
69  double HBthreshold,
70  double HBthreshold1,
71  double HBthreshold2,
72  double HESthreshold,
73  double HESthreshold1,
74  double HEDthreshold,
75  double HEDthreshold1,
76  double HOthreshold0,
77  double HOthresholdPlus1,
78  double HOthresholdMinus1,
79  double HOthresholdPlus2,
80  double HOthresholdMinus2,
81  double HF1threshold,
82  double HF2threshold,
83  double EBweight,
84  double EEweight,
85  double HBweight,
86  double HESweight,
87  double HEDweight,
88  double HOweight,
89  double HF1weight,
90  double HF2weight,
91  double EcutTower,
92  double EBSumThreshold,
93  double EESumThreshold,
94  bool useHO,
95  // (for momentum reconstruction algorithm)
96  int momConstrMethod,
97  double momHBDepth,
98  double momHEDepth,
99  double momEBDepth,
100  double momEEDepth,
101  int hcalPhase = 0);
102 
103  CaloTowersCreationAlgo(double EBthreshold,
104  double EEthreshold,
105 
106  bool useEtEBTreshold,
107  bool useEtEETreshold,
108  bool useSymEBTreshold,
109  bool useSymEETreshold,
110 
111  double HcalThreshold,
112  double HBthreshold,
113  double HBthreshold1,
114  double HBthreshold2,
115  double HESthreshold,
116  double HESthreshold1,
117  double HEDthreshold,
118  double HEDthreshold1,
119  double HOthreshold0,
120  double HOthresholdPlus1,
121  double HOthresholdMinus1,
122  double HOthresholdPlus2,
123  double HOthresholdMinus2,
124  double HF1threshold,
125  double HF2threshold,
126  const std::vector<double>& EBGrid,
127  const std::vector<double>& EBWeights,
128  const std::vector<double>& EEGrid,
129  const std::vector<double>& EEWeights,
130  const std::vector<double>& HBGrid,
131  const std::vector<double>& HBWeights,
132  const std::vector<double>& HESGrid,
133  const std::vector<double>& HESWeights,
134  const std::vector<double>& HEDGrid,
135  const std::vector<double>& HEDWeights,
136  const std::vector<double>& HOGrid,
137  const std::vector<double>& HOWeights,
138  const std::vector<double>& HF1Grid,
139  const std::vector<double>& HF1Weights,
140  const std::vector<double>& HF2Grid,
141  const std::vector<double>& HF2Weights,
142  double EBweight,
143  double EEweight,
144  double HBweight,
145  double HESweight,
146  double HEDweight,
147  double HOweight,
148  double HF1weight,
149  double HF2weight,
150  double EcutTower,
151  double EBSumThreshold,
152  double EESumThreshold,
153  bool useHO,
154  // (for momentum reconstruction algorithm)
155  int momConstrMethod,
156  double momHBDepth,
157  double momHEDepth,
158  double momEBDepth,
159  double momEEDepth,
160  int hcalPhase = 0);
161 
162  void setGeometry(const CaloTowerTopology* cttopo,
163  const CaloTowerConstituentsMap* ctmap,
164  const HcalTopology* htopo,
165  const CaloGeometry* geo);
166 
167  void setThresFromDB(const EcalPFRecHitThresholds* EcalCuts, const HcalPFCuts* HcalCuts);
168  // pass the containers of channels status from the event record (stored in DB)
169  // these are called in CaloTowersCreator
172 
173  // Kake a map of number of channels not used in RecHit production.
174  // The key is the calotower id.
175  void makeHcalDropChMap();
176 
177  void makeEcalBadChs();
178 
179  void begin();
180  void process(const HBHERecHitCollection& hbhe);
181  void process(const HORecHitCollection& ho);
182  void process(const HFRecHitCollection& hf);
183  void process(const EcalRecHitCollection& ecal);
184 
185  void process(const CaloTowerCollection& ctc);
186 
187  void finish(CaloTowerCollection& destCollection);
188 
189  // modified rescale method
190  void rescaleTowers(const CaloTowerCollection& ctInput, CaloTowerCollection& ctResult);
191 
192  void setEBEScale(double scale);
193  void setEEEScale(double scale);
194  void setHBEScale(double scale);
195  void setHESEScale(double scale);
196  void setHEDEScale(double scale);
197  void setHOEScale(double scale);
198  void setHF1EScale(double scale);
199  void setHF2EScale(double scale);
200 
201  // Assign to categories based on info from DB and RecHit status
202  // Called in assignHit to check if the energy should be added to
203  // calotower, and how to flag the channel
204  unsigned int hcalChanStatusForCaloTower(const CaloRecHit* hit);
205  std::tuple<unsigned int, bool> ecalChanStatusForCaloTower(const EcalRecHit* hit);
206 
207  // Channel flagging is based on acceptable severity levels specified in the
208  // configuration file. These methods are used to pass the values read in
209  // CaloTowersCreator
210  //
211  // from DB
213  void setEcalSeveritiesToBeExcluded(const std::vector<int>& ecalSev) { theEcalSeveritiesToBeExcluded = ecalSev; }
214 
215  // flag to use recovered hits
218 
219  // severety level calculator for HCAL
221 
222  // severity level calculator for ECAL
224 
225  // The following are needed for creating towers from rechits excluded from the ------------------------------------
226  // default reconstructions
227 
228  // NB! Controls if rejected hits shold be used instead of the default!!!
230 
233  }
234  // void setEcalAcceptSeverityLevelForRejectedHit(unsigned int level) {theEcalAcceptSeverityLevelForRejectedHit = level;}
235  void SetEcalSeveritiesToBeUsedInBadTowers(const std::vector<int>& ecalSev) {
237  }
238 
242 
243  //-------------------------------------------------------------------------------------------------------------------
244 
245  // set the EE EB handles
246 
249 
250  // Add methods to get the seperate positions for ECAL/HCAL
251  // used in constructing the 4-vectors using new methods
252  GlobalPoint emCrystalShwrPos(DetId detId, float fracDepth);
253  GlobalPoint hadSegmentShwrPos(DetId detId, float fracDepth);
254  // "effective" point for the EM/HAD shower in CaloTower
255  // position based on non-zero energy cells
256  GlobalPoint hadShwrPos(const std::vector<std::pair<DetId, float>>& metaContains, float fracDepth, double hadE);
257  GlobalPoint emShwrPos(const std::vector<std::pair<DetId, float>>& metaContains, float fracDepth, double totEmE);
258 
259  // overloaded function to get had position based on all had cells in the tower
260  GlobalPoint hadShwrPos(CaloTowerDetId id, float fracDepth);
261  GlobalPoint hadShwPosFromCells(DetId frontCell, DetId backCell, float fracDepth);
262 
263  // for Chris
264  GlobalPoint emShwrLogWeightPos(const std::vector<std::pair<DetId, float>>& metaContains,
265  float fracDepth,
266  double totEmE);
267 
268 private:
269  struct MetaTower {
271  bool empty() const { return metaConstituents.empty(); }
272  // contains also energy of RecHit
273  std::vector<std::pair<DetId, float>> metaConstituents;
275  float E = 0, E_em = 0, E_had = 0, E_outer = 0;
277  hadSumEForTime = 0; // Sum(Energy x Timing) : intermediate container
278 
279  // needed to set CaloTower status word
282  };
283 
285  void assignHitEcal(const EcalRecHit* recHit);
286  void assignHitHcal(const CaloRecHit* recHit);
287 
288  void rescale(const CaloTower* ct);
289 
291  MetaTower& find(const CaloTowerDetId& id);
292 
294  void getThresholdAndWeight(const DetId& detId, double& threshold, double& weight) const;
295 
299 
301 
307  std::vector<double> theEBGrid, theEBWeights;
308  std::vector<double> theEEGrid, theEEWeights;
309  std::vector<double> theHBGrid, theHBWeights;
310  std::vector<double> theHESGrid, theHESWeights;
311  std::vector<double> theHEDGrid, theHEDWeights;
312  std::vector<double> theHOGrid, theHOWeights;
313  std::vector<double> theHF1Grid, theHF1Weights;
314  std::vector<double> theHF2Grid, theHF2Weights;
318 
319  double theEBEScale;
320  double theEEEScale;
321  double theHBEScale;
322  double theHESEScale;
323  double theHEDEScale;
324  double theHOEScale;
325  double theHF1EScale;
326  double theHF2EScale;
334 
335  // for checking the status of ECAL and HCAL channels stored in the DB
338 
339  // calculator of severety level for HCAL
341 
342  // calculator for severity level for ECAL
344 
345  // fields that hold the information passed from the CaloTowersCreator configuration file:
346  // controll what is considered bad/recovered/problematic channel for CaloTower purposes
347  //
350  // flag to use recovered hits
353 
354  // controls the tower reconstruction from rejected hits
355 
359 
362 
363  // if Hcal is missing, fudge it scaling Ecal by this factor (if > 0)
365 
368 
369  // Switches and paramters for CaloTower 4-momentum assignment
370  // "depth" variables do not affect all algorithms
376 
377  // compactify timing info
378  int compactTime(float time);
379 
381 
382  // internal map
383  typedef std::vector<MetaTower> MetaTowerMap;
385  unsigned int theTowerMapSize = 0;
386 
387  // Number of channels in the tower that were not used in RecHit production (dead/off,...).
388  // These channels are added to the other "bad" channels found in the recHit collection.
389  typedef std::map<CaloTowerDetId, std::pair<short int, bool>> HcalDropChMap;
391 
392  // Number of bad Ecal channel in each tower
393  //unsigned short ecalBadChs[CaloTowerDetId::kSizeForDenseIndexing];
394  std::vector<unsigned short> ecalBadChs;
395 
396  // clasification of channels in tower construction: the category definition is
397  // affected by the setting in the configuration file
398  //
400 
401  // the EE and EB collections for ecal anomalous cell info
402 
405 
407 
408  std::vector<HcalDetId> ids_;
409 };
410 
411 #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)
const EcalPFRecHitThresholds * ecalCuts
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
void setThresFromDB(const EcalPFRecHitThresholds *EcalCuts, const HcalPFCuts *HcalCuts)
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:121
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)