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 Attributes
AlCaECALRecHitReducer Class Reference

#include <Calibration/EcalAlCaRecoProducers/src/AlCaECALRecHitReducer.cc>

Inheritance diagram for AlCaECALRecHitReducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 AlCaECALRecHitReducer (const edm::ParameterSet &)
 ctor More...
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 producer More...
 
 ~AlCaECALRecHitReducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

std::string alcaBarrelHitsCollection_
 
std::string alcaEndcapHitsCollection_
 
std::string alcaPreshowerHitsCollection_
 
edm::InputTag ebRecHitsLabel_
 
edm::InputTag eeRecHitsLabel_
 
edm::InputTag electronLabel_
 
int esNcolumns_
 
int esNstrips_
 
edm::InputTag esRecHitsLabel_
 
int etaSize_
 
int minEleNumber_
 
double minElePt_
 
int phiSize_
 
bool selectByEleNum_
 
float weight_
 

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
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

class declaration

Description: Example of a producer of AlCa electrons

Implementation: <Notes on="" implementation>="">

Definition at line 45 of file AlCaECALRecHitReducer.h.

Constructor & Destructor Documentation

AlCaECALRecHitReducer::AlCaECALRecHitReducer ( const edm::ParameterSet iConfig)
explicit

ctor

Definition at line 31 of file AlCaECALRecHitReducer.cc.

References alcaBarrelHitsCollection_, alcaEndcapHitsCollection_, ebRecHitsLabel_, eeRecHitsLabel_, electronLabel_, etaSize_, edm::ParameterSet::getParameter(), phiSize_, AlCaHLTBitMon_QueryRunRegistry::string, and weight_.

32 {
33 
34  ebRecHitsLabel_ = iConfig.getParameter< edm::InputTag > ("ebRecHitsLabel");
35  eeRecHitsLabel_ = iConfig.getParameter< edm::InputTag > ("eeRecHitsLabel");
36  // esRecHitsLabel_ = iConfig.getParameter< edm::InputTag > ("esRecHitsLabel");
37  electronLabel_ = iConfig.getParameter< edm::InputTag > ("electronLabel");
38 
39  alcaBarrelHitsCollection_ = iConfig.getParameter<std::string>("alcaBarrelHitCollection");
40  alcaEndcapHitsCollection_ = iConfig.getParameter<std::string>("alcaEndcapHitCollection");
41  // alcaPreshowerHitsCollection_ = iConfig.getParameter<std::string>("alcaPreshowerHitCollection");
42 
43  etaSize_ = iConfig.getParameter<int> ("etaSize");
44  phiSize_ = iConfig.getParameter<int> ("phiSize");
45  // FIXME: minimum size of etaSize_ and phiSize_
46  if ( phiSize_ % 2 == 0 || etaSize_ % 2 == 0)
47  edm::LogError("AlCaECALRecHitReducerError") << "Size of eta/phi should be odd numbers";
48 
49  weight_= iConfig.getParameter<double> ("eventWeight");
50 
51  // esNstrips_ = iConfig.getParameter<int> ("esNstrips");
52  // esNcolumns_ = iConfig.getParameter<int> ("esNcolumns");
53 
54  //register your products
55  produces< EBRecHitCollection > (alcaBarrelHitsCollection_) ;
56  produces< EERecHitCollection > (alcaEndcapHitsCollection_) ;
57  // produces< ESRecHitCollection > (alcaPreshowerHitsCollection_) ;
58  produces< double > ("weight") ;
59 }
T getParameter(std::string const &) const
AlCaECALRecHitReducer::~AlCaECALRecHitReducer ( )

Definition at line 62 of file AlCaECALRecHitReducer.cc.

63 {}

Member Function Documentation

void AlCaECALRecHitReducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

producer

Implements edm::EDProducer.

Definition at line 68 of file AlCaECALRecHitReducer.cc.

