CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripMonitorCluster.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 // Package: SiStripMonitorCluster
3 // Class: SiStripMonitorCluster
6 // Original Author: Dorian Kcira
7 // Created: Wed Feb 1 16:42:34 CET 2006
8 #include <vector>
9 #include <numeric>
10 #include <fstream>
11 #include <math.h>
12 #include "TNamed.h"
15 
33 
36 
38 
39 #include "TMath.h"
40 #include <iostream>
41 
42 //--------------------------------------------------------------------------------------------
44  : 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)
45  // , genTriggerEventFlag_(new GenericTriggerEventFlag(iConfig, consumesCollector()))
46 {
47 
48  // initialize
49  passBPTXfilter_ = true;
50 
51  // initialize GenericTriggerEventFlag by specific configuration
52  // in this way, one can set specific selections for different MEs
56 
57  firstEvent = -1;
58  eventNb = 0;
59 
60  // Detector Partitions
61  SubDetPhasePartMap["TIB"] = "TI";
62  SubDetPhasePartMap["TID__MINUS"] = "TI";
63  SubDetPhasePartMap["TID__PLUS"] = "TI";
64  SubDetPhasePartMap["TOB"] = "TO";
65  SubDetPhasePartMap["TEC__MINUS"] = "TM";
66  SubDetPhasePartMap["TEC__PLUS"] = "TP";
67 
68  //get on/off option for every cluster from cfi
69  edm::ParameterSet ParametersnClusters = conf_.getParameter<edm::ParameterSet>("TH1nClusters");
70  layerswitchncluson = ParametersnClusters.getParameter<bool>("layerswitchon");
71  moduleswitchncluson = ParametersnClusters.getParameter<bool>("moduleswitchon");
72 
73  edm::ParameterSet ParametersClusterCharge = conf_.getParameter<edm::ParameterSet>("TH1ClusterCharge");
74  layerswitchcluschargeon = ParametersClusterCharge.getParameter<bool>("layerswitchon");
75  moduleswitchcluschargeon = ParametersClusterCharge.getParameter<bool>("moduleswitchon");
76  subdetswitchcluschargeon = ParametersClusterCharge.getParameter<bool>("subdetswitchon");
77 
78  edm::ParameterSet ParametersClusterStoN = conf_.getParameter<edm::ParameterSet>("TH1ClusterStoN");
79  layerswitchclusstonon = ParametersClusterStoN.getParameter<bool>("layerswitchon");
80  moduleswitchclusstonon = ParametersClusterStoN.getParameter<bool>("moduleswitchon");
81 
82  edm::ParameterSet ParametersClusterStoNVsPos = conf_.getParameter<edm::ParameterSet>("TH1ClusterStoNVsPos");
83  layerswitchclusstonVsposon = ParametersClusterStoNVsPos.getParameter<bool>("layerswitchon");
84  moduleswitchclusstonVsposon = ParametersClusterStoNVsPos.getParameter<bool>("moduleswitchon");
85 
86  edm::ParameterSet ParametersClusterPos = conf_.getParameter<edm::ParameterSet>("TH1ClusterPos");
87  layerswitchclusposon = ParametersClusterPos.getParameter<bool>("layerswitchon");
88  moduleswitchclusposon = ParametersClusterPos.getParameter<bool>("moduleswitchon");
89 
90  edm::ParameterSet ParametersClusterDigiPos = conf_.getParameter<edm::ParameterSet>("TH1ClusterDigiPos");
91  layerswitchclusdigiposon = ParametersClusterDigiPos.getParameter<bool>("layerswitchon");
92  moduleswitchclusdigiposon = ParametersClusterDigiPos.getParameter<bool>("moduleswitchon");
93 
94  edm::ParameterSet ParametersClusterNoise = conf_.getParameter<edm::ParameterSet>("TH1ClusterNoise");
95  layerswitchclusnoiseon = ParametersClusterNoise.getParameter<bool>("layerswitchon");
96  moduleswitchclusnoiseon = ParametersClusterNoise.getParameter<bool>("moduleswitchon");
97 
98  edm::ParameterSet ParametersClusterWidth = conf_.getParameter<edm::ParameterSet>("TH1ClusterWidth");
99  layerswitchcluswidthon = ParametersClusterWidth.getParameter<bool>("layerswitchon");
100  moduleswitchcluswidthon = ParametersClusterWidth.getParameter<bool>("moduleswitchon");
101  subdetswitchcluswidthon = ParametersClusterWidth.getParameter<bool>("subdetswitchon");
102 
103  edm::ParameterSet ParametersModuleLocalOccupancy = conf_.getParameter<edm::ParameterSet>("TH1ModuleLocalOccupancy");
104  layerswitchlocaloccupancy = ParametersModuleLocalOccupancy.getParameter<bool>("layerswitchon");
105  moduleswitchlocaloccupancy = ParametersModuleLocalOccupancy.getParameter<bool>("moduleswitchon");
106 
107  edm::ParameterSet ParametersNrOfClusterizedStrips = conf_.getParameter<edm::ParameterSet>("TH1NrOfClusterizedStrips");
108  layerswitchnrclusterizedstrip = ParametersNrOfClusterizedStrips.getParameter<bool>("layerswitchon");
109  moduleswitchnrclusterizedstrip = ParametersNrOfClusterizedStrips.getParameter<bool>("moduleswitchon");
110 
111  edm::ParameterSet ParametersClusterProf = conf_.getParameter<edm::ParameterSet>("TProfNumberOfCluster");
112  layerswitchnumclusterprofon = ParametersClusterProf.getParameter<bool>("layerswitchon");
113 
114  edm::ParameterSet ParametersClusterWidthProf = conf_.getParameter<edm::ParameterSet>("TProfClusterWidth");
115  layerswitchclusterwidthprofon = ParametersClusterWidthProf.getParameter<bool>("layerswitchon");
116 
117  edm::ParameterSet ParametersTotClusterProf = conf_.getParameter<edm::ParameterSet>("TProfTotalNumberOfClusters");
118  subdetswitchtotclusprofon = ParametersTotClusterProf.getParameter<bool>("subdetswitchon");
119 
120  edm::ParameterSet ParametersTotClusterTH1 = conf_.getParameter<edm::ParameterSet>("TH1TotalNumberOfClusters");
121  subdetswitchtotclusth1on = ParametersTotClusterTH1.getParameter<bool>("subdetswitchon");
122 
123  edm::ParameterSet ParametersClusterApvProf = conf_.getParameter<edm::ParameterSet>("TProfClustersApvCycle");
124  subdetswitchapvcycleprofon = ParametersClusterApvProf.getParameter<bool>("subdetswitchon");
125 
126  edm::ParameterSet ParametersClustersApvTH2 = conf_.getParameter<edm::ParameterSet>("TH2ClustersApvCycle");
127  subdetswitchapvcycleth2on = ParametersClustersApvTH2.getParameter<bool>("subdetswitchon");
128 
129  edm::ParameterSet ParametersApvCycleDBxProf2 = conf_.getParameter<edm::ParameterSet>("TProf2ApvCycleVsDBx");
130  subdetswitchapvcycledbxprof2on = ParametersApvCycleDBxProf2.getParameter<bool>("subdetswitchon");
131 
132  edm::ParameterSet ParametersDBxCycleProf = conf_.getParameter<edm::ParameterSet>("TProfClustersVsDBxCycle");
133  subdetswitchdbxcycleprofon = ParametersDBxCycleProf.getParameter<bool>("subdetswitchon");
134 
135  edm::ParameterSet ParametersCStripVsCPix = conf_.getParameter<edm::ParameterSet>("TH2CStripVsCpixel");
136  globalswitchcstripvscpix = ParametersCStripVsCPix.getParameter<bool>("globalswitchon");
137 
138  edm::ParameterSet ParametersMultiplicityRegionsTH1 = conf_.getParameter<edm::ParameterSet>("TH1MultiplicityRegions");
139  globalswitchMultiRegions = ParametersMultiplicityRegionsTH1.getParameter<bool>("globalswitchon");
140 
141  edm::ParameterSet ParametersApvCycleVsDBxGlobalTH2 = conf_.getParameter<edm::ParameterSet>("TH2ApvCycleVsDBxGlobal");
142  globalswitchapvcycledbxth2on = ParametersApvCycleVsDBxGlobalTH2.getParameter<bool>("globalswitchon");
143 
144  edm::ParameterSet ParametersNoiseStrip2ApvCycle = conf_.getParameter<edm::ParameterSet>("TH1StripNoise2ApvCycle");
145  globalswitchstripnoise2apvcycle = ParametersNoiseStrip2ApvCycle.getParameter<bool>("globalswitchon");
146 
147  edm::ParameterSet ParametersNoiseStrip3ApvCycle = conf_.getParameter<edm::ParameterSet>("TH1StripNoise3ApvCycle");
148  globalswitchstripnoise3apvcycle = ParametersNoiseStrip3ApvCycle.getParameter<bool>("globalswitchon");
149 
150  edm::ParameterSet ParametersMainDiagonalPosition = conf_.getParameter<edm::ParameterSet>("TH1MainDiagonalPosition");
151  globalswitchmaindiagonalposition= ParametersMainDiagonalPosition.getParameter<bool>("globalswitchon");
152 
153  edm::ParameterSet ClusterMultiplicityRegions = conf_.getParameter<edm::ParameterSet>("MultiplicityRegions");
154  k0 = ClusterMultiplicityRegions.getParameter<double>("k0");
155  q0 = ClusterMultiplicityRegions.getParameter<double>("q0");
156  dk0 = ClusterMultiplicityRegions.getParameter<double>("dk0");
157  maxClus = ClusterMultiplicityRegions.getParameter<double>("MaxClus");
158  minPix = ClusterMultiplicityRegions.getParameter<double>("MinPix");
159 
160  edm::ParameterSet ParametersNclusVsCycleTimeProf2D = conf_.getParameter<edm::ParameterSet>("NclusVsCycleTimeProf2D");
161  globalswitchnclusvscycletimeprof2don = ParametersNclusVsCycleTimeProf2D.getParameter<bool>("globalswitchon");
162 
163  clustertkhistomapon = conf_.getParameter<bool>("TkHistoMap_On");
164  createTrendMEs = conf_.getParameter<bool>("CreateTrendMEs");
165  trendVsLs_ = conf_.getParameter<bool>("TrendVsLS");
166  Mod_On_ = conf_.getParameter<bool>("Mod_On");
167  ClusterHisto_ = conf_.getParameter<bool>("ClusterHisto");
168 
169  topFolderName_ = conf_.getParameter<std::string>("TopFolderName");
170 
171 
172  // Poducer name of input StripClusterCollection
173  clusterProducerStripToken_ = consumes<edmNew::DetSetVector<SiStripCluster> >(conf_.getParameter<edm::InputTag>("ClusterProducerStrip") );
174  clusterProducerPixToken_ = consumes<edmNew::DetSetVector<SiPixelCluster> >(conf_.getParameter<edm::InputTag>("ClusterProducerPix") );
175  /*
176  clusterProducerStrip_ = conf_.getParameter<edm::InputTag>("ClusterProducerStrip");
177  clusterProducerPix_ = conf_.getParameter<edm::InputTag>("ClusterProducerPix");
178  */
179  // SiStrip Quality Label
180  qualityLabel_ = conf_.getParameter<std::string>("StripQualityLabel");
181  // cluster quality conditions
182  edm::ParameterSet cluster_condition = conf_.getParameter<edm::ParameterSet>("ClusterConditions");
183  applyClusterQuality_ = cluster_condition.getParameter<bool>("On");
184  sToNLowerLimit_ = cluster_condition.getParameter<double>("minStoN");
185  sToNUpperLimit_ = cluster_condition.getParameter<double>("maxStoN");
186  widthLowerLimit_ = cluster_condition.getParameter<double>("minWidth");
187  widthUpperLimit_ = cluster_condition.getParameter<double>("maxWidth");
188 
189  // Event History Producer
190  // historyProducer_ = conf_.getParameter<edm::InputTag>("HistoryProducer");
191  historyProducerToken_ = consumes<EventWithHistory>(conf_.getParameter<edm::InputTag>("HistoryProducer") );
192  // Apv Phase Producer
193  // apvPhaseProducer_ = conf_.getParameter<edm::InputTag>("ApvPhaseProducer");
194  apvPhaseProducerToken_ = consumes<APVCyclePhaseCollection>(conf_.getParameter<edm::InputTag>("ApvPhaseProducer") );
195  // Create DCS Status
196  bool checkDCS = conf_.getParameter<bool>("UseDCSFiltering");
197  if (checkDCS) dcsStatus_ = new SiStripDCSStatus(consumesCollector());
198  else dcsStatus_ = 0;
199 
200 }
201 
203  if (dcsStatus_) delete dcsStatus_;
207 }
208 
209 
210 //--------------------------------------------------------------------------------------------
212 
213  // Initialize the GenericTriggerEventFlag
220 }
221 
222 //--------------------------------------------------------------------------------------------
224 
226 
227  //Retrieve tracker topology from geometry
228  edm::ESHandle<TrackerTopology> tTopoHandle;
229  es.get<IdealGeometryRecord>().get(tTopoHandle);
230  const TrackerTopology* const tTopo = tTopoHandle.product();
231 
232  // take from eventSetup the SiStripDetCabling object - here will use SiStripDetControl later on
234 
235  // get list of active detectors from SiStripDetCabling
236  std::vector<uint32_t> activeDets;
237  SiStripDetCabling_->addActiveDetectorsRawIds(activeDets);
238 
239  SiStripSubStructure substructure;
240 
241  SiStripFolderOrganizer folder_organizer;
242  folder_organizer.setSiStripFolderName(topFolderName_);
243  folder_organizer.setSiStripFolder();
244 
245 
246  // Create TkHistoMap for Cluster
247  if (clustertkhistomapon) {
248  // std::cout << "[SiStripMonitorCluster::createMEs] topFolderName_: " << topFolderName_ << " ";
249  if ( (topFolderName_ == "SiStrip") or (std::string::npos != topFolderName_.find("HLT")) )
250  tkmapcluster = new TkHistoMap(ibooker , topFolderName_,"TkHMap_NumberOfCluster",0.,true);
251  else tkmapcluster = new TkHistoMap(ibooker , topFolderName_+"/TkHistoMap","TkHMap_NumberOfCluster",0.,false);
252  }
253 
254  // loop over detectors and book MEs
255  edm::LogInfo("SiStripTkDQM|SiStripMonitorCluster")<<"nr. of activeDets: "<<activeDets.size();
256  for(std::vector<uint32_t>::iterator detid_iterator = activeDets.begin(); detid_iterator!=activeDets.end(); detid_iterator++){
257  uint32_t detid = (*detid_iterator);
258  // remove any eventual zero elements - there should be none, but just in case
259  if(detid == 0) {
260  activeDets.erase(detid_iterator);
261  continue;
262  }
263 
264  if (Mod_On_) {
265  ModMEs mod_single;
266  // set appropriate folder using SiStripFolderOrganizer
267  folder_organizer.setDetectorFolder(detid, tTopo); // pass the detid to this method
268  if (reset_each_run) ResetModuleMEs(detid);
269  createModuleMEs(mod_single, detid , ibooker);
270  // append to ModuleMEsMap
271  ModuleMEsMap.insert( std::make_pair(detid, mod_single));
272  }
273 
274  // Create Layer Level MEs if they are not created already
275  std::pair<std::string,int32_t> det_layer_pair = folder_organizer.GetSubDetAndLayer(detid, tTopo);
276  SiStripHistoId hidmanager;
277  std::string label = hidmanager.getSubdetid(detid,tTopo,false);
278 
279  std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(label);
280  if(iLayerME==LayerMEsMap.end()) {
281 
282  // get detids for the layer
283  int32_t lnumber = det_layer_pair.second;
284  std::vector<uint32_t> layerDetIds;
285  if (det_layer_pair.first == "TIB") {
286  substructure.getTIBDetectors(activeDets,layerDetIds,lnumber,0,0,0);
287  } else if (det_layer_pair.first == "TOB") {
288  substructure.getTOBDetectors(activeDets,layerDetIds,lnumber,0,0);
289  } else if (det_layer_pair.first == "TID" && lnumber > 0) {
290  substructure.getTIDDetectors(activeDets,layerDetIds,2,abs(lnumber),0,0);
291  } else if (det_layer_pair.first == "TID" && lnumber < 0) {
292  substructure.getTIDDetectors(activeDets,layerDetIds,1,abs(lnumber),0,0);
293  } else if (det_layer_pair.first == "TEC" && lnumber > 0) {
294  substructure.getTECDetectors(activeDets,layerDetIds,2,abs(lnumber),0,0,0,0);
295  } else if (det_layer_pair.first == "TEC" && lnumber < 0) {
296  substructure.getTECDetectors(activeDets,layerDetIds,1,abs(lnumber),0,0,0,0);
297  }
298  LayerDetMap[label] = layerDetIds;
299 
300  // book Layer MEs
301  folder_organizer.setLayerFolder(detid,tTopo,det_layer_pair.second);
302  createLayerMEs(label, layerDetIds.size() , ibooker );
303  }
304  // book sub-detector plots
305  auto sdet_pair = folder_organizer.getSubDetFolderAndTag(detid, tTopo);
306  if (SubDetMEsMap.find(sdet_pair.second) == SubDetMEsMap.end()){
307  ibooker.setCurrentFolder(sdet_pair.first);
308 
309  createSubDetMEs(sdet_pair.second , ibooker );
310  }
311  }//end of loop over detectors
312 
313  // Create Global Histogram
315  ibooker.setCurrentFolder(topFolderName_+"/MechanicalView/");
316  edm::ParameterSet GlobalTH2Parameters = conf_.getParameter<edm::ParameterSet>("TH2ApvCycleVsDBxGlobal");
317  std::string HistoName = "DeltaBx_vs_ApvCycle";
318  GlobalApvCycleDBxTH2 = ibooker.book2D(HistoName,HistoName,
319  GlobalTH2Parameters.getParameter<int32_t>("Nbinsx"),
320  GlobalTH2Parameters.getParameter<double>("xmin"),
321  GlobalTH2Parameters.getParameter<double>("xmax"),
322  GlobalTH2Parameters.getParameter<int32_t>("Nbinsy"),
323  GlobalTH2Parameters.getParameter<double>("ymin"),
324  GlobalTH2Parameters.getParameter<double>("ymax"));
325  GlobalApvCycleDBxTH2->setAxisTitle("APV Cycle (Corrected Absolute Bx % 70)",1);
326  GlobalApvCycleDBxTH2->setAxisTitle("Delta Bunch Crossing Cycle",2);
327  }
328 
330  ibooker.setCurrentFolder(topFolderName_+"/MechanicalView/");
331  edm::ParameterSet GlobalTH2Parameters = conf_.getParameter<edm::ParameterSet>("TH2CStripVsCpixel");
332  std::string HistoName = "StripClusVsPixClus";
333  GlobalCStripVsCpix = ibooker.book2D(HistoName,HistoName,
334  GlobalTH2Parameters.getParameter<int32_t>("Nbinsx"),
335  GlobalTH2Parameters.getParameter<double>("xmin"),
336  GlobalTH2Parameters.getParameter<double>("xmax"),
337  GlobalTH2Parameters.getParameter<int32_t>("Nbinsy"),
338  GlobalTH2Parameters.getParameter<double>("ymin"),
339  GlobalTH2Parameters.getParameter<double>("ymax"));
340  GlobalCStripVsCpix->setAxisTitle("Strip Clusters",1);
341  GlobalCStripVsCpix->setAxisTitle("Pix Clusters",2);
342  }
343 
345  ibooker.setCurrentFolder(topFolderName_+"/MechanicalView/");
346  edm::ParameterSet GlobalTH2Parameters = conf_.getParameter<edm::ParameterSet>("TH1MultiplicityRegions");
347  std::string HistoName = "ClusterMultiplicityRegions";
348  PixVsStripMultiplicityRegions = ibooker.book1D(HistoName,HistoName,
349  GlobalTH2Parameters.getParameter<int32_t>("Nbinx"),
350  GlobalTH2Parameters.getParameter<double>("xmin"),
351  GlobalTH2Parameters.getParameter<double>("xmax"));
353  PixVsStripMultiplicityRegions->setBinLabel(1,"Main Diagonal");
354  PixVsStripMultiplicityRegions->setBinLabel(2,"Strip Noise");
355  PixVsStripMultiplicityRegions->setBinLabel(3,"High Strip Noise");
356  PixVsStripMultiplicityRegions->setBinLabel(4,"Beam Background");
357  PixVsStripMultiplicityRegions->setBinLabel(5,"No Strip Clusters");
358  }
359 
361  ibooker.setCurrentFolder(topFolderName_+"/MechanicalView/");
362  edm::ParameterSet GlobalTH1Parameters = conf_.getParameter<edm::ParameterSet>("TH1MainDiagonalPosition");
363  std::string HistoName = "MainDiagonal Position";
364  GlobalMainDiagonalPosition = ibooker.book1D(HistoName,HistoName,
365  GlobalTH1Parameters.getParameter<int32_t>("Nbinsx"),
366  GlobalTH1Parameters.getParameter<double>("xmin"),
367  GlobalTH1Parameters.getParameter<double>("xmax"));
368  GlobalMainDiagonalPosition->setAxisTitle("atan(NPix/(k*NStrip))");
369  }
370 
371  // TO BE ADDED !!!
372  /*
373  if ( globalswitchapvcycledbxth2on or globalswitchcstripvscpix or globalswitchMultiRegions or ClusterHisto_ ) {
374  ibooker.setCurrentFolder(topFolderName_+"/MechanicalView/");
375  std::string HistoName = "BPTX rate";
376  BPTXrateTrend = ibooker.bookProfile(HistoName,HistoName, LSBin, LSMin, LSMax, 0, 10000.,"");
377  BPTXrateTrend->getTH1()->SetBit(TH1::kCanRebin);
378  BPTXrateTrend->setAxisTitle("#Lumi section",1);
379  BPTXrateTrend->setAxisTitle("Number of BPTX events per LS",2);
380  }
381  */
382 
384  ibooker.setCurrentFolder(topFolderName_+"/MechanicalView/");
385  edm::ParameterSet GlobalTH1Parameters = conf_.getParameter<edm::ParameterSet>("TH1StripNoise2ApvCycle");
386  std::string HistoName = "StripNoise_ApvCycle";
387  StripNoise2Cycle = ibooker.book1D(HistoName,HistoName,
388  GlobalTH1Parameters.getParameter<int32_t>("Nbinsx"),
389  GlobalTH1Parameters.getParameter<double>("xmin"),
390  GlobalTH1Parameters.getParameter<double>("xmax"));
391  StripNoise2Cycle->setAxisTitle("APV Cycle");
392  }
393 
395  ibooker.setCurrentFolder(topFolderName_+"/MechanicalView/");
396  edm::ParameterSet GlobalTH1Parameters = conf_.getParameter<edm::ParameterSet>("TH1StripNoise3ApvCycle");
397  std::string HistoName = "HighStripNoise_ApvCycle";
398  StripNoise3Cycle = ibooker.book1D(HistoName,HistoName,
399  GlobalTH1Parameters.getParameter<int32_t>("Nbinsx"),
400  GlobalTH1Parameters.getParameter<double>("xmin"),
401  GlobalTH1Parameters.getParameter<double>("xmax"));
402  StripNoise3Cycle->setAxisTitle("APV Cycle");
403  }
404 
406  const char* HistoName = "StripClusVsBXandOrbit";
407  const char* HistoTitle = "Strip cluster multiplicity vs BX mod(70) and Orbit;Event 1 BX mod(70);time [Orb#]";
408  edm::ParameterSet ParametersNclusVsCycleTimeProf2D = conf_.getParameter<edm::ParameterSet>("NclusVsCycleTimeProf2D");
409  NclusVsCycleTimeProf2D = ibooker.bookProfile2D ( HistoName , HistoTitle ,
410  ParametersNclusVsCycleTimeProf2D.getParameter<int32_t>("Nbins"),
411  ParametersNclusVsCycleTimeProf2D.getParameter<double>("xmin"),
412  ParametersNclusVsCycleTimeProf2D.getParameter<double>("xmax"),
413  ParametersNclusVsCycleTimeProf2D.getParameter<int32_t>("Nbinsy"),
414  ParametersNclusVsCycleTimeProf2D.getParameter<double>("ymin"),
415  ParametersNclusVsCycleTimeProf2D.getParameter<double>("ymax"),
416  0 , 0 );
417  if (NclusVsCycleTimeProf2D->kind() == MonitorElement::DQM_KIND_TPROFILE2D) NclusVsCycleTimeProf2D->getTH1()->SetBit(TH1::kCanRebin);
418  }
419 
420  if (ClusterHisto_){
421  ibooker.setCurrentFolder(topFolderName_+"/MechanicalView/");
422  edm::ParameterSet PixelCluster = conf_.getParameter<edm::ParameterSet>("TH1NClusPx");
423  std::string HistoName = "NumberOfClustersInPixel";
424  NumberOfPixelClus = ibooker.book1D(HistoName, HistoName,
425  PixelCluster.getParameter<int32_t>("Nbinsx"),
426  PixelCluster.getParameter<double>("xmin"),
427  PixelCluster.getParameter<double>("xmax"));
428  NumberOfPixelClus->setAxisTitle("# of Clusters in Pixel", 1);
429  NumberOfPixelClus->setAxisTitle("Number of Events", 2);
430  //
431  edm::ParameterSet StripCluster = conf_.getParameter<edm::ParameterSet>("TH1NClusStrip");
432  HistoName = "NumberOfClustersInStrip";
433  NumberOfStripClus = ibooker.book1D(HistoName, HistoName,
434  StripCluster.getParameter<int32_t>("Nbinsx"),
435  StripCluster.getParameter<double>("xmin"),
436  StripCluster.getParameter<double>("xmax"));
437  NumberOfStripClus->setAxisTitle("# of Clusters in Strip", 1);
438  NumberOfStripClus->setAxisTitle("Number of Events", 2);
439  }
440 
441 
442  }//end of if
443 }//end of method
444 
445 //--------------------------------------------------------------------------------------------
446 
448 {
450  unsigned long long cacheID = es.get<SiStripDetCablingRcd>().cacheIdentifier();
451  if (m_cacheID_ != cacheID) {
452  m_cacheID_ = cacheID;
453  edm::LogInfo("SiStripMonitorCluster") <<"SiStripMonitorCluster::bookHistograms: "
454  << " Creating MEs for new Cabling ";
455 
456  createMEs(es , ibooker);
457  }
458  } else if (reset_each_run) {
459  edm::LogInfo("SiStripMonitorCluster") <<"SiStripMonitorCluster::bookHistograms: "
460  << " Resetting MEs ";
461  for (std::map<uint32_t, ModMEs >::const_iterator idet = ModuleMEsMap.begin() ; idet!=ModuleMEsMap.end() ; idet++) {
462  ResetModuleMEs(idet->first);
463  }
464  }
465 
466 }
467 
468 //--------------------------------------------------------------------------------------------
470 {
471  //Retrieve tracker topology from geometry
472  edm::ESHandle<TrackerTopology> tTopoHandle;
473  iSetup.get<IdealGeometryRecord>().get(tTopoHandle);
474  const TrackerTopology* const tTopo = tTopoHandle.product();
475 
476  // Filter out events if Trigger Filtering is requested
477  passBPTXfilter_ = ( iEvent.isRealData() and genTriggerEventFlagBPTXfilter_->on() ) ? genTriggerEventFlagBPTXfilter_->accept( iEvent, iSetup) : true;
480  // std::cout << "passBPTXfilter_ ? " << passBPTXfilter_ << std::endl;
481 
482  // Filter out events if DCS Event if requested
483  if (dcsStatus_ && !dcsStatus_->getStatus(iEvent,iSetup)) return;
484 
485  runNb = iEvent.id().run();
486  eventNb++;
487  trendVar = trendVsLs_ ? iEvent.orbitNumber()/262144.0 : iEvent.orbitNumber()/11223.0; // lumisection : seconds
488 
489  int NPixClusters=0, NStripClusters=0, MultiplicityRegion=0;
490  bool isPixValid=false;
491 
492  edm::ESHandle<SiStripNoises> noiseHandle;
493  iSetup.get<SiStripNoisesRcd>().get(noiseHandle);
494 
495  edm::ESHandle<SiStripGain> gainHandle;
496  iSetup.get<SiStripGainRcd>().get(gainHandle);
497 
498  edm::ESHandle<SiStripQuality> qualityHandle;
499  iSetup.get<SiStripQualityRcd>().get(qualityLabel_,qualityHandle);
500 
502 
503  // get collection of DetSetVector of clusters from Event
505  iEvent.getByToken(clusterProducerStripToken_, cluster_detsetvektor);
506 
507  //get pixel clusters
508  edm::Handle< edmNew::DetSetVector<SiPixelCluster> > cluster_detsetvektor_pix;
509  iEvent.getByToken(clusterProducerPixToken_, cluster_detsetvektor_pix);
510 
511  if (!cluster_detsetvektor.isValid()) return;
512 
513  const edmNew::DetSetVector<SiStripCluster> * StrC= cluster_detsetvektor.product();
514  NStripClusters= StrC->data().size();
515 
516  if (cluster_detsetvektor_pix.isValid()){
517  const edmNew::DetSetVector<SiPixelCluster> * PixC= cluster_detsetvektor_pix.product();
518  NPixClusters= PixC->data().size();
519  isPixValid=true;
520  MultiplicityRegion=FindRegion(NStripClusters,NPixClusters);
521 
523  if (globalswitchcstripvscpix) GlobalCStripVsCpix->Fill(NStripClusters,NPixClusters);
524  if (globalswitchmaindiagonalposition && NStripClusters > 0) GlobalMainDiagonalPosition->Fill(atan(NPixClusters/(k0*NStripClusters)));
526  }
527 
528  if (ClusterHisto_){
530  NumberOfPixelClus->Fill(NPixClusters);
531  if ( passBPTXfilter_ and passStripDCSfilter_ )
532  NumberOfStripClus->Fill(NStripClusters);
533  }
534  }
535  // initialise # of clusters to zero
536  for (std::map<std::string, SubDetMEs>::iterator iSubdet = SubDetMEsMap.begin();
537  iSubdet != SubDetMEsMap.end(); iSubdet++) {
538  iSubdet->second.totNClusters = 0;
539  }
540 
541  SiStripFolderOrganizer folder_organizer;
542  bool found_layer_me = false;
543  for (std::map<std::string, std::vector< uint32_t > >::const_iterator iterLayer = LayerDetMap.begin();
544  iterLayer != LayerDetMap.end(); iterLayer++) {
545 
546  std::string layer_label = iterLayer->first;
547 
548  int ncluster_layer = 0;
549  std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(layer_label);
550 
551  //get Layer MEs
552  LayerMEs layer_single;
553  if(iLayerME != LayerMEsMap.end()) {
554  layer_single = iLayerME->second;
555  found_layer_me = true;
556  }
557 
558  bool found_module_me = false;
559  uint16_t iDet = 0;
560  std::string subdet_label = "";
561  // loop over all modules in the layer
562  for (std::vector< uint32_t >::const_iterator iterDets = iterLayer->second.begin() ;
563  iterDets != iterLayer->second.end() ; iterDets++) {
564  iDet++;
565  // detid and type of ME
566  uint32_t detid = (*iterDets);
567 
568  // Get SubDet label once
569  if (subdet_label.size() == 0) subdet_label = folder_organizer.getSubDetFolderAndTag(detid, tTopo).second;
570 
571  // DetId and corresponding set of MEs
572  ModMEs mod_single;
573  if (Mod_On_) {
574  std::map<uint32_t, ModMEs >::iterator imodME = ModuleMEsMap.find(detid);
575  if (imodME != ModuleMEsMap.end()) {
576  mod_single = imodME->second;
577  found_module_me = true;
578  }
579  } else found_module_me = false;
580 
581  edmNew::DetSetVector<SiStripCluster>::const_iterator isearch = cluster_detsetvektor->find(detid); // search clusters of detid
582 
583  if(isearch==cluster_detsetvektor->end()){
584  if(found_module_me && moduleswitchncluson && (mod_single.NumberOfClusters)){
585  (mod_single.NumberOfClusters)->Fill(0.); // no clusters for this detector module,fill histogram with 0
586  }
587  if(clustertkhistomapon) tkmapcluster->fill(detid,0.);
588  if (found_layer_me && layerswitchnumclusterprofon) layer_single.LayerNumberOfClusterProfile->Fill(iDet, 0.0);
589  continue; // no clusters for this detid => jump to next step of loop
590  }
591 
592  //cluster_detset is a structure, cluster_detset.data is a std::vector<SiStripCluster>, cluster_detset.id is uint32_t
593  // edmNew::DetSet<SiStripCluster> cluster_detset = (*cluster_detsetvektor)[detid]; // the statement above makes sure there exists an element with 'detid'
594  edmNew::DetSet<SiStripCluster> cluster_detset = (*isearch);
595 
596  // Filling TkHistoMap with number of clusters for each module
597  if(clustertkhistomapon) {
598  tkmapcluster->fill(detid,static_cast<float>(cluster_detset.size()));
599  }
600 
601  if(moduleswitchncluson && found_module_me && (mod_single.NumberOfClusters != NULL)){ // nr. of clusters per module
602  (mod_single.NumberOfClusters)->Fill(static_cast<float>(cluster_detset.size()));
603  }
604 
605  if (found_layer_me && layerswitchnumclusterprofon)
606  layer_single.LayerNumberOfClusterProfile->Fill(iDet, static_cast<float>(cluster_detset.size()));
607  ncluster_layer += cluster_detset.size();
608 
609  short total_clusterized_strips = 0;
610 
611  SiStripNoises::Range detNoiseRange = noiseHandle->getRange(detid);
612  SiStripApvGain::Range detGainRange = gainHandle->getRange(detid);
613  SiStripQuality::Range qualityRange = qualityHandle->getRange(detid);
614 
615  for(edmNew::DetSet<SiStripCluster>::const_iterator clusterIter = cluster_detset.begin(); clusterIter!= cluster_detset.end(); clusterIter++){
616 
617  const auto & ampls = clusterIter->amplitudes();
618  // cluster position
619  float cluster_position = clusterIter->barycenter();
620  // start defined as nr. of first strip beloning to the cluster
621  short cluster_start = clusterIter->firstStrip();
622  // width defined as nr. of strips that belong to cluster
623  short cluster_width = ampls.size();
624  // add nr of strips of this cluster to total nr. of clusterized strips
625  total_clusterized_strips = total_clusterized_strips + cluster_width;
626 
627  // cluster signal and noise from the amplitudes
628  float cluster_signal = 0.0;
629  float cluster_noise = 0.0;
630  int nrnonzeroamplitudes = 0;
631  float noise2 = 0.0;
632  float noise = 0.0;
633  for(uint iamp=0; iamp<ampls.size(); iamp++){
634  if(ampls[iamp]>0){ // nonzero amplitude
635  cluster_signal += ampls[iamp];
636  if(!qualityHandle->IsStripBad(qualityRange, clusterIter->firstStrip()+iamp)){
637  noise = noiseHandle->getNoise(clusterIter->firstStrip()+iamp,detNoiseRange)/gainHandle->getStripGain(clusterIter->firstStrip()+iamp, detGainRange);
638  }
639  noise2 += noise*noise;
640  nrnonzeroamplitudes++;
641  }
642  } // End loop over cluster amplitude
643 
644  if (nrnonzeroamplitudes > 0) cluster_noise = sqrt(noise2/nrnonzeroamplitudes);
645 
646  if( applyClusterQuality_ &&
647  (cluster_signal/cluster_noise < sToNLowerLimit_ ||
648  cluster_signal/cluster_noise > sToNUpperLimit_ ||
649  cluster_width < widthLowerLimit_ ||
650  cluster_width > widthUpperLimit_) ) continue;
651 
652  ClusterProperties cluster_properties;
653  cluster_properties.charge = cluster_signal;
654  cluster_properties.position = cluster_position;
655  cluster_properties.start = cluster_start;
656  cluster_properties.width = cluster_width;
657  cluster_properties.noise = cluster_noise;
658 
659  // Fill Module Level MEs
660  if (found_module_me) fillModuleMEs(mod_single, cluster_properties);
661 
662  // Fill Layer Level MEs
663  if (found_layer_me) {
664  fillLayerMEs(layer_single, cluster_properties);
666  layer_single.LayerClusterWidthProfile->Fill(iDet, cluster_width);
667  }
668 
670  {
671  std::map<std::string, SubDetMEs>::iterator iSubdet = SubDetMEsMap.find(subdet_label);
672  if(iSubdet != SubDetMEsMap.end())
673  {
674  if (subdetswitchcluschargeon) iSubdet->second.SubDetClusterChargeTH1->Fill(cluster_signal);
675  if (subdetswitchcluswidthon) iSubdet->second.SubDetClusterWidthTH1->Fill(cluster_width);
676  }
677  }
678  } // end loop over clusters
679 
680  short total_nr_strips = SiStripDetCabling_->nApvPairs(detid) * 2 * 128; // get correct # of avp pairs
681  float local_occupancy = static_cast<float>(total_clusterized_strips)/static_cast<float>(total_nr_strips);
682  if (found_module_me) {
683  if(moduleswitchnrclusterizedstrip && mod_single.NrOfClusterizedStrips ){ // nr of clusterized strips
684  mod_single.NrOfClusterizedStrips->Fill(static_cast<float>(total_clusterized_strips));
685  }
686 
687  if(moduleswitchlocaloccupancy && mod_single.ModuleLocalOccupancy ){ // Occupancy
688  mod_single.ModuleLocalOccupancy->Fill(local_occupancy);
689  }
690  }
691  if (layerswitchlocaloccupancy && found_layer_me && layer_single.LayerLocalOccupancy) {
692  fillME(layer_single.LayerLocalOccupancy,local_occupancy);
693  if (createTrendMEs)
694  fillME(layer_single.LayerLocalOccupancyTrend,trendVar,local_occupancy);
695  }
696  }
697  std::map<std::string, SubDetMEs>::iterator iSubdet = SubDetMEsMap.find(subdet_label);
698  if(iSubdet != SubDetMEsMap.end()) iSubdet->second.totNClusters += ncluster_layer;
699  }
700 
701  // EventHistory
702  edm::Handle<EventWithHistory> event_history;
703  iEvent.getByToken(historyProducerToken_,event_history);
704 
705  // Phase of APV
706  edm::Handle<APVCyclePhaseCollection> apv_phase_collection;
707  iEvent.getByToken(apvPhaseProducerToken_,apv_phase_collection);
708 
709  if (event_history.isValid()
710  && !event_history.failedToGet()
711  && apv_phase_collection.isValid()
712  && !apv_phase_collection.failedToGet()) {
713 
714 
715  long long dbx = event_history->deltaBX();
716  long long tbx = event_history->absoluteBX();
717 
718  bool global_histo_filled = false;
719  bool MultiplicityRegion_Vs_APVcycle_filled=false;
720 
721  for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin();
722  it != SubDetMEsMap.end(); it++) {
723  std::string sdet = it->first;
724  //std::string sdet = sdet_tag.substr(0,sdet_tag.find_first_of("_"));
725  SubDetMEs sdetmes = it->second;
726 
727  int the_phase = APVCyclePhaseCollection::invalid;
728  long long tbx_corr = tbx;
729 
730  if (SubDetPhasePartMap.find(sdet) != SubDetPhasePartMap.end()) the_phase = apv_phase_collection->getPhase(SubDetPhasePartMap[sdet]);
731  if(the_phase==APVCyclePhaseCollection::nopartition ||
734  the_phase=30;
735  //std::cout << " subdet " << it->first << " not valid" << " MR " << MultiplicityRegion <<std::endl;
736  }
737  tbx_corr -= the_phase;
738  long long dbxincycle = event_history->deltaBXinCycle(the_phase);
739  if (globalswitchapvcycledbxth2on && !global_histo_filled) {
740  GlobalApvCycleDBxTH2->Fill(tbx_corr%70,dbx);
741  global_histo_filled = true;
742  }
743 
744  if (isPixValid && !MultiplicityRegion_Vs_APVcycle_filled){
745  if (globalswitchstripnoise2apvcycle && MultiplicityRegion==2) {StripNoise2Cycle->Fill(tbx_corr%70);}
746  if (globalswitchstripnoise3apvcycle && MultiplicityRegion==3) {StripNoise3Cycle->Fill(tbx_corr%70);}
747  MultiplicityRegion_Vs_APVcycle_filled=true;
748  }
749 
751  sdetmes.SubDetTotClusterTH1->Fill(sdetmes.totNClusters);
755  sdetmes.SubDetClusterApvProf->Fill(tbx_corr%70,sdetmes.totNClusters);
757  sdetmes.SubDetClusterApvTH2->Fill(tbx_corr%70,sdetmes.totNClusters);
759  sdetmes.SubDetClusterDBxCycleProf->Fill(dbxincycle,sdetmes.totNClusters);
761  sdetmes.SubDetApvDBxProf2->Fill(tbx_corr%70,dbx,sdetmes.totNClusters);
762  }
763 
765  {
766  long long tbx_corr = tbx;
767  int the_phase = apv_phase_collection->getPhase("All");
768 
769  if( the_phase == APVCyclePhaseCollection::nopartition ||
771  the_phase == APVCyclePhaseCollection::invalid )
772  the_phase=30;
773 
774  tbx_corr -= the_phase;
775 
776  NclusVsCycleTimeProf2D->Fill( tbx_corr%70 , (int)event_history->_orbit , NStripClusters );
777  }
778  }
779 }
780 //
781 // -- Reset MEs
782 //------------------------------------------------------------------------------
784  std::map<uint32_t, ModMEs >::iterator pos = ModuleMEsMap.find(idet);
785  ModMEs mod_me = pos->second;
786 
797 }
798 //
799 // -- Create Module Level MEs
800 //
801 void SiStripMonitorCluster::createModuleMEs(ModMEs& mod_single, uint32_t detid , DQMStore::IBooker & ibooker) {
802 
803  // use SistripHistoId for producing histogram id (and title)
804  SiStripHistoId hidmanager;
805  std::string hid;
806 
807  //nr. of clusters per module
808  if(moduleswitchncluson) {
809  hid = hidmanager.createHistoId("NumberOfClusters","det",detid);
810  mod_single.NumberOfClusters = bookME1D("TH1nClusters", hid.c_str() , ibooker);
811  ibooker.tag(mod_single.NumberOfClusters, detid);
812  mod_single.NumberOfClusters->setAxisTitle("number of clusters in one detector module");
813  mod_single.NumberOfClusters->getTH1()->StatOverflows(kTRUE); // over/underflows in Mean calculation
814  }
815 
816  //ClusterPosition
818  short total_nr_strips = SiStripDetCabling_->nApvPairs(detid) * 2 * 128; // get correct # of avp pairs
819  hid = hidmanager.createHistoId("ClusterPosition","det",detid);
820  mod_single.ClusterPosition = ibooker.book1D(hid, hid, total_nr_strips, 0.5, total_nr_strips+0.5);
821  ibooker.tag(mod_single.ClusterPosition, detid);
822  mod_single.ClusterPosition->setAxisTitle("cluster position [strip number +0.5]");
823  }
824 
825  //ClusterDigiPosition
827  short total_nr_strips = SiStripDetCabling_->nApvPairs(detid) * 2 * 128; // get correct # of avp pairs
828  hid = hidmanager.createHistoId("ClusterDigiPosition","det",detid);
829  mod_single.ClusterDigiPosition = ibooker.book1D(hid, hid, total_nr_strips, 0.5, total_nr_strips+0.5);
830  ibooker.tag(mod_single.ClusterDigiPosition, detid);
831  mod_single.ClusterDigiPosition->setAxisTitle("digi in cluster position [strip number +0.5]");
832  }
833 
834  //ClusterWidth
836  hid = hidmanager.createHistoId("ClusterWidth","det",detid);
837  mod_single.ClusterWidth = bookME1D("TH1ClusterWidth", hid.c_str() , ibooker);
838  ibooker.tag(mod_single.ClusterWidth, detid);
839  mod_single.ClusterWidth->setAxisTitle("cluster width [nr strips]");
840  }
841 
842  //ClusterCharge
844  hid = hidmanager.createHistoId("ClusterCharge","det",detid);
845  mod_single.ClusterCharge = bookME1D("TH1ClusterCharge", hid.c_str() , ibooker );
846  ibooker.tag(mod_single.ClusterCharge, detid);
847  mod_single.ClusterCharge->setAxisTitle("cluster charge [ADC]");
848  }
849 
850  //ClusterNoise
852  hid = hidmanager.createHistoId("ClusterNoise","det",detid);
853  mod_single.ClusterNoise = bookME1D("TH1ClusterNoise", hid.c_str() , ibooker );
854  ibooker.tag(mod_single.ClusterNoise, detid);
855  mod_single.ClusterNoise->setAxisTitle("cluster noise");
856  }
857 
858  //ClusterSignalOverNoise
860  hid = hidmanager.createHistoId("ClusterSignalOverNoise","det",detid);
861  mod_single.ClusterSignalOverNoise = bookME1D("TH1ClusterStoN", hid.c_str() , ibooker);
862  ibooker.tag(mod_single.ClusterSignalOverNoise, detid);
863  mod_single.ClusterSignalOverNoise->setAxisTitle("ratio of signal to noise for each cluster");
864  }
865 
866  //ClusterSignalOverNoiseVsPos
868  hid = hidmanager.createHistoId("ClusterSignalOverNoiseVsPos","det",detid);
869  Parameters = conf_.getParameter<edm::ParameterSet>("TH1ClusterStoNVsPos");
870  mod_single.ClusterSignalOverNoiseVsPos= ibooker.bookProfile(hid.c_str(),hid.c_str(),
871  Parameters.getParameter<int32_t>("Nbinx"),
872  Parameters.getParameter<double>("xmin"),
873  Parameters.getParameter<double>("xmax"),
874  Parameters.getParameter<int32_t>("Nbiny"),
875  Parameters.getParameter<double>("ymin"),
876  Parameters.getParameter<double>("ymax")
877  );
878  ibooker.tag(mod_single.ClusterSignalOverNoiseVsPos, detid);
879  mod_single.ClusterSignalOverNoiseVsPos->setAxisTitle("pos");
880  }
881 
882  //ModuleLocalOccupancy
884  hid = hidmanager.createHistoId("ClusterLocalOccupancy","det",detid);
885  mod_single.ModuleLocalOccupancy = bookME1D("TH1ModuleLocalOccupancy", hid.c_str() , ibooker);
886  ibooker.tag(mod_single.ModuleLocalOccupancy, detid);
887  mod_single.ModuleLocalOccupancy->setAxisTitle("module local occupancy [% of clusterized strips]");
888  }
889 
890  //NrOfClusterizedStrips
892  hid = hidmanager.createHistoId("NrOfClusterizedStrips","det",detid);
893  mod_single.NrOfClusterizedStrips = bookME1D("TH1NrOfClusterizedStrips", hid.c_str() , ibooker );
894  ibooker.tag(mod_single.NrOfClusterizedStrips, detid);
895  mod_single.NrOfClusterizedStrips->setAxisTitle("number of clusterized strips");
896  }
897 }
898 //
899 // -- Create Module Level MEs
900 //
902 
903  SiStripHistoId hidmanager;
904 
905  LayerMEs layerMEs;
906  layerMEs.LayerClusterStoN = 0;
907  layerMEs.LayerClusterStoNTrend = 0;
908  layerMEs.LayerClusterCharge = 0;
909  layerMEs.LayerClusterChargeTrend = 0;
910  layerMEs.LayerClusterNoise = 0;
911  layerMEs.LayerClusterNoiseTrend = 0;
912  layerMEs.LayerClusterWidth = 0;
913  layerMEs.LayerClusterWidthTrend = 0;
914  layerMEs.LayerLocalOccupancy = 0;
915  layerMEs.LayerLocalOccupancyTrend = 0;
916  layerMEs.LayerNumberOfClusterProfile = 0;
917  layerMEs.LayerClusterWidthProfile = 0;
918 
919  //Cluster Width
921  layerMEs.LayerClusterWidth=bookME1D("TH1ClusterWidth", hidmanager.createHistoLayer("Summary_ClusterWidth","layer",label,"").c_str() , ibooker );
922  if (createTrendMEs)
923  layerMEs.LayerClusterWidthTrend=bookMETrend(hidmanager.createHistoLayer("Trend_ClusterWidth","layer",label,"").c_str() , ibooker );
924  }
925 
926  //Cluster Noise
928  layerMEs.LayerClusterNoise=bookME1D("TH1ClusterNoise", hidmanager.createHistoLayer("Summary_ClusterNoise","layer",label,"").c_str() , ibooker );
929  if (createTrendMEs)
930  layerMEs.LayerClusterNoiseTrend=bookMETrend(hidmanager.createHistoLayer("Trend_ClusterNoise","layer",label,"").c_str() , ibooker);
931  }
932 
933  //Cluster Charge
935  layerMEs.LayerClusterCharge=bookME1D("TH1ClusterCharge", hidmanager.createHistoLayer("Summary_ClusterCharge","layer",label,"").c_str() , ibooker );
936  if (createTrendMEs)
937  layerMEs.LayerClusterChargeTrend=bookMETrend(hidmanager.createHistoLayer("Trend_ClusterCharge","layer",label,"").c_str(),ibooker);
938  }
939 
940  //Cluster StoN
942  layerMEs.LayerClusterStoN=bookME1D("TH1ClusterStoN", hidmanager.createHistoLayer("Summary_ClusterSignalOverNoise","layer",label,"").c_str() , ibooker );
943  if (createTrendMEs)
944  layerMEs.LayerClusterStoNTrend=bookMETrend(hidmanager.createHistoLayer("Trend_ClusterSignalOverNoise","layer",label,"").c_str(),ibooker);
945  }
946 
947  //Cluster Occupancy
949  layerMEs.LayerLocalOccupancy=bookME1D("TH1ModuleLocalOccupancy", hidmanager.createHistoLayer("Summary_ClusterLocalOccupancy","layer",label,"").c_str() , ibooker );
950  if (createTrendMEs)
951  layerMEs.LayerLocalOccupancyTrend=bookMETrend(hidmanager.createHistoLayer("Trend_ClusterLocalOccupancy","layer",label,"").c_str(),ibooker);
952  }
953 
954  // # of Cluster Profile
956  std::string hid = hidmanager.createHistoLayer("NumberOfClusterProfile","layer",label,"");
957  layerMEs.LayerNumberOfClusterProfile = ibooker.bookProfile(hid, hid, ndets, 0.5, ndets+0.5,21, -0.5, 20.5);
958  }
959 
960  // Cluster Width Profile
962  std::string hid = hidmanager.createHistoLayer("ClusterWidthProfile","layer",label,"");
963  layerMEs.LayerClusterWidthProfile = ibooker.bookProfile(hid, hid, ndets, 0.5, ndets+0.5, 20, -0.5, 19.5);
964  }
965 
966  LayerMEsMap[label]=layerMEs;
967 }
968 //
969 // -- Create SubDetector MEs
970 //
972 
973  SubDetMEs subdetMEs;
974  subdetMEs.totNClusters = 0;
975  subdetMEs.SubDetTotClusterTH1 = 0;
976  subdetMEs.SubDetTotClusterProf = 0;
977  subdetMEs.SubDetClusterApvProf = 0;
978  subdetMEs.SubDetClusterApvTH2 = 0;
979  subdetMEs.SubDetClusterDBxCycleProf = 0;
980  subdetMEs.SubDetApvDBxProf2 = 0;
981  subdetMEs.SubDetClusterChargeTH1 = 0;
982  subdetMEs.SubDetClusterWidthTH1 = 0;
983 
985  // cluster charge
987  HistoName = "ClusterCharge__" + label;
988  subdetMEs.SubDetClusterChargeTH1 = bookME1D("TH1ClusterCharge",HistoName.c_str() , ibooker);
989  subdetMEs.SubDetClusterChargeTH1->setAxisTitle("Cluster charge [ADC counts]");
990  subdetMEs.SubDetClusterChargeTH1->getTH1()->StatOverflows(kTRUE); // over/underflows in Mean calculation
991  }
992  // cluster width
994  HistoName = "ClusterWidth__" + label;
995  subdetMEs.SubDetClusterWidthTH1 = bookME1D("TH1ClusterWidth",HistoName.c_str() , ibooker);
996  subdetMEs.SubDetClusterWidthTH1->setAxisTitle("Cluster width [strips]");
997  subdetMEs.SubDetClusterWidthTH1->getTH1()->StatOverflows(kTRUE); // over/underflows in Mean calculation
998  }
999  // Total Number of Cluster - 1D
1001  HistoName = "TotalNumberOfCluster__" + label;
1002  subdetMEs.SubDetTotClusterTH1 = bookME1D("TH1TotalNumberOfClusters",HistoName.c_str() , ibooker);
1003  subdetMEs.SubDetTotClusterTH1->setAxisTitle("Total number of clusters in subdetector");
1004  subdetMEs.SubDetTotClusterTH1->getTH1()->StatOverflows(kTRUE); // over/underflows in Mean calculation
1005  }
1006  // Total Number of Cluster vs Time - Profile
1009  HistoName = "TotalNumberOfClusterProfile__" + label;
1010  subdetMEs.SubDetTotClusterProf = ibooker.bookProfile(HistoName,HistoName,
1011  Parameters.getParameter<int32_t>("Nbins"),
1012  Parameters.getParameter<double>("xmin"),
1013  Parameters.getParameter<double>("xmax"),
1014  0 , 0 , "" );
1015  subdetMEs.SubDetTotClusterProf->setAxisTitle(Parameters.getParameter<std::string>("xaxis"),1);
1016  if (subdetMEs.SubDetTotClusterProf->kind() == MonitorElement::DQM_KIND_TPROFILE) subdetMEs.SubDetTotClusterProf->getTH1()->SetBit(TH1::kCanRebin);
1017  }
1018 
1019  // Total Number of Cluster vs APV cycle - Profile
1021  edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TProfClustersApvCycle");
1022  HistoName = "Cluster_vs_ApvCycle__" + label;
1023  subdetMEs.SubDetClusterApvProf=ibooker.bookProfile(HistoName,HistoName,
1024  Parameters.getParameter<int32_t>("Nbins"),
1025  Parameters.getParameter<double>("xmin"),
1026  Parameters.getParameter<double>("xmax"),
1027  200, //that parameter should not be there !?
1028  Parameters.getParameter<double>("ymin"),
1029  Parameters.getParameter<double>("ymax"),
1030  "" );
1031  subdetMEs.SubDetClusterApvProf->setAxisTitle("Apv Cycle (Corrected Absolute Bx % 70)",1);
1032  }
1033 
1034  // Total Number of Clusters vs ApvCycle - 2D
1037  HistoName = "Cluster_vs_ApvCycle_2D__" + label;
1038  // Adjusting the scale for 2D histogram
1039  double h2ymax = 9999.0;
1040  double yfact = Parameters.getParameter<double>("yfactor");
1041  if(label.find("TIB") != std::string::npos) h2ymax = (6984.*256.)*yfact;
1042  else if (label.find("TID") != std::string::npos) h2ymax = (2208.*256.)*yfact;
1043  else if (label.find("TOB") != std::string::npos) h2ymax = (12906.*256.)*yfact;
1044  else if (label.find("TEC") != std::string::npos) h2ymax = (7552.*2.*256.)*yfact;
1045 
1046  subdetMEs.SubDetClusterApvTH2=ibooker.book2D(HistoName,HistoName,
1047  Parameters.getParameter<int32_t>("Nbinsx"),
1048  Parameters.getParameter<double>("xmin"),
1049  Parameters.getParameter<double>("xmax"),
1050  Parameters.getParameter<int32_t>("Nbinsy"),
1051  Parameters.getParameter<double>("ymin"),
1052  h2ymax);
1053  subdetMEs.SubDetClusterApvTH2->setAxisTitle("Apv Cycle (Corrected Absolute Bx % 70))",1);
1054  subdetMEs.SubDetClusterApvTH2->setAxisTitle("Total # of Clusters",2);
1055 
1056  }
1057  // Total Number of Cluster vs DeltaBxCycle - Profile
1059  edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TProfClustersVsDBxCycle");
1060  HistoName = "Cluster_vs_DeltaBxCycle__" + label;
1061  subdetMEs.SubDetClusterDBxCycleProf = ibooker.bookProfile(HistoName,HistoName,
1062  Parameters.getParameter<int32_t>("Nbins"),
1063  Parameters.getParameter<double>("xmin"),
1064  Parameters.getParameter<double>("xmax"),
1065  200, //that parameter should not be there !?
1066  Parameters.getParameter<double>("ymin"),
1067  Parameters.getParameter<double>("ymax"),
1068  "" );
1069  subdetMEs.SubDetClusterDBxCycleProf->setAxisTitle("Delta Bunch Crossing Cycle",1);
1070  }
1071  // DeltaBx vs ApvCycle - 2DProfile
1074  HistoName = "DeltaBx_vs_ApvCycle__" + label;
1075  subdetMEs.SubDetApvDBxProf2 = ibooker.bookProfile2D(HistoName,HistoName,
1076  Parameters.getParameter<int32_t>("Nbinsx"),
1077  Parameters.getParameter<double>("xmin"),
1078  Parameters.getParameter<double>("xmax"),
1079  Parameters.getParameter<int32_t>("Nbinsy"),
1080  Parameters.getParameter<double>("ymin"),
1081  Parameters.getParameter<double>("ymax"),
1082  Parameters.getParameter<double>("zmin"),
1083  Parameters.getParameter<double>("zmax"),
1084  "" );
1085  subdetMEs.SubDetApvDBxProf2->setAxisTitle("APV Cycle (Corrected Absolute Bx % 70)",1);
1086  subdetMEs.SubDetApvDBxProf2->setAxisTitle("Delta Bunch Crossing Cycle",2);
1087  }
1088  SubDetMEsMap[label]=subdetMEs;
1089 }
1090 
1091 //
1092 // -- Fill Module Level Histograms
1093 //
1095 
1096  if(moduleswitchclusposon && (mod_mes.ClusterPosition)) // position of cluster
1097  (mod_mes.ClusterPosition)->Fill(cluster.position);
1098 
1099  // position of digis in cluster
1101  for(int ipos=cluster.start+1; ipos<=cluster.start+cluster.width; ipos++){
1102  (mod_mes.ClusterDigiPosition)->Fill(ipos);
1103  }
1104  }
1105 
1106  if(moduleswitchcluswidthon && (mod_mes.ClusterWidth)) // width of cluster
1107  (mod_mes.ClusterWidth)->Fill(static_cast<float>(cluster.width));
1108 
1109  if(moduleswitchclusstonon && (mod_mes.ClusterSignalOverNoise)) {// SignalToNoise
1110  if (cluster.noise > 0)
1111  (mod_mes.ClusterSignalOverNoise)->Fill(cluster.charge/cluster.noise);
1112  }
1113 
1114  if(moduleswitchclusstonVsposon && (mod_mes.ClusterSignalOverNoiseVsPos)) {// SignalToNoise
1115  if (cluster.noise > 0)
1116  (mod_mes.ClusterSignalOverNoiseVsPos)->Fill(cluster.position,cluster.charge/cluster.noise);
1117  }
1118 
1119  if(moduleswitchclusnoiseon && (mod_mes.ClusterNoise)) // Noise
1120  (mod_mes.ClusterNoise)->Fill(cluster.noise);
1121 
1122  if(moduleswitchcluschargeon && (mod_mes.ClusterCharge)) // charge of cluster
1123  (mod_mes.ClusterCharge)->Fill(cluster.charge);
1124 
1125 }
1126 //
1127 // -- Fill Layer Level MEs
1128 //
1130 
1131  if(layerswitchclusstonon) {
1132  fillME(layerMEs.LayerClusterStoN ,cluster.charge/cluster.noise);
1133  if (createTrendMEs) {
1134  fillME(layerMEs.LayerClusterStoNTrend,trendVar,cluster.charge/cluster.noise);
1135  }
1136  }
1137 
1139  fillME(layerMEs.LayerClusterCharge,cluster.charge);
1140  if (createTrendMEs) {
1141  fillME(layerMEs.LayerClusterChargeTrend,trendVar,cluster.charge);
1142  }
1143  }
1144 
1146  fillME(layerMEs.LayerClusterNoise ,cluster.noise);
1147  if (createTrendMEs) {
1148  fillME(layerMEs.LayerClusterNoiseTrend,trendVar,cluster.noise);
1149  }
1150  }
1151 
1153  fillME(layerMEs.LayerClusterWidth ,cluster.width);
1154  if (createTrendMEs) {
1155  fillME(layerMEs.LayerClusterWidthTrend,trendVar,cluster.width);
1156  }
1157  }
1158 
1159 }
1160 //------------------------------------------------------------------------------------------
1162 {
1163  edm::ParameterSet ParametersTrend = trendVsLs_ ? conf_.getParameter<edm::ParameterSet>("TrendingLS") : conf_.getParameter<edm::ParameterSet>("Trending");
1164  MonitorElement* me = ibooker.bookProfile(HistoName,HistoName,
1165  ParametersTrend.getParameter<int32_t>("Nbins"),
1166  ParametersTrend.getParameter<double>("xmin"),
1167  ParametersTrend.getParameter<double>("xmax"),
1168  0 , 0 , "" );
1169  if(!me) return me;
1170  me->setAxisTitle(ParametersTrend.getParameter<std::string>("xaxis"),1);
1171  if (me->kind() == MonitorElement::DQM_KIND_TPROFILE) me->getTH1()->SetBit(TH1::kCanRebin);
1172  return me;
1173 }
1174 
1175 //------------------------------------------------------------------------------------------
1176 MonitorElement* SiStripMonitorCluster::bookME1D(const char* ParameterSetLabel, const char* HistoName , DQMStore::IBooker & ibooker)
1177 {
1178  Parameters = conf_.getParameter<edm::ParameterSet>(ParameterSetLabel);
1179  return ibooker.book1D(HistoName,HistoName,
1180  Parameters.getParameter<int32_t>("Nbinx"),
1181  Parameters.getParameter<double>("xmin"),
1182  Parameters.getParameter<double>("xmax")
1183  );
1184 }
1185 
1186 int SiStripMonitorCluster::FindRegion(int nstrip,int npix){
1187 
1188  double kplus= k0*(1+dk0/100);
1189  double kminus=k0*(1-dk0/100);
1190  int region=0;
1191 
1192  if (nstrip!=0 && npix >= (nstrip*kminus-q0) && npix <=(nstrip*kplus+q0)) region=1;
1193  else if (nstrip!=0 && npix < (nstrip*kminus-q0) && nstrip <= maxClus) region=2;
1194  else if (nstrip!=0 && npix < (nstrip*kminus-q0) && nstrip > maxClus) region=3;
1195  else if (nstrip!=0 && npix > (nstrip*kplus+q0)) region=4;
1196  else if (npix > minPix && nstrip==0) region=5;
1197  return region;
1198 
1199 }
RunNumber_t run() const
Definition: EventID.h:39
void ResetModuleMEs(uint32_t idet)
T getParameter(std::string const &) const
virtual void analyze(const edm::Event &, const edm::EventSetup &)
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
void setSiStripFolderName(std::string name)
MonitorElement * PixVsStripMultiplicityRegions
std::pair< const std::string, const char * > getSubDetFolderAndTag(const uint32_t &detid, const TrackerTopology *tTopo)
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::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:157
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
MonitorElement * GlobalCStripVsCpix
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)
edm::ESHandle< SiStripDetCabling > SiStripDetCabling_
std::pair< std::string, int32_t > GetSubDetAndLayer(const uint32_t &detid, const TrackerTopology *tTopo, bool ring_flag=0)
#define NULL
Definition: scimark2.h:8
MonitorElement * ClusterSignalOverNoiseVsPos
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
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)
std::map< uint32_t, ModMEs > ModuleMEsMap
bool getStatus(edm::Event const &e, edm::EventSetup const &eSetup)
int iEvent
Definition: GenABIO.cc:230
void createMEs(const edm::EventSetup &es, DQMStore::IBooker &ibooker)
std::map< std::string, std::string > SubDetPhasePartMap
MonitorElement * GlobalApvCycleDBxTH2
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
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:48
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.
data_type const * data(size_t cell) const
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
void tag(MonitorElement *, unsigned int)
Definition: DQMStore.cc:286
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)
void dqmBeginRun(const edm::Run &, const edm::EventSetup &)
bool isValid() const
Definition: HandleBase.h:75
edm::EDGetTokenT< EventWithHistory > historyProducerToken_
MonitorElement * GlobalMainDiagonalPosition
SiStripDCSStatus * dcsStatus_
bool failedToGet() const
Definition: HandleBase.h:79
GenericTriggerEventFlag * genTriggerEventFlagBPTXfilter_
void setLayerFolder(uint32_t rawdetid, const TrackerTopology *tTopo, int32_t layer=0, bool ring_flag=0)
void fillME(MonitorElement *ME, float value1)
SiStripMonitorCluster(const edm::ParameterSet &)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
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
T const * product() const
Definition: ESHandle.h:86
std::string HistoName
MonitorElement * StripNoise3Cycle
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
edm::EventID id() const
Definition: EventBase.h:60
iterator end()
Definition: DetSetNew.h:70
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > clusterProducerPixToken_
std::map< std::string, SubDetMEs > SubDetMEsMap
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
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
volatile std::atomic< bool > shutdown_flag false
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:86
edm::EDGetTokenT< APVCyclePhaseCollection > apvPhaseProducerToken_
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)
MonitorElement * NclusVsCycleTimeProf2D
void fillModuleMEs(ModMEs &mod_mes, ClusterProperties &cluster)
Definition: Run.h:41
int size() const
iterator begin()
Definition: DetSetNew.h:67