CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
EgammaHLTNxNClusterProducer Class Reference

#include <EgammaHLTNxNClusterProducer.h>

Inheritance diagram for EgammaHLTNxNClusterProducer:
edm::stream::EDProducer<>

Public Member Functions

 EgammaHLTNxNClusterProducer (const edm::ParameterSet &ps)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~EgammaHLTNxNClusterProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

bool checkStatusOfEcalRecHit (const EcalChannelStatus &channelStatus, const EcalRecHit &rh)
 
void makeNxNClusters (edm::Event &evt, const edm::EventSetup &es, const EcalRecHitCollection *hits, const reco::CaloID::Detectors detector)
 

Private Attributes

const std::string barrelClusterCollection_
 
const edm::EDGetTokenT< EcalRecHitCollectionbarrelHitProducer_
 
const int clusEtaSize_
 
const int clusPhiSize_
 
const double clusSeedThr_
 
const double clusSeedThrEndCap_
 
const int debug_
 
const bool doBarrel_
 
const bool doEndcaps_
 
const std::string endcapClusterCollection_
 
const edm::EDGetTokenT< EcalRecHitCollectionendcapHitProducer_
 
const int flagLevelRecHitsToUse_
 
const int maxNumberofClusters_
 
const int maxNumberofSeeds_
 
PositionCalc posCalculator_
 
const int statusLevelRecHitsToUse_
 
const bool useDBStatus_
 
const bool useRecoFlag_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 47 of file EgammaHLTNxNClusterProducer.h.

Constructor & Destructor Documentation

EgammaHLTNxNClusterProducer::EgammaHLTNxNClusterProducer ( const edm::ParameterSet ps)

Definition at line 27 of file EgammaHLTNxNClusterProducer.cc.

References barrelClusterCollection_, and endcapClusterCollection_.

27  :
28  doBarrel_ (ps.getParameter<bool>("doBarrel")),
29  doEndcaps_ (ps.getParameter<bool>("doEndcaps")),
30  barrelHitProducer_ (consumes<EcalRecHitCollection>(ps.getParameter< edm::InputTag > ("barrelHitProducer"))),
31  endcapHitProducer_ (consumes<EcalRecHitCollection>(ps.getParameter< edm::InputTag > ("endcapHitProducer"))),
32  clusEtaSize_ (ps.getParameter<int> ("clusEtaSize")),
33  clusPhiSize_ (ps.getParameter<int> ("clusPhiSize")),
34  barrelClusterCollection_(ps.getParameter<std::string>("barrelClusterCollection")),
35  endcapClusterCollection_(ps.getParameter<std::string>("endcapClusterCollection")),
36  clusSeedThr_ (ps.getParameter<double> ("clusSeedThr")),
37  clusSeedThrEndCap_ (ps.getParameter<double> ("clusSeedThrEndCap")),
38  useRecoFlag_ (ps.getParameter<bool>("useRecoFlag")),
39  flagLevelRecHitsToUse_ (ps.getParameter<int>("flagLevelRecHitsToUse")),
40  useDBStatus_ (ps.getParameter<bool>("useDBStatus")),
41  statusLevelRecHitsToUse_(ps.getParameter<int>("statusLevelRecHitsToUse")),
42  maxNumberofSeeds_ (ps.getParameter<int> ("maxNumberofSeeds")),
43  maxNumberofClusters_ (ps.getParameter<int> ("maxNumberofClusters")),
44  debug_ (ps.getParameter<int> ("debugLevel")),
45  posCalculator_ (PositionCalc( ps.getParameter<edm::ParameterSet>("posCalcParameters"))) {
46 
47  produces< reco::BasicClusterCollection >(barrelClusterCollection_);
48  produces< reco::BasicClusterCollection >(endcapClusterCollection_);
49 }
T getParameter(std::string const &) const
const edm::EDGetTokenT< EcalRecHitCollection > endcapHitProducer_
const edm::EDGetTokenT< EcalRecHitCollection > barrelHitProducer_
EgammaHLTNxNClusterProducer::~EgammaHLTNxNClusterProducer ( )
override

Definition at line 52 of file EgammaHLTNxNClusterProducer.cc.

53 {}

Member Function Documentation

