Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DaqMon.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DaqMon.cc
1 // use #include "" only for your local include and put
2 // those in the first line(s) before any #include <>
3 // otherwise you are asking for weird behavior
4 // (more info - check the difference in include path search when using "" versus <>)
5 
6 #include "DaqMon.h"
7 
8 #include <onlmon/OnlMon.h> // for OnlMon
9 #include <onlmon/OnlMonDB.h>
10 #include <onlmon/OnlMonServer.h>
11 
12 #include <Event/msg_profile.h>
13 
14 #include <TH1.h>
15 #include <TH2.h>
16 #include <TRandom.h>
17 
18 #include <cmath>
19 #include <cstdio> // for printf
20 #include <fstream>
21 #include <iostream>
22 #include <sstream>
23 #include <string> // for allocator, string, char_traits
24 
25 enum
26 {
29 };
30 
32  : OnlMon(name)
33 {
34  // leave ctor fairly empty, its hard to debug if code crashes already
35  // during a new DaqMon()
36  return;
37 }
38 
40 {
41  // you can delete NULL pointers it results in a NOOP (No Operation)
42  return;
43 }
44 
46 {
47  gRandom->SetSeed(rand());
48  // read our calibrations from DaqMonData.dat
49  const char *daqcalib = getenv("DAQCALIB");
50  if (!daqcalib)
51  {
52  std::cout << "DAQCALIB environment variable not set" << std::endl;
53  exit(1);
54  }
55  std::string fullfile = std::string(daqcalib) + "/" + "DaqMonData.dat";
56  std::ifstream calib(fullfile);
57  calib.close();
58  // use printf for stuff which should go the screen but not into the message
59  // system (all couts are redirected)
60  printf("doing the Init\n");
61  daqhist1 = new TH1F("daqmon_hist1", "test 1d histo", 101, 0., 100.);
62  daqhist2 = new TH2F("daqmon_hist2", "test 2d histo", 101, 0., 100., 101, 0., 100.);
64  // register histograms with server otherwise client won't get them
65  se->registerHisto(this, daqhist1); // uses the TH1->GetName() as key
66  se->registerHisto(this, daqhist2);
67  Reset();
68  return 0;
69 }
70 
71 int DaqMon::BeginRun(const int /* runno */)
72 {
73  // if you need to read calibrations on a run by run basis
74  // this is the place to do it
75  return 0;
76 }
77 
78 int DaqMon::process_event(Event * /* evt */)
79 {
80  evtcnt++;
81  // get temporary pointers to histograms
82  // one can do in principle directly se->getHisto("daqhist1")->Fill()
83  // but the search in the histogram Map is somewhat expensive and slows
84  // things down if you make more than one operation on a histogram
85  daqhist1->Fill(gRandom->Gaus(50,10));
86  daqhist2->Fill(gRandom->Gaus(50,10), gRandom->Gaus(50,10), 1.);
87 
88  return 0;
89 }
90 
92 {
93  // reset our internal counters
94  evtcnt = 0;
95  idummy = 0;
96  return 0;
97 }
98