CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
EgammaHLTNxNClusterProducer Class Reference

#include <EgammaHLTNxNClusterProducer.h>

Inheritance diagram for EgammaHLTNxNClusterProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 EgammaHLTNxNClusterProducer (const edm::ParameterSet &ps)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
 ~EgammaHLTNxNClusterProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

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

std::string barrelClusterCollection_
 
edm::InputTag barrelHitProducer_
 
std::string barrelHits_
 
int clusEtaSize_
 
int clusPhiSize_
 
double clusSeedThr_
 
double clusSeedThrEndCap_
 
int debug_
 
bool doBarrel_
 
bool doEndcaps_
 
std::string endcapClusterCollection_
 
edm::InputTag endcapHitProducer_
 
std::string endcapHits_
 
int flagLevelRecHitsToUse_
 
int maxNumberofClusters_
 
int maxNumberofSeeds_
 
PositionCalc posCalculator_
 
std::map< std::string, double > providedParameters
 
int statusLevelRecHitsToUse_
 
bool useDBStatus_
 
bool useRecoFlag_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 57 of file EgammaHLTNxNClusterProducer.h.

Constructor & Destructor Documentation

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

Definition at line 45 of file EgammaHLTNxNClusterProducer.cc.

References edm::ParameterSet::getParameter().

46 {
47 
48 
49  doBarrel_ = ps.getParameter<bool>("doBarrel");
50  doEndcaps_ = ps.getParameter<bool>("doEndcaps");
51 
52  barrelHitProducer_ = ps.getParameter< edm::InputTag > ("barrelHitProducer");
53  endcapHitProducer_ = ps.getParameter< edm::InputTag > ("endcapHitProducer");
54 
55  clusEtaSize_ = ps.getParameter<int> ("clusEtaSize");
56  clusPhiSize_ = ps.getParameter<int> ("clusPhiSize");
57 
58 
59 
60  // The names of the produced cluster collections
61  barrelClusterCollection_ = ps.getParameter<std::string>("barrelClusterCollection");
62  endcapClusterCollection_ = ps.getParameter<std::string>("endcapClusterCollection");
63 
64 
65  clusSeedThr_ = ps.getParameter<double> ("clusSeedThr");
66  clusSeedThrEndCap_ = ps.getParameter<double> ("clusSeedThrEndCap");
67 
68  useRecoFlag_ = ps.getParameter<bool>("useRecoFlag");
69  flagLevelRecHitsToUse_ = ps.getParameter<int>("flagLevelRecHitsToUse");
70 
71  useDBStatus_ = ps.getParameter<bool>("useDBStatus");
72  statusLevelRecHitsToUse_ = ps.getParameter<int>("statusLevelRecHitsToUse");
73 
74  // Parameters for the position calculation:
75  posCalculator_ = PositionCalc( ps.getParameter<edm::ParameterSet>("posCalcParameters") );
76 
77  //max number of seeds / clusters, once reached, then return 0
78  maxNumberofSeeds_ = ps.getParameter<int> ("maxNumberofSeeds");
79  maxNumberofClusters_ = ps.getParameter<int> ("maxNumberofClusters");
80 
81 
82  debug_ = ps.getParameter<int> ("debugLevel");
83 
84  produces< reco::BasicClusterCollection >(barrelClusterCollection_);
85  produces< reco::BasicClusterCollection >(endcapClusterCollection_);
86 
87 
88 
89 }
T getParameter(std::string const &) const
EgammaHLTNxNClusterProducer::~EgammaHLTNxNClusterProducer ( )

Definition at line 92 of file EgammaHLTNxNClusterProducer.cc.

93 {
94  //delete island_p;
95 }

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 135 of file EgammaHLTNxNClusterProducer.cc.

References EcalRecHit::id(), DetId::rawId(), EcalRecHit::recoFlag(), and ntuplemaker::status.

