Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DEventProcessor_monitoring_hists.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: DEventProcessor_monitoring_hists.cc
4 // Created: Thu Sep 28 11:38:03 EDT 2011
5 // Creator: pmatt (on Darwin swire-b241.jlab.org 8.4.0 powerpc)
6 //
7 
9 
10 // The executable should define the ROOTfile global variable. It will
11 // be automatically linked when dlopen is called.
12 extern TFile *ROOTfile;
13 
14 // Routine used to create our DEventProcessor
15 extern "C"
16 {
17  void InitPlugin(JApplication *app)
18  {
19  InitJANAPlugin(app);
20  app->AddProcessor(new DEventProcessor_monitoring_hists());
21  }
22 } // "C"
23 
24 //------------------
25 // init
26 //------------------
28 {
30  gPARMS->SetDefaultParameter("MONITOR:MEMORY_EVENTS", dNumMemoryMonitorEvents);
31 
32  string locOutputFileName = "hd_root.root";
33  if(gPARMS->Exists("OUTPUT_FILENAME"))
34  gPARMS->GetParameter("OUTPUT_FILENAME", locOutputFileName);
35 
36  //go to file
37  TFile* locFile = (TFile*)gROOT->FindObject(locOutputFileName.c_str());
38  if(locFile != NULL)
39  locFile->cd("");
40  else
41  gDirectory->Cd("/");
42 
43  //go to directory
44  TDirectoryFile* locSubDirectory = static_cast<TDirectoryFile*>(gDirectory->Get("Independent"));
45  if(locSubDirectory == NULL) //else folder already created
46  locSubDirectory = new TDirectoryFile("Independent", "Independent");
47  locSubDirectory->cd();
48 
49  dHist_IsEvent = new TH1D("IsEvent", "Is the event an event?", 2, -0.5, 1.5);
50  dHist_IsEvent->GetXaxis()->SetBinLabel(1, "False");
51  dHist_IsEvent->GetXaxis()->SetBinLabel(2, "True");
52 
53  gDirectory->cd("..");
54 
55  return NOERROR;
56 }
57 
58 //------------------
59 // brun
60 //------------------
61 jerror_t DEventProcessor_monitoring_hists::brun(JEventLoop *locEventLoop, int32_t runnumber)
62 {
63  vector<const DMCThrown*> locMCThrowns;
64  locEventLoop->Get(locMCThrowns);
65 
66  //Initialize Actions
70 
75 
79 
81  {
84  }
85 
86  if(!locMCThrowns.empty())
87  {
91  }
92 
93  return NOERROR;
94 }
95 
96 //------------------
97 // evnt
98 //------------------
99 jerror_t DEventProcessor_monitoring_hists::evnt(JEventLoop *locEventLoop, uint64_t eventnumber)
100 {
101  // FILL HISTOGRAMS
102  // Since we are filling histograms local to this plugin, it will not interfere with other ROOT operations: can use plugin-wide ROOT fill lock
103 
104  // first fill histograms which should always be filled, whether or not this is a real "physics" event
105  vector<const DMCThrown*> locMCThrowns;
106  locEventLoop->Get(locMCThrowns);
107  if(!locMCThrowns.empty())
108  {
110  }
111 
113  dHistogramAction_ObjectMemory(locEventLoop);
114 
115  //CHECK TRIGGER TYPE
116  const DTrigger* locTrigger = NULL;
117  locEventLoop->GetSingle(locTrigger);
118  if(!locTrigger->Get_IsPhysicsEvent())
119  return NOERROR;
120 
121  japp->RootFillLock(this); //ACQUIRE ROOT FILL LOCK
122  {
123  dHist_IsEvent->Fill(1);
124  }
125  japp->RootFillUnLock(this); //RELEASE ROOT FILL LOCK
126 
127  //Fill reaction-independent histograms.
129  dHistogramAction_Reconstruction(locEventLoop);
130  dHistogramAction_EventVertex(locEventLoop);
131 
132  dHistogramAction_DetectorMatching(locEventLoop);
134  dHistogramAction_Neutrals(locEventLoop);
135  dHistogramAction_DetectorPID(locEventLoop);
136 
140 
141  if(!locMCThrowns.empty())
142  {
145  }
146 
147  return NOERROR;
148 }
149 
150 //------------------
151 // erun
152 //------------------
154 {
155  // Any final calculations on histograms (like dividing them)
156  // should be done here. This may get called more than once.
157  return NOERROR;
158 }
159 
160 //------------------
161 // fini
162 //------------------
164 {
165  return NOERROR;
166 }
167 
TFile * ROOTfile
DHistogramAction_DetectorPID dHistogramAction_DetectorPID
jerror_t brun(JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
DHistogramAction_ObjectMemory dHistogramAction_ObjectMemory
DHistogramAction_TrackShowerErrors dHistogramAction_TrackShowerErrors
jerror_t fini(void)
Called after last event of last event source has been processed.
DHistogramAction_DetectorMatching dHistogramAction_DetectorMatching
jerror_t evnt(JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
DHistogramAction_ThrownParticleKinematics dHistogramAction_ThrownParticleKinematics
jerror_t init(void)
Called once at program start.
DHistogramAction_ReconnedThrownKinematics dHistogramAction_ReconnedThrownKinematics
JApplication * japp
bool Get_IsPhysicsEvent(void) const
DHistogramAction_DetectorMatchParams dHistogramAction_DetectorMatchParams
void Initialize(JEventLoop *locEventLoop)
InitPlugin_t InitPlugin
DHistogramAction_TrackMultiplicity dHistogramAction_TrackMultiplicity
void Initialize(JEventLoop *locEventLoop)
DHistogramAction_EventVertex dHistogramAction_EventVertex
void Initialize(JEventLoop *locEventLoop)
void Initialize(JEventLoop *locEventLoop)
DHistogramAction_DetectedParticleKinematics dHistogramAction_DetectedParticleKinematics
DHistogramAction_GenReconTrackComparison dHistogramAction_GenReconTrackComparison
DHistogramAction_Reconstruction dHistogramAction_Reconstruction
DHistogramAction_NumReconstructedObjects dHistogramAction_NumReconstructedObjects
void Initialize(JEventLoop *locEventLoop)