66 clusSeedThrEndCap_ = ps.
getParameter<
double> (
"clusSeedThrEndCap");
69 flagLevelRecHitsToUse_ = ps.
getParameter<
int>(
"flagLevelRecHitsToUse");
72 statusLevelRecHitsToUse_ = ps.
getParameter<
int>(
"statusLevelRecHitsToUse");
78 maxNumberofSeeds_ = ps.
getParameter<
int> (
"maxNumberofSeeds");
79 maxNumberofClusters_ = ps.
getParameter<
int> (
"maxNumberofClusters");
84 produces< reco::BasicClusterCollection >(barrelClusterCollection_);
85 produces< reco::BasicClusterCollection >(endcapClusterCollection_);
104 evt.
getByLabel(barrelHitProducer_,barrelRecHitsHandle);
105 if (!barrelRecHitsHandle.
isValid()) {
106 LogDebug(
"") <<
"EgammaHLTNxNClusterProducer Error! can't get product eb hit!" << std::endl;
110 if( debug_>=2 )
LogDebug(
"")<<
"EgammaHLTNxNClusterProducer nEBrechits: "<< evt.
id().
run()<<
" event "<<evt.
id().
event() <<
" "<< hits_eb->
size()<<std::endl;
119 evt.
getByLabel(endcapHitProducer_,endcapRecHitsHandle);
120 if (!endcapRecHitsHandle.
isValid()) {
121 LogDebug(
"") <<
"EgammaHLTNxNClusterProducer Error! can't get product ee hit!" << std::endl;
125 if( debug_>=2 )
LogDebug(
"")<<
"EgammaHLTNxNClusterProducer nEErechits: "<< evt.
id().
run()<<
" event "<<evt.
id().
event() <<
" "<< hits_ee->
size()<<std::endl;
139 if( flagLevelRecHitsToUse_ ==0){
140 if( flag != 0)
return false;
142 else if( flagLevelRecHitsToUse_ ==1){
143 if( flag !=0 && flag != 4 )
return false;
145 else if( flagLevelRecHitsToUse_ ==2){
146 if( flag !=0 && flag != 4 && flag != 6 && flag != 7)
return false;
150 int status = int(channelStatus[rh.
id().
rawId()].getStatusCode());
151 if ( status > statusLevelRecHitsToUse_ )
return false;
171 std::vector<EcalRecHit> seeds;
173 double clusterSeedThreshold ;
175 clusterSeedThreshold = clusSeedThr_;
177 clusterSeedThreshold = clusSeedThrEndCap_;
182 double energy = itt->energy();
183 if( ! checkStatusOfEcalRecHit(channelStatus, *itt) )
continue;
184 if (energy > clusterSeedThreshold ) seeds.push_back(*itt);
186 if(
int(seeds.size()) > maxNumberofSeeds_){
200 topology_p =
new EcalBarrelTopology(geoHandle);
203 topology_p =
new EcalEndcapTopology(geoHandle);
211 std::vector<reco::BasicCluster> clusters;
212 std::vector<DetId> usedXtals;
219 for (std::vector<EcalRecHit>::iterator itseed=seeds.begin(); itseed!=seeds.end(); itseed++) {
220 DetId seed_id = itseed->id();
221 std::vector<DetId>::const_iterator usedIds;
223 std::vector<DetId>::iterator itdet =
find(usedXtals.begin(),usedXtals.end(),seed_id);
224 if(itdet != usedXtals.end())
continue;
226 std::vector<DetId> clus_v = topology_p->
getWindow(seed_id,clusEtaSize_,clusPhiSize_);
227 std::vector<std::pair<DetId, float> > clus_used;
229 float clus_energy = 0;
231 for (std::vector<DetId>::iterator det=clus_v.begin(); det!=clus_v.end(); det++) {
235 std::vector<DetId>::iterator itdet =
find(usedXtals.begin(),usedXtals.end(),
detid);
236 if(itdet != usedXtals.end())
continue;
239 if( hit == hits->
end())
continue;
241 if( ! checkStatusOfEcalRecHit(channelStatus, *hit) )
continue;
243 usedXtals.push_back(detid);
244 clus_used.push_back(std::pair<DetId, float>(detid, 1.) );
245 clus_energy += hit->energy();
249 if( clus_energy <= 0 )
continue;
251 math::XYZPoint clus_pos = posCalculator_.Calculate_Location(clus_used,hits,geometry_p,geometryES_p);
253 if (debug_>=2 )
LogDebug(
"")<<
"nxn_cluster in run "<< evt.
id().
run()<<
" event "<<evt.
id().
event()<<
" energy: "<<clus_energy <<
" eta: "<< clus_pos.Eta()<<
" phi: "<< clus_pos.Phi()<<
" nRecHits: "<< clus_used.size() <<std::endl;
256 if(
int(clusters.size()) > maxNumberofClusters_){
266 clusters_p->assign(clusters.begin(), clusters.end());
268 if(debug_>=1)
LogDebug(
"")<<
"nxnclusterProducer: "<<clusters_p->size() <<
" made in barrel"<<std::endl;
269 evt.
put(clusters_p, barrelClusterCollection_);
272 if(debug_>=1)
LogDebug(
"")<<
"nxnclusterProducer: "<<clusters_p->size() <<
" made in endcap"<<std::endl;
273 evt.
put(clusters_p, endcapClusterCollection_);
T getParameter(std::string const &) const
EventNumber_t event() const
std::vector< EcalRecHit >::const_iterator const_iterator
Flags recoFlag() const
DEPRECATED provided for temporary backward compatibility.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
uint32_t rawId() const
get the raw id
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
EgammaHLTNxNClusterProducer(const edm::ParameterSet &ps)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
const_iterator end() const
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
DetId id() const
get the id
XYZPointD XYZPoint
point in space with cartesian internal representation
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
T const * product() const
~EgammaHLTNxNClusterProducer()
iterator find(key_type k)
void makeNxNClusters(edm::Event &evt, const edm::EventSetup &es, const EcalRecHitCollection *hits, const reco::CaloID::Detectors detector)
bool checkStatusOfEcalRecHit(const EcalChannelStatus &channelStatus, const EcalRecHit &rh)
virtual void produce(edm::Event &, const edm::EventSetup &)
const_iterator begin() const