bool EgammaHLTNxNClusterProducer::checkStatusOfEcalRecHit ( const EcalChannelStatus channelStatus,
const EcalRecHit rh 
)
private

from recoFlag()

good

good || PoorCalib

good || PoorCalib || LeadingEdgeRecovered || kNeighboursRecovered,

Definition at line 122 of file EgammaHLTNxNClusterProducer.cc.

References RemoveAddSevLevel::flag, flagLevelRecHitsToUse_, EcalRecHit::id(), createfilelist::int, DetId::rawId(), EcalRecHit::recoFlag(), mps_update::status, statusLevelRecHitsToUse_, useDBStatus_, and useRecoFlag_.

Referenced by makeNxNClusters().

122  {
123 
124  if(useRecoFlag_ ){
125  int flag = rh.recoFlag();
126  if( flagLevelRecHitsToUse_ ==0){
127  if( flag != 0) return false;
128  }
129  else if( flagLevelRecHitsToUse_ ==1){
130  if( flag !=0 && flag != 4 ) return false;
131  }
132  else if( flagLevelRecHitsToUse_ ==2){
133  if( flag !=0 && flag != 4 && flag != 6 && flag != 7) return false;
134  }
135  }
136  if ( useDBStatus_){
137  int status = int(channelStatus[rh.id().rawId()].getStatusCode());
138  if ( status > statusLevelRecHitsToUse_ ) return false;
139  }
140 
141  return true;
142 }
uint32_t rawId() const
get the raw id
Definition: DetId.h:44
DetId id() const
get the id
Definition: EcalRecHit.h:77
Flags recoFlag() const
DEPRECATED provided for temporary backward compatibility.
Definition: EcalRecHit.h:206
void EgammaHLTNxNClusterProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 55 of file EgammaHLTNxNClusterProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), and AlCaHLTBitMon_QueryRunRegistry::string.