135  {
136 
137  if(useRecoFlag_ ){
138  int flag = rh.recoFlag();
139  if( flagLevelRecHitsToUse_ ==0){
140  if( flag != 0) return false;
141  }
142  else if( flagLevelRecHitsToUse_ ==1){
143  if( flag !=0 && flag != 4 ) return false;
144  }
145  else if( flagLevelRecHitsToUse_ ==2){
146  if( flag !=0 && flag != 4 && flag != 6 && flag != 7) return false;
147  }
148  }
149  if ( useDBStatus_){
150  int status = int(channelStatus[rh.id().rawId()].getStatusCode());
151  if ( status > statusLevelRecHitsToUse_ ) return false;
152  }
153 
154  return true;
155 }
long int flag
Definition: mlp_lapack.h:47
Flags recoFlag() const
DEPRECATED provided for temporary backward compatibility.
Definition: EcalRecHit.cc:133
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
DetId id() const
get the id
Definition: EcalRecHit.h:76
tuple status
Definition: ntuplemaker.py:245
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 160 of file EgammaHLTNxNClusterProducer.cc.

References edm::SortedCollection< T, SORT >::begin(), reco::CaloID::DET_ECAL_BARREL, cond::rpcobgas::detid, DetId::Ecal, EcalBarrel, EcalEndcap, EcalPreshower, edm::SortedCollection< T, SORT >::end(), relval_parameters_module::energy, edm::EventID::event(), spr::find(), edm::SortedCollection< T, SORT >::find(), edm::EventSetup::get(), CaloSubdetectorTopology::getWindow(), edm::EventBase::id(), reco::CaloCluster::island, LogDebug, edm::Event::put(), edm::EventID::run(), and python.multivaluedict::sort().

162 {
163 
164 
167  if ( useDBStatus_ ) es.get<EcalChannelStatusRcd>().get(csHandle);
168  const EcalChannelStatus &channelStatus = *csHandle;
169 
170 
171  std::vector<EcalRecHit> seeds;
172 
173  double clusterSeedThreshold ;
174  if (detector == reco::CaloID::DET_ECAL_BARREL){
175  clusterSeedThreshold = clusSeedThr_;
176  }else{
177  clusterSeedThreshold = clusSeedThrEndCap_;
178  }
179 
180 
181  for(EcalRecHitCollection::const_iterator itt = hits->begin(); itt != hits->end(); itt++){
182  double energy = itt->energy();
183  if( ! checkStatusOfEcalRecHit(channelStatus, *itt) ) continue;
184  if (energy > clusterSeedThreshold ) seeds.push_back(*itt);
185 
186  if( int(seeds.size()) > maxNumberofSeeds_){ //too many seeds, like beam splash events
187  seeds.clear();
188  break;
189  }
190  }
191 
192  // get the geometry and topology from the event setup:
193  edm::ESHandle<CaloGeometry> geoHandle;
194  es.get<CaloGeometryRecord>().get(geoHandle);
195 
196  const CaloSubdetectorGeometry *geometry_p;
197  CaloSubdetectorTopology *topology_p;
198  if (detector == reco::CaloID::DET_ECAL_BARREL) {
199  geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
200  topology_p = new EcalBarrelTopology(geoHandle);
201  }else {
202  geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
203  topology_p = new EcalEndcapTopology(geoHandle);
204  }
205 
206  const CaloSubdetectorGeometry *geometryES_p;
207  geometryES_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
208 
209 
210 
211  std::vector<reco::BasicCluster> clusters;
212  std::vector<DetId> usedXtals;
213 
214  // sort seed according to Energy
215  sort(seeds.begin(), seeds.end(), ecalRecHitSort());
216 
217 
218 
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;
222 
223  std::vector<DetId>::iterator itdet = find(usedXtals.begin(),usedXtals.end(),seed_id);
224  if(itdet != usedXtals.end()) continue;
225 
226  std::vector<DetId> clus_v = topology_p->getWindow(seed_id,clusEtaSize_,clusPhiSize_);
227  std::vector<std::pair<DetId, float> > clus_used;
228 
229  float clus_energy = 0;
230 
231  for (std::vector<DetId>::iterator det=clus_v.begin(); det!=clus_v.end(); det++) {
232  DetId detid = *det;
233 
234  //not yet used
235  std::vector<DetId>::iterator itdet = find(usedXtals.begin(),usedXtals.end(),detid);
236  if(itdet != usedXtals.end()) continue;
237  //inside the collection
239  if( hit == hits->end()) continue;
240 
241  if( ! checkStatusOfEcalRecHit(channelStatus, *hit) ) continue;
242 
243  usedXtals.push_back(detid);
244  clus_used.push_back(std::pair<DetId, float>(detid, 1.) );
245  clus_energy += hit->energy();
246 
247  }
248 
249  if( clus_energy <= 0 ) continue;
250 
251  math::XYZPoint clus_pos = posCalculator_.Calculate_Location(clus_used,hits,geometry_p,geometryES_p);
252 
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;
254 
255  clusters.push_back(reco::BasicCluster(clus_energy, clus_pos, reco::CaloID(detector), clus_used, reco::CaloCluster::island, seed_id));
256  if( int(clusters.size()) > maxNumberofClusters_){
257  clusters.clear();
258  break;
259  }
260 
261  }
262 
263 
264  //Create empty output collections
265  std::auto_ptr< reco::BasicClusterCollection > clusters_p(new reco::BasicClusterCollection);
266  clusters_p->assign(clusters.begin(), clusters.end());
267  if (detector == reco::CaloID::DET_ECAL_BARREL){
268  if(debug_>=1) LogDebug("")<<"nxnclusterProducer: "<<clusters_p->size() <<" made in barrel"<<std::endl;
269  evt.put(clusters_p, barrelClusterCollection_);
270  }
271  else {
272  if(debug_>=1) LogDebug("")<<"nxnclusterProducer: "<<clusters_p->size() <<" made in endcap"<<std::endl;
273  evt.put(clusters_p, endcapClusterCollection_);
274  }
275 
276 }
#define LogDebug(id)
RunNumber_t run() const
Definition: EventID.h:42
EventNumber_t event() const
Definition: EventID.h:44
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:7
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
const_iterator end() const
Definition: DetId.h:20
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
const T & get() const
Definition: EventSetup.h:55
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
math::XYZPoint Calculate_Location(const std::vector< std::pair< DetId, float > > &iDetIds, const EcalRecHitCollection *iRecHits, const CaloSubdetectorGeometry *iSubGeom, const CaloSubdetectorGeometry *iESGeom=0)
Definition: PositionCalc.cc:40
edm::EventID id() const
Definition: EventBase.h:56
iterator find(key_type k)
bool checkStatusOfEcalRecHit(const EcalChannelStatus &channelStatus, const EcalRecHit &rh)
const_iterator begin() const
void EgammaHLTNxNClusterProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
virtual

