128 auto rechits = std::make_unique<std::vector<reco::PFRecHit>>();
129 auto rechitsCleaned = std::make_unique<std::vector<reco::PFRecHit>>();
130 auto HFHADRecHits = std::make_unique<std::vector<reco::PFRecHit>>();
131 auto HFEMRecHits = std::make_unique<std::vector<reco::PFRecHit>>();
143 for (
auto const& ct : *caloTowers) {
150 double energy = ct.hadEnergy();
152 double energyEM = ct.emEnergy();
154 if ((energy + energyEM) < 1
e-9)
158 const std::vector<DetId>&
hits = ct.constituents();
161 bool foundHCALConstituent =
false;
165 for (
auto hit : hits) {
167 foundHCALConstituent =
true;
174 for (
auto allConstituent : allConstituents) {
205 if (foundHCALConstituent) {
211 if (rescaleFactor > 1.) {
213 pfrhCleaned->
setTime(rescaleFactor);
214 energy *= rescaleFactor;
225 if (rescaleFactor > 1.) {
227 pfrhCleaned->
setTime(rescaleFactor);
228 energy *= rescaleFactor;
246 double longFibre = energyemHF + energyhadHF / 2.;
247 double shortFibre = energyhadHF / 2.;
253 auto theLongHit = hfHandle->
find(theLongDetId);
254 auto theShortHit = hfHandle->
find(theShortDetId);
256 double theLongHitEnergy = 0.;
257 double theShortHitEnergy = 0.;
258 bool flagShortDPG =
false;
259 bool flagLongDPG =
false;
260 bool flagShortTimeDPG =
false;
261 bool flagLongTimeDPG =
false;
262 bool flagShortPulseDPG =
false;
263 bool flagLongPulseDPG =
false;
265 if (theLongHit != hfHandle->
end()) {
266 int theLongFlag = theLongHit->flags();
267 theLongHitEnergy = theLongHit->energy();
283 if (theShortHit != hfHandle->
end()) {
284 int theShortFlag = theShortHit->flags();
285 theShortHitEnergy = theShortHit->energy();
287 theShortDetId, theShortFlag & hcalHFLongShortFlagValue_, 0) >
290 theShortDetId, theShortFlag & hcalHFInTimeWindowFlagValue_, 0) >
303 flagShortTimeDPG || flagShortPulseDPG)) {
306 pfrhHFHADCleaned->
setTime(theShortHit->time());
319 shortFibre -= theShortHitEnergy;
320 theShortHitEnergy = 0.;
328 pfrhHFEMCleaned->
setTime(theLongHit->time());
341 longFibre -= theLongHitEnergy;
342 theLongHitEnergy = 0.;
351 unsigned theStatusValue = theStatus->
getValue();
352 int theSeverityLevel = hcalSevLvlComputer->
getSeverityLevel(detid, 0, theStatusValue);
359 pfrhHFHADCleaned->
setTime(theShortHit->time());
373 shortFibre -= theShortHitEnergy;
374 theShortHitEnergy = 0.;
383 unsigned theStatusValue = theStatus->
getValue();
385 int theSeverityLevel = hcalSevLvlComputer->
getSeverityLevel(detid, 0, theStatusValue);
391 pfrhHFEMCleaned->
setTime(theLongHit->time());
405 longFibre -= theLongHitEnergy;
406 theLongHitEnergy = 0.;
412 if (
abs(ieta) == 29) {
418 pfrhHFEMCleaned29->
setTime(theLongHit->time());
426 longFibre -= theLongHitEnergy;
427 theLongHitEnergy = 0.;
433 pfrhHFHADCleaned29->
setTime(theShortHit->time());
441 shortFibre -= theShortHitEnergy;
442 theShortHitEnergy = 0.;
448 else if (
abs(ieta) == 30) {
449 int ieta29 = ieta > 0 ? 29 : -29;
452 auto theLongHit29 = hfHandle->
find(theLongDetId29);
453 auto theShortHit29 = hfHandle->
find(theShortDetId29);
455 double theLongHitEnergy29 = 0.;
456 double theShortHitEnergy29 = 0.;
457 bool flagShortDPG29 =
false;
458 bool flagLongDPG29 =
false;
459 bool flagShortTimeDPG29 =
false;
460 bool flagLongTimeDPG29 =
false;
461 bool flagShortPulseDPG29 =
false;
462 bool flagLongPulseDPG29 =
false;
464 if (theLongHit29 != hfHandle->
end()) {
465 int theLongFlag29 = theLongHit29->flags();
466 theLongHitEnergy29 = theLongHit29->energy();
468 theLongDetId29, theLongFlag29 & hcalHFLongShortFlagValue_, 0) >
472 theLongFlag29 & hcalHFInTimeWindowFlagValue_,
483 if (theShortHit29 != hfHandle->
end()) {
484 int theShortFlag29 = theShortHit29->flags();
485 theShortHitEnergy29 = theShortHit29->energy();
492 theShortFlag29 & hcalHFInTimeWindowFlagValue_,
506 flagLongTimeDPG29 || flagLongPulseDPG29)) {
510 pfrhHFEMCleaned29->
setTime(theLongHit29->time());
523 longFibre -= theLongHitEnergy29;
524 theLongHitEnergy29 = 0;
529 flagShortTimeDPG29 || flagShortPulseDPG29)) {
533 pfrhHFHADCleaned29->
setTime(theShortHit29->time());
546 shortFibre -= theShortHitEnergy29;
547 theShortHitEnergy29 = 0;
552 (theLongHitEnergy29 / theShortHitEnergy29 < 2. *
longFibre_Fraction || flagShortDPG29)) {
556 unsigned theStatusValue = theStatus->
getValue();
558 int theSeverityLevel = hcalSevLvlComputer->
getSeverityLevel(detid, 0, theStatusValue);
565 pfrhHFHADCleaned29->
setTime(theShortHit29->time());
579 shortFibre -= theShortHitEnergy29;
580 theShortHitEnergy29 = 0.;
590 unsigned theStatusValue = theStatus->
getValue();
591 int theSeverityLevel = hcalSevLvlComputer->
getSeverityLevel(detid, 0, theStatusValue);
598 pfrhHFEMCleaned29->
setTime(theLongHit29->time());
612 longFibre -= theLongHitEnergy29;
613 theLongHitEnergy29 = 0.;
622 pfrhHFEMCleaned29->
setTime(theLongHit29->time());
630 longFibre -= theLongHitEnergy29;
631 theLongHitEnergy29 = 0.;
637 pfrhHFHADCleaned29->
setTime(theShortHit29->time());
645 shortFibre -= theShortHitEnergy29;
646 theShortHitEnergy29 = 0.;
651 energyhadHF = 2. * shortFibre;
652 energyemHF = longFibre - shortFibre;
658 energyhadHF += energyemHF;
676 LogError(
"PFCTRecHitProducerHCAL") <<
"CaloTower constituent: unknown layer : " << detid.
subdet() << endl;
684 rechitsCleaned->push_back(*pfrhCleaned);
688 HFEMRecHits->push_back(*pfrhHFEM);
692 HFHADRecHits->push_back(*pfrhHFHAD);
695 if (pfrhHFEMCleaned) {
696 rechitsCleaned->push_back(*pfrhHFEMCleaned);
697 delete pfrhHFEMCleaned;
699 if (pfrhHFHADCleaned) {
700 rechitsCleaned->push_back(*pfrhHFHADCleaned);
701 delete pfrhHFHADCleaned;
703 if (pfrhHFEMCleaned29) {
704 rechitsCleaned->push_back(*pfrhHFEMCleaned29);
705 delete pfrhHFEMCleaned29;
707 if (pfrhHFHADCleaned29) {
708 rechitsCleaned->push_back(*pfrhHFHADCleaned29);
709 delete pfrhHFHADCleaned29;
719 for (
unsigned int i = 0;
i <
rechits->size(); ++
i) {
726 for (
unsigned int i = 0;
i < HFEMRecHits->size(); ++
i) {
727 navigator_->associateNeighbours(HFEMRecHits->at(
i), HFEMRecHits, refProdEM);
732 for (
unsigned int i = 0;
i < HFHADRecHits->size(); ++
i) {
733 navigator_->associateNeighbours(HFHADRecHits->at(
i), HFHADRecHits, refProdHAD);
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
unsigned int ECAL_Dead_Code_
HcalSubdetector subdet() const
get the subdetector
bool getByToken(EDGetToken token, Handle< PROD > &result) const
double thresh_HF_
threshold for HF
edm::EDGetTokenT< HBHERecHitCollection > hcalToken_
std::vector< CaloTower >::const_iterator const_iterator
edm::EDGetTokenT< CaloTowerCollection > towersToken_
int hcalHFLongShortFlagValue_
std::vector< PFRecHit > PFRecHitCollection
collection of PFRecHit objects
const Item * getValues(DetId fId, bool throwOnFail=true) const
reco::PFRecHit * createHcalRecHit(const DetId &detid, double energy, PFLayer::Layer layer, const CaloSubdetectorGeometry *geom, const CaloTowerDetId &newDetId)
edm::EDGetTokenT< HFRecHitCollection > hfToken_
double longFibre_Fraction
bool getMergePositionFlag() const
double longShortFibre_Cut
std::vector< DetId > constituentsOf(const CaloTowerDetId &id) const
Get the constituent detids for this tower id ( not yet implemented )
double ECAL_Compensation_
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
double minShortTiming_Cut
int HcalMaxAllowedHFInTimeWindowSev_
const HcalChannelQuality * theHcalChStatus
int ieta() const
get the cell ieta
int hcalHFDigiTimeFlagValue_
Abs< T >::type abs(const T &t)
int HcalMaxAllowedHFLongShortSev_
int HcalMaxAllowedHFDigiTimeSev_
void setTime(double time)
RefProd< PROD > getRefBeforePut()
const CaloTowerConstituentsMap * theTowerConstituentsMap
const_iterator end() const
int iphi() const
get the cell iphi
const HcalTopology * theHcalTopology
double maxShortTiming_Cut
double shortFibre_Fraction
int getSeverityLevel(const DetId &myid, const uint32_t &myflag, const uint32_t &mystatus) const
std::unique_ptr< PFRecHitNavigatorBase > navigator_
iterator find(key_type k)
const EcalChannelStatus * theEcalChStatus
const_iterator find(uint32_t rawId) const
HcalDetId idFront(const HcalDetId &id) const
const_iterator end() const
uint32_t getValue() const
int hcalHFInTimeWindowFlagValue_
T const * product() const
int HcalMaxAllowedChannelStatusSev_