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
AlCaElectronsProducer Class Reference

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

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

Public Member Functions

 AlCaElectronsProducer (const edm::ParameterSet &)
 ctor More...
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 producer More...
 
 ~AlCaElectronsProducer ()
 
- 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 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)
 
- 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

class declaration

Description: Example of a producer of AlCa electrons

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

Definition at line 45 of file AlCaElectronsProducer.h.

Constructor & Destructor Documentation

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

ctor

Definition at line 22 of file AlCaElectronsProducer.cc.

References alcaBarrelHitsCollection_, alcaEndcapHitsCollection_, alcaPreshowerHitsCollection_, ebRecHitsLabel_, eeRecHitsLabel_, electronLabel_, esNcolumns_, esNstrips_, esRecHitsLabel_, etaSize_, edm::ParameterSet::getParameter(), phiSize_, and weight_.

23 {
24 
25  ebRecHitsLabel_ = iConfig.getParameter< edm::InputTag > ("ebRecHitsLabel");
26  eeRecHitsLabel_ = iConfig.getParameter< edm::InputTag > ("eeRecHitsLabel");
27  esRecHitsLabel_ = iConfig.getParameter< edm::InputTag > ("esRecHitsLabel");
28  electronLabel_ = iConfig.getParameter< edm::InputTag > ("electronLabel");
29 
30  alcaBarrelHitsCollection_ = iConfig.getParameter<std::string>("alcaBarrelHitCollection");
31  alcaEndcapHitsCollection_ = iConfig.getParameter<std::string>("alcaEndcapHitCollection");
32  alcaPreshowerHitsCollection_ = iConfig.getParameter<std::string>("alcaPreshowerHitCollection");
33 
34  etaSize_ = iConfig.getParameter<int> ("etaSize");
35  phiSize_ = iConfig.getParameter<int> ("phiSize");
36  if ( phiSize_ % 2 == 0 || etaSize_ % 2 == 0)
37  edm::LogError("AlCaElectronsProducerError") << "Size of eta/phi should be odd numbers";
38 
39  weight_= iConfig.getParameter<double> ("eventWeight");
40 
41  esNstrips_ = iConfig.getParameter<int> ("esNstrips");
42  esNcolumns_ = iConfig.getParameter<int> ("esNcolumns");
43 
44  //register your products
45  produces< EBRecHitCollection > (alcaBarrelHitsCollection_) ;
46  produces< EERecHitCollection > (alcaEndcapHitsCollection_) ;
47  produces< ESRecHitCollection > (alcaPreshowerHitsCollection_) ;
48  produces< double > ("weight") ;
49 }
T getParameter(std::string const &) const
std::string alcaPreshowerHitsCollection_
AlCaElectronsProducer::~AlCaElectronsProducer ( )

Definition at line 52 of file AlCaElectronsProducer.cc.

53 {}

Member Function Documentation

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

producer

Implements edm::EDProducer.

Definition at line 58 of file AlCaElectronsProducer.cc.

References alcaBarrelHitsCollection_, alcaEndcapHitsCollection_, alcaPreshowerHitsCollection_, reco::SuperCluster::clustersBegin(), reco::SuperCluster::clustersEnd(), ebRecHitsLabel_, DetId::Ecal, EcalBarrel, EcalEndcap, EcalPreshower, eeRecHitsLabel_, electronLabel_, relval_parameters_module::energy, esNcolumns_, esNstrips_, esRecHitsLabel_, EBDetId::ETAPHIMODE, etaSize_, funct::false, spr::find(), geometry, edm::EventSetup::get(), edm::Event::getByLabel(), reco::CaloCluster::hitsAndFractions(), EBDetId::ieta(), EBDetId::iphi(), EEDetId::ix(), EEDetId::iy(), DetId::null(), phiSize_, ESDetId::plane(), point, edm::Event::put(), mathSSE::return(), ESDetId::six(), ESDetId::siy(), ESDetId::strip(), funct::true, EBDetId::validDetId(), EEDetId::validDetId(), CommonMethods::weight(), weight_, X, EEDetId::XYMODE, Gflash::Z, and ESDetId::zside().

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

