File indexing completed on 2025-08-03 08:21:00
0001
0002
0003
0004
0005
0006 #include "MyMon.h"
0007
0008 #include <onlmon/OnlMon.h> // for OnlMon
0009 #include <onlmon/OnlMonDB.h>
0010 #include <onlmon/OnlMonServer.h>
0011
0012 #include <Event/msg_profile.h>
0013
0014 #include <TH1.h>
0015 #include <TH2.h>
0016 #include <TRandom.h>
0017
0018 #include <cmath>
0019 #include <cstdio> // for printf
0020 #include <iostream>
0021 #include <sstream>
0022 #include <string> // for allocator, string, char_traits
0023
0024 enum
0025 {
0026 TRGMESSAGE = 1,
0027 FILLMESSAGE = 2
0028 };
0029
0030 MyMon::MyMon(const std::string &name)
0031 : OnlMon(name)
0032 {
0033
0034
0035 return;
0036 }
0037
0038 MyMon::~MyMon()
0039 {
0040
0041 delete dbvars;
0042 return;
0043 }
0044
0045 int MyMon::Init()
0046 {
0047 gRandom->SetSeed(rand());
0048
0049
0050 printf("doing the Init\n");
0051 myhist1 = new TH1F("mymon_hist1", "test 1d histo", 101, 0., 100.);
0052 myhist2 = new TH2F("mymon_hist2", "test 2d histo", 101, 0., 100., 101, 0., 100.);
0053 OnlMonServer *se = OnlMonServer::instance();
0054
0055 se->registerHisto(this, myhist1);
0056 se->registerHisto(this, myhist2);
0057 dbvars = new OnlMonDB(ThisName);
0058 DBVarInit();
0059 Reset();
0060 return 0;
0061 }
0062
0063 int MyMon::BeginRun(const int )
0064 {
0065
0066
0067 return 0;
0068 }
0069
0070 int MyMon::process_event(Event * )
0071 {
0072 evtcnt++;
0073 OnlMonServer *se = OnlMonServer::instance();
0074
0075
0076
0077
0078 myhist1->Fill(gRandom->Gaus(50,10));
0079 myhist2->Fill(gRandom->Gaus(50,10), gRandom->Gaus(50,10), 1.);
0080
0081 if (idummy++ > 10)
0082 {
0083 if (dbvars)
0084 {
0085 dbvars->SetVar("mymoncount", (float) evtcnt, 0.1 * evtcnt, (float) evtcnt);
0086 dbvars->SetVar("mymondummy", sin((double) evtcnt), cos((double) evtcnt), (float) evtcnt);
0087 dbvars->SetVar("mymonnew", (float) evtcnt, 10000. / se->CurrentTicks(), (float) evtcnt);
0088 dbvars->DBcommit();
0089 }
0090 std::ostringstream msg;
0091 msg << "Filling Histos";
0092 se->send_message(this, MSG_SOURCE_UNSPECIFIED, MSG_SEV_INFORMATIONAL, msg.str(), FILLMESSAGE);
0093 idummy = 0;
0094 }
0095 return 0;
0096 }
0097
0098 int MyMon::Reset()
0099 {
0100
0101 evtcnt = 0;
0102 idummy = 0;
0103 return 0;
0104 }
0105
0106 int MyMon::DBVarInit()
0107 {
0108
0109 std::string varname;
0110 varname = "mymoncount";
0111 dbvars->registerVar(varname);
0112 varname = "mymondummy";
0113 dbvars->registerVar(varname);
0114 varname = "mymonnew";
0115 dbvars->registerVar(varname);
0116 if (verbosity > 0)
0117 {
0118 dbvars->Print();
0119 }
0120 dbvars->DBInit();
0121 return 0;
0122 }