Bug Summary

File:plugins/monitoring/EPICS_dump/JEventProcessor_EPICS_dump.cc
Location:line 275, column 6
Description:Value stored to 'busytime' is never read

Annotated Source Code

1// $Id$
2//
3// File: JEventProcessor_FCAL_online.cc
4// Created: Fri Nov 9 11:58:09 EST 2012
5// Creator: wolin (on Linux stan.jlab.org 2.6.32-279.11.1.el6.x86_64 x86_64)
6
7
8#include <stdint.h>
9#include <vector>
10#include <deque>
11#include <string>
12#include <iostream>
13#include <algorithm>
14#include <stdio.h>
15#include <stdlib.h>
16
17#include "JEventProcessor_EPICS_dump.h"
18#include <JANA/JApplication.h>
19
20#include "DLorentzVector.h"
21#include "TMatrixD.h"
22
23#include "BCAL/DBCALShower.h"
24#include "BCAL/DBCALCluster.h"
25#include "BCAL/DBCALPoint.h"
26#include "BCAL/DBCALHit.h"
27#include "FCAL/DFCALShower.h"
28#include "FCAL/DFCALCluster.h"
29#include "FCAL/DFCALHit.h"
30#include "TRACKING/DMCThrown.h"
31#include "ANALYSIS/DAnalysisUtilities.h"
32#include "TRIGGER/DL1Trigger.h"
33#include <DANA/DStatusBits.h>
34#include "FCAL/DFCALGeometry.h"
35#include "DAQ/DEPICSvalue.h"
36#include "DAQ/DTSscalers.h"
37
38
39using namespace std;
40using namespace jana;
41
42// #include "TRIG/DTRIG.h"
43
44#include <TDirectory.h>
45#include <TH1.h>
46
47
48// root hist pointers
49
50 static TH1I* h1epics_trgbits = NULL__null;
51 static TH1I* h1epics_AD00 = NULL__null;
52 static TH2I* h2epics_pos_inner = NULL__null;
53 static TH2I* h2epics_pos_outer = NULL__null;
54 Int_t const nscalers=32;
55 static TH1I* h1_trig_rates[nscalers]={NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,
56 NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,
57 NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,
58 NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,NULL__null};
59 static TH1I* h1_trig_livetimes[nscalers]={NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,
60 NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,
61 NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,
62 NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,NULL__null,NULL__null};
63 static TH1I* h1epics_liveinst = NULL__null;
64 static TH1F* h1epics_AD00_VSevent = NULL__null;
65 static TH1F* h1epics_entries1_VSevent = NULL__null;;
66 static TH1F* h1epics_entries2_VSevent = NULL__null;
67 static TH1F* h1epics_liveinst_VSevent = NULL__null;
68
69 static uint64_t save_ntrig[nscalers];
70 static uint64_t save_ntrig0[nscalers];
71 static bool init_ntrig = false;
72
73
74//----------------------------------------------------------------------------------
75
76
77// Routine used to create our JEventProcessor
78extern "C"{
79 void InitPlugin(JApplication *locApplication){
80 InitJANAPlugin(locApplication);
81 locApplication->AddProcessor(new JEventProcessor_EPICS_dump());
82 }
83}
84
85
86//----------------------------------------------------------------------------------
87
88
89JEventProcessor_EPICS_dump::JEventProcessor_EPICS_dump() {
90}
91
92
93//----------------------------------------------------------------------------------
94
95
96JEventProcessor_EPICS_dump::~JEventProcessor_EPICS_dump() {
97}
98
99
100//----------------------------------------------------------------------------------
101
102jerror_t JEventProcessor_EPICS_dump::init(void) {
103
104 // First thread to get here makes all histograms. If one pointer is
105 // already not NULL, assume all histograms are defined and return now
106 if(h1epics_trgbits != NULL__null){
107 return NOERROR;
108 }
109
110 // create root folder for trig and cd to it, store main dir
111 TDirectory *main = gDirectory(TDirectory::CurrentDirectory());
112 gDirectory(TDirectory::CurrentDirectory())->mkdir("EPICS_dump")->cd();
113
114
115 // book hist
116 int const nbins=100;
117 Int_t const nscalers=32;
118 char string[132];
119
120 h1epics_trgbits = new TH1I("h1epics_trgbits", "Trig Trgbits",30,0,30);
121 h1epics_trgbits->SetXTitle("trig_mask || (20+fp_trig_mask/256)");
122 h1epics_trgbits->SetYTitle("counts");
123 h1epics_trgbits = new TH1I("h1epics_trgbits", "Trig Trgbits",30,0,30);
124 h1epics_trgbits->SetXTitle("trig_mask || (20+fp_trig_mask/256)");
125 h1epics_trgbits->SetYTitle("counts");
126
127 for (Int_t j=0; j<nscalers;j++) {
128 sprintf (string,"Rates%d(kHz)",j);
129 h1_trig_rates[j] = new TH1I(string,string,nbins,0,100);
130 h1_trig_rates[j]->SetTitle(string);
131 sprintf (string,"Livetimes%d",j);
132 h1_trig_livetimes[j] = new TH1I(string,string,nbins,0,1);
133 h1_trig_livetimes[j]->SetTitle(string);
134 }
135
136 h1epics_liveinst = new TH1I("h1epics_liveinst", "Liveinst",nbins,0,1);
137 h1epics_liveinst->SetXTitle("Instantaneous Live time");
138 h1epics_liveinst->SetYTitle("counts");
139
140 h1epics_AD00 = new TH1I("h1epics_AD00", "Current AD00",nbins,0,500);
141 h1epics_AD00->SetXTitle("Current AD00 (nA)");
142 h1epics_AD00->SetYTitle("counts");
143
144 h2epics_pos_inner = new TH2I("h1epics_pos_inner", "Position AC inner",nbins,-10,10,nbins,-10,10);
145 h2epics_pos_inner->SetXTitle("Position AC inner x (mm)");
146 h2epics_pos_inner->SetYTitle("Position AC inner y (mm)");
147 h2epics_pos_outer = new TH2I("h1epics_pos_outer", "Position AC outer",nbins,-20,20,nbins,-20,20);
148 h2epics_pos_outer->SetXTitle("Position AC outer x (mm)");
149 h2epics_pos_outer->SetYTitle("Position AC outer y (mm)");
150
151
152 h1epics_AD00_VSevent = new TH1F("h1epics_AD00_VSevent", "Current AD00 (nA)",200,0,2e6);
153 h1epics_AD00_VSevent->SetXTitle("Event number");
154 h1epics_AD00_VSevent->SetYTitle("Current (nA)");
155 h1epics_entries1_VSevent = new TH1F("h1epics_entries1_VSevent", "No synch events/bin",200,0,200e6);
156 h1epics_entries1_VSevent->SetXTitle("Event number");
157 h1epics_entries1_VSevent->SetYTitle("No of synch events");
158 h1epics_entries2_VSevent = new TH1F("h1epics_entries2_VSevent", "No epics events/bin",200,0,2e6);
159 h1epics_entries2_VSevent->SetXTitle("Event number");
160 h1epics_entries2_VSevent->SetYTitle("No of synch events");
161 h1epics_liveinst_VSevent = new TH1F("h1epics_liveinst_VSevent", "",200,0,200e6);
162 h1epics_liveinst_VSevent->SetXTitle("Event number");
163 h1epics_liveinst_VSevent->SetYTitle("Live Time");
164
165
166
167 // back to main dir
168 main->cd();
169
170 // initialize live times
171 for (Int_t j=0; j<nscalers; j++) {
172 save_ntrig[j] = 0;
173 save_ntrig0[j] = 0;
174 }
175
176 return NOERROR;
177}
178
179
180//----------------------------------------------------------------------------------
181
182
183jerror_t JEventProcessor_EPICS_dump::brun(jana::JEventLoop* locEventLoop, int locRunNumber) {
184 // This is called whenever the run number changes
185 return NOERROR;
186}
187
188
189//----------------------------------------------------------------------------------
190
191
192jerror_t JEventProcessor_EPICS_dump::evnt(jana::JEventLoop* locEventLoop, uint64_t locEventNumber) {
193 // This is called for every event. Use of common resources like writing
194 // to a file or filling a histogram should be mutex protected. Using
195 // loop-Get(...) to get reconstructed objects (and thereby activating the
196 // reconstruction algorithm) should be done outside of any mutex lock
197 // since multiple threads may call this method at the same time.
198
199
200 vector<const DFCALShower*> locFCALShowers;
201 vector<const DBCALPoint*> bcalpoints;
202 vector<const DFCALHit*> fcalhits;
203 vector<const DFCALCluster*> locFCALClusters;
204 vector<const DEPICSvalue*> epicsvalues;
205 //const DDetectorMatches* locDetectorMatches = NULL;
206 //locEventLoop->GetSingle(locDetectorMatches);
207 locEventLoop->Get(locFCALShowers);
208 locEventLoop->Get(bcalpoints);
209 locEventLoop->Get(fcalhits);
210 locEventLoop->Get(locFCALClusters);
211 locEventLoop->Get(epicsvalues);
212 DFCALGeometry fcalgeom;
213 Int_t const nscalers=32;
214
215 bool isPhysics = locEventLoop->GetJEvent().GetStatusBit(kSTATUS_PHYSICS_EVENT);
216 bool isEPICS = locEventLoop->GetJEvent().GetStatusBit(kSTATUS_EPICS_EVENT);
217 // bool isSynch = locEventLoop->GetJEvent().GetStatusBit(kSTATUS_SYNCH_EVENT);
218
219 // FILL HISTOGRAMS
220 // Since we are filling histograms local to this plugin, it will not interfere with other ROOT operations: can use plugin-wide ROOT fill lock
221 japp->RootFillLock(this); //ACQUIRE ROOT FILL LOCK
222
223 uint32_t trig_mask=0, fp_trig_mask=0;
224 uint32_t temp_mask=0;
225
226 if (isPhysics) {
227 // first get trigger bits
228
229 const DL1Trigger *trig_words = NULL__null;
230
231 try {
232 locEventLoop->GetSingle(trig_words);
233 } catch(...) {};
234 if (trig_words) {
235 trig_mask = trig_words->trig_mask;
236 fp_trig_mask = trig_words->fp_trig_mask;
237 for (int j=0; j<nscalers; j++) {
238 temp_mask = trig_mask & 1<<j;
239 if (temp_mask && init_ntrig) save_ntrig[j] += 1;
240 }
241 }
242 else {
243 trig_mask = 0;
244 fp_trig_mask = 0;
245 }
246
247 int trig_bits = fp_trig_mask > 0? 20 + fp_trig_mask/256: trig_mask;
248 if (fp_trig_mask>0) printf (" Event=%d trig_bits=%d trig_mask=%X fp_trig_mask=%X\n",(int)locEventNumber,trig_bits,trig_mask,fp_trig_mask);
249
250 /* fp_trig_mask & 0x100 - upstream LED
251 fp_trig_mask & 0x200 - downstream LED
252 trig_mask & 0x1 - cosmic trigger*/
253
254 h1epics_trgbits->Fill(trig_bits);
255
256
257 // now get scalers
258
259 const DTSscalers *ts_scalers = NULL__null;
260 uint32_t livetime; /* accumulated livetime */
261 uint32_t busytime; /* accumulated busy time */
262 uint32_t live_inst; /* instantaneous livetime */
263 uint32_t timestamp; /*unix time*/
264
265 uint32_t gtp_sc[nscalers]; /* number of input triggers from GTP for 32 lanes (32 trigger bits) */
266 // uint32_t fp_sc[nscalers1]; /* number of TS front pannel triggers for 16 fron pannel lines (16 trigger bits) */
267 uint32_t gtp_rate[nscalers]; /* instant. rate of GTP triggers */
268 // uint32_t fp_rate[nscalers1]; /* instant. rate of FP triggers */
269
270 try {
271 locEventLoop->GetSingle(ts_scalers);
272 } catch(...) {};
273 if (ts_scalers) {
274 livetime = ts_scalers->live_time;
275 busytime = ts_scalers->busy_time;
Value stored to 'busytime' is never read
276 live_inst = ts_scalers->inst_livetime;
277 timestamp = ts_scalers->time;
278 h1epics_liveinst->Fill((float)live_inst/1000.);
279 h1epics_liveinst_VSevent->Fill((float)locEventNumber,(float)live_inst/1000.);
280 h1epics_entries1_VSevent->Fill((float)locEventNumber);
281 // printf ("Event=%d livetime=%d busytime=%d time=%d live_inst=%d\n",(int)locEventNumber,livetime,busytime,(int)timestamp,live_inst);
282 if (! init_ntrig) {
283 for (int j=0; j<nscalers; j++) {
284 save_ntrig0[j] = ts_scalers->gtp_scalers[j];
285 init_ntrig = true;
286 }
287 }
288 for (int j=0; j<nscalers; j++) {
289 gtp_sc[j] = ts_scalers->gtp_scalers[j] - save_ntrig0[j];
290 gtp_rate[j] = ts_scalers->gtp_rate[j];
291 // printf ("TSscalers: Event=%d j=%d gtp_sc=%d gtp_rate=%d\n",(int)locEventNumber,j,gtp_sc[j],gtp_rate[j]);
292 // printf ("TSscalers: Event=%d trig_mask=%X temp_mask=%X save_ntrig=%d\n",(int)locEventNumber,trig_mask,temp_mask,(int)save_ntrig[j]);
293 h1_trig_rates[j]->Fill(gtp_rate[j]/1000); // plot in kHz
294 if (gtp_sc[j] >0) {
295 h1_trig_livetimes[j]->Fill((float)save_ntrig[j]/(float)gtp_sc[j]);
296 save_ntrig0[j] = ts_scalers->gtp_scalers[j];
297 save_ntrig[j] = 0;
298 }
299 }
300 }
301 }
302 else if (isEPICS) {
303 // else if (TEST) {
304 // process EPICS records
305 printf (" Event=%d is an EPICS record\n",(int)locEventNumber);
306
307
308 // read in whatever epics values are in this event
309
310 // save their values
311 float pos_default=-1000.;
312 float xpos_inner = pos_default;
313 float ypos_inner = pos_default;;
314 float xpos_outer = pos_default;
315 float ypos_outer = pos_default;
316 for(vector<const DEPICSvalue*>::const_iterator val_itr = epicsvalues.begin();
317 val_itr != epicsvalues.end(); val_itr++) {
318 const DEPICSvalue* epics_val = *val_itr;
319 cout << "EPICS: " << epics_val->name << " = " << epics_val->sval << endl;
320 float fconv = atof(epics_val->sval.c_str());
321 bool isDigit = epics_val->name.length()> 12 && isdigit(epics_val->name[12]);
322 // cout << "isDigit=" << isDigit << " string=" << epics_val->name << endl;
323 if ((epics_val->name.substr(0,11) == "BCAL:pulser") & isDigit) {
324 double freq = 1.e8/fconv; // cover to s: period is in units 10 ns
325 cout << "BCAL:pulser=" << epics_val->name.substr(0,11) << epics_val->fval << " freq=" << freq <<endl;
326 }
327 else if (epics_val->name == "IBCAD00CRCUR6") {
328 h1epics_AD00->Fill(fconv);
329 h1epics_AD00_VSevent->Fill((float)locEventNumber,fconv);
330 h1epics_entries2_VSevent->Fill((float)locEventNumber);
331 cout << "IBCAD00CRCUR6 " << epics_val->name << " fconv=" << fconv << endl;
332 }
333 else if (epics_val->name == "AC:inner:position:x") {
334 xpos_inner = fconv;
335 }
336 else if (epics_val->name == "AC:inner:position:y") {
337 ypos_inner = fconv;
338 }
339 else if (epics_val->name == "AC:outer:position:x") {
340 xpos_outer = fconv;
341 }
342 else if (epics_val->name == "AC:outer:position:y") {
343 ypos_outer = fconv;
344 }
345 }
346 if (xpos_inner> pos_default && ypos_inner > pos_default) {
347 h2epics_pos_inner->Fill(xpos_inner,ypos_inner);
348 }
349 if (xpos_outer> pos_default && ypos_outer > pos_default) {
350 h2epics_pos_outer->Fill(xpos_outer,ypos_outer);
351 }
352
353 }
354
355 japp->RootFillUnLock(this); //RELEASE ROOT FILL LOCK
356
357 return NOERROR;
358}
359
360
361//----------------------------------------------------------------------------------
362
363
364jerror_t JEventProcessor_EPICS_dump::erun(void) {
365 // This is called whenever the run number changes, before it is
366 // changed to give you a chance to clean up before processing
367 // events from the next run number.
368 return NOERROR;
369}
370
371
372//----------------------------------------------------------------------------------
373
374
375jerror_t JEventProcessor_EPICS_dump::fini(void) {
376 // Called before program exit after event processing is finished.
377 return NOERROR;
378}
379
380
381//----------------------------------------------------------------------------------
382//----------------------------------------------------------------------------------