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 
29 #include <map>
30 class CaloTowerTopology;
31 class HcalTopology;
32 class CaloGeometry;
35 class CaloRecHit;
36 class DetId;
37 
43 //
44 // Modify MetaTower to save energy of rechits for use in tower 4-momentum assignment,
45 // added containers for timing assignment and for holding status information.
46 // Anton Anastassov (Northwestern)
47 //
48 
50 public:
51 
52  int nalgo=-1;
53 
55 
56  CaloTowersCreationAlgo(double EBthreshold, double EEthreshold,
57 
58  bool useEtEBTreshold, bool useEtEETreshold,
59  bool useSymEBTreshold, bool useSymEETreshold,
60 
61  double HcalThreshold,
62  double HBthreshold,
63  double HESthreshold, double HESthreshold1,
64  double HEDthreshold, double HEDthreshold1,
65  double HOthreshold0, double HOthresholdPlus1, double HOthresholdMinus1,
66  double HOthresholdPlus2, double HOthresholdMinus2,
67  double HF1threshold, double HF2threshold,
68  double EBweight, double EEweight,
69  double HBweight, double HESweight, double HEDweight,
70  double HOweight, double HF1weight, double HF2weight,
71  double EcutTower, double EBSumThreshold, double EESumThreshold, bool useHO,
72  // (for momentum reconstruction algorithm)
73  int momConstrMethod,
74  double momHBDepth,
75  double momHEDepth,
76  double momEBDepth,
77  double momEEDepth,
78  int hcalPhase=0
79  );
80 
81  CaloTowersCreationAlgo(double EBthreshold, double EEthreshold,
82 
83  bool useEtEBTreshold, bool useEtEETreshold,
84  bool useSymEBTreshold, bool useSymEETreshold,
85 
86  double HcalThreshold,
87  double HBthreshold,
88  double HESthreshold, double HESthreshold1,
89  double HEDthreshold, double HEDthreshold1,
90  double HOthreshold0, double HOthresholdPlus1, double HOthresholdMinus1,
91  double HOthresholdPlus2, double HOthresholdMinus2,
92  double HF1threshold, double HF2threshold,
93  const std::vector<double> & EBGrid, const std::vector<double> & EBWeights,
94  const std::vector<double> & EEGrid, const std::vector<double> & EEWeights,
95  const std::vector<double> & HBGrid, const std::vector<double> & HBWeights,
96  const std::vector<double> & HESGrid, const std::vector<double> & HESWeights,
97  const std::vector<double> & HEDGrid, const std::vector<double> & HEDWeights,
98  const std::vector<double> & HOGrid, const std::vector<double> & HOWeights,
99  const std::vector<double> & HF1Grid, const std::vector<double> & HF1Weights,
100  const std::vector<double> & HF2Grid, const std::vector<double> & HF2Weights,
101  double EBweight, double EEweight,
102  double HBweight, double HESweight, double HEDweight,
103  double HOweight, double HF1weight, double HF2weight,
104  double EcutTower, double EBSumThreshold, double EESumThreshold, bool useHO,
105  // (for momentum reconstruction algorithm)
106  int momConstrMethod,
107  double momHBDepth,
108  double momHEDepth,
109  double momEBDepth,
110  double momEEDepth,
111  int hcalPhase=0
112 );
113 
114  void setGeometry(const CaloTowerTopology* cttopo, const CaloTowerConstituentsMap* ctmap, const HcalTopology* htopo, const CaloGeometry* geo);
115 
116  // pass the containers of channels status from the event record (stored in DB)
117  // these are called in CaloTowersCreator
120 
121  // Kake a map of number of channels not used in RecHit production.
122  // The key is the calotower id.
123  void makeHcalDropChMap();
124 
125  void makeEcalBadChs();
126 
127  void begin();
128  void process(const HBHERecHitCollection& hbhe);
129  void process(const HORecHitCollection& ho);
130  void process(const HFRecHitCollection& hf);
131  void process(const EcalRecHitCollection& ecal);
132 
133 
134  void process(const CaloTowerCollection& ctc);
135 
136  void finish(CaloTowerCollection& destCollection);
137 
138  // modified rescale method
139  void rescaleTowers(const CaloTowerCollection& ctInput, CaloTowerCollection& ctResult);
140 
141  void setEBEScale(double scale);
142  void setEEEScale(double scale);
143  void setHBEScale(double scale);
144  void setHESEScale(double scale);
145  void setHEDEScale(double scale);
146  void setHOEScale(double scale);
147  void setHF1EScale(double scale);
148  void setHF2EScale(double scale);
149 
150 
151  // Assign to categories based on info from DB and RecHit status
152  // Called in assignHit to check if the energy should be added to
153  // calotower, and how to flag the channel
154  unsigned int hcalChanStatusForCaloTower(const CaloRecHit* hit);
155  std::tuple<unsigned int,bool> ecalChanStatusForCaloTower(const EcalRecHit* hit);
156 
157  // Channel flagging is based on acceptable severity levels specified in the
158  // configuration file. These methods are used to pass the values read in
159  // CaloTowersCreator
160  //
161  // from DB
163  void setEcalSeveritiesToBeExcluded(const std::vector<int>& ecalSev ) {theEcalSeveritiesToBeExcluded= ecalSev;}
164 
165  // flag to use recovered hits
168 
169  // severety level calculator for HCAL
171 
172  // severity level calculator for ECAL
174 
175 
176  // The following are needed for creating towers from rechits excluded from the ------------------------------------
177  // default reconstructions
178 
179  // NB! Controls if rejected hits shold be used instead of the default!!!
181 
183  // void setEcalAcceptSeverityLevelForRejectedHit(unsigned int level) {theEcalAcceptSeverityLevelForRejectedHit = level;}
184  void SetEcalSeveritiesToBeUsedInBadTowers(const std::vector<int>& ecalSev ) {theEcalSeveritiesToBeUsedInBadTowers= ecalSev;}
185 
186 
189 
190  //-------------------------------------------------------------------------------------------------------------------
191 
192 
193 
194  // set the EE EB handles
195 
198 
199 
200 
201 
202  // Add methods to get the seperate positions for ECAL/HCAL
203  // used in constructing the 4-vectors using new methods
204  GlobalPoint emCrystalShwrPos (DetId detId, float fracDepth);
205  GlobalPoint hadSegmentShwrPos(DetId detId, float fracDepth);
206  // "effective" point for the EM/HAD shower in CaloTower
207  // position based on non-zero energy cells
208  GlobalPoint hadShwrPos(const std::vector<std::pair<DetId,float> >& metaContains,
209  float fracDepth, double hadE);
210  GlobalPoint emShwrPos(const std::vector<std::pair<DetId,float> >& metaContains,
211  float fracDepth, double totEmE);
212 
213  // overloaded function to get had position based on all had cells in the tower
214  GlobalPoint hadShwrPos(CaloTowerDetId id, float fracDepth);
215  GlobalPoint hadShwPosFromCells(DetId frontCell, DetId backCell, float fracDepth);
216 
217  // for Chris
218  GlobalPoint emShwrLogWeightPos(const std::vector<std::pair<DetId,float> >& metaContains,
219  float fracDepth, double totEmE);
220 
221 
222 private:
223 
224  struct MetaTower {
226  bool empty() const { return metaConstituents.empty();}
227  // contains also energy of RecHit
228  std::vector< std::pair<DetId, float> > metaConstituents;
230  float E=0, E_em=0, E_had=0, E_outer=0;
231  float emSumTimeTimesE=0, hadSumTimeTimesE=0, emSumEForTime=0, hadSumEForTime=0; // Sum(Energy x Timing) : intermediate container
232 
233  // needed to set CaloTower status word
235 
236  };
237 
239  void assignHitEcal(const EcalRecHit* recHit);
240  void assignHitHcal(const CaloRecHit* recHit);
241 
242  void rescale(const CaloTower * ct);
243 
245  MetaTower & find(const CaloTowerDetId & id);
246 
248  void getThresholdAndWeight(const DetId & detId, double & threshold, double & weight) const;
249 
253 
254 
256 
262  std::vector<double> theEBGrid, theEBWeights;
263  std::vector<double> theEEGrid, theEEWeights;
264  std::vector<double> theHBGrid, theHBWeights;
265  std::vector<double> theHESGrid, theHESWeights;
266  std::vector<double> theHEDGrid, theHEDWeights;
267  std::vector<double> theHOGrid, theHOWeights;
268  std::vector<double> theHF1Grid, theHF1Weights;
269  std::vector<double> theHF2Grid, theHF2Weights;
273 
274  double theEBEScale;
275  double theEEEScale;
276  double theHBEScale;
277  double theHESEScale;
278  double theHEDEScale;
279  double theHOEScale;
280  double theHF1EScale;
281  double theHF2EScale;
287 
288  // for checking the status of ECAL and HCAL channels stored in the DB
291 
292  // calculator of severety level for HCAL
294 
295  // calculator for severity level for ECAL
297 
298 
299  // fields that hold the information passed from the CaloTowersCreator configuration file:
300  // controll what is considered bad/recovered/problematic channel for CaloTower purposes
301  //
304  // flag to use recovered hits
307 
308  // controls the tower reconstruction from rejected hits
309 
313 
314 
317 
318 
321 
322  // Switches and paramters for CaloTower 4-momentum assignment
323  // "depth" variables do not affect all algorithms
329 
330  // compactify timing info
331  int compactTime(float time);
332 
334 
335 
336  // internal map
337  typedef std::vector<MetaTower> MetaTowerMap;
338  MetaTowerMap theTowerMap;
339  unsigned int theTowerMapSize=0;
340 
341  // Number of channels in the tower that were not used in RecHit production (dead/off,...).
342  // These channels are added to the other "bad" channels found in the recHit collection.
343  typedef std::map<CaloTowerDetId, int> HcalDropChMap;
344  HcalDropChMap hcalDropChMap;
345 
346  // Number of bad Ecal channel in each tower
347  //unsigned short ecalBadChs[CaloTowerDetId::kSizeForDenseIndexing];
348  std::vector<unsigned short> ecalBadChs;
349 
350  // clasification of channels in tower construction: the category definition is
351  // affected by the setting in the configuration file
352  //
354 
355 
356  // the EE and EB collections for ecal anomalous cell info
357 
360 
362 
363  std::vector<HcalDetId> ids_;
364 };
365 
366 #endif
std::vector< double > theHBGrid
const EcalChannelStatus * theEcalChStatus
const HcalChannelQuality * theHcalChStatus
void setEcalChStatusFromDB(const EcalChannelStatus *s)
std::vector< std::pair< DetId, float > > metaConstituents
std::vector< double > theHESGrid
std::vector< double > theHEDGrid
GlobalPoint emCrystalShwrPos(DetId detId, float fracDepth)
void assignHitHcal(const CaloRecHit *recHit)
std::vector< int > theEcalSeveritiesToBeUsedInBadTowers
GlobalPoint emShwrPos(const std::vector< std::pair< DetId, float > > &metaContains, float fracDepth, double totEmE)
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)
GlobalPoint hadShwrPos(const std::vector< std::pair< DetId, float > > &metaContains, float fracDepth, double hadE)
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::map< CaloTowerDetId, int > HcalDropChMap
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)
GlobalPoint emShwrLogWeightPos(const std::vector< std::pair< DetId, float > > &metaContains, float fracDepth, double totEmE)
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:18
std::vector< MetaTower > MetaTowerMap
GlobalPoint hadShwPosFromCells(DetId frontCell, DetId backCell, float fracDepth)
void setRecoveredHcalHitsAreUsed(bool flag)
void getThresholdAndWeight(const DetId &detId, double &threshold, double &weight) const
helper method to look up the appropriate threshold & weight
void setUseRejectedHitsOnly(bool flag)
const HcalTopology * theHcalTopology
std::vector< int > theEcalSeveritiesToBeExcluded
std::vector< unsigned short > ecalBadChs
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)
HcalThreshold
GeV, ORCA value w/o selective readout.
std::vector< double > theEBWeights
edm::Handle< EcalRecHitCollection > theEbHandle