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 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | #include "DTTabUtilities.h" |
9 | |
10 | DTTabUtilities::DTTabUtilities(void) |
11 | { |
12 | dTScale_CAEN = 0.0234375; |
13 | } |
14 | |
15 | double DTTabUtilities::Convert_DigiTimeToNs_F1TDC(const JObject* locTDCDigiHit) const |
16 | { |
17 | |
18 | const DF1TDCHit* locF1TDCHit = dynamic_cast<const DF1TDCHit*>(locTDCDigiHit); |
19 | if(locF1TDCHit != NULL) |
20 | return Convert_DigiTimeToNs_F1TDC(locF1TDCHit); |
21 | |
22 | |
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 | |
32 | return Convert_DigiTimeToNs_F1TDC(locF1TDCHits[0]); |
33 | } |
34 | |
35 | double DTTabUtilities::Convert_DigiTimeToNs_F1TDC(const DF1TDCHit* locF1TDCHit) const |
36 | { |
37 | uint32_t locROCID = locF1TDCHit->rocid; |
38 | |
39 | |
40 | vector<const DF1TDCConfig*> locF1TDCConfigs; |
41 | locF1TDCHit->Get(locF1TDCConfigs); |
42 | |
43 | |
44 | map<uint32_t, const DCODAROCInfo*>::const_iterator locROCInfoIterator = dCODAROCInfoMap.find(locROCID); |
45 | const DCODAROCInfo* locCODAROCInfo = (locROCInfoIterator != dCODAROCInfoMap.end()) ? locROCInfoIterator->second : NULL; |
46 | |
47 | if(locCODAROCInfo == NULL) |
48 | return Convert_DigiTimeToNs_F1TDC_TriggerReferenceSignal(locF1TDCHit); |
49 | |
50 | if(locF1TDCConfigs.empty() || dHasBadOrNoF1TDCConfigInfoFlag) |
51 | return Convert_DigiTimeToNs_F1TDC_GlobalSystemClock_CCDB(locF1TDCHit, locCODAROCInfo); |
52 | |
53 | |
54 | return Convert_DigiTimeToNs_F1TDC_GlobalSystemClock_ConfigInfo(locF1TDCHit, locCODAROCInfo, locF1TDCConfigs[0]); |
55 | } |
56 | |
57 | double DTTabUtilities::Convert_DigiTimeToNs_F1TDC_GlobalSystemClock_ConfigInfo(const DF1TDCHit* locF1TDCHit, const DCODAROCInfo* locCODAROCInfo, const DF1TDCConfig* locF1TDCConfig) const |
58 | { |
59 | |
60 | |
61 | |
62 | |
63 | |
64 | bool locIsHighResolutionReadout = (locF1TDCHit->modtype != DModuleType::F1TDC48); |
65 | |
66 | |
67 | |
68 | double locTDCToNsScaleFactor = (32.0/152.0) * double(locF1TDCConfig->REFCLKDIV) / (double(locF1TDCConfig->HSDIV)); |
69 | |
70 | if(locIsHighResolutionReadout) |
71 | locTDCToNsScaleFactor /= 2.0; |
72 | |
73 | |
74 | uint64_t locRolloverTimeWindowLength = (uint64_t(32))*(uint64_t(locF1TDCConfig->REFCNT + 2)); |
75 | |
76 | |
77 | uint64_t locReferenceTimeThisWindow = Calc_ROCRefTimeThisWindow(locCODAROCInfo, locRolloverTimeWindowLength); |
78 | |
79 | |
80 | double locDeltaT = locTDCToNsScaleFactor*double(locF1TDCHit->time) - double(locReferenceTimeThisWindow); |
81 | if(locDeltaT < 0.0) |
82 | locDeltaT += double(locRolloverTimeWindowLength); |
83 | |
84 | return locDeltaT; |
85 | } |
86 | |
87 | double DTTabUtilities::Convert_DigiTimeToNs_F1TDC_GlobalSystemClock_CCDB(const DF1TDCHit* locF1TDCHit, const DCODAROCInfo* locCODAROCInfo) const |
88 | { |
89 | |
90 | |
91 | |
92 | |
93 | |
94 | bool locIsLowResolutionReadout = (locF1TDCHit->modtype == DModuleType::F1TDC48); |
95 | |
96 | |
97 | double locTDCToNsScaleFactor = Calc_TDCToNsScaleFactor_CCDB(locIsLowResolutionReadout); |
98 | |
99 | |
100 | uint64_t locReferenceTimeThisWindow = Calc_ROCRefTimeThisWindow(locCODAROCInfo, dRolloverTimeWindowLength); |
101 | |
102 | |
103 | double locDeltaT = locTDCToNsScaleFactor*double(locF1TDCHit->time) - double(locReferenceTimeThisWindow); |
104 | if(locDeltaT < 0.0) |
105 | locDeltaT += double(dRolloverTimeWindowLength); |
106 | |
107 | return locDeltaT; |
108 | } |
109 | |
110 | double DTTabUtilities::Convert_DigiTimeToNs_F1TDC_TriggerReferenceSignal(const DF1TDCHit* locF1TDCHit) const |
111 | { |
112 | |
113 | |
114 | |
115 | |
116 | |
117 | bool locIsLowResolutionReadout = (locF1TDCHit->modtype == DModuleType::F1TDC48); |
118 | |
119 | |
120 | double locTDCToNsScaleFactor = Calc_TDCToNsScaleFactor_CCDB(locIsLowResolutionReadout); |
121 | |
122 | |
123 | double locDeltaT = locTDCToNsScaleFactor*double(locF1TDCHit->time) - Convert_TriggerReferenceSignal(); |
124 | |
125 | |
126 | if(locDeltaT < 0) |
127 | locDeltaT += double(dRolloverTimeWindowLength); |
128 | |
129 | return locDeltaT; |
130 | } |
131 | |
132 | double DTTabUtilities::Calc_TDCToNsScaleFactor_CCDB(bool locIsLowResolutionReadout) const |
133 | { |
134 | double locTDCToNsScaleFactor = double(dRolloverTimeWindowLength)/double(dNumTDCTicksInRolloverTimeWindow); |
135 | if(locIsLowResolutionReadout) |
136 | locTDCToNsScaleFactor *= 2.0; |
137 | return locTDCToNsScaleFactor; |
138 | } |
139 | |
140 | uint64_t DTTabUtilities::Calc_ROCRefTimeThisWindow(const DCODAROCInfo* locCODAROCInfo, uint64_t locRolloverTimeWindowLength) const |
141 | { |
142 | |
143 | |
144 | uint64_t locReferenceClockTime = (uint64_t(4))*locCODAROCInfo->timestamp; |
145 | uint64_t locNumRollovers = locReferenceClockTime/locRolloverTimeWindowLength; |
146 | return (locReferenceClockTime - locNumRollovers*locRolloverTimeWindowLength); |
147 | } |
148 | |
149 | double DTTabUtilities::Convert_TriggerReferenceSignal(void) const |
150 | { |
151 | double locTDCToNsScaleFactor = Calc_TDCToNsScaleFactor_CCDB(dTriggerReferenceSignalIsLowResTDC); |
152 | return locTDCToNsScaleFactor * double(dTriggerReferenceSignal); |
153 | } |
154 | |
155 | double DTTabUtilities::Convert_DigiTimeToNs_CAEN1290TDC(const JObject* locTDCDigiHit) const |
156 | { |
157 | |
158 | const DCAEN1290TDCHit* locCAEN1290TDCHit = dynamic_cast<const DCAEN1290TDCHit*>(locTDCDigiHit); |
159 | if(locCAEN1290TDCHit != NULL) |
| 1 | Assuming 'locCAEN1290TDCHit' is equal to NULL | |
|
| |
160 | return Convert_DigiTimeToNs_CAEN1290TDC(locCAEN1290TDCHit); |
161 | |
162 | |
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 | |
172 | return Convert_DigiTimeToNs_CAEN1290TDC(locCAEN1290TDCHits[0]); |
173 | } |
174 | |
175 | double DTTabUtilities::Convert_DigiTimeToNs_CAEN1290TDC(const DCAEN1290TDCHit* locCAEN1290TDCHit) const |
176 | { |
177 | |
178 | |
179 | uint32_t locROCID = locCAEN1290TDCHit->rocid; |
180 | |
181 | |
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 | |
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 | |
197 | bool DTTabUtilities::CheckFADC250_PedestalOK(uint32_t QF) const |
198 | { |
199 | |
200 | return !( (QF>>6) & 0x01 ); |
201 | } |
202 | |
203 | bool DTTabUtilities::CheckFADC250_NoErrors(uint32_t QF) const |
204 | { |
205 | |
206 | |
207 | |
208 | |
209 | if ( (QF>>1) & 0x03 ) return false; |
210 | |
211 | if ( (QF>>4) & 0x02 ) return false; |
212 | |
213 | |
214 | |
215 | |
216 | |
217 | |
218 | |
219 | |
220 | return true; |
221 | } |