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  firstRun = true;
70 }
71 
72 
74 {
75  // do anything here that needs to be done at desctruction time
76  // (e.g. close files, deallocate resources etc.)
77  LogInfo ("PixelDQM") << "SiPixelClusterSource::~SiPixelClusterSource: Destructor"<<endl;
78 
79  std::map<uint32_t,SiPixelClusterModule*>::iterator struct_iter;
80  for (struct_iter = thePixelStructure.begin() ; struct_iter != thePixelStructure.end() ; struct_iter++){
81  delete struct_iter->second;
82  struct_iter->second = 0;
83  }
84 }
85 
86 
87 
89  LogInfo ("PixelDQM") << " SiPixelClusterSource::beginJob - Initialisation ... " << std::endl;
90  LogInfo ("PixelDQM") << "Mod/Lad/Lay/Phi " << modOn << "/" << ladOn << "/"
91  << layOn << "/" << phiOn << std::endl;
92  LogInfo ("PixelDQM") << "Blade/Disk/Ring" << bladeOn << "/" << diskOn << "/"
93  << ringOn << std::endl;
94  LogInfo ("PixelDQM") << "2DIM IS " << twoDimOn << "\n";
95  LogInfo ("PixelDQM") << "Smiley (Cluster sizeY vs. Cluster eta) is " << smileyOn << "\n";
96 
97  if(firstRun){
98  eventNo = 0;
99  lumSec = 0;
100  nLumiSecs = 0;
101  nBigEvents = 0;
102  // Build map
103  buildStructure(iSetup);
104 
105  firstRun = false;
106  }
107 }
108 
110  bookMEs(iBooker);
111  // Book occupancy maps in global coordinates for all clusters:
112  iBooker.setCurrentFolder("Pixel/Clusters/OffTrack");
113  //bpix
114  meClPosLayer1 = iBooker.book2D("position_siPixelClusters_Layer_1","Clusters Layer1;Global Z (cm);Global #phi",200,-30.,30.,128,-3.2,3.2);
115  meClPosLayer2 = iBooker.book2D("position_siPixelClusters_Layer_2","Clusters Layer2;Global Z (cm);Global #phi",200,-30.,30.,128,-3.2,3.2);
116  meClPosLayer3 = iBooker.book2D("position_siPixelClusters_Layer_3","Clusters Layer3;Global Z (cm);Global #phi",200,-30.,30.,128,-3.2,3.2);
117  if (isUpgrade) {
118  meClPosLayer4 = iBooker.book2D("position_siPixelClusters_Layer_4","Clusters Layer4;Global Z (cm);Global #phi",200,-30.,30.,128,-3.2,3.2);
119  }
120  //fpix
121  meClPosDisk1pz = iBooker.book2D("position_siPixelClusters_pz_Disk_1","Clusters +Z Disk1;Global X (cm);Global Y (cm)",80,-20.,20.,80,-20.,20.);
122  meClPosDisk2pz = iBooker.book2D("position_siPixelClusters_pz_Disk_2","Clusters +Z Disk2;Global X (cm);Global Y (cm)",80,-20.,20.,80,-20.,20.);
123  meClPosDisk1mz = iBooker.book2D("position_siPixelClusters_mz_Disk_1","Clusters -Z Disk1;Global X (cm);Global Y (cm)",80,-20.,20.,80,-20.,20.);
124  meClPosDisk2mz = iBooker.book2D("position_siPixelClusters_mz_Disk_2","Clusters -Z Disk2;Global X (cm);Global Y (cm)",80,-20.,20.,80,-20.,20.);
125  if (isUpgrade) {
126  meClPosDisk3pz = iBooker.book2D("position_siPixelClusters_pz_Disk_3","Clusters +Z Disk3;Global X (cm);Global Y (cm)",80,-20.,20.,80,-20.,20.);
127  meClPosDisk3mz = iBooker.book2D("position_siPixelClusters_mz_Disk_3","Clusters -Z Disk3;Global X (cm);Global Y (cm)",80,-20.,20.,80,-20.,20.);
128  }
129 }
130 
131 //------------------------------------------------------------------
132 // Method called for every event
133 //------------------------------------------------------------------
135 {
136  eventNo++;
137 
138  //if(modOn && !isUpgrade){
139  if(!isUpgrade){
140  if(meClPosLayer1 && meClPosLayer1->getEntries()>150000){
141  meClPosLayer1->Reset();
142  meClPosLayer2->Reset();
143  meClPosLayer3->Reset();
148  }
149  //}else if(modOn && isUpgrade){
150  }else if(isUpgrade){
151  if(meClPosLayer1 && meClPosLayer1->getEntries()>150000){
152  meClPosLayer1->Reset();
153  meClPosLayer2->Reset();
154  meClPosLayer3->Reset();
155  meClPosLayer4->Reset();
162  }
163  }
164 
165  // get input data
167  iEvent.getByToken(srcToken_, input);
168 
170  iSetup.get<TrackerDigiGeometryRecord> ().get (pDD);
171  const TrackerGeometry* tracker = &(* pDD);
172 
173  int lumiSection = (int)iEvent.luminosityBlock();
174  int nEventFpixClusters = 0;
175 
176 
177  std::map<uint32_t,SiPixelClusterModule*>::iterator struct_iter;
178  for (struct_iter = thePixelStructure.begin() ; struct_iter != thePixelStructure.end() ; struct_iter++) {
179 
180  int numberOfFpixClusters = (*struct_iter).second->fill(*input, tracker,
184  modOn, ladOn, layOn, phiOn,
185  bladeOn, diskOn, ringOn,
187  nEventFpixClusters = nEventFpixClusters + numberOfFpixClusters;
188 
189  }
190 
191  if(nEventFpixClusters>bigEventSize){
193  bigFpixClusterEventRate->Fill(lumiSection,1./23.);
194  }
195  }
196  //std::cout<<"nEventFpixClusters: "<<nEventFpixClusters<<" , nLumiSecs: "<<nLumiSecs<<" , nBigEvents: "<<nBigEvents<<std::endl;
197 
198  // slow down...
199  if(slowDown) usleep(10000);
200 
201 }
202 
203 //------------------------------------------------------------------
204 // Build data structure
205 //------------------------------------------------------------------
207 
208  LogInfo ("PixelDQM") <<" SiPixelClusterSource::buildStructure" ;
210  iSetup.get<TrackerDigiGeometryRecord>().get( pDD );
211 
212  LogVerbatim ("PixelDQM") << " *** Geometry node for TrackerGeom is "<<&(*pDD)<<std::endl;
213  LogVerbatim ("PixelDQM") << " *** I have " << pDD->dets().size() <<" detectors"<<std::endl;
214  LogVerbatim ("PixelDQM") << " *** I have " << pDD->detTypes().size() <<" types"<<std::endl;
215 
216  for(TrackerGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++){
217 
218  if(dynamic_cast<PixelGeomDetUnit const *>((*it))!=0){
219 
220  DetId detId = (*it)->geographicalId();
221  const GeomDetUnit * geoUnit = pDD->idToDetUnit( detId );
222  const PixelGeomDetUnit * pixDet = dynamic_cast<const PixelGeomDetUnit*>(geoUnit);
223  int nrows = (pixDet->specificTopology()).nrows();
224  int ncols = (pixDet->specificTopology()).ncolumns();
225 
226 
227  if((detId.subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) ||
228  (detId.subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap))){
229  uint32_t id = detId();
230  SiPixelClusterModule* theModule = new SiPixelClusterModule(id, ncols, nrows);
231  if(detId.subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) {
232  if(isPIB) continue;
233  LogDebug ("PixelDQM") << " ---> Adding Barrel Module " << detId.rawId() << endl;
234  thePixelStructure.insert(pair<uint32_t,SiPixelClusterModule*> (id,theModule));
235  }else if ( (detId.subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) && (!isUpgrade) ) {
236  LogDebug ("PixelDQM") << " ---> Adding Endcap Module " << detId.rawId() << endl;
238  int disk = PixelEndcapName(DetId(id)).diskName();
239  int blade = PixelEndcapName(DetId(id)).bladeName();
240  int panel = PixelEndcapName(DetId(id)).pannelName();
242  char sside[80]; sprintf(sside, "HalfCylinder_%i",side);
243  char sdisk[80]; sprintf(sdisk, "Disk_%i",disk);
244  char sblade[80]; sprintf(sblade, "Blade_%02i",blade);
245  char spanel[80]; sprintf(spanel, "Panel_%i",panel);
246  char smodule[80];sprintf(smodule,"Module_%i",module);
247  std::string side_str = sside;
248  std::string disk_str = sdisk;
249  bool mask = side_str.find("HalfCylinder_1")!=string::npos||
250  side_str.find("HalfCylinder_2")!=string::npos||
251  side_str.find("HalfCylinder_4")!=string::npos||
252  disk_str.find("Disk_2")!=string::npos;
253  // clutch to take all of FPIX, but no BPIX:
254  mask = false;
255  if(isPIB && mask) continue;
256  thePixelStructure.insert(pair<uint32_t,SiPixelClusterModule*> (id,theModule));
257  } else if ( (detId.subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) && (isUpgrade) ) {
258  LogDebug ("PixelDQM") << " ---> Adding Endcap Module " << detId.rawId() << endl;
260  int disk = PixelEndcapNameUpgrade(DetId(id)).diskName();
261  int blade = PixelEndcapNameUpgrade(DetId(id)).bladeName();
262  int panel = PixelEndcapNameUpgrade(DetId(id)).pannelName();
264  char sside[80]; sprintf(sside, "HalfCylinder_%i",side);
265  char sdisk[80]; sprintf(sdisk, "Disk_%i",disk);
266  char sblade[80]; sprintf(sblade, "Blade_%02i",blade);
267  char spanel[80]; sprintf(spanel, "Panel_%i",panel);
268  char smodule[80];sprintf(smodule,"Module_%i",module);
269  std::string side_str = sside;
270  std::string disk_str = sdisk;
271  bool mask = side_str.find("HalfCylinder_1")!=string::npos||
272  side_str.find("HalfCylinder_2")!=string::npos||
273  side_str.find("HalfCylinder_4")!=string::npos||
274  disk_str.find("Disk_2")!=string::npos;
275  // clutch to take all of FPIX, but no BPIX:
276  mask = false;
277  if(isPIB && mask) continue;
278  thePixelStructure.insert(pair<uint32_t,SiPixelClusterModule*> (id,theModule));
279  }//endif(Upgrade)
280  }
281  }
282  }
283  LogInfo ("PixelDQM") << " *** Pixel Structure Size " << thePixelStructure.size() << endl;
284 }
285 //------------------------------------------------------------------
286 // Book MEs
287 //------------------------------------------------------------------
289 
290  // Get DQM interface
291  iBooker.setCurrentFolder("Pixel");
292  char title[256]; snprintf(title, 256, "Rate of events with >%i FPIX clusters;LumiSection;Rate of large FPIX events per LS [Hz]",bigEventSize);
293  bigFpixClusterEventRate = iBooker.book1D("bigFpixClusterEventRate",title,5000,0.,5000.);
294 
295 
296  std::map<uint32_t,SiPixelClusterModule*>::iterator struct_iter;
297 
298  SiPixelFolderOrganizer theSiPixelFolder(false);
299 
300  for(struct_iter = thePixelStructure.begin(); struct_iter != thePixelStructure.end(); struct_iter++){
301 
303  if(modOn){
304  if(theSiPixelFolder.setModuleFolder(iBooker,(*struct_iter).first,0,isUpgrade)){
305  (*struct_iter).second->book( conf_,iBooker,0,twoDimOn,reducedSet,isUpgrade);
306  } else {
307 
308  if(!isPIB) throw cms::Exception("LogicError")
309  << "[SiPixelClusterSource::bookMEs] Creation of DQM folder failed";
310  }
311  }
312  if(ladOn){
313  if(theSiPixelFolder.setModuleFolder(iBooker,(*struct_iter).first,1,isUpgrade)){
314  (*struct_iter).second->book( conf_,iBooker,1,twoDimOn,reducedSet,isUpgrade);
315  } else {
316  LogDebug ("PixelDQM") << "PROBLEM WITH LADDER-FOLDER\n";
317  }
318  }
319  if(layOn){
320  if(theSiPixelFolder.setModuleFolder(iBooker,(*struct_iter).first,2,isUpgrade)){
321  (*struct_iter).second->book( conf_,iBooker,2,twoDimOn,reducedSet,isUpgrade);
322  } else {
323  LogDebug ("PixelDQM") << "PROBLEM WITH LAYER-FOLDER\n";
324  }
325  }
326  if(phiOn){
327  if(theSiPixelFolder.setModuleFolder(iBooker,(*struct_iter).first,3,isUpgrade)){
328  (*struct_iter).second->book( conf_,iBooker,3,twoDimOn,reducedSet,isUpgrade);
329  } else {
330  LogDebug ("PixelDQM") << "PROBLEM WITH PHI-FOLDER\n";
331  }
332  }
333  if(bladeOn){
334  if(theSiPixelFolder.setModuleFolder(iBooker,(*struct_iter).first,4,isUpgrade)){
335  (*struct_iter).second->book( conf_,iBooker,4,twoDimOn,reducedSet,isUpgrade);
336  } else {
337  LogDebug ("PixelDQM") << "PROBLEM WITH BLADE-FOLDER\n";
338  }
339  }
340  if(diskOn){
341  if(theSiPixelFolder.setModuleFolder(iBooker,(*struct_iter).first,5,isUpgrade)){
342  (*struct_iter).second->book( conf_,iBooker,5,twoDimOn,reducedSet,isUpgrade);
343  } else {
344  LogDebug ("PixelDQM") << "PROBLEM WITH DISK-FOLDER\n";
345  }
346  }
347  if(ringOn){
348  if(theSiPixelFolder.setModuleFolder(iBooker,(*struct_iter).first,6,isUpgrade)){
349  (*struct_iter).second->book( conf_,iBooker,6,twoDimOn,reducedSet,isUpgrade);
350  } else {
351  LogDebug ("PixelDQM") << "PROBLEM WITH RING-FOLDER\n";
352  }
353  }
354  if(smileyOn){
355  if(theSiPixelFolder.setModuleFolder(iBooker,(*struct_iter).first,7,isUpgrade)){
356  (*struct_iter).second->book( conf_,iBooker,7,twoDimOn,reducedSet,isUpgrade);
357  } else {
358  LogDebug ("PixelDQM") << "PROBLEM WITH BARREL-FOLDER\n";
359  }
360  }
361 
362  }
363 
364 }
365 
366 //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:446
#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:115
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:133
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