Bug Summary

File:plugins/monitoring/ST_online_tracking/JEventProcessor_ST_online_tracking.cc
Location:line 226, column 26
Description:Value stored to 'phi_mom' is never read

Annotated Source Code

1// $Id$
2//
3// File: JEventProcessor_ST_online_tracking.cc
4// Created: Fri Jun 19 13:22:21 EDT 2015
5// Creator: mkamel (on Linux ifarm1401 2.6.32-431.el6.x86_64 x86_64)
6//
7// $Id$
8#include "JEventProcessor_ST_online_tracking.h"
9using namespace jana;
10using namespace std;
11// Routine used to create our JEventProcessor
12#include <JANA/JApplication.h>
13#include <JANA/JFactory.h>
14// ROOT header files
15#include <TDirectory.h>
16#include <TH1.h>
17#include <TH2.h>
18// ST header files
19#include "START_COUNTER/DSCHit.h"
20#include "START_COUNTER/DSCDigiHit.h"
21// C++ header files
22#include <stdint.h>
23#include <vector>
24#include <stdio.h>
25// Include some JANA libraries
26// PID libraries
27#include "PID/DDetectorMatches.h"
28#include "PID/DParticleID.h"
29#include "PID/DChargedTrack.h"
30// Tracking libraries
31#include "TRACKING/DTrackTimeBased.h"
32
33// Define some constants
34const double RAD2DEG = 57.29577951; // Convert radians to degrees
35const uint32_t NCHANNELS = 30; // number of scintillator paddles
36
37// Declare 2D tracking histos
38static TH2I *h2_r_vs_z;
39static TH2I *h2_y_vs_x;
40static TH2I *h2_phi_vs_sector;
41static TH2I *h2_dphi_sector;
42
43static TH2I *h2_dedx_P_mag;
44static TH2I *h2_dedx_P_mag_postv;
45static TH2I *h2_dedx_P_mag_negtv;
46
47extern "C"{
48void InitPlugin(JApplication *app){
49 InitJANAPlugin(app);
50 app->AddProcessor(new JEventProcessor_ST_online_tracking());
51}
52} // "C"
53
54
55//------------------
56// JEventProcessor_ST_online_tracking (Constructor)
57//------------------
58JEventProcessor_ST_online_tracking::JEventProcessor_ST_online_tracking()
59{
60
61}
62
63//------------------
64// ~JEventProcessor_ST_online_tracking (Destructor)
65//------------------
66JEventProcessor_ST_online_tracking::~JEventProcessor_ST_online_tracking()
67{
68
69}
70
71//------------------
72// init
73//------------------
74jerror_t JEventProcessor_ST_online_tracking::init(void)
75{
76 // This is called once at program startup. If you are creating
77 // and filling historgrams in this plugin, you should lock the
78 // ROOT mutex like this:
79 //
80 // japp->RootWriteLock();
81 // ... fill historgrams or trees ...
82 // japp->RootUnLock();
83 //
84 japp->RootWriteLock(); //ACQUIRE ROOT LOCK!!
85 // Create root folder for ST and cd to it, store main dir
86 TDirectory *main = gDirectory(TDirectory::CurrentDirectory());
87 gDirectory(TDirectory::CurrentDirectory())->mkdir("st_tracking")->cd();
88 // Book some 2D histos
89 h2_r_vs_z = new TH2I("r_vs_z", "Charged Track & ST Intersection; Z (cm); R (cm)", 280, 30, 100, 500, 0, 10);
90 h2_y_vs_x = new TH2I("y_vs_x", "Charged Track & ST Intersection; X (cm); Y (cm)", 2000, -20, 20, 1000, -10, 10);
91
92 h2_phi_vs_sector = new TH2I("phi_vs_sector", "Charged Track & ST Intersection; Sector Number; #phi (deg)", NCHANNELS, 0.5, NCHANNELS + 0.5, 360, 0, 360);
93 h2_dphi_sector = new TH2I("h2_dphi_sector", "#delta #phi vs Sector; Sector Number; #delta #phi (deg)", NCHANNELS, 0.5, NCHANNELS + 0.5, 600, -15, 15);
94 h2_dedx_P_mag = new TH2I("h2_dedx_P_mag", "#frac{dE}{dx} vs Momentum; Momentum (Gev/c); dEdx (au)", 1000, 0, 2, 150, 0, .015);
95 h2_dedx_P_mag_postv= new TH2I("h2_dedx_P_mag_postv", "#frac{dE}{dx} vs Momentum (q > 0); Momentum (Gev/c); #frac{dE}{dx} (au)", 1000, 0, 2, 150, 0, .015);
96 h2_dedx_P_mag_negtv= new TH2I("h2_dedx_P_mag_negtv", "#frac{dE}{dx} vs Momentum (q < 0); Momentum (Gev/c); #frac{dE}{dx} (au)", 1000, 0, 2, 150, 0, .015);
97
98 // cd back to main directory
99 gDirectory(TDirectory::CurrentDirectory())->cd("../");
100 main->cd();
101 japp->RootUnLock(); //RELEASE ROOT LOCK!!
102
103 // for (uint32_t i = 0; i < NCHANNELS; i++)
104 // {
105 // phi_sec[i][0] = (6.0 + 12.0*double(i)) - 4.0;
106 // phi_sec[i][1] = (6.0 + 12.0*double(i)) + 4.0;
107 // }
108 return NOERROR;
109}
110//------------------
111// brun
112//------------------
113jerror_t JEventProcessor_ST_online_tracking::brun(JEventLoop *eventLoop, int32_t runnumber)
114{
115 // This is called whenever the run number changes
116 // Get the particleID object for each run
117 vector<const DParticleID *> dParticleID_algos;
118 eventLoop->Get(dParticleID_algos);
119 if(dParticleID_algos.size() < 1)
120 {
121 _DBG_std::cerr<<"plugins/monitoring/ST_online_tracking/JEventProcessor_ST_online_tracking.cc"
<<":"<<121<<" "
<<"Unable to get a DParticleID object! NO PID will be done!"<<endl;
122 return RESOURCE_UNAVAILABLE;
123 }
124 dParticleID = dParticleID_algos[0];
125 return NOERROR;
126}
127
128//------------------
129// evnt
130//------------------
131jerror_t JEventProcessor_ST_online_tracking::evnt(JEventLoop *eventLoop, uint64_t eventnumber)
132{
133 // This is called for every event. Use of common resources like writing
134 // to a file or filling a histogram should be mutex protected. Using
135 // loop->Get(...) to get reconstructed objects (and thereby activating the
136 // reconstruction algorithm) should be done outside of any mutex lock
137 // since multiple threads may call this method at the same time.
138 // Here's an example:
139 //
140 // vector<const MyDataClass*> mydataclasses;
141 // loop->Get(mydataclasses);
142 //
143 // japp->RootWriteLock();
144 // ... fill historgrams or trees ...
145 // japp->RootUnLock();
146 vector<const DSCDigiHit*> st_adc_digi_hits;
147 vector<const DParticleID*> pid_algorithm;
148 vector<const DSCHit*> st_hits;
149 eventLoop->Get(st_adc_digi_hits);
150 eventLoop->Get(pid_algorithm);
151 eventLoop->Get(st_hits);
152 vector<DVector3> sc_track_position;
153 vector<const DChargedTrack*> chargedTrackVector;
154 eventLoop->Get(chargedTrackVector);
155 // Grab the associated detector matches object
156 const DDetectorMatches* locDetectorMatches = NULL__null;
157 eventLoop->GetSingle(locDetectorMatches);
158 // Lock ROOT mutex so other threads won't interfere
159 japp->RootWriteLock();
160
161 sc_track_position.clear();
162
163// Loop over charged tracks
164 for (uint32_t i = 0; i < chargedTrackVector.size(); i++)
165 {
166 // Grab the charged track
167 const DChargedTrack *thisChargedTrack = chargedTrackVector[i];
168
169 // Declare the time based track object
170 const DTrackTimeBased *timeBasedTrack;
171
172 // Grab associated time based track object by selecting charged track with best FOM
173 thisChargedTrack->Get_BestTrackingFOM()->GetSingle(timeBasedTrack);
174 // Implement quality cuts for the time based tracks
175 float trackingFOMCut = 0.0027; // 3 sigma cut
176 if(timeBasedTrack->FOM < trackingFOMCut) continue;
177 // Get the charge of the track and cut on charged tracks
178 int q = timeBasedTrack->charge();
179 // Grab the ST hit match params object and cut on only tracks matched to the ST
180 DSCHitMatchParams locSCHitMatchParams;
181 bool foundSC = dParticleID->Get_BestSCMatchParams(timeBasedTrack, locDetectorMatches, locSCHitMatchParams);
182 if (!foundSC) continue;
183 // Define vertex vector
184 DVector3 vertex;
185 // Vertex info
186 vertex = timeBasedTrack->position();
187 // Cartesian Coordinates
188 double z_v = vertex.z();
189 double r_v = vertex.Perp();
190 // Liquid hydrogen target cuts
191 // Target length 30 cm, centered at z = 65.0 cm
192 // Upstream Diameter of target cell = 2.42 cm
193 // ID of scattering chamber = 7.49 cm
194 bool z_vertex_cut = 50.0 <= z_v && z_v <= 80.0;
195 bool r_vertex_cut = r_v < 0.5;
196 // applied vertex cut
197 if (!z_vertex_cut) continue;
198 if (!r_vertex_cut) continue;
199 // Declare a vector which quantizes the point of the intersection of a charged particle
200 // with a plane in the middle of the scintillator
201 DVector3 IntersectionPoint;
202 // Declare a vector which quantizes the unit vector of the charged particle track traversing
203 // through the scintillator with its origin at the intersection point
204 DVector3 IntersectionDir;
205 // Grab the paramteres associated to a track matched to the ST
206 vector<DSCHitMatchParams> st_params;
207 bool st_match = locDetectorMatches->Get_SCMatchParams(timeBasedTrack, st_params);
208 // If st_match = true, there is a match between this track and the ST
209 if (!st_match) continue;
210
211 bool st_match_pid = dParticleID->MatchToSC(timeBasedTrack,
212 timeBasedTrack->rt,
213 st_params[0].dSCHit,
214 st_params[0].dSCHit->t,
215 locSCHitMatchParams,
216 true,
217 &IntersectionPoint, &IntersectionDir);
218 if(!st_match_pid) continue;
219
220 DVector3 momentum_vec;
221 momentum_vec = timeBasedTrack->momentum();
222 // applied vertex cut
223 DLorentzVector Lor_Mom = timeBasedTrack->lorentzMomentum();
224 double P_mag = Lor_Mom.P();
225 double phi_mom = momentum_vec.Phi()*RAD2DEG;
226 if (phi_mom < 0.0) phi_mom += 360.0;
Value stored to 'phi_mom' is never read
227
228 if (st_match_pid) // Get the intersection point which can not be obtained from st_match
229 {
230 // Grab the sector
231 Int_t sector_m = st_params[0].dSCHit->sector;
232 //Acquire the energy loss per unit length in the ST (arbitrary units)
233 double dEdx = st_params[0].dEdx;
234 double dphi = st_params[0].dDeltaPhiToHit*RAD2DEG;
235 // Fill dEdx vs Momentum
236 h2_dedx_P_mag->Fill(P_mag,dEdx);
237 // Fill dEdx vs Momentum with cut on positive charges
238 if (q > 0)
239 {
240 h2_dedx_P_mag_postv->Fill(P_mag,dEdx);
241 }
242 // Fill dEdx vs Momentum with cut on negative charges
243 if (q < 0)
244 {
245 h2_dedx_P_mag_negtv->Fill(P_mag,dEdx);
246 }
247 // Obtain the intersection point with the ST
248 double phi_ip = IntersectionPoint.Phi()*RAD2DEG;
249 // Correct phi calculation
250 if (phi_ip < 0.0) phi_ip += 360.0;
251 // Acquire the intersection point
252 sc_track_position.push_back(IntersectionPoint);
253 //Fill 2D histos
254 h2_phi_vs_sector->Fill(sector_m,phi_ip);
255 h2_dphi_sector->Fill(sector_m,dphi);
256 } // PID match cut
257 } // Charged track loop
258 // Fill 2D histo
259 for (uint32_t i = 0; i < sc_track_position.size(); i++)
260 {
261 h2_r_vs_z->Fill(sc_track_position[i].z(),sc_track_position[i].Perp());
262 h2_y_vs_x->Fill(sc_track_position[i].x(),sc_track_position[i].y());
263 }
264 japp->RootUnLock();
265 return NOERROR;
266}
267
268//------------------
269// erun
270//------------------
271jerror_t JEventProcessor_ST_online_tracking::erun(void)
272{
273 // This is called whenever the run number changes, before it is
274 // changed to give you a chance to clean up before processing
275 // events from the next run number.
276 return NOERROR;
277}
278
279//------------------
280// fini
281//------------------
282jerror_t JEventProcessor_ST_online_tracking::fini(void)
283{
284 // Called before program exit after event processing is finished.
285 return NOERROR;
286}
287
288
289
290
291