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 #include <map>
00011 class HcalTopology;
00012 class CaloGeometry;
00013 class CaloSubdetectorGeometry;
00014 class CaloTowerConstituentsMap;
00015 class CaloRecHit;
00016 class DetId;
00017
00025
00026
00027
00028
00029
00030
00031 class CaloTowersCreationAlgo {
00032 public:
00033 CaloTowersCreationAlgo();
00034
00035 CaloTowersCreationAlgo(double EBthreshold, double EEthreshold, double HcalThreshold,
00036 double HBthreshold, double HESthreshold, double HEDthreshold,
00037 double HOthreshold, double HF1threshold, double HF2threshold,
00038 double EBweight, double EEweight,
00039 double HBweight, double HESweight, double HEDweight,
00040 double HOweight, double HF1weight, double HF2weight,
00041 double EcutTower, double EBSumThreshold, double EESumThreshold, bool useHO,
00042
00043 int momConstrMethod,
00044 double momEmDepth,
00045 double momHadDepth,
00046 double momTotDepth
00047 );
00048
00049 CaloTowersCreationAlgo(double EBthreshold, double EEthreshold, double HcalThreshold,
00050 double HBthreshold, double HESthreshold, double HEDthreshold,
00051 double HOthreshold, double HF1threshold, double HF2threshold,
00052 std::vector<double> EBGrid, std::vector<double> EBWeights,
00053 std::vector<double> EEGrid, std::vector<double> EEWeights,
00054 std::vector<double> HBGrid, std::vector<double> HBWeights,
00055 std::vector<double> HESGrid, std::vector<double> HESWeights,
00056 std::vector<double> HEDGrid, std::vector<double> HEDWeights,
00057 std::vector<double> HOGrid, std::vector<double> HOWeights,
00058 std::vector<double> HF1Grid, std::vector<double> HF1Weights,
00059 std::vector<double> HF2Grid, std::vector<double> HF2Weights,
00060 double EBweight, double EEweight,
00061 double HBweight, double HESweight, double HEDweight,
00062 double HOweight, double HF1weight, double HF2weight,
00063 double EcutTower, double EBSumThreshold, double EESumThreshold, bool useHO,
00064
00065 int momConstrMethod,
00066 double momEmDepth,
00067 double momHadDepth,
00068 double momTotDepth
00069 );
00070
00071 void setGeometry(const CaloTowerConstituentsMap* cttopo, const HcalTopology* htopo, const CaloGeometry* geo);
00072
00073 void begin();
00074 void process(const HBHERecHitCollection& hbhe);
00075 void process(const HORecHitCollection& ho);
00076 void process(const HFRecHitCollection& hf);
00077 void process(const EcalRecHitCollection& ecal);
00078
00079
00080 void process(const CaloTowerCollection& ctc);
00081
00082 void finish(CaloTowerCollection& destCollection);
00083 void setEBEScale(double scale);
00084 void setEEEScale(double scale);
00085 void setHBEScale(double scale);
00086 void setHESEScale(double scale);
00087 void setHEDEScale(double scale);
00088 void setHOEScale(double scale);
00089 void setHF1EScale(double scale);
00090 void setHF2EScale(double scale);
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 GlobalPoint emCrystalShwrPos (DetId detId, float fracDepth);
00103 GlobalPoint hadSegmentShwrPos(DetId detId, float fracDepth);
00104
00105 GlobalPoint hadShwrPos(std::vector<std::pair<DetId,double> >& metaContains,
00106 float fracDepth, double hadE);
00107 GlobalPoint emShwrPos(std::vector<std::pair<DetId,double> >& metaContains,
00108 float fracDepth, double totEmE);
00109
00110 private:
00111
00112 struct MetaTower {
00113 MetaTower();
00114 double E, E_em, E_had, E_outer;
00115
00116 std::vector< std::pair<DetId, double> > metaConstituents;
00117 double emSumTimeTimesE, hadSumTimeTimesE, emSumEForTime, hadSumEForTime;
00118 };
00119
00121 void assignHit(const CaloRecHit * recHit);
00122
00123 void rescale(const CaloTower * ct);
00124
00126 MetaTower & find(const CaloTowerDetId & id);
00127
00129 void getThresholdAndWeight(const DetId & detId, double & threshold, double & weight) const;
00130
00131 double theEBthreshold, theEEthreshold, theHcalThreshold;
00132 double theHBthreshold, theHESthreshold, theHEDthreshold;
00133 double theHOthreshold, theHF1threshold, theHF2threshold;
00134 std::vector<double> theEBGrid, theEBWeights;
00135 std::vector<double> theEEGrid, theEEWeights;
00136 std::vector<double> theHBGrid, theHBWeights;
00137 std::vector<double> theHESGrid, theHESWeights;
00138 std::vector<double> theHEDGrid, theHEDWeights;
00139 std::vector<double> theHOGrid, theHOWeights;
00140 std::vector<double> theHF1Grid, theHF1Weights;
00141 std::vector<double> theHF2Grid, theHF2Weights;
00142 double theEBweight, theEEweight;
00143 double theHBweight, theHESweight, theHEDweight, theHOweight, theHF1weight, theHF2weight;
00144 double theEcutTower, theEBSumThreshold, theEESumThreshold;
00145
00146 double theEBEScale;
00147 double theEEEScale;
00148 double theHBEScale;
00149 double theHESEScale;
00150 double theHEDEScale;
00151 double theHOEScale;
00152 double theHF1EScale;
00153 double theHF2EScale;
00154 const HcalTopology* theHcalTopology;
00155 const CaloGeometry* theGeometry;
00156 const CaloTowerConstituentsMap* theTowerConstituentsMap;
00157 const CaloSubdetectorGeometry* theTowerGeometry;
00158
00160 bool theHOIsUsed;
00161
00162
00163
00164 int theMomConstrMethod;
00165 double theMomEmDepth;
00166 double theMomHadDepth;
00167 double theMomTotDepth;
00168
00169
00170
00171 int compactTime(float time);
00172
00173 CaloTower convert(const CaloTowerDetId& id, const MetaTower& mt);
00174
00175
00176 typedef std::map<CaloTowerDetId, MetaTower> MetaTowerMap;
00177 MetaTowerMap theTowerMap;
00178 };
00179
00180 #endif