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