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