Implements edm::EDProducer.

Definition at line 98 of file EgammaHLTNxNClusterProducer.cc.

References reco::CaloID::DET_ECAL_BARREL, reco::CaloID::DET_ECAL_ENDCAP, edm::EventID::event(), edm::Event::getByLabel(), edm::EventBase::id(), edm::HandleBase::isValid(), LogDebug, edm::Handle< T >::product(), edm::EventID::run(), and edm::SortedCollection< T, SORT >::size().

99 {
100 
101 
102  if(doBarrel_){
103  Handle<EcalRecHitCollection> barrelRecHitsHandle;
104  evt.getByLabel(barrelHitProducer_,barrelRecHitsHandle);
105  if (!barrelRecHitsHandle.isValid()) {
106  LogDebug("") << "EgammaHLTNxNClusterProducer Error! can't get product eb hit!" << std::endl;
107  }
108 
109  const EcalRecHitCollection *hits_eb = barrelRecHitsHandle.product();
110  if( debug_>=2 ) LogDebug("")<<"EgammaHLTNxNClusterProducer nEBrechits: "<< evt.id().run()<<" event "<<evt.id().event() <<" "<< hits_eb->size()<<std::endl;
111 
113 
114  }
115 
116 
117  if(doEndcaps_){
118  Handle<EcalRecHitCollection> endcapRecHitsHandle;
119  evt.getByLabel(endcapHitProducer_,endcapRecHitsHandle);
120  if (!endcapRecHitsHandle.isValid()) {
121  LogDebug("") << "EgammaHLTNxNClusterProducer Error! can't get product ee hit!" << std::endl;
122  }
123 
124  const EcalRecHitCollection *hits_ee = endcapRecHitsHandle.product();
125  if( debug_>=2 ) LogDebug("")<<"EgammaHLTNxNClusterProducer nEErechits: "<< evt.id().run()<<" event "<<evt.id().event() <<" "<< hits_ee->size()<<std::endl;
127  }
128 
129 
130 
131 }
#define LogDebug(id)
RunNumber_t run() const
Definition: EventID.h:42
EventNumber_t event() const
Definition: EventID.h:44
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
T const * product() const
Definition: Handle.h:74
edm::EventID id() const
Definition: EventBase.h:56
void makeNxNClusters(edm::Event &evt, const edm::EventSetup &es, const EcalRecHitCollection *hits, const reco::CaloID::Detectors detector)
size_type size() const

