CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiPixelClusterSource.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiPixelMonitorCluster
4 // Class: SiPixelClusterSource
5 //
13 //
14 // Original Author: Vincenzo Chiochia & Andrew York
15 // Created:
16 //
17 //
18 // Updated by: Lukas Wehrli
19 // for pixel offline DQM
21 // Framework
24 // DQM Framework
27 // Geometry
32 // DataFormats
39 //
40 #include <string>
41 #include <stdlib.h>
42 
43 using namespace std;
44 using namespace edm;
45 
47  conf_(iConfig),
48  src_( conf_.getParameter<edm::InputTag>( "src" ) ),
49  saveFile( conf_.getUntrackedParameter<bool>("saveFile",false) ),
50  isPIB( conf_.getUntrackedParameter<bool>("isPIB",false) ),
51  slowDown( conf_.getUntrackedParameter<bool>("slowDown",false) ),
52  modOn( conf_.getUntrackedParameter<bool>("modOn",true) ),
53  twoDimOn( conf_.getUntrackedParameter<bool>("twoDimOn",true) ),
54  reducedSet( conf_.getUntrackedParameter<bool>("reducedSet",false) ),
55  ladOn( conf_.getUntrackedParameter<bool>("ladOn",false) ),
56  layOn( conf_.getUntrackedParameter<bool>("layOn",false) ),
57  phiOn( conf_.getUntrackedParameter<bool>("phiOn",false) ),
58  ringOn( conf_.getUntrackedParameter<bool>("ringOn",false) ),
59  bladeOn( conf_.getUntrackedParameter<bool>("bladeOn",false) ),
60  diskOn( conf_.getUntrackedParameter<bool>("diskOn",false) ),
61  smileyOn(conf_.getUntrackedParameter<bool>("smileyOn",false) ),
62  bigEventSize( conf_.getUntrackedParameter<int>("bigEventSize",100) ),
63  isUpgrade( conf_.getUntrackedParameter<bool>("isUpgrade",false) )
64 {
65  LogInfo ("PixelDQM") << "SiPixelClusterSource::SiPixelClusterSource: Got DQM BackEnd interface"<<endl;
66 
67  //set Token(-s)
68  srcToken_ = consumes<edmNew::DetSetVector<SiPixelCluster> >(conf_.getParameter<edm::InputTag>("src"));
69 }
70 
71 
73 {
74  // do anything here that needs to be done at desctruction time
75  // (e.g. close files, deallocate resources etc.)
76  LogInfo ("PixelDQM") << "SiPixelClusterSource::~SiPixelClusterSource: Destructor"<<endl;
77 
78  std::map<uint32_t,SiPixelClusterModule*>::iterator struct_iter;
79  for (struct_iter = thePixelStructure.begin() ; struct_iter != thePixelStructure.end() ; struct_iter++){
80  delete struct_iter->second;
81  struct_iter->second = 0;
82  }
83 }
84 
85 
87  firstRun = true;
88 }
89 
91  LogInfo ("PixelDQM") << " SiPixelClusterSource::beginJob - Initialisation ... " << std::endl;
92  LogInfo ("PixelDQM") << "Mod/Lad/Lay/Phi " << modOn << "/" << ladOn << "/"
93  << layOn << "/" << phiOn << std::endl;
94  LogInfo ("PixelDQM") << "Blade/Disk/Ring" << bladeOn << "/" << diskOn << "/"
95  << ringOn << std::endl;
96  LogInfo ("PixelDQM") << "2DIM IS " << twoDimOn << "\n";
97  LogInfo ("PixelDQM") << "Smiley (Cluster sizeY vs. Cluster eta) is " << smileyOn << "\n";
98 
99  if(firstRun){
100  eventNo = 0;
101  lumSec = 0;
102  nLumiSecs = 0;
103  nBigEvents = 0;
104  // Build map
105  buildStructure(iSetup);
106 
107  firstRun = false;
108  }
109 }
110 
112  bookMEs(iBooker);
113  // Book occupancy maps in global coordinates for all clusters:
114  iBooker.setCurrentFolder("Pixel/Clusters/OffTrack");
115  //bpix
116  meClPosLayer1 = iBooker.book2D("position_siPixelClusters_Layer_1","Clusters Layer1;Global Z (cm);Global #phi",200,-30.,30.,128,-3.2,3.2);
117  meClPosLayer2 = iBooker.book2D("position_siPixelClusters_Layer_2","Clusters Layer2;Global Z (cm);Global #phi",200,-30.,30.,128,-3.2,3.2);
118  meClPosLayer3 = iBooker.book2D("position_siPixelClusters_Layer_3","Clusters Layer3;Global Z (cm);Global #phi",200,-30.,30.,128,-3.2,3.2);
119  if (isUpgrade) {
120  meClPosLayer4 = iBooker.book2D("position_siPixelClusters_Layer_4","Clusters Layer4;Global Z (cm);Global #phi",200,-30.,30.,128,-3.2,3.2);
121  }
122  //fpix
123  meClPosDisk1pz = iBooker.book2D("position_siPixelClusters_pz_Disk_1","Clusters +Z Disk1;Global X (cm);Global Y (cm)",80,-20.,20.,80,-20.,20.);
124  meClPosDisk2pz = iBooker.book2D("position_siPixelClusters_pz_Disk_2","Clusters +Z Disk2;Global X (cm);Global Y (cm)",80,-20.,20.,80,-20.,20.);
125  meClPosDisk1mz = iBooker.book2D("position_siPixelClusters_mz_Disk_1","Clusters -Z Disk1;Global X (cm);Global Y (cm)",80,-20.,20.,80,-20.,20.);
126  meClPosDisk2mz = iBooker.book2D("position_siPixelClusters_mz_Disk_2","Clusters -Z Disk2;Global X (cm);Global Y (cm)",80,-20.,20.,80,-20.,20.);
127  if (isUpgrade) {
128  meClPosDisk3pz = iBooker.book2D("position_siPixelClusters_pz_Disk_3","Clusters +Z Disk3;Global X (cm);Global Y (cm)",80,-20.,20.,80,-20.,20.);
129  meClPosDisk3mz = iBooker.book2D("position_siPixelClusters_mz_Disk_3","Clusters -Z Disk3;Global X (cm);Global Y (cm)",80,-20.,20.,80,-20.,20.);
130  }
131 }
132 
133 //------------------------------------------------------------------
134 // Method called for every event
135 //------------------------------------------------------------------
137 {
138  eventNo++;
139 
140  //if(modOn && !isUpgrade){
141  if(!isUpgrade){
142  if(meClPosLayer1 && meClPosLayer1->getEntries()>150000){
143  meClPosLayer1->Reset();
144  meClPosLayer2->Reset();
145  meClPosLayer3->Reset();
150  }
151  //}else if(modOn && isUpgrade){
152  }else if(isUpgrade){
153  if(meClPosLayer1 && meClPosLayer1->getEntries()>150000){
154  meClPosLayer1->Reset();
155  meClPosLayer2->Reset();
156  meClPosLayer3->Reset();
157  meClPosLayer4->Reset();
164  }
165  }
166 
167  // get input data
169  iEvent.getByToken(srcToken_, input);
170 
172  iSetup.get<TrackerDigiGeometryRecord> ().get (pDD);
173  const TrackerGeometry* tracker = &(* pDD);
174 
175  int lumiSection = (int)iEvent.luminosityBlock();
176  int nEventFpixClusters = 0;
177 
178 
179  std::map<uint32_t,SiPixelClusterModule*>::iterator struct_iter;
180  for (struct_iter = thePixelStructure.begin() ; struct_iter != thePixelStructure.end() ; struct_iter++) {
181 
182  int numberOfFpixClusters = (*struct_iter).second->fill(*input, tracker,
186  modOn, ladOn, layOn, phiOn,
187  bladeOn, diskOn, ringOn,
189  nEventFpixClusters = nEventFpixClusters + numberOfFpixClusters;
190 
191  }
192 
193  if(nEventFpixClusters>bigEventSize){
195  bigFpixClusterEventRate->Fill(lumiSection,1./23.);
196  }
197  }
198  //std::cout<<"nEventFpixClusters: "<<nEventFpixClusters<<" , nLumiSecs: "<<nLumiSecs<<" , nBigEvents: "<<nBigEvents<<std::endl;
199 
200  // slow down...
201  if(slowDown) usleep(10000);
202 
203 }
204 
205 //------------------------------------------------------------------
206 // Build data structure
207 //------------------------------------------------------------------
209 
210  LogInfo ("PixelDQM") <<" SiPixelClusterSource::buildStructure" ;
212  iSetup.get<TrackerDigiGeometryRecord>().get( pDD );
213 
214  LogVerbatim ("PixelDQM") << " *** Geometry node for TrackerGeom is "<<&(*pDD)<<std::endl;
215  LogVerbatim ("PixelDQM") << " *** I have " << pDD->dets().size() <<" detectors"<<std::endl;
216  LogVerbatim ("PixelDQM") << " *** I have " << pDD->detTypes().size() <<" types"<<std::endl;
217 
218  for(TrackerGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++){
219 
220  if(dynamic_cast<PixelGeomDetUnit const *>((*it))!=0){
221 
222  DetId detId = (*it)->geographicalId();
223  const GeomDetUnit * geoUnit = pDD->idToDetUnit( detId );
224  const PixelGeomDetUnit * pixDet = dynamic_cast<const PixelGeomDetUnit*>(geoUnit);
225  int nrows = (pixDet->specificTopology()).nrows();
226  int ncols = (pixDet->specificTopology()).ncolumns();
227 
228 
229  if((detId.subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) ||
230  (detId.subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap))){
231  uint32_t id = detId();
232  SiPixelClusterModule* theModule = new SiPixelClusterModule(id, ncols, nrows);
233  if(detId.subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) {
234  if(isPIB) continue;
235  LogDebug ("PixelDQM") << " ---> Adding Barrel Module " << detId.rawId() << endl;
236  thePixelStructure.insert(pair<uint32_t,SiPixelClusterModule*> (id,theModule));
237  }else if ( (detId.subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) && (!isUpgrade) ) {
238  LogDebug ("PixelDQM") << " ---> Adding Endcap Module " << detId.rawId() << endl;
240  int disk = PixelEndcapName(DetId(id)).diskName();
241  int blade = PixelEndcapName(DetId(id)).bladeName();
242  int panel = PixelEndcapName(DetId(id)).pannelName();
244  char sside[80]; sprintf(sside, "HalfCylinder_%i",side);
245  char sdisk[80]; sprintf(sdisk, "Disk_%i",disk);
246  char sblade[80]; sprintf(sblade, "Blade_%02i",blade);
247  char spanel[80]; sprintf(spanel, "Panel_%i",panel);
248  char smodule[80];sprintf(smodule,"Module_%i",module);
249  std::string side_str = sside;
250  std::string disk_str = sdisk;
251  bool mask = side_str.find("HalfCylinder_1")!=string::npos||
252  side_str.find("HalfCylinder_2")!=string::npos||
253  side_str.find("HalfCylinder_4")!=string::npos||
254  disk_str.find("Disk_2")!=string::npos;
255  // clutch to take all of FPIX, but no BPIX:
256  mask = false;
257  if(isPIB && mask) continue;
258  thePixelStructure.insert(pair<uint32_t,SiPixelClusterModule*> (id,theModule));
259  } else if ( (detId.subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) && (isUpgrade) ) {
260  LogDebug ("PixelDQM") << " ---> Adding Endcap Module " << detId.rawId() << endl;
262  int disk = PixelEndcapNameUpgrade(DetId(id)).diskName();
263  int blade = PixelEndcapNameUpgrade(DetId(id)).bladeName();
264  int panel = PixelEndcapNameUpgrade(DetId(id)).pannelName();
266  char sside[80]; sprintf(sside, "HalfCylinder_%i",side);
267  char sdisk[80]; sprintf(sdisk, "Disk_%i",disk);
268  char sblade[80]; sprintf(sblade, "Blade_%02i",blade);
269  char spanel[80]; sprintf(spanel, "Panel_%i",panel);
270  char smodule[80];sprintf(smodule,"Module_%i",module);
271  std::string side_str = sside;
272  std::string disk_str = sdisk;
273  bool mask = side_str.find("HalfCylinder_1")!=string::npos||
274  side_str.find("HalfCylinder_2")!=string::npos||
275  side_str.find("HalfCylinder_4")!=string::npos||
276  disk_str.find("Disk_2")!=string::npos;
277  // clutch to take all of FPIX, but no BPIX:
278  mask = false;
279  if(isPIB && mask) continue;
280  thePixelStructure.insert(pair<uint32_t,SiPixelClusterModule*> (id,theModule));
281  }//endif(Upgrade)
282  }
283  }
284  }
285  LogInfo ("PixelDQM") << " *** Pixel Structure Size " << thePixelStructure.size() << endl;
286 }
287 //------------------------------------------------------------------
288 // Book MEs
289 //------------------------------------------------------------------
291 
292  // Get DQM interface
293  iBooker.setCurrentFolder("Pixel");
294  char title[256]; snprintf(title, 256, "Rate of events with >%i FPIX clusters;LumiSection;Rate of large FPIX events per LS [Hz]",bigEventSize);
295  bigFpixClusterEventRate = iBooker.book1D("bigFpixClusterEventRate",title,5000,0.,5000.);
296 
297 
298  std::map<uint32_t,SiPixelClusterModule*>::iterator struct_iter;
299 
300  SiPixelFolderOrganizer theSiPixelFolder;
301 
302  for(struct_iter = thePixelStructure.begin(); struct_iter != thePixelStructure.end(); struct_iter++){
303 
305  if(modOn){
306  if(theSiPixelFolder.setModuleFolder((*struct_iter).first,0,isUpgrade)){
307  (*struct_iter).second->book( conf_,iBooker,0,twoDimOn,reducedSet,isUpgrade);
308  } else {
309 
310  if(!isPIB) throw cms::Exception("LogicError")
311  << "[SiPixelClusterSource::bookMEs] Creation of DQM folder failed";
312  }
313  }
314  if(ladOn){
315  if(theSiPixelFolder.setModuleFolder((*struct_iter).first,1,isUpgrade)){
316  (*struct_iter).second->book( conf_,iBooker,1,twoDimOn,reducedSet,isUpgrade);
317  } else {
318  LogDebug ("PixelDQM") << "PROBLEM WITH LADDER-FOLDER\n";
319  }
320  }
321  if(layOn){
322  if(theSiPixelFolder.setModuleFolder((*struct_iter).first,2,isUpgrade)){
323  (*struct_iter).second->book( conf_,iBooker,2,twoDimOn,reducedSet,isUpgrade);
324  } else {
325  LogDebug ("PixelDQM") << "PROBLEM WITH LAYER-FOLDER\n";
326  }
327  }
328  if(phiOn){
329  if(theSiPixelFolder.setModuleFolder((*struct_iter).first,3,isUpgrade)){
330  (*struct_iter).second->book( conf_,iBooker,3,twoDimOn,reducedSet,isUpgrade);
331  } else {
332  LogDebug ("PixelDQM") << "PROBLEM WITH PHI-FOLDER\n";
333  }
334  }
335  if(bladeOn){
336  if(theSiPixelFolder.setModuleFolder((*struct_iter).first,4,isUpgrade)){
337  (*struct_iter).second->book( conf_,iBooker,4,twoDimOn,reducedSet,isUpgrade);
338  } else {
339  LogDebug ("PixelDQM") << "PROBLEM WITH BLADE-FOLDER\n";
340  }
341  }
342  if(diskOn){
343  if(theSiPixelFolder.setModuleFolder((*struct_iter).first,5,isUpgrade)){
344  (*struct_iter).second->book( conf_,iBooker,5,twoDimOn,reducedSet,isUpgrade);
345  } else {
346  LogDebug ("PixelDQM") << "PROBLEM WITH DISK-FOLDER\n";
347  }
348  }
349  if(ringOn){
350  if(theSiPixelFolder.setModuleFolder((*struct_iter).first,6,isUpgrade)){
351  (*struct_iter).second->book( conf_,iBooker,6,twoDimOn,reducedSet,isUpgrade);
352  } else {
353  LogDebug ("PixelDQM") << "PROBLEM WITH RING-FOLDER\n";
354  }
355  }
356  if(smileyOn){
357  if(theSiPixelFolder.setModuleFolder((*struct_iter).first,7,isUpgrade)){
358  (*struct_iter).second->book( conf_,iBooker,7,twoDimOn,reducedSet,isUpgrade);
359  } else {
360  LogDebug ("PixelDQM") << "PROBLEM WITH BARREL-FOLDER\n";
361  }
362  }
363 
364  }
365 
366 }
367 
368 //define this as a plug-in
#define LogDebug(id)
int plaquetteName() const
plaquetteId (in pannel)
virtual void buildStructure(edm::EventSetup const &)
T getParameter(std::string const &) const
MonitorElement * meClPosDisk3pz
MonitorElement * meClPosDisk2pz
virtual void analyze(const edm::Event &, const edm::EventSetup &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
double getEntries(void) const
get # of entries
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > srcToken_
int plaquetteName() const
plaquetteId (in pannel)
MonitorElement * meClPosLayer4
SiPixelClusterSource(const edm::ParameterSet &conf)
static std::string const input
Definition: EdmProvDump.cc:44
void Fill(long long x)
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
MonitorElement * meClPosLayer3
int bladeName() const
blade id
int iEvent
Definition: GenABIO.cc:230
bool setModuleFolder(const uint32_t &rawdetid=0, int type=0, bool isUpgrade=false)
Set folder name for a module or plaquette.
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:113
MonitorElement * meClPosLayer1
int bladeName() const
blade id
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
int diskName() const
disk id
edm::ParameterSet conf_
Definition: DetId.h:18
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
virtual void bookMEs(DQMStore::IBooker &)
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:131
const T & get() const
Definition: EventSetup.h:55
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
virtual void dqmBeginRun(const edm::Run &, edm::EventSetup const &)
int pannelName() const
pannel id
MonitorElement * meClPosDisk3mz
MonitorElement * meClPosDisk2mz
int diskName() const
disk id
std::map< uint32_t, SiPixelClusterModule * > thePixelStructure
volatile std::atomic< bool > shutdown_flag false
MonitorElement * meClPosLayer2
HalfCylinder halfCylinder() const
HalfCylinder halfCylinder() const
int pannelName() const
pannel id
void Reset(void)
reset ME (ie. contents, errors, etc)
Definition: vlib.h:208
MonitorElement * bigFpixClusterEventRate
MonitorElement * meClPosDisk1mz
MonitorElement * meClPosDisk1pz
Definition: Run.h:41