Bug Summary

File:/home/sdobbs/work/clang/halld_recon/src/libraries/TTAB/DTTabUtilities.cc
Warning:line 164, column 2
Called C++ object pointer is null

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -main-file-name DTTabUtilities.cc -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=none -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /w/halld-scifs17exp/home/sdobbs/clang/llvm-project/install/lib/clang/12.0.0 -D HAVE_CCDB -D HAVE_RCDB -D HAVE_EVIO -D HAVE_TMVA=1 -D RCDB_MYSQL=1 -D RCDB_SQLITE=1 -D SQLITE_USE_LEGACY_STRUCT=ON -I .Linux_CentOS7.7-x86_64-gcc4.8.5/libraries/TTAB -I libraries/TTAB -I . -I libraries -I libraries/include -I /w/halld-scifs17exp/home/sdobbs/clang/halld_recon/Linux_CentOS7.7-x86_64-gcc4.8.5/include -I external/xstream/include -I /usr/include/tirpc -I /group/halld/Software/builds/Linux_CentOS7.7-x86_64-gcc4.8.5/root/root-6.08.06/include -I /w/halld-scifs17exp/halld2/home/sdobbs/Software/jana/jana_0.8.2/Linux_CentOS7.7-x86_64-gcc4.8.5/include -I /group/halld/Software/builds/Linux_CentOS7.7-x86_64-gcc4.8.5/ccdb/ccdb_1.06.06/include -I /group/halld/Software/builds/Linux_CentOS7.7-x86_64-gcc4.8.5/rcdb/rcdb_0.06.00/cpp/include -I /usr/include/mysql -I /group/halld/Software/builds/Linux_CentOS7.7-x86_64-gcc4.8.5/sqlitecpp/SQLiteCpp-2.2.0^bs130/include -I /group/halld/Software/builds/Linux_CentOS7.7-x86_64-gcc4.8.5/sqlite/sqlite-3.13.0^bs130/include -I /group/halld/Software/builds/Linux_CentOS7.7-x86_64-gcc4.8.5/hdds/hdds-4.9.0/Linux_CentOS7.7-x86_64-gcc4.8.5/src -I /group/halld/Software/builds/Linux_CentOS7.7-x86_64-gcc4.8.5/xerces-c/xerces-c-3.1.4/include -I /group/halld/Software/builds/Linux_CentOS7.7-x86_64-gcc4.8.5/evio/evio-4.4.6/Linux-x86_64/include -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5 -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/x86_64-redhat-linux -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/backward -internal-isystem /usr/local/include -internal-isystem /w/halld-scifs17exp/home/sdobbs/clang/llvm-project/install/lib/clang/12.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /home/sdobbs/work/clang/halld_recon/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -o /tmp/scan-build-2021-01-21-110224-160369-1 -x c++ libraries/TTAB/DTTabUtilities.cc
1// $Id$
2//
3// File: DTTabUtilities.cc
4// Created: Fri Apr 3 09:41:29 EDT 2015
5// Creator: pmatt (on Linux pmattdesktop.jlab.org 2.6.32-504.12.2.el6.x86_64 x86_64)
6//
7
8#include "DTTabUtilities.h"
9
10DTTabUtilities::DTTabUtilities(void)
11{
12 dTScale_CAEN = 0.0234375; // ~ 23.4375 ps/count (TOF) +/- 0.0012
13}
14
15double DTTabUtilities::Convert_DigiTimeToNs_F1TDC(const JObject* locTDCDigiHit) const
16{
17 //See if the input object is an DF1TDCHit. If so, convert it
18 const DF1TDCHit* locF1TDCHit = dynamic_cast<const DF1TDCHit*>(locTDCDigiHit);
19 if(locF1TDCHit != NULL__null) //it's an F1TDCHit
20 return Convert_DigiTimeToNs_F1TDC(locF1TDCHit);
21
22 //Get the DF1TDCHit associated object
23 vector<const DF1TDCHit*> locF1TDCHits;
24 locTDCDigiHit->Get(locF1TDCHits);
25 if(locF1TDCHits.empty())
26 {
27 cout << "ERROR: INCORRECT INPUT OBJECT TO DTTabUtilities::Convert_DigiTimeToNs_F1TDC(). RETURNING NaN." << endl;
28 return std::numeric_limits<double>::quiet_NaN();
29 }
30
31 //Convert
32 return Convert_DigiTimeToNs_F1TDC(locF1TDCHits[0]);
33}
34
35double DTTabUtilities::Convert_DigiTimeToNs_F1TDC(const DF1TDCHit* locF1TDCHit) const
36{
37 uint32_t locROCID = locF1TDCHit->rocid;
38
39 // Get DF1TDCConfig for this ROC
40 vector<const DF1TDCConfig*> locF1TDCConfigs;
41 locF1TDCHit->Get(locF1TDCConfigs);
42
43 // Get DCODAROCInfo for this ROC
44 map<uint32_t, const DCODAROCInfo*>::const_iterator locROCInfoIterator = dCODAROCInfoMap.find(locROCID);
45 const DCODAROCInfo* locCODAROCInfo = (locROCInfoIterator != dCODAROCInfoMap.end()) ? locROCInfoIterator->second : NULL__null;
46
47 if(locCODAROCInfo == NULL__null) //e.g. MC
48 return Convert_DigiTimeToNs_F1TDC_TriggerReferenceSignal(locF1TDCHit);
49
50 if(locF1TDCConfigs.empty() || dHasBadOrNoF1TDCConfigInfoFlag) //e.g. Early Fall 2014 Commissioning Data (use CCDB constants)
51 return Convert_DigiTimeToNs_F1TDC_GlobalSystemClock_CCDB(locF1TDCHit, locCODAROCInfo);
52
53 // Have all objects needed, call the main function
54 return Convert_DigiTimeToNs_F1TDC_GlobalSystemClock_ConfigInfo(locF1TDCHit, locCODAROCInfo, locF1TDCConfigs[0]);
55}
56
57double DTTabUtilities::Convert_DigiTimeToNs_F1TDC_GlobalSystemClock_ConfigInfo(const DF1TDCHit* locF1TDCHit, const DCODAROCInfo* locCODAROCInfo, const DF1TDCConfig* locF1TDCConfig) const
58{
59 //compare the digi time to the global system clock available on the crate, then convert to ns
60 //GlueX Doc 2686 Appendix A, using the global system clock
61
62 //GlueX DOC 747
63 //48-channel-readout = F1TDCV3 (FDC) = low-resolution readout (115 ps vs 57 ps) //fewer (factor 2) TDC-ticks per ns
64 bool locIsHighResolutionReadout = (locF1TDCHit->modtype != DModuleType::F1TDC48);
65
66 //Calculate TDC -> ns Scale Factor
67 //32.0 is TREF and should be extracted from the data-stream but it's not available
68 double locTDCToNsScaleFactor = (32.0/152.0) * double(locF1TDCConfig->REFCLKDIV) / (double(locF1TDCConfig->HSDIV)); // 32 ns / #-tdc-ticks-in-32ns
69 //(32.0/152.0) * double(128) / (232)
70 if(locIsHighResolutionReadout) //should use HIGHRES bit from the data-stream, but it's not available
71 locTDCToNsScaleFactor /= 2.0; //more TDC-ticks per ns
72
73 //Calculate rollover window size for the F1TDCs
74 uint64_t locRolloverTimeWindowLength = (uint64_t(32))*(uint64_t(locF1TDCConfig->REFCNT + 2));
75
76 // Transition the reference time into this F1TDC time window (get remainder)
77 uint64_t locReferenceTimeThisWindow = Calc_ROCRefTimeThisWindow(locCODAROCInfo, locRolloverTimeWindowLength);
78
79 //compute and return the time difference
80 double locDeltaT = locTDCToNsScaleFactor*double(locF1TDCHit->time) - double(locReferenceTimeThisWindow); // in ns
81 if(locDeltaT < 0.0) // Take care of rollover
82 locDeltaT += double(locRolloverTimeWindowLength); //the time rolled over between the hit and reference times
83
84 return locDeltaT;
85}
86
87double DTTabUtilities::Convert_DigiTimeToNs_F1TDC_GlobalSystemClock_CCDB(const DF1TDCHit* locF1TDCHit, const DCODAROCInfo* locCODAROCInfo) const
88{
89 //compare the digi time to the global system clock available on the crate, then convert to ns
90 //GlueX Doc 2686 Appendix A, using the global system clock, but the CCDB for the constants
91
92 //GlueX DOC 747
93 //48-channel-readout = F1TDCV3 (FDC) = low-resolution readout (115 ps vs 57 ps) //fewer (factor 2) TDC-ticks per ns
94 bool locIsLowResolutionReadout = (locF1TDCHit->modtype == DModuleType::F1TDC48);
95
96 //Calculate TDC -> ns Scale Factor
97 double locTDCToNsScaleFactor = Calc_TDCToNsScaleFactor_CCDB(locIsLowResolutionReadout);
98
99 // Transition the reference time into this F1TDC time window (get remainder)
100 uint64_t locReferenceTimeThisWindow = Calc_ROCRefTimeThisWindow(locCODAROCInfo, dRolloverTimeWindowLength);
101
102 //compute and return the time difference
103 double locDeltaT = locTDCToNsScaleFactor*double(locF1TDCHit->time) - double(locReferenceTimeThisWindow); // in ns
104 if(locDeltaT < 0.0) // Take care of rollover
105 locDeltaT += double(dRolloverTimeWindowLength); //the time rolled over between the hit and reference times
106
107 return locDeltaT;
108}
109
110double DTTabUtilities::Convert_DigiTimeToNs_F1TDC_TriggerReferenceSignal(const DF1TDCHit* locF1TDCHit) const
111{
112 //compare the digi time to the trigger reference signal, then convert to ns
113 //GlueX Doc 2686 Appendix A, using the trigger reference signal
114
115 //GlueX DOC 747
116 //48-channel-readout = F1TDCV3 (FDC) = low-resolution readout (115 ps vs 57 ps) //fewer (factor 2) TDC-ticks per ns
117 bool locIsLowResolutionReadout = (locF1TDCHit->modtype == DModuleType::F1TDC48);
118
119 //Calculate TDC -> ns Scale Factor
120 double locTDCToNsScaleFactor = Calc_TDCToNsScaleFactor_CCDB(locIsLowResolutionReadout);
121
122 //Calc delta-t //potentially different scale factors between trigger reference & hit
123 double locDeltaT = locTDCToNsScaleFactor*double(locF1TDCHit->time) - Convert_TriggerReferenceSignal();
124
125 // Take care of rollover
126 if(locDeltaT < 0)
127 locDeltaT += double(dRolloverTimeWindowLength);
128
129 return locDeltaT;
130}
131
132double DTTabUtilities::Calc_TDCToNsScaleFactor_CCDB(bool locIsLowResolutionReadout) const
133{
134 double locTDCToNsScaleFactor = double(dRolloverTimeWindowLength)/double(dNumTDCTicksInRolloverTimeWindow);
135 if(locIsLowResolutionReadout)
136 locTDCToNsScaleFactor *= 2.0; //fewer TDC-ticks per ns
137 return locTDCToNsScaleFactor;
138}
139
140uint64_t DTTabUtilities::Calc_ROCRefTimeThisWindow(const DCODAROCInfo* locCODAROCInfo, uint64_t locRolloverTimeWindowLength) const
141{
142 // Transition the reference time into this F1TDC time window (get remainder)
143 // DCODAROCInfo::timestamp is the number of clock ticks of the global system clock since it was reset (at the beginning of the run)
144 uint64_t locReferenceClockTime = (uint64_t(4))*locCODAROCInfo->timestamp; // one clock tick = 4 ns
145 uint64_t locNumRollovers = locReferenceClockTime/locRolloverTimeWindowLength;
146 return (locReferenceClockTime - locNumRollovers*locRolloverTimeWindowLength);
147}
148
149double DTTabUtilities::Convert_TriggerReferenceSignal(void) const
150{
151 double locTDCToNsScaleFactor = Calc_TDCToNsScaleFactor_CCDB(dTriggerReferenceSignalIsLowResTDC);
152 return locTDCToNsScaleFactor * double(dTriggerReferenceSignal);
153}
154
155double DTTabUtilities::Convert_DigiTimeToNs_CAEN1290TDC(const JObject* locTDCDigiHit) const
156{
157 //See if the input object is an DCAEN1290TDCHit. If so, convert it
158 const DCAEN1290TDCHit* locCAEN1290TDCHit = dynamic_cast<const DCAEN1290TDCHit*>(locTDCDigiHit);
159 if(locCAEN1290TDCHit != NULL__null) //it's an DCAEN1290TDCHit
1
Assuming 'locCAEN1290TDCHit' is equal to NULL
2
Taking false branch
160 return Convert_DigiTimeToNs_CAEN1290TDC(locCAEN1290TDCHit);
161
162 //Get the DF1TDCHit associated object
163 vector<const DCAEN1290TDCHit*> locCAEN1290TDCHits;
164 locTDCDigiHit->Get(locCAEN1290TDCHits);
3
Called C++ object pointer is null
165 if(locCAEN1290TDCHits.empty())
166 {
167 cout << "ERROR: INCORRECT INPUT OBJECT TO DTTabUtilities::Convert_DigiTimeToNs_CAEN1290TDC(). RETURNING NaN." << endl;
168 return std::numeric_limits<double>::quiet_NaN();
169 }
170
171 //Convert
172 return Convert_DigiTimeToNs_CAEN1290TDC(locCAEN1290TDCHits[0]);
173}
174
175double DTTabUtilities::Convert_DigiTimeToNs_CAEN1290TDC(const DCAEN1290TDCHit* locCAEN1290TDCHit) const
176{
177 //compare the digi time to the trigger reference signal, then convert to ns
178 //GlueX Doc 2686
179 uint32_t locROCID = locCAEN1290TDCHit->rocid;
180
181 // Get DCODAROCInfo for this ROC
182 map<uint32_t, const DCODAROCInfo*>::const_iterator locROCInfoIterator = dCODAROCInfoMap.find(locROCID);
183 if(locROCInfoIterator == dCODAROCInfoMap.end())
184 return std::numeric_limits<double>::quiet_NaN();
185 const DCODAROCInfo* locCODAROCInfo = locROCInfoIterator->second;
186
187 int locSystemClockBinRemainder = locCODAROCInfo->timestamp % (uint64_t(6));
188
189 // The number of TI-counter (4 ns) blocks to shift the CAEN time to line-up with the TI time
190 int locNum4NsBlocksToShift = dCAENTIPhaseDifference - locSystemClockBinRemainder;
191 if(locNum4NsBlocksToShift <= 0)
192 locNum4NsBlocksToShift += 6;
193
194 return dTScale_CAEN*double(locCAEN1290TDCHit->time) + 4.0*double(locNum4NsBlocksToShift);
195}
196
197bool DTTabUtilities::CheckFADC250_PedestalOK(uint32_t QF) const
198{
199 // only check to see if the "bad pedestal" flag is set
200 return !( (QF>>6) & 0x01 );
201}
202
203bool DTTabUtilities::CheckFADC250_NoErrors(uint32_t QF) const
204{
205 // only return true if there are no flagged errors from the flash algorithm
206 // this is probably stricter than we want...
207
208 // check for integration errors
209 if ( (QF>>1) & 0x03 ) return false;
210 // check for timing errors
211 if ( (QF>>4) & 0x02 ) return false;
212
213 // add other options for future convenience...
214 // if( (QF>>1) & 0x01 ) return false; // NSA beyond readout window
215 // if( (QF>>2) & 0x01 ) return false; // one or more samples were overflow
216 // if( (QF>>3) & 0x01 ) return false; // one or more samples were underflow
217 // if( (QF>>4) & 0x01 ) return false; // timing peak beyond NSA
218 // if( (QF>>5) & 0x01 ) return false; // timing peak not found
219
220 return true;
221}