110 produces<reco::PFRecHitCollection>(
"HFHAD").setBranchAlias(
"HFHADRecHits");
111 produces<reco::PFRecHitCollection>(
"HFEM").setBranchAlias(
"HFEMRecHits");
122 vector<reco::PFRecHit>& rechitsCleaned,
134 map<unsigned, unsigned > idSortedRecHits;
135 map<unsigned, unsigned > idSortedRecHitsHFEM;
136 map<unsigned, unsigned > idSortedRecHitsHFHAD;
137 typedef map<unsigned, unsigned >::iterator
IDH;
157 auto_ptr< vector<reco::PFRecHit> > HFHADRecHits(
new vector<reco::PFRecHit> );
158 auto_ptr< vector<reco::PFRecHit> > HFEMRecHits(
new vector<reco::PFRecHit> );
187 LogError(
"PFRecHitProducerHCAL")<<err.str()<<endl;
192 assert( caloTowers.
isValid() );
202 LogError(
"PFRecHitProducerHCAL")<<err.str()<<endl;
207 assert( hfHandle.isValid() );
218 LogError(
"PFRecHitProducerHCAL")<<err.str()<<endl;
223 assert( hbheHandle.
isValid() );
229 for(ICT ict=caloTowers->begin(); ict!=caloTowers->end();ict++) {
234 if(!caloTowerGeometry)
235 caloTowerGeometry = geoHandle->getSubdetectorGeometry(ct.
id());
248 if( (energy+energyEM) < 1
e-9 )
continue;
286 bool foundHCALConstituent =
false;
292 for(
unsigned int i=0;
i< hits.size();++
i) {
294 foundHCALConstituent =
true;
298 for(
unsigned int j=0;
j<allConstituents.size();++
j) {
327 if(foundHCALConstituent)
330 switch( detid.
subdet() ) {
355 if ( rescaleFactor > 1. ) {
362 energy *= rescaleFactor;
396 if ( rescaleFactor > 1. ) {
403 energy *= rescaleFactor;
425 if((energyemHF+energyhadHF) <
thresh_HF_ )
continue;
428 double longFibre = energyemHF + energyhadHF/2.;
429 double shortFibre = energyhadHF/2.;
430 int ieta = detid.
ieta();
431 int iphi = detid.
iphi();
435 iHF theLongHit = hfHandle->find(theLongDetId);
436 iHF theShortHit = hfHandle->find(theShortDetId);
438 double theLongHitEnergy = 0.;
439 double theShortHitEnergy = 0.;
440 bool flagShortDPG =
false;
441 bool flagLongDPG =
false;
442 bool flagShortTimeDPG =
false;
443 bool flagLongTimeDPG =
false;
444 bool flagShortPulseDPG =
false;
445 bool flagLongPulseDPG =
false;
447 if ( theLongHit != hfHandle->end() ) {
448 int theLongFlag = theLongHit->flags();
449 theLongHitEnergy = theLongHit->energy();
459 if ( theShortHit != hfHandle->end() ) {
460 int theShortFlag = theShortHit->flags();
461 theShortHitEnergy = theShortHit->energy();
474 flagShortTimeDPG || flagShortPulseDPG ) ) {
481 pfrhHFHADCleaned->
setRescale(theShortHit->time());
494 shortFibre -= theShortHitEnergy;
495 theShortHitEnergy = 0.;
502 flagLongTimeDPG || flagLongPulseDPG ) ) {
509 pfrhHFEMCleaned->
setRescale(theLongHit->time());
522 longFibre -= theLongHitEnergy;
523 theLongHitEnergy = 0.;
533 unsigned theStatusValue = theStatus->
getValue();
534 int theSeverityLevel = hcalSevLvlComputer->
getSeverityLevel(detid, 0, theStatusValue);
544 pfrhHFHADCleaned->
setRescale(theShortHit->time());
558 shortFibre -= theShortHitEnergy;
559 theShortHitEnergy = 0.;
569 unsigned theStatusValue = theStatus->
getValue();
571 int theSeverityLevel = hcalSevLvlComputer->
getSeverityLevel(detid, 0, theStatusValue);
582 pfrhHFEMCleaned->
setRescale(theLongHit->time());
596 longFibre -= theLongHitEnergy;
597 theLongHitEnergy = 0.;
603 if (
abs(ieta) == 29 ) {
612 pfrhHFEMCleaned29->
setRescale(theLongHit->time());
620 longFibre -= theLongHitEnergy;
621 theLongHitEnergy = 0.;
630 pfrhHFHADCleaned29->
setRescale(theShortHit->time());
638 shortFibre -= theShortHitEnergy;
639 theShortHitEnergy = 0.;
645 else if (
abs(ieta) == 30 ) {
646 int ieta29 = ieta > 0 ? 29 : -29;
649 iHF theLongHit29 = hfHandle->find(theLongDetId29);
650 iHF theShortHit29 = hfHandle->find(theShortDetId29);
652 double theLongHitEnergy29 = 0.;
653 double theShortHitEnergy29 = 0.;
654 bool flagShortDPG29 =
false;
655 bool flagLongDPG29 =
false;
656 bool flagShortTimeDPG29 =
false;
657 bool flagLongTimeDPG29 =
false;
658 bool flagShortPulseDPG29 =
false;
659 bool flagLongPulseDPG29 =
false;
661 if ( theLongHit29 != hfHandle->end() ) {
662 int theLongFlag29 = theLongHit29->flags();
663 theLongHitEnergy29 = theLongHit29->energy() ;
673 if ( theShortHit29 != hfHandle->end() ) {
674 int theShortFlag29 = theShortHit29->flags();
675 theShortHitEnergy29 = theShortHit29->energy();
688 flagLongTimeDPG29 || flagLongPulseDPG29 ) ) {
695 pfrhHFEMCleaned29->
setRescale(theLongHit29->time());
708 longFibre -= theLongHitEnergy29;
709 theLongHitEnergy29 = 0;
715 flagShortTimeDPG29 || flagShortPulseDPG29 ) ) {
722 pfrhHFHADCleaned29->
setRescale(theShortHit29->time());
735 shortFibre -= theShortHitEnergy29;
736 theShortHitEnergy29 = 0.;
746 unsigned theStatusValue = theStatus->
getValue();
748 int theSeverityLevel = hcalSevLvlComputer->
getSeverityLevel(detid, 0, theStatusValue);
758 pfrhHFHADCleaned29->
setRescale(theShortHit29->time());
772 shortFibre -= theShortHitEnergy29;
773 theShortHitEnergy29 = 0.;
784 unsigned theStatusValue = theStatus->
getValue();
785 int theSeverityLevel = hcalSevLvlComputer->
getSeverityLevel(detid, 0, theStatusValue);
796 pfrhHFEMCleaned29->
setRescale(theLongHit29->time());
810 longFibre -= theLongHitEnergy29;
811 theLongHitEnergy29 = 0.;
823 pfrhHFEMCleaned29->
setRescale(theLongHit29->time());
831 longFibre -= theLongHitEnergy29;
832 theLongHitEnergy29 = 0.;
841 pfrhHFHADCleaned29->
setRescale(theShortHit29->time());
849 shortFibre -= theShortHitEnergy29;
850 theShortHitEnergy29 = 0.;
856 energyhadHF = 2.*shortFibre;
857 energyemHF = longFibre - shortFibre;
863 energyhadHF += energyemHF;
886 pfrhHFHAD->setEnergyUp(energyemHF);
893 <<
"CaloTower constituent: unknown layer : "
898 rechits.push_back( *pfrh );
900 idSortedRecHits.insert( make_pair(ct.
id().
rawId(),
901 rechits.size()-1 ) );
904 rechitsCleaned.push_back( *pfrhCleaned );
909 HFEMRecHits->push_back( *pfrhHFEM );
911 idSortedRecHitsHFEM.insert( make_pair(ct.
id().
rawId(),
912 HFEMRecHits->size()-1 ) );
915 HFHADRecHits->push_back( *pfrhHFHAD );
917 idSortedRecHitsHFHAD.insert( make_pair(ct.
id().
rawId(),
918 HFHADRecHits->size()-1 ) );
921 if(pfrhHFEMCleaned) {
922 rechitsCleaned.push_back( *pfrhHFEMCleaned );
923 delete pfrhHFEMCleaned;
925 if(pfrhHFHADCleaned) {
926 rechitsCleaned.push_back( *pfrhHFHADCleaned );
927 delete pfrhHFHADCleaned;
929 if(pfrhHFEMCleaned29) {
930 rechitsCleaned.push_back( *pfrhHFEMCleaned29 );
931 delete pfrhHFEMCleaned29;
933 if(pfrhHFHADCleaned29) {
934 rechitsCleaned.push_back( *pfrhHFHADCleaned29 );
935 delete pfrhHFHADCleaned29;
940 for(
unsigned i=0;
i<rechits.size();
i++ ) {
945 for(
unsigned i=0;
i<HFEMRecHits->size();
i++ ) {
950 for(
unsigned i=0;
i<HFHADRecHits->size();
i++ ) {
952 idSortedRecHitsHFHAD,
955 iEvent.
put( HFHADRecHits,
"HFHAD" );
956 iEvent.
put( HFEMRecHits,
"HFEM" );
978 LogError(
"PFRecHitProducerHCAL")<<err.str()<<endl;
983 assert( hcalHandle.
isValid() );
986 for(
unsigned irechit=0; irechit<handle->size(); irechit++) {
995 switch( detid.
subdet() ) {
1002 hcalBarrelGeometry );
1011 hcalEndcapGeometry );
1020 hcalEndcapGeometry );
1025 <<
"HCAL rechit: unknown layer : "<<detid.
subdet()<<endl;
1030 rechits.push_back( *pfrh );
1032 idSortedRecHits.insert( make_pair(detid.
rawId(),
1033 rechits.size()-1 ) );
1039 for(
unsigned i=0;
i<rechits.size();
i++ ) {
1043 *hcalBarrelGeometry,
1045 *hcalEndcapGeometry);
1061 unsigned newDetId ) {
1066 <<
"warning detid "<<detid.
rawId()<<
" not found in layer "
1073 double depth_correction = 0.;
1085 unsigned id =
detid;
1086 if(newDetId)
id = newDetId;
1089 position.
x(), position.
y(), position.
z()+depth_correction,
1098 assert( corners.size() == 8 );
1100 rh->
setNECorner( corners[0].
x(), corners[0].
y(), corners[0].
z()+depth_correction );
1101 rh->
setSECorner( corners[1].
x(), corners[1].
y(), corners[1].
z()+depth_correction );
1102 rh->
setSWCorner( corners[2].
x(), corners[2].
y(), corners[2].
z()+depth_correction );
1103 rh->
setNWCorner( corners[3].
x(), corners[3].
y(), corners[3].
z()+depth_correction );
1114 const map<unsigned,unsigned >& sortedHits,
1121 if(navigation_HF_ ==
false){
1132 switch( rh.
layer() ) {
1134 topology = &endcapTopology;
1135 geometry = &endcapGeometry;
1138 topology = &barrelTopology;
1139 geometry = &barrelGeometry;
1142 topology = &endcapTopology;
1143 geometry = &endcapGeometry;
1146 topology = &barrelTopology;
1147 geometry = &barrelGeometry;
1151 topology = &barrelTopology;
1152 geometry = &barrelGeometry;
1158 assert( topology && geometry );
1160 CaloNavigator<DetId> navigator(
detid, topology);
1165 if( north !=
DetId(0) ) {
1166 northeast = navigator.east();
1176 if( south !=
DetId(0) ) {
1177 southwest = navigator.west();
1184 if( east !=
DetId(0) ) {
1185 southeast = navigator.south();
1190 if( west !=
DetId(0) ) {
1191 northwest = navigator.north();
1195 IDH i = sortedHits.find( north.
rawId() );
1196 if(i != sortedHits.end() )
1199 i = sortedHits.find( northeast.
rawId() );
1200 if(i != sortedHits.end() )
1203 i = sortedHits.find( south.
rawId() );
1204 if(i != sortedHits.end() )
1207 i = sortedHits.find( southwest.
rawId() );
1208 if(i != sortedHits.end() )
1211 i = sortedHits.find( east.
rawId() );
1212 if(i != sortedHits.end() )
1215 i = sortedHits.find( southeast.
rawId() );
1216 if(i != sortedHits.end() )
1219 i = sortedHits.find( west.
rawId() );
1220 if(i != sortedHits.end() )
1223 i = sortedHits.find( northwest.
rawId() );
1224 if(i != sortedHits.end() )
1234 const map<unsigned, unsigned >& sortedHits,
1242 if(navigation_HF_ ==
false){
1251 vector<DetId> northids = topology.
north(ctDetId);
1252 vector<DetId> westids = topology.
west(ctDetId);
1253 vector<DetId> southids = topology.
south(ctDetId);
1254 vector<DetId> eastids = topology.
east(ctDetId);
1277 switch( northids.size() ) {
1281 north = northids[0];
1284 stringstream err(
"PFRecHitProducerHCAL::findRecHitNeighboursCT : incorrect number of neighbours north: ");
1285 err<<northids.size();
1289 switch( southids.size() ) {
1293 south = southids[0];
1296 stringstream err(
"PFRecHitProducerHCAL::findRecHitNeighboursCT : incorrect number of neighbours south: ");
1297 err<<southids.size();
1304 switch( eastids.size() ) {
1309 northeast = getNorth(east, topology);
1310 southeast = getSouth(east, topology);
1316 northeast = getNorth(east, topology );
1317 southeast = getSouth(east2, topology);
1318 northeast2 = getNorth(northeast, topology );
1319 southeast2 = getSouth(southeast, topology);
1322 stringstream err(
"PFRecHitProducerHCAL::findRecHitNeighboursCT : incorrect number of neighbours eastids: ");
1323 err<<eastids.size();
1328 switch( westids.size() ) {
1333 northwest = getNorth(west, topology);
1334 southwest = getSouth(west, topology);
1340 northwest = getNorth(west, topology );
1341 southwest = getSouth(west2, topology );
1342 northwest2 = getNorth(northwest, topology );
1343 southwest2 = getSouth(southwest, topology );
1346 stringstream err(
"PFRecHitProducerHCAL::findRecHitNeighboursCT : incorrect number of neighbours westids: ");
1347 err<< westids.size();
1356 IDH i = sortedHits.find( north.
rawId() );
1357 if(i != sortedHits.end() )
1360 i = sortedHits.find( northeast.
rawId() );
1361 if(i != sortedHits.end() )
1364 i = sortedHits.find( northeast2.
rawId() );
1365 if(i != sortedHits.end() )
1368 i = sortedHits.find( south.
rawId() );
1369 if(i != sortedHits.end() )
1372 i = sortedHits.find( southwest.
rawId() );
1373 if(i != sortedHits.end() )
1376 i = sortedHits.find( southwest2.
rawId() );
1377 if(i != sortedHits.end() )
1380 i = sortedHits.find( east.
rawId() );
1381 if(i != sortedHits.end() )
1384 i = sortedHits.find( east2.
rawId() );
1385 if(i != sortedHits.end() )
1388 i = sortedHits.find( southeast.
rawId() );
1389 if(i != sortedHits.end() )
1392 i = sortedHits.find( southeast2.
rawId() );
1393 if(i != sortedHits.end() )
1396 i = sortedHits.find( west.
rawId() );
1397 if(i != sortedHits.end() )
1400 i = sortedHits.find( west2.
rawId() );
1401 if(i != sortedHits.end() )
1404 i = sortedHits.find( northwest.
rawId() );
1405 if(i != sortedHits.end() )
1408 i = sortedHits.find( northwest2.
rawId() );
1409 if(i != sortedHits.end() )
1426 vector<DetId> sids = topology.
south(
id);
1427 if(sids.size() == 1)
1440 vector<DetId> nids = topology.
north(
id);
1441 if(nids.size() == 1)
void setSECorner(double posx, double posy, double posz)
T getParameter(std::string const &) const
void add4Neighbour(unsigned index)
int HcalMaxAllowedHFDigiTimeSev_
void add8Neighbour(unsigned index)
size_t constituentsSize() const
void setNECorner(double posx, double posy, double posz)
HcalSubdetector subdet() const
get the subdetector
const DetId & detid() const
unsigned detId() const
rechit detId
int HcalMaxAllowedChannelStatusSev_
unsigned int ECAL_Dead_Code_
std::vector< CaloTower >::const_iterator const_iterator
virtual std::vector< DetId > west(const DetId &id) const =0
int hcalHFLongShortFlagValue_
const Item * getValues(DetId fId, bool throwOnFail=true) const
reco::PFRecHit * createHcalRecHit(const DetId &detid, double energy, PFLayer::Layer layer, const CaloSubdetectorGeometry *geom, unsigned newDetId=0)
const EcalChannelStatus * theEcalChStatus
int HcalMaxAllowedHFLongShortSev_
static int position[TOTALCHAMBERS][3]
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 )
double minShortTiming_Cut
double ECAL_Compensation_
uint32_t rawId() const
get the raw id
PFLayer::Layer layer() const
rechit layer
void setSWCorner(double posx, double posy, double posz)
double longShortFibre_Cut
edm::InputTag inputTagCaloTowers_
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Base producer for particle flow rechits (PFRecHit)
const T & max(const T &a, const T &b)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
double shortFibre_Fraction
void setEnergyUp(double eUp)
edm::InputTag inputTagHcalRecHitsHF_
int ieta() const
get the cell ieta
const std::vector< DetId > & constituents() const
DetId getSouth(const DetId &id, const CaloSubdetectorTopology &topology)
void setRescale(double factor)
double longFibre_Fraction
void setNWCorner(double posx, double posy, double posz)
search for pointers to neighbours, using neighbours' DetId.
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
edm::InputTag inputTagHcalRecHitsHBHE_
void findRecHitNeighbours(reco::PFRecHit &rh, const std::map< unsigned, unsigned > &sortedHits, const CaloSubdetectorTopology &barrelTopo, const CaloSubdetectorGeometry &barrelGeom, const CaloSubdetectorTopology &endcapTopo, const CaloSubdetectorGeometry &endcapGeom)
void findRecHitNeighboursCT(reco::PFRecHit &rh, const std::map< unsigned, unsigned > &sortedHits, const CaloSubdetectorTopology &topology)
virtual std::vector< DetId > north(const DetId &id) const =0
int iphi() const
get the cell iphi
CaloTowerDetId id() const
const HcalChannelQuality * theHcalChStatus
void createRecHits(std::vector< reco::PFRecHit > &rechits, std::vector< reco::PFRecHit > &rechitsCleaned, edm::Event &, const edm::EventSetup &)
int hcalHFDigiTimeFlagValue_
std::vector< Item >::const_iterator const_iterator
T const * product() const
int getSeverityLevel(const DetId &myid, const uint32_t &myflag, const uint32_t &mystatus) const
int hcalHFInTimeWindowFlagValue_
int HcalMaxAllowedHFInTimeWindowSev_
const CaloTowerConstituentsMap * theTowerConstituentsMap
ESHandle< TrackerGeometry > geometry
std::map< unsigned, unsigned >::const_iterator IDH
virtual std::vector< DetId > south(const DetId &id) const =0
const_iterator find(uint32_t rawId) const
double thresh_Barrel_
rechits with E < threshold will not give rise to a PFRecHit
const_iterator end() const
double thresh_HF_
threshold for HF
DetId getNorth(const DetId &id, const CaloSubdetectorTopology &topology)
double maxShortTiming_Cut
uint32_t getValue() const
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
virtual std::vector< DetId > east(const DetId &id) const =0
PFRecHitProducerHCAL(const edm::ParameterSet &)
virtual const CornersVec & getCorners() const =0
Returns the corner points of this cell's volume.