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