CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
27 
28 #include <map>
29 class HcalTopology;
30 class CaloGeometry;
33 class CaloRecHit;
34 class DetId;
35 
41 //
42 // Modify MetaTower to save energy of rechits for use in tower 4-momentum assignment,
43 // added containers for timing assignment and for holding status information.
44 // Anton Anastassov (Northwestern)
45 //
46 
48 public:
50 
51  CaloTowersCreationAlgo(double EBthreshold, double EEthreshold,
52 
53  bool useEtEBTreshold, bool useEtEETreshold,
54  bool useSymEBTreshold, bool useSymEETreshold,
55 
56  double HcalThreshold,
57  double HBthreshold, double HESthreshold, double HEDthreshold,
58  double HOthreshold0, double HOthresholdPlus1, double HOthresholdMinus1,
59  double HOthresholdPlus2, double HOthresholdMinus2,
60  double HF1threshold, double HF2threshold,
61  double EBweight, double EEweight,
62  double HBweight, double HESweight, double HEDweight,
63  double HOweight, double HF1weight, double HF2weight,
64  double EcutTower, double EBSumThreshold, double EESumThreshold, bool useHO,
65  // (for momentum reconstruction algorithm)
66  int momConstrMethod,
67  double momHBDepth,
68  double momHEDepth,
69  double momEBDepth,
70  double momEEDepth
71  );
72 
73  CaloTowersCreationAlgo(double EBthreshold, double EEthreshold,
74 
75  bool useEtEBTreshold, bool useEtEETreshold,
76  bool useSymEBTreshold, bool useSymEETreshold,
77 
78  double HcalThreshold,
79  double HBthreshold, double HESthreshold, double HEDthreshold,
80  double HOthreshold0, double HOthresholdPlus1, double HOthresholdMinus1,
81  double HOthresholdPlus2, double HOthresholdMinus2,
82  double HF1threshold, double HF2threshold,
83  const std::vector<double> & EBGrid, const std::vector<double> & EBWeights,
84  const std::vector<double> & EEGrid, const std::vector<double> & EEWeights,
85  const std::vector<double> & HBGrid, const std::vector<double> & HBWeights,
86  const std::vector<double> & HESGrid, const std::vector<double> & HESWeights,
87  const std::vector<double> & HEDGrid, const std::vector<double> & HEDWeights,
88  const std::vector<double> & HOGrid, const std::vector<double> & HOWeights,
89  const std::vector<double> & HF1Grid, const std::vector<double> & HF1Weights,
90  const std::vector<double> & HF2Grid, const std::vector<double> & HF2Weights,
91  double EBweight, double EEweight,
92  double HBweight, double HESweight, double HEDweight,
93  double HOweight, double HF1weight, double HF2weight,
94  double EcutTower, double EBSumThreshold, double EESumThreshold, bool useHO,
95  // (for momentum reconstruction algorithm)
96  int momConstrMethod,
97  double momHBDepth,
98  double momHEDepth,
99  double momEBDepth,
100  double momEEDepth
101 );
102 
103  void setGeometry(const CaloTowerConstituentsMap* cttopo, const HcalTopology* htopo, const CaloGeometry* geo);
104 
105  // pass the containers of channels status from the event record (stored in DB)
106  // these are called in CaloTowersCreator
109 
110  // Kake a map of number of channels not used in RecHit production.
111  // The key is the calotower id.
112  void makeHcalDropChMap();
113 
114  void begin();
115  void process(const HBHERecHitCollection& hbhe);
116  void process(const HORecHitCollection& ho);
117  void process(const HFRecHitCollection& hf);
118  void process(const EcalRecHitCollection& ecal);
119 
120 
121  void process(const CaloTowerCollection& ctc);
122 
123  void finish(CaloTowerCollection& destCollection);
124 
125  // modified rescale method
126  void rescaleTowers(const CaloTowerCollection& ctInput, CaloTowerCollection& ctResult);
127 
128  void setEBEScale(double scale);
129  void setEEEScale(double scale);
130  void setHBEScale(double scale);
131  void setHESEScale(double scale);
132  void setHEDEScale(double scale);
133  void setHOEScale(double scale);
134  void setHF1EScale(double scale);
135  void setHF2EScale(double scale);
136 
137 
138  // Assign to categories based on info from DB and RecHit status
139  // Called in assignHit to check if the energy should be added to
140  // calotower, and how to flag the channel
141  unsigned int hcalChanStatusForCaloTower(const CaloRecHit* hit);
142  unsigned int ecalChanStatusForCaloTower(const CaloRecHit* hit);
143 
144  // Channel flagging is based on acceptable severity levels specified in the
145  // configuration file. These methods are used to pass the values read in
146  // CaloTowersCreator
147  //
148  // from DB
150  void setEcalSeveritiesToBeExcluded(const std::vector<int>& ecalSev ) {theEcalSeveritiesToBeExcluded= ecalSev;}
151 
152  // flag to use recovered hits
155 
156  // severety level calculator for HCAL
158 
159  // severity level calculator for ECAL
161 
162 
163  // The following are needed for creating towers from rechits excluded from the ------------------------------------
164  // default reconstructions
165 
166  // NB! Controls if rejected hits shold be used instead of the default!!!
167  void setUseRejectedHitsOnly(bool flag) { useRejectedHitsOnly = flag; }
168 
170  // void setEcalAcceptSeverityLevelForRejectedHit(unsigned int level) {theEcalAcceptSeverityLevelForRejectedHit = level;}
171  void SetEcalSeveritiesToBeUsedInBadTowers(const std::vector<int>& ecalSev ) {theEcalSeveritiesToBeUsedInBadTowers= ecalSev;}
172 
173 
176 
177  //-------------------------------------------------------------------------------------------------------------------
178 
179 
180 
181  // set the EE EB handles
182 
185 
186 
187 
188 
189  // Add methods to get the seperate positions for ECAL/HCAL
190  // used in constructing the 4-vectors using new methods
191  GlobalPoint emCrystalShwrPos (DetId detId, float fracDepth);
192  GlobalPoint hadSegmentShwrPos(DetId detId, float fracDepth);
193  // "effective" point for the EM/HAD shower in CaloTower
194  // position based on non-zero energy cells
195  GlobalPoint hadShwrPos(const std::vector<std::pair<DetId,double> >& metaContains,
196  float fracDepth, double hadE);
197  GlobalPoint emShwrPos(const std::vector<std::pair<DetId,double> >& metaContains,
198  float fracDepth, double totEmE);
199 
200  // overloaded function to get had position based on all had cells in the tower
201  GlobalPoint hadShwrPos(CaloTowerDetId id, float fracDepth);
202  GlobalPoint hadShwPosFromCells(DetId frontCell, DetId backCell, float fracDepth);
203 
204  // for Chris
205  GlobalPoint emShwrLogWeightPos(const std::vector<std::pair<DetId,double> >& metaContains,
206  float fracDepth, double totEmE);
207 
208 
209 private:
210 
211  struct MetaTower {
212  MetaTower();
213  double E, E_em, E_had, E_outer;
214  // contains also energy of RecHit
215  std::vector< std::pair<DetId, double> > metaConstituents;
216  double emSumTimeTimesE, hadSumTimeTimesE, emSumEForTime, hadSumEForTime; // Sum(Energy x Timing) : intermediate container
217 
218  // needed to set CaloTower status word
220 
221  };
222 
224  void assignHit(const CaloRecHit * recHit);
225 
226  void rescale(const CaloTower * ct);
227 
229  MetaTower & find(const CaloTowerDetId & id);
230 
232  void getThresholdAndWeight(const DetId & detId, double & threshold, double & weight) const;
233 
237 
238 
240 
244  std::vector<double> theEBGrid, theEBWeights;
245  std::vector<double> theEEGrid, theEEWeights;
246  std::vector<double> theHBGrid, theHBWeights;
247  std::vector<double> theHESGrid, theHESWeights;
248  std::vector<double> theHEDGrid, theHEDWeights;
249  std::vector<double> theHOGrid, theHOWeights;
250  std::vector<double> theHF1Grid, theHF1Weights;
251  std::vector<double> theHF2Grid, theHF2Weights;
255 
256  double theEBEScale;
257  double theEEEScale;
258  double theHBEScale;
259  double theHESEScale;
260  double theHEDEScale;
261  double theHOEScale;
262  double theHF1EScale;
263  double theHF2EScale;
268 
269  // for checking the status of ECAL and HCAL channels stored in the DB
272 
273  // calculator of severety level for HCAL
275 
276  // calculator for severity level for ECAL
278 
279 
280  // fields that hold the information passed from the CaloTowersCreator configuration file:
281  // controll what is considered bad/recovered/problematic channel for CaloTower purposes
282  //
285  // flag to use recovered hits
288 
289  // controls the tower reconstruction from rejected hits
290 
294 
295 
298 
299 
302 
303  // Switches and paramters for CaloTower 4-momentum assignment
304  // "depth" variables do not affect all algorithms
310 
311  // compactify timing info
312  int compactTime(float time);
313 
314  void convert(const CaloTowerDetId& id, const MetaTower& mt, CaloTowerCollection & collection);
315 
316 
317  // internal map
318  typedef std::map<CaloTowerDetId, MetaTower> MetaTowerMap;
320 
321  // Number of channels in the tower that were not used in RecHit production (dead/off,...).
322  // These channels are added to the other "bad" channels found in the recHit collection.
323  typedef std::map<CaloTowerDetId, int> HcalDropChMap;
325 
326  // clasification of channels in tower construction: the category definition is
327  // affected by the setting in the configuration file
328  //
330 
331 
332  // the EE and EB collections for ecal anomalous cell info
333 
336 
337 
338 
339 };
340 
341 #endif
std::vector< double > theHBGrid
const EcalChannelStatus * theEcalChStatus
const HcalChannelQuality * theHcalChStatus
void setEcalChStatusFromDB(const EcalChannelStatus *s)
std::map< CaloTowerDetId, MetaTower > MetaTowerMap
std::vector< double > theHESGrid
std::vector< double > theHEDGrid
GlobalPoint emCrystalShwrPos(DetId detId, float fracDepth)
std::vector< int > theEcalSeveritiesToBeUsedInBadTowers
void setHcalChStatusFromDB(const HcalChannelQuality *s)
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)
unsigned int ecalChanStatusForCaloTower(const CaloRecHit *hit)
GlobalPoint emShwrPos(const std::vector< std::pair< DetId, double > > &metaContains, float fracDepth, double totEmE)
std::vector< double > theEEWeights
std::vector< double > theHESWeights
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)
void setHcalSevLvlComputer(const HcalSeverityLevelComputer *c)
std::vector< double > theHOGrid
const CaloTowerConstituentsMap * theTowerConstituentsMap
void convert(const CaloTowerDetId &id, const MetaTower &mt, CaloTowerCollection &collection)
void SetEcalSeveritiesToBeUsedInBadTowers(const std::vector< int > &ecalSev)
std::vector< double > theHF1Weights
void setRecoveredEcalHitsAreUsed(bool flag)
GlobalPoint hadSegmentShwrPos(DetId detId, float fracDepth)
std::vector< std::pair< DetId, double > > metaConstituents
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
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 &amp; weight
void setUseRejectedHitsOnly(bool flag)
const HcalTopology * theHcalTopology
std::vector< int > theEcalSeveritiesToBeExcluded
GlobalPoint hadShwrPos(const std::vector< std::pair< DetId, double > > &metaContains, float fracDepth, double hadE)
const EcalSeverityLevelAlgo * theEcalSevLvlAlgo
double a
Definition: hdecay.h:121
void setHcalAcceptSeverityLevel(unsigned int level)
std::vector< double > theHF1Grid
void assignHit(const CaloRecHit *recHit)
adds a single hit to the tower
std::vector< double > theEBGrid
tuple level
Definition: testEve_cfg.py:34
std::vector< double > theHF2Weights
void setEcalSevLvlAlgo(const EcalSeverityLevelAlgo *a)
int weight
Definition: histoStyle.py:50
void setUseRejectedRecoveredHcalHits(bool flag)
unsigned int theHcalAcceptSeverityLevelForRejectedHit
void setGeometry(const CaloTowerConstituentsMap *cttopo, const HcalTopology *htopo, const CaloGeometry *geo)
std::vector< double > theEBWeights
edm::Handle< EcalRecHitCollection > theEbHandle
GlobalPoint emShwrLogWeightPos(const std::vector< std::pair< DetId, double > > &metaContains, float fracDepth, double totEmE)