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  * $Date: 2009/12/14 22:22:19 $
8  * $Revision: 1.3 $
9  *
10  *
11  * Description: Monitoring of Phi Symmetry Calibration Stream
12 */
13 
14 
19 
20 // DQM include files
21 
23 
24 // work on collections
29 
31 
34 
35 
36 using namespace std;
37 using namespace edm;
38 
39 
40 // ******************************************
41 // constructors
42 // *****************************************
43 
45 eventCounter_(0)
46 {
48  folderName_ = ps.getUntrackedParameter<string>("FolderName","ALCAStreamEcalSingleEle");
49  productMonitoredEB_= ps.getParameter<edm::InputTag>("AlCaStreamEBTag");
50  productMonitoredEE_= ps.getParameter<edm::InputTag>("AlCaStreamEETag");
51 
52  saveToFile_=ps.getUntrackedParameter<bool>("SaveToFile",false);
53  fileName_= ps.getUntrackedParameter<string>("FileName","MonitorAlCaEcalSingleEle.root");
54  productMonitoredElectrons_ = ps.getParameter<InputTag>("electronCollection");
55  prescaleFactor_ = ps.getUntrackedParameter<unsigned int>("prescaleFactor",1);
56 
57 }
58 
59 
61 {}
62 
63 
64 //--------------------------------------------------------
66 
67  // create and cd into new folder
69 
70  recHitsPerElectron_ = dbe_->book1D("recHitsPerElectron_","recHitPerElectron",
71  200,0,200);
72  ElectronsNumber_ = dbe_->book1D("ElectronsNumber_","electrons in the event",
73  40,0,40);
74  ESCoP_ = dbe_->book1D ("ESCoP","ESCoP",50,0,5);
75 
76  OccupancyEB_= dbe_->book2D("OccupancyEB_","OccupancyEB",360,1,361,171,-85,86);
77  OccupancyEEP_= dbe_->book2D("OccupancyEEP_","Occupancy EE Plus",100,1,101,100,1,101);
78  OccupancyEEM_= dbe_->book2D("OccupancyEEM_","Occupancy EE Minus",100,1,101,100,1,101);
79  HitsVsAssociatedHits_ = dbe_->book1D ("HitsVsAssociatedHits_","HitsVsAssociatedHits",100,0,5);
80  LocalOccupancyEB_ = dbe_->book2D ("LocalOccupancyEB_","Local occupancy Barrel",9,-4,5,9,-4,5);
81  LocalOccupancyEE_ = dbe_->book2D ("LocalOccupancyEE_","Local occupancy Endcap",9,-4,5,9,-4,5);
82 
83 }
84 
85 //--------------------------------------------------------
86 void DQMSourceEleCalib::beginRun(const edm::Run& r, const EventSetup& context) {
87 
88 }
89 
90 //--------------------------------------------------------
92  const EventSetup& context) {
93 
94 }
95 
96 //-------------------------------------------------------------
97 
99  const EventSetup& iSetup ){
100 
101 // if (eventCounter_% prescaleFactor_ ) return; //FIXME
102  eventCounter_++;
103  int numberOfHits=0;
104  int numberOfElectrons=0;
105  int numberOfAssociatedHits = 0;
106  //reads the recHits
109 
110  iEvent.getByLabel(productMonitoredEB_, rhEB);
111  iEvent.getByLabel(productMonitoredEE_, rhEE);
112 
114 
115  //reads the electrons
117  iEvent.getByLabel (productMonitoredElectrons_, pElectrons) ;
118 
119  if (pElectrons.isValid()){
120  ElectronsNumber_->Fill(pElectrons->size()+0.1);
121  numberOfElectrons = pElectrons->size();
122  for (reco::GsfElectronCollection::const_iterator eleIt = pElectrons->begin();
123  eleIt!= pElectrons->end(); ++eleIt){
124  ESCoP_->Fill(eleIt->eSuperClusterOverP());
125  numberOfAssociatedHits+= eleIt->superCluster()->size();
126  DetId Max = findMaxHit (eleIt->superCluster ()->hitsAndFractions (),
127  rhEB.product(), rhEE.product()) ;
128  if (!Max.det()) continue;
129  if (Max.subdetId()==EcalBarrel) {
130  EBDetId EBMax (Max);
131  fillAroundBarrel (rhEB.product(),EBMax.ieta(),EBMax.iphi());
132  }
133  if (Max.subdetId()==EcalEndcap) {
134  EEDetId EEMax (Max);
135  fillAroundEndcap (rhEE.product(),EEMax.ix(),EEMax.iy());
136  }
137  }
138  }//is valid electron
139 
140  // fill EB histos
141  if (rhEB.isValid())
142  {
143  numberOfHits+= rhEB->size();
144  for(itb=rhEB->begin(); itb!=rhEB->end(); ++itb){
145  EBDetId id(itb->id());
146  OccupancyEB_->Fill(id.iphi(),id.ieta());
147  } // Eb rechits
148  } //is Valid
149  if (rhEE.isValid())
150  {
151  numberOfHits+= rhEE->size();
152  for (itb = rhEE->begin(); itb!=rhEE->end(); ++itb){
153  EEDetId id (itb->id());
154  if (id.zside()>0){
155  OccupancyEEP_->Fill(id.ix(),id.iy());
156  } //zside>0
157  else if (id.zside()<0){
158  OccupancyEEM_->Fill(id.ix(),id.iy());
159  } //zside<0
160 
161  }//EE reChit
162  }//is Valid
163  if (numberOfElectrons) recHitsPerElectron_->Fill((double)numberOfHits/((double)numberOfElectrons));
164  if (numberOfHits) HitsVsAssociatedHits_->Fill((double)numberOfAssociatedHits/((double)numberOfHits));
165 } //end of the analyzer
166 
167 
168 
169 
170 //--------------------------------------------------------
172  const EventSetup& context) {
173 }
174 //--------------------------------------------------------
175 void DQMSourceEleCalib::endRun(const Run& r, const EventSetup& context){
176 
177 }
178 //--------------------------------------------------------
180 
181  if (saveToFile_) {
182  dbe_->save(fileName_);
183  }
184 
185 }
186 
187 
188 DetId
189 DQMSourceEleCalib::findMaxHit (const std::vector<std::pair<DetId,float> > & v1,
190  const EcalRecHitCollection* EBhits,
191  const EcalRecHitCollection* EEhits)
192 {
193 
194  double currEnergy = 0. ;
195  DetId maxHit ;
196  for (std::vector<std::pair<DetId,float> >::const_iterator idsIt = v1.begin () ;
197  idsIt != v1.end () ; ++idsIt)
198  {
199 
200  if (idsIt->first.subdetId () == EcalBarrel)
201  {
203  itrechit = EBhits->find ((*idsIt).first) ;
204  if (itrechit == EBhits->end () )
205  {
206  edm::LogInfo ("reading")
207  << "[findMaxHit] rechit not found! " ;
208  continue ;
209  }
210 //FIXME: wnat to use the fraction i.e. .second??
211  if (itrechit->energy () > currEnergy)
212  {
213  currEnergy = itrechit->energy () ;
214  maxHit= (*idsIt).first ;
215  }
216  }
217  else
218  {
220  itrechit = EEhits->find ((*idsIt).first) ;
221  if (itrechit == EEhits->end () )
222  {
223  edm::LogInfo ("reading")
224  << "[findMaxHit] rechit not found! " ;
225  continue ;
226  }
227 
228 //FIXME: wnat to use the fraction i.e. .second??
229  if (itrechit->energy () > currEnergy)
230  {
231  currEnergy=itrechit->energy () ;
232  maxHit= (*idsIt).first ;
233  }
234  }
235  }
236  return maxHit ;
237 }
238 
239 
240 void
242 {
243 
244  for (EcalRecHitCollection::const_iterator elem = recHits->begin () ;
245  elem != recHits->end () ;
246  ++elem)
247  {
248  EBDetId elementId = elem->id () ;
250  elementId.ieta () - eta ,
251  elementId.iphi () - phi ,
252  elem->energy ()
253  ) ;
254  }
255  return ;
256 }
257 
258 
259 // ----------------------------------------------------------------
260 
261 
262 void
264 {
265  for (EcalRecHitCollection::const_iterator elem = recHits->begin () ;
266  elem != recHits->end () ;
267  ++elem)
268  {
269  EEDetId elementId = elem->id () ;
271  elementId.ix () - ics ,
272  elementId.iy () - ips ,
273  elem->energy ()
274  ) ;
275  }
276  return ;
277 }
MonitorElement * ESCoP_
ESCoP.
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int ix() const
Definition: EEDetId.h:77
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:722
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2118
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.
void beginRun(const edm::Run &r, const edm::EventSetup &c)
edm::InputTag productMonitoredElectrons_
electrons to monitor
T eta() const
void Fill(long long x)
int iphi() const
get the crystal iphi
Definition: EBDetId.h:54
edm::InputTag productMonitoredEE_
object to monitor
MonitorElement * OccupancyEEM_
bool saveToFile_
Write to file.
int iEvent
Definition: GenABIO.cc:243
MonitorElement * HitsVsAssociatedHits_
recHits over associated recHits
std::string folderName_
DQM folder name.
void endRun(const edm::Run &r, const edm::EventSetup &c)
int iy() const
Definition: EEDetId.h:83
int ieta() const
get the crystal ieta
Definition: EBDetId.h:52
MonitorElement * OccupancyEEP_
bool isValid() const
Definition: HandleBase.h:76
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
DQMSourceEleCalib(const edm::ParameterSet &)
void fillAroundEndcap(const EcalRecHitCollection *, int, int)
MonitorElement * recHitsPerElectron_
Number of recHits per electron.
edm::InputTag productMonitoredEB_
object to monitor
const_iterator end() const
unsigned int prescaleFactor_
Monitor every prescaleFactor_ events.
void analyze(const edm::Event &e, const edm::EventSetup &c)
void fillAroundBarrel(const EcalRecHitCollection *, int, int)
fills local occupancy graphs
Definition: DetId.h:20
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context)
MonitorElement * OccupancyEB_
Occupancy.
DetId findMaxHit(const std::vector< std::pair< DetId, float > > &, const EcalRecHitCollection *, const EcalRecHitCollection *)
find the MOX
T const * product() const
Definition: Handle.h:74
iterator find(key_type k)
MonitorElement * ElectronsNumber_
Number of electrons.
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:850
Detector det() const
get the detector field from this detid
Definition: DetId.h:37
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
const_iterator begin() const
Definition: Run.h:36
MonitorElement * LocalOccupancyEB_
Definition: DDAxes.h:10