102 produces<reco::PFRecHitCollection>(
"HFHAD").setBranchAlias(
"HFHADRecHits");
103 produces<reco::PFRecHitCollection>(
"HFEM").setBranchAlias(
"HFEMRecHits");
114 vector<reco::PFRecHit>& rechitsCleaned,
126 map<unsigned, unsigned > idSortedRecHits;
127 map<unsigned, unsigned > idSortedRecHitsHFEM;
128 map<unsigned, unsigned > idSortedRecHitsHFHAD;
129 typedef map<unsigned, unsigned >::iterator
IDH;
144 auto_ptr< vector<reco::PFRecHit> > HFHADRecHits(
new vector<reco::PFRecHit> );
145 auto_ptr< vector<reco::PFRecHit> > HFEMRecHits(
new vector<reco::PFRecHit> );
174 LogError(
"PFRecHitProducerHCAL")<<err.str()<<endl;
179 assert( caloTowers.
isValid() );
189 LogError(
"PFRecHitProducerHCAL")<<err.str()<<endl;
194 assert( hfHandle.isValid() );
205 LogError(
"PFRecHitProducerHCAL")<<err.str()<<endl;
210 assert( hbheHandle.
isValid() );
216 for(ICT ict=caloTowers->begin(); ict!=caloTowers->end();ict++) {
221 if(!caloTowerGeometry)
222 caloTowerGeometry = geoHandle->getSubdetectorGeometry(ct.
id());
235 if( (energy+energyEM) < 1
e-9 )
continue;
273 bool foundHCALConstituent =
false;
279 for(
unsigned int i=0;
i< hits.size();++
i) {
281 foundHCALConstituent =
true;
285 for(
unsigned int j=0;
j<allConstituents.size();++
j) {
314 if(foundHCALConstituent)
317 switch( detid.
subdet() ) {
342 if ( rescaleFactor > 1. ) {
349 energy *= rescaleFactor;
382 if ( rescaleFactor > 1. ) {
389 energy *= rescaleFactor;
411 if((energyemHF+energyhadHF) <
thresh_HF_ )
continue;
414 double longFibre = energyemHF + energyhadHF/2.;
415 double shortFibre = energyhadHF/2.;
416 int ieta = detid.
ieta();
417 int iphi = detid.
iphi();
421 iHF theLongHit = hfHandle->find(theLongDetId);
422 iHF theShortHit = hfHandle->find(theShortDetId);
424 double theLongHitEnergy = 0.;
425 double theShortHitEnergy = 0.;
426 bool flagShortDPG =
false;
427 bool flagLongDPG =
false;
428 bool flagShortTimeDPG =
false;
429 bool flagLongTimeDPG =
false;
430 bool flagShortPulseDPG =
false;
431 bool flagLongPulseDPG =
false;
433 if ( theLongHit != hfHandle->end() ) {
434 theLongHitEnergy = theLongHit->energy();
440 if ( theShortHit != hfHandle->end() ) {
441 theShortHitEnergy = theShortHit->energy();
451 flagShortTimeDPG || flagShortPulseDPG ) ) {
458 pfrhHFHADCleaned->
setRescale(theShortHit->time());
471 shortFibre -= theShortHitEnergy;
472 theShortHitEnergy = 0.;
479 flagLongTimeDPG || flagLongPulseDPG ) ) {
486 pfrhHFEMCleaned->
setRescale(theLongHit->time());
499 longFibre -= theLongHitEnergy;
500 theLongHitEnergy = 0.;
510 unsigned theStatusValue = theStatus->
getValue();
512 if ( !theStatusValue ) {
519 pfrhHFHADCleaned->
setRescale(theShortHit->time());
533 shortFibre -= theShortHitEnergy;
534 theShortHitEnergy = 0.;
544 unsigned theStatusValue = theStatus->
getValue();
546 if ( !theStatusValue ) {
553 pfrhHFEMCleaned->
setRescale(theLongHit->time());
567 longFibre -= theLongHitEnergy;
568 theLongHitEnergy = 0.;
574 if (
abs(ieta) == 29 ) {
583 pfrhHFEMCleaned29->
setRescale(theLongHit->time());
591 longFibre -= theLongHitEnergy;
592 theLongHitEnergy = 0.;
601 pfrhHFHADCleaned29->
setRescale(theShortHit->time());
609 shortFibre -= theShortHitEnergy;
610 theShortHitEnergy = 0.;
616 else if (
abs(ieta) == 30 ) {
617 int ieta29 = ieta > 0 ? 29 : -29;
620 iHF theLongHit29 = hfHandle->find(theLongDetId29);
621 iHF theShortHit29 = hfHandle->find(theShortDetId29);
623 double theLongHitEnergy29 = 0.;
624 double theShortHitEnergy29 = 0.;
625 bool flagShortDPG29 =
false;
626 bool flagLongDPG29 =
false;
627 bool flagShortTimeDPG29 =
false;
628 bool flagLongTimeDPG29 =
false;
629 bool flagShortPulseDPG29 =
false;
630 bool flagLongPulseDPG29 =
false;
632 if ( theLongHit29 != hfHandle->end() ) {
633 theLongHitEnergy29 = theLongHit29->energy() ;
639 if ( theShortHit29 != hfHandle->end() ) {
640 theShortHitEnergy29 = theShortHit29->energy();
649 flagLongTimeDPG29 || flagLongPulseDPG29 ) ) {
656 pfrhHFEMCleaned29->
setRescale(theLongHit29->time());
669 longFibre -= theLongHitEnergy29;
670 theLongHitEnergy29 = 0;
676 flagShortTimeDPG29 || flagShortPulseDPG29 ) ) {
683 pfrhHFHADCleaned29->
setRescale(theShortHit29->time());
696 shortFibre -= theShortHitEnergy29;
697 theShortHitEnergy29 = 0.;
707 unsigned theStatusValue = theStatus->
getValue();
709 if ( !theStatusValue ) {
716 pfrhHFHADCleaned29->
setRescale(theShortHit29->time());
730 shortFibre -= theShortHitEnergy29;
731 theShortHitEnergy29 = 0.;
742 unsigned theStatusValue = theStatus->
getValue();
744 if ( !theStatusValue ) {
751 pfrhHFEMCleaned29->
setRescale(theLongHit29->time());
765 longFibre -= theLongHitEnergy29;
766 theLongHitEnergy29 = 0.;
778 pfrhHFEMCleaned29->
setRescale(theLongHit29->time());
786 longFibre -= theLongHitEnergy29;
787 theLongHitEnergy29 = 0.;
796 pfrhHFHADCleaned29->
setRescale(theShortHit29->time());
804 shortFibre -= theShortHitEnergy29;
805 theShortHitEnergy29 = 0.;
811 energyhadHF = 2.*shortFibre;
812 energyemHF = longFibre - shortFibre;
818 energyhadHF += energyemHF;
842 pfrhHFHAD->setEnergyUp(energyemHF);
849 <<
"CaloTower constituent: unknown layer : "
854 rechits.push_back( *pfrh );
856 idSortedRecHits.insert( make_pair(ct.
id().
rawId(),
857 rechits.size()-1 ) );
860 rechitsCleaned.push_back( *pfrhCleaned );
865 HFEMRecHits->push_back( *pfrhHFEM );
867 idSortedRecHitsHFEM.insert( make_pair(ct.
id().
rawId(),
868 HFEMRecHits->size()-1 ) );
871 HFHADRecHits->push_back( *pfrhHFHAD );
873 idSortedRecHitsHFHAD.insert( make_pair(ct.
id().
rawId(),
874 HFHADRecHits->size()-1 ) );
877 if(pfrhHFEMCleaned) {
878 rechitsCleaned.push_back( *pfrhHFEMCleaned );
879 delete pfrhHFEMCleaned;
881 if(pfrhHFHADCleaned) {
882 rechitsCleaned.push_back( *pfrhHFHADCleaned );
883 delete pfrhHFHADCleaned;
885 if(pfrhHFEMCleaned29) {
886 rechitsCleaned.push_back( *pfrhHFEMCleaned29 );
887 delete pfrhHFEMCleaned29;
889 if(pfrhHFHADCleaned29) {
890 rechitsCleaned.push_back( *pfrhHFHADCleaned29 );
891 delete pfrhHFHADCleaned29;
896 for(
unsigned i=0;
i<rechits.size();
i++ ) {
901 for(
unsigned i=0;
i<HFEMRecHits->size();
i++ ) {
906 for(
unsigned i=0;
i<HFHADRecHits->size();
i++ ) {
908 idSortedRecHitsHFHAD,
911 iEvent.
put( HFHADRecHits,
"HFHAD" );
912 iEvent.
put( HFEMRecHits,
"HFEM" );
933 LogError(
"PFRecHitProducerHCAL")<<err.str()<<endl;
938 assert( hcalHandle.
isValid() );
941 for(
unsigned irechit=0; irechit<handle->size(); irechit++) {
950 switch( detid.
subdet() ) {
957 hcalBarrelGeometry );
966 hcalEndcapGeometry );
975 hcalEndcapGeometry );
980 <<
"HCAL rechit: unknown layer : "<<detid.
subdet()<<endl;
985 rechits.push_back( *pfrh );
987 idSortedRecHits.insert( make_pair(detid.
rawId(),
988 rechits.size()-1 ) );
994 for(
unsigned i=0;
i<rechits.size();
i++ ) {
1000 *hcalEndcapGeometry);
1016 unsigned newDetId ) {
1021 <<
"warning detid "<<detid.
rawId()<<
" not found in layer "
1028 double depth_correction = 0.;
1040 unsigned id =
detid;
1041 if(newDetId)
id = newDetId;
1044 position.
x(), position.
y(), position.
z()+depth_correction,
1053 assert( corners.size() == 8 );
1055 rh->
setNECorner( corners[0].
x(), corners[0].
y(), corners[0].
z()+depth_correction );
1056 rh->
setSECorner( corners[1].
x(), corners[1].
y(), corners[1].
z()+depth_correction );
1057 rh->
setSWCorner( corners[2].
x(), corners[2].
y(), corners[2].
z()+depth_correction );
1058 rh->
setNWCorner( corners[3].
x(), corners[3].
y(), corners[3].
z()+depth_correction );
1069 const map<unsigned,unsigned >& sortedHits,
1076 if(navigation_HF_ ==
false){
1088 switch( rh.
layer() ) {
1090 topology = &endcapTopology;
1091 geometry = &endcapGeometry;
1094 topology = &barrelTopology;
1095 geometry = &barrelGeometry;
1098 topology = &endcapTopology;
1099 geometry = &endcapGeometry;
1100 othergeometry = &barrelGeometry;
1103 topology = &barrelTopology;
1104 geometry = &barrelGeometry;
1105 othergeometry = &endcapGeometry;
1109 topology = &barrelTopology;
1110 geometry = &barrelGeometry;
1111 othergeometry = &endcapGeometry;
1117 assert( topology && geometry );
1124 if( north !=
DetId(0) ) {
1125 northeast = navigator.
east();
1135 if( south !=
DetId(0) ) {
1136 southwest = navigator.
west();
1143 if( east !=
DetId(0) ) {
1144 southeast = navigator.
south();
1149 if( west !=
DetId(0) ) {
1150 northwest = navigator.
north();
1154 IDH i = sortedHits.find( north.
rawId() );
1155 if(i != sortedHits.end() )
1158 i = sortedHits.find( northeast.
rawId() );
1159 if(i != sortedHits.end() )
1162 i = sortedHits.find( south.
rawId() );
1163 if(i != sortedHits.end() )
1166 i = sortedHits.find( southwest.
rawId() );
1167 if(i != sortedHits.end() )
1170 i = sortedHits.find( east.
rawId() );
1171 if(i != sortedHits.end() )
1174 i = sortedHits.find( southeast.
rawId() );
1175 if(i != sortedHits.end() )
1178 i = sortedHits.find( west.
rawId() );
1179 if(i != sortedHits.end() )
1182 i = sortedHits.find( northwest.
rawId() );
1183 if(i != sortedHits.end() )
1193 const map<unsigned, unsigned >& sortedHits,
1201 if(navigation_HF_ ==
false){
1210 vector<DetId> northids = topology.
north(ctDetId);
1211 vector<DetId> westids = topology.
west(ctDetId);
1212 vector<DetId> southids = topology.
south(ctDetId);
1213 vector<DetId> eastids = topology.
east(ctDetId);
1235 stringstream err(
"PFRecHitProducerHCAL::findRecHitNeighboursCT : incorrect number of neighbours ");
1237 switch( northids.size() ) {
1241 north = northids[0];
1244 err<<
"north: "<<northids.size();
1248 switch( southids.size() ) {
1252 south = southids[0];
1255 err<<
"south: "<<southids.size();
1262 switch( eastids.size() ) {
1267 northeast = getNorth(east, topology);
1268 southeast = getSouth(east, topology);
1274 northeast = getNorth(east, topology );
1275 southeast = getSouth(east2, topology);
1276 northeast2 = getNorth(northeast, topology );
1277 southeast2 = getSouth(southeast, topology);
1280 err<<
"eastids: "<<eastids.size();
1285 switch( westids.size() ) {
1290 northwest = getNorth(west, topology);
1291 southwest = getSouth(west, topology);
1297 northwest = getNorth(west, topology );
1298 southwest = getSouth(west2, topology );
1299 northwest2 = getNorth(northwest, topology );
1300 southwest2 = getSouth(southwest, topology );
1303 err<<
"westids: "<< westids.size();
1312 IDH i = sortedHits.find( north.
rawId() );
1313 if(i != sortedHits.end() )
1316 i = sortedHits.find( northeast.
rawId() );
1317 if(i != sortedHits.end() )
1320 i = sortedHits.find( northeast2.
rawId() );
1321 if(i != sortedHits.end() )
1324 i = sortedHits.find( south.
rawId() );
1325 if(i != sortedHits.end() )
1328 i = sortedHits.find( southwest.
rawId() );
1329 if(i != sortedHits.end() )
1332 i = sortedHits.find( southwest2.
rawId() );
1333 if(i != sortedHits.end() )
1336 i = sortedHits.find( east.
rawId() );
1337 if(i != sortedHits.end() )
1340 i = sortedHits.find( east2.
rawId() );
1341 if(i != sortedHits.end() )
1344 i = sortedHits.find( southeast.
rawId() );
1345 if(i != sortedHits.end() )
1348 i = sortedHits.find( southeast2.
rawId() );
1349 if(i != sortedHits.end() )
1352 i = sortedHits.find( west.
rawId() );
1353 if(i != sortedHits.end() )
1356 i = sortedHits.find( west2.
rawId() );
1357 if(i != sortedHits.end() )
1360 i = sortedHits.find( northwest.
rawId() );
1361 if(i != sortedHits.end() )
1364 i = sortedHits.find( northwest2.
rawId() );
1365 if(i != sortedHits.end() )
1382 vector<DetId> sids = topology.
south(
id);
1383 if(sids.size() == 1)
1396 vector<DetId> nids = topology.
north(
id);
1397 if(nids.size() == 1)
void setSECorner(double posx, double posy, double posz)
T getParameter(std::string const &) const
void add4Neighbour(unsigned index)
const HcalPFCorrs * myPFCorr
void add8Neighbour(unsigned index)
size_t constituentsSize() const
void setNECorner(double posx, double posy, double posz)
HcalSubdetector subdet() const
get the subdetector
void home() const
move the navigator back to the starting point
const DetId & detid() const
unsigned detId() const
rechit detId
unsigned int ECAL_Dead_Code_
virtual T west() const
move the navigator west
std::vector< CaloTower >::const_iterator const_iterator
virtual std::vector< DetId > west(const DetId &id) const =0
reco::PFRecHit * createHcalRecHit(const DetId &detid, double energy, PFLayer::Layer layer, const CaloSubdetectorGeometry *geom, unsigned newDetId=0)
const EcalChannelStatus * theEcalChStatus
virtual T north() const
move the navigator north
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_
virtual T east() const
move the navigator east
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 &)
std::vector< Item >::const_iterator const_iterator
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
virtual T south() const
move the navigator south
const Item * getValues(DetId fId) const
const GlobalPoint & getPosition() const
virtual std::vector< DetId > east(const DetId &id) const =0
PFRecHitProducerHCAL(const edm::ParameterSet &)
virtual const CornersVec & getCorners() const =0