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 
19 
20 // DQM include files
21 
24 
25 // work on collections
33 
35 public:
37  ~DQMSourceEleCalib() override;
38 
39 protected:
40  void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
41 
42  void analyze(const edm::Event &e, const edm::EventSetup &c) override;
43 
44 private:
46  DetId findMaxHit(const std::vector<std::pair<DetId, float>> &,
47  const EcalRecHitCollection *,
48  const EcalRecHitCollection *);
50  void fillAroundBarrel(const EcalRecHitCollection *, int, int);
51  void fillAroundEndcap(const EcalRecHitCollection *, int, int);
52 
54 
67 
70 
73 
78 
80  unsigned int prescaleFactor_;
81 
84 
87 
90 };
91 
92 // ******************************************
93 // constructors
94 // *****************************************
95 
97  folderName_ = ps.getUntrackedParameter<std::string>("FolderName", "ALCAStreamEcalSingleEle");
98  productMonitoredEB_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("AlCaStreamEBTag"));
99  productMonitoredEE_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("AlCaStreamEETag"));
100 
101  saveToFile_ = ps.getUntrackedParameter<bool>("SaveToFile", false);
102  fileName_ = ps.getUntrackedParameter<std::string>("FileName", "MonitorAlCaEcalSingleEle.root");
104  consumes<reco::GsfElectronCollection>(ps.getParameter<edm::InputTag>("electronCollection"));
105  prescaleFactor_ = ps.getUntrackedParameter<unsigned int>("prescaleFactor", 1);
106 }
107 
109 
110 //--------------------------------------------------------
112  edm::Run const &irun,
113  edm::EventSetup const &isetup) {
114  // create and cd into new folder
115  ibooker.setCurrentFolder(folderName_);
116 
117  recHitsPerElectron_ = ibooker.book1D("recHitsPerElectron_", "recHitPerElectron", 200, 0, 200);
118  ElectronsNumber_ = ibooker.book1D("ElectronsNumber_", "electrons in the event", 40, 0, 40);
119  ESCoP_ = ibooker.book1D("ESCoP", "ESCoP", 50, 0, 5);
120 
121  OccupancyEB_ = ibooker.book2D("OccupancyEB_", "OccupancyEB", 360, 1, 361, 171, -85, 86);
122  OccupancyEEP_ = ibooker.book2D("OccupancyEEP_", "Occupancy EE Plus", 100, 1, 101, 100, 1, 101);
123  OccupancyEEM_ = ibooker.book2D("OccupancyEEM_", "Occupancy EE Minus", 100, 1, 101, 100, 1, 101);
124  HitsVsAssociatedHits_ = ibooker.book1D("HitsVsAssociatedHits_", "HitsVsAssociatedHits", 100, 0, 5);
125  LocalOccupancyEB_ = ibooker.book2D("LocalOccupancyEB_", "Local occupancy Barrel", 9, -4, 5, 9, -4, 5);
126  LocalOccupancyEE_ = ibooker.book2D("LocalOccupancyEE_", "Local occupancy Endcap", 9, -4, 5, 9, -4, 5);
127 }
128 
129 //--------------------------------------------------------
130 
131 //-------------------------------------------------------------
132 
134  // if (eventCounter_% prescaleFactor_ ) return; //FIXME
135  eventCounter_++;
136  int numberOfHits = 0;
137  int numberOfElectrons = 0;
138  int numberOfAssociatedHits = 0;
139  // reads the recHits
142 
143  iEvent.getByToken(productMonitoredEB_, rhEB);
144  iEvent.getByToken(productMonitoredEE_, rhEE);
145 
147 
148  // reads the electrons
150  iEvent.getByToken(productMonitoredElectrons_, pElectrons);
151 
152  if (pElectrons.isValid()) {
153  ElectronsNumber_->Fill(pElectrons->size() + 0.1);
154  numberOfElectrons = pElectrons->size();
155  for (reco::GsfElectronCollection::const_iterator eleIt = pElectrons->begin(); eleIt != pElectrons->end(); ++eleIt) {
156  ESCoP_->Fill(eleIt->eSuperClusterOverP());
157  numberOfAssociatedHits += eleIt->superCluster()->size();
158  DetId Max = findMaxHit(eleIt->superCluster()->hitsAndFractions(), rhEB.product(), rhEE.product());
159  if (!Max.det())
160  continue;
161  if (Max.subdetId() == EcalBarrel) {
162  EBDetId EBMax(Max);
163  fillAroundBarrel(rhEB.product(), EBMax.ieta(), EBMax.iphi());
164  }
165  if (Max.subdetId() == EcalEndcap) {
166  EEDetId EEMax(Max);
167  fillAroundEndcap(rhEE.product(), EEMax.ix(), EEMax.iy());
168  }
169  }
170  } // is valid electron
171 
172  // fill EB histos
173  if (rhEB.isValid()) {
174  numberOfHits += rhEB->size();
175  for (itb = rhEB->begin(); itb != rhEB->end(); ++itb) {
176  EBDetId id(itb->id());
177  OccupancyEB_->Fill(id.iphi(), id.ieta());
178  } // Eb rechits
179  } // is Valid
180  if (rhEE.isValid()) {
181  numberOfHits += rhEE->size();
182  for (itb = rhEE->begin(); itb != rhEE->end(); ++itb) {
183  EEDetId id(itb->id());
184  if (id.zside() > 0) {
185  OccupancyEEP_->Fill(id.ix(), id.iy());
186  } // zside>0
187  else if (id.zside() < 0) {
188  OccupancyEEM_->Fill(id.ix(), id.iy());
189  } // zside<0
190 
191  } // EE reChit
192  } // is Valid
193  if (numberOfElectrons)
194  recHitsPerElectron_->Fill((double)numberOfHits / ((double)numberOfElectrons));
195  if (numberOfHits)
196  HitsVsAssociatedHits_->Fill((double)numberOfAssociatedHits / ((double)numberOfHits));
197 } // end of the analyzer
198 
199 //--------------------------------------------------------
200 
201 //------------------------------------------------
202 
203 DetId DQMSourceEleCalib::findMaxHit(const std::vector<std::pair<DetId, float>> &v1,
204  const EcalRecHitCollection *EBhits,
205  const EcalRecHitCollection *EEhits) {
206  double currEnergy = 0.;
207  DetId maxHit;
208  for (std::vector<std::pair<DetId, float>>::const_iterator idsIt = v1.begin(); idsIt != v1.end(); ++idsIt) {
209  if (idsIt->first.subdetId() == EcalBarrel) {
211  itrechit = EBhits->find((*idsIt).first);
212  if (itrechit == EBhits->end()) {
213  edm::LogInfo("reading") << "[findMaxHit] rechit not found! ";
214  continue;
215  }
216  // FIXME: wnat to use the fraction i.e. .second??
217  if (itrechit->energy() > currEnergy) {
218  currEnergy = itrechit->energy();
219  maxHit = (*idsIt).first;
220  }
221  } else {
223  itrechit = EEhits->find((*idsIt).first);
224  if (itrechit == EEhits->end()) {
225  edm::LogInfo("reading") << "[findMaxHit] rechit not found! ";
226  continue;
227  }
228 
229  // FIXME: wnat to use the fraction i.e. .second??
230  if (itrechit->energy() > currEnergy) {
231  currEnergy = itrechit->energy();
232  maxHit = (*idsIt).first;
233  }
234  }
235  }
236  return maxHit;
237 }
238 
240  for (EcalRecHitCollection::const_iterator elem = recHits->begin(); elem != recHits->end(); ++elem) {
241  EBDetId elementId = elem->id();
242  LocalOccupancyEB_->Fill(elementId.ieta() - eta, elementId.iphi() - phi, elem->energy());
243  }
244  return;
245 }
246 
247 // ----------------------------------------------------------------
248 
250  for (EcalRecHitCollection::const_iterator elem = recHits->begin(); elem != recHits->end(); ++elem) {
251  EEDetId elementId = elem->id();
252  LocalOccupancyEE_->Fill(elementId.ix() - ics, elementId.iy() - ips, elem->energy());
253  }
254  return;
255 }
256 
MonitorElement * ESCoP_
ESCoP.
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
void analyze(const edm::Event &e, const edm::EventSetup &c) override
size_type size() const
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
T const * product() const
Definition: Handle.h:70
int ix() const
Definition: EEDetId.h:77
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
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
T getUntrackedParameter(std::string const &, T const &) const
void Fill(long long x)
MonitorElement * OccupancyEEM_
bool saveToFile_
Write to file.
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< EcalRecHitCollection > productMonitoredEB_
object to monitor
MonitorElement * HitsVsAssociatedHits_
recHits over associated recHits
std::string folderName_
DQM folder name.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const_iterator begin() const
MonitorElement * OccupancyEEP_
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.
Log< level::Info, false > LogInfo
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t ix(uint32_t id)
void fillAroundBarrel(const EcalRecHitCollection *, int, int)
fills local occupancy graphs
Definition: DetId.h:17
MonitorElement * OccupancyEB_
Occupancy.
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
bool isValid() const
Definition: HandleBase.h:70
iterator find(key_type k)
MonitorElement * ElectronsNumber_
Number of electrons.
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t iy(uint32_t id)
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
Definition: Run.h:45
int iy() const
Definition: EEDetId.h:83
MonitorElement * LocalOccupancyEB_
edm::EDGetTokenT< reco::GsfElectronCollection > productMonitoredElectrons_
electrons to monitor