CMS 3D CMS Logo

APVValidationPlots.cc
Go to the documentation of this file.
1 // system include files
2 #include <memory>
3 
4 // user include files
7 
10 
12 
14 
19 
21 
22 #include "TH1F.h"
23 #include "TFile.h"
24 #include "TCanvas.h"
25 #include "TH1.h"
26 #include "TH2F.h"
27 #include "TH1D.h"
28 #include "TProfile.h"
29 #include "TStyle.h"
30 #include "TTree.h"
31 
32 #include <sstream>
33 #include <iostream>
34 #include <vector>
35 
36 //
37 // class decleration
38 //
39 
41 public:
44 
45  explicit APVValidationPlots(const edm::ParameterSet&);
46 
47 private:
48  void analyze(const edm::Event&, const edm::EventSetup&) override;
49  void endJob() override;
50 
53 
54  // ----------member data ---------------------------
55 };
56 
57 //
58 // constants, enums and typedefs
59 //
60 
61 //
62 // static data member definitions
63 //
64 
65 //
66 // constructors and destructor
67 //
69  : infilename(iConfig.getUntrackedParameter<std::string>("inputFilename", "in.root")),
70  outfilename(iConfig.getUntrackedParameter<std::string>("outputFilename", "out.root"))
71 
72 {
73  //now do what ever initialization is needed
74 }
75 
76 //
77 // member functions
78 //
79 
80 // ------------ method called to for each event ------------
82 
83 // ------------ method called once each job just after ending the event loop ------------
85  std::ostringstream oss;
86  oss << 1; //runNumber
87 
88  DQMStore* dqmStore = edm::Service<DQMStore>().operator->();
89  dqmStore->setCurrentFolder("ChannelStatusPlots");
90 
91  // Initialize histograms
92  std::vector<std::string> subDetName;
93  std::vector<unsigned int> nLayers;
94  std::vector<std::string> layerName;
95  subDetName.push_back("");
96  subDetName.push_back("TIB");
97  subDetName.push_back("TID");
98  subDetName.push_back("TOB");
99  subDetName.push_back("TEC");
100  nLayers.push_back(0);
101  nLayers.push_back(4);
102  nLayers.push_back(3);
103  nLayers.push_back(6);
104  nLayers.push_back(9);
105  layerName.push_back("");
106  layerName.push_back("Layer");
107  layerName.push_back("Disk");
108  layerName.push_back("Layer");
109  layerName.push_back("Disk");
110 
112  std::string histoTitle;
113  // Histograms
114  // indexes in these arrays are [SubDetId-2][LayerN]
115  // histograms for [SubDetId-2][0] are global for the subdetector
116  // histogram for [0][0] is global for the tracker
117  TH2F* medianVsAbsoluteOccupancy[5][10];
118  TH1F* medianOccupancy[5][10];
119  TH1F* absoluteOccupancy[5][10];
120  for (unsigned int i = 0; i < subDetName.size(); i++) {
121  for (unsigned int j = 0; j <= nLayers[i]; j++) {
122  histoName = "medianVsAbsoluteOccupancy" + subDetName[i];
123  if (j != 0) {
124  oss.str("");
125  oss << j;
126  histoName += layerName[i] + oss.str();
127  }
128  histoTitle = "Median APV occupancy vs. absolute APV occupancy";
129  if (i != 0)
130  histoTitle += " in " + subDetName[i];
131  if (j != 0) {
132  histoTitle += " " + layerName[i] + " " + oss.str();
133  }
134  MonitorElement* tmp = dqmStore->book2D(histoName.c_str(), histoTitle.c_str(), 1000, 0., 6., 1000, -1., 3.);
135  medianVsAbsoluteOccupancy[i][j] = tmp->getTH2F();
136  medianVsAbsoluteOccupancy[i][j]->Rebin2D(10, 10);
137  medianVsAbsoluteOccupancy[i][j]->GetXaxis()->SetTitle("log_{10}(Abs. Occupancy)");
138  medianVsAbsoluteOccupancy[i][j]->GetYaxis()->SetTitle("log_{10}(Median Occupancy)");
139  //
140  histoName = "medianOccupancy" + subDetName[i];
141  if (j != 0) {
142  oss.str("");
143  oss << j;
144  histoName += layerName[i] + oss.str();
145  }
146  histoTitle = "Median APV occupancy";
147  if (i != 0)
148  histoTitle += " in " + subDetName[i];
149  if (j != 0) {
150  histoTitle += " " + layerName[i] + " " + oss.str();
151  }
152  tmp = dqmStore->book1D(histoName.c_str(), histoTitle.c_str(), 1000, -1., 3.);
153  medianOccupancy[i][j] = tmp->getTH1F();
154  medianOccupancy[i][j]->GetXaxis()->SetTitle("log_{10}(Occupancy)");
155  medianOccupancy[i][j]->GetYaxis()->SetTitle("APVs");
156  //
157  histoName = "absoluteOccupancy" + subDetName[i];
158  if (j != 0) {
159  oss.str("");
160  oss << j;
161  histoName += layerName[i] + oss.str();
162  }
163  histoTitle = "Absolute APV occupancy";
164  if (i != 0)
165  histoTitle += " in " + subDetName[i];
166  if (j != 0) {
167  histoTitle += " " + layerName[i] + " " + oss.str();
168  }
169  tmp = dqmStore->book1D(histoName.c_str(), histoTitle.c_str(), 1000, 0., 6.);
170  absoluteOccupancy[i][j] = tmp->getTH1F();
171  absoluteOccupancy[i][j]->GetXaxis()->SetTitle("log_{10}(Occupancy)");
172  absoluteOccupancy[i][j]->GetYaxis()->SetTitle("APVs");
173  }
174  }
175 
176  TFile* infile = new TFile(infilename.c_str(), "READ");
177  TTree* intree = (TTree*)infile->Get("moduleOccupancy");
178 
179  // Declaration of leaf types
180  Int_t DetRawId;
181  Int_t SubDetId;
182  Int_t Layer_Ring;
183  Int_t Disc;
184  Int_t IsBack;
185  Int_t IsExternalString;
186  Int_t IsZMinusSide;
187  Int_t RodStringPetal;
188  Int_t IsStereo;
189  Int_t ModulePosition;
190  Int_t NumberOfStrips;
191  Float_t APVGlobalPositionX;
192  Float_t APVGlobalPositionY;
193  Float_t APVGlobalPositionZ;
194  Int_t APVNumber;
195  Int_t APVAbsoluteOccupancy;
196  Double_t APVMedianOccupancy;
197  intree->SetBranchAddress("DetRawId", &DetRawId);
198  intree->SetBranchAddress("SubDetId", &SubDetId);
199  intree->SetBranchAddress("Layer_Ring", &Layer_Ring);
200  intree->SetBranchAddress("Disc", &Disc);
201  intree->SetBranchAddress("IsBack", &IsBack);
202  intree->SetBranchAddress("IsExternalString", &IsExternalString);
203  intree->SetBranchAddress("IsZMinusSide", &IsZMinusSide);
204  intree->SetBranchAddress("RodStringPetal", &RodStringPetal);
205  intree->SetBranchAddress("IsStereo", &IsStereo);
206  intree->SetBranchAddress("ModuleNumber", &ModulePosition);
207  intree->SetBranchAddress("NumberOfStrips", &NumberOfStrips);
208  intree->SetBranchAddress("APVGlobalPositionX", &APVGlobalPositionX);
209  intree->SetBranchAddress("APVGlobalPositionY", &APVGlobalPositionY);
210  intree->SetBranchAddress("APVGlobalPositionZ", &APVGlobalPositionZ);
211  intree->SetBranchAddress("APVNumber", &APVNumber);
212  intree->SetBranchAddress("APVAbsoluteOccupancy", &APVAbsoluteOccupancy);
213  intree->SetBranchAddress("APVMedianOccupancy", &APVMedianOccupancy);
214 
215  for (int i = 0; i < intree->GetEntries(); i++) {
216  intree->GetEntry(i);
217 
218  double logMedianOccupancy = -1;
219  double logAbsoluteOccupancy = -1;
220 
221  if (APVMedianOccupancy > 0)
222  logMedianOccupancy = log10(APVMedianOccupancy);
223  if (APVAbsoluteOccupancy > 0)
224  logAbsoluteOccupancy = log10(APVAbsoluteOccupancy);
225 
226  // The layer/disk information is stored in Layer_Ring for TIB/TOB and in Disc for TID/TEC
227  unsigned int layer = 0;
228  if (SubDetId == 3 || SubDetId == 5)
229  layer = Layer_Ring;
230  else
231  layer = Disc;
232 
233  // Fill histograms for all the tracker
234  medianVsAbsoluteOccupancy[0][0]->Fill(logAbsoluteOccupancy, logMedianOccupancy);
235  medianOccupancy[0][0]->Fill(logMedianOccupancy);
236  absoluteOccupancy[0][0]->Fill(logAbsoluteOccupancy);
237  // Fill summary histograms for each subdetector
238  medianVsAbsoluteOccupancy[SubDetId - 2][0]->Fill(logAbsoluteOccupancy, logMedianOccupancy);
239  medianOccupancy[SubDetId - 2][0]->Fill(logMedianOccupancy);
240  absoluteOccupancy[SubDetId - 2][0]->Fill(logAbsoluteOccupancy);
241  // Fill histograms for each layer/disk
242  medianVsAbsoluteOccupancy[SubDetId - 2][layer]->Fill(logAbsoluteOccupancy, logMedianOccupancy);
243  medianOccupancy[SubDetId - 2][layer]->Fill(logMedianOccupancy);
244  absoluteOccupancy[SubDetId - 2][layer]->Fill(logAbsoluteOccupancy);
245  }
246 
247  dqmStore->cd();
248  dqmStore->save(outfilename, "ChannelStatusPlots");
249 }
250 
251 //define this as a plug-in
APVValidationPlots::APVValidationPlots
APVValidationPlots(const edm::ParameterSet &)
Definition: APVValidationPlots.cc:68
mps_fire.i
i
Definition: mps_fire.py:428
DQMStore.h
dqm::legacy::MonitorElement
Definition: MonitorElement.h:462
EDAnalyzer.h
APVValidationPlots::infilename
const std::string infilename
Definition: APVValidationPlots.cc:51
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
dqm::legacy::DQMStore
Definition: DQMStore.h:728
SiStripCommissioningSource_FromRAW_cfg.outfilename
outfilename
Definition: SiStripCommissioningSource_FromRAW_cfg.py:122
Service.h
APVValidationPlots::MonitorElement
dqm::legacy::MonitorElement MonitorElement
Definition: APVValidationPlots.cc:43
L1TBPTX_cfi.dqmStore
dqmStore
Definition: L1TBPTX_cfi.py:6
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
MuonTCMETValueMapProducer_cff.nLayers
nLayers
Definition: MuonTCMETValueMapProducer_cff.py:38
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
APVValidationPlots::DQMStore
dqm::legacy::DQMStore DQMStore
Definition: APVValidationPlots.cc:42
edm::Service
Definition: Service.h:30
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:58
DetSetVector.h
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
APVValidationPlots::endJob
void endJob() override
Definition: APVValidationPlots.cc:84
std
Definition: JetResolutionObject.h:76
APVValidationPlots
Definition: APVValidationPlots.cc:40
Frameworkfwd.h
HltBtagPostValidation_cff.histoName
histoName
Definition: HltBtagPostValidation_cff.py:17
timingPdfMaker.infile
infile
Definition: timingPdfMaker.py:349
APVValidationPlots::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: APVValidationPlots.cc:81
ParameterSet.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
SiStripClusterCollection.h
edm::Event
Definition: Event.h:73
phase1PixelTopology::layerName
constexpr char const * layerName[numberOfLayers]
Definition: phase1PixelTopology.h:37
SiStripCommissioningSource_FromEDM_cfg.infilename
infilename
Definition: SiStripCommissioningSource_FromEDM_cfg.py:64
StripSubdetector.h
DetSetVectorNew.h
APVValidationPlots::outfilename
const std::string outfilename
Definition: APVValidationPlots.cc:52