otsdaq_demo  v2_05_02_indev
DemoDQMHistos.cc
1 #include "otsdaq-demo/DemoRootUtilities/DemoDQMHistos.h"
2 
3 #include <iostream>
4 #include <sstream>
5 #include <string>
6 
7 #include <TDirectory.h>
8 #include <TFile.h>
9 #include <TH1I.h>
10 
11 using namespace ots;
12 
13 //==============================================================================
14 DemoDQMHistos::DemoDQMHistos(void) {}
15 
16 //==============================================================================
17 DemoDQMHistos::~DemoDQMHistos(void) {}
18 
19 //==============================================================================
20 void DemoDQMHistos::book(TFile* rootFile)
21 {
22  std::cout << "Booking start!" << std::endl;
23  TDirectory* currentDir = rootFile->mkdir("General", "General");
24  currentDir->cd();
25 
26  sequenceNumbers_ = new TH1I("SequenceNumber", "Sequence Number", 256, 0, 255);
27  dataNumbers_ = new TH1I("Data", "Data", 101, 0, 0x400000 * 100);
28 }
29 
30 //==============================================================================
31 void DemoDQMHistos::fill(std::string& buffer, std::map<std::string, std::string> /*header*/)
32 {
33  std::stringstream ss;
34  unsigned long long dataQW = *((unsigned long long*)&((buffer)[2]));
35  { // print
36  ss << "dataP Read: 0x ";
37  for(unsigned int i = 0; i < (buffer).size(); ++i)
38  ss << std::hex << (int)(((buffer)[i] >> 4) & 0xF)
39  << (int)(((buffer)[i]) & 0xF) << " " << std::dec;
40  ss << std::endl;
41  std::cout << "\n" << ss.str();
42 
43  std::cout << "sequence = " << (int)*((unsigned char*)&((buffer)[1])) << std::endl;
44 
45  std::cout << "dataQW = 0x" << std::hex << (dataQW) << " " << std::dec << dataQW
46  << std::endl;
47  }
48 
49  sequenceNumbers_->Fill((unsigned int)(*((unsigned char*)&((buffer)[1]))));
50  dataNumbers_->Fill(dataQW
51  //*((unsigned long long *)&((*dataP_)[2]))
52  );
53 }
54 
55 //==============================================================================
56 void DemoDQMHistos::load(std::string /*fileName*/)
57 {
58  /*LORE 2016 MUST BE FIXED THIS MONDAY
59  DQMHistosBase::openFile (fileName);
60  numberOfTriggers_ = (TH1I*)theFile_->Get("General/NumberOfTriggers");
61 
62  std::string directory = "Planes";
63  std::stringstream name;
64  for(unsigned int p=0; p<4; p++)
65  {
66  name.str("");
67  name << directory << "/Plane_" << p << "_Occupancy";
68  //FIXME Must organize better all histograms!!!!!
69  //planeOccupancies_.push_back((TH1I*)theFile_->Get(name.str().c_str()));
70  }
71  //canvas_ = (TCanvas*) theFile_->Get("MainDirectory/MainCanvas");
72  //histo1D_ = (TH1F*) theFile_->Get("MainDirectory/Histo1D");
73  //histo2D_ = (TH2F*) theFile_->Get("MainDirectory/Histo2D");
74  //profile_ = (TProfile*) theFile_->Get("MainDirectory/Profile");
75  closeFile();
76  */
77 }