Bug Summary

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