Bug Summary

File:plugins/monitoring/EPICS_dump/JEventProcessor_EPICS_dump.cc
Location:line 276, 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",80,0,80);
121 h1epics_trgbits->SetXTitle("trig_mask || (70+fp_trig_mask/256)");
122 h1epics_trgbits->SetYTitle("counts");
123
124 for (Int_t j=0; j<nscalers;j++) {
125 sprintf (string,"Rates%d(kHz)",j);
126 h1_trig_rates[j] = new TH1I(string,string,nbins,0,100);
127 h1_trig_rates[j]->SetTitle(string);
128 sprintf (string,"Livetimes%d",j);
129 h1_trig_livetimes[j] = new TH1I(string,string,nbins,0,1);
130 h1_trig_livetimes[j]->SetTitle(string);
131 }
132
133 h1epics_liveinst = new TH1I("h1epics_liveinst", "Liveinst",nbins,0,1);
134 h1epics_liveinst->SetXTitle("Instantaneous Live time");
135 h1epics_liveinst->SetYTitle("counts");
136
137 h1epics_AD00 = new TH1I("h1epics_AD00", "Current AD00",nbins,0,500);
138 h1epics_AD00->SetXTitle("Current AD00 (nA)");
139 h1epics_AD00->SetYTitle("counts");
140
141 h2epics_pos_inner = new TH2I("h1epics_pos_inner", "Position AC inner",nbins,-10,10,nbins,-10,10);
142 h2epics_pos_inner->SetXTitle("Position AC inner x (mm)");
143 h2epics_pos_inner->SetYTitle("Position AC inner y (mm)");
144 h2epics_pos_outer = new TH2I("h1epics_pos_outer", "Position AC outer",nbins,-20,20,nbins,-20,20);
145 h2epics_pos_outer->SetXTitle("Position AC outer x (mm)");
146 h2epics_pos_outer->SetYTitle("Position AC outer y (mm)");
147
148
149 h1epics_AD00_VSevent = new TH1F("h1epics_AD00_VSevent", "Current AD00 (nA)",200,0,2e6);
150 h1epics_AD00_VSevent->SetXTitle("Event number");
151 h1epics_AD00_VSevent->SetYTitle("Current (nA)");
152 h1epics_entries1_VSevent = new TH1F("h1epics_entries1_VSevent", "No synch events/bin",200,0,200e6);
153 h1epics_entries1_VSevent->SetXTitle("Event number");
154 h1epics_entries1_VSevent->SetYTitle("No of synch events");
155 h1epics_entries2_VSevent = new TH1F("h1epics_entries2_VSevent", "No epics events/bin",200,0,2e6);
156 h1epics_entries2_VSevent->SetXTitle("Event number");
157 h1epics_entries2_VSevent->SetYTitle("No of synch events");
158 h1epics_liveinst_VSevent = new TH1F("h1epics_liveinst_VSevent", "",200,0,200e6);
159 h1epics_liveinst_VSevent->SetXTitle("Event number");
160 h1epics_liveinst_VSevent->SetYTitle("Live Time");
161
162
163
164 // back to main dir
165 main->cd();
166
167 // initialize live times
168 for (Int_t j=0; j<nscalers; j++) {
169 save_ntrig[j] = 0;
170 save_ntrig0[j] = 0;
171 }
172
173 return NOERROR;
174}
175
176
177//----------------------------------------------------------------------------------
178
179
180jerror_t JEventProcessor_EPICS_dump::brun(jana::JEventLoop* locEventLoop, int locRunNumber) {
181 // This is called whenever the run number changes
182 return NOERROR;
183}
184
185
186//----------------------------------------------------------------------------------
187
188
189jerror_t JEventProcessor_EPICS_dump::evnt(jana::JEventLoop* locEventLoop, uint64_t locEventNumber) {
190 // This is called for every event. Use of common resources like writing
191 // to a file or filling a histogram should be mutex protected. Using
192 // loop-Get(...) to get reconstructed objects (and thereby activating the
193 // reconstruction algorithm) should be done outside of any mutex lock
194 // since multiple threads may call this method at the same time.
195
196
197 vector<const DFCALShower*> locFCALShowers;
198 vector<const DBCALPoint*> bcalpoints;
199 vector<const DFCALHit*> fcalhits;
200 vector<const DFCALCluster*> locFCALClusters;
201 vector<const DEPICSvalue*> epicsvalues;
202 //const DDetectorMatches* locDetectorMatches = NULL;
203 //locEventLoop->GetSingle(locDetectorMatches);
204 locEventLoop->Get(locFCALShowers);
205 locEventLoop->Get(bcalpoints);
206 locEventLoop->Get(fcalhits);
207 locEventLoop->Get(locFCALClusters);
208 locEventLoop->Get(epicsvalues);
209 DFCALGeometry fcalgeom;
210 Int_t const nscalers=32;
211
212 bool isPhysics = locEventLoop->GetJEvent().GetStatusBit(kSTATUS_PHYSICS_EVENT);
213 bool isEPICS = locEventLoop->GetJEvent().GetStatusBit(kSTATUS_EPICS_EVENT);
214 // bool isSynch = locEventLoop->GetJEvent().GetStatusBit(kSTATUS_SYNCH_EVENT);
215
216 // get trigger information, if it exists
217 const DL1Trigger *trig_words = NULL__null;
218
219 try {
220 locEventLoop->GetSingle(trig_words);
221 } catch(...) {};
222
223 // get information about scalars, if it exists
224 const DTSscalers *ts_scalers = NULL__null;
225 try {
226 locEventLoop->GetSingle(ts_scalers);
227 } catch(...) {};
228
229 // FILL HISTOGRAMS
230 // Since we are filling histograms local to this plugin, it will not interfere with other ROOT operations: can use plugin-wide ROOT fill lock
231 japp->RootFillLock(this); //ACQUIRE ROOT FILL LOCK
232
233 uint32_t trig_mask=0, fp_trig_mask=0;
234 uint32_t temp_mask=0;
235
236 if (isPhysics) {
237
238 // fill trigger histograms
239 if (trig_words) {
240 trig_mask = trig_words->trig_mask;
241 fp_trig_mask = trig_words->fp_trig_mask;
242 for (int j=0; j<nscalers; j++) {
243 temp_mask = trig_mask & 1<<j;
244 if (temp_mask && init_ntrig) save_ntrig[j] += 1;
245 }
246 }
247 else {
248 trig_mask = 0;
249 fp_trig_mask = 0;
250 }
251
252 int trig_bits = fp_trig_mask > 0? 70 + fp_trig_mask/256: trig_mask;
253 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);
254
255 /* fp_trig_mask & 0x100 - upstream LED
256 fp_trig_mask & 0x200 - downstream LED
257 trig_mask & 0x1 - cosmic trigger*/
258
259 h1epics_trgbits->Fill(trig_bits);
260
261
262 // now fill scalers
263
264 uint32_t livetime; /* accumulated livetime */
265 uint32_t busytime; /* accumulated busy time */
266 uint32_t live_inst; /* instantaneous livetime */
267 uint32_t timestamp; /*unix time*/
268
269 uint32_t gtp_sc[nscalers]; /* number of input triggers from GTP for 32 lanes (32 trigger bits) */
270 // uint32_t fp_sc[nscalers1]; /* number of TS front pannel triggers for 16 fron pannel lines (16 trigger bits) */
271 uint32_t gtp_rate[nscalers]; /* instant. rate of GTP triggers */
272 // uint32_t fp_rate[nscalers1]; /* instant. rate of FP triggers */
273
274 if (ts_scalers) {
275 livetime = ts_scalers->live_time;
276 busytime = ts_scalers->busy_time;
Value stored to 'busytime' is never read
277 live_inst = ts_scalers->inst_livetime;
278 timestamp = ts_scalers->time;
279 h1epics_liveinst->Fill((float)live_inst/1000.);
280 h1epics_liveinst_VSevent->Fill((float)locEventNumber,(float)live_inst/1000.);
281 h1epics_entries1_VSevent->Fill((float)locEventNumber);
282 // printf ("Event=%d livetime=%d busytime=%d time=%d live_inst=%d\n",(int)locEventNumber,livetime,busytime,(int)timestamp,live_inst);
283 if (! init_ntrig) {
284 for (int j=0; j<nscalers; j++) {
285 save_ntrig0[j] = ts_scalers->gtp_scalers[j];
286 init_ntrig = true;
287 }
288 }
289 for (int j=0; j<nscalers; j++) {
290 gtp_sc[j] = ts_scalers->gtp_scalers[j] - save_ntrig0[j];
291 gtp_rate[j] = ts_scalers->gtp_rate[j];
292 // printf ("TSscalers: Event=%d j=%d gtp_sc=%d gtp_rate=%d\n",(int)locEventNumber,j,gtp_sc[j],gtp_rate[j]);
293 // printf ("TSscalers: Event=%d trig_mask=%X temp_mask=%X save_ntrig=%d\n",(int)locEventNumber,trig_mask,temp_mask,(int)save_ntrig[j]);
294 h1_trig_rates[j]->Fill(gtp_rate[j]/1000); // plot in kHz
295 if (gtp_sc[j] >0) {
296 h1_trig_livetimes[j]->Fill((float)save_ntrig[j]/(float)gtp_sc[j]);
297 save_ntrig0[j] = ts_scalers->gtp_scalers[j];
298 save_ntrig[j] = 0;
299 }
300 }
301 }
302 }
303 else if (isEPICS) {
304 // else if (TEST) {
305 // process EPICS records
306 printf (" Event=%d is an EPICS record\n",(int)locEventNumber);
307
308
309 // read in whatever epics values are in this event
310
311 // save their values
312 float pos_default=-1000.;
313 float xpos_inner = pos_default;
314 float ypos_inner = pos_default;;
315 float xpos_outer = pos_default;
316 float ypos_outer = pos_default;
317 for(vector<const DEPICSvalue*>::const_iterator val_itr = epicsvalues.begin();
318 val_itr != epicsvalues.end(); val_itr++) {
319 const DEPICSvalue* epics_val = *val_itr;
320 cout << "EPICS: " << epics_val->name << " = " << epics_val->sval << endl;
321 float fconv = atof(epics_val->sval.c_str());
322 unsigned int iconv = atoi(epics_val->sval.c_str());
323 bool isDigit = epics_val->name.length()> 12 && isdigit(epics_val->name[12]);
324 // cout << "isDigit=" << isDigit << " string=" << epics_val->name << endl;
325 if ((epics_val->name.substr(0,11) == "BCAL:pulser") & isdigit(epics_val->name[11])) {
326 val_itr++; // increment counter and get low order word
327 epics_val = *val_itr;
328 cout << "EPICS: " << epics_val->name << " = " << epics_val->sval << endl;
329 unsigned int iconv_low = atoi(epics_val->sval.c_str());
330 // cout << "BCAL:pulser status=" << epics_val->name.substr(0,11) << endl;
331 // printf ("BCAL:pulser iconv=%d, %0X, iconv_low=%d %0X\n",iconv,iconv,iconv_low,iconv_low);
332 iconv_low = iconv_low >> 31;
333 iconv = ((iconv <<1) & 0XFFFF) + iconv_low;
334 // cout << "BCAL:pulser status=" << epics_val->name.substr(0,11) << endl;
335 printf ("BCAL:pulser status=%d, %0X, iconv_low=%0X\n",iconv,iconv,iconv_low);
336 }
337 else if ((epics_val->name.substr(0,11) == "BCAL:pulser") & isDigit) {
338 double freq = 1.e8/fconv; // cover to s: period is in units 10 ns
339 cout << "BCAL:pulser=" << epics_val->name.substr(0,11) << epics_val->fval << " freq=" << freq <<endl;
340 }
341 else if (epics_val->name == "IBCAD00CRCUR6") {
342 h1epics_AD00->Fill(fconv);
343 h1epics_AD00_VSevent->Fill((float)locEventNumber,fconv);
344 h1epics_entries2_VSevent->Fill((float)locEventNumber);
345 cout << "IBCAD00CRCUR6 " << epics_val->name << " fconv=" << fconv << endl;
346 }
347 else if (epics_val->name == "AC:inner:position:x") {
348 xpos_inner = fconv;
349 }
350 else if (epics_val->name == "AC:inner:position:y") {
351 ypos_inner = fconv;
352 }
353 else if (epics_val->name == "AC:outer:position:x") {
354 xpos_outer = fconv;
355 }
356 else if (epics_val->name == "AC:outer:position:y") {
357 ypos_outer = fconv;
358 }
359 }
360 if (xpos_inner> pos_default && ypos_inner > pos_default) {
361 h2epics_pos_inner->Fill(xpos_inner,ypos_inner);
362 }
363 if (xpos_outer> pos_default && ypos_outer > pos_default) {
364 h2epics_pos_outer->Fill(xpos_outer,ypos_outer);
365 }
366
367 }
368
369 japp->RootFillUnLock(this); //RELEASE ROOT FILL LOCK
370
371 return NOERROR;
372}
373
374
375//----------------------------------------------------------------------------------
376
377
378jerror_t JEventProcessor_EPICS_dump::erun(void) {
379 // This is called whenever the run number changes, before it is
380 // changed to give you a chance to clean up before processing
381 // events from the next run number.
382 return NOERROR;
383}
384
385
386//----------------------------------------------------------------------------------
387
388
389jerror_t JEventProcessor_EPICS_dump::fini(void) {
390 // Called before program exit after event processing is finished.
391 return NOERROR;
392}
393
394
395//----------------------------------------------------------------------------------
396//----------------------------------------------------------------------------------