55  {
56 
58  desc.add<bool>(("doBarrel"), true);
59  desc.add<bool>(("doEndcaps"), true);
60  desc.add<edm::InputTag>(("barrelHitProducer"), edm::InputTag("hltEcalRegionalPi0EtaRecHit","EcalRecHitsEB"));
61  desc.add<edm::InputTag>(("endcapHitProducer"), edm::InputTag("hltEcalRegionalPi0EtaRecHit","EcalRecHitsEE"));
62  desc.add<int>(("clusEtaSize"), 3);
63  desc.add<int>(("clusPhiSize"), 3);
64  desc.add<std::string>(("barrelClusterCollection"), "Simple3x3ClustersBarrel");
65  desc.add<std::string>(("endcapClusterCollection"), "Simple3x3ClustersEndcap");
66  desc.add<double>(("clusSeedThr"), 0.5);
67  desc.add<double>(("clusSeedThrEndCap"), 1.0);
68  desc.add<bool>(("useRecoFlag"), false);
69  desc.add<int>(("flagLevelRecHitsToUse"), 1);
70  desc.add<bool>(("useDBStatus"), true);
71  desc.add<int>(("statusLevelRecHitsToUse"), 1);
72 
73  edm::ParameterSetDescription posCalcPSET;
74  posCalcPSET.add<double>("T0_barl", 7.4);
75  posCalcPSET.add<double>("T0_endc", 3.1);
76  posCalcPSET.add<double>("T0_endcPresh", 1.2);
77  posCalcPSET.add<double>("W0", 4.2);
78  posCalcPSET.add<double>("X0", 0.89);
79  posCalcPSET.add<bool>("LogWeighted", true);
80  desc.add<edm::ParameterSetDescription>("posCalcParameters", posCalcPSET);
81 
82  desc.add<int>(("maxNumberofSeeds"), 1000);
83  desc.add<int>(("maxNumberofClusters"), 200);
84  desc.add<int>(("debugLevel"), 0);
85  descriptions.add(("hltEgammaHLTNxNClusterProducer"), desc);
86 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void EgammaHLTNxNClusterProducer::makeNxNClusters ( edm::Event evt,
const edm::EventSetup es,
const EcalRecHitCollection hits,
const reco::CaloID::Detectors  detector 
)
private

get status from DB

if too much clusters made, then return 0 also

Definition at line 147 of file EgammaHLTNxNClusterProducer.cc.

References barrelClusterCollection_, edm::SortedCollection< T, SORT >::begin(), PositionCalc::Calculate_Location(), checkStatusOfEcalRecHit(), clusEtaSize_, clusPhiSize_, clusSeedThr_, clusSeedThrEndCap_, fastPrimaryVertexProducer_cfi::clusters, debug_, reco::CaloID::DET_ECAL_BARREL, DetId::Ecal, EcalBarrel, EcalEndcap, EcalPreshower, edm::SortedCollection< T, SORT >::end(), endcapClusterCollection_, edm::EventID::event(), spr::find(), edm::SortedCollection< T, SORT >::find(), edm::EventSetup::get(), CaloGeometry::getSubdetectorGeometry(), edm::EventBase::id(), reco::CaloCluster::island, LogDebug, maxNumberofClusters_, maxNumberofSeeds_, eostools::move(), posCalculator_, edm::Event::put(), edm::EventID::run(), and useDBStatus_.

Referenced by produce().

149 {
150 
151 
154  if ( useDBStatus_ ) es.get<EcalChannelStatusRcd>().get(csHandle);
155  const EcalChannelStatus &channelStatus = *csHandle;
156 
157 
158  std::vector<EcalRecHit> seeds;
159 
160  double clusterSeedThreshold ;
162  clusterSeedThreshold = clusSeedThr_;
163  }else{
164  clusterSeedThreshold = clusSeedThrEndCap_;
165  }
166 
167 
168  for(EcalRecHitCollection::const_iterator itt = hits->begin(); itt != hits->end(); itt++){
169  double energy = itt->energy();
170  if( ! checkStatusOfEcalRecHit(channelStatus, *itt) ) continue;
171  if (energy > clusterSeedThreshold ) seeds.push_back(*itt);
172 
173  if( int(seeds.size()) > maxNumberofSeeds_){ //too many seeds, like beam splash events
174  seeds.clear();
175  break;
176  }
177  }
178 
179  // get the geometry and topology from the event setup:
180  edm::ESHandle<CaloGeometry> geoHandle;
181  es.get<CaloGeometryRecord>().get(geoHandle);
182 
183  const CaloSubdetectorGeometry *geometry_p;
184  std::unique_ptr<CaloSubdetectorTopology> topology_p;
186  geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
187  topology_p.reset(new EcalBarrelTopology(geoHandle));
188  }else {
189  geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
190  topology_p.reset(new EcalEndcapTopology(geoHandle));
191  }
192 
193  const CaloSubdetectorGeometry *geometryES_p;
194  geometryES_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
195 
196 
197 
198  std::vector<reco::BasicCluster> clusters;
199  std::vector<DetId> usedXtals;
200 
201  // sort seed according to Energy
202  sort(seeds.begin(), seeds.end(), ecalRecHitSort());
203 
204 
205 
206  for (std::vector<EcalRecHit>::iterator itseed=seeds.begin(); itseed!=seeds.end(); itseed++) {
207  DetId seed_id = itseed->id();
208  std::vector<DetId>::const_iterator usedIds;
209 
210  std::vector<DetId>::iterator itdet = find(usedXtals.begin(),usedXtals.end(),seed_id);
211  if(itdet != usedXtals.end()) continue;
212 
213  std::vector<DetId> clus_v = topology_p->getWindow(seed_id,clusEtaSize_,clusPhiSize_);
214  std::vector<std::pair<DetId, float> > clus_used;
215 
216  float clus_energy = 0;
217 
218  for (std::vector<DetId>::iterator det=clus_v.begin(); det!=clus_v.end(); det++) {
219  DetId detid = *det;
220 
221  //not yet used
222  std::vector<DetId>::iterator itdet = find(usedXtals.begin(),usedXtals.end(),detid);
223  if(itdet != usedXtals.end()) continue;
224  //inside the collection
226  if( hit == hits->end()) continue;
227 
228  if( ! checkStatusOfEcalRecHit(channelStatus, *hit) ) continue;
229 
230  usedXtals.push_back(detid);
231  clus_used.push_back(std::pair<DetId, float>(detid, 1.) );
232  clus_energy += hit->energy();
233 
234  }
235 
236  if( clus_energy <= 0 ) continue;
237 
238  math::XYZPoint clus_pos = posCalculator_.Calculate_Location(clus_used,hits,geometry_p,geometryES_p);
239 
240  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;
241 
242  clusters.push_back(reco::BasicCluster(clus_energy, clus_pos, reco::CaloID(detector), clus_used, reco::CaloCluster::island, seed_id));
243  if( int(clusters.size()) > maxNumberofClusters_){
244  clusters.clear();
245  break;
246  }
247 
248  }
249 
250 
251  //Create empty output collections
252  auto clusters_p = std::make_unique<reco::BasicClusterCollection>();
253  clusters_p->assign(clusters.begin(), clusters.end());
255  if(debug_>=1) LogDebug("")<<"nxnclusterProducer: "<<clusters_p->size() <<" made in barrel"<<std::endl;
256  evt.put(std::move(clusters_p), barrelClusterCollection_);
257  }
258  else {
259  if(debug_>=1) LogDebug("")<<"nxnclusterProducer: "<<clusters_p->size() <<" made in endcap"<<std::endl;
260  evt.put(std::move(clusters_p), endcapClusterCollection_);
261  }
262 
263 }
#define LogDebug(id)
RunNumber_t run() const
Definition: EventID.h:39
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:44
EventNumber_t event() const
Definition: EventID.h:41
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
std::vector< EcalRecHit >::const_iterator const_iterator
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
const_iterator end() const
Definition: DetId.h:18
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
const T & get() const
Definition: EventSetup.h:59
edm::EventID id() const
Definition: EventBase.h:60
iterator find(key_type k)
math::XYZPoint Calculate_Location(const HitsAndFractions &iDetIds, const edm::SortedCollection< HitType > *iRecHits, const CaloSubdetectorGeometry *iSubGeom, const CaloSubdetectorGeometry *iESGeom=0)
Definition: PositionCalc.h:68
bool checkStatusOfEcalRecHit(const EcalChannelStatus &channelStatus, const EcalRecHit &rh)
def move(src, dest)
Definition: eostools.py:510
const_iterator begin() const
void EgammaHLTNxNClusterProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 88 of file EgammaHLTNxNClusterProducer.cc.

