CMS 3D CMS Logo

CMHistograms.cc
Go to the documentation of this file.
4 
5 #include "DQM/SiStripMonitorHardware/interface/CMHistograms.hh"
6 
7 CMHistograms::CMHistograms() {
8  for (unsigned int i(0); i < 500; i++) {
9  doFed_[i] = false;
10  }
11 }
12 
13 CMHistograms::~CMHistograms() {}
14 
15 void CMHistograms::initialise(const edm::ParameterSet& iConfig, std::ostringstream* pDebugStream) {
16  getConfigForHistogram(medianAPV1vsAPV0_, "MedianAPV1vsAPV0", iConfig, pDebugStream);
17  getConfigForHistogram(medianAPV0minusAPV1_, "MedianAPV0minusAPV1", iConfig, pDebugStream);
18 
19  getConfigForHistogram(meanCMPerFedvsFedId_, "MeanCMPerFedvsFedId", iConfig, pDebugStream);
20  getConfigForHistogram(meanCMPerFedvsTime_, "MeanCMPerFedvsTime", iConfig, pDebugStream);
21  getConfigForHistogram(variationsPerFedvsFedId_, "VariationsPerFedvsFedId", iConfig, pDebugStream);
22  getConfigForHistogram(variationsPerFedvsTime_, "VariationsPerFedvsTime", iConfig, pDebugStream);
23 
24  getConfigForHistogram(medianAPV1vsAPV0perFED_, "MedianAPV1vsAPV0perFED", iConfig, pDebugStream);
25  getConfigForHistogram(medianAPV0minusAPV1perFED_, "MedianAPV0minusAPV1perFED", iConfig, pDebugStream);
26 
27  getConfigForHistogram(medianperChannel_, "MedianperChannel", iConfig, pDebugStream);
28  getConfigForHistogram(medianAPV0minusAPV1perChannel_, "MedianAPV0minusAPV1perChannel", iConfig, pDebugStream);
29 
30  getConfigForHistogram(tkMapConfig_, "TkHistoMap", iConfig, pDebugStream);
31 
32  if (iConfig.exists("FedIdVec")) {
33  std::vector<unsigned int> lIdVec = iConfig.getUntrackedParameter<std::vector<unsigned int> >("FedIdVec");
34  for (unsigned int i(0); i < lIdVec.size(); i++) {
35  if (lIdVec.at(i) < 500)
36  doFed_[lIdVec.at(i)] = true;
37  }
38  }
39 }
40 
41 void CMHistograms::fillHistograms(const std::vector<CMvalues>& aVec, float aTime, unsigned int aFedId) {
42  float lMean = 0;
43  float lPrevMean = 0;
44 
45  for (unsigned iEle(0); iEle < aVec.size(); iEle++) { //loop on elements
46 
47  CMvalues lVal = aVec[iEle];
48 
49  if (lVal.Medians.first >= 1024 || lVal.Medians.second >= 1024) {
50  std::cout << "----- WARNING ! New max found: " << lVal.Medians.first << " " << lVal.Medians.second << " "
51  << __FILE__ << " " << __LINE__ << std::endl;
52  }
53 
54  fillHistogram(medianAPV1vsAPV0_, lVal.Medians.first, lVal.Medians.second);
55  fillHistogram(medianAPV0minusAPV1_, lVal.Medians.first - lVal.Medians.second);
56 
57  lMean += lVal.Medians.first + lVal.Medians.second;
58  lPrevMean += lVal.PreviousMedians.first + lVal.PreviousMedians.second;
59 
60  if (doFed_[aFedId]) {
61  fillHistogram(medianAPV1vsAPV0perFEDMap_[aFedId], lVal.Medians.first, lVal.Medians.second);
62  fillHistogram(medianAPV0minusAPV1perFEDMap_[aFedId], lVal.Medians.first - lVal.Medians.second);
63  fillHistogram(medianperChannelMap_[aFedId][lVal.ChannelID], lVal.Medians.first);
64  fillHistogram(medianAPV0minusAPV1perChannelMap_[aFedId][lVal.ChannelID],
65  lVal.Medians.first - lVal.Medians.second);
66  }
67 
68  } //loop on elements
69 
70  if (!aVec.empty()) {
71  lMean = lMean / (2 * aVec.size());
72  lPrevMean = lPrevMean / (2 * aVec.size());
73  }
74 
75  fillHistogram(meanCMPerFedvsFedId_, aFedId, lMean);
76  fillHistogram(meanCMPerFedvsTime_, aTime, lMean);
77  fillHistogram(variationsPerFedvsFedId_, aFedId, lMean - lPrevMean);
78  fillHistogram(variationsPerFedvsTime_, aTime, lMean - lPrevMean);
79 }
80 
81 void CMHistograms::bookTopLevelHistograms(DQMStore::IBooker& ibooker, const TkDetMap* tkDetMap) {
82  //book FED level histograms
83  //get FED IDs
84  //const unsigned int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
85  const unsigned int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID;
86  histosBooked_.resize(siStripFedIdMax + 1, false);
87 
88  std::string lDir = ibooker.pwd() + "/";
89 
90  ibooker.cd(lDir);
91 
92  ibooker.setCurrentFolder(lDir);
93 
94  book2DHistogram(ibooker,
95  medianAPV1vsAPV0_,
96  "MedianAPV1vsAPV0",
97  "median APV1 vs APV0",
98  250,
99  0,
100  1024,
101  250,
102  0,
103  1024,
104  "median APV0",
105  "median APV1");
106 
107  bookHistogram(ibooker,
108  medianAPV0minusAPV1_,
109  "MedianAPV0minusAPV1",
110  "median APV0 - median APV1",
111  500,
112  -500,
113  500,
114  "median APV0 - median APV1");
115 
116  bookProfile(ibooker,
117  meanCMPerFedvsFedId_,
118  "MeanCMPerFedvsFedId",
119  "<CM> vs fedID",
120  440,
121  50,
122  490,
123  -1000,
124  1000,
125  "fedID",
126  "<CM>^{FED}");
127 
128  bookProfile(ibooker, meanCMPerFedvsTime_, "MeanCMPerFedvsTime", "<CM> vs time", 0, 1000, "Time", "<CM>^{FED}");
129 
130  bookProfile(ibooker,
131  variationsPerFedvsFedId_,
132  "VariationsPerFedvsFedId",
133  "<CM> vs fedID",
134  440,
135  50,
136  490,
137  -1000,
138  1000,
139  "fedID",
140  "<CM>^{FED}_{t}-<CM>^{FED}_{t-1}");
141 
142  bookProfile(ibooker,
143  variationsPerFedvsTime_,
144  "VariationsPerFedvsTime",
145  "<CM> vs time",
146  0,
147  1000,
148  "Time",
149  "<CM>^{FED}_{t}-<CM>^{FED}_{t-1}");
150 
151  ibooker.cd(lDir);
152 
153  //book map after, as it creates a new folder...
154  if (tkMapConfig_.enabled) {
155  tkmapCM_[0] = std::make_unique<TkHistoMap>(tkDetMap, "SiStrip/TkHisto", "TkHMap_MeanCMAPV", 0., true);
156  tkmapCM_[1] = std::make_unique<TkHistoMap>(tkDetMap, "SiStrip/TkHisto", "TkHMap_RmsCMAPV", 0., true);
157  tkmapCM_[2] = std::make_unique<TkHistoMap>(tkDetMap, "SiStrip/TkHisto", "TkHMap_MeanCMAPV0minusAPV1", -500., true);
158  tkmapCM_[3] = std::make_unique<TkHistoMap>(tkDetMap, "SiStrip/TkHisto", "TkHMap_RmsCMAPV0minusAPV1", -500., true);
159  } else {
160  tkmapCM_[0] = nullptr;
161  tkmapCM_[1] = nullptr;
162  tkmapCM_[2] = nullptr;
163  tkmapCM_[3] = nullptr;
164  }
165 
166  for (unsigned int i = sistrip::FED_ID_MIN; i <= sistrip::FED_ID_MAX; i++)
167  if (doFed_[i])
168  bookFEDHistograms(ibooker, i);
169 }
170 
171 void CMHistograms::bookFEDHistograms(DQMStore::IBooker& ibooker, unsigned int fedId) {
172  if (!histosBooked_[fedId]) {
173  //will do that only once
174 
175  SiStripFedKey fedKey(fedId, 0, 0, 0);
176  std::stringstream fedIdStream;
177  fedIdStream << fedId;
178 
179  ibooker.setCurrentFolder(fedKey.path());
180 
181  book2DHistogram(ibooker,
182  medianAPV1vsAPV0perFED_,
183  medianAPV1vsAPV0perFEDMap_[fedId],
184  "MedianAPV1vsAPV0forFED" + fedIdStream.str(),
185  "median APV1 vs APV0 for FED " + fedIdStream.str(),
186  250,
187  0,
188  500,
189  250,
190  0,
191  500,
192  "APV0",
193  "APV1");
194 
195  bookHistogram(ibooker,
196  medianAPV0minusAPV1perFED_,
197  medianAPV0minusAPV1perFEDMap_[fedId],
198  "MedianAPV0minusAPV1forFED" + fedIdStream.str(),
199  "median APV0 - median APV1 for FED " + fedIdStream.str(),
200  500,
201  -500,
202  500,
203  "#Delta(medians)");
204 
205  bookChannelsHistograms(ibooker, fedId);
206 
207  histosBooked_[fedId] = true;
208  }
209 }
210 
211 void CMHistograms::bookChannelsHistograms(DQMStore::IBooker& ibooker, unsigned int fedId) {
212  SiStripFedKey fedKey(fedId, 0, 0, 0);
213  std::stringstream fedIdStream;
214  fedIdStream << fedId;
215 
216  ibooker.setCurrentFolder(fedKey.path());
217  medianperChannelMap_[fedId].resize(sistrip::FEDCH_PER_FED, nullptr);
218  medianAPV0minusAPV1perChannelMap_[fedId].resize(sistrip::FEDCH_PER_FED, nullptr);
219 
220  for (unsigned int iCh(0); iCh < sistrip::FEDCH_PER_FED; iCh++) {
221  std::ostringstream lName0, lTitle0, lName1, lTitle1, lName2, lTitle2;
222  lName0 << "MedianForFed" << fedId << "Channel" << iCh;
223  lTitle0 << "Median for FED/Ch " << fedId << "/" << iCh;
224  lName2 << "MedianAPV0minusAPV1ForFed" << fedId << "Channel" << iCh;
225  lTitle2 << "Median APV0-APV1 for FED/Ch " << fedId << "/" << iCh;
226 
227  bookHistogram(ibooker,
228  medianperChannel_,
229  medianperChannelMap_[fedId][iCh],
230  lName0.str(),
231  lTitle0.str(),
232  250,
233  0,
234  500,
235  "median APVs");
236 
237  bookHistogram(ibooker,
238  medianAPV0minusAPV1perChannel_,
239  medianAPV0minusAPV1perChannelMap_[fedId][iCh],
240  lName2.str(),
241  lTitle2.str(),
242  250,
243  -500,
244  500,
245  "median APV0-APV1");
246  }
247 }
248 
249 void CMHistograms::bookAllFEDHistograms(DQMStore::IBooker& ibooker) {
250  //get FED IDs
251  const unsigned int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
252  const unsigned int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID;
253  //book them
254  for (unsigned int iFed = siStripFedIdMin; iFed <= siStripFedIdMax; iFed++) {
255  bookFEDHistograms(ibooker, iFed);
256  }
257 }
258 
259 bool CMHistograms::tkHistoMapEnabled(unsigned int aIndex) { return tkMapConfig_.enabled; }
260 
261 TkHistoMap* CMHistograms::tkHistoMapPointer(unsigned int aIndex) {
262  assert(aIndex < 4);
263  return tkmapCM_[aIndex].get();
264 }
static const uint16_t FED_ID_MIN
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
A container class for generic run and event-related info, information required by the commissioning a...
Definition: SiStripFedKey.h:56
virtual std::string pwd()
Definition: DQMStore.cc:20
bool exists(std::string const &parameterName) const
checks if a parameter exists
assert(be >=bs)
T getUntrackedParameter(std::string const &, T const &) const
Constants and enumerated types for FED/FEC systems.
static const uint16_t FEDCH_PER_FED
static const uint16_t FED_ID_MAX