9 #include "Math/Interpolator.h" 15 : theEBthreshold(-1000.),
16 theEEthreshold(-1000.),
18 theUseEtEBTresholdFlag(
false),
19 theUseEtEETresholdFlag(
false),
20 theUseSymEBTresholdFlag(
false),
21 theUseSymEETresholdFlag(
false),
23 theHcalThreshold(-1000.),
24 theHBthreshold(-1000.),
25 theHBthreshold1(-1000.),
26 theHBthreshold2(-1000.),
27 theHESthreshold(-1000.),
28 theHESthreshold1(-1000.),
29 theHEDthreshold(-1000.),
30 theHEDthreshold1(-1000.),
31 theHOthreshold0(-1000.),
32 theHOthresholdPlus1(-1000.),
33 theHOthresholdMinus1(-1000.),
34 theHOthresholdPlus2(-1000.),
35 theHOthresholdMinus2(-1000.),
36 theHF1threshold(-1000.),
37 theHF2threshold(-1000.),
38 theEBGrid(
std::vector<double>(5, 10.)),
39 theEBWeights(
std::vector<double>(5, 1.)),
40 theEEGrid(
std::vector<double>(5, 10.)),
41 theEEWeights(
std::vector<double>(5, 1.)),
42 theHBGrid(
std::vector<double>(5, 10.)),
43 theHBWeights(
std::vector<double>(5, 1.)),
44 theHESGrid(
std::vector<double>(5, 10.)),
45 theHESWeights(
std::vector<double>(5, 1.)),
46 theHEDGrid(
std::vector<double>(5, 10.)),
47 theHEDWeights(
std::vector<double>(5, 1.)),
48 theHOGrid(
std::vector<double>(5, 10.)),
49 theHOWeights(
std::vector<double>(5, 1.)),
50 theHF1Grid(
std::vector<double>(5, 10.)),
51 theHF1Weights(
std::vector<double>(5, 1.)),
52 theHF2Grid(
std::vector<double>(5, 10.)),
53 theHF2Weights(
std::vector<double>(5, 1.)),
63 theEBSumThreshold(-1000.),
64 theEESumThreshold(-1000.),
75 theTowerConstituentsMap(
nullptr),
76 theHcalAcceptSeverityLevel(0),
77 theRecoveredHcalHitsAreUsed(
false),
78 theRecoveredEcalHitsAreUsed(
false),
79 useRejectedHitsOnly(
false),
80 theHcalAcceptSeverityLevelForRejectedHit(0),
81 useRejectedRecoveredHcalHits(0),
82 useRejectedRecoveredEcalHits(0),
86 theMomConstrMethod(0),
98 bool useSymEBTreshold,
99 bool useSymEETreshold,
106 double HESthreshold1,
108 double HEDthreshold1,
110 double HOthresholdPlus1,
111 double HOthresholdMinus1,
112 double HOthresholdPlus2,
113 double HOthresholdMinus2,
216 bool useEtEBTreshold,
217 bool useEtEETreshold,
218 bool useSymEBTreshold,
219 bool useSymEETreshold,
226 double HESthreshold1,
228 double HEDthreshold1,
230 double HOthresholdPlus1,
231 double HOthresholdMinus1,
232 double HOthresholdPlus2,
233 double HOthresholdMinus2,
236 const std::vector<double>&
EBGrid,
238 const std::vector<double>&
EEGrid,
240 const std::vector<double>&
HBGrid,
242 const std::vector<double>&
HESGrid,
244 const std::vector<double>&
HEDGrid,
246 const std::vector<double>&
HOGrid,
248 const std::vector<double>&
HF1Grid,
250 const std::vector<double>&
HF2Grid,
429 double newE_em = ctcItr->emEnergy();
430 double newE_had = ctcItr->hadEnergy();
431 double newE_outer = ctcItr->outerEnergy();
438 double E_short = 0.5 * newE_had;
439 double E_long = newE_em + 0.5 * newE_had;
444 newE_em = E_long - E_short;
445 newE_had = 2.0 * E_short;
451 for (
unsigned int iConst = 0; iConst < ctcItr->constituentsSize(); ++iConst) {
452 DetId constId = ctcItr->constituent(iConst);
460 for (
unsigned int iConst = 0; iConst < ctcItr->constituentsSize(); ++iConst) {
461 DetId constId = ctcItr->constituent(iConst);
471 for (
unsigned int iConst = 0; iConst < ctcItr->constituentsSize(); ++iConst) {
472 DetId constId = ctcItr->constituent(iConst);
480 newE_outer *= weight;
494 double f_em = 1.0 / cosh(emPoint.
eta());
495 double f_had = 1.0 / cosh(hadPoint.
eta());
505 double newE_tot = newE_em + newE_had;
511 CaloTower rescaledTower(twrId, newE_em, newE_had, newE_outer, -1, -1, towerP4, emPoint, hadPoint);
513 rescaledTower.setEcalTime(
int(ctcItr->ecalTime() * 100.0 + 0.5));
514 rescaledTower.setHcalTime(
int(ctcItr->hcalTime() * 100.0 + 0.5));
522 for (
unsigned int iConst = 0; iConst < ctcItr->constituentsSize(); ++iConst) {
523 contains.push_back(ctcItr->constituent(iConst));
525 rescaledTower.addConstituents(contains);
527 rescaledTower.setCaloTowerStatus(ctcItr->towerStatusWord());
575 if (towerDetId.
null())
581 tower29.numBadHcalCells += 1;
584 else if (0.5 * energy >= threshold) {
587 if (towerDetId.
null())
595 tower29.numRecHcalCells += 1;
598 tower29.numProbHcalCells += 1;
602 double e28 = 0.5 *
e;
603 double e29 = 0.5 *
e;
605 tower28.
E_had += e28;
607 std::pair<DetId, float>
mc(detId, e28);
610 tower29.E_had += e29;
612 tower29.metaConstituents.push_back(mc);
620 tower29.hadSumTimeTimesE += (e29 * recHit->
time());
621 tower29.hadSumEForTime += e29;
626 tower29.E_outer += e29;
637 if (towerDetId.
null())
646 else if (energy >= threshold) {
660 std::pair<DetId, float>
mc(detId, e);
671 if (towerDetId.
null())
677 else if (energy >= threshold) {
679 if (towerDetId.
null())
683 if (hcalDetId.
depth() == 1) {
705 std::pair<DetId, float>
mc(detId, e);
716 if (towerDetId.
null())
720 }
else if (energy >= threshold) {
722 if (towerDetId.
null())
743 if (theHcalPhase == 0) {
745 (hcalDetId.
depth() == 3 && hcalDetId.
ietaAbs() == 27) ||
746 (hcalDetId.
depth() == 3 && hcalDetId.
ietaAbs() == 16)) {
751 else if (theHcalPhase == 1) {
754 (hcalDetId.
depth() == 3 && hcalDetId.
ietaAbs() == 17) ||
755 (hcalDetId.
depth() == 4 && hcalDetId.
ietaAbs() == 16)) {
761 std::pair<DetId, float>
mc(detId, e);
775 unsigned int chStatusForCT;
776 bool ecalIsBad =
false;
797 bool passEmThreshold =
false;
803 passEmThreshold = (fabs(energy) >=
threshold);
811 passEmThreshold = (fabs(energy) >=
threshold);
817 if (towerDetId.
null())
855 std::pair<DetId, float>
mc(detId, e);
867 if (towerDetId.
null())
883 if (hcalDetId.
depth() == 1)
885 if (hcalDetId.
depth() == 2)
897 std::pair<DetId, float>
mc(detId, 0);
925 assert(
id.rawId() != 0);
929 double E_em = mt.
E_em;
930 double E_had = mt.
E_had;
944 std::vector<std::pair<DetId, float> > metaContains_noecal;
946 for (std::vector<std::pair<DetId, float> >::iterator
i = metaContains.begin();
i != metaContains.end(); ++
i)
948 metaContains_noecal.push_back(*
i);
949 metaContains.swap(metaContains_noecal);
959 std::vector<std::pair<DetId, float> > metaContains_nohcal;
961 for (std::vector<std::pair<DetId, float> >::iterator
i = metaContains.begin();
i != metaContains.end(); ++
i)
963 metaContains_nohcal.push_back(*
i);
964 metaContains.swap(metaContains_nohcal);
967 if (metaContains.empty())
986 bool massless =
true;
993 double momEmDepth = 0.;
994 double momHadDepth = 0.;
995 if (
id.ietaAbs() <= 17) {
1023 emPoint =
emShwrPos(metaContains, momEmDepth, E_em);
1026 towerP4 = emP4 * E_em;
1031 if ((E_had + E_outer) > 0) {
1032 massless = (E_em <= 0);
1037 auto diff = lP4 - emP4;
1098 UNLIKELY((towerP4[3] == 0) & (E_outer > 0)) {
1100 collection.emplace_back(
id,
1111 collection.emplace_back(
1112 id, E_em, E_had, E_outer, -1, -1,
GlobalVector(towerP4), towerP4[3], mass2, emPoint, hadPoint);
1114 auto& caloTower = collection.
back();
1143 unsigned int numBadEcalChan = 0;
1153 numBadHcalChan += dropChItr->second.first;
1209 caloTower.setCaloTowerStatus(
1210 numBadHcalChan, numBadEcalChan, numRecHcalChan, numRecEcalChan, numProbHcalChan, numProbEcalChan);
1212 double maxCellE = -999.0;
1215 contains.reserve(metaContains.size());
1216 for (std::vector<std::pair<DetId, float> >::iterator
i = metaContains.begin();
i != metaContains.end(); ++
i) {
1217 contains.push_back(
i->first);
1219 if (maxCellE < i->
second) {
1226 maxCellE =
i->second;
1229 maxCellE =
i->second;
1231 maxCellE =
i->second;
1238 caloTower.setConstituents(
std::move(contains));
1239 caloTower.setHottestCellE(maxCellE);
1305 else if (hcalDetId.
ieta() < 0) {
1320 if (hcalDetId.
depth() == 1) {
1337 edm::LogError(
"CaloTowersCreationAlgo") <<
"Bad cell: " << det << std::endl;
1342 if (scale > 0.00001)
1349 if (scale > 0.00001)
1356 if (scale > 0.00001)
1363 if (scale > 0.00001)
1370 if (scale > 0.00001)
1377 if (scale > 0.00001)
1384 if (scale > 0.00001)
1391 if (scale > 0.00001)
1406 const GlobalPoint& backPoint = cellGeometry->getBackPoint();
1407 point += fracDepth * (backPoint -
point);
1423 std::cout <<
"hadShwrPos called with " << metaContains.size() <<
" elements and energy " << hadE <<
":" << fracDepth
1435 std::vector<std::pair<DetId, float> >::const_iterator mc_it = metaContains.begin();
1436 for (; mc_it != metaContains.end(); ++mc_it) {
1453 return GlobalPoint(hadX / nConst, hadY / nConst, hadZ / nConst);
1462 std::cout <<
"hadShwrPos " << towerId <<
" frac " << fracDepth << std::endl;
1466 else if (fracDepth > 1)
1471 int iEta = towerId.
ieta();
1472 int iPhi = towerId.
iphi();
1483 int frontDepth = 1000;
1484 int backDepth = -1000;
1485 for (
unsigned i = 0;
i < items.size();
i++) {
1504 std::cout <<
"Front " << frontCellId <<
" Back " << backCellId <<
" Depths " << frontDepth <<
":" << backDepth
1512 std::cout << towerId28 <<
" with " << items28.size() <<
" constituents:";
1513 for (
unsigned k = 0;
k < items28.size(); ++
k)
1518 for (
unsigned i = 0;
i < items28.size();
i++) {
1532 std::cout <<
"Back " << backDepth <<
" ID " << backCellId << std::endl;
1544 HcalDetId hid1(frontCellId), hid2(backCellId);
1560 const GlobalPoint& backPoint = backCellGeometry->getBackPoint();
1562 point += fracDepth * (backPoint -
point);
1579 std::vector<std::pair<DetId, float> >::const_iterator mc_it = metaContains.begin();
1580 for (; mc_it != metaContains.end(); ++mc_it) {
1584 double e = mc_it->second;
1594 return GlobalPoint(emX / eSum, emY / eSum, emZ / eSum);
1605 double sumWeights = 0;
1607 double crystalThresh = 0.015 * emE;
1609 std::vector<std::pair<DetId, float> >::const_iterator mc_it = metaContains.begin();
1610 for (; mc_it != metaContains.end(); ++mc_it) {
1611 if (mc_it->second < 0)
1613 if (mc_it->first.det() ==
DetId::Ecal && mc_it->second > crystalThresh)
1614 sumEmE += mc_it->second;
1617 for (mc_it = metaContains.begin(); mc_it != metaContains.end(); ++mc_it) {
1618 if (mc_it->first.det() !=
DetId::Ecal || mc_it->second < crystalThresh)
1623 weight = 4.2 +
log(mc_it->second / sumEmE);
1631 return GlobalPoint(emX / sumWeights, emY / sumWeights, emZ / sumWeights);
1635 const float timeUnit = 0.01;
1642 return int(time / timeUnit + 0.5);
1657 std::cout <<
"DropChMap with " << allChanInStatusCont.size() <<
" channels" << std::endl;
1659 for (std::vector<DetId>::iterator it = allChanInStatusCont.begin(); it != allChanInStatusCont.end(); ++it) {
1684 if (pair.second.first == 0)
1686 int ngood = 0, nbad = 0;
1700 if (nbad > 0 && nbad >= ngood) {
1704 pair.second.second =
true;
1725 for (std::vector<DetId>::iterator ac_it = allConstituents.begin(); ac_it != allConstituents.end(); ++ac_it) {
1732 std::vector<int>::const_iterator sevit =
1757 std::cout <<
"ChanStatusForCaloTower for " << hid <<
" to " <<
HcalDetId(
id) << std::endl;
1759 const uint32_t recHitFlag = hit->
flags();
1790 if (severityLevel == 0)
1838 std::vector<int>::const_iterator sevit =
1875 return std::make_tuple(
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
missingHcalRescaleFactorForEcal
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< T >::const_iterator const_iterator
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)
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
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
GlobalPoint hadShwrPos(const std::vector< std::pair< DetId, float >> &metaContains, float fracDepth, double hadE)
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)
bool accepted(std::vector< std::string_view > const &, std::string_view)
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
GlobalPoint emShwrPos(const std::vector< std::pair< DetId, float >> &metaContains, float fracDepth, double totEmE)
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.
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)
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
GlobalPoint emShwrLogWeightPos(const std::vector< std::pair< DetId, float >> &metaContains, float fracDepth, double totEmE)
constexpr Detector det() const
get the detector field from this detid
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
def merge(dictlist, TELL=False)