60 {
61  using namespace edm;
62  using namespace std;
63 
64  // get the ECAL geometry:
65  ESHandle<CaloGeometry> geoHandle;
66  iSetup.get<CaloGeometryRecord>().get(geoHandle);
67 
68  const CaloSubdetectorGeometry *geometry = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
69  const CaloSubdetectorGeometry *& geometry_p = geometry;
70 
71  // Get GSFElectrons
73  iEvent.getByLabel(electronLabel_, pElectrons);
74  if (!pElectrons.isValid()) {
75  edm::LogError ("reading") << electronLabel_ << " not found" ;
76  // std::cerr << "[AlCaElectronsProducer]" << electronLabel_ << " not found" ;
77  return ;
78  }
79 
80  const reco::GsfElectronCollection * electronCollection =
81  pElectrons.product();
82 
83  // get RecHits
84  Handle<EBRecHitCollection> barrelRecHitsHandle;
85  bool barrelIsFull = true ;
86 
87  iEvent.getByLabel(ebRecHitsLabel_,barrelRecHitsHandle);
88  if (!barrelRecHitsHandle.isValid()) {
89  edm::LogError ("reading") << ebRecHitsLabel_ << " not found" ;
90  barrelIsFull = false ;
91  }
92 
93  const EBRecHitCollection * barrelHitsCollection = 0 ;
94  if (barrelIsFull)
95  barrelHitsCollection = barrelRecHitsHandle.product () ;
96 
97  // get RecHits
98  Handle<EERecHitCollection> endcapRecHitsHandle;
99  bool endcapIsFull = true ;
100 
101  iEvent.getByLabel(eeRecHitsLabel_,endcapRecHitsHandle);
102  if (!endcapRecHitsHandle.isValid()) {
103  edm::LogError ("reading") << eeRecHitsLabel_ << " not found" ;
104  endcapIsFull = false ;
105  }
106 
107  const EERecHitCollection * endcapHitsCollection = 0 ;
108  if (endcapIsFull)
109  endcapHitsCollection = endcapRecHitsHandle.product () ;
110  // const EERecHitCollection * endcapHitsCollection = endcapRecHitsHandle.product();
111 
112  // get ES RecHits
113  Handle<ESRecHitCollection> preshowerRecHitsHandle;
114  bool preshowerIsFull = true ;
115 
116  iEvent.getByLabel(esRecHitsLabel_,preshowerRecHitsHandle);
117  if (!preshowerRecHitsHandle.isValid()) {
118  edm::LogError ("reading") << esRecHitsLabel_ << " not found" ;
119  preshowerIsFull = false ;
120  }
121 
122  const ESRecHitCollection * preshowerHitsCollection = 0 ;
123  if (preshowerIsFull)
124  preshowerHitsCollection = preshowerRecHitsHandle.product () ;
125 
126  // make a vector to store the used ES rechits:
127  set<ESDetId> used_strips;
128  used_strips.clear();
129 
130  //Create empty output collections
131  std::auto_ptr< EBRecHitCollection > miniEBRecHitCollection (new EBRecHitCollection) ;
132  std::auto_ptr< EERecHitCollection > miniEERecHitCollection (new EERecHitCollection) ;
133  std::auto_ptr< ESRecHitCollection > miniESRecHitCollection (new ESRecHitCollection) ;
134  std::auto_ptr< double > weight (new double(1));
135  (*weight) = weight_;
136 
137  // loop on SiStrip Electrons
138 
139  reco::GsfElectronCollection::const_iterator eleIt;
140  int ii=0;
141 
142  for (eleIt=electronCollection->begin(); eleIt!=electronCollection->end(); eleIt++) {
143  //PG barrel
144  if (fabs(eleIt->eta()) <= 1.479) {
145 
146  ii++;
147  const reco::SuperCluster& sc = *(eleIt->superCluster()) ;
148 
149  int yy = 0;
150  double currEnergy = 0.;
151  EBDetId maxHit(0);
152  std::vector<EBDetId> scXtals;
153  scXtals.clear();
154  const std::vector< std::pair<DetId, float> > & v1 = sc.hitsAndFractions();
155 
156  for(std::vector< std::pair<DetId, float> >::const_iterator idsIt = v1.begin();
157  idsIt != v1.end(); ++idsIt)
158  {
159  yy++;
160 
161  //PG discard hits not belonging to the Ecal Barrel
162  if((*idsIt).first.subdetId()!=EcalBarrel || (*idsIt).first.det()!= DetId::Ecal) continue;
163 
164  if((barrelHitsCollection->find( (*idsIt).first ))->energy() > currEnergy) {
165  currEnergy=(barrelHitsCollection->find( (*idsIt).first ))->energy();
166  maxHit=(*idsIt).first;
167  }
168  miniEBRecHitCollection->push_back(*(barrelHitsCollection->find( (*idsIt).first )));
169  scXtals.push_back( (*idsIt).first );
170  }
171 
172  if (!maxHit.null())
173  for (int icry=0;icry< etaSize_*phiSize_;icry++)
174  {
175 
176  unsigned int row = icry / etaSize_;
177  unsigned int column= icry % etaSize_;
178  int curr_eta=maxHit.ieta() + column - (etaSize_/2);
179  int curr_phi=maxHit.iphi() + row - (phiSize_/2);
180 
181  if (curr_eta * maxHit.ieta() <= 0) {if (maxHit.ieta() > 0) curr_eta--; else curr_eta++; } // JUMP over 0
182  if (curr_phi < 1) curr_phi += 360;
183  if (curr_phi > 360) curr_phi -= 360;
184  if (!(EBDetId::validDetId(curr_eta,curr_phi))) continue;
185  EBDetId det = EBDetId(curr_eta,curr_phi,EBDetId::ETAPHIMODE);
186  std::vector<EBDetId>::const_iterator usedIds;
187 
188  bool HitAlreadyUsed=false;
189  for(usedIds=scXtals.begin(); usedIds!=scXtals.end(); usedIds++)
190  if(*usedIds==det)
191  {
192  HitAlreadyUsed=true;
193  break;
194  }
195 
196  if(!HitAlreadyUsed)
197  if (barrelHitsCollection->find(det) != barrelHitsCollection->end())
198  miniEBRecHitCollection->push_back(*(barrelHitsCollection->find(det)));
199  }
200  } //PG barrel
201  else //PG endcap
202  {
203 
204  ii++;
205  const reco::SuperCluster& sc = *(eleIt->superCluster()) ;
206 
207  int yy = 0;
208  double currEnergy = 0.;
209  EEDetId maxHit(0);
210  vector<EEDetId> scXtals;
211  scXtals.clear();
212  const std::vector< std::pair<DetId, float> > & v1 = sc.hitsAndFractions();
213 
214  for(std::vector< std::pair<DetId, float> >::const_iterator idsIt = v1.begin();
215  idsIt != v1.end(); ++idsIt)
216  {
217  yy++;
218 
219  //PG discard hits belonging to the Ecal Barrel
220  if((*idsIt).first.subdetId()!=EcalEndcap ||
221  (*idsIt).first.det()!= DetId::Ecal) continue;
222 
223  if((endcapHitsCollection->find( (*idsIt).first ))->energy() > currEnergy)
224  {
225  currEnergy=(endcapHitsCollection->find( (*idsIt).first ))->energy();
226  maxHit=(*idsIt).first;
227  }
228  miniEERecHitCollection->push_back (
229  *(endcapHitsCollection->find ( (*idsIt).first ))
230  );
231  scXtals.push_back ( (*idsIt).first ) ;
232  }
233 
234  int side = phiSize_ ;
235  if (phiSize_ < etaSize_) side = etaSize_ ;
236  int iz = 1 ;
237  if (eleIt->eta () < 0) iz = -1 ;
238  if (!maxHit.null())
239  //PG loop over the local array of xtals
240  for (int icry = 0 ; icry < side*side ; icry++)
241  {
242  unsigned int row = icry / side ;
243  unsigned int column = icry % side ;
244  int curr_eta = maxHit.ix () + column - (side/2);
245  int curr_phi = maxHit.iy () + row - (side/2);
246  if ( curr_eta <= 0 || curr_phi <= 0
247  || curr_eta > 100 || curr_phi > 100 ) continue ;
248  if (!(EEDetId::validDetId(curr_eta,curr_phi,iz))) continue;
249  EEDetId det = EEDetId (curr_eta,curr_phi,iz,EEDetId::XYMODE) ;
250  if (find (scXtals.begin (), scXtals.end (), det) != scXtals.end ())
251  if (endcapHitsCollection->find (det) != endcapHitsCollection->end ())
252  miniEERecHitCollection->push_back (*(endcapHitsCollection->find (det))) ;
253  }
254 
255  // Loop over basic clusters to find ES rec hits
257  for ( ; bc_iter != sc.clustersEnd(); ++bc_iter ) {
258  if (geometry) {
259  double X = (*bc_iter)->x();
260  double Y = (*bc_iter)->y();
261  double Z = (*bc_iter)->z();
262  const GlobalPoint point(X,Y,Z);
263 
264  DetId tmp1 = (dynamic_cast<const EcalPreshowerGeometry*>(geometry_p))->getClosestCellInPlane(point, 1);
265  DetId tmp2 = (dynamic_cast<const EcalPreshowerGeometry*>(geometry_p))->getClosestCellInPlane(point, 2);
266  ESDetId strip1 = (tmp1 == DetId(0)) ? ESDetId(0) : ESDetId(tmp1);
267  ESDetId strip2 = (tmp2 == DetId(0)) ? ESDetId(0) : ESDetId(tmp2);
268 
269  int esindexE1 = (tmp1 == DetId(0)) ? -1 : (strip1.six()-1)*32+strip1.strip();
270  int esindexE2 = (tmp2 == DetId(0)) ? -1 : (strip2.siy()-1)*32+strip2.strip();
271  int esindexRh = 0;
272 
274  for (esit = preshowerHitsCollection->begin(); esit != preshowerHitsCollection->end(); esit++) {
275 
276  ESDetId esid = ESDetId(esit->id());
277 
278  if (used_strips.find(esid) != used_strips.end()) continue;
279 
280  if (strip1 != ESDetId(0) && esid.plane()==1) {
281 
282  esindexRh = (esid.six()-1)*32+esid.strip();
283 
284  if (fabs(esindexE1-esindexRh) <= esNstrips_ && fabs(strip1.siy()-esid.siy()) <= esNcolumns_ && strip1.zside()==esid.zside()) {
285  miniESRecHitCollection->push_back(*esit);
286  used_strips.insert(esid);
287  }
288  }
289  if (strip2 != ESDetId(0) && esid.plane()==2) {
290 
291  esindexRh = (esid.siy()-1)*32+esid.strip();
292 
293  if (fabs(esindexE2-esindexRh) <= esNstrips_ && fabs(strip2.six()-esid.six()) <= esNcolumns_ && strip2.zside()==esid.zside()) {
294  miniESRecHitCollection->push_back(*esit);
295  used_strips.insert(esid);
296  }
297  }
298 
299  }
300  }
301  }
302 
303  } //PG endcap
304 
305  } //PG loop on Si strip electrons
306 
307  //Put selected information in the event
308  iEvent.put( miniEBRecHitCollection,alcaBarrelHitsCollection_ );
309  iEvent.put( miniEERecHitCollection,alcaEndcapHitsCollection_ );
310  iEvent.put( miniESRecHitCollection,alcaPreshowerHitsCollection_ );
311  iEvent.put( weight, "weight");
312 }
const double Z[kNumberCalorimeter]
static bool validDetId(int i, int j)
check if a valid index combination
Definition: EBDetId.cc:59
int strip() const
Definition: ESDetId.h:41
std::string alcaPreshowerHitsCollection_
static const int XYMODE
Definition: EEDetId.h:316
std::vector< T >::const_iterator const_iterator
#define X(str)
Definition: MuonsGrabber.cc:49
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:189
int six() const
Definition: ESDetId.h:37
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.cc:562
return((rh^lh)&mask)
int siy() const
Definition: ESDetId.h:39
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
int zside() const
Definition: ESDetId.h:33
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
static const int ETAPHIMODE
Definition: EBDetId.h:145
Definition: DetId.h:20
const T & get() const
Definition: EventSetup.h:55
ESHandle< TrackerGeometry > geometry
int plane() const
Definition: ESDetId.h:35
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
Definition: SuperCluster.h:65
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents
Definition: SuperCluster.h:68

