CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DQMSourceEleCalib.cc
Go to the documentation of this file.
1 /*
2  * \file DQMSourceEleCalib.cc
3  *
4  * \author Andrea Gozzelino - Universita  e INFN Torino
5  * \author Stefano Argiro
6  *
7  *
8  *
9  * Description: Monitoring of Phi Symmetry Calibration Stream
10 */
11 
12 
17 
18 // DQM include files
19 
21 
22 // work on collections
25 
27 
30 
31 
32 using namespace std;
33 using namespace edm;
34 
35 
36 // ******************************************
37 // constructors
38 // *****************************************
39 
41 eventCounter_(0)
42 {
43  folderName_ = ps.getUntrackedParameter<string>("FolderName","ALCAStreamEcalSingleEle");
44  productMonitoredEB_= consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("AlCaStreamEBTag"));
45  productMonitoredEE_= consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("AlCaStreamEETag"));
46 
47  saveToFile_=ps.getUntrackedParameter<bool>("SaveToFile",false);
48  fileName_= ps.getUntrackedParameter<string>("FileName","MonitorAlCaEcalSingleEle.root");
49  productMonitoredElectrons_ = consumes<reco::GsfElectronCollection>(ps.getParameter<InputTag>("electronCollection"));
50  prescaleFactor_ = ps.getUntrackedParameter<unsigned int>("prescaleFactor",1);
51 
52 }
53 
54 
56 {}
57 
58 
59 //--------------------------------------------------------
60 void DQMSourceEleCalib::bookHistograms(DQMStore::IBooker & ibooker, edm::Run const & irun, edm::EventSetup const & isetup) {
61 
62  // create and cd into new folder
64 
65  recHitsPerElectron_ = ibooker.book1D("recHitsPerElectron_","recHitPerElectron",
66  200,0,200);
67  ElectronsNumber_ = ibooker.book1D("ElectronsNumber_","electrons in the event",
68  40,0,40);
69  ESCoP_ = ibooker.book1D ("ESCoP","ESCoP",50,0,5);
70 
71  OccupancyEB_= ibooker.book2D("OccupancyEB_","OccupancyEB",360,1,361,171,-85,86);
72  OccupancyEEP_= ibooker.book2D("OccupancyEEP_","Occupancy EE Plus",100,1,101,100,1,101);
73  OccupancyEEM_= ibooker.book2D("OccupancyEEM_","Occupancy EE Minus",100,1,101,100,1,101);
74  HitsVsAssociatedHits_ = ibooker.book1D ("HitsVsAssociatedHits_","HitsVsAssociatedHits",100,0,5);
75  LocalOccupancyEB_ = ibooker.book2D ("LocalOccupancyEB_","Local occupancy Barrel",9,-4,5,9,-4,5);
76  LocalOccupancyEE_ = ibooker.book2D ("LocalOccupancyEE_","Local occupancy Endcap",9,-4,5,9,-4,5);
77 
78 }
79 
80 //--------------------------------------------------------
82  const EventSetup& context) {
83 
84 }
85 
86 //-------------------------------------------------------------
87 
89  const EventSetup& iSetup ){
90 
91 // if (eventCounter_% prescaleFactor_ ) return; //FIXME
92  eventCounter_++;
93  int numberOfHits=0;
94  int numberOfElectrons=0;
95  int numberOfAssociatedHits = 0;
96  //reads the recHits
99 
100  iEvent.getByToken(productMonitoredEB_, rhEB);
101  iEvent.getByToken(productMonitoredEE_, rhEE);
102 
104 
105  //reads the electrons
107  iEvent.getByToken (productMonitoredElectrons_, pElectrons) ;
108 
109  if (pElectrons.isValid()){
110  ElectronsNumber_->Fill(pElectrons->size()+0.1);
111  numberOfElectrons = pElectrons->size();
112  for (reco::GsfElectronCollection::const_iterator eleIt = pElectrons->begin();
113  eleIt!= pElectrons->end(); ++eleIt){
114  ESCoP_->Fill(eleIt->eSuperClusterOverP());
115  numberOfAssociatedHits+= eleIt->superCluster()->size();
116  DetId Max = findMaxHit (eleIt->superCluster ()->hitsAndFractions (),
117  rhEB.product(), rhEE.product()) ;
118  if (!Max.det()) continue;
119  if (Max.subdetId()==EcalBarrel) {
120  EBDetId EBMax (Max);
121  fillAroundBarrel (rhEB.product(),EBMax.ieta(),EBMax.iphi());
122  }
123  if (Max.subdetId()==EcalEndcap) {
124  EEDetId EEMax (Max);
125  fillAroundEndcap (rhEE.product(),EEMax.ix(),EEMax.iy());
126  }
127  }
128  }//is valid electron
129 
130  // fill EB histos
131  if (rhEB.isValid())
132  {
133  numberOfHits+= rhEB->size();
134  for(itb=rhEB->begin(); itb!=rhEB->end(); ++itb){
135  EBDetId id(itb->id());
136  OccupancyEB_->Fill(id.iphi(),id.ieta());
137  } // Eb rechits
138  } //is Valid
139  if (rhEE.isValid())
140  {
141  numberOfHits+= rhEE->size();
142  for (itb = rhEE->begin(); itb!=rhEE->end(); ++itb){
143  EEDetId id (itb->id());
144  if (id.zside()>0){
145  OccupancyEEP_->Fill(id.ix(),id.iy());
146  } //zside>0
147  else if (id.zside()<0){
148  OccupancyEEM_->Fill(id.ix(),id.iy());
149  } //zside<0
150 
151  }//EE reChit
152  }//is Valid
153  if (numberOfElectrons) recHitsPerElectron_->Fill((double)numberOfHits/((double)numberOfElectrons));
154  if (numberOfHits) HitsVsAssociatedHits_->Fill((double)numberOfAssociatedHits/((double)numberOfHits));
155 } //end of the analyzer
156 
157 
158 
159 
160 //--------------------------------------------------------
162  const EventSetup& context) {
163 }
164 
165 //------------------------------------------------
166 
167 
168 DetId
169 DQMSourceEleCalib::findMaxHit (const std::vector<std::pair<DetId,float> > & v1,
170  const EcalRecHitCollection* EBhits,
171  const EcalRecHitCollection* EEhits)
172 {
173 
174  double currEnergy = 0. ;
175  DetId maxHit ;
176  for (std::vector<std::pair<DetId,float> >::const_iterator idsIt = v1.begin () ;
177  idsIt != v1.end () ; ++idsIt)
178  {
179 
180  if (idsIt->first.subdetId () == EcalBarrel)
181  {
183  itrechit = EBhits->find ((*idsIt).first) ;
184  if (itrechit == EBhits->end () )
185  {
186  edm::LogInfo ("reading")
187  << "[findMaxHit] rechit not found! " ;
188  continue ;
189  }
190 //FIXME: wnat to use the fraction i.e. .second??
191  if (itrechit->energy () > currEnergy)
192  {
193  currEnergy = itrechit->energy () ;
194  maxHit= (*idsIt).first ;
195  }
196  }
197  else
198  {
200  itrechit = EEhits->find ((*idsIt).first) ;
201  if (itrechit == EEhits->end () )
202  {
203  edm::LogInfo ("reading")
204  << "[findMaxHit] rechit not found! " ;
205  continue ;
206  }
207 
208 //FIXME: wnat to use the fraction i.e. .second??
209  if (itrechit->energy () > currEnergy)
210  {
211  currEnergy=itrechit->energy () ;
212  maxHit= (*idsIt).first ;
213  }
214  }
215  }
216  return maxHit ;
217 }
218 
219 
220 void
222 {
223 
224  for (EcalRecHitCollection::const_iterator elem = recHits->begin () ;
225  elem != recHits->end () ;
226  ++elem)
227  {
228  EBDetId elementId = elem->id () ;
230  elementId.ieta () - eta ,
231  elementId.iphi () - phi ,
232  elem->energy ()
233  ) ;
234  }
235  return ;
236 }
237 
238 
239 // ----------------------------------------------------------------
240 
241 
242 void
244 {
245  for (EcalRecHitCollection::const_iterator elem = recHits->begin () ;
246  elem != recHits->end () ;
247  ++elem)
248  {
249  EEDetId elementId = elem->id () ;
251  elementId.ix () - ics ,
252  elementId.iy () - ips ,
253  elem->energy ()
254  ) ;
255  }
256  return ;
257 }
MonitorElement * ESCoP_
ESCoP.
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
int ix() const
Definition: EEDetId.h:76
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
MonitorElement * LocalOccupancyEE_
std::vector< EcalRecHit >::const_iterator const_iterator
std::string fileName_
Output file name if required.
int zside(DetId const &)
edm::EDGetTokenT< EcalRecHitCollection > productMonitoredEE_
object to monitor
return((rh^lh)&mask)
void Fill(long long x)
int iphi() const
get the crystal iphi
Definition: EBDetId.h:53
MonitorElement * OccupancyEEM_
bool saveToFile_
Write to file.
int iEvent
Definition: GenABIO.cc:230
edm::EDGetTokenT< EcalRecHitCollection > productMonitoredEB_
object to monitor
MonitorElement * HitsVsAssociatedHits_
recHits over associated recHits
std::string folderName_
DQM folder name.
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
int iy() const
Definition: EEDetId.h:82
int ieta() const
get the crystal ieta
Definition: EBDetId.h:51
MonitorElement * OccupancyEEP_
bool isValid() const
Definition: HandleBase.h:75
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
DQMSourceEleCalib(const edm::ParameterSet &)
void fillAroundEndcap(const EcalRecHitCollection *, int, int)
MonitorElement * recHitsPerElectron_
Number of recHits per electron.
const_iterator end() const
unsigned int prescaleFactor_
Monitor every prescaleFactor_ events.
T Max(T a, T b)
Definition: MathUtil.h:44
void analyze(const edm::Event &e, const edm::EventSetup &c)
void fillAroundBarrel(const EcalRecHitCollection *, int, int)
fills local occupancy graphs
Definition: DetId.h:18
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context)
T const * product() const
Definition: Handle.h:81
MonitorElement * OccupancyEB_
Occupancy.
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
DetId findMaxHit(const std::vector< std::pair< DetId, float > > &, const EcalRecHitCollection *, const EcalRecHitCollection *)
find the MOX
Geom::Phi< T > phi() const
iterator find(key_type k)
MonitorElement * ElectronsNumber_
Number of electrons.
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
const_iterator begin() const
Definition: Run.h:43
MonitorElement * LocalOccupancyEB_
edm::EDGetTokenT< reco::GsfElectronCollection > productMonitoredElectrons_
electrons to monitor