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