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