Bug Summary

File:plugins/monitoring/EPICS_dump/JEventProcessor_EPICS_dump.cc
Location:line 166, column 4
Description:Value stored to 'iconv' is never read

Annotated Source Code

1// $Id$
2//
3// File: JEventProcessor_EPICS_dump.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 "TH2I.h"
18
19#include "JEventProcessor_EPICS_dump.h"
20#include <JANA/JApplication.h>
21
22#include "TRIGGER/DL1Trigger.h"
23#include <DANA/DStatusBits.h>
24#include "DAQ/DEPICSvalue.h"
25
26using namespace std;
27using namespace jana;
28
29#include <TDirectory.h>
30#include <TH1.h>
31
32
33// root hist pointers
34static TH1I* h1epics_AD00 = NULL__null;
35static TH2I* h2epics_pos_inner = NULL__null;
36static TH2I* h2epics_pos_outer = NULL__null;
37static TH1F* h1epics_AD00_VSevent = NULL__null;
38static TH1F* h1epics_entries_VSevent = NULL__null;
39
40//----------------------------------------------------------------------------------
41
42
43// Routine used to create our JEventProcessor
44extern "C"{
45 void InitPlugin(JApplication *locApplication){
46 InitJANAPlugin(locApplication);
47 locApplication->AddProcessor(new JEventProcessor_EPICS_dump());
48 }
49}
50
51
52//----------------------------------------------------------------------------------
53
54
55JEventProcessor_EPICS_dump::JEventProcessor_EPICS_dump() {
56}
57
58
59//----------------------------------------------------------------------------------
60
61
62JEventProcessor_EPICS_dump::~JEventProcessor_EPICS_dump() {
63}
64
65
66//----------------------------------------------------------------------------------
67
68jerror_t JEventProcessor_EPICS_dump::init(void) {
69
70 // First thread to get here makes all histograms. If one pointer is
71 // already not NULL, assume all histograms are defined and return now
72 if(h1epics_AD00 != NULL__null){
73 return NOERROR;
74 }
75
76 // create root folder for trig and cd to it, store main dir
77 TDirectory *main = gDirectory(TDirectory::CurrentDirectory());
78 gDirectory(TDirectory::CurrentDirectory())->mkdir("EPICS_dump")->cd();
79
80 // book hist
81 int const nbins=100;
82
83 h1epics_AD00 = new TH1I("h1epics_AD00", "Current AD00",nbins,0,500);
84 h1epics_AD00->SetXTitle("Current AD00 (nA)");
85 h1epics_AD00->SetYTitle("counts");
86
87 h2epics_pos_inner = new TH2I("h1epics_pos_inner", "Position AC inner",nbins,-10,10,nbins,-10,10);
88 h2epics_pos_inner->SetXTitle("Position AC inner x (mm)");
89 h2epics_pos_inner->SetYTitle("Position AC inner y (mm)");
90 h2epics_pos_outer = new TH2I("h1epics_pos_outer", "Position AC outer",nbins,-20,20,nbins,-20,20);
91 h2epics_pos_outer->SetXTitle("Position AC outer x (mm)");
92 h2epics_pos_outer->SetYTitle("Position AC outer y (mm)");
93
94 h1epics_AD00_VSevent = new TH1F("h1epics_AD00_VSevent", "Current AD00 (nA)",200,0,2e6);
95 h1epics_AD00_VSevent->SetXTitle("Event number");
96 h1epics_AD00_VSevent->SetYTitle("Current (nA)");
97
98 h1epics_entries_VSevent = new TH1F("h1epics_entries_VSevent", "No epics events/bin",200,0,2e6);
99 h1epics_entries_VSevent->SetXTitle("Event number");
100 h1epics_entries_VSevent->SetYTitle("No of epics events");
101
102 // back to main dir
103 main->cd();
104
105 return NOERROR;
106}
107
108
109//----------------------------------------------------------------------------------
110
111
112jerror_t JEventProcessor_EPICS_dump::brun(jana::JEventLoop* locEventLoop, int locRunNumber) {
113 // This is called whenever the run number changes
114 return NOERROR;
115}
116
117
118//----------------------------------------------------------------------------------
119
120
121jerror_t JEventProcessor_EPICS_dump::evnt(jana::JEventLoop* locEventLoop, uint64_t locEventNumber) {
122 // This is called for every event. Use of common resources like writing
123 // to a file or filling a histogram should be mutex protected. Using
124 // loop-Get(...) to get reconstructed objects (and thereby activating the
125 // reconstruction algorithm) should be done outside of any mutex lock
126 // since multiple threads may call this method at the same time.
127
128 vector<const DEPICSvalue*> epicsvalues;
129 locEventLoop->Get(epicsvalues);
130
131 bool isEPICS = locEventLoop->GetJEvent().GetStatusBit(kSTATUS_EPICS_EVENT);
132 if(!isEPICS)
133 return NOERROR;
134
135 // FILL HISTOGRAMS
136 // Since we are filling histograms local to this plugin, it will not interfere with other ROOT operations: can use plugin-wide ROOT fill lock
137 japp->RootFillLock(this); //ACQUIRE ROOT FILL LOCK
138
139 // process EPICS records
140 //printf (" Event=%d is an EPICS record\n",(int)locEventNumber);
141
142 // read in whatever epics values are in this event
143
144 // save their values
145 float pos_default=-1000.;
146 float xpos_inner = pos_default;
147 float ypos_inner = pos_default;;
148 float xpos_outer = pos_default;
149 float ypos_outer = pos_default;
150 for(vector<const DEPICSvalue*>::const_iterator val_itr = epicsvalues.begin();
151 val_itr != epicsvalues.end(); val_itr++) {
152 const DEPICSvalue* epics_val = *val_itr;
153 //cout << "EPICS: " << epics_val->name << " = " << epics_val->sval << endl;
154 float fconv = atof(epics_val->sval.c_str());
155 unsigned int iconv = atoi(epics_val->sval.c_str());
156 bool isDigit = epics_val->name.length()> 12 && isdigit(epics_val->name[12]);
157 // cout << "isDigit=" << isDigit << " string=" << epics_val->name << endl;
158 if ((epics_val->name.substr(0,11) == "BCAL:pulser") & isdigit(epics_val->name[11])) {
159 val_itr++; // increment counter and get low order word
160 epics_val = *val_itr;
161 //cout << "EPICS: " << epics_val->name << " = " << epics_val->sval << endl;
162 unsigned int iconv_low = atoi(epics_val->sval.c_str());
163 // cout << "BCAL:pulser status=" << epics_val->name.substr(0,11) << endl;
164 // printf ("BCAL:pulser iconv=%d, %0X, iconv_low=%d %0X\n",iconv,iconv,iconv_low,iconv_low);
165 iconv_low = iconv_low >> 31;
166 iconv = ((iconv <<1) & 0XFFFF) + iconv_low;
Value stored to 'iconv' is never read
167 // cout << "BCAL:pulser status=" << epics_val->name.substr(0,11) << endl;
168 //printf ("BCAL:pulser status=%d, %0X, iconv_low=%0X\n",iconv,iconv,iconv_low);
169 }
170 else if ((epics_val->name.substr(0,11) == "BCAL:pulser") & isDigit) {
171 //double freq = 1.e8/fconv; // cover to s: period is in units 10 ns
172 //cout << "BCAL:pulser=" << epics_val->name.substr(0,11) << epics_val->fval << " freq=" << freq <<endl;
173 }
174 else if (epics_val->name == "IBCAD00CRCUR6") {
175 h1epics_AD00->Fill(fconv);
176 h1epics_AD00_VSevent->Fill((float)locEventNumber,fconv);
177 h1epics_entries_VSevent->Fill((float)locEventNumber);
178 //cout << "IBCAD00CRCUR6 " << epics_val->name << " fconv=" << fconv << endl;
179 }
180 else if (epics_val->name == "AC:inner:position:x") {
181 xpos_inner = fconv;
182 }
183 else if (epics_val->name == "AC:inner:position:y") {
184 ypos_inner = fconv;
185 }
186 else if (epics_val->name == "AC:outer:position:x") {
187 xpos_outer = fconv;
188 }
189 else if (epics_val->name == "AC:outer:position:y") {
190 ypos_outer = fconv;
191 }
192 }
193 if (xpos_inner> pos_default && ypos_inner > pos_default) {
194 h2epics_pos_inner->Fill(xpos_inner,ypos_inner);
195 }
196 if (xpos_outer> pos_default && ypos_outer > pos_default) {
197 h2epics_pos_outer->Fill(xpos_outer,ypos_outer);
198 }
199
200 japp->RootFillUnLock(this); //RELEASE ROOT FILL LOCK
201
202 return NOERROR;
203}
204
205
206//----------------------------------------------------------------------------------
207
208
209jerror_t JEventProcessor_EPICS_dump::erun(void) {
210 // This is called whenever the run number changes, before it is
211 // changed to give you a chance to clean up before processing
212 // events from the next run number.
213 return NOERROR;
214}
215
216
217//----------------------------------------------------------------------------------
218
219
220jerror_t JEventProcessor_EPICS_dump::fini(void) {
221 // Called before program exit after event processing is finished.
222 return NOERROR;
223}
224
225
226//----------------------------------------------------------------------------------
227//----------------------------------------------------------------------------------