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),
86 theMomConstrMethod(0),
99 bool useSymEBTreshold,
100 bool useSymEETreshold,
103 double HBthreshold,
double HBthreshold1,
double HBthreshold2,
104 double HESthreshold,
double HESthreshold1,
105 double HEDthreshold,
double HEDthreshold1,
106 double HOthreshold0,
double HOthresholdPlus1,
double HOthresholdMinus1,
107 double HOthresholdPlus2,
double HOthresholdMinus2,
108 double HF1threshold,
double HF2threshold,
109 double EBweight,
double EEweight,
110 double HBweight,
double HESweight,
double HEDweight,
111 double HOweight,
double HF1weight,
double HF2weight,
202 bool useEtEBTreshold,
203 bool useEtEETreshold,
204 bool useSymEBTreshold,
205 bool useSymEETreshold,
208 double HBthreshold,
double HBthreshold1,
double HBthreshold2,
209 double HESthreshold,
double HESthreshold1,
210 double HEDthreshold,
double HEDthreshold1,
211 double HOthreshold0,
double HOthresholdPlus1,
double HOthresholdMinus1,
212 double HOthresholdPlus2,
double HOthresholdMinus2,
213 double HF1threshold,
double HF2threshold,
214 const std::vector<double> &
EBGrid,
const std::vector<double> &
EBWeights,
215 const std::vector<double> &
EEGrid,
const std::vector<double> &
EEWeights,
216 const std::vector<double> &
HBGrid,
const std::vector<double> &
HBWeights,
219 const std::vector<double> &
HOGrid,
const std::vector<double> &
HOWeights,
222 double EBweight,
double EEweight,
223 double HBweight,
double HESweight,
double HEDweight,
224 double HOweight,
double HF1weight,
double HF2weight,
337 hbheItr != hbhe.
end(); ++hbheItr)
343 hoItr != ho.
end(); ++hoItr)
349 hfItr != hf.
end(); ++hfItr)
355 ecItr != ec.
end(); ++ecItr)
365 ctcItr != ctc.
end(); ++ctcItr) {
396 ctcItr != ctc.
end(); ++ctcItr) {
399 double newE_em = ctcItr->emEnergy();
400 double newE_had = ctcItr->hadEnergy();
401 double newE_outer = ctcItr->outerEnergy();
408 double E_short = 0.5 * newE_had;
409 double E_long = newE_em + 0.5 * newE_had;
414 newE_em = E_long - E_short;
415 newE_had = 2.0 * E_short;
421 for (
unsigned int iConst = 0; iConst < ctcItr->constituentsSize(); ++iConst) {
422 DetId constId = ctcItr->constituent(iConst);
429 for (
unsigned int iConst = 0; iConst < ctcItr->constituentsSize(); ++iConst) {
430 DetId constId = ctcItr->constituent(iConst);
438 for (
unsigned int iConst = 0; iConst < ctcItr->constituentsSize(); ++iConst) {
439 DetId constId = ctcItr->constituent(iConst);
457 double f_em = 1.0/cosh(emPoint.
eta());
458 double f_had = 1.0/cosh(hadPoint.
eta());
467 double newE_tot = newE_em + newE_had;
474 CaloTower rescaledTower(twrId, newE_em, newE_had, newE_outer, -1, -1, towerP4, emPoint, hadPoint);
476 rescaledTower.setEcalTime(
int(ctcItr->ecalTime()*100.0 + 0.5) );
477 rescaledTower.setHcalTime(
int(ctcItr->hcalTime()*100.0 + 0.5) );
485 for (
unsigned int iConst = 0; iConst < ctcItr->constituentsSize(); ++iConst) {
486 contains.push_back(ctcItr->constituent(iConst));
488 rescaledTower.addConstituents(contains);
490 rescaledTower.setCaloTowerStatus(ctcItr->towerStatusWord());
520 double energy = recHit->
energy();
543 if (towerDetId.
null())
return;
549 tower29.numBadHcalCells += 1;
552 else if (0.5*energy >= threshold) {
555 if (towerDetId.
null())
return;
563 tower29.numRecHcalCells += 1;
567 tower29.numProbHcalCells += 1;
571 double e28 = 0.5 *
e;
572 double e29 = 0.5 *
e;
574 tower28.
E_had += e28;
576 std::pair<DetId,float>
mc(detId,e28);
579 tower29.E_had += e29;
581 tower29.metaConstituents.push_back(mc);
589 tower29.hadSumTimeTimesE += ( e29 * recHit->
time() );
590 tower29.hadSumEForTime += e29;
595 tower29.E_outer += e29;
607 if (towerDetId.
null())
return;
614 else if (energy >= threshold) {
630 std::pair<DetId,float>
mc(detId,e);
642 if (towerDetId.
null())
return;
647 else if (energy >= threshold) {
649 if (towerDetId.
null())
return;
652 if (hcalDetId.
depth() == 1) {
676 std::pair<DetId,float>
mc(detId,e);
687 if (towerDetId.
null())
return;
691 else if (energy >= threshold) {
693 if (towerDetId.
null())
return;
714 if(theHcalPhase==0) {
722 else if(theHcalPhase==1) {
732 std::pair<DetId,float>
mc(detId,e);
746 unsigned int chStatusForCT;
747 bool ecalIsBad=
false;
757 double energy = recHit->
energy();
767 bool passEmThreshold =
false;
772 else passEmThreshold = (energy >=
threshold);
778 else passEmThreshold = (energy >=
threshold);
782 if (towerDetId.
null())
return;
824 std::pair<DetId,float>
mc(detId,e);
839 if (towerDetId.
null())
return;
869 std::pair<DetId, float>
mc(detId, 0);
901 assert(
id.rawId()!=0);
906 double E_had=mt.
E_had;
920 std::vector<std::pair<DetId,float> > metaContains_noecal;
922 for (std::vector<std::pair<DetId,float> >::iterator
i=metaContains.begin();
i!=metaContains.end(); ++
i)
923 if (
i->first.det()!=
DetId::Ecal) metaContains_noecal.push_back(*
i);
924 metaContains.swap(metaContains_noecal);
933 std::vector<std::pair<DetId,float> > metaContains_nohcal;
935 for (std::vector<std::pair<DetId,float> >::iterator
i=metaContains.begin();
i!=metaContains.end(); ++
i)
936 if (
i->first.det()!=
DetId::Hcal) metaContains_nohcal.push_back(*
i);
937 metaContains.swap(metaContains_nohcal);
940 if(metaContains.empty())
return;
958 double momEmDepth = 0.;
959 double momHadDepth = 0.;
960 if (
id.ietaAbs()<=17) {
994 emPoint =
emShwrPos(metaContains, momEmDepth, E_em);
1002 if ( (E_had + E_outer) >0) {
1003 massless = (E_em<=0);
1069 if UNLIKELY ( (towerP4[3]==0) & (E_outer>0) ) {
1071 collection.emplace_back(
id, E_em, E_had, E_outer, -1, -1,
CaloTower::PolarLorentzVector(val,hadPoint.
eta(), hadPoint.
phi(),0), emPoint, hadPoint);
1073 collection.emplace_back(
id, E_em, E_had, E_outer, -1, -1,
GlobalVector(towerP4), towerP4[3], mass2, emPoint, hadPoint);
1075 auto & caloTower = collection.
back();
1101 unsigned int numBadEcalChan = 0;
1110 if (dropChItr !=
hcalDropChMap.end()) numBadHcalChan += dropChItr->second;
1167 caloTower.setCaloTowerStatus(numBadHcalChan, numBadEcalChan,
1168 numRecHcalChan, numRecEcalChan,
1169 numProbHcalChan, numProbEcalChan);
1171 double maxCellE = -999.0;
1174 contains.reserve(metaContains.size());
1175 for (std::vector<std::pair<DetId,float> >::iterator
i=metaContains.begin();
i!=metaContains.end(); ++
i) {
1177 contains.push_back(
i->first);
1179 if (maxCellE < i->
second) {
1187 maxCellE =
i->second;
1191 maxCellE =
i->second;
1199 caloTower.setConstituents(
std::move(contains));
1200 caloTower.setHottestCellE(maxCellE);
1271 else if(hcalDetId.
ieta() < 0) {
1286 if(hcalDetId.
depth() == 1) {
1304 edm::LogError(
"CaloTowersCreationAlgo") <<
"Bad cell: " << det << std::endl;
1353 if (fracDepth<=0)
return point;
1354 if (fracDepth>1) fracDepth=1;
1356 const GlobalPoint& backPoint = cellGeometry->getBackPoint();
1357 point += fracDepth * (backPoint-
point);
1369 float fracDepth,
double hadE) {
1374 std::cout <<
"hadShwrPos called with " << metaContains.size()
1375 <<
" elements and energy " << hadE <<
":" << fracDepth
1386 std::vector<std::pair<DetId,float> >::const_iterator mc_it = metaContains.begin();
1387 for (; mc_it!=metaContains.end(); ++mc_it) {
1402 return GlobalPoint(hadX/nConst, hadY/nConst, hadZ/nConst);
1413 std::cout <<
"hadShwrPos " << towerId <<
" frac " << fracDepth << std::endl;
1415 if (fracDepth < 0) fracDepth = 0;
1416 else if (fracDepth > 1) fracDepth = 1;
1420 int iEta = towerId.
ieta();
1421 int iPhi = towerId.
iphi();
1433 int frontDepth = 1000;
1434 int backDepth = -1000;
1435 for(
unsigned i = 0;
i < items.size();
i++){
1451 std::cout <<
"Front " << frontCellId <<
" Back " << backCellId
1452 <<
" Depths " << frontDepth <<
":" << backDepth << std::endl;
1459 std::cout << towerId28 <<
" with " << items28.size() <<
" constituents:";
1460 for (
unsigned k=0;
k<items28.size(); ++
k)
1464 for(
unsigned i = 0;
i < items28.size();
i++){
1475 std::cout <<
"Back " << backDepth <<
" ID " << backCellId << std::endl;
1488 HcalDetId hid1(frontCellId), hid2(backCellId);
1504 const GlobalPoint& backPoint = backCellGeometry->getBackPoint();
1506 point += fracDepth * (backPoint -
point);
1513 float fracDepth,
double emE) {
1523 std::vector<std::pair<DetId,float> >::const_iterator mc_it = metaContains.begin();
1524 for (; mc_it!=metaContains.end(); ++mc_it) {
1527 double e = mc_it->second;
1543 float fracDepth,
double emE) {
1550 double sumWeights = 0;
1552 double crystalThresh = 0.015 * emE;
1554 std::vector<std::pair<DetId,float> >::const_iterator mc_it = metaContains.begin();
1555 for (; mc_it!=metaContains.end(); ++mc_it) {
1556 if (mc_it->second < 0)
continue;
1557 if (mc_it->first.det() ==
DetId::Ecal && mc_it->second > crystalThresh) sumEmE += mc_it->second;
1560 for (mc_it = metaContains.begin(); mc_it!=metaContains.end(); ++mc_it) {
1562 if (mc_it->first.det() !=
DetId::Ecal || mc_it->second < crystalThresh)
continue;
1566 weight = 4.2 +
log(mc_it->second/sumEmE);
1574 return GlobalPoint(emX/sumWeights, emY/sumWeights, emZ/sumWeights);
1583 const float timeUnit = 0.01;
1585 if (time> 300.0)
return 30000;
1586 if (time< -300.0)
return -30000;
1588 return int(time/timeUnit + 0.5);
1610 std::cout <<
"DropChMap with " << allChanInStatusCont.size() <<
" channels" 1613 for (std::vector<DetId>::iterator it = allChanInStatusCont.begin(); it!=allChanInStatusCont.end(); ++it) {
1658 for (std::vector<DetId>::iterator ac_it=allConstituents.begin();
1659 ac_it!=allConstituents.end(); ++ac_it) {
1698 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
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::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)