8 #include "Math/Interpolator.h"
11 : theEBthreshold(-1000.),
12 theEEthreshold(-1000.),
14 theUseEtEBTresholdFlag(
false),
15 theUseEtEETresholdFlag(
false),
16 theUseSymEBTresholdFlag(
false),
17 theUseSymEETresholdFlag(
false),
20 theHcalThreshold(-1000.),
21 theHBthreshold(-1000.),
22 theHESthreshold(-1000.),
23 theHEDthreshold(-1000.),
24 theHOthreshold0(-1000.),
25 theHOthresholdPlus1(-1000.),
26 theHOthresholdMinus1(-1000.),
27 theHOthresholdPlus2(-1000.),
28 theHOthresholdMinus2(-1000.),
29 theHF1threshold(-1000.),
30 theHF2threshold(-1000.),
31 theEBGrid(std::vector<double>(5,10.)),
32 theEBWeights(std::vector<double>(5,1.)),
33 theEEGrid(std::vector<double>(5,10.)),
34 theEEWeights(std::vector<double>(5,1.)),
35 theHBGrid(std::vector<double>(5,10.)),
36 theHBWeights(std::vector<double>(5,1.)),
37 theHESGrid(std::vector<double>(5,10.)),
38 theHESWeights(std::vector<double>(5,1.)),
39 theHEDGrid(std::vector<double>(5,10.)),
40 theHEDWeights(std::vector<double>(5,1.)),
41 theHOGrid(std::vector<double>(5,10.)),
42 theHOWeights(std::vector<double>(5,1.)),
43 theHF1Grid(std::vector<double>(5,10.)),
44 theHF1Weights(std::vector<double>(5,1.)),
45 theHF2Grid(std::vector<double>(5,10.)),
46 theHF2Weights(std::vector<double>(5,1.)),
56 theEBSumThreshold(-1000.),
57 theEESumThreshold(-1000.),
60 theTowerConstituentsMap(0),
63 theMomConstrMethod(0),
75 bool useSymEBTreshold,
76 bool useSymEETreshold,
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 double EBweight,
double EEweight,
84 double HBweight,
double HESweight,
double HEDweight,
85 double HOweight,
double HF1weight,
double HF2weight,
95 : theEBthreshold(EBthreshold),
96 theEEthreshold(EEthreshold),
98 theUseEtEBTresholdFlag(useEtEBTreshold),
99 theUseEtEETresholdFlag(useEtEETreshold),
100 theUseSymEBTresholdFlag(useSymEBTreshold),
101 theUseSymEETresholdFlag(useSymEETreshold),
103 theHcalThreshold(HcalThreshold),
104 theHBthreshold(HBthreshold),
105 theHESthreshold(HESthreshold),
106 theHEDthreshold(HEDthreshold),
107 theHOthreshold0(HOthreshold0),
108 theHOthresholdPlus1(HOthresholdPlus1),
109 theHOthresholdMinus1(HOthresholdMinus1),
110 theHOthresholdPlus2(HOthresholdPlus2),
111 theHOthresholdMinus2(HOthresholdMinus2),
112 theHF1threshold(HF1threshold),
113 theHF2threshold(HF2threshold),
114 theEBGrid(std::vector<double>(5,10.)),
115 theEBWeights(std::vector<double>(5,1.)),
116 theEEGrid(std::vector<double>(5,10.)),
117 theEEWeights(std::vector<double>(5,1.)),
118 theHBGrid(std::vector<double>(5,10.)),
119 theHBWeights(std::vector<double>(5,1.)),
120 theHESGrid(std::vector<double>(5,10.)),
121 theHESWeights(std::vector<double>(5,1.)),
122 theHEDGrid(std::vector<double>(5,10.)),
123 theHEDWeights(std::vector<double>(5,1.)),
124 theHOGrid(std::vector<double>(5,10.)),
125 theHOWeights(std::vector<double>(5,1.)),
126 theHF1Grid(std::vector<double>(5,10.)),
127 theHF1Weights(std::vector<double>(5,1.)),
128 theHF2Grid(std::vector<double>(5,10.)),
129 theHF2Weights(std::vector<double>(5,1.)),
130 theEBweight(EBweight),
131 theEEweight(EEweight),
132 theHBweight(HBweight),
133 theHESweight(HESweight),
134 theHEDweight(HEDweight),
135 theHOweight(HOweight),
136 theHF1weight(HF1weight),
137 theHF2weight(HF2weight),
138 theEcutTower(EcutTower),
139 theEBSumThreshold(EBSumThreshold),
140 theEESumThreshold(EESumThreshold),
143 theMomConstrMethod(momConstrMethod),
144 theMomHBDepth(momHBDepth),
145 theMomHEDepth(momHEDepth),
146 theMomEBDepth(momEBDepth),
147 theMomEEDepth(momEEDepth)
153 bool useEtEBTreshold,
154 bool useEtEETreshold,
155 bool useSymEBTreshold,
156 bool useSymEETreshold,
159 double HBthreshold,
double HESthreshold,
double HEDthreshold,
160 double HOthreshold0,
double HOthresholdPlus1,
double HOthresholdMinus1,
161 double HOthresholdPlus2,
double HOthresholdMinus2,
162 double HF1threshold,
double HF2threshold,
163 const std::vector<double> &
EBGrid,
const std::vector<double> &
EBWeights,
164 const std::vector<double> &
EEGrid,
const std::vector<double> &
EEWeights,
165 const std::vector<double> &
HBGrid,
const std::vector<double> &
HBWeights,
168 const std::vector<double> &
HOGrid,
const std::vector<double> &
HOWeights,
171 double EBweight,
double EEweight,
172 double HBweight,
double HESweight,
double HEDweight,
173 double HOweight,
double HF1weight,
double HF2weight,
183 : theEBthreshold(EBthreshold),
184 theEEthreshold(EEthreshold),
186 theUseEtEBTresholdFlag(useEtEBTreshold),
187 theUseEtEETresholdFlag(useEtEETreshold),
188 theUseSymEBTresholdFlag(useSymEBTreshold),
189 theUseSymEETresholdFlag(useSymEETreshold),
191 theHcalThreshold(HcalThreshold),
192 theHBthreshold(HBthreshold),
193 theHESthreshold(HESthreshold),
194 theHEDthreshold(HEDthreshold),
195 theHOthreshold0(HOthreshold0),
196 theHOthresholdPlus1(HOthresholdPlus1),
197 theHOthresholdMinus1(HOthresholdMinus1),
198 theHOthresholdPlus2(HOthresholdPlus2),
199 theHOthresholdMinus2(HOthresholdMinus2),
200 theHF1threshold(HF1threshold),
201 theHF2threshold(HF2threshold),
203 theEBWeights(EBWeights),
205 theEEWeights(EEWeights),
207 theHBWeights(HBWeights),
209 theHESWeights(HESWeights),
211 theHEDWeights(HEDWeights),
213 theHOWeights(HOWeights),
215 theHF1Weights(HF1Weights),
217 theHF2Weights(HF2Weights),
218 theEBweight(EBweight),
219 theEEweight(EEweight),
220 theHBweight(HBweight),
221 theHESweight(HESweight),
222 theHEDweight(HEDweight),
223 theHOweight(HOweight),
224 theHF1weight(HF1weight),
225 theHF2weight(HF2weight),
226 theEcutTower(EcutTower),
227 theEBSumThreshold(EBSumThreshold),
228 theEESumThreshold(EESumThreshold),
231 theMomConstrMethod(momConstrMethod),
232 theMomHBDepth(momHBDepth),
233 theMomHEDepth(momHEDepth),
234 theMomEBDepth(momEBDepth),
235 theMomEEDepth(momEEDepth)
259 hbheItr != hbhe.
end(); ++hbheItr)
265 hoItr != ho.
end(); ++hoItr)
271 hfItr != hf.
end(); ++hfItr)
277 ecItr != ec.
end(); ++ecItr)
287 ctcItr != ctc.
end(); ++ctcItr) {
304 if (!mt.empty() ) {
convert(mt.id, mt, result); }
318 ctcItr != ctc.
end(); ++ctcItr) {
321 double newE_em = ctcItr->emEnergy();
322 double newE_had = ctcItr->hadEnergy();
323 double newE_outer = ctcItr->outerEnergy();
329 if (ctcItr->ietaAbs()>=30) {
330 double E_short = 0.5 * newE_had;
331 double E_long = newE_em + 0.5 * newE_had;
336 newE_em = E_long - E_short;
337 newE_had = 2.0 * E_short;
343 for (
unsigned int iConst = 0; iConst < ctcItr->constituentsSize(); ++iConst) {
344 DetId constId = ctcItr->constituent(iConst);
351 for (
unsigned int iConst = 0; iConst < ctcItr->constituentsSize(); ++iConst) {
352 DetId constId = ctcItr->constituent(iConst);
360 for (
unsigned int iConst = 0; iConst < ctcItr->constituentsSize(); ++iConst) {
361 DetId constId = ctcItr->constituent(iConst);
366 if (ctcItr->ietaAbs()>16) newE_outer *= weight;
374 double newE_hadTot = (
theHOIsUsed && twrId.
ietaAbs()<16)? newE_had+newE_outer : newE_had;
379 double f_em = 1.0/cosh(emPoint.
eta());
380 double f_had = 1.0/cosh(hadPoint.
eta());
384 if (ctcItr->ietaAbs()<30) {
389 double newE_tot = newE_em + newE_had;
396 CaloTower rescaledTower(twrId, newE_em, newE_had, newE_outer, -1, -1, towerP4, emPoint, hadPoint);
398 rescaledTower.
setEcalTime(
int(ctcItr->ecalTime()*100.0 + 0.5) );
399 rescaledTower.
setHcalTime(
int(ctcItr->hcalTime()*100.0 + 0.5) );
402 for (
unsigned int iConst = 0; iConst < ctcItr->constituentsSize(); ++iConst) {
403 contains.push_back(ctcItr->constituent(iConst));
444 if (towerDetId.
null())
return;
450 tower29.numBadHcalCells += 1;
453 else if (0.5*energy >= threshold) {
456 if (towerDetId.
null())
return;
464 tower29.numRecHcalCells += 1;
468 tower29.numProbHcalCells += 1;
472 double e28 = 0.5 *
e;
473 double e29 = 0.5 *
e;
475 tower28.
E_had += e28;
477 std::pair<DetId,float> mc(detId,e28);
480 tower29.E_had += e29;
482 tower29.metaConstituents.push_back(mc);
490 tower29.hadSumTimeTimesE += ( e29 * recHit->
time() );
491 tower29.hadSumEForTime += e29;
496 tower29.E_outer += e29;
509 if (towerDetId.
null())
return;
516 else if (energy >= threshold) {
532 std::pair<DetId,float> mc(detId,e);
544 if (towerDetId.
null())
return;
549 else if (energy >= threshold) {
551 if (towerDetId.
null())
return;
554 if (hcalDetId.
depth() == 1) {
578 std::pair<DetId,float> mc(detId,e);
589 if (towerDetId.
null())
return;
593 else if (energy >= threshold) {
595 if (towerDetId.
null())
return;
623 std::pair<DetId,float> mc(detId,e);
637 unsigned int chStatusForCT;
638 bool ecalIsBad=
false;
658 bool passEmThreshold =
false;
663 else passEmThreshold = (energy >=
threshold);
669 else passEmThreshold = (energy >=
threshold);
673 if (towerDetId.
null())
return;
715 std::pair<DetId,float> mc(detId,e);
730 if (towerDetId.
null())
return;
760 std::pair<DetId, float> mc(detId, 0);
781 mt.metaConstituents.reserve(detId.
ietaAbs()<30 ? 12 : 2);
797 double E_had=mt.
E_had;
808 if (
id.ietaAbs()<=29 && E_em<ecalThres) {
811 std::vector<std::pair<DetId,float> > metaContains_noecal;
813 for (std::vector<std::pair<DetId,float> >::iterator
i=metaContains.begin();
i!=metaContains.end(); ++
i)
814 if (
i->first.det()!=
DetId::Ecal) metaContains_noecal.push_back(*
i);
815 metaContains.swap(metaContains_noecal);
824 std::vector<std::pair<DetId,float> > metaContains_nohcal;
826 for (std::vector<std::pair<DetId,float> >::iterator
i=metaContains.begin();
i!=metaContains.end(); ++
i)
827 if (
i->first.det()!=
DetId::Hcal) metaContains_nohcal.push_back(*
i);
828 metaContains.swap(metaContains_nohcal);
831 if(metaContains.empty())
return;
833 double E_had_tot = (
theHOIsUsed &&
id.ietaAbs()<16)? E_had+E_outer : E_had;
849 double momEmDepth = 0.;
850 double momHadDepth = 0.;
851 if (
id.ietaAbs()<=17) {
882 if (
id.ietaAbs()<=29) {
885 emPoint =
emShwrPos(metaContains, momEmDepth, E_em);
893 if ( (E_had + E_outer) >0) {
894 massless = (E_em<=0);
930 if (
id.ietaAbs()<=29) {
960 if unlikely ( (towerP4[3]==0) & (E_outer>0) ) {
961 collection.emplace_back(
id, E_em, E_had, E_outer, -1, -1,
CaloTower::PolarLorentzVector(0,hadPoint.
eta(), hadPoint.
phi(),0), emPoint, hadPoint);
963 collection.emplace_back(
id, E_em, E_had, E_outer, -1, -1,
GlobalVector(towerP4), towerP4[3], mass2, emPoint, hadPoint);
965 auto & caloTower = collection.
back();
986 unsigned int numBadEcalChan = 0;
995 if (dropChItr !=
hcalDropChMap.end()) numBadHcalChan += dropChItr->second;
1052 caloTower.setCaloTowerStatus(numBadHcalChan, numBadEcalChan,
1053 numRecHcalChan, numRecEcalChan,
1054 numProbHcalChan, numProbEcalChan);
1056 double maxCellE = -999.0;
1059 contains.reserve(metaContains.size());
1060 for (std::vector<std::pair<DetId,float> >::iterator
i=metaContains.begin();
i!=metaContains.end(); ++
i) {
1062 contains.push_back(
i->first);
1064 if (maxCellE < i->
second) {
1072 maxCellE =
i->second;
1076 maxCellE =
i->second;
1084 caloTower.setConstituents(std::move(contains));
1085 caloTower.setHottestCellE(maxCellE);
1155 else if(hcalDetId.
ieta() < 0) {
1170 if(hcalDetId.
depth() == 1) {
1188 edm::LogError(
"CaloTowersCreationAlgo") <<
"Bad cell: " << det << std::endl;
1237 if (fracDepth<=0)
return point;
1238 if (fracDepth>1) fracDepth=1;
1241 point += fracDepth * (backPoint-
point);
1253 float fracDepth,
double hadE) {
1265 std::vector<std::pair<DetId,float> >::const_iterator mc_it = metaContains.begin();
1266 for (; mc_it!=metaContains.end(); ++mc_it) {
1281 return GlobalPoint(hadX/nConst, hadY/nConst, hadZ/nConst);
1292 if (fracDepth < 0) fracDepth = 0;
1293 else if (fracDepth > 1) fracDepth = 1;
1297 int iEta = towerId.
ieta();
1298 int iPhi = towerId.
iphi();
1302 if (towerId.
ietaAbs() <= 14) {
1307 else if (towerId.
ietaAbs() == 15) {
1312 else if (towerId.
ietaAbs() == 16) {
1317 else if (towerId.
ietaAbs() == 17) {
1327 else if (towerId.
ietaAbs() <= 29) {
1331 if (iEta == 29) iEta = 28;
1332 if (iEta == -29) iEta = -28;
1335 else if (towerId.
ietaAbs() >= 30) {
1361 point += fracDepth * (backPoint -
point);
1368 float fracDepth,
double emE) {
1378 std::vector<std::pair<DetId,float> >::const_iterator mc_it = metaContains.begin();
1379 for (; mc_it!=metaContains.end(); ++mc_it) {
1382 double e = mc_it->second;
1398 float fracDepth,
double emE) {
1405 double sumWeights = 0;
1407 double crystalThresh = 0.015 * emE;
1409 std::vector<std::pair<DetId,float> >::const_iterator mc_it = metaContains.begin();
1410 for (; mc_it!=metaContains.end(); ++mc_it) {
1411 if (mc_it->second < 0)
continue;
1412 if (mc_it->first.det() ==
DetId::Ecal && mc_it->second > crystalThresh) sumEmE += mc_it->second;
1415 for (mc_it = metaContains.begin(); mc_it!=metaContains.end(); ++mc_it) {
1417 if (mc_it->first.det() !=
DetId::Ecal || mc_it->second < crystalThresh)
continue;
1421 weight = 4.2 +
log(mc_it->second/sumEmE);
1429 return GlobalPoint(emX/sumWeights, emY/sumWeights, emZ/sumWeights);
1438 const float timeUnit = 0.01;
1440 if (time> 300.0)
return 30000;
1441 if (time< -300.0)
return -30000;
1443 return int(time/timeUnit + 0.5);
1464 for (std::vector<DetId>::iterator it = allChanInStatusCont.begin(); it!=allChanInStatusCont.end(); ++it) {
1507 for (std::vector<DetId>::iterator ac_it=allConstituents.begin();
1508 ac_it!=allConstituents.end(); ++ac_it) {
1543 const uint32_t recHitFlag = hit->
flags();
std::vector< double > theHBGrid
unsigned short ecalBadChs[CaloTowerDetId::kSizeForDenseIndexing]
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
bool theUseEtEETresholdFlag
const HcalChannelQuality * theHcalChStatus
size_t constituentsSize() const
const GlobalPoint & getBackPoint() const
bool contains(EventRange const &lh, EventID const &rh)
HcalSubdetector subdet() const
get the subdetector
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id) const
Evaluate status from id use channelStatus from DB.
int ietaAbs() const
get the absolute value of the tower ieta
const DetId & detid() const
DetId constituent(size_t i) const
void setHF1EScale(double scale)
uint32_t denseIndex() const
void setCaloTowerStatus(unsigned int numBadHcalChan, unsigned int numBadEcalChan, unsigned int numRecHcalChan, unsigned int numRecEcalChan, unsigned int numProbHcalChan, unsigned int numProbEcalChan)
std::vector< double > theHESGrid
std::vector< double > theHEDGrid
GlobalPoint emCrystalShwrPos(DetId detId, float fracDepth)
void assignHitHcal(const CaloRecHit *recHit)
std::vector< int > theEcalSeveritiesToBeUsedInBadTowers
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Geom::Phi< T > phi() const
Basic3DVector unit() const
Global3DPoint GlobalPoint
const DetId & detid() const
std::vector< HBHERecHit >::const_iterator const_iterator
GlobalPoint emShwrPos(const std::vector< std::pair< DetId, float > > &metaContains, float fracDepth, double totEmE)
void push_back(T const &t)
void setHF2EScale(double scale)
void finish(CaloTowerCollection &destCollection)
const Item * getValues(DetId fId, bool throwOnFail=true) const
std::vector< double > theHOWeights
MetaTower & find(const CaloTowerDetId &id)
looks for a given tower in the internal cache. If it can't find it, it makes it.
std::vector< double > theEEGrid
void rescale(const CaloTower *ct)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void setHBEScale(double scale)
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
std::vector< DetId > constituentsOf(const CaloTowerDetId &id) const
Get the constituent detids for this tower id ( not yet implemented )
static CaloTowerDetId detIdFromDenseIndex(uint32_t din)
std::vector< double > theEEWeights
std::vector< double > theHESWeights
U second(std::pair< T, U > const &p)
GlobalPoint hadShwrPos(const std::vector< std::pair< DetId, float > > &metaContains, float fracDepth, double hadE)
const CaloSubdetectorGeometry * theTowerGeometry
int depth() const
get the tower depth
void addConstituents(const std::vector< DetId > &ids)
unsigned int hcalChanStatusForCaloTower(const CaloRecHit *hit)
CaloTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
std::vector< double > theHF2Grid
std::vector< double > theHEDWeights
unsigned int useRejectedRecoveredEcalHits
void rescaleTowers(const CaloTowerCollection &ctInput, CaloTowerCollection &ctResult)
static const int SubdetId
std::vector< DetId > getAllChannels() const
bool recoveredRecHit(const DetId &myid, const uint32_t &myflag) const
const CaloGeometry * theGeometry
int ieta() const
get the cell ieta
GlobalPoint emShwrLogWeightPos(const std::vector< std::pair< DetId, float > > &metaContains, float fracDepth, double totEmE)
int iphi() const
get the tower iphi
std::vector< double > theHOGrid
void assignHitEcal(const EcalRecHit *recHit)
adds a single hit to the tower
bool dropChannel(const uint32_t &mystatus) const
const CaloTowerConstituentsMap * theTowerConstituentsMap
double theHOthresholdPlus1
void convert(const CaloTowerDetId &id, const MetaTower &mt, CaloTowerCollection &collection)
std::vector< double > theHF1Weights
int firstHEDoublePhiRing() const
GlobalPoint hadSegmentShwrPos(DetId detId, float fracDepth)
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
bool theRecoveredHcalHitsAreUsed
unsigned towerId(DetId const &)
bool theHOIsUsed
only affects energy and ET calculation. HO is still recorded in the tower
void process(const HBHERecHitCollection &hbhe)
int ietaAbs() const
get the absolute value of the cell ieta
unsigned int useRejectedRecoveredHcalHits
const_iterator end() const
double theHOthresholdMinus2
std::vector< double > theHBWeights
const HcalSeverityLevelComputer * theHcalSevLvlComputer
void setHESEScale(double scale)
void setHEDEScale(double scale)
unsigned int theTowerMapSize
bool theUseSymEBTresholdFlag
void setEEEScale(double scale)
CaloTowerDetId id() const
int compactTime(float time)
GlobalPoint hadShwPosFromCells(DetId frontCell, DetId backCell, float fracDepth)
bool null() const
is this a null id ?
int zside() const
get the z-side of the tower (1/-1)
void getThresholdAndWeight(const DetId &detId, double &threshold, double &weight) const
helper method to look up the appropriate threshold & weight
int getSeverityLevel(const DetId &myid, const uint32_t &myflag, const uint32_t &mystatus) const
const HcalTopology * theHcalTopology
std::vector< int > theEcalSeveritiesToBeExcluded
void setHOEScale(double scale)
double theHOthresholdMinus1
const EcalSeverityLevelAlgo * theEcalSevLvlAlgo
const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id.
std::vector< double > theHF1Grid
void reserve(size_type n)
std::vector< double > theEBGrid
std::vector< double > theHF2Weights
volatile std::atomic< bool > shutdown_flag false
int ieta() const
get the tower ieta
bool theUseEtEBTresholdFlag
uint32_t getValue() const
unsigned int theHcalAcceptSeverityLevelForRejectedHit
if(conf.exists("allCellsPositionCalc"))
std::tuple< unsigned int, bool > ecalChanStatusForCaloTower(const EcalRecHit *hit)
Detector det() const
get the detector field from this detid
void setGeometry(const CaloTowerConstituentsMap *cttopo, const HcalTopology *htopo, const CaloGeometry *geo)
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
const BasicVectorType & basicVector() const
HcalDropChMap hcalDropChMap
void setEBEScale(double scale)
std::vector< double > theEBWeights
double theHOthresholdPlus2
bool theRecoveredEcalHitsAreUsed
unsigned int theHcalAcceptSeverityLevel
bool theUseSymEETresholdFlag
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
double outerEnergy() const
const_iterator begin() const
const_reference back() const
Global3DVector GlobalVector
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.