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