00001 #ifndef RECOLOCALCALO_CALOTOWERSCREATOR_CALOTOWERSCREATIONALGO_H
00002 #define RECOLOCALCALO_CALOTOWERSCREATOR_CALOTOWERSCREATIONALGO_H 1
00003
00004 #include "DataFormats/CaloTowers/interface/CaloTowerCollection.h"
00005 #include "DataFormats/CaloTowers/interface/CaloTowerDetId.h"
00006 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00007 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00008 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00009
00010
00011 #include "CondFormats/EcalObjects/interface/EcalChannelStatus.h"
00012 #include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h"
00013
00014 #include "CondFormats/HcalObjects/interface/HcalChannelQuality.h"
00015 #include "CondFormats/DataRecord/interface/HcalChannelQualityRcd.h"
00016
00017
00018 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputer.h"
00019 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputerRcd.h"
00020
00021
00022 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h"
00023
00024
00025 #include "FWCore/Framework/interface/ESHandle.h"
00026
00027
00028 #include <map>
00029 class HcalTopology;
00030 class CaloGeometry;
00031 class CaloSubdetectorGeometry;
00032 class CaloTowerConstituentsMap;
00033 class CaloRecHit;
00034 class DetId;
00035
00043
00044
00045
00046
00047
00048
00049 class CaloTowersCreationAlgo {
00050 public:
00051 CaloTowersCreationAlgo();
00052
00053 CaloTowersCreationAlgo(double EBthreshold, double EEthreshold,
00054
00055 bool useEtEBTreshold, bool useEtEETreshold,
00056 bool useSymEBTreshold, bool useSymEETreshold,
00057
00058 double HcalThreshold,
00059 double HBthreshold, double HESthreshold, double HEDthreshold,
00060 double HOthreshold0, double HOthresholdPlus1, double HOthresholdMinus1,
00061 double HOthresholdPlus2, double HOthresholdMinus2,
00062 double HF1threshold, double HF2threshold,
00063 double EBweight, double EEweight,
00064 double HBweight, double HESweight, double HEDweight,
00065 double HOweight, double HF1weight, double HF2weight,
00066 double EcutTower, double EBSumThreshold, double EESumThreshold, bool useHO,
00067
00068 int momConstrMethod,
00069 double momHBDepth,
00070 double momHEDepth,
00071 double momEBDepth,
00072 double momEEDepth
00073 );
00074
00075 CaloTowersCreationAlgo(double EBthreshold, double EEthreshold,
00076
00077 bool useEtEBTreshold, bool useEtEETreshold,
00078 bool useSymEBTreshold, bool useSymEETreshold,
00079
00080 double HcalThreshold,
00081 double HBthreshold, double HESthreshold, double HEDthreshold,
00082 double HOthreshold0, double HOthresholdPlus1, double HOthresholdMinus1,
00083 double HOthresholdPlus2, double HOthresholdMinus2,
00084 double HF1threshold, double HF2threshold,
00085 std::vector<double> EBGrid, std::vector<double> EBWeights,
00086 std::vector<double> EEGrid, std::vector<double> EEWeights,
00087 std::vector<double> HBGrid, std::vector<double> HBWeights,
00088 std::vector<double> HESGrid, std::vector<double> HESWeights,
00089 std::vector<double> HEDGrid, std::vector<double> HEDWeights,
00090 std::vector<double> HOGrid, std::vector<double> HOWeights,
00091 std::vector<double> HF1Grid, std::vector<double> HF1Weights,
00092 std::vector<double> HF2Grid, std::vector<double> HF2Weights,
00093 double EBweight, double EEweight,
00094 double HBweight, double HESweight, double HEDweight,
00095 double HOweight, double HF1weight, double HF2weight,
00096 double EcutTower, double EBSumThreshold, double EESumThreshold, bool useHO,
00097
00098 int momConstrMethod,
00099 double momHBDepth,
00100 double momHEDepth,
00101 double momEBDepth,
00102 double momEEDepth
00103 );
00104
00105 void setGeometry(const CaloTowerConstituentsMap* cttopo, const HcalTopology* htopo, const CaloGeometry* geo);
00106
00107
00108
00109 void setHcalChStatusFromDB(const HcalChannelQuality* s) { theHcalChStatus = s; }
00110 void setEcalChStatusFromDB(const EcalChannelStatus* s) { theEcalChStatus = s; }
00111
00112
00113
00114 void makeHcalDropChMap();
00115
00116 void begin();
00117 void process(const HBHERecHitCollection& hbhe);
00118 void process(const HORecHitCollection& ho);
00119 void process(const HFRecHitCollection& hf);
00120 void process(const EcalRecHitCollection& ecal);
00121
00122
00123 void process(const CaloTowerCollection& ctc);
00124
00125 void finish(CaloTowerCollection& destCollection);
00126
00127
00128 void rescaleTowers(const CaloTowerCollection& ctInput, CaloTowerCollection& ctResult);
00129
00130 void setEBEScale(double scale);
00131 void setEEEScale(double scale);
00132 void setHBEScale(double scale);
00133 void setHESEScale(double scale);
00134 void setHEDEScale(double scale);
00135 void setHOEScale(double scale);
00136 void setHF1EScale(double scale);
00137 void setHF2EScale(double scale);
00138
00139
00140
00141
00142
00143 unsigned int hcalChanStatusForCaloTower(const CaloRecHit* hit);
00144 unsigned int ecalChanStatusForCaloTower(const CaloRecHit* hit);
00145
00146
00147
00148
00149
00150
00151 void setHcalAcceptSeverityLevel(unsigned int level) {theHcalAcceptSeverityLevel = level;}
00152 void setEcalAcceptSeverityLevel(unsigned int level) {theEcalAcceptSeverityLevel = level;}
00153
00154
00155 void setRecoveredHcalHitsAreUsed(bool flag) {theRecoveredHcalHitsAreUsed = flag; };
00156 void setRecoveredEcalHitsAreUsed(bool flag) {theRecoveredEcalHitsAreUsed = flag; };
00157
00158
00159 void setHcalSevLvlComputer(const HcalSeverityLevelComputer* c) {theHcalSevLvlComputer = c; };
00160
00161
00162 void setEcalSevLvlAlgo(const EcalSeverityLevelAlgo* a) { theEcalSevLvlAlgo = a; }
00163
00164
00165
00166
00167
00168
00169 void setUseRejectedHitsOnly(bool flag) { useRejectedHitsOnly = flag; }
00170
00171 void setHcalAcceptSeverityLevelForRejectedHit(unsigned int level) {theHcalAcceptSeverityLevelForRejectedHit = level;}
00172 void setEcalAcceptSeverityLevelForRejectedHit(unsigned int level) {theEcalAcceptSeverityLevelForRejectedHit = level;}
00173
00174 void setUseRejectedRecoveredHcalHits(bool flag) {useRejectedRecoveredHcalHits = flag; };
00175 void setUseRejectedRecoveredEcalHits(bool flag) {useRejectedRecoveredEcalHits = flag; };
00176
00177
00178
00179
00180
00181
00182
00183 void setEbHandle(const edm::Handle<EcalRecHitCollection> eb) { theEbHandle = eb; }
00184 void setEeHandle(const edm::Handle<EcalRecHitCollection> ee) { theEeHandle = ee; }
00185
00186
00187
00188
00189
00190
00191 GlobalPoint emCrystalShwrPos (DetId detId, float fracDepth);
00192 GlobalPoint hadSegmentShwrPos(DetId detId, float fracDepth);
00193
00194
00195 GlobalPoint hadShwrPos(std::vector<std::pair<DetId,double> >& metaContains,
00196 float fracDepth, double hadE);
00197 GlobalPoint emShwrPos(std::vector<std::pair<DetId,double> >& metaContains,
00198 float fracDepth, double totEmE);
00199
00200
00201 GlobalPoint hadShwrPos(CaloTowerDetId id, float fracDepth);
00202 GlobalPoint hadShwPosFromCells(DetId frontCell, DetId backCell, float fracDepth);
00203
00204
00205 GlobalPoint emShwrLogWeightPos(std::vector<std::pair<DetId,double> >& metaContains,
00206 float fracDepth, double totEmE);
00207
00208
00209 private:
00210
00211 struct MetaTower {
00212 MetaTower();
00213 double E, E_em, E_had, E_outer;
00214
00215 std::vector< std::pair<DetId, double> > metaConstituents;
00216 double emSumTimeTimesE, hadSumTimeTimesE, emSumEForTime, hadSumEForTime;
00217
00218
00219 int numBadEcalCells, numRecEcalCells, numProbEcalCells, numBadHcalCells, numRecHcalCells, numProbHcalCells;
00220
00221 };
00222
00224 void assignHit(const CaloRecHit * recHit);
00225
00226 void rescale(const CaloTower * ct);
00227
00229 MetaTower & find(const CaloTowerDetId & id);
00230
00232 void getThresholdAndWeight(const DetId & detId, double & threshold, double & weight) const;
00233
00234 double theEBthreshold, theEEthreshold;
00235 bool theUseEtEBTresholdFlag, theUseEtEETresholdFlag;
00236 bool theUseSymEBTresholdFlag,theUseSymEETresholdFlag;
00237
00238
00239 double theHcalThreshold;
00240
00241 double theHBthreshold, theHESthreshold, theHEDthreshold;
00242 double theHOthreshold0, theHOthresholdPlus1, theHOthresholdMinus1;
00243 double theHOthresholdPlus2, theHOthresholdMinus2, theHF1threshold, theHF2threshold;
00244 std::vector<double> theEBGrid, theEBWeights;
00245 std::vector<double> theEEGrid, theEEWeights;
00246 std::vector<double> theHBGrid, theHBWeights;
00247 std::vector<double> theHESGrid, theHESWeights;
00248 std::vector<double> theHEDGrid, theHEDWeights;
00249 std::vector<double> theHOGrid, theHOWeights;
00250 std::vector<double> theHF1Grid, theHF1Weights;
00251 std::vector<double> theHF2Grid, theHF2Weights;
00252 double theEBweight, theEEweight;
00253 double theHBweight, theHESweight, theHEDweight, theHOweight, theHF1weight, theHF2weight;
00254 double theEcutTower, theEBSumThreshold, theEESumThreshold;
00255
00256 double theEBEScale;
00257 double theEEEScale;
00258 double theHBEScale;
00259 double theHESEScale;
00260 double theHEDEScale;
00261 double theHOEScale;
00262 double theHF1EScale;
00263 double theHF2EScale;
00264 const HcalTopology* theHcalTopology;
00265 const CaloGeometry* theGeometry;
00266 const CaloTowerConstituentsMap* theTowerConstituentsMap;
00267 const CaloSubdetectorGeometry* theTowerGeometry;
00268
00269
00270 const EcalChannelStatus* theEcalChStatus;
00271 const HcalChannelQuality* theHcalChStatus;
00272
00273
00274 const HcalSeverityLevelComputer* theHcalSevLvlComputer;
00275
00276
00277 const EcalSeverityLevelAlgo* theEcalSevLvlAlgo;
00278
00279
00280
00281
00282
00283 unsigned int theHcalAcceptSeverityLevel;
00284 unsigned int theEcalAcceptSeverityLevel;
00285
00286 bool theRecoveredHcalHitsAreUsed;
00287 bool theRecoveredEcalHitsAreUsed;
00288
00289
00290
00291 bool useRejectedHitsOnly;
00292 unsigned int theHcalAcceptSeverityLevelForRejectedHit;
00293 unsigned int theEcalAcceptSeverityLevelForRejectedHit;
00294 unsigned int useRejectedRecoveredHcalHits;
00295 unsigned int useRejectedRecoveredEcalHits;
00296
00297
00299 bool theHOIsUsed;
00300
00301
00302
00303 int theMomConstrMethod;
00304 double theMomEmDepth;
00305 double theMomHadDepth;
00306
00307 double theMomHBDepth;
00308 double theMomHEDepth;
00309 double theMomEBDepth;
00310 double theMomEEDepth;
00311
00312
00313 int compactTime(float time);
00314
00315 CaloTower convert(const CaloTowerDetId& id, const MetaTower& mt);
00316
00317
00318 typedef std::map<CaloTowerDetId, MetaTower> MetaTowerMap;
00319 MetaTowerMap theTowerMap;
00320
00321
00322
00323 std::map<CaloTowerDetId, int> hcalDropChMap;
00324
00325
00326
00327
00328 enum ctHitCategory {GoodChan = 0, BadChan = 1, RecoveredChan = 2, ProblematicChan = 3, IgnoredChan = 99 };
00329
00330
00331
00332
00333 edm::Handle<EcalRecHitCollection> theEbHandle;
00334 edm::Handle<EcalRecHitCollection> theEeHandle;
00335
00336
00337
00338 };
00339
00340 #endif