Member Data Documentation

std::string AlCaElectronsProducer::alcaBarrelHitsCollection_
private

Definition at line 83 of file AlCaElectronsProducer.h.

Referenced by AlCaElectronsProducer(), and produce().

std::string AlCaElectronsProducer::alcaEndcapHitsCollection_
private

Definition at line 84 of file AlCaElectronsProducer.h.

Referenced by AlCaElectronsProducer(), and produce().

std::string AlCaElectronsProducer::alcaPreshowerHitsCollection_
private

Definition at line 85 of file AlCaElectronsProducer.h.

Referenced by AlCaElectronsProducer(), and produce().

edm::InputTag AlCaElectronsProducer::ebRecHitsLabel_
private

Definition at line 79 of file AlCaElectronsProducer.h.

Referenced by AlCaElectronsProducer(), and produce().

edm::InputTag AlCaElectronsProducer::eeRecHitsLabel_
private

Definition at line 80 of file AlCaElectronsProducer.h.

Referenced by AlCaElectronsProducer(), and produce().

edm::InputTag AlCaElectronsProducer::electronLabel_
private

Definition at line 82 of file AlCaElectronsProducer.h.

Referenced by AlCaElectronsProducer(), and produce().

int AlCaElectronsProducer::esNcolumns_
private

Definition at line 90 of file AlCaElectronsProducer.h.

