ATLAS Offline Software
Loading...
Searching...
No Matches
HistogramDataCOOL.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4
5// **********************************************************************
6// $Id: HistogramDataCOOL.cxx,v 1.9 2009-02-13 12:32:11 ponyisi Exp $
7// Last Modified 07/18/2008 by M.D'Onofrio
8// **********************************************************************
9
11
12//CORAL API include files
13#include "CoralBase/Attribute.h"
14
15//COOL API include files (CoolKernel)
16#include "CoolKernel/IDatabase.h"
17#include "CoolKernel/IFolder.h"
18#include "CoolKernel/IObjectIterator.h"
19#include "CoolKernel/IObject.h"
20#include "CoolKernel/Record.h"
21#include "CoolKernel/Exception.h"
22#include "CoolKernel/IDatabaseSvc.h"
23#include "CoolKernel/StorageType.h"
24#include "CoolKernel/ConstRecordAdapter.h"
25
26
27#include <TCanvas.h>
28#include <TDirectory.h>
29#include <TFile.h>
30#include <TGraph.h>
31#include <TGraphErrors.h>
32#include <TH1.h>
33#include <TH2.h>
34#include <TIterator.h>
35#include <TKey.h>
36#include <TLegend.h>
37#include <TProfile.h>
38#include <TROOT.h>
39#include <TStyle.h>
40#include <TLatex.h>
41#include <TMath.h>
42#include <TColor.h>
43#include <TTree.h>
44#include <iostream>
45#include <fstream>
46
47
49
50namespace dqutils {
51 cool::IDatabasePtr
53 coolDbInstance(const std::string& dbStr, bool readOnly) {
54 try {
55 std::cout << "Opening database '" << dbStr << "'...";
56 cool::IDatabaseSvc& dbSvc = this->databaseService();
57 std::cout << "done." << std::endl;
58 return dbSvc.openDatabase(dbStr.c_str(), readOnly);
59 }
60 catch (cool::DatabaseDoesNotExist&) {
61 std::cout << "Error! Database does not exist!" << std::endl;
62 throw;
63 }
64 }
65
66 cool::IFolderPtr
68 coolFolderInstance(const std::string& folderStr) {
69 try {
70 cool::IFolderPtr folder = m_coolDb->getFolder(folderStr.c_str());
71 std::cout << "Browsing objects of '" << folderStr << "'" << std::endl;
72 return folder;
73 }
74 catch (cool::FolderNotFound&) {
75 std::cout << "Error! Folder '" << folderStr << "' does not exist!" << std::endl;
76 throw;
77 }
78 }
79
80 void
82 setSince(cool::Int64 run, cool::Int64 lumi) {
83 m_since = ((run << 32) + lumi);
84 }
85
86 void
88 setUntil(cool::Int64 run, cool::Int64 lumi) {
89 m_until = ((run << 32) + lumi);
90 }
91
92 void
94 setIOV(cool::Int64 runS, cool::Int64 lumiS, cool::Int64 runU, cool::Int64 lumiU) {
95 this->setSince(runS, lumiS);
96 this->setUntil(runU, lumiU);
97 this->printIOV();
98 }
99
100 void
102 setIOV(cool::Int64 run) {
103 this->setSince(run, 0);
104 this->setUntil(run, cool::UInt32Max);
105 //this->printIOV();
106 }
107
108 void
110 printIOV() {
111 cool::Int64 runS = m_since >> 32;
112 cool::Int64 lumiS = m_since - (runS << 32);
113 cool::Int64 runU = m_until >> 32;
114 cool::Int64 lumiU = m_until - (runU << 32);
115 std::cout << "Using IOVrange [(" << runS << "," << lumiS << "),(" << runU << "," << lumiU << ")] " << "[" <<
116 m_since << "," << m_until << "]" << std::endl;
117 }
118
120 HistogramDataCOOL (const std::string& dbStr, const std::string& folderStr, int runS, int lumiS, int runU,
121 int lumiU) {
122 m_coolDb = this->coolDbInstance(dbStr, false);
123 m_coolFolder = this->coolFolderInstance(folderStr);
124 m_coolFolderH = this->coolFolderInstance(folderStr);
125 this->setIOV(runS, lumiS, runU, lumiU);
126 }
127
129 HistogramDataCOOL (int runS, int lumiS, int runU, int lumiU) {
130 m_coolDb = this->coolDbInstance("COOLOFL_GLOBAL/OFLP200", false);
131 m_coolFolder = this->coolFolderInstance("/GLOBAL/DETSTATUS/DQMFOFL");
132 m_coolFolderH = this->coolFolderInstance("/GLOBAL/DETSTATUS/DQMFOFLH");
133 this->setIOV(runS, lumiS, runU, lumiU);
134 }
135
138 m_coolDb = this->coolDbInstance("COOLOFL_GLOBAL/OFLP200", false);
139 m_coolFolder = this->coolFolderInstance("/GLOBAL/DETSTATUS/DQMFOFL");
140 m_coolFolderH = this->coolFolderInstance("/GLOBAL/DETSTATUS/DQMFOFLH");
141 this->setIOV(0, 0, 0, 0);
142 }
143
146 m_coolDb->closeDatabase();
147 std::cout << "Cleared!" << std::endl;
148 }
149
150 cool::RecordSpecification
152 createSpec() {
153 //std::cout << "Preparing RecordSpecification" << std::endl;
154 cool::RecordSpecification spec;
155 spec.extend("Code", cool::StorageType::Int32);
156 spec.extend("deadFrac", cool::StorageType::Float);
157 spec.extend("Thrust", cool::StorageType::Float);
158 if (!(spec == m_coolFolder->payloadSpecification())) {
159 std::cout << "ERROR Source and destination folder specifications differ." << std::endl;
160 }
161 return spec;
162 }
163
164 coral::AttributeList
166 createPayload(int colourCode, float dfrac, float thrust, const cool::RecordSpecification& spec) {
167 coral::AttributeList payload = cool::Record(spec).attributeList();
168 payload["Code"].data<cool::Int32>() = colourCode;
169 payload["deadFrac"].data<cool::Float>() = dfrac;
170 payload["Thrust"].data<cool::Float>() = thrust;
171 //std::cout << "Creating payload: ";
172 //std::cout << "[Code : " << colourCode << "],";
173 //std::cout << "[DeadFraction : " << dfrac << "],";
174 //std::cout << "[Thrust : " << thrust << "]" << std::endl;
175 return payload;
176 }
177
178 // Monica 4/6/2008, modified 24/6/2008 to allocate more quantities
179 cool::RecordSpecification
181 createSpecH() {
182 cool::RecordSpecification specH;
183 specH.extend("Code", cool::StorageType::Int32);
184 specH.extend("Algo", cool::StorageType::String255);
185 specH.extend("Entries", cool::StorageType::Int32);
186 specH.extend("Par1", cool::StorageType::Float);
187 specH.extend("Par2", cool::StorageType::Float);
188 specH.extend("Par3", cool::StorageType::Float);
189 specH.extend("Par4", cool::StorageType::Float);
190 specH.extend("Par5", cool::StorageType::Float);
191
192 if (!(specH == m_coolFolderH->payloadSpecification())) {
193 std::cout << "ERROR Source and destination folder specifications differ. histos" << std::endl;
194 }
195 return specH;
196 }
197
198 coral::AttributeList
200 createPayloadH(int colourCode,
201 const std::string& algo,
202 int entries, float par1, float par2, float par3, float par4, float par5,
203 const cool::RecordSpecification& specH) {
204 coral::AttributeList payloadH = cool::Record(specH).attributeList();
205 payloadH["Code"].data<cool::Int32>() = colourCode;
206 payloadH["Algo"].data<cool::String255>() = algo;
207 payloadH["Entries"].data<cool::Int32>() = entries;
208 payloadH["Par1"].data<cool::Float>() = par1;
209 payloadH["Par2"].data<cool::Float>() = par2;
210 payloadH["Par3"].data<cool::Float>() = par3;
211 payloadH["Par4"].data<cool::Float>() = par4;
212 payloadH["Par5"].data<cool::Float>() = par5;
213 std::cout << "Creating payload histos: ";
214 std::cout << "[Code : " << colourCode << "],";
215 std::cout << "[Algo : " << algo << "],";
216 std::cout << "[Entries : " << entries << "],";
217 std::cout << "[Par1 : " << par1 << "],";
218 std::cout << "[Par2 : " << par2 << "],";
219 std::cout << "[Par3 : " << par3 << "],";
220 std::cout << "[Par4 : " << par4 << "],";
221 std::cout << "[Par5 : " << par5 << "]" << std::endl;
222 return payloadH;
223 }
224
225 // end of modification in create new folder and payload (Monica 4/6/2008)
226
227 void
229 dump(cool::ChannelSelection selection, const std::string & tag_name) {
230 try {
231 // cool::IObjectIteratorPtr objects = m_coolFolder->browseObjects(m_since, m_until,
232 // selection,"DetStatusDQMFOFLH-FDR2-01");
233 cool::IObjectIteratorPtr objects = m_coolFolder->browseObjects(m_since, m_until, selection, tag_name);
234 while (objects->goToNext()) {
235 const cool::IObject& element = objects->currentRef();
236 std::cout << element << std::endl;
237 }
238 }
239 catch (cool::Exception& e) {
240 std::cout << "Unknown exception caught!" << e.what() << std::endl;
241 }
242 }
243
244 int
246 dumpCode(const std::string& channelName, const std::string& tag_name) {
247 std::string result = this->dumpHisto(this->getCoolFolderH()->channelId(channelName.c_str()), "Code", tag_name);
248 return atoi(result.c_str());
249 }
250
251 void
253 dumpall(const std::string& tag_name) {
254 this->dump(cool::ChannelSelection::all(), tag_name);
255 }
256
257 // Monica 4/6/2208
258 std::string
260 dumpHisto(cool::ChannelId channelId, const std::string & field, const std::string & tag_name) {
261 std::string result = "";
262 try {
263 cool::ChannelSelection selection = cool::ChannelSelection(channelId);
264 // cool::IObjectIteratorPtr objects = m_coolFolderH->browseObjects(m_since, m_until,
265 // selection,"DetStatusDQMFOFLH-FDR2-01");
266 cool::IObjectIteratorPtr objects = m_coolFolderH->browseObjects(m_since, m_until, selection, tag_name);
267 while (objects->goToNext()) {
268 const cool::IObject& element = objects->currentRef();
269 result = element.payloadValue(field);
270 }
271 }
272 catch (cool::Exception& e) {
273 std::cout << "Unknown exception caught!" << e.what() << std::endl;
274 }
275 return result;
276 }
277
278 void
280 insertH(cool::ChannelId channelId, int code,
281 const std::string& algo,
282 int entries, float par1, float par2, float par3, float par4, float par5,
283 const std::string& tag_name) {
284 try {
285 cool::RecordSpecification specH = this->createSpecH();
286 coral::AttributeList payloadH = this->createPayloadH(code, algo, entries, par1, par2, par3, par4, par5, specH);
287 std::cout << "Trying to store payload histos [channel " << this->getCoolFolderH()->channelName(channelId) <<
288 " (" << channelId << ")]...";
289 // m_coolFolderH->storeObject(m_since, m_until, payloadH, channelId, "DetStatusDQMFOFLH-FDR2-01", true);
290 m_coolFolderH->storeObject(m_since, m_until, cool::Record(
291 m_coolFolder->payloadSpecification(), payloadH), channelId, tag_name, true);
292 std::cout << "stored!" << std::endl;
293 }
294 catch (cool::Exception& e) {
295 std::cout << "Unknown exception caught!" << e.what() << std::endl;
296 }
297 }
298
299 void
301 insertH(const std::string & channelName, int code, const std::string & algo, int entries, float par1, float par2, float par3,
302 float par4, float par5, const std::string & tag_name) {
303 try {
304 this->insertH(this->getCoolFolderH()->channelId(
305 channelName), code, algo, entries, par1, par2, par3, par4, par5, tag_name);
306 }
307 catch (cool::Exception& e) {
308 std::cout << "Unknown exception caught!" << e.what() << std::endl;
309 }
310 }
311
312 cool::IFolderPtr
315 return this->m_coolFolderH;
316 }
317
318 void
320 ntupleDB(int HistoId, const std::string& nameHisto, const std::string& configuration, int Irun, int Frun) {
321 gROOT->Reset();
322 gROOT->SetBatch();
323 gStyle->SetFrameBorderMode(0);
324 gStyle->SetCanvasBorderMode(0);
325 gStyle->SetPadBorderMode(0);
326 gStyle->SetPadColor(0);
327 gStyle->SetCanvasColor(0);
328 gStyle->SetTitleColor(1);
329 gStyle->SetStatColor(0);
330 gStyle->SetFillColor(1);
331 gStyle->SetPalette(1, 0);
332 gStyle->SetTitleFontSize(0.06);
333 gStyle->SetTitleH(0.06);
334
335 // Declaration of leave types
336 UInt_t RunSince;
337 UInt_t RunUntil;
338 UInt_t LBSince;
339 UInt_t LBUntil;
340 UInt_t ChannelID;
341 Char_t TagID[26];
342 Int_t Code;
343 Char_t Algo[100];
344 Int_t Entries;
345 Float_t Par1;
346 Float_t Par2;
347 Float_t Par3;
348 Float_t Par4;
349 Float_t Par5;
350
351 // List of branches
352 TBranch* b_RunSince;
353 TBranch* b_RunUntil;
354 TBranch* b_LBSince;
355 TBranch* b_LBUntil;
356 TBranch* b_ChannelID;
357 TBranch* b_TagID;
358 TBranch* b_Code;
359 TBranch* b_Algo;
360 TBranch* b_Entries;
361 TBranch* b_Par1;
362 TBranch* b_Par2;
363 TBranch* b_Par3;
364 TBranch* b_Par4;
365 TBranch* b_Par5;
366
367 unsigned int i = HistoId;
368 unsigned int init_run = Irun;
369 unsigned int last_run = Frun;
370 std::string nameh = nameHisto;
371 std::string config = configuration;
372
373 char f_name[200];
374 char dir_name[200];
375 sprintf(f_name, "dqmfoflh_%s.root", config.c_str());
376 sprintf(dir_name, "dqmfoflh_%s.root:/COOL/GLOBAL/DETSTATUS", config.c_str());
377 TFile* f = (TFile*) gROOT->GetListOfFiles()->FindObject(f_name);
378 if (!f) {
379 f = new TFile(f_name);
380 f->cd(dir_name);
381 }
382 TTree* tree = (TTree*) gDirectory->Get("DQMFOFLH");
383
384 if (!tree) return;
385
386 tree->SetBranchAddress("RunSince", &RunSince, &b_RunSince);
387 tree->SetBranchAddress("RunUntil", &RunUntil, &b_RunUntil);
388 tree->SetBranchAddress("LBSince", &LBSince, &b_LBSince);
389 tree->SetBranchAddress("LBUntil", &LBUntil, &b_LBUntil);
390 tree->SetBranchAddress("ChannelID", &ChannelID, &b_ChannelID);
391 tree->SetBranchAddress("TagID", TagID, &b_TagID);
392 tree->SetBranchAddress("Code", &Code, &b_Code);
393 tree->SetBranchAddress("Algo", Algo, &b_Algo);
394 tree->SetBranchAddress("Entries", &Entries, &b_Entries);
395 tree->SetBranchAddress("Par1", &Par1, &b_Par1);
396 tree->SetBranchAddress("Par2", &Par2, &b_Par2);
397 tree->SetBranchAddress("Par3", &Par3, &b_Par3);
398 tree->SetBranchAddress("Par4", &Par4, &b_Par4);
399 tree->SetBranchAddress("Par5", &Par5, &b_Par5);
400
401 TGraphErrors* entr_g = new TGraphErrors();
402 TGraphErrors* par1_g[4];
403 TGraphErrors* par2_g[4];
404 TGraphErrors* par3_g[4];
405 TGraphErrors* par4_g[4];
406 TGraphErrors* par5_g[4];
407
408 for (int k = 0; k < 4; k++) {
409 par1_g[k] = new TGraphErrors();
410 par2_g[k] = new TGraphErrors();
411 par3_g[k] = new TGraphErrors();
412 par4_g[k] = new TGraphErrors();
413 par5_g[k] = new TGraphErrors();
414 }
415
416 std::string Algorithm;
417
418 Int_t nentries = tree->GetEntries();
419
420 if (nentries < 1) {
421 std::cout << " The TTree is empty! Check if the right Folder DB Tag is used" << std::endl;
422 return;
423 }
424
425 for (Int_t jj = 0; jj < nentries; jj++) {
426 tree->GetEntry(jj);
427
428 if (i == ChannelID && ((RunSince >= init_run) && (RunSince <= last_run))) {
429 Algorithm = Algo;
430 if (Algorithm == "BinContentComp" && Par5 != 0.) {
431 int npoints = 0;
432
433 // N Entries
434 npoints = entr_g->GetN();
435 npoints++;
436 entr_g->Set(npoints);
437 entr_g->SetPoint(npoints - 1, RunSince, Entries);
438 entr_g->SetPointError(npoints - 1, 0., sqrt(Entries));
439
440 // Par 1
441 int npoints1 = 0;
442 int npoints2 = 0;
443 int npoints3 = 0;
444 int npoints4 = 0;
445 int npoints5 = 0;
446 npoints1 = 0;
447 npoints2 = 0;
448 npoints3 = 0;
449 npoints4 = 0;
450 npoints5 = 0;
451 for (int k = 0; k < 4; k++) npoints1 = par1_g[k]->GetN();
452 for (int k = 0; k < 4; k++) npoints2 = par2_g[k]->GetN();
453 for (int k = 0; k < 4; k++) npoints3 = par3_g[k]->GetN();
454 for (int k = 0; k < 4; k++) npoints4 = par4_g[k]->GetN();
455 for (int k = 0; k < 4; k++) npoints5 = par5_g[k]->GetN();
456 npoints1++;
457 npoints2++;
458 npoints3++;
459 npoints4++;
460 npoints5++;
461 for (int k = 0; k < 4; k++) {
462 par1_g[k]->Set(npoints1);
463 par2_g[k]->Set(npoints2);
464 par3_g[k]->Set(npoints3);
465 par4_g[k]->Set(npoints4);
466 par5_g[k]->Set(npoints5);
467 }
468 par1_g[0]->SetPoint(npoints1 - 1, RunSince, Par1);
469 par2_g[0]->SetPoint(npoints2 - 1, RunSince, Par2);
470 par3_g[0]->SetPoint(npoints3 - 1, RunSince, Par3);
471 par4_g[0]->SetPoint(npoints4 - 1, RunSince, Par4);
472 par5_g[0]->SetPoint(npoints5 - 1, RunSince, Par5);
473 if (Code == 1) {
474 par1_g[1]->SetPoint(npoints1 - 1, RunSince, Par1);
475 par2_g[1]->SetPoint(npoints2 - 1, RunSince, Par2);
476 par3_g[1]->SetPoint(npoints3 - 1, RunSince, Par3);
477 par4_g[1]->SetPoint(npoints4 - 1, RunSince, Par4);
478 par5_g[1]->SetPoint(npoints5 - 1, RunSince, Par5);
479 }
480 if (Code == 2) {
481 par1_g[2]->SetPoint(npoints1 - 1, RunSince, Par1);
482 par2_g[2]->SetPoint(npoints2 - 1, RunSince, Par2);
483 par3_g[2]->SetPoint(npoints3 - 1, RunSince, Par3);
484 par4_g[2]->SetPoint(npoints4 - 1, RunSince, Par4);
485 par5_g[2]->SetPoint(npoints5 - 1, RunSince, Par5);
486 }
487 if (Code == 3) {
488 par1_g[3]->SetPoint(npoints1 - 1, RunSince, Par1);
489 par2_g[3]->SetPoint(npoints2 - 1, RunSince, Par2);
490 par3_g[3]->SetPoint(npoints3 - 1, RunSince, Par3);
491 par4_g[3]->SetPoint(npoints4 - 1, RunSince, Par4);
492 par5_g[3]->SetPoint(npoints5 - 1, RunSince, Par5);
493 }
494
495 par1_g[0]->SetPointError(npoints1 - 1, 0., 0.);
496 par2_g[0]->SetPointError(npoints2 - 1, 0., Par2 / sqrt(Entries));
497 par3_g[0]->SetPointError(npoints3 - 1, 0., Par3 / sqrt(Entries));
498 par4_g[0]->SetPointError(npoints4 - 1, 0., Par4 / sqrt(Entries));
499 par5_g[0]->SetPointError(npoints5 - 1, 0., Par5 / sqrt(Entries));
500 }
501 }
502
503 if (i == ChannelID && ((RunSince >= init_run) && (RunSince <= last_run))) {
504 Algorithm = Algo;
505 int npoints = 0;
506 // N Entries
507 npoints = entr_g->GetN();
508 npoints++;
509 entr_g->Set(npoints);
510 entr_g->SetPoint(npoints - 1, RunSince, Entries);
511 entr_g->SetPointError(npoints - 1, 0., sqrt(Entries));
512
513 // Par 1
514 npoints = 0;
515 for (int k = 0; k < 4; k++) npoints = par1_g[k]->GetN();
516 npoints++;
517 for (int k = 0; k < 4; k++) par1_g[k]->Set(npoints);
518 par1_g[0]->SetPoint(npoints - 1, RunSince, Par1);
519 if (Code == 1) par1_g[1]->SetPoint(npoints - 1, RunSince, Par1);
520 if (Code == 2) par1_g[2]->SetPoint(npoints - 1, RunSince, Par1);
521 if (Code == 3) par1_g[3]->SetPoint(npoints - 1, RunSince, Par1);
522
523
524 std::string::size_type loc = Algorithm.find("CheckHisto_Mean&GatherData", 0);
525 if (loc != std::string::npos) {
526 Algorithm = "CheckHisto_Mean&GatherData";
527 }
528
529 if (Algorithm == "GatherData" || Algorithm == "Histogram_Not_Empty&GatherData" ||
530 Algorithm == "CheckHisto_Mean&GatherData" || Algorithm == "BinContentComp&GatherData") {
531 // in this case, Par1=Mean, error depends on the algorithm
532 if (Par3 > 0 || Par4 > 0) {
533 // this is the new GatherData: return Mean, EMean, RMS, ERMS or
534 // Mean, EMean, RMS, ERMS + XMean or Mean, EMean, NBins, RMS, ERMS
535 par1_g[0]->SetPointError(npoints - 1, 0., Par2);
536 } else {
537 // this is the old GatherData: return Mean and RMS only
538 if (Entries > 0.) {
539 par1_g[0]->SetPointError(npoints - 1, 0., Par2 / sqrt(Entries));
540 } else {
541 par1_g[0]->SetPointError(npoints - 1, 0., 0.);
542 }
543 }
544 } else {
545 if (Entries > 0.) {
546 if (Algorithm == "Simple_gaus_Fit") {
547 par1_g[0]->SetPointError(npoints - 1, 0., Par2 / sqrt(Entries));
548 } else {
549 par1_g[0]->SetPointError(npoints - 1, 0., Par1 / sqrt(Entries));
550 }
551 } else {
552 par1_g[0]->SetPointError(npoints - 1, 0., 0.);
553 }
554 }
555
556 // Par2
557 npoints = 0;
558 for (int k = 0; k < 4; k++) npoints = par2_g[k]->GetN();
559 npoints++;
560 for (int k = 0; k < 4; k++) par2_g[k]->Set(npoints);
561 par2_g[0]->SetPoint(npoints - 1, RunSince, Par2);
562 if (Code == 1) par2_g[1]->SetPoint(npoints - 1, RunSince, Par2);
563 if (Code == 2) par2_g[2]->SetPoint(npoints - 1, RunSince, Par2);
564 if (Code == 3) par2_g[3]->SetPoint(npoints - 1, RunSince, Par2);
565 if (Entries > 0.) {
566 par2_g[0]->SetPointError(npoints - 1, 0., Par2 / sqrt(Entries));
567 } else {
568 par2_g[0]->SetPointError(npoints - 1, 0., 0.);
569 }
570
571 if ((Algorithm == "GatherData" || Algorithm == "Histogram_Not_Empty&GatherData") &&
572 (Par3 > 0 || Par4 > 0)) {
573 // this is the new GatherData: return Mean, EMean, RMS, ERMS
574 par2_g[0]->SetPoint(npoints - 1, RunSince, Par3);
575 if (Code == 1) par2_g[1]->SetPoint(npoints - 1, RunSince, Par3);
576 if (Code == 2) par2_g[2]->SetPoint(npoints - 1, RunSince, Par3);
577 if (Code == 3) par2_g[3]->SetPoint(npoints - 1, RunSince, Par3);
578 par2_g[0]->SetPointError(npoints - 1, 0., Par4);
579 }
580
581 if ((Algorithm == "CheckHisto_Mean&GatherData" || Algorithm == "BinContentComp&GatherData"
582 ) && (Par5 != 0)) {
583 // this is the new GatherData: return Mean, EMean, RMS, ERMS + XMean or Mean, EMean, NBins, RMS, ERMS
584 if (Algorithm == "BinContentComp&GatherData") {
585 par2_g[0]->SetPoint(npoints - 1, RunSince, Par4);
586 if (Code == 1) par2_g[1]->SetPoint(npoints - 1, RunSince, Par4);
587 if (Code == 2) par2_g[2]->SetPoint(npoints - 1, RunSince, Par4);
588 if (Code == 3) par2_g[3]->SetPoint(npoints - 1, RunSince, Par4);
589 par2_g[0]->SetPointError(npoints - 1, 0., Par5);
590 }
591 if (Algorithm == "CheckHisto_Mean&GatherData") {
592 par2_g[0]->SetPoint(npoints - 1, RunSince, Par3);
593 if (Code == 1) par2_g[1]->SetPoint(npoints - 1, RunSince, Par3);
594 if (Code == 2) par2_g[2]->SetPoint(npoints - 1, RunSince, Par3);
595 if (Code == 3) par2_g[3]->SetPoint(npoints - 1, RunSince, Par3);
596 par2_g[0]->SetPointError(npoints - 1, 0., Par4);
597 }
598 }
599
600 //Par3
601 npoints = 0;
602 if (Algorithm == "Simple_gaus_Fit" || Algorithm == "BinContentComp&GatherData"
603 || Algorithm == "CheckHisto_Mean&GatherData") { //currently the only algorithms with third parameter filled
604 for (int k = 0; k < 4; k++) npoints = par3_g[k]->GetN();
605 npoints++;
606 for (int k = 0; k < 4; k++) par3_g[k]->Set(npoints);
607 par3_g[0]->SetPoint(npoints - 1, RunSince, Par3);
608 if (Code == 1) par3_g[1]->SetPoint(npoints - 1, RunSince, Par3);
609 if (Code == 2) par3_g[2]->SetPoint(npoints - 1, RunSince, Par3);
610 if (Code == 3) par3_g[3]->SetPoint(npoints - 1, RunSince, Par3);
611 if (Entries > 0.) {
612 par3_g[0]->SetPointError(npoints - 1, 0., Par3 / sqrt(Entries));
613 } else {
614 par3_g[0]->SetPointError(npoints - 1, 0., 0.);
615 }
616 if (Algorithm == "CheckHisto_Mean&GatherData") {
617 if (Par5 != 0) {
618 par3_g[0]->SetPoint(npoints - 1, RunSince, Par5);
619 if (Code == 1) par3_g[1]->SetPoint(npoints - 1, RunSince, Par5);
620 if (Code == 2) par3_g[2]->SetPoint(npoints - 1, RunSince, Par5);
621 if (Code == 3) par3_g[3]->SetPoint(npoints - 1, RunSince, Par5);
622 par3_g[0]->SetPointError(npoints - 1, 0., Par4);
623 } else {
624 par3_g[0]->SetPoint(npoints - 1, RunSince, Par3);
625 if (Code == 1) par3_g[1]->SetPoint(npoints - 1, RunSince, Par3);
626 if (Code == 2) par3_g[2]->SetPoint(npoints - 1, RunSince, Par3);
627 if (Code == 3) par3_g[3]->SetPoint(npoints - 1, RunSince, Par3);
628 if (Entries > 0.) par3_g[0]->SetPointError(npoints - 1, 0., Par2 / sqrt(Entries));
629 }
630 }
631 }
632 } // end channel selection and run range selection
633 }
634
635 TFile* hfile = (TFile*) gROOT->GetListOfFiles()->FindObject("c1.root");
636 if (hfile) hfile->Close();
637 hfile = new TFile("c1.root", "RECREATE", "ROOT file with graphs");
638
639 std::string par1_name = defParName(Algorithm, nameh, 1);
640 std::string par2_name = defParName(Algorithm, nameh, 2);
641 std::string par3_name = defParName(Algorithm, nameh, 3);
642 std::string par4_name = defParName(Algorithm, nameh, 4);
643 std::string par5_name = defParName(Algorithm, nameh, 5);
644
645 std::string status_code[4];
646 status_code[0] = "";
647 status_code[1] = "Red";
648 status_code[2] = "Yellow";
649 status_code[3] = "Green";
650
651 std::string par1_g_name[4];
652 std::string par2_g_name[4];
653 std::string par3_g_name[4];
654 std::string par4_g_name[4];
655 std::string par5_g_name[4];
656 for (int k = 0; k < 4; k++) {
657 par1_g_name[k] = "Par1, Algo:" + Algorithm + " " + status_code[k];
658 par2_g_name[k] = "Par2, Algo:" + Algorithm + " " + status_code[k];
659 par3_g_name[k] = "Par3, Algo:" + Algorithm + " " + status_code[k];
660 par4_g_name[k] = "Par4, Algo:" + Algorithm + " " + status_code[k];
661 par5_g_name[k] = "Par5, Algo:" + Algorithm + " " + status_code[k];
662 }
663
664 TCanvas* c1 = new TCanvas("c1", " History ");
665 if (Algorithm == "Simple_gaus_Fit" || Algorithm == "BinContentComp&GatherData" ||
666 Algorithm == "CheckHisto_Mean&GatherData") { //currently the only algorithms with third parameter filled
667 c1->SetCanvasSize(900, 900);
668 c1->Divide(2, 2);
669 } else {
670 if (Algorithm == "BinContentComp") {
671 c1->SetCanvasSize(900, 900);
672 c1->Divide(2, 3);
673 } else {
674 c1->SetCanvasSize(1000, 450);
675 c1->Divide(3, 1);
676 }
677 }
678 c1->Update();
679 int green = TColor::GetColor("#009900");
680 int yellow = TColor::GetColor("#ff9933");
681
682 c1->cd(1);
683 gPad->SetGridx();
684 gPad->SetGridy();
685 formatGraph(c1, entr_g);
686 entr_g->SetTitle("N Entries");
687 entr_g->GetYaxis()->SetTitle("N entries");
688 entr_g->SetMarkerStyle(20);
689
690 bool non_zero = false;
691
692 if (entr_g->GetMaxSize() != 0) {
693 entr_g->Draw("ap");
694 non_zero = true;
695 }
696
697 c1->cd(2);
698 gPad->SetGridx();
699 gPad->SetGridy();
700 formatGraph(c1, par1_g[0]);
701 for (int k = 0; k < 4; k++) {
702 par1_g[k]->SetTitle(par1_g_name[k].c_str());
703 par1_g[k]->SetMarkerStyle(20);
704 }
705 par1_g[0]->GetYaxis()->SetTitle(par1_name.c_str());
706 par1_g[1]->SetMarkerColor(2);
707 par1_g[2]->SetMarkerColor(yellow);
708 par1_g[3]->SetMarkerColor(green);
709 if (non_zero) {
710 par1_g[0]->Draw("ap");
711 par1_g[1]->Draw("p");
712 par1_g[2]->Draw("p");
713 par1_g[3]->Draw("p");
714 }
715 c1->cd(3);
716 gPad->SetGridx();
717 gPad->SetGridy();
718 formatGraph(c1, par2_g[0]);
719 par2_g[0]->GetYaxis()->SetTitle(par2_name.c_str());
720 for (int k = 0; k < 4; k++) {
721 par2_g[k]->SetTitle(par2_g_name[k].c_str());
722 par2_g[k]->SetMarkerStyle(20);
723 }
724 par2_g[1]->SetMarkerColor(2);
725 par2_g[2]->SetMarkerColor(yellow);
726 par2_g[3]->SetMarkerColor(green);
727 if (non_zero) {
728 par2_g[0]->Draw("ap");
729 par2_g[1]->Draw("p");
730 par2_g[2]->Draw("p");
731 par2_g[3]->Draw("p");
732 }
733 if (Algorithm == "Simple_gaus_Fit" || Algorithm == "BinContentComp&GatherData" || (Algorithm == "BinContentComp") ||
734 Algorithm == "CheckHisto_Mean&GatherData") { //currently the only algorithm with third parameter filled
735 c1->cd(4);
736 gPad->SetGridx();
737 gPad->SetGridy();
738 formatGraph(c1, par3_g[0]);
739 par3_g[0]->GetYaxis()->SetTitle(par3_name.c_str());
740 for (int k = 0; k < 4; k++) {
741 par3_g[k]->SetMarkerStyle(20);
742 par3_g[k]->SetTitle(par3_g_name[k].c_str());
743 }
744 par3_g[1]->SetMarkerColor(2);
745 par3_g[2]->SetMarkerColor(yellow);
746 par3_g[3]->SetMarkerColor(green);
747 if (non_zero) {
748 par3_g[0]->Draw("ap");
749 par3_g[1]->Draw("p");
750 par3_g[2]->Draw("p");
751 par3_g[3]->Draw("p");
752 }
753 }
754
755 if (Algorithm == "BinContentComp") {
756 c1->cd(5);
757 gPad->SetGridx();
758 gPad->SetGridy();
759 formatGraph(c1, par4_g[0]);
760 par4_g[0]->GetYaxis()->SetTitle(par4_name.c_str());
761 for (int k = 0; k < 4; k++) {
762 par4_g[k]->SetMarkerStyle(20);
763 par4_g[k]->SetTitle(par4_g_name[k].c_str());
764 }
765 par4_g[1]->SetMarkerColor(2);
766 par4_g[2]->SetMarkerColor(yellow);
767 par4_g[3]->SetMarkerColor(green);
768 if (non_zero) {
769 par4_g[0]->Draw("ap");
770 par4_g[1]->Draw("p");
771 par4_g[2]->Draw("p");
772 par4_g[3]->Draw("p");
773 }
774
775 c1->cd(6);
776 gPad->SetGridx();
777 gPad->SetGridy();
778 formatGraph(c1, par5_g[0]);
779 par5_g[0]->GetYaxis()->SetTitle(par5_name.c_str());
780 for (int k = 0; k < 4; k++) {
781 par5_g[k]->SetMarkerStyle(20);
782 par5_g[k]->SetTitle(par5_g_name[k].c_str());
783 }
784 par5_g[1]->SetMarkerColor(2);
785 par5_g[2]->SetMarkerColor(yellow);
786 par5_g[3]->SetMarkerColor(green);
787 if (non_zero) {
788 par5_g[0]->Draw("ap");
789 par5_g[1]->Draw("p");
790 par5_g[2]->Draw("p");
791 par5_g[3]->Draw("p");
792 }
793 }
794
795 entr_g->Write("Nentr");
796 for (int k = 0; k < 4; k++) {
797 if (par1_g[k]) par1_g[k]->Write(par1_g_name[k].c_str());
798 if (par2_g[k]) par2_g[k]->Write(par2_g_name[k].c_str());
799 if (par3_g[k]) par3_g[k]->Write(par3_g_name[k].c_str());
800 if (par4_g[k]) par4_g[k]->Write(par4_g_name[k].c_str());
801 if (par5_g[k]) par5_g[k]->Write(par5_g_name[k].c_str());
802 }
803
804 hfile->Close();
805 if (non_zero) {
806 c1->Print("c1.gif");
807 }
808 delete entr_g;
809 for (int k = 0; k < 4; k++) {
810 if (par1_g[k]) delete par1_g[k];
811 if (par2_g[k]) delete par2_g[k];
812 if (par3_g[k]) delete par3_g[k];
813 if (par4_g[k]) delete par4_g[k];
814 if (par5_g[k]) delete par5_g[k];
815 }
816 f->Close();
817 }
818
819 void
821 historyDB(int HistoId, const std::string& nameHisto, const std::string& tag_name) {
822 gStyle->SetFrameBorderMode(0);
823 gStyle->SetCanvasBorderMode(0);
824 gStyle->SetPadBorderMode(0);
825 gStyle->SetPadColor(0);
826 gStyle->SetCanvasColor(0);
827 gStyle->SetTitleColor(1);
828 gStyle->SetStatColor(0);
829 gStyle->SetFillColor(1);
830 gStyle->SetPalette(1, 0);
831 gStyle->SetTitleFontSize(0.06);
832 gStyle->SetTitleH(0.06);
833
834 auto pRun = std::make_unique<std::array<int, 10000> >();
835 float StatusH[1000];
836 float Entries[1000];
837 float Par1[1000] = {};
838 float Par2[1000] = {};
839 float Par3[1000] = {};
840 float Par4[1000] = {};
841 float Par5[1000] = {};
842 std::string Algorithm;
843 std::string Algorithm1;
844
845 gROOT->SetBatch();
846
847 std::ifstream tmp_run("runxml");
848 if (!tmp_run.is_open()) {
849 std::cout << " Could not open the run list file " << std::endl;
850 return;
851 }
852
853 Int_t dummy = 0;
854 while (tmp_run.good()) {
855 tmp_run >> pRun->at(dummy);
856 dummy++;
857 }
858 int ALL = dummy - 1;
859 int i = HistoId;
860 std::string nameh = nameHisto;
861 std::string tagDB = tag_name;
862
863 for (int j = 0; j < ALL; j++) {
864 setIOV(pRun->at(j));
865 StatusH[j] = dumpCode(nameh, tagDB);
866 std::string entr = dumpHisto(i, "Entries", tagDB);
867 std::string alg = dumpHisto(i, "Algo", tagDB);
868 std::string aa = dumpHisto(i, "Par1", tagDB);
869 std::string cc = dumpHisto(i, "Par2", tagDB);
870 std::string ee = dumpHisto(i, "Par3", tagDB);
871 std::string gg = dumpHisto(i, "Par4", tagDB);
872 std::string ll = dumpHisto(i, "Par5", tagDB);
873
874 std::istringstream entri(entr);
875 std::istringstream algo(alg);
876 std::istringstream bb(aa);
877 std::istringstream dd(cc);
878 std::istringstream ff(ee);
879 std::istringstream hh(gg);
880 std::istringstream mm(ll);
881
882 entri >> Entries[j];
883 algo >> Algorithm1;
884 bb >> Par1[j];
885 dd >> Par2[j];
886 ff >> Par3[j];
887 hh >> Par4[j];
888 mm >> Par5[j];
889 if (alg.length() > 0) Algorithm = Algorithm1;
890 }
891
892 TFile* hfile = (TFile*) gROOT->GetListOfFiles()->FindObject("c1.root");
893 if (hfile) hfile->Close();
894 hfile = new TFile("c1.root", "RECREATE", "ROOT file with graphs");
895
896 TGraphErrors* entr_g = new TGraphErrors();
897 TGraphErrors* par1_g[4];
898 TGraphErrors* par2_g[4];
899 TGraphErrors* par3_g[4];
900 TGraphErrors* par4_g[4];
901 // TGraphErrors *par5_g[4];
902
903 for (int k = 0; k < 4; k++) {
904 par1_g[k] = new TGraphErrors();
905 par2_g[k] = new TGraphErrors();
906 par3_g[k] = new TGraphErrors();
907 par4_g[k] = new TGraphErrors();
908 // par5_g[k] = new TGraphErrors();
909 }
910
911
912 std::string par1_name = defParName(Algorithm, nameh, 1);
913 std::string par2_name = defParName(Algorithm, nameh, 2);
914 std::string par3_name = defParName(Algorithm, nameh, 3);
915 std::string par4_name = defParName(Algorithm, nameh, 4);
916 std::string par5_name = defParName(Algorithm, nameh, 5);
917
918 std::string status_code[4];
919 status_code[0] = "";
920 status_code[1] = "Red";
921 status_code[2] = "Yellow";
922 status_code[3] = "Green";
923
924 std::string par1_g_name[4];
925 std::string par2_g_name[4];
926 std::string par3_g_name[4];
927 std::string par4_g_name[4];
928 std::string par5_g_name[4];
929 for (int k = 0; k < 4; k++) {
930 par1_g_name[k] = "Par1, Algo:" + Algorithm + " " + status_code[k];
931 par2_g_name[k] = "Par2, Algo:" + Algorithm + " " + status_code[k];
932 par3_g_name[k] = "Par3, Algo:" + Algorithm + " " + status_code[k];
933 par4_g_name[k] = "Par4, Algo:" + Algorithm + " " + status_code[k];
934 par5_g_name[k] = "Par5, Algo:" + Algorithm + " " + status_code[k];
935 }
936
937 for (int j = 0; j < (ALL); j++) {
938 int npoints = entr_g->GetN();
939 npoints++;
940 entr_g->Set(npoints);
941 entr_g->SetPoint(npoints - 1, pRun->at(j), Entries[j]);
942 entr_g->SetPointError(npoints - 1, 0., sqrt(Entries[j]));
943 }
944
945 std::string::size_type loc = Algorithm.find("CheckHisto_Mean&GatherData", 0);
946 if (loc != std::string::npos) {
947 Algorithm = "CheckHisto_Mean&GatherData";
948 }
949
950 //Par1
951 for (int j = 0; j < (ALL); j++) {
952 int npoints;
953 for (int k = 0; k < 4; k++) npoints = par1_g[k]->GetN();
954 npoints++;
955 for (int k = 0; k < 4; k++) par1_g[k]->Set(npoints);
956 par1_g[0]->SetPoint(npoints - 1, pRun->at(j), Par1[j]);
957 if (StatusH[j] == 1) par1_g[1]->SetPoint(npoints - 1, pRun->at(j), Par1[j]);
958 if (StatusH[j] == 2) par1_g[2]->SetPoint(npoints - 1, pRun->at(j), Par1[j]);
959 if (StatusH[j] == 3) par1_g[3]->SetPoint(npoints - 1, pRun->at(j), Par1[j]);
960
961 if (Algorithm == "GatherData" || Algorithm == "Histogram_Not_Empty&GatherData" ||
962 Algorithm == "CheckHisto_Mean&GatherData" || Algorithm == "BinContentComp&GatherData") {
963 // in this case, Par1=Mean, error depends on the algorithm
964 if (Par3[j] > 0 || Par4[j] > 0) {
965 // this is the new GatherData: return Mean, EMean, RMS, ERMS or
966 // Mean, EMean, RMS, ERMS + XMean or Mean, EMean, NBins, RMS, ERMS
967 par1_g[0]->SetPointError(npoints - 1, 0., Par2[j]);
968 } else {
969 // this is the old GatherData: return Mean and RMS only
970 if (Entries[j] > 0.) {
971 par1_g[0]->SetPointError(npoints - 1, 0., Par2[j] / sqrt(Entries[j]));
972 } else {
973 par1_g[0]->SetPointError(npoints - 1, 0., 0.);
974 }
975 }
976 } else {
977 if (Entries[j] > 0.) {
978 if (Algorithm == "Simple_gaus_Fit") {
979 par1_g[0]->SetPointError(npoints - 1, 0., Par2[j] / sqrt(Entries[j]));
980 } else {
981 par1_g[0]->SetPointError(npoints - 1, 0., Par1[j] / sqrt(Entries[j]));
982 }
983 } else {
984 par1_g[0]->SetPointError(npoints - 1, 0., 0.);
985 }
986 }
987 }
988
989 //Par2
990 for (int j = 0; j < (ALL); j++) {
991 int npoints;
992 for (int k = 0; k < 4; k++) npoints = par2_g[k]->GetN();
993 npoints++;
994 for (int k = 0; k < 4; k++) par2_g[k]->Set(npoints);
995 par2_g[0]->SetPoint(npoints - 1, pRun->at(j), Par2[j]);
996 if (StatusH[j] == 1) par2_g[1]->SetPoint(npoints - 1, pRun->at(j), Par2[j]);
997 if (StatusH[j] == 2) par2_g[2]->SetPoint(npoints - 1, pRun->at(j), Par2[j]);
998 if (StatusH[j] == 3) par2_g[3]->SetPoint(npoints - 1, pRun->at(j), Par2[j]);
999 if (Entries[j] > 0.) {
1000 par2_g[0]->SetPointError(npoints - 1, 0., Par2[j] / sqrt(Entries[j]));
1001 } else {
1002 par2_g[0]->SetPointError(npoints - 1, 0., 0.);
1003 }
1004
1005 if ((Algorithm == "GatherData" || Algorithm == "Histogram_Not_Empty&GatherData") &&
1006 (Par3[j] > 0 || Par4[j] > 0)) {
1007 // this is the new GatherData: return Mean, EMean, RMS, ERMS
1008 par2_g[0]->SetPoint(npoints - 1, pRun->at(j), Par3[j]);
1009 if (StatusH[j] == 1) par2_g[1]->SetPoint(npoints - 1, pRun->at(j), Par3[j]);
1010 if (StatusH[j] == 2) par2_g[2]->SetPoint(npoints - 1, pRun->at(j), Par3[j]);
1011 if (StatusH[j] == 3) par2_g[3]->SetPoint(npoints - 1, pRun->at(j), Par3[j]);
1012 par2_g[0]->SetPointError(npoints - 1, 0., Par4[j]);
1013 }
1014
1015 if ((Algorithm == "CheckHisto_Mean&GatherData" || Algorithm == "BinContentComp&GatherData"
1016 ) && (Par5[j] != 0)) {
1017 // this is the new GatherData: return Mean, EMean, RMS, ERMS + XMean or Mean, EMean, NBins, RMS, ERMS
1018 if (Algorithm == "BinContentComp&GatherData") {
1019 par2_g[0]->SetPoint(npoints - 1, pRun->at(j), Par4[j]);
1020 if (StatusH[j] == 1) par2_g[1]->SetPoint(npoints - 1, pRun->at(j), Par4[j]);
1021 if (StatusH[j] == 2) par2_g[2]->SetPoint(npoints - 1, pRun->at(j), Par4[j]);
1022 if (StatusH[j] == 3) par2_g[3]->SetPoint(npoints - 1, pRun->at(j), Par4[j]);
1023 par2_g[0]->SetPointError(npoints - 1, 0., Par5[j]);
1024 }
1025 if (Algorithm == "CheckHisto_Mean&GatherData") {
1026 par2_g[0]->SetPoint(npoints - 1, pRun->at(j), Par3[j]);
1027 if (StatusH[j] == 1) par2_g[1]->SetPoint(npoints - 1, pRun->at(j), Par3[j]);
1028 if (StatusH[j] == 2) par2_g[2]->SetPoint(npoints - 1, pRun->at(j), Par3[j]);
1029 if (StatusH[j] == 3) par2_g[3]->SetPoint(npoints - 1, pRun->at(j), Par3[j]);
1030 par2_g[0]->SetPointError(npoints - 1, 0., Par4[j]);
1031 }
1032 }
1033 }
1034
1035 //Par3
1036 if (Algorithm == "Simple_gaus_Fit" || Algorithm == "BinContentComp&GatherData"
1037 || Algorithm == "CheckHisto_Mean&GatherData") { //currently the only algorithms with third parameter filled
1038 for (int j = 0; j < (ALL); j++) {
1039 int npoints;
1040 for (int k = 0; k < 4; k++) npoints = par3_g[k]->GetN();
1041 npoints++;
1042 for (int k = 0; k < 4; k++) par3_g[k]->Set(npoints);
1043 par3_g[0]->SetPoint(npoints - 1, pRun->at(j), Par3[j]);
1044 if (StatusH[j] == 1) par3_g[1]->SetPoint(npoints - 1, pRun->at(j), Par3[j]);
1045 if (StatusH[j] == 2) par3_g[2]->SetPoint(npoints - 1, pRun->at(j), Par3[j]);
1046 if (StatusH[j] == 3) par3_g[3]->SetPoint(npoints - 1, pRun->at(j), Par3[j]);
1047 if (Entries[j] > 0.) {
1048 par3_g[0]->SetPointError(npoints - 1, 0., Par3[j] / sqrt(Entries[j]));
1049 } else {
1050 par3_g[0]->SetPointError(npoints - 1, 0., 0.);
1051 }
1052 if (Algorithm == "CheckHisto_Mean&GatherData") {
1053 if (Par5[j] != 0) {
1054 par3_g[0]->SetPoint(npoints - 1, pRun->at(j), Par5[j]);
1055 if (StatusH[j] == 1) par3_g[1]->SetPoint(npoints - 1, pRun->at(j), Par5[j]);
1056 if (StatusH[j] == 2) par3_g[2]->SetPoint(npoints - 1, pRun->at(j), Par5[j]);
1057 if (StatusH[j] == 3) par3_g[3]->SetPoint(npoints - 1, pRun->at(j), Par5[j]);
1058 par3_g[0]->SetPointError(npoints - 1, 0., Par4[j]);
1059 } else {
1060 par3_g[0]->SetPoint(npoints - 1, pRun->at(j), Par3[j]);
1061 if (StatusH[j] == 1) par3_g[1]->SetPoint(npoints - 1, pRun->at(j), Par3[j]);
1062 if (StatusH[j] == 2) par3_g[2]->SetPoint(npoints - 1, pRun->at(j), Par3[j]);
1063 if (StatusH[j] == 3) par3_g[3]->SetPoint(npoints - 1, pRun->at(j), Par3[j]);
1064 if (Entries[j] > 0.) par3_g[0]->SetPointError(npoints - 1, 0., Par2[j] / sqrt(Entries[j]));
1065 }
1066 }
1067 }
1068 }
1069
1070 TCanvas* c1 = new TCanvas("c1", " History ");
1071 if (Algorithm == "Simple_gaus_Fit" || Algorithm == "BinContentComp&GatherData"
1072 || (Algorithm == "CheckHisto_Mean&GatherData")) { //currently the only algorithms with third parameter filled
1073 c1->SetCanvasSize(900, 900);
1074 c1->Divide(2, 2);
1075 } else {
1076 c1->SetCanvasSize(1000, 450);
1077 c1->Divide(3, 1);
1078 }
1079
1080 c1->Update();
1081 int green = TColor::GetColor("#009900");
1082 int yellow = TColor::GetColor("#ff9933");
1083
1084 c1->cd(1);
1085 gPad->SetGridx();
1086 gPad->SetGridy();
1087 formatGraph(c1, entr_g);
1088 entr_g->SetTitle("N Entries");
1089 entr_g->GetXaxis()->SetRange(pRun->at(0), pRun->at(ALL - 1));
1090 entr_g->GetYaxis()->SetTitle("N entries");
1091 entr_g->SetMarkerStyle(20);
1092 entr_g->Draw("ap");
1093
1094 c1->cd(2);
1095 gPad->SetGridx();
1096 gPad->SetGridy();
1097 formatGraph(c1, par1_g[0]);
1098 for (int k = 0; k < 4; k++) {
1099 par1_g[k]->SetTitle(par1_g_name[k].c_str());
1100 par1_g[k]->SetMarkerStyle(20);
1101 }
1102 par1_g[0]->GetYaxis()->SetTitle(par1_name.c_str());
1103 par1_g[1]->SetMarkerColor(2);
1104 par1_g[2]->SetMarkerColor(yellow);
1105 par1_g[3]->SetMarkerColor(green);
1106 par1_g[0]->Draw("ap");
1107 par1_g[1]->Draw("p");
1108 par1_g[2]->Draw("p");
1109 par1_g[3]->Draw("p");
1110
1111 c1->cd(3);
1112 gPad->SetGridx();
1113 gPad->SetGridy();
1114 formatGraph(c1, par2_g[0]);
1115 par2_g[0]->GetYaxis()->SetTitle(par2_name.c_str());
1116 for (int k = 0; k < 4; k++) {
1117 par2_g[k]->SetTitle(par2_g_name[k].c_str());
1118 par2_g[k]->SetMarkerStyle(20);
1119 }
1120 par2_g[1]->SetMarkerColor(2);
1121 par2_g[2]->SetMarkerColor(yellow);
1122 par2_g[3]->SetMarkerColor(green);
1123 par2_g[0]->Draw("ap");
1124 par2_g[1]->Draw("p");
1125 par2_g[2]->Draw("p");
1126 par2_g[3]->Draw("p");
1127
1128
1129 if (Algorithm == "Simple_gaus_Fit" || Algorithm == "BinContentComp&GatherData" ||
1130 Algorithm == "CheckHisto_Mean&GatherData") { //currently the only algorithm with third parameter filled
1131 c1->cd(4);
1132 gPad->SetGridx();
1133 gPad->SetGridy();
1134 formatGraph(c1, par3_g[0]);
1135 par3_g[0]->GetYaxis()->SetTitle(par3_name.c_str());
1136 for (int k = 0; k < 4; k++) {
1137 par3_g[k]->SetMarkerStyle(20);
1138 par3_g[k]->SetTitle(par3_g_name[k].c_str());
1139 }
1140 par3_g[1]->SetMarkerColor(2);
1141 par3_g[2]->SetMarkerColor(yellow);
1142 par3_g[3]->SetMarkerColor(green);
1143 par3_g[0]->Draw("ap");
1144 par3_g[1]->Draw("p");
1145 par3_g[2]->Draw("p");
1146 par3_g[3]->Draw("p");
1147 }
1148
1149
1150 entr_g->Write("Nentr");
1151 for (int k = 0; k < 4; k++) {
1152 if (par1_g[k]) par1_g[k]->Write(par1_g_name[k].c_str());
1153 if (par2_g[k]) par2_g[k]->Write(par2_g_name[k].c_str());
1154 if (par3_g[k]) par3_g[k]->Write(par3_g_name[k].c_str());
1155 if (par4_g[k]) par4_g[k]->Write(par4_g_name[k].c_str());
1156 }
1157
1158 hfile->Close();
1159 c1->Print("c1.gif");
1160
1161 delete entr_g;
1162 for (int k = 0; k < 4; k++) {
1163 if (par1_g[k]) delete par1_g[k];
1164 if (par2_g[k]) delete par2_g[k];
1165 if (par3_g[k]) delete par3_g[k];
1166 if (par4_g[k]) delete par4_g[k];
1167 }
1168
1169 return;
1170 }
1171
1172 std::string
1174 defParName(const std::string& algo, const std::string& nameHisto, int i) {
1175 std::string Algorithm = algo;
1176 std::string nameh = nameHisto;
1177 std::string par1_name = "Par1";
1178 std::string par2_name = "Par2";
1179 std::string par3_name = "Par3";
1180 std::string par4_name = "Par4";
1181 std::string par5_name = "Par5";
1182
1183
1184 if (Algorithm == "GatherData" || Algorithm == "Histogram_Not_Empty&GatherData") {
1185 par1_name = "Mean";
1186 par2_name = "RMS";
1187 }
1188 if (Algorithm == "CheckHisto_Mean&GatherData") {
1189 par1_name = "Mean";
1190 par2_name = "RMS";
1191 par3_name = "XMean";
1192 par4_name = "YMean";
1193 }
1194 if (Algorithm == "BinContentComp&GatherData") {
1195 par1_name = "Mean";
1196 par2_name = "RMS";
1197 par3_name = "NBins";
1198 }
1199 if (Algorithm == "Bins_Diff_FromAvg") {
1200 par1_name = "Average";
1201 par2_name = "NBins_above_Av";
1202 }
1203 if (Algorithm == "Simple_pol1_Fit") {
1204 par1_name = "par[0]";
1205 par2_name = "par[1]";
1206 }
1207 if (Algorithm == "Simple_gaus_Fit") {
1208 par1_name = "Mean gaus";
1209 par2_name = "RMS gaus";
1210 par3_name = "Constant gaus";
1211 }
1212 if (Algorithm == "SideBand_Absolute" ||
1213 Algorithm == "SideBand_Relative") {
1214 par1_name = "SideBands";
1215 par2_name = "Total Integral";
1216 }
1217 if (Algorithm == "CheckHisto_Mean") {
1218 par1_name = "XMean";
1219 par2_name = "YMean";
1220 }
1221 if (Algorithm == "CheckHisto_RMS") {
1222 par1_name = "XRMS";
1223 par2_name = "YRMS";
1224 }
1225 if (Algorithm == "Histogram_Not_Empty" ||
1226 Algorithm == "Histogram_Empty" ||
1227 Algorithm == "No_OverFlows" ||
1228 Algorithm == "No_UnderFlows" ||
1229 Algorithm == "Histogram_Effective_Empty") {
1230 par1_name = "NULL par";
1231 par2_name = "NULL par";
1232 }
1233
1234 if (Algorithm == "Bins_LessThan_Threshold" ||
1235 Algorithm == "Bins_LessThanEqual_Threshold" ||
1236 Algorithm == "Bins_GreaterThan_Threshold" ||
1237 Algorithm == "Bins_GreaterThanEqual_Threshold" ||
1238 Algorithm == "Bins_Equal_Threshold" ||
1239 Algorithm == "Bins_NotEqual_Threshold") {
1240 par1_name = "NBins Less/Equal/NotEqual/Above Threshold";
1241 par2_name = "NULL par";
1242 }
1243
1244 if (Algorithm == "BinContentComp") {
1245 par1_name = "NBins";
1246 par2_name = "Pix L0";
1247 par3_name = "Pix L1";
1248 par4_name = "Pix L2";
1249 par5_name = "SCT L0 S0";
1250 }
1251
1252 if (i == 1) {
1253 return par1_name;
1254 } else {
1255 if (i == 2) {
1256 return par2_name;
1257 } else {
1258 if (i == 3) {
1259 return par3_name;
1260 } else {
1261 if (i == 4) {
1262 return par4_name;
1263 } else {
1264 if (i == 5) {
1265 return par5_name;
1266 } else return "";
1267 }
1268 }
1269 }
1270 }
1271 }
1272
1273 void
1275 formatGraph(TCanvas* c, TGraphErrors* gr) const {
1276 if (c == 0 || gr == 0) return;
1277
1278 c->SetLeftMargin(0.15);
1279 c->SetRightMargin(0.13);
1280 c->SetBottomMargin(0.15);
1281 c->SetTopMargin(0.12);
1282
1283 gr->GetXaxis()->SetLabelSize(0.04);
1284 gr->GetYaxis()->SetLabelSize(0.04);
1285 gr->GetXaxis()->SetLabelFont(62);
1286 gr->GetYaxis()->SetLabelFont(62);
1287
1288 gr->GetXaxis()->SetTitleSize(0.04);
1289 gr->GetYaxis()->SetTitleSize(0.04);
1290 gr->GetXaxis()->SetTitleFont(62);
1291 gr->GetYaxis()->SetTitleFont(62);
1292 gr->GetXaxis()->SetTitle("Runs");
1293
1294 gr->GetYaxis()->SetTitleOffset(1.5);
1295 gr->GetXaxis()->SetTitleOffset(0.9);
1296
1297 gr->GetXaxis()->SetNdivisions(504);
1298 }
1299
1300 // end of modification in insert functions (Monica 4/6/2008)
1301
1302 cool::IDatabasePtr
1304 getCoolDb() {
1305 return this->m_coolDb;
1306 }
1307} //namespace dqutils
#define gr
ClassImp(dqutils::HistogramDataCOOL) namespace dqutils
std::string defParName(const std::string &Algorithm, const std::string &nameHisto, int i)
void dumpall(const std::string &tag_name)
void dump(cool::ChannelSelection selection, const std::string &tag_name)
cool::IFolderPtr coolFolderInstance(const std::string &folderStr)
void insertH(cool::ChannelId channelId, int code, const std::string &algo, int entries, float par1, float par2, float par3, float par4, float par5, const std::string &tag_name)
cool::IDatabasePtr getCoolDb()
void setUntil(cool::Int64 run, cool::Int64 lumi)
virtual void historyDB(int HistoId, const std::string &nameHisto, const std::string &tag_name)
cool::IDatabasePtr coolDbInstance(const std::string &dbStr, bool readOnly)
std::string dumpHisto(cool::ChannelId channelId, const std::string &field, const std::string &tag_name)
void setIOV(cool::Int64 runS, cool::Int64 lumiS, cool::Int64 runU, cool::Int64 lumiU)
cool::RecordSpecification createSpec()
virtual void ntupleDB(int HistoId, const std::string &nameHisto, const std::string &configuration, int Irun, int Frun)
int dumpCode(const std::string &channelName, const std::string &tag_name)
cool::RecordSpecification createSpecH()
void setSince(cool::Int64 run, cool::Int64 lumi)
virtual void formatGraph(TCanvas *c, TGraphErrors *gr) const
cool::IFolderPtr getCoolFolderH()
coral::AttributeList createPayloadH(int colourCode, const std::string &algo, int entries, float par1, float par2, float par3, float par4, float par5, const cool::RecordSpecification &specH)
coral::AttributeList createPayload(int colourCode, float dfrac, float thrust, const cool::RecordSpecification &spec)
double Entries(TH1 *h)
Definition computils.cxx:52
const std::string selection
double entries
Definition listroot.cxx:49
-event-from-file
struct _Set Set
Represents a set of values.
Definition set.h:59
TChain * tree
int run(int argc, char *argv[])