References alcaBarrelHitsCollection_, alcaEndcapHitsCollection_, dtNoiseDBValidation_cfg::cerr, gather_cfg::cout, ebRecHitsLabel_, EcalRecHitsCustom_cff::ecalRecHit, eeRecHitsLabel_, electronLabel_, CaloRecHit::energy(), etaSize_, funct::false, edm::EventSetup::get(), edm::Event::getByLabel(), reco::CaloCluster::hitsAndFractions(), i, EBDetId::ieta(), EBDetId::iphi(), max(), phiSize_, edm::Event::put(), hitfit::return, reco::SuperCluster::seed(), reco::CaloCluster::size(), funct::true, histoStyle::weight, and weight_.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

70 {
71  using namespace edm;
72  using namespace std;
73 
75 
76  // get the ECAL geometry:
77  ESHandle<CaloGeometry> geoHandle;
78  iSetup.get<CaloGeometryRecord>().get(geoHandle);
79 
80  edm::ESHandle<CaloTopology> theCaloTopology;
81  iSetup.get<CaloTopologyRecord>().get(theCaloTopology);
82  const CaloTopology *caloTopology = theCaloTopology.product();
83 
84  // Get GSFElectrons
86  iEvent.getByLabel(electronLabel_, pElectrons);
87  if (!pElectrons.isValid()) {
88  edm::LogError ("reading") << electronLabel_ << " not found" ;
89  // std::cerr << "[AlCaECALRecHitReducer]" << electronLabel_ << " not found" ;
90  return ;
91  }
92 
93  const reco::GsfElectronCollection * electronCollection =
94  pElectrons.product();
95 
96  // get RecHits
97  Handle<EBRecHitCollection> barrelRecHitsHandle;
98  bool barrelIsFull = true ;
99 
100  iEvent.getByLabel(ebRecHitsLabel_,barrelRecHitsHandle);
101  if (!barrelRecHitsHandle.isValid()) {
102  edm::LogError ("reading") << ebRecHitsLabel_ << " not found" ;
103  barrelIsFull = false ;
104  }
105 
106  const EBRecHitCollection * barrelHitsCollection = 0 ;
107  if (barrelIsFull)
108  barrelHitsCollection = barrelRecHitsHandle.product () ;
109 
110  // get RecHits
111  Handle<EERecHitCollection> endcapRecHitsHandle;
112  bool endcapIsFull = true ;
113 
114  iEvent.getByLabel(eeRecHitsLabel_,endcapRecHitsHandle);
115  if (!endcapRecHitsHandle.isValid()) {
116  edm::LogError ("reading") << eeRecHitsLabel_ << " not found" ;
117  endcapIsFull = false ;
118  }
119 
120  const EERecHitCollection * endcapHitsCollection = 0 ;
121  if (endcapIsFull)
122  endcapHitsCollection = endcapRecHitsHandle.product () ;
123  // const EERecHitCollection * endcapHitsCollection = endcapRecHitsHandle.product();
124 
125  // // get ES RecHits
126  // Handle<ESRecHitCollection> preshowerRecHitsHandle;
127  // bool preshowerIsFull = true ;
128 
129  // iEvent.getByLabel(esRecHitsLabel_,preshowerRecHitsHandle);
130  // if (!preshowerRecHitsHandle.isValid()) {
131  // edm::LogError ("reading") << esRecHitsLabel_ << " not found" ;
132  // preshowerIsFull = false ;
133  // }
134 
135  // const ESRecHitCollection * preshowerHitsCollection = 0 ;
136  // if (preshowerIsFull)
137  // preshowerHitsCollection = preshowerRecHitsHandle.product () ;
138 
139  // // make a vector to store the used ES rechits:
140  // set<ESDetId> used_strips;
141  // used_strips.clear();
142 
143  //Create empty output collections
144  std::auto_ptr< EBRecHitCollection > miniEBRecHitCollection (new EBRecHitCollection) ;
145  std::auto_ptr< EERecHitCollection > miniEERecHitCollection (new EERecHitCollection) ;
146  // std::auto_ptr< ESRecHitCollection > miniESRecHitCollection (new ESRecHitCollection) ;
147  std::auto_ptr< double > weight (new double(1));
148  (*weight) = weight_;
149 
150  // loop on SiStrip Electrons
151 
152  reco::GsfElectronCollection::const_iterator eleIt;
153  int nEle_EB=0;
154  int nEle_EE=0;
155 
156  std::set<DetId> reducedRecHit_EBmap;
157  std::set<DetId> reducedRecHit_EEmap;
158 
159  for (eleIt=electronCollection->begin(); eleIt!=electronCollection->end(); eleIt++) {
160  // barrel
161  const reco::SuperCluster& sc = *(eleIt->superCluster()) ;
162 
163  if (eleIt->isEB()) {
164  nEle_EB++;
165 
166  // find the seed
167  EBDetId seed=(sc.seed()->seed());
168 
169  std::vector<DetId> recHit_window = caloTopology->getWindow(seed, phiSize_, etaSize_);
170  for(unsigned int i =0; i < recHit_window.size(); i++){
171 #ifdef DEBUG2
172  std::cout << i << "/" << recHit_window.size() << "\t" << recHit_window[i]() << std::endl;
173 #endif
174  reducedRecHit_EBmap.insert(recHit_window[i]);
175 #ifdef DEBUG2
176  EBDetId ebrechit(recHit_window[i]);
177  std::cout << ebrechit.ieta() << "\t" << ebrechit.iphi() << std::endl;
178 #endif
179  }
180 
181 #ifdef DEBUG
182  // find the most energetic crystal
183  float energy_recHit_max=-999;
184 
185  if(reducedRecHit_EBmap.size() < sc.size())
186  std::cerr << "[WARNING] number of recHit in selected window < RECO SC recHits!" << std::endl;
187 #endif
188 
189 #ifndef QUICK
190  const std::vector< std::pair<DetId, float> > & scHits = sc.hitsAndFractions();
191 
192 #ifdef DEBUG
193  std::vector< std::pair<DetId, float> >::const_iterator scHit_max_itr = scHits.end();
194 #endif
195  for(std::vector< std::pair<DetId, float> >::const_iterator scHit_itr = scHits.begin();
196  scHit_itr != scHits.end(); scHit_itr++){
197  // the map fills just one time (avoiding double insert of recHits)
198  reducedRecHit_EBmap.insert(scHit_itr->first);
199 
200 #ifdef DEBUG2
201  const EcalRecHit ecalRecHit = *(barrelHitsCollection->find( (*scHit_itr).first ));
202  if(energy_recHit_max < ecalRecHit.energy()){
203  scHit_max_itr = scHit_itr;
204  energy_recHit_max=ecalRecHit.energy();
205  }
206 #endif
207  }
208 #endif
209 
210 #ifdef DEBUG2
211  // cross check, the seed should be the highest energetic crystal in the SC
212  if(EBDetId(scHit_max_itr->first) != seed)
213  std::cerr << "[ERROR] highest energetic crystal is not the seed of the SC" << std::endl;
214 
215  else{
216 
217  std::cout << "[DEBUG] highest energetic crystal = " << EBDetId(scHit_max_itr->first) << std::endl;
218  std::cout << "[DEBUG] seed of the SC = " << seed << std::endl;
219  }
220 #endif
221  // (id, phi, eta)
222 
223  if(reducedRecHit_EBmap.size() < sc.size()){
224  if(eleIt->ecalDrivenSeed())
225  edm::LogError("AlCaSavedRecHitsEB") << "[ERROR] ecalDrivenSeed: number of saved recHits < RECO SC recHits!: " << reducedRecHit_EBmap.size() << " < " << sc.size() << std::endl;
226  else
227  edm::LogWarning("AlCaSavedRecHitsEB") << "[WARNING] trackerDrivenSeed: number of saved recHits < RECO SC recHits!: " << reducedRecHit_EBmap.size() << " < " << sc.size() << std::endl;
228 
229  }
230 
231  } else { // endcap
232  nEle_EE++;
233 
234  // find the seed
235  EEDetId seed=(sc.seed()->seed());
236 
237  // get detId for a window around the seed of the SC
238  int sideSize = std::max(phiSize_,etaSize_);
239  std::vector<DetId> recHit_window = caloTopology->getWindow(seed, sideSize, sideSize);
240 
241  // fill the recHit map with the DetId of the window
242  for(std::vector<DetId>::const_iterator window_itr = recHit_window.begin();
243  window_itr != recHit_window.end(); window_itr++){
244  reducedRecHit_EEmap.insert(*window_itr);
245  }
246 #ifdef DEBUG
247  if(reducedRecHit_EEmap.size() < sc.size())
248  std::cerr << "[WARNING] number of recHit in selected window < RECO SC recHits!" << std::endl;
249 #endif
250 
251  const std::vector< std::pair<DetId, float> > & scHits = sc.hitsAndFractions();
252 
253 #ifndef QUICK
254  // fill the recHit map with the DetId of the SC recHits
255 
256  for(std::vector< std::pair<DetId, float> >::const_iterator scHit_itr = scHits.begin();
257  scHit_itr != scHits.end(); scHit_itr++){
258  // the map fills just one time (avoiding double insert of recHits)
259  reducedRecHit_EEmap.insert(scHit_itr->first);
260 
261  }
262 #endif
263 
264  if(reducedRecHit_EEmap.size() < sc.size()){
265  if(eleIt->ecalDrivenSeed())
266  edm::LogError("AlCaSavedRecHitsEE") << "[ERROR] ecalDrivenSeed: number of saved recHits < RECO SC recHits!: " << reducedRecHit_EEmap.size() << " < " << sc.size() << std::endl;
267  else
268  edm::LogWarning("AlCaSavedRecHitsEE") << "[WARNING] trackerDrivenSeed: number of saved recHits < RECO SC recHits!: " << reducedRecHit_EEmap.size() << " < " << sc.size() << std::endl;
269 
270  }
271 
272  } // end of endcap
273  }
274 
275 #ifndef ALLrecHits
276  for(std::set<DetId>::const_iterator itr = reducedRecHit_EBmap.begin();
277  itr != reducedRecHit_EBmap.end(); itr++){
278  if (barrelHitsCollection->find(*itr) != barrelHitsCollection->end())
279  miniEBRecHitCollection->push_back(*(barrelHitsCollection->find(*itr)));
280  }
281 #else
282  for(EcalRecHitCollection::const_iterator recHits_itr = barrelHitsCollection->begin();
283  recHits_itr != barrelHitsCollection->end();
284  recHits_itr++){
285  miniEBRecHitCollection->push_back(*recHits_itr);
286  }
287 #endif
288 
289  // fill the alcareco reduced recHit collection
290  for(std::set<DetId>::const_iterator itr = reducedRecHit_EEmap.begin();
291  itr != reducedRecHit_EEmap.end(); itr++){
292  if (endcapHitsCollection->find(*itr) != endcapHitsCollection->end())
293  miniEERecHitCollection->push_back(*(endcapHitsCollection->find(*itr)));
294  }
295 
296 
297 
298 #ifdef DEBUG
299  std::cout << "nEle_EB= " << nEle_EB << "\tnEle_EE = " << nEle_EE << std::endl;
300  if(nEle_EB > 0 && miniEBRecHitCollection->size() < (unsigned int) phiSize_*etaSize_)
301  edm::LogError("AlCaECALRecHitReducerError") << "Size EBRecHitCollection < " << phiSize_*etaSize_ << ": " << miniEBRecHitCollection->size() ;
302 
303  int side = phiSize_ ;
304  if (phiSize_ < etaSize_) side = etaSize_ ;
305 
306  if(nEle_EE > 0 && miniEERecHitCollection->size() < (unsigned int )side*side)
307  edm::LogError("AlCaECALRecHitReducerError") << "Size EERecHitCollection < " << side*side << ": " << miniEERecHitCollection->size() ;
308 #endif
309 
310  //Put selected information in the event
311  iEvent.put( miniEBRecHitCollection,alcaBarrelHitsCollection_ );
312  iEvent.put( miniEERecHitCollection,alcaEndcapHitsCollection_ );
313  // iEvent.put( miniESRecHitCollection,alcaPreshowerHitsCollection_ );
314  iEvent.put( weight, "weight");
315 }
int i
Definition: DBlmapReader.cc:9
std::vector< EcalRecHit >::const_iterator const_iterator
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:189
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
const T & max(const T &a, const T &b)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
float energy() const
Definition: CaloRecHit.h:19
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
const T & get() const
Definition: EventSetup.h:55
size_t size() const
size in number of hits (e.g. in crystals for ECAL)
Definition: CaloCluster.h:166
tuple cout
Definition: gather_cfg.py:121
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:68
int weight
Definition: histoStyle.py:50

