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