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 {
44  folderName_ = ps.getUntrackedParameter<string>("FolderName","ALCAStreamEcalSingleEle");
45  productMonitoredEB_= consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("AlCaStreamEBTag"));
46  productMonitoredEE_= consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("AlCaStreamEETag"));
47 
48  saveToFile_=ps.getUntrackedParameter<bool>("SaveToFile",false);
49  fileName_= ps.getUntrackedParameter<string>("FileName","MonitorAlCaEcalSingleEle.root");
50  productMonitoredElectrons_ = consumes<reco::GsfElectronCollection>(ps.getParameter<InputTag>("electronCollection"));
51  prescaleFactor_ = ps.getUntrackedParameter<unsigned int>("prescaleFactor",1);
52 
53 }
54 
55 
57 {}
58 
59 
60 //--------------------------------------------------------
62 
63  // create and cd into new folder
65 
66  recHitsPerElectron_ = dbe_->book1D("recHitsPerElectron_","recHitPerElectron",
67  200,0,200);
68  ElectronsNumber_ = dbe_->book1D("ElectronsNumber_","electrons in the event",
69  40,0,40);
70  ESCoP_ = dbe_->book1D ("ESCoP","ESCoP",50,0,5);
71 
72  OccupancyEB_= dbe_->book2D("OccupancyEB_","OccupancyEB",360,1,361,171,-85,86);
73  OccupancyEEP_= dbe_->book2D("OccupancyEEP_","Occupancy EE Plus",100,1,101,100,1,101);
74  OccupancyEEM_= dbe_->book2D("OccupancyEEM_","Occupancy EE Minus",100,1,101,100,1,101);
75  HitsVsAssociatedHits_ = dbe_->book1D ("HitsVsAssociatedHits_","HitsVsAssociatedHits",100,0,5);
76  LocalOccupancyEB_ = dbe_->book2D ("LocalOccupancyEB_","Local occupancy Barrel",9,-4,5,9,-4,5);
77  LocalOccupancyEE_ = dbe_->book2D ("LocalOccupancyEE_","Local occupancy Endcap",9,-4,5,9,-4,5);
78 
79 }
80 
81 //--------------------------------------------------------
82 void DQMSourceEleCalib::beginRun(const edm::Run& r, const EventSetup& context) {
83 
84 }
85 
86 //--------------------------------------------------------
88  const EventSetup& context) {
89 
90 }
91 
92 //-------------------------------------------------------------
93 
95  const EventSetup& iSetup ){
96 
97 // if (eventCounter_% prescaleFactor_ ) return; //FIXME
98  eventCounter_++;
99  int numberOfHits=0;
100  int numberOfElectrons=0;
101  int numberOfAssociatedHits = 0;
102  //reads the recHits
105 
106  iEvent.getByToken(productMonitoredEB_, rhEB);
107  iEvent.getByToken(productMonitoredEE_, rhEE);
108 
110 
111  //reads the electrons
113  iEvent.getByToken (productMonitoredElectrons_, pElectrons) ;
114 
115  if (pElectrons.isValid()){
116  ElectronsNumber_->Fill(pElectrons->size()+0.1);
117  numberOfElectrons = pElectrons->size();
118  for (reco::GsfElectronCollection::const_iterator eleIt = pElectrons->begin();
119  eleIt!= pElectrons->end(); ++eleIt){
120  ESCoP_->Fill(eleIt->eSuperClusterOverP());
121  numberOfAssociatedHits+= eleIt->superCluster()->size();
122  DetId Max = findMaxHit (eleIt->superCluster ()->hitsAndFractions (),
123  rhEB.product(), rhEE.product()) ;
124  if (!Max.det()) continue;
125  if (Max.subdetId()==EcalBarrel) {
126  EBDetId EBMax (Max);
127  fillAroundBarrel (rhEB.product(),EBMax.ieta(),EBMax.iphi());
128  }
129  if (Max.subdetId()==EcalEndcap) {
130  EEDetId EEMax (Max);
131  fillAroundEndcap (rhEE.product(),EEMax.ix(),EEMax.iy());
132  }
133  }
134  }//is valid electron
135 
136  // fill EB histos
137  if (rhEB.isValid())
138  {
139  numberOfHits+= rhEB->size();
140  for(itb=rhEB->begin(); itb!=rhEB->end(); ++itb){
141  EBDetId id(itb->id());
142  OccupancyEB_->Fill(id.iphi(),id.ieta());
143  } // Eb rechits
144  } //is Valid
145  if (rhEE.isValid())
146  {
147  numberOfHits+= rhEE->size();
148  for (itb = rhEE->begin(); itb!=rhEE->end(); ++itb){
149  EEDetId id (itb->id());
150  if (id.zside()>0){
151  OccupancyEEP_->Fill(id.ix(),id.iy());
152  } //zside>0
153  else if (id.zside()<0){
154  OccupancyEEM_->Fill(id.ix(),id.iy());
155  } //zside<0
156 
157  }//EE reChit
158  }//is Valid
159  if (numberOfElectrons) recHitsPerElectron_->Fill((double)numberOfHits/((double)numberOfElectrons));
160  if (numberOfHits) HitsVsAssociatedHits_->Fill((double)numberOfAssociatedHits/((double)numberOfHits));
161 } //end of the analyzer
162 
163 
164 
165 
166 //--------------------------------------------------------
168  const EventSetup& context) {
169 }
170 //--------------------------------------------------------
171 void DQMSourceEleCalib::endRun(const Run& r, const EventSetup& context){
172 
173 }
174 //--------------------------------------------------------
176 
177  if (saveToFile_) {
178  dbe_->save(fileName_);
179  }
180 
181 }
182 
183 
184 DetId
185 DQMSourceEleCalib::findMaxHit (const std::vector<std::pair<DetId,float> > & v1,
186  const EcalRecHitCollection* EBhits,
187  const EcalRecHitCollection* EEhits)
188 {
189 
190  double currEnergy = 0. ;
191  DetId maxHit ;
192  for (std::vector<std::pair<DetId,float> >::const_iterator idsIt = v1.begin () ;
193  idsIt != v1.end () ; ++idsIt)
194  {
195 
196  if (idsIt->first.subdetId () == EcalBarrel)
197  {
199  itrechit = EBhits->find ((*idsIt).first) ;
200  if (itrechit == EBhits->end () )
201  {
202  edm::LogInfo ("reading")
203  << "[findMaxHit] rechit not found! " ;
204  continue ;
205  }
206 //FIXME: wnat to use the fraction i.e. .second??
207  if (itrechit->energy () > currEnergy)
208  {
209  currEnergy = itrechit->energy () ;
210  maxHit= (*idsIt).first ;
211  }
212  }
213  else
214  {
216  itrechit = EEhits->find ((*idsIt).first) ;
217  if (itrechit == EEhits->end () )
218  {
219  edm::LogInfo ("reading")
220  << "[findMaxHit] rechit not found! " ;
221  continue ;
222  }
223 
224 //FIXME: wnat to use the fraction i.e. .second??
225  if (itrechit->energy () > currEnergy)
226  {
227  currEnergy=itrechit->energy () ;
228  maxHit= (*idsIt).first ;
229  }
230  }
231  }
232  return maxHit ;
233 }
234 
235 
236 void
238 {
239 
240  for (EcalRecHitCollection::const_iterator elem = recHits->begin () ;
241  elem != recHits->end () ;
242  ++elem)
243  {
244  EBDetId elementId = elem->id () ;
246  elementId.ieta () - eta ,
247  elementId.iphi () - phi ,
248  elem->energy ()
249  ) ;
250  }
251  return ;
252 }
253 
254 
255 // ----------------------------------------------------------------
256 
257 
258 void
260 {
261  for (EcalRecHitCollection::const_iterator elem = recHits->begin () ;
262  elem != recHits->end () ;
263  ++elem)
264  {
265  EEDetId elementId = elem->id () ;
267  elementId.ix () - ics ,
268  elementId.iy () - ips ,
269  elem->energy ()
270  ) ;
271  }
272  return ;
273 }
MonitorElement * ESCoP_
ESCoP.
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int ix() const
Definition: EEDetId.h:76
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:954
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
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)
int zside(DetId const &)
T eta() 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.
void endRun(const edm::Run &r, const edm::EventSetup &c)
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:76
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 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:81
iterator find(key_type k)
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, const uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE", const bool resetMEsAfterWriting=false)
Definition: DQMStore.cc:2540
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:1082
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:667
const_iterator begin() const
Definition: Run.h:41
MonitorElement * LocalOccupancyEB_
edm::EDGetTokenT< reco::GsfElectronCollection > productMonitoredElectrons_
electrons to monitor
Definition: DDAxes.h:10