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