Bug Summary

File:libraries/TRACKING/DTrackCandidate_factory_CDC_or_FDCpseudo.cc
Location:line 66, column 20
Description:Dereference of null pointer

Annotated Source Code

1// $Id$
2//
3// File: DTrackCandidate_factory_CDC_or_FDCpseudo.cc
4// Created: Thu Apr 16 09:14:49 EDT 2009
5// Creator: davidl (on Darwin harriet.jlab.org 9.6.0 i386)
6//
7
8
9#include <iostream>
10#include <iomanip>
11using namespace std;
12
13#include "DTrackCandidate_factory_CDC_or_FDCpseudo.h"
14using namespace jana;
15
16//------------------
17// init
18//------------------
19jerror_t DTrackCandidate_factory_CDC_or_FDCpseudo::init(void)
20{
21 DEBUG_LEVEL = 0;
22
23 gPARMS->SetDefaultParameter("TRKFIND:DEBUG_LEVEL", DEBUG_LEVEL);
24
25 return NOERROR;
26}
27
28//------------------
29// brun
30//------------------
31jerror_t DTrackCandidate_factory_CDC_or_FDCpseudo::brun(jana::JEventLoop *eventLoop, int runnumber)
32{
33
34 return NOERROR;
35}
36
37//------------------
38// evnt
39//------------------
40jerror_t DTrackCandidate_factory_CDC_or_FDCpseudo::evnt(JEventLoop *loop, int eventnumber)
41{
42
43 /// This factory simply combines the list of candidates from the
44 /// DTrackCandidate:CDC and DTrackCandidate:FDCpseudo factories
45 /// into a single lit. It simply copies the pointers and flags
46 /// itself as not being the owner of any of these objects.
47 vector<const DTrackCandidate*> cdc;
48 vector<const DTrackCandidate*> fdc;
49
50 loop->Get(cdc, "CDC");
51 loop->Get(fdc, "FDCpseudo");
52
53 // Add FDC candidates
54 if(DEBUG_LEVEL>2)_DBG_std::cerr<<"DTrackCandidate_factory_CDC_or_FDCpseudo.cc"
<<":"<<54<<" "
<<"Copying "<<fdc.size()<<" FDC generated candidates to final list"<<endl;
1
Taking false branch
55 for(unsigned int i=0; i<fdc.size(); i++)_data.push_back((DTrackCandidate*)fdc[i]);
2
Loop condition is false. Execution continues on line 58
56
57 // Add CDC candidates providing they aren't clones of ones already added
58 if(DEBUG_LEVEL>2)_DBG_std::cerr<<"DTrackCandidate_factory_CDC_or_FDCpseudo.cc"
<<":"<<58<<" "
<<"Checking "<<cdc.size()<<" CDC generated candidates for inclusion in final list ..."<<endl;
3
Taking false branch
59 for(unsigned int i=0; i<cdc.size(); i++){
4
Loop condition is true. Entering loop body
7
Loop condition is true. Entering loop body
10
Loop condition is true. Entering loop body
60 // Look to see that we don't already have a similar candidate in the list
61 DVector3 mom1 = cdc[i]->momentum();
62 DVector3 pos1 = cdc[i]->position();
63 double q1 = cdc[i]->charge();
64 bool is_clone = false;
65 for(unsigned int j=0; j<_data.size(); j++){
5
Loop condition is false. Execution continues on line 83
8
Loop condition is false. Execution continues on line 83
11
Loop condition is true. Entering loop body
66 DVector3 mom2 = _data[j]->momentum();
12
Dereference of null pointer
67 DVector3 pos2 = _data[j]->position();
68 double q2 = _data[j]->charge();
69 double curvature_diff = fabs(1.0/mom1.Mag() - 1.0/mom2.Mag())/((1.0/mom1.Mag() + 1.0/mom2.Mag())/2.0);
70 double relative_mom_diff = fabs(mom1.Mag()-mom2.Mag())/((mom1.Mag()+mom2.Mag())/2.0);
71 if(DEBUG_LEVEL>4)_DBG_std::cerr<<"DTrackCandidate_factory_CDC_or_FDCpseudo.cc"
<<":"<<71<<" "
<<"q1="<<q1<<" q2="<<q2<<" mom1,mom2 angle:"<<mom1.Angle(mom2)*57.3<<" curvature diff:"<<curvature_diff<<" relative_mom_diff:"<<relative_mom_diff<<" pos diff:"<<(pos1-pos2).Mag()<<endl;
72 if(q1!=q2)continue;
73 if(mom1.Angle(mom2)*57.3<5.0){ // Angle within 5 degrees
74 if(curvature_diff<0.15 || relative_mom_diff<0.15){ // curvature or momentum within 15 % (should use Perp, but this avoids division by zero)
75 if((pos1-pos2).Mag()<30.0){ // vertex position within 30cm
76 is_clone = true;
77 if(DEBUG_LEVEL>1)_DBG_std::cerr<<"DTrackCandidate_factory_CDC_or_FDCpseudo.cc"
<<":"<<77<<" "
<<" CDC candidate "<<i<<" is a clone of candidate "<<j<<" dropping."<<endl;
78 break;
79 }
80 }
81 }
82 }
83 if(!is_clone){
6
Taking true branch
9
Taking true branch
84 _data.push_back((DTrackCandidate*)cdc[i]);
85 }
86 }
87
88 SetFactoryFlag(NOT_OBJECT_OWNER); // make sure these aren't deleted twice
89
90 return NOERROR;
91}
92
93//------------------
94// erun
95//------------------
96jerror_t DTrackCandidate_factory_CDC_or_FDCpseudo::erun(void)
97{
98 return NOERROR;
99}
100
101//------------------
102// fini
103//------------------
104jerror_t DTrackCandidate_factory_CDC_or_FDCpseudo::fini(void)
105{
106 return NOERROR;
107}
108