Member Data Documentation

std::string EgammaHLTNxNClusterProducer::barrelClusterCollection_
private

Definition at line 76 of file EgammaHLTNxNClusterProducer.h.

edm::InputTag EgammaHLTNxNClusterProducer::barrelHitProducer_
private

Definition at line 93 of file EgammaHLTNxNClusterProducer.h.

std::string EgammaHLTNxNClusterProducer::barrelHits_
private

Definition at line 80 of file EgammaHLTNxNClusterProducer.h.

int EgammaHLTNxNClusterProducer::clusEtaSize_
private

Definition at line 109 of file EgammaHLTNxNClusterProducer.h.

int EgammaHLTNxNClusterProducer::clusPhiSize_
private

Definition at line 110 of file EgammaHLTNxNClusterProducer.h.

double EgammaHLTNxNClusterProducer::clusSeedThr_
private

Definition at line 97 of file EgammaHLTNxNClusterProducer.h.

double EgammaHLTNxNClusterProducer::clusSeedThrEndCap_
private

Definition at line 98 of file EgammaHLTNxNClusterProducer.h.

int EgammaHLTNxNClusterProducer::debug_
private

Definition at line 113 of file EgammaHLTNxNClusterProducer.h.

bool EgammaHLTNxNClusterProducer::doBarrel_
private

Definition at line 100 of file EgammaHLTNxNClusterProducer.h.

bool EgammaHLTNxNClusterProducer::doEndcaps_
private

Definition at line 101 of file EgammaHLTNxNClusterProducer.h.

std::string EgammaHLTNxNClusterProducer::endcapClusterCollection_
private

Definition at line 77 of file EgammaHLTNxNClusterProducer.h.

edm::InputTag EgammaHLTNxNClusterProducer::endcapHitProducer_
private

Definition at line 94 of file EgammaHLTNxNClusterProducer.h.

std::string EgammaHLTNxNClusterProducer::endcapHits_
private

Definition at line 81 of file EgammaHLTNxNClusterProducer.h.

int EgammaHLTNxNClusterProducer::flagLevelRecHitsToUse_
private

Definition at line 106 of file EgammaHLTNxNClusterProducer.h.

int EgammaHLTNxNClusterProducer::maxNumberofClusters_
private

Definition at line 117 of file EgammaHLTNxNClusterProducer.h.

int EgammaHLTNxNClusterProducer::maxNumberofSeeds_
private

Definition at line 116 of file EgammaHLTNxNClusterProducer.h.

PositionCalc EgammaHLTNxNClusterProducer::posCalculator_
private

Definition at line 85 of file EgammaHLTNxNClusterProducer.h.

std::map<std::string,double> EgammaHLTNxNClusterProducer::providedParameters
private

Definition at line 89 of file EgammaHLTNxNClusterProducer.h.

int EgammaHLTNxNClusterProducer::statusLevelRecHitsToUse_
private

Definition at line 107 of file EgammaHLTNxNClusterProducer.h.

bool EgammaHLTNxNClusterProducer::useDBStatus_
private

Definition at line 105 of file EgammaHLTNxNClusterProducer.h.

bool EgammaHLTNxNClusterProducer::useRecoFlag_
private

Definition at line 104 of file EgammaHLTNxNClusterProducer.h.