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 
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:
52 
53  CaloTowersCreationAlgo(double EBthreshold, double EEthreshold,
54 
55  bool useEtEBTreshold, bool useEtEETreshold,
56  bool useSymEBTreshold, bool useSymEETreshold,
57 
58  double HcalThreshold,
59  double HBthreshold, double HESthreshold, double HEDthreshold,
60  double HOthreshold0, double HOthresholdPlus1, double HOthresholdMinus1,
61  double HOthresholdPlus2, double HOthresholdMinus2,
62  double HF1threshold, double HF2threshold,
63  double EBweight, double EEweight,
64  double HBweight, double HESweight, double HEDweight,
65  double HOweight, double HF1weight, double HF2weight,
66  double EcutTower, double EBSumThreshold, double EESumThreshold, bool useHO,
67  // (for momentum reconstruction algorithm)
68  int momConstrMethod,
69  double momHBDepth,
70  double momHEDepth,
71  double momEBDepth,
72  double momEEDepth
73  );
74 
75  CaloTowersCreationAlgo(double EBthreshold, double EEthreshold,
76 
77  bool useEtEBTreshold, bool useEtEETreshold,
78  bool useSymEBTreshold, bool useSymEETreshold,
79 
80  double HcalThreshold,
81  double HBthreshold, double HESthreshold, double HEDthreshold,
82  double HOthreshold0, double HOthresholdPlus1, double HOthresholdMinus1,
83  double HOthresholdPlus2, double HOthresholdMinus2,
84  double HF1threshold, double HF2threshold,
85  const std::vector<double> & EBGrid, const std::vector<double> & EBWeights,
86  const std::vector<double> & EEGrid, const std::vector<double> & EEWeights,
87  const std::vector<double> & HBGrid, const std::vector<double> & HBWeights,
88  const std::vector<double> & HESGrid, const std::vector<double> & HESWeights,
89  const std::vector<double> & HEDGrid, const std::vector<double> & HEDWeights,
90  const std::vector<double> & HOGrid, const std::vector<double> & HOWeights,
91  const std::vector<double> & HF1Grid, const std::vector<double> & HF1Weights,
92  const std::vector<double> & HF2Grid, const std::vector<double> & HF2Weights,
93  double EBweight, double EEweight,
94  double HBweight, double HESweight, double HEDweight,
95  double HOweight, double HF1weight, double HF2weight,
96  double EcutTower, double EBSumThreshold, double EESumThreshold, bool useHO,
97  // (for momentum reconstruction algorithm)
98  int momConstrMethod,
99  double momHBDepth,
100  double momHEDepth,
101  double momEBDepth,
102  double momEEDepth
103 );
104 
105  void setGeometry(const CaloTowerConstituentsMap* cttopo, const HcalTopology* htopo, const CaloGeometry* geo);
106 
107  // pass the containers of channels status from the event record (stored in DB)
108  // these are called in CaloTowersCreator
111 
112  // Kake a map of number of channels not used in RecHit production.
113  // The key is the calotower id.
114  void makeHcalDropChMap();
115 
116  void begin();
117  void process(const HBHERecHitCollection& hbhe);
118  void process(const HORecHitCollection& ho);
119  void process(const HFRecHitCollection& hf);
120  void process(const EcalRecHitCollection& ecal);
121 
122 
123  void process(const CaloTowerCollection& ctc);
124 
125  void finish(CaloTowerCollection& destCollection);
126 
127  // modified rescale method
128  void rescaleTowers(const CaloTowerCollection& ctInput, CaloTowerCollection& ctResult);
129 
130  void setEBEScale(double scale);
131  void setEEEScale(double scale);
132  void setHBEScale(double scale);
133  void setHESEScale(double scale);
134  void setHEDEScale(double scale);
135  void setHOEScale(double scale);
136  void setHF1EScale(double scale);
137  void setHF2EScale(double scale);
138 
139 
140  // Assign to categories based on info from DB and RecHit status
141  // Called in assignHit to check if the energy should be added to
142  // calotower, and how to flag the channel
143  unsigned int hcalChanStatusForCaloTower(const CaloRecHit* hit);
144  unsigned int ecalChanStatusForCaloTower(const CaloRecHit* hit);
145 
146  // Channel flagging is based on acceptable severity levels specified in the
147  // configuration file. These methods are used to pass the values read in
148  // CaloTowersCreator
149  //
150  // from DB
152  void setEcalSeveritiesToBeExcluded(const std::vector<int>& ecalSev ) {theEcalSeveritiesToBeExcluded= ecalSev;}
153 
154  // flag to use recovered hits
157 
158  // severety level calculator for HCAL
160 
161  // severity level calculator for ECAL
163 
164 
165  // The following are needed for creating towers from rechits excluded from the ------------------------------------
166  // default reconstructions
167 
168  // NB! Controls if rejected hits shold be used instead of the default!!!
170 
172  // void setEcalAcceptSeverityLevelForRejectedHit(unsigned int level) {theEcalAcceptSeverityLevelForRejectedHit = level;}
173  void SetEcalSeveritiesToBeUsedInBadTowers(const std::vector<int>& ecalSev ) {theEcalSeveritiesToBeUsedInBadTowers= ecalSev;}
174 
175 
178 
179  //-------------------------------------------------------------------------------------------------------------------
180 
181 
182 
183  // set the EE EB handles
184 
187 
188 
189 
190 
191  // Add methods to get the seperate positions for ECAL/HCAL
192  // used in constructing the 4-vectors using new methods
193  GlobalPoint emCrystalShwrPos (DetId detId, float fracDepth);
194  GlobalPoint hadSegmentShwrPos(DetId detId, float fracDepth);
195  // "effective" point for the EM/HAD shower in CaloTower
196  // position based on non-zero energy cells
197  GlobalPoint hadShwrPos(const std::vector<std::pair<DetId,double> >& metaContains,
198  float fracDepth, double hadE);
199  GlobalPoint emShwrPos(const std::vector<std::pair<DetId,double> >& metaContains,
200  float fracDepth, double totEmE);
201 
202  // overloaded function to get had position based on all had cells in the tower
203  GlobalPoint hadShwrPos(CaloTowerDetId id, float fracDepth);
204  GlobalPoint hadShwPosFromCells(DetId frontCell, DetId backCell, float fracDepth);
205 
206  // for Chris
207  GlobalPoint emShwrLogWeightPos(const std::vector<std::pair<DetId,double> >& metaContains,
208  float fracDepth, double totEmE);
209 
210 
211 private:
212 
213  struct MetaTower {
214  MetaTower();
215  double E, E_em, E_had, E_outer;
216  // contains also energy of RecHit
217  std::vector< std::pair<DetId, double> > metaConstituents;
218  double emSumTimeTimesE, hadSumTimeTimesE, emSumEForTime, hadSumEForTime; // Sum(Energy x Timing) : intermediate container
219 
220  // needed to set CaloTower status word
222 
223  };
224 
226  void assignHit(const CaloRecHit * recHit);
227 
228  void rescale(const CaloTower * ct);
229 
231  MetaTower & find(const CaloTowerDetId & id);
232 
234  void getThresholdAndWeight(const DetId & detId, double & threshold, double & weight) const;
235 
239 
240 
242 
246  std::vector<double> theEBGrid, theEBWeights;
247  std::vector<double> theEEGrid, theEEWeights;
248  std::vector<double> theHBGrid, theHBWeights;
249  std::vector<double> theHESGrid, theHESWeights;
250  std::vector<double> theHEDGrid, theHEDWeights;
251  std::vector<double> theHOGrid, theHOWeights;
252  std::vector<double> theHF1Grid, theHF1Weights;
253  std::vector<double> theHF2Grid, theHF2Weights;
257 
258  double theEBEScale;
259  double theEEEScale;
260  double theHBEScale;
261  double theHESEScale;
262  double theHEDEScale;
263  double theHOEScale;
264  double theHF1EScale;
265  double theHF2EScale;
270 
271  // for checking the status of ECAL and HCAL channels stored in the DB
274 
275  // calculator of severety level for HCAL
277 
278  // calculator for severity level for ECAL
280 
281 
282  // fields that hold the information passed from the CaloTowersCreator configuration file:
283  // controll what is considered bad/recovered/problematic channel for CaloTower purposes
284  //
287  // flag to use recovered hits
290 
291  // controls the tower reconstruction from rejected hits
292 
296 
297 
300 
301 
304 
305  // Switches and paramters for CaloTower 4-momentum assignment
306  // "depth" variables do not affect all algorithms
312 
313  // compactify timing info
314  int compactTime(float time);
315 
316  void convert(const CaloTowerDetId& id, const MetaTower& mt, CaloTowerCollection & collection);
317 
318 
319  // internal map
320  typedef std::map<CaloTowerDetId, MetaTower> MetaTowerMap;
322 
323  // Number of channels in the tower that were not used in RecHit production (dead/off,...).
324  // These channels are added to the other "bad" channels found in the recHit collection.
325  typedef std::map<CaloTowerDetId, int> HcalDropChMap;
327 
328  // clasification of channels in tower construction: the category definition is
329  // affected by the setting in the configuration file
330  //
332 
333 
334  // the EE and EB collections for ecal anomalous cell info
335 
338 
339 
340 
341 };
342 
343 #endif
std::vector< double > theHBGrid
const EcalChannelStatus * theEcalChStatus
const HcalChannelQuality * theHcalChStatus
long int flag
Definition: mlp_lapack.h:47
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:20
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)