9 #include "Math/Interpolator.h" 15 : theEBthreshold(-1000.),
16 theEEthreshold(-1000.),
18 theUseEtEBTresholdFlag(
false),
19 theUseEtEETresholdFlag(
false),
20 theUseSymEBTresholdFlag(
false),
21 theUseSymEETresholdFlag(
false),
24 theHcalThreshold(-1000.),
25 theHBthreshold(-1000.),
26 theHBthreshold1(-1000.),
27 theHBthreshold2(-1000.),
28 theHESthreshold(-1000.),
29 theHESthreshold1(-1000.),
30 theHEDthreshold(-1000.),
31 theHEDthreshold1(-1000.),
32 theHOthreshold0(-1000.),
33 theHOthresholdPlus1(-1000.),
34 theHOthresholdMinus1(-1000.),
35 theHOthresholdPlus2(-1000.),
36 theHOthresholdMinus2(-1000.),
37 theHF1threshold(-1000.),
38 theHF2threshold(-1000.),
39 theEBGrid(
std::vector<double>(5,10.)),
40 theEBWeights(
std::vector<double>(5,1.)),
41 theEEGrid(
std::vector<double>(5,10.)),
42 theEEWeights(
std::vector<double>(5,1.)),
43 theHBGrid(
std::vector<double>(5,10.)),
44 theHBWeights(
std::vector<double>(5,1.)),
45 theHESGrid(
std::vector<double>(5,10.)),
46 theHESWeights(
std::vector<double>(5,1.)),
47 theHEDGrid(
std::vector<double>(5,10.)),
48 theHEDWeights(
std::vector<double>(5,1.)),
49 theHOGrid(
std::vector<double>(5,10.)),
50 theHOWeights(
std::vector<double>(5,1.)),
51 theHF1Grid(
std::vector<double>(5,10.)),
52 theHF1Weights(
std::vector<double>(5,1.)),
53 theHF2Grid(
std::vector<double>(5,10.)),
54 theHF2Weights(
std::vector<double>(5,1.)),
64 theEBSumThreshold(-1000.),
65 theEESumThreshold(-1000.),
76 theTowerConstituentsMap(
nullptr),
77 theHcalAcceptSeverityLevel(0),
78 theRecoveredHcalHitsAreUsed(
false),
79 theRecoveredEcalHitsAreUsed(
false),
80 useRejectedHitsOnly(
false),
81 theHcalAcceptSeverityLevelForRejectedHit(0),
82 useRejectedRecoveredHcalHits(0),
83 useRejectedRecoveredEcalHits(0),
87 theMomConstrMethod(0),
100 bool useSymEBTreshold,
101 bool useSymEETreshold,
104 double HBthreshold,
double HBthreshold1,
double HBthreshold2,
105 double HESthreshold,
double HESthreshold1,
106 double HEDthreshold,
double HEDthreshold1,
107 double HOthreshold0,
double HOthresholdPlus1,
double HOthresholdMinus1,
108 double HOthresholdPlus2,
double HOthresholdMinus2,
109 double HF1threshold,
double HF2threshold,
110 double EBweight,
double EEweight,
111 double HBweight,
double HESweight,
double HEDweight,
112 double HOweight,
double HF1weight,
double HF2weight,
204 bool useEtEBTreshold,
205 bool useEtEETreshold,
206 bool useSymEBTreshold,
207 bool useSymEETreshold,
210 double HBthreshold,
double HBthreshold1,
double HBthreshold2,
211 double HESthreshold,
double HESthreshold1,
212 double HEDthreshold,
double HEDthreshold1,
213 double HOthreshold0,
double HOthresholdPlus1,
double HOthresholdMinus1,
214 double HOthresholdPlus2,
double HOthresholdMinus2,
215 double HF1threshold,
double HF2threshold,
216 const std::vector<double> &
EBGrid,
const std::vector<double> &
EBWeights,
217 const std::vector<double> &
EEGrid,
const std::vector<double> &
EEWeights,
218 const std::vector<double> &
HBGrid,
const std::vector<double> &
HBWeights,
221 const std::vector<double> &
HOGrid,
const std::vector<double> &
HOWeights,
224 double EBweight,
double EEweight,
225 double HBweight,
double HESweight,
double HEDweight,
226 double HOweight,
double HF1weight,
double HF2weight,
340 hbheItr != hbhe.
end(); ++hbheItr)
346 hoItr != ho.
end(); ++hoItr)
352 hfItr != hf.
end(); ++hfItr)
358 ecItr != ec.
end(); ++ecItr)
368 ctcItr != ctc.
end(); ++ctcItr) {
399 ctcItr != ctc.
end(); ++ctcItr) {
402 double newE_em = ctcItr->emEnergy();
403 double newE_had = ctcItr->hadEnergy();
404 double newE_outer = ctcItr->outerEnergy();
411 double E_short = 0.5 * newE_had;
412 double E_long = newE_em + 0.5 * newE_had;
417 newE_em = E_long - E_short;
418 newE_had = 2.0 * E_short;
424 for (
unsigned int iConst = 0; iConst < ctcItr->constituentsSize(); ++iConst) {
425 DetId constId = ctcItr->constituent(iConst);
432 for (
unsigned int iConst = 0; iConst < ctcItr->constituentsSize(); ++iConst) {
433 DetId constId = ctcItr->constituent(iConst);
441 for (
unsigned int iConst = 0; iConst < ctcItr->constituentsSize(); ++iConst) {
442 DetId constId = ctcItr->constituent(iConst);
460 double f_em = 1.0/cosh(emPoint.
eta());
461 double f_had = 1.0/cosh(hadPoint.
eta());
470 double newE_tot = newE_em + newE_had;
477 CaloTower rescaledTower(twrId, newE_em, newE_had, newE_outer, -1, -1, towerP4, emPoint, hadPoint);
479 rescaledTower.setEcalTime(
int(ctcItr->ecalTime()*100.0 + 0.5) );
480 rescaledTower.setHcalTime(
int(ctcItr->hcalTime()*100.0 + 0.5) );
488 for (
unsigned int iConst = 0; iConst < ctcItr->constituentsSize(); ++iConst) {
489 contains.push_back(ctcItr->constituent(iConst));
491 rescaledTower.addConstituents(contains);
493 rescaledTower.setCaloTowerStatus(ctcItr->towerStatusWord());
523 double energy = recHit->
energy();
546 if (towerDetId.
null())
return;
552 tower29.numBadHcalCells += 1;
555 else if (0.5*energy >= threshold) {
558 if (towerDetId.
null())
return;
566 tower29.numRecHcalCells += 1;
570 tower29.numProbHcalCells += 1;
574 double e28 = 0.5 *
e;
575 double e29 = 0.5 *
e;
577 tower28.
E_had += e28;
579 std::pair<DetId,float>
mc(detId,e28);
582 tower29.E_had += e29;
584 tower29.metaConstituents.push_back(mc);
592 tower29.hadSumTimeTimesE += ( e29 * recHit->
time() );
593 tower29.hadSumEForTime += e29;
598 tower29.E_outer += e29;
610 if (towerDetId.
null())
return;
617 else if (energy >= threshold) {
633 std::pair<DetId,float>
mc(detId,e);
645 if (towerDetId.
null())
return;
650 else if (energy >= threshold) {
652 if (towerDetId.
null())
return;
655 if (hcalDetId.
depth() == 1) {
679 std::pair<DetId,float>
mc(detId,e);
690 if (towerDetId.
null())
return;
694 else if (energy >= threshold) {
696 if (towerDetId.
null())
return;
717 if(theHcalPhase==0) {
725 else if(theHcalPhase==1) {
735 std::pair<DetId,float>
mc(detId,e);
749 unsigned int chStatusForCT;
750 bool ecalIsBad=
false;
760 double energy = recHit->
energy();
770 bool passEmThreshold =
false;
775 else passEmThreshold = (energy >=
threshold);
781 else passEmThreshold = (energy >=
threshold);
785 if (towerDetId.
null())
return;
827 std::pair<DetId,float>
mc(detId,e);
842 if (towerDetId.
null())
return;
872 std::pair<DetId, float>
mc(detId, 0);
904 assert(
id.rawId()!=0);
909 double E_had=mt.
E_had;
923 std::vector<std::pair<DetId,float> > metaContains_noecal;
925 for (std::vector<std::pair<DetId,float> >::iterator
i=metaContains.begin();
i!=metaContains.end(); ++
i)
926 if (
i->first.det()!=
DetId::Ecal) metaContains_noecal.push_back(*
i);
927 metaContains.swap(metaContains_noecal);
936 std::vector<std::pair<DetId,float> > metaContains_nohcal;
938 for (std::vector<std::pair<DetId,float> >::iterator
i=metaContains.begin();
i!=metaContains.end(); ++
i)
939 if (
i->first.det()!=
DetId::Hcal) metaContains_nohcal.push_back(*
i);
940 metaContains.swap(metaContains_nohcal);
943 if(metaContains.empty())
return;
969 double momEmDepth = 0.;
970 double momHadDepth = 0.;
971 if (
id.ietaAbs()<=17) {
1005 emPoint =
emShwrPos(metaContains, momEmDepth, E_em);
1008 towerP4 = emP4*E_em;
1013 if ( (E_had + E_outer) >0) {
1014 massless = (E_em<=0);
1080 if UNLIKELY ( (towerP4[3]==0) & (E_outer>0) ) {
1082 collection.emplace_back(
id, E_em, E_had, E_outer, -1, -1,
CaloTower::PolarLorentzVector(val,hadPoint.
eta(), hadPoint.
phi(),0), emPoint, hadPoint);
1084 collection.emplace_back(
id, E_em, E_had, E_outer, -1, -1,
GlobalVector(towerP4), towerP4[3], mass2, emPoint, hadPoint);
1086 auto & caloTower = collection.
back();
1112 unsigned int numBadEcalChan = 0;
1121 if (dropChItr !=
hcalDropChMap.end()) numBadHcalChan += dropChItr->second.first;
1178 caloTower.setCaloTowerStatus(numBadHcalChan, numBadEcalChan,
1179 numRecHcalChan, numRecEcalChan,
1180 numProbHcalChan, numProbEcalChan);
1182 double maxCellE = -999.0;
1185 contains.reserve(metaContains.size());
1186 for (std::vector<std::pair<DetId,float> >::iterator
i=metaContains.begin();
i!=metaContains.end(); ++
i) {
1188 contains.push_back(
i->first);
1190 if (maxCellE < i->
second) {
1198 maxCellE =
i->second;
1202 maxCellE =
i->second;
1210 caloTower.setConstituents(
std::move(contains));
1211 caloTower.setHottestCellE(maxCellE);
1282 else if(hcalDetId.
ieta() < 0) {
1297 if(hcalDetId.
depth() == 1) {
1315 edm::LogError(
"CaloTowersCreationAlgo") <<
"Bad cell: " << det << std::endl;
1364 if (fracDepth<=0)
return point;
1365 if (fracDepth>1) fracDepth=1;
1367 const GlobalPoint& backPoint = cellGeometry->getBackPoint();
1368 point += fracDepth * (backPoint-
point);
1380 float fracDepth,
double hadE) {
1385 std::cout <<
"hadShwrPos called with " << metaContains.size()
1386 <<
" elements and energy " << hadE <<
":" << fracDepth
1397 std::vector<std::pair<DetId,float> >::const_iterator mc_it = metaContains.begin();
1398 for (; mc_it!=metaContains.end(); ++mc_it) {
1413 return GlobalPoint(hadX/nConst, hadY/nConst, hadZ/nConst);
1424 std::cout <<
"hadShwrPos " << towerId <<
" frac " << fracDepth << std::endl;
1426 if (fracDepth < 0) fracDepth = 0;
1427 else if (fracDepth > 1) fracDepth = 1;
1431 int iEta = towerId.
ieta();
1432 int iPhi = towerId.
iphi();
1444 int frontDepth = 1000;
1445 int backDepth = -1000;
1446 for(
unsigned i = 0;
i < items.size();
i++){
1462 std::cout <<
"Front " << frontCellId <<
" Back " << backCellId
1463 <<
" Depths " << frontDepth <<
":" << backDepth << std::endl;
1470 std::cout << towerId28 <<
" with " << items28.size() <<
" constituents:";
1471 for (
unsigned k=0;
k<items28.size(); ++
k)
1475 for(
unsigned i = 0;
i < items28.size();
i++){
1486 std::cout <<
"Back " << backDepth <<
" ID " << backCellId << std::endl;
1499 HcalDetId hid1(frontCellId), hid2(backCellId);
1515 const GlobalPoint& backPoint = backCellGeometry->getBackPoint();
1517 point += fracDepth * (backPoint -
point);
1524 float fracDepth,
double emE) {
1534 std::vector<std::pair<DetId,float> >::const_iterator mc_it = metaContains.begin();
1535 for (; mc_it!=metaContains.end(); ++mc_it) {
1538 double e = mc_it->second;
1554 float fracDepth,
double emE) {
1561 double sumWeights = 0;
1563 double crystalThresh = 0.015 * emE;
1565 std::vector<std::pair<DetId,float> >::const_iterator mc_it = metaContains.begin();
1566 for (; mc_it!=metaContains.end(); ++mc_it) {
1567 if (mc_it->second < 0)
continue;
1568 if (mc_it->first.det() ==
DetId::Ecal && mc_it->second > crystalThresh) sumEmE += mc_it->second;
1571 for (mc_it = metaContains.begin(); mc_it!=metaContains.end(); ++mc_it) {
1573 if (mc_it->first.det() !=
DetId::Ecal || mc_it->second < crystalThresh)
continue;
1577 weight = 4.2 +
log(mc_it->second/sumEmE);
1585 return GlobalPoint(emX/sumWeights, emY/sumWeights, emZ/sumWeights);
1594 const float timeUnit = 0.01;
1596 if (time> 300.0)
return 30000;
1597 if (time< -300.0)
return -30000;
1599 return int(time/timeUnit + 0.5);
1621 std::cout <<
"DropChMap with " << allChanInStatusCont.size() <<
" channels" 1624 for (std::vector<DetId>::iterator it = allChanInStatusCont.begin(); it!=allChanInStatusCont.end(); ++it) {
1651 if (pair.second.first == 0)
continue;
1652 int ngood = 0, nbad = 0;
1664 if (nbad > 0 && nbad >= ngood) {
1668 pair.second.second =
true;
1692 for (std::vector<DetId>::iterator ac_it=allConstituents.begin();
1693 ac_it!=allConstituents.end(); ++ac_it) {
1732 const uint32_t recHitFlag = hit->
flags();
constexpr float energy() const
std::vector< double > theHBGrid
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
bool theUseEtEETresholdFlag
const HcalChannelQuality * theHcalChStatus
bool mergedDepth29(HcalDetId id) const
size_t constituentsSize() 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
DetId constituent(size_t i) const
constexpr bool null() const
is this a null id ?
void setHF1EScale(double scale)
constexpr const DetId & detid() const
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
float missingHcalRescaleFactorForEcal
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
bool validHcal(const HcalDetId &id) const
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)
bool getMergePositionFlag() const
void setHBEScale(double scale)
std::vector< DetId > constituentsOf(const CaloTowerDetId &id) const
Get the constituent detids for this tower id ( not yet implemented )
HcalDetId mergedDepthDetId(const HcalDetId &id) const
std::vector< double > theEEWeights
std::vector< double > theHESWeights
U second(std::pair< T, U > const &p)
void setGeometry(const CaloTowerTopology *cttopo, const CaloTowerConstituentsMap *ctmap, const HcalTopology *htopo, const CaloGeometry *geo)
GlobalPoint hadShwrPos(const std::vector< std::pair< DetId, float > > &metaContains, float fracDepth, double hadE)
const CaloSubdetectorGeometry * theTowerGeometry
CaloTowerDetId detIdFromDenseIndex(uint32_t din) const
int depth() const
get the tower depth
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
constexpr float time() const
int ieta() const
get the cell ieta
GlobalPoint emShwrLogWeightPos(const std::vector< std::pair< DetId, float > > &metaContains, float fracDepth, double totEmE)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
int iphi() const
get the tower iphi
Abs< T >::type abs(const T &t)
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)
const CaloTowerTopology * theTowerTopology
std::vector< double > theHF1Weights
int firstHEDoublePhiRing() const
GlobalPoint hadSegmentShwrPos(DetId detId, float fracDepth)
bool theRecoveredHcalHitsAreUsed
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)
uint32_t denseIndex(const DetId &id) const
unsigned int theTowerMapSize
bool theUseSymEBTresholdFlag
void setEEEScale(double scale)
CaloTowerDetId id() const
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
int compactTime(float time)
GlobalPoint hadShwPosFromCells(DetId frontCell, DetId backCell, float fracDepth)
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
std::vector< unsigned short > ecalBadChs
void setHOEScale(double scale)
double theHOthresholdMinus1
HcalDetId idBack(const HcalDetId &id) const
const EcalSeverityLevelAlgo * theEcalSevLvlAlgo
std::shared_ptr< 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)
int convertCTtoHcal(int ct_ieta) const
std::vector< double > theEBGrid
HcalDetId idFront(const HcalDetId &id) const
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
missingHcalRescaleFactorForEcal
std::vector< double > theHF2Weights
int ieta() const
get the tower ieta
bool theUseEtEBTresholdFlag
uint32_t getValue() const
unsigned int theHcalAcceptSeverityLevelForRejectedHit
std::tuple< unsigned int, bool > ecalChanStatusForCaloTower(const EcalRecHit *hit)
HcalThreshold
GeV, ORCA value w/o selective readout.
const BasicVectorType & basicVector() const
HcalDropChMap hcalDropChMap
void setEBEScale(double scale)
std::vector< double > theEBWeights
double theHOthresholdPlus2
bool theRecoveredEcalHitsAreUsed
constexpr uint32_t flags() const
unsigned int theHcalAcceptSeverityLevel
bool theUseSymEETresholdFlag
uint32_t sizeForDenseIndexing() const
*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
constexpr Detector det() const
get the detector field from this detid
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
def merge(dictlist, TELL=False)