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 const std::vector<double> & EBGrid, const std::vector<double> & EBWeights,
00086 const std::vector<double> & EEGrid, const std::vector<double> & EEWeights,
00087 const std::vector<double> & HBGrid, const std::vector<double> & HBWeights,
00088 const std::vector<double> & HESGrid, const std::vector<double> & HESWeights,
00089 const std::vector<double> & HEDGrid, const std::vector<double> & HEDWeights,
00090 const std::vector<double> & HOGrid, const std::vector<double> & HOWeights,
00091 const std::vector<double> & HF1Grid, const std::vector<double> & HF1Weights,
00092 const std::vector<double> & HF2Grid, const 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 setEcalSeveritiesToBeExcluded(const std::vector<int>& ecalSev ) {theEcalSeveritiesToBeExcluded= ecalSev;}
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
00173 void SetEcalSeveritiesToBeUsedInBadTowers(const std::vector<int>& ecalSev ) {theEcalSeveritiesToBeUsedInBadTowers= ecalSev;}
00174
00175
00176 void setUseRejectedRecoveredHcalHits(bool flag) {useRejectedRecoveredHcalHits = flag; };
00177 void setUseRejectedRecoveredEcalHits(bool flag) {useRejectedRecoveredEcalHits = flag; };
00178
00179
00180
00181
00182
00183
00184
00185 void setEbHandle(const edm::Handle<EcalRecHitCollection> eb) { theEbHandle = eb; }
00186 void setEeHandle(const edm::Handle<EcalRecHitCollection> ee) { theEeHandle = ee; }
00187
00188
00189
00190
00191
00192
00193 GlobalPoint emCrystalShwrPos (DetId detId, float fracDepth);
00194 GlobalPoint hadSegmentShwrPos(DetId detId, float fracDepth);
00195
00196
00197 GlobalPoint hadShwrPos(const std::vector<std::pair<DetId,double> >& metaContains,
00198 float fracDepth, double hadE);
00199 GlobalPoint emShwrPos(const std::vector<std::pair<DetId,double> >& metaContains,
00200 float fracDepth, double totEmE);
00201
00202
00203 GlobalPoint hadShwrPos(CaloTowerDetId id, float fracDepth);
00204 GlobalPoint hadShwPosFromCells(DetId frontCell, DetId backCell, float fracDepth);
00205
00206
00207 GlobalPoint emShwrLogWeightPos(const std::vector<std::pair<DetId,double> >& metaContains,
00208 float fracDepth, double totEmE);
00209
00210
00211 private:
00212
00213 struct MetaTower {
00214 MetaTower();
00215 double E, E_em, E_had, E_outer;
00216
00217 std::vector< std::pair<DetId, double> > metaConstituents;
00218 double emSumTimeTimesE, hadSumTimeTimesE, emSumEForTime, hadSumEForTime;
00219
00220
00221 int numBadEcalCells, numRecEcalCells, numProbEcalCells, numBadHcalCells, numRecHcalCells, numProbHcalCells;
00222
00223 };
00224
00226 void assignHit(const CaloRecHit * recHit);
00227
00228 void rescale(const CaloTower * ct);
00229
00231 MetaTower & find(const CaloTowerDetId & id);
00232
00234 void getThresholdAndWeight(const DetId & detId, double & threshold, double & weight) const;
00235
00236 double theEBthreshold, theEEthreshold;
00237 bool theUseEtEBTresholdFlag, theUseEtEETresholdFlag;
00238 bool theUseSymEBTresholdFlag,theUseSymEETresholdFlag;
00239
00240
00241 double theHcalThreshold;
00242
00243 double theHBthreshold, theHESthreshold, theHEDthreshold;
00244 double theHOthreshold0, theHOthresholdPlus1, theHOthresholdMinus1;
00245 double theHOthresholdPlus2, theHOthresholdMinus2, theHF1threshold, theHF2threshold;
00246 std::vector<double> theEBGrid, theEBWeights;
00247 std::vector<double> theEEGrid, theEEWeights;
00248 std::vector<double> theHBGrid, theHBWeights;
00249 std::vector<double> theHESGrid, theHESWeights;
00250 std::vector<double> theHEDGrid, theHEDWeights;
00251 std::vector<double> theHOGrid, theHOWeights;
00252 std::vector<double> theHF1Grid, theHF1Weights;
00253 std::vector<double> theHF2Grid, theHF2Weights;
00254 double theEBweight, theEEweight;
00255 double theHBweight, theHESweight, theHEDweight, theHOweight, theHF1weight, theHF2weight;
00256 double theEcutTower, theEBSumThreshold, theEESumThreshold;
00257
00258 double theEBEScale;
00259 double theEEEScale;
00260 double theHBEScale;
00261 double theHESEScale;
00262 double theHEDEScale;
00263 double theHOEScale;
00264 double theHF1EScale;
00265 double theHF2EScale;
00266 const HcalTopology* theHcalTopology;
00267 const CaloGeometry* theGeometry;
00268 const CaloTowerConstituentsMap* theTowerConstituentsMap;
00269 const CaloSubdetectorGeometry* theTowerGeometry;
00270
00271
00272 const EcalChannelStatus* theEcalChStatus;
00273 const HcalChannelQuality* theHcalChStatus;
00274
00275
00276 const HcalSeverityLevelComputer* theHcalSevLvlComputer;
00277
00278
00279 const EcalSeverityLevelAlgo* theEcalSevLvlAlgo;
00280
00281
00282
00283
00284
00285 unsigned int theHcalAcceptSeverityLevel;
00286 std::vector<int> theEcalSeveritiesToBeExcluded;
00287
00288 bool theRecoveredHcalHitsAreUsed;
00289 bool theRecoveredEcalHitsAreUsed;
00290
00291
00292
00293 bool useRejectedHitsOnly;
00294 unsigned int theHcalAcceptSeverityLevelForRejectedHit;
00295 std::vector<int> theEcalSeveritiesToBeUsedInBadTowers;
00296
00297
00298 unsigned int useRejectedRecoveredHcalHits;
00299 unsigned int useRejectedRecoveredEcalHits;
00300
00301
00303 bool theHOIsUsed;
00304
00305
00306
00307 int theMomConstrMethod;
00308 double theMomHBDepth;
00309 double theMomHEDepth;
00310 double theMomEBDepth;
00311 double theMomEEDepth;
00312
00313
00314 int compactTime(float time);
00315
00316 void convert(const CaloTowerDetId& id, const MetaTower& mt, CaloTowerCollection & collection);
00317
00318
00319
00320 typedef std::map<CaloTowerDetId, MetaTower> MetaTowerMap;
00321 MetaTowerMap theTowerMap;
00322
00323
00324
00325 typedef std::map<CaloTowerDetId, int> HcalDropChMap;
00326 HcalDropChMap hcalDropChMap;
00327
00328
00329
00330
00331 enum ctHitCategory {GoodChan = 0, BadChan = 1, RecoveredChan = 2, ProblematicChan = 3, IgnoredChan = 99 };
00332
00333
00334
00335
00336 edm::Handle<EcalRecHitCollection> theEbHandle;
00337 edm::Handle<EcalRecHitCollection> theEeHandle;
00338
00339
00340
00341 };
00342
00343 #endif