104 produces<reco::PFRecHitCollection>(
"HFHAD").setBranchAlias(
"HFHADRecHits");
105 produces<reco::PFRecHitCollection>(
"HFEM").setBranchAlias(
"HFEMRecHits");
116 vector<reco::PFRecHit>& rechitsCleaned,
128 map<unsigned, unsigned > idSortedRecHits;
129 map<unsigned, unsigned > idSortedRecHitsHFEM;
130 map<unsigned, unsigned > idSortedRecHitsHFHAD;
131 typedef map<unsigned, unsigned >::iterator
IDH;
146 auto_ptr< vector<reco::PFRecHit> > HFHADRecHits(
new vector<reco::PFRecHit> );
147 auto_ptr< vector<reco::PFRecHit> > HFEMRecHits(
new vector<reco::PFRecHit> );
176 LogError(
"PFRecHitProducerHCAL")<<err.str()<<endl;
181 assert( caloTowers.
isValid() );
191 LogError(
"PFRecHitProducerHCAL")<<err.str()<<endl;
196 assert( hfHandle.isValid() );
207 LogError(
"PFRecHitProducerHCAL")<<err.str()<<endl;
212 assert( hbheHandle.
isValid() );
218 for(ICT ict=caloTowers->begin(); ict!=caloTowers->end();ict++) {
223 if(!caloTowerGeometry)
224 caloTowerGeometry = geoHandle->getSubdetectorGeometry(ct.
id());
237 if( (energy+energyEM) < 1e-9 )
continue;
275 bool foundHCALConstituent =
false;
281 for(
unsigned int i=0;
i< hits.size();++
i) {
283 foundHCALConstituent =
true;
287 for(
unsigned int j=0;
j<allConstituents.size();++
j) {
316 if(foundHCALConstituent)
319 switch( detid.
subdet() ) {
344 if ( rescaleFactor > 1. ) {
351 energy *= rescaleFactor;
385 if ( rescaleFactor > 1. ) {
392 energy *= rescaleFactor;
414 if((energyemHF+energyhadHF) <
thresh_HF_ )
continue;
417 double longFibre = energyemHF + energyhadHF/2.;
418 double shortFibre = energyhadHF/2.;
419 int ieta = detid.
ieta();
420 int iphi = detid.
iphi();
424 iHF theLongHit = hfHandle->find(theLongDetId);
425 iHF theShortHit = hfHandle->find(theShortDetId);
427 double theLongHitEnergy = 0.;
428 double theShortHitEnergy = 0.;
429 bool flagShortDPG =
false;
430 bool flagLongDPG =
false;
431 bool flagShortTimeDPG =
false;
432 bool flagLongTimeDPG =
false;
433 bool flagShortPulseDPG =
false;
434 bool flagLongPulseDPG =
false;
436 if ( theLongHit != hfHandle->end() ) {
437 theLongHitEnergy = theLongHit->energy();
443 if ( theShortHit != hfHandle->end() ) {
444 theShortHitEnergy = theShortHit->energy();
454 flagShortTimeDPG || flagShortPulseDPG ) ) {
461 pfrhHFHADCleaned->
setRescale(theShortHit->time());
474 shortFibre -= theShortHitEnergy;
475 theShortHitEnergy = 0.;
482 flagLongTimeDPG || flagLongPulseDPG ) ) {
489 pfrhHFEMCleaned->
setRescale(theLongHit->time());
502 longFibre -= theLongHitEnergy;
503 theLongHitEnergy = 0.;
513 unsigned theStatusValue = theStatus->
getValue();
515 if ( !theStatusValue ) {
522 pfrhHFHADCleaned->
setRescale(theShortHit->time());
536 shortFibre -= theShortHitEnergy;
537 theShortHitEnergy = 0.;
547 unsigned theStatusValue = theStatus->
getValue();
549 if ( !theStatusValue ) {
556 pfrhHFEMCleaned->
setRescale(theLongHit->time());
570 longFibre -= theLongHitEnergy;
571 theLongHitEnergy = 0.;
577 if (
abs(ieta) == 29 ) {
586 pfrhHFEMCleaned29->
setRescale(theLongHit->time());
594 longFibre -= theLongHitEnergy;
595 theLongHitEnergy = 0.;
604 pfrhHFHADCleaned29->
setRescale(theShortHit->time());
612 shortFibre -= theShortHitEnergy;
613 theShortHitEnergy = 0.;
619 else if (
abs(ieta) == 30 ) {
620 int ieta29 = ieta > 0 ? 29 : -29;
623 iHF theLongHit29 = hfHandle->find(theLongDetId29);
624 iHF theShortHit29 = hfHandle->find(theShortDetId29);
626 double theLongHitEnergy29 = 0.;
627 double theShortHitEnergy29 = 0.;
628 bool flagShortDPG29 =
false;
629 bool flagLongDPG29 =
false;
630 bool flagShortTimeDPG29 =
false;
631 bool flagLongTimeDPG29 =
false;
632 bool flagShortPulseDPG29 =
false;
633 bool flagLongPulseDPG29 =
false;
635 if ( theLongHit29 != hfHandle->end() ) {
636 theLongHitEnergy29 = theLongHit29->energy() ;
642 if ( theShortHit29 != hfHandle->end() ) {
643 theShortHitEnergy29 = theShortHit29->energy();
652 flagLongTimeDPG29 || flagLongPulseDPG29 ) ) {
659 pfrhHFEMCleaned29->
setRescale(theLongHit29->time());
672 longFibre -= theLongHitEnergy29;
673 theLongHitEnergy29 = 0;
679 flagShortTimeDPG29 || flagShortPulseDPG29 ) ) {
686 pfrhHFHADCleaned29->
setRescale(theShortHit29->time());
699 shortFibre -= theShortHitEnergy29;
700 theShortHitEnergy29 = 0.;
710 unsigned theStatusValue = theStatus->
getValue();
712 if ( !theStatusValue ) {
719 pfrhHFHADCleaned29->
setRescale(theShortHit29->time());
733 shortFibre -= theShortHitEnergy29;
734 theShortHitEnergy29 = 0.;
745 unsigned theStatusValue = theStatus->
getValue();
747 if ( !theStatusValue ) {
754 pfrhHFEMCleaned29->
setRescale(theLongHit29->time());
768 longFibre -= theLongHitEnergy29;
769 theLongHitEnergy29 = 0.;
781 pfrhHFEMCleaned29->
setRescale(theLongHit29->time());
789 longFibre -= theLongHitEnergy29;
790 theLongHitEnergy29 = 0.;
799 pfrhHFHADCleaned29->
setRescale(theShortHit29->time());
807 shortFibre -= theShortHitEnergy29;
808 theShortHitEnergy29 = 0.;
814 energyhadHF = 2.*shortFibre;
815 energyemHF = longFibre - shortFibre;
821 energyhadHF += energyemHF;
844 pfrhHFHAD->setEnergyUp(energyemHF);
851 <<
"CaloTower constituent: unknown layer : "
856 rechits.push_back( *pfrh );
858 idSortedRecHits.insert( make_pair(ct.
id().
rawId(),
859 rechits.size()-1 ) );
862 rechitsCleaned.push_back( *pfrhCleaned );
867 HFEMRecHits->push_back( *pfrhHFEM );
869 idSortedRecHitsHFEM.insert( make_pair(ct.
id().
rawId(),
870 HFEMRecHits->size()-1 ) );
873 HFHADRecHits->push_back( *pfrhHFHAD );
875 idSortedRecHitsHFHAD.insert( make_pair(ct.
id().
rawId(),
876 HFHADRecHits->size()-1 ) );
879 if(pfrhHFEMCleaned) {
880 rechitsCleaned.push_back( *pfrhHFEMCleaned );
881 delete pfrhHFEMCleaned;
883 if(pfrhHFHADCleaned) {
884 rechitsCleaned.push_back( *pfrhHFHADCleaned );
885 delete pfrhHFHADCleaned;
887 if(pfrhHFEMCleaned29) {
888 rechitsCleaned.push_back( *pfrhHFEMCleaned29 );
889 delete pfrhHFEMCleaned29;
891 if(pfrhHFHADCleaned29) {
892 rechitsCleaned.push_back( *pfrhHFHADCleaned29 );
893 delete pfrhHFHADCleaned29;
898 for(
unsigned i=0;
i<rechits.size();
i++ ) {
903 for(
unsigned i=0;
i<HFEMRecHits->size();
i++ ) {
908 for(
unsigned i=0;
i<HFHADRecHits->size();
i++ ) {
910 idSortedRecHitsHFHAD,
913 iEvent.
put( HFHADRecHits,
"HFHAD" );
914 iEvent.
put( HFEMRecHits,
"HFEM" );
935 LogError(
"PFRecHitProducerHCAL")<<err.str()<<endl;
940 assert( hcalHandle.
isValid() );
943 for(
unsigned irechit=0; irechit<handle->size(); irechit++) {
952 switch( detid.
subdet() ) {
959 hcalBarrelGeometry );
968 hcalEndcapGeometry );
977 hcalEndcapGeometry );
982 <<
"HCAL rechit: unknown layer : "<<detid.
subdet()<<endl;
987 rechits.push_back( *pfrh );
989 idSortedRecHits.insert( make_pair(detid.
rawId(),
990 rechits.size()-1 ) );
996 for(
unsigned i=0;
i<rechits.size();
i++ ) {
1000 *hcalBarrelGeometry,
1002 *hcalEndcapGeometry);
1018 unsigned newDetId ) {
1023 <<
"warning detid "<<detid.
rawId()<<
" not found in layer "
1030 double depth_correction = 0.;
1042 unsigned id =
detid;
1043 if(newDetId)
id = newDetId;
1046 position.
x(), position.
y(), position.
z()+depth_correction,
1055 assert( corners.size() == 8 );
1057 rh->
setNECorner( corners[0].
x(), corners[0].
y(), corners[0].
z()+depth_correction );
1058 rh->
setSECorner( corners[1].
x(), corners[1].
y(), corners[1].
z()+depth_correction );
1059 rh->
setSWCorner( corners[2].
x(), corners[2].
y(), corners[2].
z()+depth_correction );
1060 rh->
setNWCorner( corners[3].
x(), corners[3].
y(), corners[3].
z()+depth_correction );
1071 const map<unsigned,unsigned >& sortedHits,
1078 if(navigation_HF_ ==
false){
1090 switch( rh.
layer() ) {
1092 topology = &endcapTopology;
1093 geometry = &endcapGeometry;
1096 topology = &barrelTopology;
1097 geometry = &barrelGeometry;
1100 topology = &endcapTopology;
1101 geometry = &endcapGeometry;
1102 othergeometry = &barrelGeometry;
1105 topology = &barrelTopology;
1106 geometry = &barrelGeometry;
1107 othergeometry = &endcapGeometry;
1111 topology = &barrelTopology;
1112 geometry = &barrelGeometry;
1113 othergeometry = &endcapGeometry;
1119 assert( topology && geometry );
1126 if( north !=
DetId(0) ) {
1127 northeast = navigator.
east();
1137 if( south !=
DetId(0) ) {
1138 southwest = navigator.
west();
1145 if( east !=
DetId(0) ) {
1146 southeast = navigator.
south();
1151 if( west !=
DetId(0) ) {
1152 northwest = navigator.
north();
1156 IDH i = sortedHits.find( north.
rawId() );
1157 if(i != sortedHits.end() )
1160 i = sortedHits.find( northeast.
rawId() );
1161 if(i != sortedHits.end() )
1164 i = sortedHits.find( south.
rawId() );
1165 if(i != sortedHits.end() )
1168 i = sortedHits.find( southwest.
rawId() );
1169 if(i != sortedHits.end() )
1172 i = sortedHits.find( east.
rawId() );
1173 if(i != sortedHits.end() )
1176 i = sortedHits.find( southeast.
rawId() );
1177 if(i != sortedHits.end() )
1180 i = sortedHits.find( west.
rawId() );
1181 if(i != sortedHits.end() )
1184 i = sortedHits.find( northwest.
rawId() );
1185 if(i != sortedHits.end() )
1195 const map<unsigned, unsigned >& sortedHits,
1203 if(navigation_HF_ ==
false){
1212 vector<DetId> northids = topology.
north(ctDetId);
1213 vector<DetId> westids = topology.
west(ctDetId);
1214 vector<DetId> southids = topology.
south(ctDetId);
1215 vector<DetId> eastids = topology.
east(ctDetId);
1238 switch( northids.size() ) {
1242 north = northids[0];
1245 stringstream err(
"PFRecHitProducerHCAL::findRecHitNeighboursCT : incorrect number of neighbours north: ");
1246 err<<northids.size();
1250 switch( southids.size() ) {
1254 south = southids[0];
1257 stringstream err(
"PFRecHitProducerHCAL::findRecHitNeighboursCT : incorrect number of neighbours south: ");
1258 err<<southids.size();
1265 switch( eastids.size() ) {
1270 northeast = getNorth(east, topology);
1271 southeast = getSouth(east, topology);
1277 northeast = getNorth(east, topology );
1278 southeast = getSouth(east2, topology);
1279 northeast2 = getNorth(northeast, topology );
1280 southeast2 = getSouth(southeast, topology);
1283 stringstream err(
"PFRecHitProducerHCAL::findRecHitNeighboursCT : incorrect number of neighbours eastids: ");
1284 err<<eastids.size();
1289 switch( westids.size() ) {
1294 northwest = getNorth(west, topology);
1295 southwest = getSouth(west, topology);
1301 northwest = getNorth(west, topology );
1302 southwest = getSouth(west2, topology );
1303 northwest2 = getNorth(northwest, topology );
1304 southwest2 = getSouth(southwest, topology );
1307 stringstream err(
"PFRecHitProducerHCAL::findRecHitNeighboursCT : incorrect number of neighbours westids: ");
1308 err<< westids.size();
1317 IDH i = sortedHits.find( north.
rawId() );
1318 if(i != sortedHits.end() )
1321 i = sortedHits.find( northeast.
rawId() );
1322 if(i != sortedHits.end() )
1325 i = sortedHits.find( northeast2.
rawId() );
1326 if(i != sortedHits.end() )
1329 i = sortedHits.find( south.
rawId() );
1330 if(i != sortedHits.end() )
1333 i = sortedHits.find( southwest.
rawId() );
1334 if(i != sortedHits.end() )
1337 i = sortedHits.find( southwest2.
rawId() );
1338 if(i != sortedHits.end() )
1341 i = sortedHits.find( east.
rawId() );
1342 if(i != sortedHits.end() )
1345 i = sortedHits.find( east2.
rawId() );
1346 if(i != sortedHits.end() )
1349 i = sortedHits.find( southeast.
rawId() );
1350 if(i != sortedHits.end() )
1353 i = sortedHits.find( southeast2.
rawId() );
1354 if(i != sortedHits.end() )
1357 i = sortedHits.find( west.
rawId() );
1358 if(i != sortedHits.end() )
1361 i = sortedHits.find( west2.
rawId() );
1362 if(i != sortedHits.end() )
1365 i = sortedHits.find( northwest.
rawId() );
1366 if(i != sortedHits.end() )
1369 i = sortedHits.find( northwest2.
rawId() );
1370 if(i != sortedHits.end() )
1387 vector<DetId> sids = topology.
south(
id);
1388 if(sids.size() == 1)
1401 vector<DetId> nids = topology.
north(
id);
1402 if(nids.size() == 1)
void setSECorner(double posx, double posy, double posz)
T getParameter(std::string const &) const
void add4Neighbour(unsigned index)
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