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 
17 
18 // DQM include files
19 
21 
22 // work on collections
25 
27 
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 
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 }
DQMSourceEleCalib::fileName_
std::string fileName_
Output file name if required.
Definition: DQMSourceEleCalib.h:78
DQMSourceEleCalib::findMaxHit
DetId findMaxHit(const std::vector< std::pair< DetId, float >> &, const EcalRecHitCollection *, const EcalRecHitCollection *)
find the MOX
Definition: DQMSourceEleCalib.cc:143
DQMSourceEleCalib::LocalOccupancyEE_
MonitorElement * LocalOccupancyEE_
Definition: DQMSourceEleCalib.h:55
DQMSourceEleCalib::ElectronsNumber_
MonitorElement * ElectronsNumber_
Number of electrons.
Definition: DQMSourceEleCalib.h:47
EBDetId::ieta
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
edm::SortedCollection< EcalRecHit >::const_iterator
std::vector< EcalRecHit >::const_iterator const_iterator
Definition: SortedCollection.h:80
MessageLogger.h
DQMSourceEleCalib::~DQMSourceEleCalib
~DQMSourceEleCalib() override
Definition: DQMSourceEleCalib.cc:48
edm::Handle::product
T const * product() const
Definition: Handle.h:70
edm::Run
Definition: Run.h:45
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
EBDetId
Definition: EBDetId.h:17
edm
HLT enums.
Definition: AlignableModifier.h:19
DQMSourceEleCalib::LocalOccupancyEB_
MonitorElement * LocalOccupancyEB_
Definition: DQMSourceEleCalib.h:54
DQMSourceEleCalib::productMonitoredEE_
edm::EDGetTokenT< EcalRecHitCollection > productMonitoredEE_
object to monitor
Definition: DQMSourceEleCalib.h:64
EBDetId.h
EEDetId.h
DQMSourceEleCalib::OccupancyEEM_
MonitorElement * OccupancyEEM_
Definition: DQMSourceEleCalib.h:53
DQMSourceEleCalib::saveToFile_
bool saveToFile_
Write to file.
Definition: DQMSourceEleCalib.h:75
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
edm::SortedCollection< EcalRecHit >
DQMStore.h
edm::SortedCollection::size
size_type size() const
Definition: SortedCollection.h:215
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
DQMSourceEleCalib::productMonitoredEB_
edm::EDGetTokenT< EcalRecHitCollection > productMonitoredEB_
object to monitor
Definition: DQMSourceEleCalib.h:61
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
DQMSourceEleCalib::HitsVsAssociatedHits_
MonitorElement * HitsVsAssociatedHits_
recHits over associated recHits
Definition: DQMSourceEleCalib.h:58
EEDetId::ix
int ix() const
Definition: EEDetId.h:77
edm::Handle
Definition: AssociativeIterator.h:50
DQMSourceEleCalib::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: DQMSourceEleCalib.cc:51
EcalBarrel
Definition: EcalSubdetector.h:10
DQMSourceEleCalib::analyze
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Definition: DQMSourceEleCalib.cc:73
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
DetId
Definition: DetId.h:17
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
Service.h
PVValHelper::eta
Definition: PVValidationHelpers.h:70
DQMSourceEleCalib::eventCounter_
int eventCounter_
Definition: DQMSourceEleCalib.h:42
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
DQMSourceEleCalib::recHitsPerElectron_
MonitorElement * recHitsPerElectron_
Number of recHits per electron.
Definition: DQMSourceEleCalib.h:45
DQMSourceEleCalib::OccupancyEB_
MonitorElement * OccupancyEB_
Occupancy.
Definition: DQMSourceEleCalib.h:51
EcalRecHit.h
MTVHistoProducerAlgoForTrackerBlock_cfi.maxHit
maxHit
Definition: MTVHistoProducerAlgoForTrackerBlock_cfi.py:37
EEDetId
Definition: EEDetId.h:14
EcalEndcap
Definition: EcalSubdetector.h:10
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
PVValHelper::phi
Definition: PVValidationHelpers.h:69
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
iEvent
int iEvent
Definition: GenABIO.cc:224
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
Max
T Max(T a, T b)
Definition: MathUtil.h:44
edm::EventSetup
Definition: EventSetup.h:58
EEDetId::iy
int iy() const
Definition: EEDetId.h:83
DDAxes::phi
edm::SortedCollection::find
iterator find(key_type k)
Definition: SortedCollection.h:240
DQMSourceEleCalib::productMonitoredElectrons_
edm::EDGetTokenT< reco::GsfElectronCollection > productMonitoredElectrons_
electrons to monitor
Definition: DQMSourceEleCalib.h:66
DQMSourceEleCalib::folderName_
std::string folderName_
DQM folder name.
Definition: DQMSourceEleCalib.h:72
std
Definition: JetResolutionObject.h:76
DQMSourceEleCalib::DQMSourceEleCalib
DQMSourceEleCalib(const edm::ParameterSet &)
Definition: DQMSourceEleCalib.cc:37
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
DQMSourceEleCalib::fillAroundEndcap
void fillAroundEndcap(const EcalRecHitCollection *, int, int)
Definition: DQMSourceEleCalib.cc:189
dqm::implementation::IBooker::book2D
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:177
DQMSourceEleCalib::prescaleFactor_
unsigned int prescaleFactor_
Monitor every prescaleFactor_ events.
Definition: DQMSourceEleCalib.h:69
DQMSourceEleCalib::OccupancyEEP_
MonitorElement * OccupancyEEP_
Definition: DQMSourceEleCalib.h:52
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
DQMSourceEleCalib::ESCoP_
MonitorElement * ESCoP_
ESCoP.
Definition: DQMSourceEleCalib.h:49
Ecal07UnpackerData_cfi.ics
ics
Definition: Ecal07UnpackerData_cfi.py:55
dqm::implementation::IBooker
Definition: DQMStore.h:43
DQMSourceEleCalib::fillAroundBarrel
void fillAroundBarrel(const EcalRecHitCollection *, int, int)
fills local occupancy graphs
Definition: DQMSourceEleCalib.cc:179
EBDetId::iphi
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
ParameterSet.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
DQMSourceEleCalib.h
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98