Member Data Documentation

std::string AlCaECALRecHitReducer::alcaBarrelHitsCollection_
private

Definition at line 83 of file AlCaECALRecHitReducer.h.

Referenced by AlCaECALRecHitReducer(), and produce().

std::string AlCaECALRecHitReducer::alcaEndcapHitsCollection_
private

Definition at line 84 of file AlCaECALRecHitReducer.h.

Referenced by AlCaECALRecHitReducer(), and produce().

std::string AlCaECALRecHitReducer::alcaPreshowerHitsCollection_
private

Definition at line 85 of file AlCaECALRecHitReducer.h.

edm::InputTag AlCaECALRecHitReducer::ebRecHitsLabel_
private

Definition at line 79 of file AlCaECALRecHitReducer.h.

Referenced by AlCaECALRecHitReducer(), and produce().

edm::InputTag AlCaECALRecHitReducer::eeRecHitsLabel_
private

Definition at line 80 of file AlCaECALRecHitReducer.h.

Referenced by AlCaECALRecHitReducer(), and produce().

edm::InputTag AlCaECALRecHitReducer::electronLabel_
private

Definition at line 82 of file AlCaECALRecHitReducer.h.

Referenced by AlCaECALRecHitReducer(), and produce().

int AlCaECALRecHitReducer::esNcolumns_
private