Referenced by AlCaElectronsProducer(), and produce().

int AlCaElectronsProducer::esNstrips_
private

Definition at line 89 of file AlCaElectronsProducer.h.

Referenced by AlCaElectronsProducer(), and produce().

edm::InputTag AlCaElectronsProducer::esRecHitsLabel_
private

Definition at line 81 of file AlCaElectronsProducer.h.

Referenced by AlCaElectronsProducer(), and produce().

int AlCaElectronsProducer::etaSize_
private

Definition at line 86 of file AlCaElectronsProducer.h.

Referenced by AlCaElectronsProducer(), and produce().

int AlCaElectronsProducer::minEleNumber_
private

Definition at line 93 of file AlCaElectronsProducer.h.

double AlCaElectronsProducer::minElePt_
private

Definition at line 94 of file AlCaElectronsProducer.h.

int AlCaElectronsProducer::phiSize_
private

Definition at line 87 of file AlCaElectronsProducer.h.

Referenced by AlCaElectronsProducer(), and produce().

bool AlCaElectronsProducer::selectByEleNum_
private

Definition at line 92 of file AlCaElectronsProducer.h.

float AlCaElectronsProducer::weight_
private

Definition at line 88 of file AlCaElectronsProducer.h.

Referenced by AlCaElectronsProducer(), and produce().