Bug Summary

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