References barrelHitProducer_, debug_, reco::CaloID::DET_ECAL_BARREL, reco::CaloID::DET_ECAL_ENDCAP, doBarrel_, doEndcaps_, endcapHitProducer_, edm::EventID::event(), edm::Event::getByToken(), edm::EventBase::id(), edm::HandleBase::isValid(), LogDebug, makeNxNClusters(), edm::Handle< T >::product(), edm::EventID::run(), and edm::SortedCollection< T, SORT >::size().

88  {
89 
90  if(doBarrel_) {
91  edm::Handle<EcalRecHitCollection> barrelRecHitsHandle;
92  evt.getByToken(barrelHitProducer_, barrelRecHitsHandle);
93  if (!barrelRecHitsHandle.isValid()) {
94  LogDebug("") << "EgammaHLTNxNClusterProducer Error! can't get product eb hit!" << std::endl;
95  }
96 
97  const EcalRecHitCollection *hits_eb = barrelRecHitsHandle.product();
98  if( debug_>=2 )
99  LogDebug("")<<"EgammaHLTNxNClusterProducer nEBrechits: "<< evt.id().run()<<" event "<<evt.id().event() <<" "<< hits_eb->size()<<std::endl;
100 
102 
103  }
104 
105 
106  if(doEndcaps_) {
107  edm::Handle<EcalRecHitCollection> endcapRecHitsHandle;
108  evt.getByToken(endcapHitProducer_, endcapRecHitsHandle);
109  if (!endcapRecHitsHandle.isValid()) {
110  LogDebug("") << "EgammaHLTNxNClusterProducer Error! can't get product ee hit!" << std::endl;
111  }
112 
113  const EcalRecHitCollection *hits_ee = endcapRecHitsHandle.product();
114  if( debug_>=2 )
115  LogDebug("")<<"EgammaHLTNxNClusterProducer nEErechits: "<< evt.id().run()<<" event "<<evt.id().event() <<" "<< hits_ee->size()<<std::endl;
117  }
118 }
#define LogDebug(id)
RunNumber_t run() const
Definition: EventID.h:39
EventNumber_t event() const
Definition: EventID.h:41
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
const edm::EDGetTokenT< EcalRecHitCollection > endcapHitProducer_
bool isValid() const
Definition: HandleBase.h:74
T const * product() const
Definition: Handle.h:81
edm::EventID id() const
Definition: EventBase.h:60
void makeNxNClusters(edm::Event &evt, const edm::EventSetup &es, const EcalRecHitCollection *hits, const reco::CaloID::Detectors detector)
size_type size() const
const edm::EDGetTokenT< EcalRecHitCollection > barrelHitProducer_