Definition at line 90 of file AlCaECALRecHitReducer.h.

int AlCaECALRecHitReducer::esNstrips_
private

Definition at line 89 of file AlCaECALRecHitReducer.h.

edm::InputTag AlCaECALRecHitReducer::esRecHitsLabel_
private

Definition at line 81 of file AlCaECALRecHitReducer.h.

int AlCaECALRecHitReducer::etaSize_
private

Definition at line 86 of file AlCaECALRecHitReducer.h.

Referenced by AlCaECALRecHitReducer(), and produce().

int AlCaECALRecHitReducer::minEleNumber_
private

Definition at line 93 of file AlCaECALRecHitReducer.h.

double AlCaECALRecHitReducer::minElePt_
private

Definition at line 94 of file AlCaECALRecHitReducer.h.

int AlCaECALRecHitReducer::phiSize_
private

Definition at line 87 of file AlCaECALRecHitReducer.h.

Referenced by AlCaECALRecHitReducer(), and produce().

bool AlCaECALRecHitReducer::selectByEleNum_
private

Definition at line 92 of file AlCaECALRecHitReducer.h.

float AlCaECALRecHitReducer::weight_
private

Definition at line 88 of file AlCaECALRecHitReducer.h.

Referenced by AlCaECALRecHitReducer(), and produce().