CMS 3D CMS Logo

SiStripMonitorCluster.cc
Go to the documentation of this file.
1 
2 // -*- C++ -*-
3 // Package: SiStripMonitorCluster
4 // Class: SiStripMonitorCluster
7 // Original Author: Dorian Kcira
8 // Created: Wed Feb 1 16:42:34 CET 2006
9 #include <vector>
10 #include <numeric>
11 #include <fstream>
12 #include <math.h>
13 #include "TNamed.h"
16 
34 
37 
40 
41 #include "TMath.h"
42 #include <iostream>
43 
44 //--------------------------------------------------------------------------------------------
46  : conf_(iConfig), show_mechanical_structure_view(true), show_readout_view(false), show_control_view(false), select_all_detectors(false), reset_each_run(false), m_cacheID_(0)
47  // , genTriggerEventFlag_(new GenericTriggerEventFlag(iConfig, consumesCollector()))
48 {
49 
50  // initialize
51  passBPTXfilter_ = true;
52 
53  // initialize GenericTriggerEventFlag by specific configuration
54  // in this way, one can set specific selections for different MEs
58 
59  firstEvent = -1;
60  eventNb = 0;
61 
62  // Detector Partitions
63  SubDetPhasePartMap["TIB"] = "TI";
64  SubDetPhasePartMap["TID__MINUS"] = "TI";
65  SubDetPhasePartMap["TID__PLUS"] = "TI";
66  SubDetPhasePartMap["TOB"] = "TO";
67  SubDetPhasePartMap["TEC__MINUS"] = "TM";
68  SubDetPhasePartMap["TEC__PLUS"] = "TP";
69 
70  //get on/off option for every cluster from cfi
71  edm::ParameterSet ParametersnClusters = conf_.getParameter<edm::ParameterSet>("TH1nClusters");
72  layerswitchncluson = ParametersnClusters.getParameter<bool>("layerswitchon");
73  moduleswitchncluson = ParametersnClusters.getParameter<bool>("moduleswitchon");
74 
75  edm::ParameterSet ParametersClusterCharge = conf_.getParameter<edm::ParameterSet>("TH1ClusterCharge");
76  layerswitchcluschargeon = ParametersClusterCharge.getParameter<bool>("layerswitchon");
77  moduleswitchcluschargeon = ParametersClusterCharge.getParameter<bool>("moduleswitchon");
78  subdetswitchcluschargeon = ParametersClusterCharge.getParameter<bool>("subdetswitchon");
79 
80  edm::ParameterSet ParametersClusterStoN = conf_.getParameter<edm::ParameterSet>("TH1ClusterStoN");
81  layerswitchclusstonon = ParametersClusterStoN.getParameter<bool>("layerswitchon");
82  moduleswitchclusstonon = ParametersClusterStoN.getParameter<bool>("moduleswitchon");
83 
84  edm::ParameterSet ParametersClusterStoNVsPos = conf_.getParameter<edm::ParameterSet>("TH1ClusterStoNVsPos");
85  layerswitchclusstonVsposon = ParametersClusterStoNVsPos.getParameter<bool>("layerswitchon");
86  moduleswitchclusstonVsposon = ParametersClusterStoNVsPos.getParameter<bool>("moduleswitchon");
87 
88  edm::ParameterSet ParametersClusterPos = conf_.getParameter<edm::ParameterSet>("TH1ClusterPos");
89  layerswitchclusposon = ParametersClusterPos.getParameter<bool>("layerswitchon");
90  moduleswitchclusposon = ParametersClusterPos.getParameter<bool>("moduleswitchon");
91 
92  edm::ParameterSet ParametersClusterDigiPos = conf_.getParameter<edm::ParameterSet>("TH1ClusterDigiPos");
93  layerswitchclusdigiposon = ParametersClusterDigiPos.getParameter<bool>("layerswitchon");
94  moduleswitchclusdigiposon = ParametersClusterDigiPos.getParameter<bool>("moduleswitchon");
95 
96  edm::ParameterSet ParametersClusterNoise = conf_.getParameter<edm::ParameterSet>("TH1ClusterNoise");
97  layerswitchclusnoiseon = ParametersClusterNoise.getParameter<bool>("layerswitchon");
98  moduleswitchclusnoiseon = ParametersClusterNoise.getParameter<bool>("moduleswitchon");
99 
100  edm::ParameterSet ParametersClusterWidth = conf_.getParameter<edm::ParameterSet>("TH1ClusterWidth");
101  layerswitchcluswidthon = ParametersClusterWidth.getParameter<bool>("layerswitchon");
102  moduleswitchcluswidthon = ParametersClusterWidth.getParameter<bool>("moduleswitchon");
103  subdetswitchcluswidthon = ParametersClusterWidth.getParameter<bool>("subdetswitchon");
104 
105  edm::ParameterSet ParametersModuleLocalOccupancy = conf_.getParameter<edm::ParameterSet>("TH1ModuleLocalOccupancy");
106  layerswitchlocaloccupancy = ParametersModuleLocalOccupancy.getParameter<bool>("layerswitchon");
107  moduleswitchlocaloccupancy = ParametersModuleLocalOccupancy.getParameter<bool>("moduleswitchon");
108 
109  edm::ParameterSet ParametersNrOfClusterizedStrips = conf_.getParameter<edm::ParameterSet>("TH1NrOfClusterizedStrips");
110  layerswitchnrclusterizedstrip = ParametersNrOfClusterizedStrips.getParameter<bool>("layerswitchon");
111  moduleswitchnrclusterizedstrip = ParametersNrOfClusterizedStrips.getParameter<bool>("moduleswitchon");
112 
113  edm::ParameterSet ParametersClusterProf = conf_.getParameter<edm::ParameterSet>("TProfNumberOfCluster");
114  layerswitchnumclusterprofon = ParametersClusterProf.getParameter<bool>("layerswitchon");
115 
116  edm::ParameterSet ParametersClusterWidthProf = conf_.getParameter<edm::ParameterSet>("TProfClusterWidth");
117  layerswitchclusterwidthprofon = ParametersClusterWidthProf.getParameter<bool>("layerswitchon");
118 
119  edm::ParameterSet ParametersTotClusterProf = conf_.getParameter<edm::ParameterSet>("TProfTotalNumberOfClusters");
120  subdetswitchtotclusprofon = ParametersTotClusterProf.getParameter<bool>("subdetswitchon");
121 
122  edm::ParameterSet ParametersTotClusterTH1 = conf_.getParameter<edm::ParameterSet>("TH1TotalNumberOfClusters");
123  subdetswitchtotclusth1on = ParametersTotClusterTH1.getParameter<bool>("subdetswitchon");
124 
125  edm::ParameterSet ParametersClusterApvProf = conf_.getParameter<edm::ParameterSet>("TProfClustersApvCycle");
126  subdetswitchapvcycleprofon = ParametersClusterApvProf.getParameter<bool>("subdetswitchon");
127 
128  edm::ParameterSet ParametersClustersApvTH2 = conf_.getParameter<edm::ParameterSet>("TH2ClustersApvCycle");
129  subdetswitchapvcycleth2on = ParametersClustersApvTH2.getParameter<bool>("subdetswitchon");
130 
131  edm::ParameterSet ParametersApvCycleDBxProf2 = conf_.getParameter<edm::ParameterSet>("TProf2ApvCycleVsDBx");
132  subdetswitchapvcycledbxprof2on = ParametersApvCycleDBxProf2.getParameter<bool>("subdetswitchon");
133 
134  edm::ParameterSet ParametersDBxCycleProf = conf_.getParameter<edm::ParameterSet>("TProfClustersVsDBxCycle");
135  subdetswitchdbxcycleprofon = ParametersDBxCycleProf.getParameter<bool>("subdetswitchon");
136 
137  edm::ParameterSet ParametersCStripVsCPix = conf_.getParameter<edm::ParameterSet>("TH2CStripVsCpixel");
138  globalswitchcstripvscpix = ParametersCStripVsCPix.getParameter<bool>("globalswitchon");
139 
140  edm::ParameterSet ParametersMultiplicityRegionsTH1 = conf_.getParameter<edm::ParameterSet>("TH1MultiplicityRegions");
141  globalswitchMultiRegions = ParametersMultiplicityRegionsTH1.getParameter<bool>("globalswitchon");
142 
143  edm::ParameterSet ParametersApvCycleVsDBxGlobalTH2 = conf_.getParameter<edm::ParameterSet>("TH2ApvCycleVsDBxGlobal");
144  globalswitchapvcycledbxth2on = ParametersApvCycleVsDBxGlobalTH2.getParameter<bool>("globalswitchon");
145 
146  edm::ParameterSet ParametersNoiseStrip2ApvCycle = conf_.getParameter<edm::ParameterSet>("TH1StripNoise2ApvCycle");
147  globalswitchstripnoise2apvcycle = ParametersNoiseStrip2ApvCycle.getParameter<bool>("globalswitchon");
148 
149  edm::ParameterSet ParametersNoiseStrip3ApvCycle = conf_.getParameter<edm::ParameterSet>("TH1StripNoise3ApvCycle");
150  globalswitchstripnoise3apvcycle = ParametersNoiseStrip3ApvCycle.getParameter<bool>("globalswitchon");
151 
152  edm::ParameterSet ParametersMainDiagonalPosition = conf_.getParameter<edm::ParameterSet>("TH1MainDiagonalPosition");
153  globalswitchmaindiagonalposition= ParametersMainDiagonalPosition.getParameter<bool>("globalswitchon");
154 
155  edm::ParameterSet ClusterMultiplicityRegions = conf_.getParameter<edm::ParameterSet>("MultiplicityRegions");
156  k0 = ClusterMultiplicityRegions.getParameter<double>("k0");
157  q0 = ClusterMultiplicityRegions.getParameter<double>("q0");
158  dk0 = ClusterMultiplicityRegions.getParameter<double>("dk0");
159  maxClus = ClusterMultiplicityRegions.getParameter<double>("MaxClus");
160  minPix = ClusterMultiplicityRegions.getParameter<double>("MinPix");
161 
162  edm::ParameterSet ParametersNclusVsCycleTimeProf2D = conf_.getParameter<edm::ParameterSet>("NclusVsCycleTimeProf2D");
163  globalswitchnclusvscycletimeprof2don = ParametersNclusVsCycleTimeProf2D.getParameter<bool>("globalswitchon");
164 
165  edm::ParameterSet ParametersFEDCluster = conf_.getParameter<edm::ParameterSet>("TProfNClustersFED");
166  globalswitchFEDCluster = ParametersFEDCluster.getParameter<bool>("globalswitchon");
167 
168  edm::ParameterSet ParametersClusWidthVsAmpTH2 = conf_.getParameter<edm::ParameterSet>("ClusWidthVsAmpTH2");
169  clusterWidth_vs_amplitude_on = ParametersClusWidthVsAmpTH2.getParameter<bool>("globalswitchon");
170  layer_clusterWidth_vs_amplitude_on = ParametersClusWidthVsAmpTH2.getParameter<bool>("layerswitchon");
171  subdet_clusterWidth_vs_amplitude_on = ParametersClusWidthVsAmpTH2.getParameter<bool>("subdetswitchon");
172  module_clusterWidth_vs_amplitude_on = ParametersClusWidthVsAmpTH2.getParameter<bool>("moduleswitchon");
173 
174  clustertkhistomapon = conf_.getParameter<bool>("TkHistoMap_On");
175  clusterchtkhistomapon = conf_.getParameter<bool>("ClusterChTkHistoMap_On");
176  createTrendMEs = conf_.getParameter<bool>("CreateTrendMEs");
177  trendVsLs_ = conf_.getParameter<bool>("TrendVsLS");
178  Mod_On_ = conf_.getParameter<bool>("Mod_On");
179  ClusterHisto_ = conf_.getParameter<bool>("ClusterHisto");
180 
181  topFolderName_ = conf_.getParameter<std::string>("TopFolderName");
182 
183 
184  // Poducer name of input StripClusterCollection
185  clusterProducerStripToken_ = consumes<edmNew::DetSetVector<SiStripCluster> >(conf_.getParameter<edm::InputTag>("ClusterProducerStrip") );
186  clusterProducerPixToken_ = consumes<edmNew::DetSetVector<SiPixelCluster> >(conf_.getParameter<edm::InputTag>("ClusterProducerPix") );
187  /*
188  clusterProducerStrip_ = conf_.getParameter<edm::InputTag>("ClusterProducerStrip");
189  clusterProducerPix_ = conf_.getParameter<edm::InputTag>("ClusterProducerPix");
190  */
191  // SiStrip Quality Label
192  qualityLabel_ = conf_.getParameter<std::string>("StripQualityLabel");
193  // cluster quality conditions
194  edm::ParameterSet cluster_condition = conf_.getParameter<edm::ParameterSet>("ClusterConditions");
195  applyClusterQuality_ = cluster_condition.getParameter<bool>("On");
196  sToNLowerLimit_ = cluster_condition.getParameter<double>("minStoN");
197  sToNUpperLimit_ = cluster_condition.getParameter<double>("maxStoN");
198  widthLowerLimit_ = cluster_condition.getParameter<double>("minWidth");
199  widthUpperLimit_ = cluster_condition.getParameter<double>("maxWidth");
200 
201  // Event History Producer
202  // historyProducer_ = conf_.getParameter<edm::InputTag>("HistoryProducer");
203  historyProducerToken_ = consumes<EventWithHistory>(conf_.getParameter<edm::InputTag>("HistoryProducer") );
204  // Apv Phase Producer
205  // apvPhaseProducer_ = conf_.getParameter<edm::InputTag>("ApvPhaseProducer");
206  apvPhaseProducerToken_ = consumes<APVCyclePhaseCollection>(conf_.getParameter<edm::InputTag>("ApvPhaseProducer") );
207  // Create DCS Status
208  bool checkDCS = conf_.getParameter<bool>("UseDCSFiltering");
209  if (checkDCS) dcsStatus_ = new SiStripDCSStatus(consumesCollector());
210  else dcsStatus_ = 0;
211 
212 }
213 
215  if (dcsStatus_) delete dcsStatus_;
219 }
220 
221 
222 //--------------------------------------------------------------------------------------------
224 
225  // Initialize the GenericTriggerEventFlag
232 }
233 
234 //--------------------------------------------------------------------------------------------
236 
238 
239  //Retrieve tracker topology from geometry
240  edm::ESHandle<TrackerTopology> tTopoHandle;
241  es.get<TrackerTopologyRcd>().get(tTopoHandle);
242  const TrackerTopology* const tTopo = tTopoHandle.product();
243 
244  // take from eventSetup the SiStripDetCabling object - here will use SiStripDetControl later on
246 
247  // get list of active detectors from SiStripDetCabling
248  std::vector<uint32_t> activeDets;
250 
251  SiStripSubStructure substructure;
252 
253  SiStripFolderOrganizer folder_organizer;
254  folder_organizer.setSiStripFolderName(topFolderName_);
255  folder_organizer.setSiStripFolder();
256 
257 
258  // Create TkHistoMap for Cluster
259  if (clustertkhistomapon) {
260  // std::cout << "[SiStripMonitorCluster::createMEs] topFolderName_: " << topFolderName_ << " ";
261  if ( (topFolderName_ == "SiStrip") or (std::string::npos != topFolderName_.find("HLT")) )
262  tkmapcluster = new TkHistoMap(ibooker , topFolderName_,"TkHMap_NumberOfCluster",0.,true);
263  else tkmapcluster = new TkHistoMap(ibooker , topFolderName_+"/TkHistoMap","TkHMap_NumberOfCluster",0.,false);
264  }
265  if (clusterchtkhistomapon) {
266  if ( (topFolderName_ == "SiStrip") or (std::string::npos != topFolderName_.find("HLT")) )
267  tkmapclusterch = new TkHistoMap(ibooker , topFolderName_,"TkHMap_ClusterCharge",0.,true);
268  else tkmapclusterch = new TkHistoMap(ibooker , topFolderName_+"/TkHistoMap","TkHMap_ClusterCharge",0.,false);
269  }
270 
271  // loop over detectors and book MEs
272  edm::LogInfo("SiStripTkDQM|SiStripMonitorCluster")<<"nr. of activeDets: "<<activeDets.size();
273  for(std::vector<uint32_t>::iterator detid_iterator = activeDets.begin(); detid_iterator!=activeDets.end(); detid_iterator++){
274  uint32_t detid = (*detid_iterator);
275  // remove any eventual zero elements - there should be none, but just in case
276  if(detid == 0) {
277  activeDets.erase(detid_iterator);
278  continue;
279  }
280 
281  if (Mod_On_) {
282  ModMEs mod_single;
283  // set appropriate folder using SiStripFolderOrganizer
284  folder_organizer.setDetectorFolder(detid, tTopo); // pass the detid to this method
285  if (reset_each_run) ResetModuleMEs(detid);
286  createModuleMEs(mod_single, detid , ibooker);
287  // append to ModuleMEsMap
288  ModuleMEsMap.insert( std::make_pair(detid, mod_single));
289  }
290 
291  // Create Layer Level MEs if they are not created already
292  std::pair<std::string,int32_t> det_layer_pair = folder_organizer.GetSubDetAndLayer(detid, tTopo);
293  SiStripHistoId hidmanager;
294  std::string label = hidmanager.getSubdetid(detid,tTopo,false);
295 
296  std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(label);
297  if(iLayerME==LayerMEsMap.end()) {
298 
299  // get detids for the layer
300  int32_t lnumber = det_layer_pair.second;
301  std::vector<uint32_t> layerDetIds;
302  if (det_layer_pair.first == "TIB") {
303  substructure.getTIBDetectors(activeDets,layerDetIds,lnumber,0,0,0);
304  } else if (det_layer_pair.first == "TOB") {
305  substructure.getTOBDetectors(activeDets,layerDetIds,lnumber,0,0);
306  } else if (det_layer_pair.first == "TID" && lnumber > 0) {
307  substructure.getTIDDetectors(activeDets,layerDetIds,2,std::abs(lnumber),0,0);
308  } else if (det_layer_pair.first == "TID" && lnumber < 0) {
309  substructure.getTIDDetectors(activeDets,layerDetIds,1,std::abs(lnumber),0,0);
310  } else if (det_layer_pair.first == "TEC" && lnumber > 0) {
311  substructure.getTECDetectors(activeDets,layerDetIds,2,std::abs(lnumber),0,0,0,0);
312  } else if (det_layer_pair.first == "TEC" && lnumber < 0) {
313  substructure.getTECDetectors(activeDets,layerDetIds,1,std::abs(lnumber),0,0,0,0);
314  }
315  LayerDetMap[label] = layerDetIds;
316 
317  // book Layer MEs
318  folder_organizer.setLayerFolder(detid,tTopo,det_layer_pair.second);
319  createLayerMEs(label, layerDetIds.size() , ibooker );
320  }
321  // book sub-detector plots
322  auto sdet_pair = folder_organizer.getSubDetFolderAndTag(detid, tTopo);
323  if (SubDetMEsMap.find(sdet_pair.second) == SubDetMEsMap.end()){
324  ibooker.setCurrentFolder(sdet_pair.first);
325 
326  createSubDetMEs(sdet_pair.second , ibooker );
327  }
328  }//end of loop over detectors
329 
330  // Create Global Histogram
332  ibooker.setCurrentFolder(topFolderName_+"/MechanicalView/");
333  edm::ParameterSet GlobalTH2Parameters = conf_.getParameter<edm::ParameterSet>("TH2ApvCycleVsDBxGlobal");
334  std::string HistoName = "DeltaBx_vs_ApvCycle";
335  GlobalApvCycleDBxTH2 = ibooker.book2D(HistoName,HistoName,
336  GlobalTH2Parameters.getParameter<int32_t>("Nbinsx"),
337  GlobalTH2Parameters.getParameter<double>("xmin"),
338  GlobalTH2Parameters.getParameter<double>("xmax"),
339  GlobalTH2Parameters.getParameter<int32_t>("Nbinsy"),
340  GlobalTH2Parameters.getParameter<double>("ymin"),
341  GlobalTH2Parameters.getParameter<double>("ymax"));
342  GlobalApvCycleDBxTH2->setAxisTitle("APV Cycle (Corrected Absolute Bx % 70)",1);
343  GlobalApvCycleDBxTH2->setAxisTitle("Delta Bunch Crossing Cycle",2);
344 
345  // plot DeltaBX ***************************
346  edm::ParameterSet GlobalTH1Parameters = conf_.getParameter<edm::ParameterSet>("TH1DBxGlobal");
347  HistoName = "DeltaBx";
348  GlobalDBxTH1 = ibooker.book1D(HistoName,HistoName,
349  GlobalTH1Parameters.getParameter<int32_t>("Nbinsx"),
350  GlobalTH1Parameters.getParameter<double>("xmin"),
351  GlobalTH1Parameters.getParameter<double>("xmax"));
352  GlobalDBxTH1->setAxisTitle("Delta Bunch Crossing",1);
353 
354 
355 
356  // plot DeltaBXCycle ***************************
357  edm::ParameterSet DBxCycle = conf_.getParameter<edm::ParameterSet>("TH1DBxCycleGlobal");
358  HistoName = "DeltaBxCycle";
359  GlobalDBxCycleTH1 = ibooker.book1D(HistoName,HistoName,
360  DBxCycle.getParameter<int32_t>("Nbinsx"),
361  DBxCycle.getParameter<double>("xmin"),
362  DBxCycle.getParameter<double>("xmax"));
363  GlobalDBxCycleTH1->setAxisTitle("Delta Bunch Crossing Cycle",1);
364 
365 
366  }
367 
369  ibooker.setCurrentFolder(topFolderName_+"/MechanicalView/");
370  edm::ParameterSet GlobalTH2Parameters = conf_.getParameter<edm::ParameterSet>("TH2CStripVsCpixel");
371  std::string HistoName = "StripClusVsPixClus";
372  GlobalCStripVsCpix = ibooker.book2D(HistoName,HistoName,
373  GlobalTH2Parameters.getParameter<int32_t>("Nbinsx"),
374  GlobalTH2Parameters.getParameter<double>("xmin"),
375  GlobalTH2Parameters.getParameter<double>("xmax"),
376  GlobalTH2Parameters.getParameter<int32_t>("Nbinsy"),
377  GlobalTH2Parameters.getParameter<double>("ymin"),
378  GlobalTH2Parameters.getParameter<double>("ymax"));
379  GlobalCStripVsCpix->setAxisTitle("Strip Clusters",1);
380  GlobalCStripVsCpix->setAxisTitle("Pix Clusters",2);
381 
382  // Absolute Bunch Crossing ***********************
383  edm::ParameterSet GlobalTH1Parameters = conf_.getParameter<edm::ParameterSet>("TH1ABx_CSCP");
384  HistoName = "AbsoluteBx_CStripVsCpixel";
385  GlobalABXTH1_CSCP = ibooker.book1D(HistoName,HistoName,
386  GlobalTH1Parameters.getParameter<int32_t>("Nbinsx"),
387  GlobalTH1Parameters.getParameter<double>("xmin"),
388  GlobalTH1Parameters.getParameter<double>("xmax"));
389  GlobalABXTH1_CSCP->setAxisTitle("Absolute Bunch Crossing",1);
390  }
391 
393  ibooker.setCurrentFolder(topFolderName_+"/MechanicalView/");
394  edm::ParameterSet GlobalTH2Parameters = conf_.getParameter<edm::ParameterSet>("TH1MultiplicityRegions");
395  std::string HistoName = "ClusterMultiplicityRegions";
396  PixVsStripMultiplicityRegions = ibooker.book1D(HistoName,HistoName,
397  GlobalTH2Parameters.getParameter<int32_t>("Nbinx"),
398  GlobalTH2Parameters.getParameter<double>("xmin"),
399  GlobalTH2Parameters.getParameter<double>("xmax"));
401  PixVsStripMultiplicityRegions->setBinLabel(1,"Main Diagonal");
402  PixVsStripMultiplicityRegions->setBinLabel(2,"Strip Noise");
403  PixVsStripMultiplicityRegions->setBinLabel(3,"High Strip Noise");
404  PixVsStripMultiplicityRegions->setBinLabel(4,"Beam Background");
405  PixVsStripMultiplicityRegions->setBinLabel(5,"No Strip Clusters");
406  }
407 
409  ibooker.setCurrentFolder(topFolderName_+"/MechanicalView/");
410  edm::ParameterSet GlobalTH1Parameters = conf_.getParameter<edm::ParameterSet>("TH1MainDiagonalPosition");
411  std::string HistoName = "MainDiagonal Position";
412  GlobalMainDiagonalPosition = ibooker.book1D(HistoName,HistoName,
413  GlobalTH1Parameters.getParameter<int32_t>("Nbinsx"),
414  GlobalTH1Parameters.getParameter<double>("xmin"),
415  GlobalTH1Parameters.getParameter<double>("xmax"));
416  GlobalMainDiagonalPosition->setAxisTitle("atan(NPix/(k*NStrip))");
417 
418  //PLOT MainDiagonalPosition_vs_BX ***************************
419  edm::ParameterSet GlobalTProfParameters = conf_.getParameter<edm::ParameterSet>("TProfMainDiagonalPosition");
420  HistoName = "MainDiagonalPosition_vs_BX";
421  GlobalMainDiagonalPosition_vs_BX = ibooker.bookProfile(HistoName, HistoName,
422  GlobalTProfParameters.getParameter<int32_t>("Nbinsx"),
423  GlobalTProfParameters.getParameter<double>("xmin"),
424  GlobalTProfParameters.getParameter<double>("xmax"),
425  GlobalTProfParameters.getParameter<int32_t>("Nbinsy"),
426  GlobalTProfParameters.getParameter<double>("ymin"),
427  GlobalTProfParameters.getParameter<double>("ymax"));
428 
430  GlobalMainDiagonalPosition_vs_BX->setAxisTitle("tan^{-1}(NPix/k*NStrip))", 2);
431 
432 
433  edm::ParameterSet GlobalTH2Parameters = conf_.getParameter<edm::ParameterSet>("TH2MainDiagonalPosition");
434  HistoName = "TH2MainDiagonalPosition_vs_BX";
435  GlobalTH2MainDiagonalPosition_vs_BX = ibooker.book2D(HistoName,HistoName,
436  GlobalTH2Parameters.getParameter<int32_t>("Nbinsx"),
437  GlobalTH2Parameters.getParameter<double>("xmin"),
438  GlobalTH2Parameters.getParameter<double>("xmax"),
439  GlobalTH2Parameters.getParameter<int32_t>("Nbinsy"),
440  GlobalTH2Parameters.getParameter<double>("ymin"),
441  GlobalTH2Parameters.getParameter<double>("ymax"));
443  GlobalTH2MainDiagonalPosition_vs_BX->setAxisTitle("tan^{-1}(NPix/k*NStrip))",2);
444 
445 
446 
447  }
448 
449  // TO BE ADDED !!!
450  /*
451  if ( globalswitchapvcycledbxth2on or globalswitchcstripvscpix or globalswitchMultiRegions or ClusterHisto_ ) {
452  ibooker.setCurrentFolder(topFolderName_+"/MechanicalView/");
453  std::string HistoName = "BPTX rate";
454  BPTXrateTrend = ibooker.bookProfile(HistoName,HistoName, LSBin, LSMin, LSMax, 0, 10000.,"");
455  BPTXrateTrend->getTH1()->SetCanExtend(TH1::kAllAxes);
456  BPTXrateTrend->setAxisTitle("#Lumi section",1);
457  BPTXrateTrend->setAxisTitle("Number of BPTX events per LS",2);
458  }
459  */
460 
462  ibooker.setCurrentFolder(topFolderName_+"/MechanicalView/");
463  edm::ParameterSet GlobalTH1Parameters = conf_.getParameter<edm::ParameterSet>("TH1StripNoise2ApvCycle");
464  std::string HistoName = "StripNoise_ApvCycle";
465  StripNoise2Cycle = ibooker.book1D(HistoName,HistoName,
466  GlobalTH1Parameters.getParameter<int32_t>("Nbinsx"),
467  GlobalTH1Parameters.getParameter<double>("xmin"),
468  GlobalTH1Parameters.getParameter<double>("xmax"));
469  StripNoise2Cycle->setAxisTitle("APV Cycle");
470  }
471 
473  ibooker.setCurrentFolder(topFolderName_+"/MechanicalView/");
474  edm::ParameterSet GlobalTH1Parameters = conf_.getParameter<edm::ParameterSet>("TH1StripNoise3ApvCycle");
475  std::string HistoName = "HighStripNoise_ApvCycle";
476  StripNoise3Cycle = ibooker.book1D(HistoName,HistoName,
477  GlobalTH1Parameters.getParameter<int32_t>("Nbinsx"),
478  GlobalTH1Parameters.getParameter<double>("xmin"),
479  GlobalTH1Parameters.getParameter<double>("xmax"));
480  StripNoise3Cycle->setAxisTitle("APV Cycle");
481  }
482 
484  const char* HistoName = "StripClusVsBXandOrbit";
485  const char* HistoTitle = "Strip cluster multiplicity vs BX mod(70) and Orbit;Event 1 BX mod(70);time [Orb#]";
486  edm::ParameterSet ParametersNclusVsCycleTimeProf2D = conf_.getParameter<edm::ParameterSet>("NclusVsCycleTimeProf2D");
487  NclusVsCycleTimeProf2D = ibooker.bookProfile2D ( HistoName , HistoTitle ,
488  ParametersNclusVsCycleTimeProf2D.getParameter<int32_t>("Nbins"),
489  ParametersNclusVsCycleTimeProf2D.getParameter<double>("xmin"),
490  ParametersNclusVsCycleTimeProf2D.getParameter<double>("xmax"),
491  ParametersNclusVsCycleTimeProf2D.getParameter<int32_t>("Nbinsy"),
492  ParametersNclusVsCycleTimeProf2D.getParameter<double>("ymin"),
493  ParametersNclusVsCycleTimeProf2D.getParameter<double>("ymax"),
494  0 , 0 );
495  if (NclusVsCycleTimeProf2D->kind() == MonitorElement::DQM_KIND_TPROFILE2D) NclusVsCycleTimeProf2D->getTH1()->SetCanExtend(TH1::kAllAxes);
496  }
498  ibooker.setCurrentFolder(topFolderName_+"/MechanicalView/");
499  edm::ParameterSet ParametersClusWidthVsAmpTH2 = conf_.getParameter<edm::ParameterSet>("ClusWidthVsAmpTH2");
500  const char* HistoName = "ClusterWidths_vs_Amplitudes";
501  const char* HistoTitle = "Cluster widths vs amplitudes;Amplitudes (integrated ADC counts);Cluster widths";
502  ClusWidthVsAmpTH2 = ibooker.book2D(HistoName,HistoTitle,
503  ParametersClusWidthVsAmpTH2.getParameter<int32_t>("Nbinsx"),
504  ParametersClusWidthVsAmpTH2.getParameter<double>("xmin"),
505  ParametersClusWidthVsAmpTH2.getParameter<double>("xmax"),
506  ParametersClusWidthVsAmpTH2.getParameter<int32_t>("Nbinsy"),
507  ParametersClusWidthVsAmpTH2.getParameter<double>("ymin"),
508  ParametersClusWidthVsAmpTH2.getParameter<double>("ymax"));
509  }
510 
511  if (ClusterHisto_){
512  ibooker.setCurrentFolder(topFolderName_+"/MechanicalView/");
513  edm::ParameterSet PixelCluster = conf_.getParameter<edm::ParameterSet>("TH1NClusPx");
514  std::string HistoName = "NumberOfClustersInPixel";
515  NumberOfPixelClus = ibooker.book1D(HistoName, HistoName,
516  PixelCluster.getParameter<int32_t>("Nbinsx"),
517  PixelCluster.getParameter<double>("xmin"),
518  PixelCluster.getParameter<double>("xmax"));
519  NumberOfPixelClus->setAxisTitle("# of Clusters in Pixel", 1);
520  NumberOfPixelClus->setAxisTitle("Number of Events", 2);
521  //
522  edm::ParameterSet StripCluster = conf_.getParameter<edm::ParameterSet>("TH1NClusStrip");
523  HistoName = "NumberOfClustersInStrip";
524  NumberOfStripClus = ibooker.book1D(HistoName, HistoName,
525  StripCluster.getParameter<int32_t>("Nbinsx"),
526  StripCluster.getParameter<double>("xmin"),
527  StripCluster.getParameter<double>("xmax"));
528  NumberOfStripClus->setAxisTitle("# of Clusters in Strip", 1);
529  NumberOfStripClus->setAxisTitle("Number of Events", 2);
530 
531  // NumberOfClustersinStrip vs BX PLOT ****************************
532  edm::ParameterSet StripClusterBX = conf_.getParameter<edm::ParameterSet>("TProfNClusStrip");
533  HistoName = "NumberOfClustersInStrip_vs_BX";
534  NumberOfStripClus_vs_BX = ibooker.bookProfile(HistoName, HistoName,
535  StripClusterBX.getParameter<int32_t>("Nbinsx"),
536  StripClusterBX.getParameter<double>("xmin"),
537  StripClusterBX.getParameter<double>("xmax"),
538  StripClusterBX.getParameter<int32_t>("Nbinsy"),
539  StripClusterBX.getParameter<double>("ymin"),
540  StripClusterBX.getParameter<double>("ymax"));
541 
542  NumberOfStripClus_vs_BX->setAxisTitle("Absolute BX", 1);
543  NumberOfStripClus_vs_BX->setAxisTitle("# of Clusters in Strip", 2);
544 
545  // NumberOfClustersinStrip vs BX PLOT ****************************
546  edm::ParameterSet PixelClusterBX = conf_.getParameter<edm::ParameterSet>("TProfNClusPixel");
547  HistoName = "NumberOfClustersInPixel_vs_BX";
548  NumberOfPixelClus_vs_BX = ibooker.bookProfile(HistoName, HistoName,
549  PixelClusterBX.getParameter<int32_t>("Nbinsx"),
550  PixelClusterBX.getParameter<double>("xmin"),
551  PixelClusterBX.getParameter<double>("xmax"),
552  PixelClusterBX.getParameter<int32_t>("Nbinsy"),
553  PixelClusterBX.getParameter<double>("ymin"),
554  PixelClusterBX.getParameter<double>("ymax"));
555 
556  NumberOfPixelClus_vs_BX->setAxisTitle("Absolute BX", 1);
557  NumberOfPixelClus_vs_BX->setAxisTitle("# of Clusters in Pixel", 2);
558 
560  // Number of clusters per FED
561  edm::ParameterSet FEDCluster = conf_.getParameter<edm::ParameterSet>("TProfNClustersFED");
562  HistoName = "NumberOfClustersinFED_v_FEDID";
563  NumberOfFEDClus = ibooker.bookProfile(HistoName,
564  HistoName,
565  FEDCluster.getParameter<int32_t>("Nbinsx"),
566  FEDCluster.getParameter<double>("xmin"),
567  FEDCluster.getParameter<double>("xmax"),
568  FEDCluster.getParameter<int32_t>("Nbinsy"),
569  FEDCluster.getParameter<double>("ymin"),
570  FEDCluster.getParameter<double>("ymax"));
571  NumberOfFEDClus->setAxisTitle("FED ID",1);
572  NumberOfFEDClus->setAxisTitle("Mean # of Cluster in FED",2);
573  }
574 
575  }
576 
577  }//end of if
578 }//end of method
579 
580 //--------------------------------------------------------------------------------------------
581 
583 {
585  unsigned long long cacheID = es.get<SiStripDetCablingRcd>().cacheIdentifier();
586  if (m_cacheID_ != cacheID) {
587  m_cacheID_ = cacheID;
588  edm::LogInfo("SiStripMonitorCluster") <<"SiStripMonitorCluster::bookHistograms: "
589  << " Creating MEs for new Cabling ";
590 
591  createMEs(es , ibooker);
592  }
593  } else if (reset_each_run) {
594  edm::LogInfo("SiStripMonitorCluster") <<"SiStripMonitorCluster::bookHistograms: "
595  << " Resetting MEs ";
596  for (std::map<uint32_t, ModMEs >::const_iterator idet = ModuleMEsMap.begin() ; idet!=ModuleMEsMap.end() ; idet++) {
597  ResetModuleMEs(idet->first);
598  }
599  }
600 
601 }
602 
603 //--------------------------------------------------------------------------------------------
605 {
606  //Retrieve tracker topology from geometry
607  edm::ESHandle<TrackerTopology> tTopoHandle;
608  iSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
609  const TrackerTopology* const tTopo = tTopoHandle.product();
610 
611  // Filter out events if Trigger Filtering is requested
612  passBPTXfilter_ = ( iEvent.isRealData() and genTriggerEventFlagBPTXfilter_->on() ) ? genTriggerEventFlagBPTXfilter_->accept( iEvent, iSetup) : true;
615  // std::cout << "passBPTXfilter_ ? " << passBPTXfilter_ << std::endl;
616 
617  // Filter out events if DCS Event if requested
618  if (dcsStatus_ && !dcsStatus_->getStatus(iEvent,iSetup)) return;
619 
620  runNb = iEvent.id().run();
621  eventNb++;
622  trendVar = trendVsLs_ ? iEvent.orbitNumber()/262144.0 : iEvent.orbitNumber()/11223.0; // lumisection : seconds
623 
624  int NPixClusters=0, NStripClusters=0, MultiplicityRegion=0;
625  bool isPixValid=false;
626 
627  edm::ESHandle<SiStripNoises> noiseHandle;
628  iSetup.get<SiStripNoisesRcd>().get(noiseHandle);
629 
630  edm::ESHandle<SiStripGain> gainHandle;
631  iSetup.get<SiStripGainRcd>().get(gainHandle);
632 
633  edm::ESHandle<SiStripQuality> qualityHandle;
634  iSetup.get<SiStripQualityRcd>().get(qualityLabel_,qualityHandle);
635 
637 
638  // get collection of DetSetVector of clusters from Event
640  iEvent.getByToken(clusterProducerStripToken_, cluster_detsetvektor);
641 
642  //get pixel clusters
643  edm::Handle< edmNew::DetSetVector<SiPixelCluster> > cluster_detsetvektor_pix;
644  iEvent.getByToken(clusterProducerPixToken_, cluster_detsetvektor_pix);
645 
646  if (!cluster_detsetvektor.isValid()) return;
647 
648  const edmNew::DetSetVector<SiStripCluster> * StrC= cluster_detsetvektor.product();
649  NStripClusters= StrC->data().size();
650 
651  if (cluster_detsetvektor_pix.isValid()){
652  const edmNew::DetSetVector<SiPixelCluster> * PixC= cluster_detsetvektor_pix.product();
653  NPixClusters= PixC->data().size();
654  isPixValid=true;
655  MultiplicityRegion=FindRegion(NStripClusters,NPixClusters);
656 
658  if (globalswitchcstripvscpix) GlobalCStripVsCpix->Fill(NStripClusters,NPixClusters);
659  if (globalswitchmaindiagonalposition && NStripClusters > 0) GlobalMainDiagonalPosition->Fill(atan(NPixClusters/(k0*NStripClusters)));
660 
662  }
663 
664  if (ClusterHisto_){
666  NumberOfPixelClus->Fill(NPixClusters);
667  if ( passBPTXfilter_ and passStripDCSfilter_ )
668  NumberOfStripClus->Fill(NStripClusters);
669  }
670  }
671  // initialise # of clusters to zero
672  for (std::map<std::string, SubDetMEs>::iterator iSubdet = SubDetMEsMap.begin();
673  iSubdet != SubDetMEsMap.end(); iSubdet++) {
674  iSubdet->second.totNClusters = 0;
675  }
676 
677  SiStripFolderOrganizer folder_organizer;
678  bool found_layer_me = false;
679  //Map of cumulative clusters per fed ID.
680  std::map<int,int> FEDID_v_clustersum;
681 
682  for (std::map<std::string, std::vector< uint32_t > >::const_iterator iterLayer = LayerDetMap.begin();
683  iterLayer != LayerDetMap.end(); iterLayer++) {
684 
685  std::string layer_label = iterLayer->first;
686 
687  int ncluster_layer = 0;
688  std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(layer_label);
689 
690  //get Layer MEs
691  LayerMEs layer_single;
692  if(iLayerME != LayerMEsMap.end()) {
693  layer_single = iLayerME->second;
694  found_layer_me = true;
695  }
696 
697 
698  int ncluster_ring[20] = {0};
699 
700  bool found_module_me = false;
701  uint16_t iDet = 0;
702  std::string subdet_label = "";
703  // loop over all modules in the layer
704  for (std::vector< uint32_t >::const_iterator iterDets = iterLayer->second.begin() ;
705  iterDets != iterLayer->second.end() ; iterDets++) {
706  iDet++;
707  // detid and type of ME
708  uint32_t detid = (*iterDets);
709 
710  // Get SubDet label once
711  if (subdet_label.size() == 0) subdet_label = folder_organizer.getSubDetFolderAndTag(detid, tTopo).second;
712 
713  // DetId and corresponding set of MEs
714  ModMEs mod_single;
715  if (Mod_On_) {
716  std::map<uint32_t, ModMEs >::iterator imodME = ModuleMEsMap.find(detid);
717  if (imodME != ModuleMEsMap.end()) {
718  mod_single = imodME->second;
719  found_module_me = true;
720  }
721  } else found_module_me = false;
722 
723  edmNew::DetSetVector<SiStripCluster>::const_iterator isearch = cluster_detsetvektor->find(detid); // search clusters of detid
724 
725  if(isearch==cluster_detsetvektor->end()){
726  if(found_module_me && moduleswitchncluson && (mod_single.NumberOfClusters)){
727  (mod_single.NumberOfClusters)->Fill(0.); // no clusters for this detector module,fill histogram with 0
728  }
729  if(clustertkhistomapon) tkmapcluster->fill(detid,0.);
731  if (found_layer_me && layerswitchnumclusterprofon) layer_single.LayerNumberOfClusterProfile->Fill(iDet, 0.0);
732  continue; // no clusters for this detid => jump to next step of loop
733  }
734 
735  //cluster_detset is a structure, cluster_detset.data is a std::vector<SiStripCluster>, cluster_detset.id is uint32_t
736  //edmNew::DetSet<SiStripCluster> cluster_detset = (*cluster_detsetvektor)[detid]; // the statement above makes sure there exists an element with 'detid'
737  edmNew::DetSet<SiStripCluster> cluster_detset = (*isearch);
738 
739 
741  // Get all FED connections associated with given detID.
742  // All connections for a detid have same FED Id therefore one FEDID is associated with a given detID.
743  // Vector of constant FedChannelConnection objects to variable pointers.
744  std::vector<const FedChannelConnection*> fedConnections = SiStripDetCabling_->getConnections(detid);
745 
746  // Filling FED Id associated clusters map.
747 
748  int good_fcc_index = -999;
749  for(unsigned int x=0;x<fedConnections.size();x++){
750  if(fedConnections[x]!=NULL){
751  good_fcc_index = x;
752  break;
753  }
754  }
755  if(good_fcc_index!=-999 && fedConnections[good_fcc_index]!=NULL){
756  int temp_fedid = fedConnections[good_fcc_index]->fedId();
757  if(FEDID_v_clustersum.find(temp_fedid) != FEDID_v_clustersum.end()){
758  if(cluster_detset.size() < 1000 && !cluster_detset.empty()){
759  FEDID_v_clustersum[temp_fedid] = FEDID_v_clustersum.find(temp_fedid)->second + cluster_detset.size();
760  }
761  }
762  else{
763  if(cluster_detset.size() < 1000 && !cluster_detset.empty()){
764  FEDID_v_clustersum[temp_fedid] = cluster_detset.size();
765  }
766  }
767  }
768  else{
769  edm::LogInfo("SiStripMonitorCluster") << "SiStripMonitorCluster::analyze WARNING! no good connections for detid = " << detid << endl;
770  }
772 
773 
774  // Filling TkHistoMap with number of clusters for each module
775  if(clustertkhistomapon) {
776  tkmapcluster->fill(detid,static_cast<float>(cluster_detset.size()));
777  }
778 
779  if(moduleswitchncluson && found_module_me && (mod_single.NumberOfClusters != NULL)){ // nr. of clusters per module
780  (mod_single.NumberOfClusters)->Fill(static_cast<float>(cluster_detset.size()));
781  }
782 
783  if (found_layer_me && layerswitchnumclusterprofon)
784  layer_single.LayerNumberOfClusterProfile->Fill(iDet, static_cast<float>(cluster_detset.size()));
785  ncluster_layer += cluster_detset.size();
786 
787  short total_clusterized_strips = 0;
788 
789  SiStripNoises::Range detNoiseRange = noiseHandle->getRange(detid);
790  SiStripApvGain::Range detGainRange = gainHandle->getRange(detid);
791  SiStripQuality::Range qualityRange = qualityHandle->getRange(detid);
792 
793  for(edmNew::DetSet<SiStripCluster>::const_iterator clusterIter = cluster_detset.begin(); clusterIter!= cluster_detset.end(); clusterIter++){
794 
795  const auto & ampls = clusterIter->amplitudes();
796  // cluster position
797  float cluster_position = clusterIter->barycenter();
798  // start defined as nr. of first strip beloning to the cluster
799  short cluster_start = clusterIter->firstStrip();
800  // width defined as nr. of strips that belong to cluster
801  short cluster_width = ampls.size();
802  // add nr of strips of this cluster to total nr. of clusterized strips
803  total_clusterized_strips = total_clusterized_strips + cluster_width;
804 
805  if(clusterchtkhistomapon) tkmapclusterch->fill(detid,static_cast<float>(clusterIter->charge()));
806 
807  // cluster signal and noise from the amplitudes
808  float cluster_signal = 0.0;
809  float cluster_noise = 0.0;
810  int nrnonzeroamplitudes = 0;
811  float noise2 = 0.0;
812  float noise = 0.0;
813  for(uint iamp=0; iamp<ampls.size(); iamp++){
814  if(ampls[iamp]>0){ // nonzero amplitude
815  cluster_signal += ampls[iamp];
816  if(!qualityHandle->IsStripBad(qualityRange, clusterIter->firstStrip()+iamp)){
817  noise = noiseHandle->getNoise(clusterIter->firstStrip()+iamp,detNoiseRange)/gainHandle->getStripGain(clusterIter->firstStrip()+iamp, detGainRange);
818  }
819  noise2 += noise*noise;
820  nrnonzeroamplitudes++;
821  }
822  } // End loop over cluster amplitude
823 
824  if (nrnonzeroamplitudes > 0) cluster_noise = sqrt(noise2/nrnonzeroamplitudes);
825 
826  if( applyClusterQuality_ &&
827  (cluster_signal/cluster_noise < sToNLowerLimit_ ||
828  cluster_signal/cluster_noise > sToNUpperLimit_ ||
829  cluster_width < widthLowerLimit_ ||
830  cluster_width > widthUpperLimit_) ) continue;
831 
832  ClusterProperties cluster_properties;
833  cluster_properties.charge = cluster_signal;
834  cluster_properties.position = cluster_position;
835  cluster_properties.start = cluster_start;
836  cluster_properties.width = cluster_width;
837  cluster_properties.noise = cluster_noise;
838 
839  // Fill Module Level MEs
840  if (found_module_me) fillModuleMEs(mod_single, cluster_properties);
841 
842  // Fill Layer Level MEs
843  if (found_layer_me) {
844  fillLayerMEs(layer_single, cluster_properties);
846  layer_single.LayerClusterWidthProfile->Fill(iDet, cluster_width);
847  }
848 
850  {
851  std::map<std::string, SubDetMEs>::iterator iSubdet = SubDetMEsMap.find(subdet_label);
852  if(iSubdet != SubDetMEsMap.end())
853  {
854  if (subdetswitchcluschargeon) iSubdet->second.SubDetClusterChargeTH1->Fill(cluster_signal);
855  if (subdetswitchcluswidthon) iSubdet->second.SubDetClusterWidthTH1->Fill(cluster_width);
856  }
857  }
858 
859 
861  std::map<std::string, SubDetMEs>::iterator iSubdet = SubDetMEsMap.find(subdet_label);
862  if(iSubdet != SubDetMEsMap.end()) iSubdet->second.SubDetClusWidthVsAmpTH2->Fill(cluster_signal, cluster_width);
863  }
864 
866  ClusWidthVsAmpTH2->Fill(cluster_signal, cluster_width);
867  }
868 
869  if (subdetswitchtotclusprofon && (subdet_label.find("TID")!=std::string::npos || subdet_label.find("TEC")!=std::string::npos)){
870  std::pair<std::string,int32_t> det_ring_pair = folder_organizer.GetSubDetAndLayer(detid,tTopo,true);
871  ncluster_ring[std::abs(det_ring_pair.second)] ++ ;
872  }
873 
874  } // end loop over clusters
875 
877  std::map<std::string, SubDetMEs>::iterator iSubdet = SubDetMEsMap.find(subdet_label);
878  std::pair<std::string,int32_t> det_layer_pair = folder_organizer.GetSubDetAndLayer(detid, tTopo);
879  iSubdet->second.SubDetNumberOfClusterPerLayerTrend->Fill(trendVar,std::abs(det_layer_pair.second), ncluster_layer);
880  }
881 
882  if (subdetswitchtotclusprofon && (subdet_label.find("TID")!=std::string::npos || subdet_label.find("TEC")!=std::string::npos)){
883  std::pair<std::string,int32_t> det_ring_pair = folder_organizer.GetSubDetAndLayer(detid,tTopo,true);
884  layer_single.LayerNumberOfClusterPerRingTrend->Fill(trendVar, std::abs(det_ring_pair.second), ncluster_ring[std::abs(det_ring_pair.second)]);
885  }
886 
887  short total_nr_strips = SiStripDetCabling_->nApvPairs(detid) * 2 * 128; // get correct # of avp pairs
888  float local_occupancy = static_cast<float>(total_clusterized_strips)/static_cast<float>(total_nr_strips);
889  if (found_module_me) {
890  if(moduleswitchnrclusterizedstrip && mod_single.NrOfClusterizedStrips ){ // nr of clusterized strips
891  mod_single.NrOfClusterizedStrips->Fill(static_cast<float>(total_clusterized_strips));
892  }
893 
894  if(moduleswitchlocaloccupancy && mod_single.ModuleLocalOccupancy ){ // Occupancy
895  mod_single.ModuleLocalOccupancy->Fill(local_occupancy);
896  }
897  }
898  if (layerswitchlocaloccupancy && found_layer_me && layer_single.LayerLocalOccupancy) {
899  fillME(layer_single.LayerLocalOccupancy,local_occupancy);
900  if (createTrendMEs)
901  fillME(layer_single.LayerLocalOccupancyTrend,trendVar,local_occupancy);
902  }
903  }
904 
906  fillME(layer_single.LayerNumberOfClusterTrend,trendVar,ncluster_layer);
907 
908  std::map<std::string, SubDetMEs>::iterator iSubdet = SubDetMEsMap.find(subdet_label);
909  if(iSubdet != SubDetMEsMap.end()) iSubdet->second.totNClusters += ncluster_layer;
910  }
911 
912 
913 
914 
915 
916 
917  // EventHistory
918  edm::Handle<EventWithHistory> event_history;
919  iEvent.getByToken(historyProducerToken_,event_history);
920 
921  // Phase of APV
922  edm::Handle<APVCyclePhaseCollection> apv_phase_collection;
923  iEvent.getByToken(apvPhaseProducerToken_,apv_phase_collection);
924 
925  if (event_history.isValid()
926  && !event_history.failedToGet()
927  && apv_phase_collection.isValid()
928  && !apv_phase_collection.failedToGet()) {
929 
930 
931  long long dbx = event_history->deltaBX();
932  long long tbx = event_history->absoluteBX();
933 
934  bool global_histo_filled = false;
935  bool MultiplicityRegion_Vs_APVcycle_filled=false;
936 
937  // plot n 2
940  }
941  // plot n 2
942 
943  for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin();
944  it != SubDetMEsMap.end(); it++) {
945  std::string sdet = it->first;
946  //std::string sdet = sdet_tag.substr(0,sdet_tag.find_first_of("_"));
947  SubDetMEs sdetmes = it->second;
948 
949  int the_phase = APVCyclePhaseCollection::invalid;
950  long long tbx_corr = tbx;
951 
952 
953  if (SubDetPhasePartMap.find(sdet) != SubDetPhasePartMap.end()) the_phase = apv_phase_collection->getPhase(SubDetPhasePartMap[sdet]);
954  if(the_phase==APVCyclePhaseCollection::nopartition ||
957  the_phase=30;
958  //std::cout << " subdet " << it->first << " not valid" << " MR " << MultiplicityRegion <<std::endl;
959  }
960  tbx_corr -= the_phase;
961 
962  long long dbxincycle = event_history->deltaBXinCycle(the_phase);
963  //std::cout<<"dbx in cycle: " << dbxincycle << std::endl;
964  if (globalswitchapvcycledbxth2on && !global_histo_filled) {
965  GlobalApvCycleDBxTH2->Fill(tbx_corr%70,dbx);
966  GlobalDBxTH1->Fill(dbx);
967  GlobalDBxCycleTH1->Fill(dbxincycle);
968  global_histo_filled = true;
969  }
970 
971 
972  // Fill MainDiagonalPosition plots ***************
973  if (cluster_detsetvektor_pix.isValid()){
974  if (ClusterHisto_){
975  if ( passBPTXfilter_ and passStripDCSfilter_ ){
976  NumberOfStripClus_vs_BX->Fill(tbx%3564,NStripClusters);
977  if(passPixelDCSfilter_ ){
978  NumberOfPixelClus_vs_BX->Fill(tbx%3564,NPixClusters);
979  if (globalswitchmaindiagonalposition && NStripClusters > 0){
980  GlobalMainDiagonalPosition_vs_BX->Fill(tbx%3564,atan(NPixClusters/(k0*NStripClusters)));
981  GlobalTH2MainDiagonalPosition_vs_BX->Fill(tbx%3564,atan(NPixClusters/(k0*NStripClusters)));
982  }
983  }
984 
985  }
986 
987  //Filling # clusters per FED ID histogram from FED Id clusters map (for all layers simultaneously).
988  map<int,int>::iterator it;
989  //for(it=FEDID_v_clustersum.begin(); it!=FEDID_v_clustersum.end(); it++){
990  for ( auto const & fedidEntry : FEDID_v_clustersum ) {
991  //NumberOfFEDClus->Fill(it->first,it->second);
992  NumberOfFEDClus->Fill(fedidEntry.first,fedidEntry.second);
993  //if(it->first < 100){
994  // Trend_NumberOfFEDClus->Fill(trendVar,it->first,it->second);
995  //}
996  }
997  FEDID_v_clustersum.clear();
998 
999  }
1000  }
1001 
1002  if (isPixValid && !MultiplicityRegion_Vs_APVcycle_filled){
1003  if (globalswitchstripnoise2apvcycle && MultiplicityRegion==2) {StripNoise2Cycle->Fill(tbx_corr%70);}
1004  if (globalswitchstripnoise3apvcycle && MultiplicityRegion==3) {StripNoise3Cycle->Fill(tbx_corr%70);}
1005  MultiplicityRegion_Vs_APVcycle_filled=true;
1006  }
1007 
1009  sdetmes.SubDetTotClusterTH1->Fill(sdetmes.totNClusters);
1011  sdetmes.SubDetTotClusterProf->Fill(trendVar,sdetmes.totNClusters);
1013  sdetmes.SubDetClusterApvProf->Fill(tbx_corr%70,sdetmes.totNClusters);
1015  sdetmes.SubDetClusterApvTH2->Fill(tbx_corr%70,sdetmes.totNClusters);
1017  sdetmes.SubDetClusterDBxCycleProf->Fill(dbxincycle,sdetmes.totNClusters);
1018  }
1020  sdetmes.SubDetApvDBxProf2->Fill(tbx_corr%70,dbx,sdetmes.totNClusters);
1021  }
1022 
1024  {
1025  long long tbx_corr = tbx;
1026  int the_phase = apv_phase_collection->getPhase("All");
1027 
1028  if( the_phase == APVCyclePhaseCollection::nopartition ||
1029  the_phase == APVCyclePhaseCollection::multiphase ||
1030  the_phase == APVCyclePhaseCollection::invalid )
1031  the_phase=30;
1032 
1033  tbx_corr -= the_phase;
1034 
1035  NclusVsCycleTimeProf2D->Fill( tbx_corr%70 , (int)event_history->_orbit , NStripClusters );
1036  }
1037  }
1038 }
1039 //
1040 // -- Reset MEs
1041 //------------------------------------------------------------------------------
1043  std::map<uint32_t, ModMEs >::iterator pos = ModuleMEsMap.find(idet);
1044  ModMEs mod_me = pos->second;
1045 
1057 }
1058 //
1059 // -- Create Module Level MEs
1060 //
1061 void SiStripMonitorCluster::createModuleMEs(ModMEs& mod_single, uint32_t detid , DQMStore::IBooker & ibooker) {
1062 
1063  // use SistripHistoId for producing histogram id (and title)
1064  SiStripHistoId hidmanager;
1065  std::string hid;
1066 
1067  //nr. of clusters per module
1068  if(moduleswitchncluson) {
1069  hid = hidmanager.createHistoId("NumberOfClusters","det",detid);
1070  mod_single.NumberOfClusters = bookME1D("TH1nClusters", hid.c_str() , ibooker);
1071  ibooker.tag(mod_single.NumberOfClusters, detid);
1072  mod_single.NumberOfClusters->setAxisTitle("number of clusters in one detector module");
1073  mod_single.NumberOfClusters->getTH1()->StatOverflows(kTRUE); // over/underflows in Mean calculation
1074  }
1075 
1076  //ClusterPosition
1077  if(moduleswitchclusposon) {
1078  short total_nr_strips = SiStripDetCabling_->nApvPairs(detid) * 2 * 128; // get correct # of avp pairs
1079  hid = hidmanager.createHistoId("ClusterPosition","det",detid);
1080  mod_single.ClusterPosition = ibooker.book1D(hid, hid, total_nr_strips, 0.5, total_nr_strips+0.5);
1081  ibooker.tag(mod_single.ClusterPosition, detid);
1082  mod_single.ClusterPosition->setAxisTitle("cluster position [strip number +0.5]");
1083  }
1084 
1085  //ClusterDigiPosition
1087  short total_nr_strips = SiStripDetCabling_->nApvPairs(detid) * 2 * 128; // get correct # of avp pairs
1088  hid = hidmanager.createHistoId("ClusterDigiPosition","det",detid);
1089  mod_single.ClusterDigiPosition = ibooker.book1D(hid, hid, total_nr_strips, 0.5, total_nr_strips+0.5);
1090  ibooker.tag(mod_single.ClusterDigiPosition, detid);
1091  mod_single.ClusterDigiPosition->setAxisTitle("digi in cluster position [strip number +0.5]");
1092  }
1093 
1094  //ClusterWidth
1096  hid = hidmanager.createHistoId("ClusterWidth","det",detid);
1097  mod_single.ClusterWidth = bookME1D("TH1ClusterWidth", hid.c_str() , ibooker);
1098  ibooker.tag(mod_single.ClusterWidth, detid);
1099  mod_single.ClusterWidth->setAxisTitle("cluster width [nr strips]");
1100  }
1101 
1102  //ClusterCharge
1104  hid = hidmanager.createHistoId("ClusterCharge","det",detid);
1105  mod_single.ClusterCharge = bookME1D("TH1ClusterCharge", hid.c_str() , ibooker );
1106  ibooker.tag(mod_single.ClusterCharge, detid);
1107  mod_single.ClusterCharge->setAxisTitle("cluster charge [ADC]");
1108  }
1109 
1110  //ClusterNoise
1112  hid = hidmanager.createHistoId("ClusterNoise","det",detid);
1113  mod_single.ClusterNoise = bookME1D("TH1ClusterNoise", hid.c_str() , ibooker );
1114  ibooker.tag(mod_single.ClusterNoise, detid);
1115  mod_single.ClusterNoise->setAxisTitle("cluster noise");
1116  }
1117 
1118  //ClusterSignalOverNoise
1120  hid = hidmanager.createHistoId("ClusterSignalOverNoise","det",detid);
1121  mod_single.ClusterSignalOverNoise = bookME1D("TH1ClusterStoN", hid.c_str() , ibooker);
1122  ibooker.tag(mod_single.ClusterSignalOverNoise, detid);
1123  mod_single.ClusterSignalOverNoise->setAxisTitle("ratio of signal to noise for each cluster");
1124  }
1125 
1126  //ClusterSignalOverNoiseVsPos
1128  hid = hidmanager.createHistoId("ClusterSignalOverNoiseVsPos","det",detid);
1129  Parameters = conf_.getParameter<edm::ParameterSet>("TH1ClusterStoNVsPos");
1130  mod_single.ClusterSignalOverNoiseVsPos= ibooker.bookProfile(hid.c_str(),hid.c_str(),
1131  Parameters.getParameter<int32_t>("Nbinx"),
1132  Parameters.getParameter<double>("xmin"),
1133  Parameters.getParameter<double>("xmax"),
1134  Parameters.getParameter<int32_t>("Nbiny"),
1135  Parameters.getParameter<double>("ymin"),
1136  Parameters.getParameter<double>("ymax")
1137  );
1138  ibooker.tag(mod_single.ClusterSignalOverNoiseVsPos, detid);
1139  mod_single.ClusterSignalOverNoiseVsPos->setAxisTitle("pos");
1140  }
1141 
1142  //ModuleLocalOccupancy
1144  hid = hidmanager.createHistoId("ClusterLocalOccupancy","det",detid);
1145  mod_single.ModuleLocalOccupancy = bookME1D("TH1ModuleLocalOccupancy", hid.c_str() , ibooker);
1146  ibooker.tag(mod_single.ModuleLocalOccupancy, detid);
1147  mod_single.ModuleLocalOccupancy->setAxisTitle("module local occupancy [% of clusterized strips]");
1148  }
1149 
1150  //NrOfClusterizedStrips
1152  hid = hidmanager.createHistoId("NrOfClusterizedStrips","det",detid);
1153  mod_single.NrOfClusterizedStrips = bookME1D("TH1NrOfClusterizedStrips", hid.c_str() , ibooker );
1154  ibooker.tag(mod_single.NrOfClusterizedStrips, detid);
1155  mod_single.NrOfClusterizedStrips->setAxisTitle("number of clusterized strips");
1156  }
1157 
1159  hid = hidmanager.createHistoId("ClusterWidths_vs_Amplitudes","det",detid);
1160  Parameters = conf_.getParameter<edm::ParameterSet>("ClusWidthVsAmpTH2");
1161  int32_t Nbinsx = Parameters.getParameter<int32_t>("Nbinsx");
1162  Nbinsx = Nbinsx/2; //Without this "rebinning" the job is killed on lxplus. We think it's due to the high memory needed to create all those histograms.
1163  mod_single.Module_ClusWidthVsAmpTH2 = ibooker.book2D(hid.c_str() , hid.c_str(),
1164  Nbinsx,
1165  Parameters.getParameter<double>("xmin"),
1166  Parameters.getParameter<double>("xmax"),
1167  Parameters.getParameter<int32_t>("Nbinsy"),
1168  Parameters.getParameter<double>("ymin"),
1169  Parameters.getParameter<double>("ymax")
1170  );
1171  ibooker.tag(mod_single.Module_ClusWidthVsAmpTH2, detid);
1172  mod_single.Module_ClusWidthVsAmpTH2->setAxisTitle("Amplitudes (integrated ADC counts)",1);
1173  mod_single.Module_ClusWidthVsAmpTH2->setAxisTitle("Cluster widths",2);
1174  }
1175 
1176 }
1177 //
1178 // -- Create Module Level MEs
1179 //
1181 
1182  SiStripHistoId hidmanager;
1183 
1184  LayerMEs layerMEs;
1185  layerMEs.LayerClusterStoN = 0;
1186  layerMEs.LayerClusterStoNTrend = 0;
1187  layerMEs.LayerClusterCharge = 0;
1188  layerMEs.LayerClusterChargeTrend = 0;
1189  layerMEs.LayerClusterNoise = 0;
1190  layerMEs.LayerClusterNoiseTrend = 0;
1191  layerMEs.LayerClusterWidth = 0;
1192  layerMEs.LayerClusterWidthTrend = 0;
1193  layerMEs.LayerLocalOccupancy = 0;
1194  layerMEs.LayerLocalOccupancyTrend = 0;
1195  layerMEs.LayerNumberOfClusterProfile = 0;
1196  layerMEs.LayerNumberOfClusterTrend = 0;
1197  layerMEs.LayerNumberOfClusterPerRingTrend = 0;
1198  layerMEs.LayerClusterWidthProfile = 0;
1199  layerMEs.LayerClusWidthVsAmpTH2 = 0;
1200  layerMEs.LayerClusterPosition = 0;
1201 
1202  //Cluster Width
1204  layerMEs.LayerClusterWidth=bookME1D("TH1ClusterWidth", hidmanager.createHistoLayer("Summary_ClusterWidth","layer",label,"").c_str() , ibooker );
1205  if (createTrendMEs)
1206  layerMEs.LayerClusterWidthTrend=bookMETrend(hidmanager.createHistoLayer("Trend_ClusterWidth","layer",label,"").c_str() , ibooker );
1207  }
1208 
1209  //Cluster Noise
1211  layerMEs.LayerClusterNoise=bookME1D("TH1ClusterNoise", hidmanager.createHistoLayer("Summary_ClusterNoise","layer",label,"").c_str() , ibooker );
1212  if (createTrendMEs)
1213  layerMEs.LayerClusterNoiseTrend=bookMETrend(hidmanager.createHistoLayer("Trend_ClusterNoise","layer",label,"").c_str() , ibooker);
1214  }
1215 
1216  //Cluster Charge
1218  layerMEs.LayerClusterCharge=bookME1D("TH1ClusterCharge", hidmanager.createHistoLayer("Summary_ClusterCharge","layer",label,"").c_str() , ibooker );
1219  if (createTrendMEs)
1220  layerMEs.LayerClusterChargeTrend=bookMETrend(hidmanager.createHistoLayer("Trend_ClusterCharge","layer",label,"").c_str(),ibooker);
1221  }
1222 
1223  //Cluster StoN
1224  if(layerswitchclusstonon) {
1225  layerMEs.LayerClusterStoN=bookME1D("TH1ClusterStoN", hidmanager.createHistoLayer("Summary_ClusterSignalOverNoise","layer",label,"").c_str() , ibooker );
1226  if (createTrendMEs)
1227  layerMEs.LayerClusterStoNTrend=bookMETrend(hidmanager.createHistoLayer("Trend_ClusterSignalOverNoise","layer",label,"").c_str(),ibooker);
1228  }
1229 
1230  //Cluster Occupancy
1232  layerMEs.LayerLocalOccupancy=bookME1D("TH1ModuleLocalOccupancy", hidmanager.createHistoLayer("Summary_ClusterLocalOccupancy","layer",label,"").c_str() , ibooker );
1233  if (createTrendMEs)
1234  layerMEs.LayerLocalOccupancyTrend=bookMETrend(hidmanager.createHistoLayer("Trend_ClusterLocalOccupancy","layer",label,"").c_str(),ibooker);
1235  }
1236 
1237  // # of Cluster Profile
1239  std::string hid = hidmanager.createHistoLayer("NumberOfClusterProfile","layer",label,"");
1240  layerMEs.LayerNumberOfClusterProfile = ibooker.bookProfile(hid, hid, ndets, 0.5, ndets+0.5,21, -0.5, 20.5);
1241  }
1242 
1243  // # of Cluster Trend
1245  layerMEs.LayerNumberOfClusterTrend = bookMETrend(hidmanager.createHistoLayer("NumberOfClusterTrend","layer",label,"").c_str(),ibooker);
1246 
1247  if (label.find("TID")!=std::string::npos || label.find("TEC")!=std::string::npos){
1248  edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("NumberOfClusterPerRingVsTrendVar");
1249 
1250  layerMEs.LayerNumberOfClusterPerRingTrend = ibooker.bookProfile2D("NumberOfClusterPerRingVsTrendVar", hidmanager.createHistoLayer("NumberOfClusterPerRing_vs_TrendVar","layer",label,"").c_str(),
1251  Parameters.getParameter<int32_t>("Nbinsx"),
1252  Parameters.getParameter<double>("xmin"),
1253  Parameters.getParameter<double>("xmax"),
1254  Parameters.getParameter<int32_t>("Nbinsy"),
1255  Parameters.getParameter<double>("ymin"),
1256  Parameters.getParameter<double>("ymax"), 0, 0, "" );
1257 
1258 
1259  }
1260  }
1261 
1262  // Cluster Width Profile
1264  std::string hid = hidmanager.createHistoLayer("ClusterWidthProfile","layer",label,"");
1265  layerMEs.LayerClusterWidthProfile = ibooker.bookProfile(hid, hid, ndets, 0.5, ndets+0.5, 20, -0.5, 19.5);
1266  }
1267 
1269  layerMEs.LayerClusWidthVsAmpTH2=bookME2D("ClusWidthVsAmpTH2", hidmanager.createHistoLayer("ClusterWidths_vs_Amplitudes","layer",label,"").c_str() , ibooker );
1270  }
1271 
1272  // Cluster Position
1273  if (layerswitchclusposon) {
1274  std::string hid = hidmanager.createHistoLayer("ClusterPosition","layer",label,"");
1275  layerMEs.LayerClusterPosition=ibooker.book1D(hid, hid, 128*6, 0.5, 128*6+0.5);
1276  }
1277 
1278  LayerMEsMap[label]=layerMEs;
1279 }
1280 //
1281 // -- Create SubDetector MEs
1282 //
1284 
1285  SubDetMEs subdetMEs;
1286  subdetMEs.totNClusters = 0;
1287  subdetMEs.SubDetTotClusterTH1 = 0;
1288  subdetMEs.SubDetTotClusterProf = 0;
1289  subdetMEs.SubDetClusterApvProf = 0;
1290  subdetMEs.SubDetClusterApvTH2 = 0;
1291  subdetMEs.SubDetClusterDBxCycleProf = 0;
1292  subdetMEs.SubDetApvDBxProf2 = 0;
1293  subdetMEs.SubDetClusterChargeTH1 = 0;
1294  subdetMEs.SubDetClusterWidthTH1 = 0;
1295  subdetMEs.SubDetClusWidthVsAmpTH2 = 0;
1296  subdetMEs.SubDetNumberOfClusterPerLayerTrend = 0;
1297 
1299  // cluster charge
1301  HistoName = "ClusterCharge__" + label;
1302  subdetMEs.SubDetClusterChargeTH1 = bookME1D("TH1ClusterCharge",HistoName.c_str() , ibooker);
1303  subdetMEs.SubDetClusterChargeTH1->setAxisTitle("Cluster charge [ADC counts]");
1304  subdetMEs.SubDetClusterChargeTH1->getTH1()->StatOverflows(kTRUE); // over/underflows in Mean calculation
1305  }
1306  // cluster width
1308  HistoName = "ClusterWidth__" + label;
1309  subdetMEs.SubDetClusterWidthTH1 = bookME1D("TH1ClusterWidth",HistoName.c_str() , ibooker);
1310  subdetMEs.SubDetClusterWidthTH1->setAxisTitle("Cluster width [strips]");
1311  subdetMEs.SubDetClusterWidthTH1->getTH1()->StatOverflows(kTRUE); // over/underflows in Mean calculation
1312  }
1313  // Total Number of Cluster - 1D
1315  HistoName = "TotalNumberOfCluster__" + label;
1316  subdetMEs.SubDetTotClusterTH1 = bookME1D("TH1TotalNumberOfClusters",HistoName.c_str() , ibooker);
1317  subdetMEs.SubDetTotClusterTH1->setAxisTitle("Total number of clusters in subdetector");
1318  subdetMEs.SubDetTotClusterTH1->getTH1()->StatOverflows(kTRUE); // over/underflows in Mean calculation
1319  }
1320  // Total Number of Cluster vs Time - Profile
1323  HistoName = "TotalNumberOfClusterProfile__" + label;
1324  subdetMEs.SubDetTotClusterProf = ibooker.bookProfile(HistoName,HistoName,
1325  Parameters.getParameter<int32_t>("Nbins"),
1326  Parameters.getParameter<double>("xmin"),
1327  Parameters.getParameter<double>("xmax"),
1328  0 , 0 , "" );
1329  subdetMEs.SubDetTotClusterProf->setAxisTitle(Parameters.getParameter<std::string>("xaxis"),1);
1330  if (subdetMEs.SubDetTotClusterProf->kind() == MonitorElement::DQM_KIND_TPROFILE) subdetMEs.SubDetTotClusterProf->getTH1()->SetCanExtend(TH1::kAllAxes);
1331 
1332  Parameters = conf_.getParameter<edm::ParameterSet>("NumberOfClusterPerLayerTrendVar");
1333  HistoName = "TotalNumberOfClusterPerLayer__" + label;
1334  subdetMEs.SubDetNumberOfClusterPerLayerTrend = ibooker.bookProfile2D("NumberOfClusterPerLayerTrendVar", HistoName.c_str(),
1335  Parameters.getParameter<int32_t>("Nbinsx"),
1336  Parameters.getParameter<double>("xmin"),
1337  Parameters.getParameter<double>("xmax"),
1338  Parameters.getParameter<int32_t>("Nbinsy"),
1339  Parameters.getParameter<double>("ymin"),
1340  Parameters.getParameter<double>("ymax"), 0, 0, "" );
1341  subdetMEs.SubDetNumberOfClusterPerLayerTrend->setAxisTitle("Lumisection",1);
1342  subdetMEs.SubDetNumberOfClusterPerLayerTrend->setAxisTitle("Layer Number",2);
1343  }
1344 
1345  // Total Number of Cluster vs APV cycle - Profile
1347  edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TProfClustersApvCycle");
1348  HistoName = "Cluster_vs_ApvCycle__" + label;
1349  subdetMEs.SubDetClusterApvProf=ibooker.bookProfile(HistoName,HistoName,
1350  Parameters.getParameter<int32_t>("Nbins"),
1351  Parameters.getParameter<double>("xmin"),
1352  Parameters.getParameter<double>("xmax"),
1353  200, //that parameter should not be there !?
1354  Parameters.getParameter<double>("ymin"),
1355  Parameters.getParameter<double>("ymax"),
1356  "" );
1357  subdetMEs.SubDetClusterApvProf->setAxisTitle("Apv Cycle (Corrected Absolute Bx % 70)",1);
1358  }
1359 
1360  // Total Number of Clusters vs ApvCycle - 2D
1363  HistoName = "Cluster_vs_ApvCycle_2D__" + label;
1364  // Adjusting the scale for 2D histogram
1365  double h2ymax = 9999.0;
1366  double yfact = Parameters.getParameter<double>("yfactor");
1367  if(label.find("TIB") != std::string::npos) h2ymax = (6984.*256.)*yfact;
1368  else if (label.find("TID") != std::string::npos) h2ymax = (2208.*256.)*yfact;
1369  else if (label.find("TOB") != std::string::npos) h2ymax = (12906.*256.)*yfact;
1370  else if (label.find("TEC") != std::string::npos) h2ymax = (7552.*2.*256.)*yfact;
1371 
1372  subdetMEs.SubDetClusterApvTH2=ibooker.book2D(HistoName,HistoName,
1373  Parameters.getParameter<int32_t>("Nbinsx"),
1374  Parameters.getParameter<double>("xmin"),
1375  Parameters.getParameter<double>("xmax"),
1376  Parameters.getParameter<int32_t>("Nbinsy"),
1377  Parameters.getParameter<double>("ymin"),
1378  h2ymax);
1379  subdetMEs.SubDetClusterApvTH2->setAxisTitle("Apv Cycle (Corrected Absolute Bx % 70))",1);
1380  subdetMEs.SubDetClusterApvTH2->setAxisTitle("Total # of Clusters",2);
1381 
1382  }
1383 
1384  // Cluster widths vs amplitudes - 2D
1387  HistoName = "ClusterWidths_vs_Amplitudes__" + label;
1388  subdetMEs.SubDetClusWidthVsAmpTH2=ibooker.book2D(HistoName,HistoName,
1389  Parameters.getParameter<int32_t>("Nbinsx"),
1390  Parameters.getParameter<double>("xmin"),
1391  Parameters.getParameter<double>("xmax"),
1392  Parameters.getParameter<int32_t>("Nbinsy"),
1393  Parameters.getParameter<double>("ymin"),
1394  Parameters.getParameter<double>("ymax"));
1395  subdetMEs.SubDetClusWidthVsAmpTH2->setAxisTitle("Amplitudes (integrated ADC counts)",1);
1396  subdetMEs.SubDetClusWidthVsAmpTH2->setAxisTitle("Cluster widths",2);
1397 
1398  }
1399 
1400 
1401 
1402  // Total Number of Cluster vs DeltaBxCycle - Profile
1404  edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TProfClustersVsDBxCycle");
1405  HistoName = "Cluster_vs_DeltaBxCycle__" + label;
1406  subdetMEs.SubDetClusterDBxCycleProf = ibooker.bookProfile(HistoName,HistoName,
1407  Parameters.getParameter<int32_t>("Nbins"),
1408  Parameters.getParameter<double>("xmin"),
1409  Parameters.getParameter<double>("xmax"),
1410  200, //that parameter should not be there !?
1411  Parameters.getParameter<double>("ymin"),
1412  Parameters.getParameter<double>("ymax"),
1413  "" );
1414  subdetMEs.SubDetClusterDBxCycleProf->setAxisTitle("Delta Bunch Crossing Cycle",1);
1415  }
1416  // DeltaBx vs ApvCycle - 2DProfile
1419  HistoName = "DeltaBx_vs_ApvCycle__" + label;
1420  subdetMEs.SubDetApvDBxProf2 = ibooker.bookProfile2D(HistoName,HistoName,
1421  Parameters.getParameter<int32_t>("Nbinsx"),
1422  Parameters.getParameter<double>("xmin"),
1423  Parameters.getParameter<double>("xmax"),
1424  Parameters.getParameter<int32_t>("Nbinsy"),
1425  Parameters.getParameter<double>("ymin"),
1426  Parameters.getParameter<double>("ymax"),
1427  Parameters.getParameter<double>("zmin"),
1428  Parameters.getParameter<double>("zmax"),
1429  "" );
1430  subdetMEs.SubDetApvDBxProf2->setAxisTitle("APV Cycle (Corrected Absolute Bx % 70)",1);
1431  subdetMEs.SubDetApvDBxProf2->setAxisTitle("Delta Bunch Crossing Cycle",2);
1432  }
1433  SubDetMEsMap[label]=subdetMEs;
1434 }
1435 
1436 //
1437 // -- Fill Module Level Histograms
1438 //
1440 
1441  if(moduleswitchclusposon && (mod_mes.ClusterPosition)) // position of cluster
1442  (mod_mes.ClusterPosition)->Fill(cluster.position);
1443 
1444  // position of digis in cluster
1446  for(int ipos=cluster.start+1; ipos<=cluster.start+cluster.width; ipos++){
1447  (mod_mes.ClusterDigiPosition)->Fill(ipos);
1448  }
1449  }
1450 
1451  if(moduleswitchcluswidthon && (mod_mes.ClusterWidth)) // width of cluster
1452  (mod_mes.ClusterWidth)->Fill(static_cast<float>(cluster.width));
1453 
1454  if(moduleswitchclusstonon && (mod_mes.ClusterSignalOverNoise)) {// SignalToNoise
1455  if (cluster.noise > 0)
1456  (mod_mes.ClusterSignalOverNoise)->Fill(cluster.charge/cluster.noise);
1457  }
1458 
1459  if(moduleswitchclusstonVsposon && (mod_mes.ClusterSignalOverNoiseVsPos)) {// SignalToNoise
1460  if (cluster.noise > 0)
1461  (mod_mes.ClusterSignalOverNoiseVsPos)->Fill(cluster.position,cluster.charge/cluster.noise);
1462  }
1463 
1464  if(moduleswitchclusnoiseon && (mod_mes.ClusterNoise)) // Noise
1465  (mod_mes.ClusterNoise)->Fill(cluster.noise);
1466 
1467  if(moduleswitchcluschargeon && (mod_mes.ClusterCharge)) // charge of cluster
1468  (mod_mes.ClusterCharge)->Fill(cluster.charge);
1469 
1471 }
1472 //
1473 // -- Fill Layer Level MEs
1474 //
1476 
1477  if(layerswitchclusstonon) {
1478  fillME(layerMEs.LayerClusterStoN ,cluster.charge/cluster.noise);
1479  if (createTrendMEs) {
1480  fillME(layerMEs.LayerClusterStoNTrend,trendVar,cluster.charge/cluster.noise);
1481  }
1482  }
1483 
1485  fillME(layerMEs.LayerClusterCharge,cluster.charge);
1486  if (createTrendMEs) {
1487  fillME(layerMEs.LayerClusterChargeTrend,trendVar,cluster.charge);
1488  }
1489  }
1490 
1492  fillME(layerMEs.LayerClusterNoise ,cluster.noise);
1493  if (createTrendMEs) {
1494  fillME(layerMEs.LayerClusterNoiseTrend,trendVar,cluster.noise);
1495  }
1496  }
1497 
1499  fillME(layerMEs.LayerClusterWidth ,cluster.width);
1500  if (createTrendMEs) {
1501  fillME(layerMEs.LayerClusterWidthTrend,trendVar,cluster.width);
1502  }
1503  }
1504 
1506  fillME(layerMEs.LayerClusWidthVsAmpTH2, cluster.charge, cluster.width);
1507  }
1508 
1509  if (layerswitchclusposon) {
1510  fillME(layerMEs.LayerClusterPosition,cluster.position);
1511  }
1512 }
1513 //------------------------------------------------------------------------------------------
1515 {
1516  edm::ParameterSet ParametersTrend = trendVsLs_ ? conf_.getParameter<edm::ParameterSet>("TrendingLS") : conf_.getParameter<edm::ParameterSet>("Trending");
1517  MonitorElement* me = ibooker.bookProfile(HistoName,HistoName,
1518  ParametersTrend.getParameter<int32_t>("Nbins"),
1519  ParametersTrend.getParameter<double>("xmin"),
1520  ParametersTrend.getParameter<double>("xmax"),
1521  0 , 0 , "" );
1522  if(!me) return me;
1523  me->setAxisTitle(ParametersTrend.getParameter<std::string>("xaxis"),1);
1524  if (me->kind() == MonitorElement::DQM_KIND_TPROFILE) me->getTH1()->SetCanExtend(TH1::kAllAxes);
1525  return me;
1526 }
1527 
1528 //------------------------------------------------------------------------------------------
1529 MonitorElement* SiStripMonitorCluster::bookME1D(const char* ParameterSetLabel, const char* HistoName , DQMStore::IBooker & ibooker)
1530 {
1531  Parameters = conf_.getParameter<edm::ParameterSet>(ParameterSetLabel);
1532  return ibooker.book1D(HistoName,HistoName,
1533  Parameters.getParameter<int32_t>("Nbinx"),
1534  Parameters.getParameter<double>("xmin"),
1535  Parameters.getParameter<double>("xmax")
1536  );
1537 }
1538 
1539 //------------------------------------------------------------------------------------------
1540 MonitorElement* SiStripMonitorCluster::bookME2D(const char* ParameterSetLabel, const char* HistoName , DQMStore::IBooker & ibooker)
1541 {
1542  Parameters = conf_.getParameter<edm::ParameterSet>(ParameterSetLabel);
1543  return ibooker.book2D(HistoName,HistoName,
1544  Parameters.getParameter<int32_t>("Nbinsx"),
1545  Parameters.getParameter<double>("xmin"),
1546  Parameters.getParameter<double>("xmax"),
1547  Parameters.getParameter<int32_t>("Nbinsy"),
1548  Parameters.getParameter<double>("ymin"),
1549  Parameters.getParameter<double>("ymax")
1550  );
1551 }
1552 
1553 
1554 int SiStripMonitorCluster::FindRegion(int nstrip,int npix){
1555 
1556  double kplus= k0*(1+dk0/100);
1557  double kminus=k0*(1-dk0/100);
1558  int region=0;
1559 
1560  if (nstrip!=0 && npix >= (nstrip*kminus-q0) && npix <=(nstrip*kplus+q0)) region=1;
1561  else if (nstrip!=0 && npix < (nstrip*kminus-q0) && nstrip <= maxClus) region=2;
1562  else if (nstrip!=0 && npix < (nstrip*kminus-q0) && nstrip > maxClus) region=3;
1563  else if (nstrip!=0 && npix > (nstrip*kplus+q0)) region=4;
1564  else if (npix > minPix && nstrip==0) region=5;
1565  return region;
1566 
1567 }
RunNumber_t run() const
Definition: EventID.h:39
MonitorElement * GlobalABXTH1_CSCP
void ResetModuleMEs(uint32_t idet)
T getParameter(std::string const &) const
MonitorElement * bookME1D(const char *ParameterSetLabel, const char *HistoName, DQMStore::IBooker &ibooker)
int FindRegion(int nstrip, int npixel)
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
MonitorElement * NumberOfPixelClus_vs_BX
void addActiveDetectorsRawIds(std::vector< uint32_t > &) const
void setSiStripFolderName(std::string name)
long long deltaBX(const unsigned int ev2, const unsigned int ev1) const
MonitorElement * PixVsStripMultiplicityRegions
std::pair< const std::string, const char * > getSubDetFolderAndTag(const uint32_t &detid, const TrackerTopology *tTopo)
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:157
MonitorElement * GlobalTH2MainDiagonalPosition_vs_BX
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
MonitorElement * GlobalCStripVsCpix
bool IsStripBad(const uint32_t &detid, const short &strip) const
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
long long absoluteBX(const unsigned int ev1) const
edm::ESHandle< SiStripDetCabling > SiStripDetCabling_
#define NULL
Definition: scimark2.h:8
MonitorElement * ClusterSignalOverNoiseVsPos
void setLayerFolder(uint32_t rawdetid, const TrackerTopology *tTopo, int32_t layer=0, bool ring_flag=false)
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
MonitorElement * StripNoise2Cycle
data_type const * const_iterator
Definition: DetSetNew.h:30
void createLayerMEs(std::string label, int ndets, DQMStore::IBooker &ibooker)
std::map< std::string, LayerMEs > LayerMEsMap
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
bool isRealData() const
Definition: EventBase.h:64
std::map< std::string, std::vector< uint32_t > > LayerDetMap
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
void Fill(long long x)
MonitorElement * NumberOfPixelClus
void setDetectorFolder(uint32_t rawdetid, const TrackerTopology *tTopo)
unsigned long long m_cacheID_
void createSubDetMEs(std::string label, DQMStore::IBooker &ibooker)
const std::vector< const FedChannelConnection * > & getConnections(uint32_t det_id) const
std::map< uint32_t, ModMEs > ModuleMEsMap
bool getStatus(edm::Event const &e, edm::EventSetup const &eSetup)
static float getNoise(uint16_t strip, const Range &range)
Definition: SiStripNoises.h:72
int iEvent
Definition: GenABIO.cc:230
void createMEs(const edm::EventSetup &es, DQMStore::IBooker &ibooker)
std::map< std::string, std::string > SubDetPhasePartMap
MonitorElement * GlobalApvCycleDBxTH2
const int getPhase(const std::string partition) const
vector< ParameterSet > Parameters
void getTOBDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tobDetRawIds, uint32_t layer=0, uint32_t bkw_frw=0, uint32_t rod=0) const
static float getStripGain(const uint16_t &strip, const SiStripApvGain::Range &range)
Definition: SiStripGain.h:68
MonitorElement * bookProfile2D(Args &&...args)
Definition: DQMStore.h:163
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
GenericTriggerEventFlag * genTriggerEventFlagPixelDCSfilter_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
T sqrt(T t)
Definition: SSEVec.h:18
void fill(uint32_t &detid, float value)
Definition: TkHistoMap.cc:180
bool accept(const edm::Event &event, const edm::EventSetup &setup)
To be called from analyze/filter() methods.
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
bool empty() const
Definition: DetSetNew.h:90
data_type const * data(size_t cell) const
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
void tag(MonitorElement *, unsigned int)
Definition: DQMStore.cc:289
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::pair< ContainerIterator, ContainerIterator > Range
MonitorElement * bookMETrend(const char *, DQMStore::IBooker &ibooker)
TH1 * getTH1(void) const
int orbitNumber() const
Definition: EventBase.h:67
MonitorElement * NumberOfStripClus
Kind kind(void) const
Get the type of the monitor element.
std::string getSubdetid(uint32_t id, const TrackerTopology *tTopo, bool flag_ring)
MonitorElement * GlobalMainDiagonalPosition_vs_BX
bool isValid() const
Definition: HandleBase.h:74
MonitorElement * NumberOfStripClus_vs_BX
edm::EDGetTokenT< EventWithHistory > historyProducerToken_
MonitorElement * ClusWidthVsAmpTH2
MonitorElement * GlobalMainDiagonalPosition
MonitorElement * bookME2D(const char *ParameterSetLabel, const char *HistoName, DQMStore::IBooker &ibooker)
SiStripDCSStatus * dcsStatus_
bool failedToGet() const
Definition: HandleBase.h:78
GenericTriggerEventFlag * genTriggerEventFlagBPTXfilter_
MonitorElement * LayerNumberOfClusterPerRingTrend
void fillME(MonitorElement *ME, float value1)
SiStripMonitorCluster(const edm::ParameterSet &)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
T const * product() const
Definition: Handle.h:81
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
std::string createHistoId(std::string description, std::string id_type, uint32_t component_id)
const T & get() const
Definition: EventSetup.h:55
MonitorElement * NumberOfFEDClus
std::string HistoName
MonitorElement * StripNoise3Cycle
std::pair< std::string, int32_t > GetSubDetAndLayer(const uint32_t &detid, const TrackerTopology *tTopo, bool ring_flag=false)
void createModuleMEs(ModMEs &mod_single, uint32_t detid, DQMStore::IBooker &ibooker)
void getTECDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tecDetRawIds, uint32_t side=0, uint32_t wheel=0, uint32_t petal_bkw_frw=0, uint32_t petal=0, uint32_t ring=0, uint32_t ster=0) const
long long deltaBXinCycle(const unsigned int ev2, const unsigned int ev1, const int bx0) const
const uint16_t nApvPairs(uint32_t det_id) const
edm::EventID id() const
Definition: EventBase.h:60
const Range getRange(const uint32_t detID) const
iterator end()
Definition: DetSetNew.h:70
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > clusterProducerPixToken_
std::map< std::string, SubDetMEs > SubDetMEsMap
const Range getRange(const uint32_t detID) const
void fillLayerMEs(LayerMEs &, ClusterProperties &cluster)
std::pair< ContainerIterator, ContainerIterator > Range
void getTIBDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tibDetRawIds, uint32_t layer=0, uint32_t bkw_frw=0, uint32_t int_ext=0, uint32_t string=0) const
unsigned int _orbit
Definition: TinyEvent.h:88
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > clusterProducerStripToken_
void getTIDDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tidDetRawIds, uint32_t side=0, uint32_t wheel=0, uint32_t ring=0, uint32_t ster=0) const
void initRun(const edm::Run &run, const edm::EventSetup &setup)
To be called from beginRun() methods.
std::string createHistoLayer(std::string description, std::string id_type, std::string path, std::string flag)
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripNoises.h:48
size_type size() const
Definition: DetSetNew.h:87
MonitorElement * GlobalDBxCycleTH1
edm::EDGetTokenT< APVCyclePhaseCollection > apvPhaseProducerToken_
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
GenericTriggerEventFlag * genTriggerEventFlagStripDCSfilter_
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void Reset(void)
reset ME (ie. contents, errors, etc)
T const * product() const
Definition: ESHandle.h:86
MonitorElement * NclusVsCycleTimeProf2D
void fillModuleMEs(ModMEs &mod_mes, ClusterProperties &cluster)
MonitorElement * SubDetNumberOfClusterPerLayerTrend
Definition: Run.h:42
const SiStripApvGain::Range getRange(uint32_t detID) const
Definition: SiStripGain.h:66
int size() const
iterator begin()
Definition: DetSetNew.h:67