Bug Summary

File:plugins/Utilities/run_summary/DEventProcessor_run_summary.cc
Location:line 149, column 3
Description:Value stored to 'run_branch' is never read

Annotated Source Code

1// $Id$
2//
3// File: DEventProcessor_run_summary.cc
4// Created: Tue Nov 18 15:44:17 EST 2014
5// Creator: sdobbs (on Linux ifarm1102 2.6.32-220.7.1.el6.x86_64 x86_64)
6//
7
8#include "DEventProcessor_run_summary.h"
9#include "DEPICSstore.h"
10
11#include <DAQ/DEPICSvalue.h>
12
13#include <TDirectory.h>
14
15static int VERBOSE = 0;
16
17// Routine used to create our DEventProcessor
18
19extern "C"
20{
21 void InitPlugin(JApplication *locApplication)
22 {
23 InitJANAPlugin(locApplication);
24 locApplication->AddProcessor(new DEventProcessor_run_summary()); //register this plugin
25 }
26} // "C"
27
28//------------------
29// init
30//------------------
31jerror_t DEventProcessor_run_summary::init(void)
32{
33 // This is called once at program startup. If you are creating
34 // and filling historgrams in this plugin, you should lock the
35 // ROOT mutex like this:
36 //
37 // japp->RootWriteLock();
38 // ... create historgrams or trees ...
39 // japp->RootUnLock();
40 //
41
42 current_run_number = -1;
43 conditions_tree = NULL__null;
44 epics_info = NULL__null;
45
46 // deal with command line parameters
47 gPARMS->SetDefaultParameter("SUMMARY:VERBOSE", VERBOSE,
48 "Verbosity level for creating summary values. 0=no messages, 10=all messages");
49 if(VERBOSE)
50 cout << "Run summary verbosity level = " << VERBOSE << endl;
51
52 return NOERROR;
53}
54
55//------------------
56// brun
57//------------------
58jerror_t DEventProcessor_run_summary::brun(jana::JEventLoop* locEventLoop, int locRunNumber)
59{
60 // This is called whenever the run number changes
61 // keep track of current run number for use in our end run function
62 current_run_number = locRunNumber;
63
64 // make tree if it doesn't exist
65 japp->RootWriteLock();
66
67 //Create a folder in the ROOT output file that will contain all of the output ROOT objects (if any) for this plugin
68 //If another thread has already created the folder, it just changes to it.
69 TDirectory *main_dir = gDirectory(TDirectory::CurrentDirectory());
70 gDirectory(TDirectory::CurrentDirectory())->cd("/");
71
72 TDirectory* plugin_dir = static_cast<TDirectory*>(gDirectory(TDirectory::CurrentDirectory())->GetDirectory("conditions")); // TDirectoryFile
73 if(plugin_dir == NULL__null)
74 plugin_dir = gDirectory(TDirectory::CurrentDirectory())->mkdir("conditions");
75 plugin_dir->cd();
76
77 if(gDirectory(TDirectory::CurrentDirectory())->Get("conditions") == NULL__null) //check to see if already created by another thread
78 conditions_tree = new TTree("conditions","");
79 else //already created by another thread
80 conditions_tree = static_cast<TTree*>(gDirectory(TDirectory::CurrentDirectory())->Get("conditions"));
81
82 japp->RootUnLock();
83
84 // reset EPICS summary info each run
85 if(epics_info)
86 delete epics_info;
87 epics_info = new DEPICSstore;
88
89 main_dir->cd();
90 return NOERROR;
91}
92
93//------------------
94// evnt
95//------------------
96jerror_t DEventProcessor_run_summary::evnt(jana::JEventLoop* locEventLoop, uint64_t locEventNumber)
97{
98 // This is called for every event. Use of common resources like writing
99 // to a file or filling a histogram should be mutex protected. Using
100 // locEventLoop->Get(...) to get reconstructed objects (and thereby activating the
101 // reconstruction algorithm) should be done outside of any mutex lock
102 // since multiple threads may call this method at the same time.
103 //
104 // Here's an example:
105 //
106 // vector<const MyDataClass*> mydataclasses;
107 // locEventLoop->Get(mydataclasses);
108 //
109 // japp->RootWriteLock();
110 // ... fill historgrams or trees ...
111 // japp->RootUnLock();
112
113 // read in whatever epics values are in this event
114 vector<const DEPICSvalue*> epicsvalues;
115 locEventLoop->Get(epicsvalues);
116
117 // save their values
118 for(vector<const DEPICSvalue*>::const_iterator val_itr = epicsvalues.begin();
119 val_itr != epicsvalues.end(); val_itr++) {
120 const DEPICSvalue* epics_val = *val_itr;
121 if(VERBOSE)
122 cout << "EPICS: " << epics_val->name << " = " << epics_val->sval << endl;
123
124 if(epics_info)
125 epics_info->AddValue(epics_val);
126 else
127 jerr << "EPICS store object not loaded!" << endl;
128 }
129
130 return NOERROR;
131}
132
133//------------------
134// erun
135//------------------
136jerror_t DEventProcessor_run_summary::erun(void)
137{
138 // This is called whenever the run number changes, before it is
139 // changed to give you a chance to clean up before processing
140 // events from the next run number.
141
142 // if we couldn't create the tree earlier, then throw it away
143 if(conditions_tree == NULL__null)
144 return NOERROR;
145
146 // make a branch for the run number
147 TBranch *run_branch = conditions_tree->FindBranch("run_number");
148 if(run_branch == NULL__null)
149 run_branch = conditions_tree->Branch("run_number", &current_run_number, "run_number/D");
Value stored to 'run_branch' is never read
150 else
151 conditions_tree->SetBranchAddress("run_number", &current_run_number);
152
153 // make branches for each of the values
154 const map<string, DEPICSvalue_data_t> &epics_store = epics_info->GetStore();
155 for(map<string, DEPICSvalue_data_t>::const_iterator epics_val_itr = epics_store.begin();
156 epics_val_itr != epics_store.end(); epics_val_itr++) {
157 string branch_name = epics_val_itr->first;
158 TBranch *the_branch = conditions_tree->FindBranch(branch_name.c_str());
159 if(the_branch == NULL__null) {
160 string branch_def = branch_name + "/D";
161 the_branch = conditions_tree->Branch(branch_name.c_str(), &(epics_val_itr->second.value->fval), branch_def.c_str());
162 } else {
163 conditions_tree->SetBranchAddress(branch_name.c_str(), &(epics_val_itr->second.value->fval));
164 }
165 }
166
167 // save the values for this run
168 conditions_tree->Fill();
169
170 return NOERROR;
171}
172
173//------------------
174// fini
175//------------------
176jerror_t DEventProcessor_run_summary::fini(void)
177{
178 // Called before program exit after event processing is finished.
179 return NOERROR;
180}
181