CMS 3D CMS Logo

SiPixelRecHitSource.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiPixelMonitorRecHits
4 // Class: SiPixelRecHitSource
5 //
14 //
15 // Original Author: Vincenzo Chiochia
16 // Created:
17 //
18 //
19 // Adapted by: Keith Rose
20 // For use in SiPixelMonitorClient for RecHits
21 // Updated by: Lukas Wehrli
22 // for pixel offline DQM
23 
25 // Framework
28 // DQM Framework
31 // Geometry
36 // DataFormats
43 
44 //
45 #include <cstdlib>
46 #include <iostream>
47 #include <string>
48 using namespace std;
49 using namespace edm;
50 
52  : conf_(iConfig),
53  src_(consumes<SiPixelRecHitCollection>(conf_.getParameter<edm::InputTag>("src"))),
54  saveFile(conf_.getUntrackedParameter<bool>("saveFile", false)),
55  isPIB(conf_.getUntrackedParameter<bool>("isPIB", false)),
56  slowDown(conf_.getUntrackedParameter<bool>("slowDown", false)),
57  modOn(conf_.getUntrackedParameter<bool>("modOn", true)),
58  twoDimOn(conf_.getUntrackedParameter<bool>("twoDimOn", true)),
59  reducedSet(conf_.getUntrackedParameter<bool>("reducedSet", false)),
60  ladOn(conf_.getUntrackedParameter<bool>("ladOn", false)),
61  layOn(conf_.getUntrackedParameter<bool>("layOn", false)),
62  phiOn(conf_.getUntrackedParameter<bool>("phiOn", false)),
63  ringOn(conf_.getUntrackedParameter<bool>("ringOn", false)),
64  bladeOn(conf_.getUntrackedParameter<bool>("bladeOn", false)),
65  diskOn(conf_.getUntrackedParameter<bool>("diskOn", false)),
66  isUpgrade(conf_.getUntrackedParameter<bool>("isUpgrade", false)) {
67  firstRun = true;
68  LogInfo("PixelDQM") << "SiPixelRecHitSource::SiPixelRecHitSource: Got DQM BackEnd interface" << endl;
69  topFolderName_ = conf_.getParameter<std::string>("TopFolderName");
70 }
71 
73  // do anything here that needs to be done at desctruction time
74  // (e.g. close files, deallocate resources etc.)
75  LogInfo("PixelDQM") << "SiPixelRecHitSource::~SiPixelRecHitSource: Destructor" << endl;
76  std::map<uint32_t, SiPixelRecHitModule *>::iterator struct_iter;
77  for (struct_iter = thePixelStructure.begin(); struct_iter != thePixelStructure.end(); struct_iter++) {
78  delete struct_iter->second;
79  struct_iter->second = nullptr;
80  }
81 }
82 
84  LogInfo("PixelDQM") << " SiPixelRecHitSource::beginJob - Initialisation ... " << std::endl;
85  LogInfo("PixelDQM") << "Mod/Lad/Lay/Phi " << modOn << "/" << ladOn << "/" << layOn << "/" << phiOn << std::endl;
86  LogInfo("PixelDQM") << "Blade/Disk/Ring" << bladeOn << "/" << diskOn << "/" << ringOn << std::endl;
87  LogInfo("PixelDQM") << "2DIM IS " << twoDimOn << "\n";
88 
89  if (firstRun) {
90  eventNo = 0;
91  // Build map
92  buildStructure(iSetup);
93  // Book Monitoring Elements
94  firstRun = false;
95  }
96 }
97 
99  bookMEs(iBooker, iSetup);
100 }
101 
102 //------------------------------------------------------------------
103 // Method called for every event
104 //------------------------------------------------------------------
106  eventNo++;
107  // cout << eventNo << endl;
108  // get input data
110  iEvent.getByToken(src_, recHitColl);
111 
112  std::map<uint32_t, SiPixelRecHitModule *>::iterator struct_iter;
113  for (struct_iter = thePixelStructure.begin(); struct_iter != thePixelStructure.end(); struct_iter++) {
114  uint32_t TheID = (*struct_iter).first;
115 
117 
118  // if( pixelrechitRangeIteratorBegin == pixelrechitRangeIteratorEnd) {cout
119  // << "oops" << endl;}
120  float rechit_x = 0;
121  float rechit_y = 0;
122  int rechit_count = 0;
123 
124  if (match != recHitColl->end()) {
125  SiPixelRecHitCollection::DetSet pixelrechitRange = *match;
126  SiPixelRecHitCollection::DetSet::const_iterator pixelrechitRangeIteratorBegin = pixelrechitRange.begin();
127  SiPixelRecHitCollection::DetSet::const_iterator pixelrechitRangeIteratorEnd = pixelrechitRange.end();
128  SiPixelRecHitCollection::DetSet::const_iterator pixeliter = pixelrechitRangeIteratorBegin;
129 
130  for (; pixeliter != pixelrechitRangeIteratorEnd; pixeliter++) {
131  rechit_count++;
132  // cout << TheID << endl;
133  SiPixelRecHit::ClusterRef const &clust = pixeliter->cluster();
134  int sizeX = (*clust).sizeX();
135  // cout << sizeX << endl;
136  int sizeY = (*clust).sizeY();
137  // cout << sizeY << endl;
138  LocalPoint lp = pixeliter->localPosition();
139  rechit_x = lp.x();
140  rechit_y = lp.y();
141 
142  LocalError lerr = pixeliter->localPositionError();
143  float lerr_x = sqrt(lerr.xx());
144  float lerr_y = sqrt(lerr.yy());
145  // std::cout << "errors " << lerr_x << " " << lerr_y << std::endl;
146  (*struct_iter)
147  .second->fill(rechit_x,
148  rechit_y,
149  sizeX,
150  sizeY,
151  lerr_x,
152  lerr_y,
153  modOn,
154  ladOn,
155  layOn,
156  phiOn,
157  bladeOn,
158  diskOn,
159  ringOn,
160  twoDimOn,
161  reducedSet);
162  }
163  }
164  if (rechit_count > 0)
165  (*struct_iter).second->nfill(rechit_count, modOn, ladOn, layOn, phiOn, bladeOn, diskOn, ringOn);
166  }
167 
168  // slow down...
169  if (slowDown)
170  usleep(10000);
171 }
172 
173 //------------------------------------------------------------------
174 // Build data structure
175 //------------------------------------------------------------------
177  LogInfo("PixelDQM") << " SiPixelRecHitSource::buildStructure";
178 
180  edm::ESHandle<TrackerTopology> tTopoHandle;
181 
182  iSetup.get<TrackerDigiGeometryRecord>().get(pDD);
183  iSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
184 
185  const TrackerTopology *pTT = tTopoHandle.product();
186 
187  LogVerbatim("PixelDQM") << " *** Geometry node for TrackerGeom is " << &(*pDD) << std::endl;
188  LogVerbatim("PixelDQM") << " *** I have " << pDD->dets().size() << " detectors" << std::endl;
189  LogVerbatim("PixelDQM") << " *** I have " << pDD->detTypes().size() << " types" << std::endl;
190 
191  for (TrackerGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++) {
192  if (dynamic_cast<PixelGeomDetUnit const *>((*it)) != nullptr) {
193  DetId detId = (*it)->geographicalId();
194 
195  if ((detId.subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) ||
196  (detId.subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap))) {
197  uint32_t id = detId();
198 
199  if (detId.subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) {
200  if (isPIB)
201  continue;
202  LogDebug("PixelDQM") << " ---> Adding Barrel Module " << detId.rawId() << endl;
203  SiPixelRecHitModule *theModule = new SiPixelRecHitModule(id);
204  thePixelStructure.insert(pair<uint32_t, SiPixelRecHitModule *>(id, theModule));
205 
206  } else if ((detId.subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap))) {
207  LogDebug("PixelDQM") << " ---> Adding Endcap Module " << detId.rawId() << endl;
208 
210  int disk = PixelEndcapName(DetId(id), pTT, isUpgrade).diskName();
211  int blade = PixelEndcapName(DetId(id), pTT, isUpgrade).bladeName();
212  int panel = PixelEndcapName(DetId(id), pTT, isUpgrade).pannelName();
214 
215  char sside[80];
216  sprintf(sside, "HalfCylinder_%i", side);
217  char sdisk[80];
218  sprintf(sdisk, "Disk_%i", disk);
219  char sblade[80];
220  sprintf(sblade, "Blade_%02i", blade);
221  char spanel[80];
222  sprintf(spanel, "Panel_%i", panel);
223  char smodule[80];
224  sprintf(smodule, "Module_%i", module);
225  std::string side_str = sside;
226  std::string disk_str = sdisk;
227  bool mask = side_str.find("HalfCylinder_1") != string::npos ||
228  side_str.find("HalfCylinder_2") != string::npos ||
229  side_str.find("HalfCylinder_4") != string::npos || disk_str.find("Disk_2") != string::npos;
230  if (isPIB && mask)
231  continue;
232 
233  SiPixelRecHitModule *theModule = new SiPixelRecHitModule(id);
234  thePixelStructure.insert(pair<uint32_t, SiPixelRecHitModule *>(id, theModule));
235  }
236  }
237  }
238  } // FOR_LOOP
239 
240  LogInfo("PixelDQM") << " *** Pixel Structure Size " << thePixelStructure.size() << endl;
241 }
242 //------------------------------------------------------------------
243 // Book MEs
244 //------------------------------------------------------------------
246  std::map<uint32_t, SiPixelRecHitModule *>::iterator struct_iter;
247 
248  SiPixelFolderOrganizer theSiPixelFolder(false);
249 
250  for (struct_iter = thePixelStructure.begin(); struct_iter != thePixelStructure.end(); struct_iter++) {
252  if (modOn) {
253  if (theSiPixelFolder.setModuleFolder(iBooker, (*struct_iter).first, 0, isUpgrade)) {
254  (*struct_iter).second->book(conf_, iBooker, iSetup, 0, twoDimOn, reducedSet, isUpgrade);
255  } else {
256  if (!isPIB)
257  throw cms::Exception("LogicError") << "[SiPixelDigiSource::bookMEs] Creation of DQM folder failed";
258  }
259  }
260  if (ladOn) {
261  if (theSiPixelFolder.setModuleFolder(iBooker, (*struct_iter).first, 1, isUpgrade)) {
262  (*struct_iter).second->book(conf_, iBooker, iSetup, 1, twoDimOn, reducedSet, isUpgrade);
263  } else {
264  LogDebug("PixelDQM") << "PROBLEM WITH LADDER-FOLDER\n";
265  }
266  }
267  if (layOn) {
268  if (theSiPixelFolder.setModuleFolder(iBooker, (*struct_iter).first, 2, isUpgrade)) {
269  (*struct_iter).second->book(conf_, iBooker, iSetup, 2, twoDimOn, reducedSet, isUpgrade);
270  } else {
271  LogDebug("PixelDQM") << "PROBLEM WITH LAYER-FOLDER\n";
272  }
273  }
274  if (phiOn) {
275  if (theSiPixelFolder.setModuleFolder(iBooker, (*struct_iter).first, 3, isUpgrade)) {
276  (*struct_iter).second->book(conf_, iBooker, iSetup, 3, twoDimOn, reducedSet, isUpgrade);
277  } else {
278  LogDebug("PixelDQM") << "PROBLEM WITH PHI-FOLDER\n";
279  }
280  }
281  if (bladeOn) {
282  if (theSiPixelFolder.setModuleFolder(iBooker, (*struct_iter).first, 4, isUpgrade)) {
283  (*struct_iter).second->book(conf_, iBooker, iSetup, 4, twoDimOn, reducedSet, isUpgrade);
284  } else {
285  LogDebug("PixelDQM") << "PROBLEM WITH BLADE-FOLDER\n";
286  }
287  }
288  if (diskOn) {
289  if (theSiPixelFolder.setModuleFolder(iBooker, (*struct_iter).first, 5, isUpgrade)) {
290  (*struct_iter).second->book(conf_, iBooker, iSetup, 5, twoDimOn, reducedSet, isUpgrade);
291  } else {
292  LogDebug("PixelDQM") << "PROBLEM WITH DISK-FOLDER\n";
293  }
294  }
295  if (ringOn) {
296  if (theSiPixelFolder.setModuleFolder(iBooker, (*struct_iter).first, 6, isUpgrade)) {
297  (*struct_iter).second->book(conf_, iBooker, iSetup, 6, twoDimOn, reducedSet, isUpgrade);
298  } else {
299  LogDebug("PixelDQM") << "PROBLEM WITH RING-FOLDER\n";
300  }
301  }
302  }
303 }
304 
305 // define this as a plug-in
SiPixelRecHitSource::isUpgrade
bool isUpgrade
Definition: SiPixelRecHitSource.h:86
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
SiPixelRecHitSource::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: SiPixelRecHitSource.cc:105
SiPixelRecHitSource::firstRun
bool firstRun
Definition: SiPixelRecHitSource.h:85
electrons_cff.bool
bool
Definition: electrons_cff.py:372
PixelSubdetector.h
PixelBarrelName.h
MessageLogger.h
funct::false
false
Definition: Factorize.h:34
PixelSubdetector::PixelEndcap
Definition: PixelSubdetector.h:11
TrackerGeometry.h
PixelSubdetector::PixelBarrel
Definition: PixelSubdetector.h:11
SiPixelRecHitSource::isPIB
bool isPIB
Definition: SiPixelRecHitSource.h:72
SiPixelRecHitModule
Definition: SiPixelRecHitModule.h:34
SiPixelFolderOrganizer::setModuleFolder
bool setModuleFolder(const uint32_t &rawdetid=0, int type=0, bool isUpgrade=false)
Set folder name for a module or plaquette.
Definition: SiPixelFolderOrganizer.cc:27
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
SiPixelOfflineDQM_source_cff.reducedSet
reducedSet
Definition: SiPixelOfflineDQM_source_cff.py:8
SiPixelRecHitSource::diskOn
bool diskOn
Definition: SiPixelRecHitSource.h:83
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
TrackerTopology
Definition: TrackerTopology.h:16
edm::LogInfo
Definition: MessageLogger.h:254
SiPixelRecHitSource
Definition: SiPixelRecHitSource.h:51
edmNew::DetSetVector::const_iterator
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
Definition: DetSetVectorNew.h:231
SiPixelRecHitSource::bladeOn
bool bladeOn
Definition: SiPixelRecHitSource.h:83
DQMStore.h
TrackerGeometry::detTypes
const DetTypeContainer & detTypes() const override
Return a vector of all det types.
Definition: TrackerGeometry.h:60
PixelEndcapName::halfCylinder
HalfCylinder halfCylinder() const
Definition: PixelEndcapName.h:42
fed_dqm_sourceclient-live_cfg.saveFile
saveFile
Definition: fed_dqm_sourceclient-live_cfg.py:54
SiPixelRecHitSource::dqmBeginRun
void dqmBeginRun(const edm::Run &, edm::EventSetup const &) override
Definition: SiPixelRecHitSource.cc:83
SiPixelRecHitSource::modOn
bool modOn
Definition: SiPixelRecHitSource.h:77
PixelEndcapName::pannelName
int pannelName() const
pannel id
Definition: PixelEndcapName.h:51
edm::Handle
Definition: AssociativeIterator.h:50
SiPixelRecHitSource::SiPixelRecHitSource
SiPixelRecHitSource(const edm::ParameterSet &conf)
Definition: SiPixelRecHitSource.cc:51
SiPixelOfflineDQM_source_cff.phiOn
phiOn
Definition: SiPixelOfflineDQM_source_cff.py:48
PixelEndcapName::bladeName
int bladeName() const
blade id
Definition: PixelEndcapName.h:48
edm::Ref
Definition: AssociativeIterator.h:58
SiPixelOfflineDQM_source_cff.ladOn
ladOn
Definition: SiPixelOfflineDQM_source_cff.py:37
DetId
Definition: DetId.h:17
edmNew::DetSet::end
iterator end()
Definition: DetSetNew.h:56
edmNew::DetSetVector::find
const_iterator find(id_type i, bool update=false) const
Definition: DetSetVectorNew.h:560
TrackerTopologyRcd.h
PixelEndcapName
Definition: PixelEndcapName.h:16
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
SiPixelRecHitSource::twoDimOn
bool twoDimOn
Definition: SiPixelRecHitSource.h:78
SiPixelOfflineDQM_source_cff.bladeOn
bladeOn
Definition: SiPixelOfflineDQM_source_cff.py:38
LocalError::xx
float xx() const
Definition: LocalError.h:22
Service.h
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
SiPixelOfflineDQM_source_cff.ringOn
ringOn
Definition: SiPixelOfflineDQM_source_cff.py:51
SiPixelRecHitSource::thePixelStructure
std::map< uint32_t, SiPixelRecHitModule * > thePixelStructure
Definition: SiPixelRecHitSource.h:75
edm::ESHandle< TrackerGeometry >
edmNew::DetSet
Definition: DetSetNew.h:22
RecoTauValidation_cfi.sizeY
sizeY
Definition: RecoTauValidation_cfi.py:291
SiPixelRecHitSource::layOn
bool layOn
Definition: SiPixelRecHitSource.h:81
SiPixelOfflineDQM_source_cff.modOn
modOn
online/offline RawDataErrors
Definition: SiPixelOfflineDQM_source_cff.py:36
Point3DBase< float, LocalTag >
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SiPixelRecHitSource::phiOn
bool phiOn
Definition: SiPixelRecHitSource.h:81
funct::true
true
Definition: Factorize.h:173
SiPixelRecHitSource::~SiPixelRecHitSource
~SiPixelRecHitSource() override
Definition: SiPixelRecHitSource.cc:72
SiPixelOfflineDQM_source_cff.twoDimOn
twoDimOn
Definition: SiPixelOfflineDQM_source_cff.py:41
TrackerDigiGeometryRecord.h
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
SiPixelRecHitSource.h
RecoTauValidation_cfi.sizeX
sizeX
Definition: RecoTauValidation_cfi.py:290
SiPixelRecHitSource::bookMEs
virtual void bookMEs(DQMStore::IBooker &, const edm::EventSetup &iSetup)
Definition: SiPixelRecHitSource.cc:245
LocalError
Definition: LocalError.h:12
SiPixelRecHitSource::topFolderName_
std::string topFolderName_
Definition: SiPixelRecHitSource.h:65
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
SiPixelRecHitSource::eventNo
int eventNo
Definition: SiPixelRecHitSource.h:74
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
iEvent
int iEvent
Definition: GenABIO.cc:224
SiPixelRecHitSource::src_
edm::EDGetTokenT< SiPixelRecHitCollection > src_
Definition: SiPixelRecHitSource.h:69
edm::LogVerbatim
Definition: MessageLogger.h:297
SiPixelOfflineDQM_source_cff.isPIB
isPIB
Definition: SiPixelOfflineDQM_source_cff.py:6
SiPixelRecHitSource::ladOn
bool ladOn
Definition: SiPixelRecHitSource.h:81
edmNew::DetSet::begin
iterator begin()
Definition: DetSetNew.h:54
edm::EventSetup
Definition: EventSetup.h:57
TrackerGeometry::dets
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
Definition: TrackerGeometry.h:62
module
Definition: vlib.h:198
get
#define get
SiPixelOfflineDQM_source_cff.layOn
layOn
Definition: SiPixelOfflineDQM_source_cff.py:47
SiPixelRecHitSource::rechit_count
std::map< uint32_t, int > rechit_count
Definition: SiPixelRecHitSource.h:76
alignCSCRings.r
r
Definition: alignCSCRings.py:93
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
fed_dqm_sourceclient-live_cfg.slowDown
slowDown
Definition: fed_dqm_sourceclient-live_cfg.py:55
edmNew::DetSetVector
Definition: DetSetNew.h:13
std
Definition: JetResolutionObject.h:76
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
SiPixelRecHitSource::slowDown
bool slowDown
Definition: SiPixelRecHitSource.h:73
PixelEndcapName::HalfCylinder
HalfCylinder
Definition: PixelEndcapName.h:18
PixelEndcapName::diskName
int diskName() const
disk id
Definition: PixelEndcapName.h:45
SiPixelRecHitSource::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, const edm::EventSetup &) override
Definition: SiPixelRecHitSource.cc:98
DetId.h
edmNew::DetSetVector::end
const_iterator end(bool update=false) const
Definition: DetSetVectorNew.h:577
SiPixelRecHitSource::buildStructure
virtual void buildStructure(edm::EventSetup const &)
Definition: SiPixelRecHitSource.cc:176
Exception
Definition: hltDiff.cc:246
SiPixelFolderOrganizer
Definition: SiPixelFolderOrganizer.h:26
SiPixelRecHitSource::conf_
edm::ParameterSet conf_
Definition: SiPixelRecHitSource.h:68
PixelGeomDetUnit.h
SiPixelRecHitSource::ringOn
bool ringOn
Definition: SiPixelRecHitSource.h:83
PixelEndcapNameUpgrade.h
dqm::implementation::IBooker
Definition: DQMStore.h:43
SiPixelOfflineDQM_source_cff.diskOn
diskOn
Definition: SiPixelOfflineDQM_source_cff.py:50
SiPixelRecHitSource::reducedSet
bool reducedSet
Definition: SiPixelRecHitSource.h:79
SiPixelFolderOrganizer.h
PixelEndcapName::plaquetteName
int plaquetteName() const
plaquetteId (in pannel)
Definition: PixelEndcapName.h:54
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
SiPixelOfflineDQM_client_cff.isUpgrade
isUpgrade
Definition: SiPixelOfflineDQM_client_cff.py:19
PixelBarrelNameUpgrade.h
edm::Event
Definition: Event.h:73
LocalError::yy
float yy() const
Definition: LocalError.h:24
edm::InputTag
Definition: InputTag.h:15
PixelEndcapName.h