CMS 3D CMS Logo

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 //--------------------------------------------------------
81 
82 //-------------------------------------------------------------
83 
85  const EventSetup& iSetup ){
86 
87 // if (eventCounter_% prescaleFactor_ ) return; //FIXME
88  eventCounter_++;
89  int numberOfHits=0;
90  int numberOfElectrons=0;
91  int numberOfAssociatedHits = 0;
92  //reads the recHits
95 
96  iEvent.getByToken(productMonitoredEB_, rhEB);
97  iEvent.getByToken(productMonitoredEE_, rhEE);
98 
100 
101  //reads the electrons
103  iEvent.getByToken (productMonitoredElectrons_, pElectrons) ;
104 
105  if (pElectrons.isValid()){
106  ElectronsNumber_->Fill(pElectrons->size()+0.1);
107  numberOfElectrons = pElectrons->size();
108  for (reco::GsfElectronCollection::const_iterator eleIt = pElectrons->begin();
109  eleIt!= pElectrons->end(); ++eleIt){
110  ESCoP_->Fill(eleIt->eSuperClusterOverP());
111  numberOfAssociatedHits+= eleIt->superCluster()->size();
112  DetId Max = findMaxHit (eleIt->superCluster ()->hitsAndFractions (),
113  rhEB.product(), rhEE.product()) ;
114  if (!Max.det()) continue;
115  if (Max.subdetId()==EcalBarrel) {
116  EBDetId EBMax (Max);
117  fillAroundBarrel (rhEB.product(),EBMax.ieta(),EBMax.iphi());
118  }
119  if (Max.subdetId()==EcalEndcap) {
120  EEDetId EEMax (Max);
121  fillAroundEndcap (rhEE.product(),EEMax.ix(),EEMax.iy());
122  }
123  }
124  }//is valid electron
125 
126  // fill EB histos
127  if (rhEB.isValid())
128  {
129  numberOfHits+= rhEB->size();
130  for(itb=rhEB->begin(); itb!=rhEB->end(); ++itb){
131  EBDetId id(itb->id());
132  OccupancyEB_->Fill(id.iphi(),id.ieta());
133  } // Eb rechits
134  } //is Valid
135  if (rhEE.isValid())
136  {
137  numberOfHits+= rhEE->size();
138  for (itb = rhEE->begin(); itb!=rhEE->end(); ++itb){
139  EEDetId id (itb->id());
140  if (id.zside()>0){
141  OccupancyEEP_->Fill(id.ix(),id.iy());
142  } //zside>0
143  else if (id.zside()<0){
144  OccupancyEEM_->Fill(id.ix(),id.iy());
145  } //zside<0
146 
147  }//EE reChit
148  }//is Valid
149  if (numberOfElectrons) recHitsPerElectron_->Fill((double)numberOfHits/((double)numberOfElectrons));
150  if (numberOfHits) HitsVsAssociatedHits_->Fill((double)numberOfAssociatedHits/((double)numberOfHits));
151 } //end of the analyzer
152 
153 
154 
155 
156 //--------------------------------------------------------
157 
158 //------------------------------------------------
159 
160 
161 DetId
162 DQMSourceEleCalib::findMaxHit (const std::vector<std::pair<DetId,float> > & v1,
163  const EcalRecHitCollection* EBhits,
164  const EcalRecHitCollection* EEhits)
165 {
166 
167  double currEnergy = 0. ;
168  DetId maxHit ;
169  for (std::vector<std::pair<DetId,float> >::const_iterator idsIt = v1.begin () ;
170  idsIt != v1.end () ; ++idsIt)
171  {
172 
173  if (idsIt->first.subdetId () == EcalBarrel)
174  {
176  itrechit = EBhits->find ((*idsIt).first) ;
177  if (itrechit == EBhits->end () )
178  {
179  edm::LogInfo ("reading")
180  << "[findMaxHit] rechit not found! " ;
181  continue ;
182  }
183 //FIXME: wnat to use the fraction i.e. .second??
184  if (itrechit->energy () > currEnergy)
185  {
186  currEnergy = itrechit->energy () ;
187  maxHit= (*idsIt).first ;
188  }
189  }
190  else
191  {
193  itrechit = EEhits->find ((*idsIt).first) ;
194  if (itrechit == EEhits->end () )
195  {
196  edm::LogInfo ("reading")
197  << "[findMaxHit] rechit not found! " ;
198  continue ;
199  }
200 
201 //FIXME: wnat to use the fraction i.e. .second??
202  if (itrechit->energy () > currEnergy)
203  {
204  currEnergy=itrechit->energy () ;
205  maxHit= (*idsIt).first ;
206  }
207  }
208  }
209  return maxHit ;
210 }
211 
212 
213 void
215 {
216 
217  for (EcalRecHitCollection::const_iterator elem = recHits->begin () ;
218  elem != recHits->end () ;
219  ++elem)
220  {
221  EBDetId elementId = elem->id () ;
223  elementId.ieta () - eta ,
224  elementId.iphi () - phi ,
225  elem->energy ()
226  ) ;
227  }
228  return ;
229 }
230 
231 
232 // ----------------------------------------------------------------
233 
234 
235 void
237 {
238  for (EcalRecHitCollection::const_iterator elem = recHits->begin () ;
239  elem != recHits->end () ;
240  ++elem)
241  {
242  EEDetId elementId = elem->id () ;
244  elementId.ix () - ics ,
245  elementId.iy () - ips ,
246  elem->energy ()
247  ) ;
248  }
249  return ;
250 }
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
void analyze(const edm::Event &e, const edm::EventSetup &c) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
MonitorElement * LocalOccupancyEE_
std::vector< EcalRecHit >::const_iterator const_iterator
std::string fileName_
Output file name if required.
~DQMSourceEleCalib() override
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
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
edm::EDGetTokenT< EcalRecHitCollection > productMonitoredEB_
object to monitor
MonitorElement * HitsVsAssociatedHits_
recHits over associated recHits
std::string folderName_
DQM folder name.
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
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:74
DQMSourceEleCalib(const edm::ParameterSet &)
void fillAroundEndcap(const EcalRecHitCollection *, int, int)
MonitorElement * recHitsPerElectron_
Number of recHits per electron.
def elem(elemtype, innerHTML='', html_class='', kwargs)
Definition: HTMLExport.py:18
const_iterator end() const
unsigned int prescaleFactor_
Monitor every prescaleFactor_ events.
T Max(T a, T b)
Definition: MathUtil.h:44
void fillAroundBarrel(const EcalRecHitCollection *, int, int)
fills local occupancy graphs
Definition: DetId.h:18
T const * product() const
Definition: Handle.h:81
MonitorElement * OccupancyEB_
Occupancy.
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
DetId findMaxHit(const std::vector< std::pair< DetId, float > > &, const EcalRecHitCollection *, const EcalRecHitCollection *)
find the MOX
iterator find(key_type k)
HLT enums.
size_type size() const
MonitorElement * ElectronsNumber_
Number of electrons.
const_iterator begin() const
Definition: Run.h:44
MonitorElement * LocalOccupancyEB_
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:39
edm::EDGetTokenT< reco::GsfElectronCollection > productMonitoredElectrons_
electrons to monitor