CMS 3D CMS Logo

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