Member Data Documentation

const std::string EgammaHLTNxNClusterProducer::barrelClusterCollection_
private

Definition at line 70 of file EgammaHLTNxNClusterProducer.h.

Referenced by EgammaHLTNxNClusterProducer(), and makeNxNClusters().

const edm::EDGetTokenT<EcalRecHitCollection> EgammaHLTNxNClusterProducer::barrelHitProducer_
private

Definition at line 66 of file EgammaHLTNxNClusterProducer.h.

Referenced by produce().

const int EgammaHLTNxNClusterProducer::clusEtaSize_
private

Definition at line 68 of file EgammaHLTNxNClusterProducer.h.

Referenced by makeNxNClusters().

const int EgammaHLTNxNClusterProducer::clusPhiSize_
private

Definition at line 69 of file EgammaHLTNxNClusterProducer.h.

Referenced by makeNxNClusters().

const double EgammaHLTNxNClusterProducer::clusSeedThr_
private

Definition at line 72 of file EgammaHLTNxNClusterProducer.h.

Referenced by makeNxNClusters().

const double EgammaHLTNxNClusterProducer::clusSeedThrEndCap_
private

Definition at line 73 of file EgammaHLTNxNClusterProducer.h.

Referenced by makeNxNClusters().

const int EgammaHLTNxNClusterProducer::debug_
private

Definition at line 83 of file EgammaHLTNxNClusterProducer.h.

Referenced by makeNxNClusters(), and produce().

const bool EgammaHLTNxNClusterProducer::doBarrel_
private

Definition at line 64 of file EgammaHLTNxNClusterProducer.h.

Referenced by produce().

const bool EgammaHLTNxNClusterProducer::doEndcaps_
private

Definition at line 65 of file EgammaHLTNxNClusterProducer.h.

Referenced by produce().

const std::string EgammaHLTNxNClusterProducer::endcapClusterCollection_
private

Definition at line 71 of file EgammaHLTNxNClusterProducer.h.

Referenced by EgammaHLTNxNClusterProducer(), and makeNxNClusters().

const edm::EDGetTokenT<EcalRecHitCollection> EgammaHLTNxNClusterProducer::endcapHitProducer_
private

Definition at line 67 of file EgammaHLTNxNClusterProducer.h.

Referenced by produce().

const int EgammaHLTNxNClusterProducer::flagLevelRecHitsToUse_
private

Definition at line 76 of file EgammaHLTNxNClusterProducer.h.

Referenced by checkStatusOfEcalRecHit().

const int EgammaHLTNxNClusterProducer::maxNumberofClusters_
private

Definition at line 81 of file EgammaHLTNxNClusterProducer.h.

Referenced by makeNxNClusters().

const int EgammaHLTNxNClusterProducer::maxNumberofSeeds_
private

Definition at line 80 of file EgammaHLTNxNClusterProducer.h.

Referenced by makeNxNClusters().

PositionCalc EgammaHLTNxNClusterProducer::posCalculator_
private

Definition at line 85 of file EgammaHLTNxNClusterProducer.h.

Referenced by makeNxNClusters().

const int EgammaHLTNxNClusterProducer::statusLevelRecHitsToUse_
private

Definition at line 78 of file EgammaHLTNxNClusterProducer.h.

Referenced by checkStatusOfEcalRecHit().

const bool EgammaHLTNxNClusterProducer::useDBStatus_
private

Definition at line 77 of file EgammaHLTNxNClusterProducer.h.

Referenced by checkStatusOfEcalRecHit(), and makeNxNClusters().

const bool EgammaHLTNxNClusterProducer::useRecoFlag_
private

Definition at line 75 of file EgammaHLTNxNClusterProducer.h.

Referenced by checkStatusOfEcalRecHit().