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 
16 
17 // DQM include files
18 
20 
21 // work on collections
24 
26 
29 
30 using namespace std;
31 using namespace edm;
32 
33 // ******************************************
34 // constructors
35 // *****************************************
36 
38  folderName_ = ps.getUntrackedParameter<string>("FolderName", "ALCAStreamEcalSingleEle");
39  productMonitoredEB_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("AlCaStreamEBTag"));
40  productMonitoredEE_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("AlCaStreamEETag"));
41 
42  saveToFile_ = ps.getUntrackedParameter<bool>("SaveToFile", false);
43  fileName_ = ps.getUntrackedParameter<string>("FileName", "MonitorAlCaEcalSingleEle.root");
44  productMonitoredElectrons_ = consumes<reco::GsfElectronCollection>(ps.getParameter<InputTag>("electronCollection"));
45  prescaleFactor_ = ps.getUntrackedParameter<unsigned int>("prescaleFactor", 1);
46 }
47 
49 
50 //--------------------------------------------------------
52  edm::Run const &irun,
53  edm::EventSetup const &isetup) {
54  // create and cd into new folder
56 
57  recHitsPerElectron_ = ibooker.book1D("recHitsPerElectron_", "recHitPerElectron", 200, 0, 200);
58  ElectronsNumber_ = ibooker.book1D("ElectronsNumber_", "electrons in the event", 40, 0, 40);
59  ESCoP_ = ibooker.book1D("ESCoP", "ESCoP", 50, 0, 5);
60 
61  OccupancyEB_ = ibooker.book2D("OccupancyEB_", "OccupancyEB", 360, 1, 361, 171, -85, 86);
62  OccupancyEEP_ = ibooker.book2D("OccupancyEEP_", "Occupancy EE Plus", 100, 1, 101, 100, 1, 101);
63  OccupancyEEM_ = ibooker.book2D("OccupancyEEM_", "Occupancy EE Minus", 100, 1, 101, 100, 1, 101);
64  HitsVsAssociatedHits_ = ibooker.book1D("HitsVsAssociatedHits_", "HitsVsAssociatedHits", 100, 0, 5);
65  LocalOccupancyEB_ = ibooker.book2D("LocalOccupancyEB_", "Local occupancy Barrel", 9, -4, 5, 9, -4, 5);
66  LocalOccupancyEE_ = ibooker.book2D("LocalOccupancyEE_", "Local occupancy Endcap", 9, -4, 5, 9, -4, 5);
67 }
68 
69 //--------------------------------------------------------
70 
71 //-------------------------------------------------------------
72 
73 void DQMSourceEleCalib::analyze(const Event &iEvent, const EventSetup &iSetup) {
74  // if (eventCounter_% prescaleFactor_ ) return; //FIXME
75  eventCounter_++;
76  int numberOfHits = 0;
77  int numberOfElectrons = 0;
78  int numberOfAssociatedHits = 0;
79  // reads the recHits
82 
83  iEvent.getByToken(productMonitoredEB_, rhEB);
84  iEvent.getByToken(productMonitoredEE_, rhEE);
85 
87 
88  // reads the electrons
90  iEvent.getByToken(productMonitoredElectrons_, pElectrons);
91 
92  if (pElectrons.isValid()) {
93  ElectronsNumber_->Fill(pElectrons->size() + 0.1);
94  numberOfElectrons = pElectrons->size();
95  for (reco::GsfElectronCollection::const_iterator eleIt = pElectrons->begin(); eleIt != pElectrons->end(); ++eleIt) {
96  ESCoP_->Fill(eleIt->eSuperClusterOverP());
97  numberOfAssociatedHits += eleIt->superCluster()->size();
98  DetId Max = findMaxHit(eleIt->superCluster()->hitsAndFractions(), rhEB.product(), rhEE.product());
99  if (!Max.det())
100  continue;
101  if (Max.subdetId() == EcalBarrel) {
102  EBDetId EBMax(Max);
103  fillAroundBarrel(rhEB.product(), EBMax.ieta(), EBMax.iphi());
104  }
105  if (Max.subdetId() == EcalEndcap) {
106  EEDetId EEMax(Max);
107  fillAroundEndcap(rhEE.product(), EEMax.ix(), EEMax.iy());
108  }
109  }
110  } // is valid electron
111 
112  // fill EB histos
113  if (rhEB.isValid()) {
114  numberOfHits += rhEB->size();
115  for (itb = rhEB->begin(); itb != rhEB->end(); ++itb) {
116  EBDetId id(itb->id());
117  OccupancyEB_->Fill(id.iphi(), id.ieta());
118  } // Eb rechits
119  } // is Valid
120  if (rhEE.isValid()) {
121  numberOfHits += rhEE->size();
122  for (itb = rhEE->begin(); itb != rhEE->end(); ++itb) {
123  EEDetId id(itb->id());
124  if (id.zside() > 0) {
125  OccupancyEEP_->Fill(id.ix(), id.iy());
126  } // zside>0
127  else if (id.zside() < 0) {
128  OccupancyEEM_->Fill(id.ix(), id.iy());
129  } // zside<0
130 
131  } // EE reChit
132  } // is Valid
133  if (numberOfElectrons)
134  recHitsPerElectron_->Fill((double)numberOfHits / ((double)numberOfElectrons));
135  if (numberOfHits)
136  HitsVsAssociatedHits_->Fill((double)numberOfAssociatedHits / ((double)numberOfHits));
137 } // end of the analyzer
138 
139 //--------------------------------------------------------
140 
141 //------------------------------------------------
142 
143 DetId DQMSourceEleCalib::findMaxHit(const std::vector<std::pair<DetId, float>> &v1,
144  const EcalRecHitCollection *EBhits,
145  const EcalRecHitCollection *EEhits) {
146  double currEnergy = 0.;
147  DetId maxHit;
148  for (std::vector<std::pair<DetId, float>>::const_iterator idsIt = v1.begin(); idsIt != v1.end(); ++idsIt) {
149  if (idsIt->first.subdetId() == EcalBarrel) {
151  itrechit = EBhits->find((*idsIt).first);
152  if (itrechit == EBhits->end()) {
153  edm::LogInfo("reading") << "[findMaxHit] rechit not found! ";
154  continue;
155  }
156  // FIXME: wnat to use the fraction i.e. .second??
157  if (itrechit->energy() > currEnergy) {
158  currEnergy = itrechit->energy();
159  maxHit = (*idsIt).first;
160  }
161  } else {
163  itrechit = EEhits->find((*idsIt).first);
164  if (itrechit == EEhits->end()) {
165  edm::LogInfo("reading") << "[findMaxHit] rechit not found! ";
166  continue;
167  }
168 
169  // FIXME: wnat to use the fraction i.e. .second??
170  if (itrechit->energy() > currEnergy) {
171  currEnergy = itrechit->energy();
172  maxHit = (*idsIt).first;
173  }
174  }
175  }
176  return maxHit;
177 }
178 
180  for (EcalRecHitCollection::const_iterator elem = recHits->begin(); elem != recHits->end(); ++elem) {
181  EBDetId elementId = elem->id();
182  LocalOccupancyEB_->Fill(elementId.ieta() - eta, elementId.iphi() - phi, elem->energy());
183  }
184  return;
185 }
186 
187 // ----------------------------------------------------------------
188 
189 void DQMSourceEleCalib::fillAroundEndcap(const EcalRecHitCollection *recHits, int ics, int ips) {
190  for (EcalRecHitCollection::const_iterator elem = recHits->begin(); elem != recHits->end(); ++elem) {
191  EEDetId elementId = elem->id();
192  LocalOccupancyEE_->Fill(elementId.ix() - ics, elementId.iy() - ips, elem->energy());
193  }
194  return;
195 }
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:77
void analyze(const edm::Event &e, const edm::EventSetup &c) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
MonitorElement * LocalOccupancyEE_
DetId findMaxHit(const std::vector< std::pair< DetId, float >> &, const EcalRecHitCollection *, const EcalRecHitCollection *)
find the MOX
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
void Fill(long long x)
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
MonitorElement * OccupancyEEM_
bool saveToFile_
Write to file.
int iEvent
Definition: GenABIO.cc:224
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:83
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
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:19
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:74
MonitorElement * OccupancyEB_
Occupancy.
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
iterator find(key_type k)
HLT enums.
size_type size() const
MonitorElement * ElectronsNumber_
Number of electrons.
const_iterator begin() const
Definition: Run.h:45
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