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  bool hcalCollapsed=false
80  );
81 
82  CaloTowersCreationAlgo(double EBthreshold, double EEthreshold,
83 
84  bool useEtEBTreshold, bool useEtEETreshold,
85  bool useSymEBTreshold, bool useSymEETreshold,
86 
87  double HcalThreshold,
88  double HBthreshold,
89  double HESthreshold, double HESthreshold1,
90  double HEDthreshold, double HEDthreshold1,
91  double HOthreshold0, double HOthresholdPlus1, double HOthresholdMinus1,
92  double HOthresholdPlus2, double HOthresholdMinus2,
93  double HF1threshold, double HF2threshold,
94  const std::vector<double> & EBGrid, const std::vector<double> & EBWeights,
95  const std::vector<double> & EEGrid, const std::vector<double> & EEWeights,
96  const std::vector<double> & HBGrid, const std::vector<double> & HBWeights,
97  const std::vector<double> & HESGrid, const std::vector<double> & HESWeights,
98  const std::vector<double> & HEDGrid, const std::vector<double> & HEDWeights,
99  const std::vector<double> & HOGrid, const std::vector<double> & HOWeights,
100  const std::vector<double> & HF1Grid, const std::vector<double> & HF1Weights,
101  const std::vector<double> & HF2Grid, const std::vector<double> & HF2Weights,
102  double EBweight, double EEweight,
103  double HBweight, double HESweight, double HEDweight,
104  double HOweight, double HF1weight, double HF2weight,
105  double EcutTower, double EBSumThreshold, double EESumThreshold, bool useHO,
106  // (for momentum reconstruction algorithm)
107  int momConstrMethod,
108  double momHBDepth,
109  double momHEDepth,
110  double momEBDepth,
111  double momEEDepth,
112  int hcalPhase=0,
113  bool hcalCollapsed=false
114 );
115 
116  void setGeometry(const CaloTowerTopology* cttopo, const CaloTowerConstituentsMap* ctmap, const HcalTopology* htopo, const CaloGeometry* geo);
117 
118  // pass the containers of channels status from the event record (stored in DB)
119  // these are called in CaloTowersCreator
122 
123  // Kake a map of number of channels not used in RecHit production.
124  // The key is the calotower id.
125  void makeHcalDropChMap();
126 
127  void makeEcalBadChs();
128 
129  void begin();
130  void process(const HBHERecHitCollection& hbhe);
131  void process(const HORecHitCollection& ho);
132  void process(const HFRecHitCollection& hf);
133  void process(const EcalRecHitCollection& ecal);
134 
135 
136  void process(const CaloTowerCollection& ctc);
137 
138  void finish(CaloTowerCollection& destCollection);
139 
140  // modified rescale method
141  void rescaleTowers(const CaloTowerCollection& ctInput, CaloTowerCollection& ctResult);
142 
143  void setEBEScale(double scale);
144  void setEEEScale(double scale);
145  void setHBEScale(double scale);
146  void setHESEScale(double scale);
147  void setHEDEScale(double scale);
148  void setHOEScale(double scale);
149  void setHF1EScale(double scale);
150  void setHF2EScale(double scale);
151 
152 
153  // Assign to categories based on info from DB and RecHit status
154  // Called in assignHit to check if the energy should be added to
155  // calotower, and how to flag the channel
156  unsigned int hcalChanStatusForCaloTower(const CaloRecHit* hit);
157  std::tuple<unsigned int,bool> ecalChanStatusForCaloTower(const EcalRecHit* hit);
158 
159  // Channel flagging is based on acceptable severity levels specified in the
160  // configuration file. These methods are used to pass the values read in
161  // CaloTowersCreator
162  //
163  // from DB
165  void setEcalSeveritiesToBeExcluded(const std::vector<int>& ecalSev ) {theEcalSeveritiesToBeExcluded= ecalSev;}
166 
167  // flag to use recovered hits
170 
171  // severety level calculator for HCAL
173 
174  // severity level calculator for ECAL
176 
177 
178  // The following are needed for creating towers from rechits excluded from the ------------------------------------
179  // default reconstructions
180 
181  // NB! Controls if rejected hits shold be used instead of the default!!!
183 
185  // void setEcalAcceptSeverityLevelForRejectedHit(unsigned int level) {theEcalAcceptSeverityLevelForRejectedHit = level;}
186  void SetEcalSeveritiesToBeUsedInBadTowers(const std::vector<int>& ecalSev ) {theEcalSeveritiesToBeUsedInBadTowers= ecalSev;}
187 
188 
191 
192  //-------------------------------------------------------------------------------------------------------------------
193 
194 
195 
196  // set the EE EB handles
197 
200 
201 
202 
203 
204  // Add methods to get the seperate positions for ECAL/HCAL
205  // used in constructing the 4-vectors using new methods
206  GlobalPoint emCrystalShwrPos (DetId detId, float fracDepth);
207  GlobalPoint hadSegmentShwrPos(DetId detId, float fracDepth);
208  // "effective" point for the EM/HAD shower in CaloTower
209  // position based on non-zero energy cells
210  GlobalPoint hadShwrPos(const std::vector<std::pair<DetId,float> >& metaContains,
211  float fracDepth, double hadE);
212  GlobalPoint emShwrPos(const std::vector<std::pair<DetId,float> >& metaContains,
213  float fracDepth, double totEmE);
214 
215  // overloaded function to get had position based on all had cells in the tower
216  GlobalPoint hadShwrPos(CaloTowerDetId id, float fracDepth);
217  GlobalPoint hadShwPosFromCells(DetId frontCell, DetId backCell, float fracDepth);
218 
219  // for Chris
220  GlobalPoint emShwrLogWeightPos(const std::vector<std::pair<DetId,float> >& metaContains,
221  float fracDepth, double totEmE);
222 
223 
224 private:
225 
226  struct MetaTower {
228  bool empty() const { return metaConstituents.empty();}
229  // contains also energy of RecHit
230  std::vector< std::pair<DetId, float> > metaConstituents;
232  float E=0, E_em=0, E_had=0, E_outer=0;
233  float emSumTimeTimesE=0, hadSumTimeTimesE=0, emSumEForTime=0, hadSumEForTime=0; // Sum(Energy x Timing) : intermediate container
234 
235  // needed to set CaloTower status word
237 
238  };
239 
241  void assignHitEcal(const EcalRecHit* recHit);
242  void assignHitHcal(const CaloRecHit* recHit);
243 
244  void rescale(const CaloTower * ct);
245 
247  MetaTower & find(const CaloTowerDetId & id);
248 
250  void getThresholdAndWeight(const DetId & detId, double & threshold, double & weight) const;
251 
252  // wrapper for HcalTopology method
253  bool mergedDepth29(HcalDetId id) const;
254 
258 
259 
261 
267  std::vector<double> theEBGrid, theEBWeights;
268  std::vector<double> theEEGrid, theEEWeights;
269  std::vector<double> theHBGrid, theHBWeights;
270  std::vector<double> theHESGrid, theHESWeights;
271  std::vector<double> theHEDGrid, theHEDWeights;
272  std::vector<double> theHOGrid, theHOWeights;
273  std::vector<double> theHF1Grid, theHF1Weights;
274  std::vector<double> theHF2Grid, theHF2Weights;
278 
279  double theEBEScale;
280  double theEEEScale;
281  double theHBEScale;
282  double theHESEScale;
283  double theHEDEScale;
284  double theHOEScale;
285  double theHF1EScale;
286  double theHF2EScale;
292 
293  // for checking the status of ECAL and HCAL channels stored in the DB
296 
297  // calculator of severety level for HCAL
299 
300  // calculator for severity level for ECAL
302 
303 
304  // fields that hold the information passed from the CaloTowersCreator configuration file:
305  // controll what is considered bad/recovered/problematic channel for CaloTower purposes
306  //
309  // flag to use recovered hits
312 
313  // controls the tower reconstruction from rejected hits
314 
318 
319 
322 
323 
326 
327  // Switches and paramters for CaloTower 4-momentum assignment
328  // "depth" variables do not affect all algorithms
334 
335  // compactify timing info
336  int compactTime(float time);
337 
339 
340 
341  // internal map
342  typedef std::vector<MetaTower> MetaTowerMap;
343  MetaTowerMap theTowerMap;
344  unsigned int theTowerMapSize=0;
345 
346  // Number of channels in the tower that were not used in RecHit production (dead/off,...).
347  // These channels are added to the other "bad" channels found in the recHit collection.
348  typedef std::map<CaloTowerDetId, int> HcalDropChMap;
349  HcalDropChMap hcalDropChMap;
350 
351  // Number of bad Ecal channel in each tower
352  //unsigned short ecalBadChs[CaloTowerDetId::kSizeForDenseIndexing];
353  std::vector<unsigned short> ecalBadChs;
354 
355  // clasification of channels in tower construction: the category definition is
356  // affected by the setting in the configuration file
357  //
359 
360 
361  // the EE and EB collections for ecal anomalous cell info
362 
365 
368 
369  std::vector<HcalDetId> ids_;
370 };
371 
372 #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)
bool mergedDepth29(HcalDetId id) const
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