clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -main-file-name DHistogramActions_Thrown.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/ANALYSIS -I libraries/ANALYSIS -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/ANALYSIS/DHistogramActions_Thrown.cc
1 | #include "ANALYSIS/DHistogramActions.h" |
2 | |
3 | |
4 | void DHistogramAction_ParticleComboGenReconComparison::Initialize(JEventLoop* locEventLoop) |
5 | { |
6 | if(Get_UseKinFitResultsFlag() && (Get_Reaction()->Get_KinFitType() == d_NoFit)) |
7 | { |
8 | cout << "WARNING: REQUESTED HISTOGRAM OF KINEMAITIC FIT RESULTS WHEN NO KINEMATIC FIT!!!" << endl; |
9 | return; |
10 | } |
11 | |
12 | Run_Update(locEventLoop); |
13 | |
14 | vector<const DParticleID*> locParticleIDs; |
15 | locEventLoop->Get(locParticleIDs); |
16 | |
17 | string locHistName, locHistTitle, locStepName, locStepROOTName, locParticleName, locParticleROOTName; |
18 | Particle_t locPID; |
19 | |
20 | size_t locNumSteps = Get_Reaction()->Get_NumReactionSteps(); |
21 | |
22 | dHistDeque_DeltaPOverP.resize(locNumSteps); |
23 | dHistDeque_DeltaTheta.resize(locNumSteps); |
24 | dHistDeque_DeltaPhi.resize(locNumSteps); |
25 | dHistDeque_DeltaT.resize(locNumSteps); |
26 | dHistDeque_DeltaT_TOF.resize(locNumSteps); |
27 | dHistDeque_DeltaT_BCAL.resize(locNumSteps); |
28 | dHistDeque_DeltaT_FCAL.resize(locNumSteps); |
29 | dHistDeque_DeltaVertexZ.resize(locNumSteps); |
30 | dHistDeque_DeltaPOverPVsP.resize(locNumSteps); |
31 | dHistDeque_DeltaPOverPVsTheta.resize(locNumSteps); |
32 | dHistDeque_DeltaThetaVsP.resize(locNumSteps); |
33 | dHistDeque_DeltaThetaVsTheta.resize(locNumSteps); |
34 | dHistDeque_DeltaPhiVsP.resize(locNumSteps); |
35 | dHistDeque_DeltaPhiVsTheta.resize(locNumSteps); |
36 | dHistDeque_DeltaTVsTheta.resize(locNumSteps); |
37 | dHistDeque_DeltaTVsP.resize(locNumSteps); |
38 | dHistDeque_DeltaVertexZVsTheta.resize(locNumSteps); |
39 | |
40 | dHistDeque_Pulls.resize(locNumSteps); |
41 | dHistDeque_PullsVsP.resize(locNumSteps); |
42 | dHistDeque_PullsVsTheta.resize(locNumSteps); |
43 | |
44 | dHistDeque_TimePull_CDC.resize(locNumSteps); |
45 | dHistDeque_TimePull_ST.resize(locNumSteps); |
46 | dHistDeque_TimePull_BCAL.resize(locNumSteps); |
47 | dHistDeque_TimePull_TOF.resize(locNumSteps); |
48 | dHistDeque_TimePull_FCAL.resize(locNumSteps); |
49 | |
50 | dHistDeque_TimePullVsTheta_CDC.resize(locNumSteps); |
51 | dHistDeque_TimePullVsTheta_BCAL.resize(locNumSteps); |
52 | dHistDeque_TimePullVsTheta_ST.resize(locNumSteps); |
53 | |
54 | dHistDeque_TimePullVsP_CDC.resize(locNumSteps); |
55 | dHistDeque_TimePullVsP_BCAL.resize(locNumSteps); |
56 | dHistDeque_TimePullVsP_ST.resize(locNumSteps); |
57 | dHistDeque_TimePullVsP_TOF.resize(locNumSteps); |
58 | dHistDeque_TimePullVsP_FCAL.resize(locNumSteps); |
59 | |
60 | |
61 | |
62 | japp->RootWriteLock(); |
63 | { |
64 | CreateAndChangeTo_ActionDirectory(); |
65 | |
66 | |
67 | locHistName = "DeltaT_RFBeamBunch"; |
68 | dRFBeamBunchDeltaT_Hist = GetOrCreate_Histogram<TH1I>(locHistName, ";RF #Deltat (Reconstructed - Thrown)", dNumRFDeltaTBins, dMinRFDeltaT, dMaxRFDeltaT); |
69 | |
70 | |
71 | locPID = Get_Reaction()->Get_ReactionStep(0)->Get_InitialPID(); |
72 | bool locBeamParticleUsed = (locPID == Gamma); |
73 | if(locBeamParticleUsed) |
74 | { |
75 | locParticleName = string("Beam_") + ParticleType(locPID); |
76 | CreateAndChangeTo_Directory(locParticleName, locParticleName); |
77 | locParticleROOTName = ParticleName_ROOT(locPID); |
78 | |
79 | |
80 | locHistName = string("DeltaPOverP"); |
81 | locHistTitle = locParticleROOTName + string(";#Deltap/p (Reconstructed - Thrown)"); |
82 | dBeamParticleHist_DeltaPOverP = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumDeltaPOverPBins, dMinDeltaPOverP, dMaxDeltaPOverP); |
83 | |
84 | |
85 | locHistName = string("DeltaPOverPVsP"); |
86 | locHistTitle = locParticleROOTName + string(";p (GeV/c);#Deltap/p (Reconstructed - Thrown)"); |
87 | dBeamParticleHist_DeltaPOverPVsP = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DPBins, dMinP, dMaxP, dNumDeltaPOverPBins, dMinDeltaPOverP, dMaxDeltaPOverP); |
88 | |
89 | |
90 | locHistName = string("DeltaT"); |
91 | locHistTitle = locParticleROOTName + string(";#Deltat (ns) (Reconstructed - Thrown)"); |
92 | dBeamParticleHist_DeltaT = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumDeltaTBins, dMinDeltaT, dMaxDeltaT); |
93 | |
94 | gDirectory->cd(".."); |
95 | } |
96 | |
97 | deque<string> locPullNames(8, ""); |
98 | locPullNames[0] = "E"; locPullNames[1] = "Px"; locPullNames[2] = "Py"; locPullNames[3] = "Pz"; |
99 | locPullNames[4] = "Xx"; locPullNames[5] = "Xy"; locPullNames[6] = "Xz"; locPullNames[7] = "T"; |
100 | |
101 | deque<string> locPullTitles(8, ""); |
102 | locPullTitles[0] = "E"; locPullTitles[1] = "p_{x}"; locPullTitles[2] = "p_{y}"; locPullTitles[3] = "p_{z}"; |
103 | locPullTitles[4] = "x_{x}"; locPullTitles[5] = "x_{y}"; locPullTitles[6] = "x_{z}"; locPullTitles[7] = "t"; |
104 | |
105 | |
106 | deque<Particle_t> locPIDs; |
107 | for(size_t loc_i = 0; loc_i < locNumSteps; ++loc_i) |
108 | { |
109 | const DReactionStep* locReactionStep = Get_Reaction()->Get_ReactionStep(loc_i); |
110 | locStepName = DAnalysis::Get_StepName(locReactionStep, true, false); |
111 | locStepROOTName = DAnalysis::Get_StepName(locReactionStep, true, true); |
112 | |
113 | Particle_t locInitialPID = locReactionStep->Get_InitialPID(); |
114 | |
115 | |
116 | auto locPIDs = Get_Reaction()->Get_FinalPIDs(loc_i, Get_UseKinFitResultsFlag(), Get_UseKinFitResultsFlag(), d_AllCharges, false); |
117 | if(Get_UseKinFitResultsFlag()) |
118 | { |
119 | if((!locBeamParticleUsed) || (loc_i != 0)) |
120 | locPIDs.insert(locPIDs.begin(), locInitialPID); |
121 | } |
122 | if(locPIDs.empty()) |
123 | continue; |
124 | |
125 | CreateAndChangeTo_Directory(locStepName, locStepName); |
126 | for(size_t loc_j = 0; loc_j < locPIDs.size(); ++loc_j) |
127 | { |
128 | locPID = locPIDs[loc_j]; |
129 | locParticleName = ParticleType(locPID); |
130 | locParticleROOTName = ParticleName_ROOT(locPID); |
131 | if(dHistDeque_DeltaPOverP[loc_i].find(locPID) != dHistDeque_DeltaPOverP[loc_i].end()) |
132 | continue; |
133 | |
134 | CreateAndChangeTo_Directory(locParticleName, locParticleName); |
135 | |
136 | |
137 | locHistName = string("DeltaPOverP"); |
138 | locHistTitle = locParticleROOTName + string(";#Deltap/p (Reconstructed - Thrown)"); |
139 | dHistDeque_DeltaPOverP[loc_i][locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumDeltaPOverPBins, dMinDeltaPOverP, dMaxDeltaPOverP); |
140 | |
141 | |
142 | locHistName = string("DeltaTheta"); |
143 | locHistTitle = locParticleROOTName + string(";#Delta#theta#circ (Reconstructed - Thrown)"); |
144 | dHistDeque_DeltaTheta[loc_i][locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumDeltaThetaBins, dMinDeltaTheta, dMaxDeltaTheta); |
145 | |
146 | |
147 | locHistName = string("DeltaPhi"); |
148 | locHistTitle = locParticleROOTName + string(";#Delta#phi#circ (Reconstructed - Thrown)"); |
149 | dHistDeque_DeltaPhi[loc_i][locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumDeltaPhiBins, dMinDeltaPhi, dMaxDeltaPhi); |
150 | |
151 | |
152 | locHistName = string("DeltaT"); |
153 | locHistTitle = locParticleROOTName + string(";#Deltat (ns) (Reconstructed - Thrown)"); |
154 | dHistDeque_DeltaT[loc_i][locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumDeltaTBins, dMinDeltaT, dMaxDeltaT); |
155 | |
156 | |
157 | locHistName = string("DeltaT_BCAL"); |
158 | locHistTitle = locParticleROOTName + string(" in BCAL;#Deltat (ns) (Reconstructed - Thrown)"); |
159 | dHistDeque_DeltaT_BCAL[loc_i][locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumDeltaTBins, dMinDeltaT, dMaxDeltaT); |
160 | |
161 | |
162 | if(ParticleCharge(locPID) != 0) |
163 | { |
164 | locHistName = string("DeltaT_TOF"); |
165 | locHistTitle = locParticleROOTName + string(" in TOF;#Deltat (ns) (Reconstructed - Thrown)"); |
166 | dHistDeque_DeltaT_TOF[loc_i][locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumDeltaTBins, dMinDeltaT, dMaxDeltaT); |
167 | } |
168 | |
169 | |
170 | if(ParticleCharge(locPID) == 0) |
171 | { |
172 | locHistName = string("DeltaT_FCAL"); |
173 | locHistTitle = locParticleROOTName + string(" in FCAL;#Deltat (ns) (Reconstructed - Thrown)"); |
174 | dHistDeque_DeltaT_FCAL[loc_i][locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumDeltaTBins, dMinDeltaT, dMaxDeltaT); |
175 | } |
176 | |
177 | |
178 | locHistName = string("DeltaVertexZ"); |
179 | locHistTitle = locParticleROOTName + string(";#DeltaVertex-Z (cm) (Reconstructed - Thrown)"); |
180 | dHistDeque_DeltaVertexZ[loc_i][locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumDeltaVertexZBins, dMinDeltaVertexZ, dMaxDeltaVertexZ); |
181 | |
182 | |
183 | locHistName = string("DeltaPOverPVsP"); |
184 | locHistTitle = locParticleROOTName + string(";p (GeV/c);#Deltap/p (Reconstructed - Thrown)"); |
185 | dHistDeque_DeltaPOverPVsP[loc_i][locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DPBins, dMinP, dMaxP, dNumDeltaPOverPBins, dMinDeltaPOverP, dMaxDeltaPOverP); |
186 | |
187 | |
188 | locHistName = string("DeltaPOverPVsTheta"); |
189 | locHistTitle = locParticleROOTName + string(";#theta#circ;#Deltap/p (Reconstructed - Thrown)"); |
190 | dHistDeque_DeltaPOverPVsTheta[loc_i][locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DThetaBins, dMinTheta, dMaxTheta, dNumDeltaPOverPBins, dMinDeltaPOverP, dMaxDeltaPOverP); |
191 | |
192 | |
193 | locHistName = string("DeltaThetaVsP"); |
194 | locHistTitle = locParticleROOTName + string(";p (GeV/c);#Delta#theta#circ (Reconstructed - Thrown)"); |
195 | dHistDeque_DeltaThetaVsP[loc_i][locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DPBins, dMinP, dMaxP, dNumDeltaThetaBins, dMinDeltaTheta, dMaxDeltaTheta); |
196 | |
197 | |
198 | locHistName = string("DeltaThetaVsTheta"); |
199 | locHistTitle = locParticleROOTName + string(";#theta#circ;#Delta#theta#circ (Reconstructed - Thrown)"); |
200 | dHistDeque_DeltaThetaVsTheta[loc_i][locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DThetaBins, dMinTheta, dMaxTheta, dNumDeltaThetaBins, dMinDeltaTheta, dMaxDeltaTheta); |
201 | |
202 | |
203 | locHistName = string("DeltaPhiVsP"); |
204 | locHistTitle = locParticleROOTName + string(";p (GeV/c);#Delta#phi#circ (Reconstructed - Thrown)"); |
205 | dHistDeque_DeltaPhiVsP[loc_i][locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DPBins, dMinP, dMaxP, dNumDeltaPhiBins, dMinDeltaPhi, dMaxDeltaPhi); |
206 | |
207 | |
208 | locHistName = string("DeltaPhiVsTheta"); |
209 | locHistTitle = locParticleROOTName + string(";#theta#circ;#Delta#phi#circ (Reconstructed - Thrown)"); |
210 | dHistDeque_DeltaPhiVsTheta[loc_i][locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DThetaBins, dMinTheta, dMaxTheta, dNumDeltaPhiBins, dMinDeltaPhi, dMaxDeltaPhi); |
211 | |
212 | |
213 | locHistName = string("DeltaTVsTheta"); |
214 | locHistTitle = locParticleROOTName + string(";#theta#circ;#Deltat (ns) (Reconstructed - Thrown)"); |
215 | dHistDeque_DeltaTVsTheta[loc_i][locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DThetaBins, dMinTheta, dMaxTheta, dNumDeltaTBins, dMinDeltaT, dMaxDeltaT); |
216 | |
217 | |
218 | locHistName = string("DeltaTVsP"); |
219 | locHistTitle = locParticleROOTName + string(";p (GeV/c);#Deltat (ns) (Reconstructed - Thrown)"); |
220 | dHistDeque_DeltaTVsP[loc_i][locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DPBins, dMinP, dMaxP, dNumDeltaTBins, dMinDeltaT, dMaxDeltaT); |
221 | |
222 | |
223 | locHistName = string("DeltaVertexZVsTheta"); |
224 | locHistTitle = locParticleROOTName + string(";#theta#circ;#DeltaVertex-Z (cm) (Reconstructed - Thrown)"); |
225 | dHistDeque_DeltaVertexZVsTheta[loc_i][locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DThetaBins, dMinTheta, dMaxTheta, dNumDeltaVertexZBins, dMinDeltaVertexZ, dMaxDeltaVertexZ); |
226 | |
227 | |
228 | |
229 | CreateAndChangeTo_Directory("Pulls", "Pulls"); |
230 | for(size_t loc_j = 0; loc_j < dPullTypes.size(); ++loc_j) |
231 | { |
232 | if((ParticleCharge(locPID) != 0) && (dPullTypes[loc_j] == d_EPull)) |
233 | continue; |
234 | if((ParticleCharge(locPID) == 0) && ((dPullTypes[loc_j] >= d_PxPull) && (dPullTypes[loc_j] <= d_PzPull))) |
235 | continue; |
236 | |
237 | |
238 | locHistName = locPullNames[loc_j] + string("Pull"); |
239 | locHistTitle = locParticleROOTName + string(";#Delta") + locPullTitles[loc_j] + string("/#sigma_{") + locPullTitles[loc_j] + string("} (Reconstructed - Thrown)"); |
240 | dHistDeque_Pulls[loc_i][locPID][dPullTypes[loc_j]] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumPullBins, -10.0, 10.0); |
241 | |
242 | |
243 | locHistName = locPullNames[loc_j] + string("PullVsP"); |
244 | locHistTitle = locParticleROOTName + string(";p (GeV/c);#Delta") + locPullTitles[loc_j] + string("/#sigma_{") + locPullTitles[loc_j] + string("} (Reconstructed - Thrown)"); |
245 | dHistDeque_PullsVsP[loc_i][locPID][dPullTypes[loc_j]] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DPBins, dMinP, dMaxP, dNum2DPullBins, -10.0, 10.0); |
246 | |
247 | |
248 | locHistName = locPullNames[loc_j] + string("PullVsTheta"); |
249 | locHistTitle = locParticleROOTName + string(";#theta#circ;#Delta") + locPullTitles[loc_j] + string("/#sigma_{") + locPullTitles[loc_j] + string("} (Reconstructed - Thrown)"); |
250 | dHistDeque_PullsVsTheta[loc_i][locPID][dPullTypes[loc_j]] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DThetaBins, dMinTheta, dMaxTheta, dNum2DPullBins, -10.0, 10.0); |
251 | } |
252 | |
253 | |
254 | if(ParticleCharge(locPID) != 0) |
255 | { |
256 | |
257 | locHistName = "TimePull_CDC"; |
258 | locHistTitle = locParticleROOTName + string(";#Deltat/#sigma_{#Deltat}"); |
259 | dHistDeque_TimePull_CDC[loc_i][locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumPullBins, -10.0, 10.0); |
260 | |
261 | locHistName = "TimePullVsTheta_CDC"; |
262 | locHistTitle = locParticleROOTName + string(";#theta#circ;#Deltat/#sigma_{#Deltat}"); |
263 | dHistDeque_TimePullVsTheta_CDC[loc_i][locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DThetaBins, dMinTheta, dMaxTheta, dNum2DPullBins, -10.0, 10.0); |
264 | |
265 | locHistName = "TimePullVsP_CDC"; |
266 | locHistTitle = locParticleROOTName + string(";p (GeV/c);#Deltat/#sigma_{#Deltat}"); |
267 | dHistDeque_TimePullVsP_CDC[loc_i][locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DPBins, dMinP, dMaxP, dNum2DPullBins, -10.0, 10.0); |
268 | |
269 | |
270 | locHistName = "TimePull_ST"; |
271 | locHistTitle = locParticleROOTName + string(";#Deltat/#sigma_{#Deltat}"); |
272 | dHistDeque_TimePull_ST[loc_i][locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumPullBins, -10.0, 10.0); |
273 | |
274 | locHistName = "TimePullVsTheta_ST"; |
275 | locHistTitle = locParticleROOTName + string(";#theta#circ;#Deltat/#sigma_{#Deltat}"); |
276 | dHistDeque_TimePullVsTheta_ST[loc_i][locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DThetaBins, dMinTheta, dMaxTheta, dNum2DPullBins, -10.0, 10.0); |
277 | |
278 | locHistName = "TimePullVsP_ST"; |
279 | locHistTitle = locParticleROOTName + string(";p (GeV/c);#Deltat/#sigma_{#Deltat}"); |
280 | dHistDeque_TimePullVsP_ST[loc_i][locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DPBins, dMinP, dMaxP, dNum2DPullBins, -10.0, 10.0); |
281 | } |
282 | |
283 | |
284 | locHistName = "TimePull_BCAL"; |
285 | locHistTitle = locParticleROOTName + string(";#Deltat/#sigma_{#Deltat}"); |
286 | dHistDeque_TimePull_BCAL[loc_i][locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumPullBins, -10.0, 10.0); |
287 | |
288 | locHistName = "TimePullVsTheta_BCAL"; |
289 | locHistTitle = locParticleROOTName + string(";#theta#circ;#Deltat/#sigma_{#Deltat}"); |
290 | dHistDeque_TimePullVsTheta_BCAL[loc_i][locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DThetaBins, dMinTheta, dMaxTheta, dNum2DPullBins, -10.0, 10.0); |
291 | |
292 | locHistName = "TimePullVsP_BCAL"; |
293 | locHistTitle = locParticleROOTName + string(";p (GeV/c);#Deltat/#sigma_{#Deltat}"); |
294 | dHistDeque_TimePullVsP_BCAL[loc_i][locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DPBins, dMinP, dMaxP, dNum2DPullBins, -10.0, 10.0); |
295 | |
296 | |
297 | if(ParticleCharge(locPID) != 0) |
298 | { |
299 | locHistName = "TimePull_TOF"; |
300 | locHistTitle = locParticleROOTName + string(";#Deltat/#sigma_{#Deltat}"); |
301 | dHistDeque_TimePull_TOF[loc_i][locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumPullBins, -10.0, 10.0); |
302 | |
303 | locHistName = "TimePullVsP_TOF"; |
304 | locHistTitle = locParticleROOTName + string(";p (GeV/c);#Deltat/#sigma_{#Deltat}"); |
305 | dHistDeque_TimePullVsP_TOF[loc_i][locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DPBins, dMinP, dMaxP, dNum2DPullBins, -10.0, 10.0); |
306 | } |
307 | |
308 | |
309 | locHistName = "TimePull_FCAL"; |
310 | locHistTitle = locParticleROOTName + string(";#Deltat/#sigma_{#Deltat}"); |
311 | dHistDeque_TimePull_FCAL[loc_i][locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumPullBins, -10.0, 10.0); |
312 | |
313 | locHistName = "TimePullVsP_FCAL"; |
314 | locHistTitle = locParticleROOTName + string(";p (GeV/c);#Deltat/#sigma_{#Deltat}"); |
315 | dHistDeque_TimePullVsP_FCAL[loc_i][locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DPBins, dMinP, dMaxP, dNum2DPullBins, -10.0, 10.0); |
316 | |
317 | gDirectory->cd(".."); |
318 | |
319 | gDirectory->cd(".."); |
320 | } |
321 | gDirectory->cd(".."); |
322 | } |
323 | |
324 | |
325 | ChangeTo_BaseDirectory(); |
326 | } |
327 | japp->RootUnLock(); |
328 | } |
329 | |
330 | void DHistogramAction_ParticleComboGenReconComparison::Run_Update(JEventLoop* locEventLoop) |
331 | { |
332 | DApplication* locApplication = dynamic_cast<DApplication*>(locEventLoop->GetJApplication()); |
333 | DGeometry *locGeometry = locApplication->GetDGeometry(locEventLoop->GetJEvent().GetRunNumber()); |
334 | locGeometry->GetTargetZ(dTargetZCenter); |
335 | } |
336 | |
337 | bool DHistogramAction_ParticleComboGenReconComparison::Perform_Action(JEventLoop* locEventLoop, const DParticleCombo* locParticleCombo) |
338 | { |
339 | if(Get_UseKinFitResultsFlag() && (Get_Reaction()->Get_KinFitType() == d_NoFit)) |
340 | { |
341 | cout << "WARNING: REQUESTED HISTOGRAM OF KINEMAITIC FIT RESULTS WHEN NO KINEMATIC FIT!!! Skipping histogram." << endl; |
342 | return true; |
343 | } |
344 | |
345 | vector<const DMCThrown*> locMCThrowns; |
346 | locEventLoop->Get(locMCThrowns); |
347 | if(locMCThrowns.empty()) |
348 | return true; |
349 | |
350 | vector<const DBeamPhoton*> locBeamPhotons; |
351 | locEventLoop->Get(locBeamPhotons, "MCGEN"); |
352 | const DBeamPhoton* locThrownBeamPhoton = locBeamPhotons.empty() ? NULL : locBeamPhotons[0]; |
353 | |
354 | vector<const DMCThrownMatching*> locMCThrownMatchingVector; |
355 | locEventLoop->Get(locMCThrownMatchingVector); |
356 | if(locMCThrownMatchingVector.empty()) |
357 | return true; |
358 | const DMCThrownMatching* locMCThrownMatching = locMCThrownMatchingVector[0]; |
359 | |
360 | const DEventRFBunch* locEventRFBunch = locParticleCombo->Get_EventRFBunch(); |
361 | const DEventRFBunch* locThrownEventRFBunch = NULL; |
362 | locEventLoop->GetSingle(locThrownEventRFBunch, "Thrown"); |
363 | |
364 | |
365 | double locRFTime = locEventRFBunch->dTime; |
366 | double locRFDeltaT = locRFTime - locThrownEventRFBunch->dTime; |
367 | |
368 | |
369 | |
370 | Lock_Action(); |
371 | { |
372 | dRFBeamBunchDeltaT_Hist->Fill(locRFDeltaT); |
373 | } |
374 | Unlock_Action(); |
375 | |
376 | const DKinematicData* locKinematicData; |
377 | for(size_t loc_i = 0; loc_i < locParticleCombo->Get_NumParticleComboSteps(); ++loc_i) |
378 | { |
379 | const DParticleComboStep* locParticleComboStep = locParticleCombo->Get_ParticleComboStep(loc_i); |
380 | |
381 | |
382 | if(Get_UseKinFitResultsFlag()) |
383 | locKinematicData = locParticleComboStep->Get_InitialParticle(); |
384 | else |
385 | locKinematicData = locParticleComboStep->Get_InitialParticle_Measured(); |
386 | if(locKinematicData != NULL) |
387 | { |
388 | if(locKinematicData->PID() == Gamma) |
389 | { |
390 | |
391 | const JObject* locSourceObject = locParticleComboStep->Get_InitialParticle_Measured(); |
392 | if(dPreviouslyHistogrammedBeamParticles.find(locSourceObject) == dPreviouslyHistogrammedBeamParticles.end()) |
393 | { |
394 | dPreviouslyHistogrammedBeamParticles.insert(locSourceObject); |
395 | Fill_BeamHists(locKinematicData, locThrownBeamPhoton); |
396 | } |
397 | } |
398 | } |
399 | |
400 | |
401 | for(size_t loc_j = 0; loc_j < locParticleComboStep->Get_NumFinalParticles(); ++loc_j) |
402 | { |
403 | if(Get_UseKinFitResultsFlag()) |
404 | locKinematicData = locParticleComboStep->Get_FinalParticle(loc_j); |
405 | else |
406 | locKinematicData = locParticleComboStep->Get_FinalParticle_Measured(loc_j); |
407 | if(locKinematicData == NULL) |
408 | continue; |
409 | if(DAnalysis::Get_DecayStepIndex(Get_Reaction(), loc_i, loc_j) > 0) |
410 | continue; |
411 | if(Get_Reaction()->Get_ReactionStep(loc_i)->Get_MissingParticleIndex() == int(loc_j)) |
412 | continue; |
413 | |
414 | |
415 | const JObject* locSourceObject = locParticleComboStep->Get_FinalParticle_SourceObject(loc_j); |
416 | if(locSourceObject != NULL) |
417 | { |
418 | pair<Particle_t, const JObject*> locParticleInfo(locKinematicData->PID(), locSourceObject); |
419 | pair<size_t, pair<Particle_t, const JObject*> > locHistInfo(loc_i, locParticleInfo); |
420 | if(dPreviouslyHistogrammedParticles.find(locHistInfo) != dPreviouslyHistogrammedParticles.end()) |
421 | continue; |
422 | dPreviouslyHistogrammedParticles.insert(locHistInfo); |
423 | } |
424 | |
425 | if(ParticleCharge(locKinematicData->PID()) != 0) |
426 | { |
427 | const DChargedTrackHypothesis* locChargedTrackHypothesis = static_cast<const DChargedTrackHypothesis*>(locKinematicData); |
428 | double locMatchFOM = 0.0; |
429 | const DMCThrown* locMCThrown = locMCThrownMatching->Get_MatchingMCThrown(locChargedTrackHypothesis, locMatchFOM); |
430 | if(locMCThrown != NULL) |
431 | Fill_ChargedHists(locChargedTrackHypothesis, locMCThrown, locThrownEventRFBunch, loc_i); |
432 | } |
433 | else |
434 | { |
435 | const DNeutralParticleHypothesis* locNeutralParticleHypothesis = static_cast<const DNeutralParticleHypothesis*>(locKinematicData); |
436 | double locMatchFOM = 0.0; |
437 | const DMCThrown* locMCThrown = locMCThrownMatching->Get_MatchingMCThrown(locNeutralParticleHypothesis, locMatchFOM); |
438 | if(locMCThrown != NULL) |
439 | Fill_NeutralHists(locNeutralParticleHypothesis, locMCThrown, locThrownEventRFBunch, loc_i); |
440 | } |
441 | } |
442 | } |
443 | return true; |
444 | } |
445 | |
446 | void DHistogramAction_ParticleComboGenReconComparison::Fill_BeamHists(const DKinematicData* locKinematicData, const DKinematicData* locThrownKinematicData) |
447 | { |
448 | if(locThrownKinematicData == NULL) |
449 | return; |
450 | |
451 | DVector3 locMomentum = locKinematicData->momentum(); |
452 | DVector3 locThrownMomentum = locThrownKinematicData->momentum(); |
453 | |
454 | double locThrownP = locThrownMomentum.Mag(); |
455 | double locDeltaPOverP = (locMomentum.Mag() - locThrownP)/locThrownP; |
456 | double locDeltaT = locKinematicData->time() - locThrownKinematicData->time(); |
457 | |
458 | |
459 | |
460 | |
461 | Lock_Action(); |
462 | { |
463 | dBeamParticleHist_DeltaPOverP->Fill(locDeltaPOverP); |
464 | dBeamParticleHist_DeltaPOverPVsP->Fill(locThrownP, locDeltaPOverP); |
465 | dBeamParticleHist_DeltaT->Fill(locDeltaT); |
466 | } |
467 | Unlock_Action(); |
468 | } |
469 | |
470 | void DHistogramAction_ParticleComboGenReconComparison::Fill_ChargedHists(const DChargedTrackHypothesis* locChargedTrackHypothesis, const DMCThrown* locMCThrown, const DEventRFBunch* locThrownEventRFBunch, size_t locStepIndex) |
471 | { |
472 | Particle_t locPID = locChargedTrackHypothesis->PID(); |
473 | double locThrownP = locMCThrown->momentum().Mag(); |
474 | double locThrownTheta = locMCThrown->momentum().Theta()*180.0/TMath::Pi(); |
475 | double locDeltaPOverP = (locChargedTrackHypothesis->momentum().Mag() - locThrownP)/locThrownP; |
476 | double locDeltaTheta = locChargedTrackHypothesis->momentum().Theta()*180.0/TMath::Pi() - locThrownTheta; |
477 | double locDeltaPhi = locChargedTrackHypothesis->momentum().Phi()*180.0/TMath::Pi() - locMCThrown->momentum().Phi()*180.0/TMath::Pi(); |
478 | double locDeltaT = locChargedTrackHypothesis->time() - locMCThrown->time(); |
479 | double locDeltaVertexZ = locChargedTrackHypothesis->position().Z() - locMCThrown->position().Z(); |
480 | const TMatrixDSym& locCovarianceMatrix = *(locChargedTrackHypothesis->errorMatrix().get()); |
481 | |
482 | double locStartTime = locThrownEventRFBunch->dTime + (locMCThrown->z() - dTargetZCenter)/29.9792458; |
483 | double locTimePull = (locStartTime - locChargedTrackHypothesis->time())/sqrt(locCovarianceMatrix(6, 6)); |
484 | double locT0Pull = (locStartTime - locChargedTrackHypothesis->t0())/locChargedTrackHypothesis->t0_err(); |
485 | |
486 | |
487 | |
488 | |
489 | Lock_Action(); |
490 | { |
491 | dHistDeque_DeltaPOverP[locStepIndex][locPID]->Fill(locDeltaPOverP); |
492 | dHistDeque_DeltaTheta[locStepIndex][locPID]->Fill(locDeltaTheta); |
493 | dHistDeque_DeltaPhi[locStepIndex][locPID]->Fill(locDeltaPhi); |
494 | dHistDeque_DeltaT[locStepIndex][locPID]->Fill(locDeltaT); |
495 | if(locChargedTrackHypothesis->t0_detector() == SYS_START) |
496 | { |
497 | dHistDeque_TimePull_ST[locStepIndex][locPID]->Fill(locT0Pull); |
498 | dHistDeque_TimePullVsTheta_ST[locStepIndex][locPID]->Fill(locThrownTheta, locT0Pull); |
499 | dHistDeque_TimePullVsP_ST[locStepIndex][locPID]->Fill(locThrownP, locT0Pull); |
500 | } |
501 | if(locChargedTrackHypothesis->t0_detector() == SYS_CDC) |
502 | { |
503 | dHistDeque_TimePull_CDC[locStepIndex][locPID]->Fill(locT0Pull); |
504 | dHistDeque_TimePullVsTheta_CDC[locStepIndex][locPID]->Fill(locThrownTheta, locT0Pull); |
505 | dHistDeque_TimePullVsP_CDC[locStepIndex][locPID]->Fill(locThrownP, locT0Pull); |
506 | } |
507 | else if(locChargedTrackHypothesis->t1_detector() == SYS_CDC) |
508 | { |
509 | dHistDeque_TimePull_CDC[locStepIndex][locPID]->Fill(locTimePull); |
510 | dHistDeque_TimePullVsTheta_CDC[locStepIndex][locPID]->Fill(locThrownTheta, locTimePull); |
511 | dHistDeque_TimePullVsP_CDC[locStepIndex][locPID]->Fill(locThrownP, locTimePull); |
512 | } |
513 | if(locChargedTrackHypothesis->t1_detector() == SYS_BCAL) |
514 | { |
515 | dHistDeque_DeltaT_BCAL[locStepIndex][locPID]->Fill(locDeltaT); |
516 | dHistDeque_TimePull_BCAL[locStepIndex][locPID]->Fill(locTimePull); |
517 | dHistDeque_TimePullVsTheta_BCAL[locStepIndex][locPID]->Fill(locThrownTheta, locTimePull); |
518 | dHistDeque_TimePullVsP_BCAL[locStepIndex][locPID]->Fill(locThrownP, locTimePull); |
519 | } |
520 | else if(locChargedTrackHypothesis->t1_detector() == SYS_TOF) |
521 | { |
522 | dHistDeque_DeltaT_TOF[locStepIndex][locPID]->Fill(locDeltaT); |
523 | dHistDeque_TimePull_TOF[locStepIndex][locPID]->Fill(locTimePull); |
524 | dHistDeque_TimePullVsP_TOF[locStepIndex][locPID]->Fill(locThrownP, locTimePull); |
525 | } |
526 | else if(locChargedTrackHypothesis->t1_detector() == SYS_FCAL) |
527 | { |
528 | dHistDeque_TimePull_FCAL[locStepIndex][locPID]->Fill(locTimePull); |
529 | dHistDeque_TimePullVsP_FCAL[locStepIndex][locPID]->Fill(locThrownP, locTimePull); |
530 | } |
531 | dHistDeque_DeltaVertexZ[locStepIndex][locPID]->Fill(locDeltaVertexZ); |
532 | dHistDeque_DeltaPOverPVsP[locStepIndex][locPID]->Fill(locThrownP, locDeltaPOverP); |
533 | dHistDeque_DeltaPOverPVsTheta[locStepIndex][locPID]->Fill(locThrownTheta, locDeltaPOverP); |
534 | dHistDeque_DeltaThetaVsP[locStepIndex][locPID]->Fill(locThrownP, locDeltaTheta); |
535 | dHistDeque_DeltaThetaVsTheta[locStepIndex][locPID]->Fill(locThrownTheta, locDeltaTheta); |
536 | dHistDeque_DeltaPhiVsP[locStepIndex][locPID]->Fill(locThrownP, locDeltaPhi); |
537 | dHistDeque_DeltaPhiVsTheta[locStepIndex][locPID]->Fill(locThrownTheta, locDeltaPhi); |
538 | dHistDeque_DeltaTVsTheta[locStepIndex][locPID]->Fill(locThrownTheta, locDeltaT); |
539 | dHistDeque_DeltaTVsP[locStepIndex][locPID]->Fill(locThrownP, locDeltaT); |
540 | dHistDeque_DeltaVertexZVsTheta[locStepIndex][locPID]->Fill(locThrownTheta, locDeltaVertexZ); |
541 | |
542 | for(size_t loc_j = 0; loc_j < dPullTypes.size(); ++loc_j) |
543 | { |
544 | if(dPullTypes[loc_j] == d_EPull) |
545 | continue; |
546 | double locPull = 0.0; |
547 | if((dPullTypes[loc_j] >= d_PxPull) && (dPullTypes[loc_j] <= d_PzPull)) |
548 | { |
549 | int locIndex = int(dPullTypes[loc_j] - d_PxPull); |
550 | locPull = (locChargedTrackHypothesis->momentum()(locIndex) - locMCThrown->momentum()(locIndex))/sqrt(locCovarianceMatrix(locIndex, locIndex)); |
551 | } |
552 | else if((dPullTypes[loc_j] >= d_XxPull) && (dPullTypes[loc_j] <= d_XzPull)) |
553 | { |
554 | int locIndex = int(dPullTypes[loc_j] - d_XxPull); |
555 | locPull = (locChargedTrackHypothesis->position()(locIndex) - locMCThrown->position()(locIndex))/sqrt(locCovarianceMatrix(locIndex + 3, locIndex + 3)); |
556 | } |
557 | else if(dPullTypes[loc_j] == d_TPull) |
558 | locPull = (locChargedTrackHypothesis->time() - locMCThrown->time())/sqrt(locCovarianceMatrix(6, 6)); |
559 | (dHistDeque_Pulls[locStepIndex][locPID])[dPullTypes[loc_j]]->Fill(locPull); |
560 | (dHistDeque_PullsVsP[locStepIndex][locPID])[dPullTypes[loc_j]]->Fill(locThrownP, locPull); |
561 | (dHistDeque_PullsVsTheta[locStepIndex][locPID])[dPullTypes[loc_j]]->Fill(locThrownTheta, locPull); |
562 | } |
563 | } |
564 | Unlock_Action(); |
565 | } |
566 | |
567 | void DHistogramAction_ParticleComboGenReconComparison::Fill_NeutralHists(const DNeutralParticleHypothesis* locNeutralParticleHypothesis, const DMCThrown* locMCThrown, const DEventRFBunch* locThrownEventRFBunch, size_t locStepIndex) |
568 | { |
569 | Particle_t locPID = locNeutralParticleHypothesis->PID(); |
570 | const DNeutralShower* locNeutralShower = locNeutralParticleHypothesis->Get_NeutralShower(); |
571 | |
572 | double locThrownP = locMCThrown->momentum().Mag(); |
573 | double locThrownTheta = locMCThrown->momentum().Theta()*180.0/TMath::Pi(); |
574 | DVector3 locNeutralP3 = locNeutralParticleHypothesis->momentum(); |
575 | double locPMag = locNeutralP3.Mag(); |
576 | double locDeltaPOverP = (locPMag - locThrownP)/locThrownP; |
577 | double locDeltaTheta = locNeutralP3.Theta()*180.0/TMath::Pi() - locThrownTheta; |
578 | double locDeltaPhi = locNeutralP3.Phi()*180.0/TMath::Pi() - locMCThrown->momentum().Phi()*180.0/TMath::Pi(); |
579 | double locDeltaT = locNeutralParticleHypothesis->time() - locMCThrown->time(); |
580 | double locDeltaVertexZ = locNeutralParticleHypothesis->position().Z() - locMCThrown->position().Z(); |
581 | auto locCovarianceMatrix = locNeutralParticleHypothesis->errorMatrix(); |
582 | |
583 | double locStartTime = locThrownEventRFBunch->dTime + (locMCThrown->z() - dTargetZCenter)/29.9792458; |
584 | double locTimePull = (locCovarianceMatrix != nullptr) ? (locStartTime - locNeutralParticleHypothesis->time())/sqrt((*locCovarianceMatrix)(6, 6)) : std::numeric_limits<double>::quiet_NaN(); |
585 | |
586 | double locEPull = 0.0; |
587 | if(Get_UseKinFitResultsFlag()) |
588 | { |
589 | DMatrix locJacobian(1, 7); |
590 | locJacobian(0, 0) = locNeutralP3.Px()/locPMag; |
591 | locJacobian(0, 1) = locNeutralP3.Py()/locPMag; |
592 | locJacobian(0, 2) = locNeutralP3.Pz()/locPMag; |
593 | for(unsigned int loc_i = 0; loc_i < 4; ++loc_i) |
594 | locJacobian(0, 3 + loc_i) = 0.0; |
595 | |
596 | if(locCovarianceMatrix != nullptr) |
597 | { |
598 | TMatrixDSym locCovCopy = *locCovarianceMatrix; |
599 | locCovCopy.Similarity(locJacobian); |
600 | double locEUncertainty = sqrt(locCovCopy(0, 0)); |
601 | locEPull = (locNeutralParticleHypothesis->energy() - locMCThrown->energy())/locEUncertainty; |
602 | } |
603 | else |
604 | locEPull = std::numeric_limits<double>::quiet_NaN(); |
605 | } |
606 | else |
607 | locEPull = (locNeutralShower->dEnergy - locMCThrown->energy())/sqrt((*(locNeutralShower->dCovarianceMatrix))(0, 0)); |
608 | |
609 | |
610 | |
611 | |
612 | Lock_Action(); |
613 | { |
614 | dHistDeque_DeltaPOverP[locStepIndex][locPID]->Fill(locDeltaPOverP); |
615 | dHistDeque_DeltaTheta[locStepIndex][locPID]->Fill(locDeltaTheta); |
616 | dHistDeque_DeltaPhi[locStepIndex][locPID]->Fill(locDeltaPhi); |
617 | dHistDeque_DeltaT[locStepIndex][locPID]->Fill(locDeltaT); |
618 | if(locNeutralParticleHypothesis->t1_detector() == SYS_BCAL) |
619 | { |
620 | dHistDeque_DeltaT_BCAL[locStepIndex][locPID]->Fill(locDeltaT); |
621 | dHistDeque_TimePull_BCAL[locStepIndex][locPID]->Fill(locTimePull); |
622 | dHistDeque_TimePullVsTheta_BCAL[locStepIndex][locPID]->Fill(locThrownTheta, locTimePull); |
623 | dHistDeque_TimePullVsP_BCAL[locStepIndex][locPID]->Fill(locThrownP, locTimePull); |
624 | } |
625 | else if(locNeutralParticleHypothesis->t1_detector() == SYS_FCAL) |
626 | { |
627 | dHistDeque_DeltaT_FCAL[locStepIndex][locPID]->Fill(locDeltaT); |
628 | dHistDeque_TimePull_FCAL[locStepIndex][locPID]->Fill(locTimePull); |
629 | dHistDeque_TimePullVsP_FCAL[locStepIndex][locPID]->Fill(locThrownP, locTimePull); |
630 | } |
631 | |
632 | dHistDeque_DeltaVertexZ[locStepIndex][locPID]->Fill(locDeltaVertexZ); |
633 | dHistDeque_DeltaPOverPVsP[locStepIndex][locPID]->Fill(locThrownP, locDeltaPOverP); |
634 | dHistDeque_DeltaPOverPVsTheta[locStepIndex][locPID]->Fill(locThrownTheta, locDeltaPOverP); |
635 | dHistDeque_DeltaThetaVsP[locStepIndex][locPID]->Fill(locThrownP, locDeltaTheta); |
636 | dHistDeque_DeltaThetaVsTheta[locStepIndex][locPID]->Fill(locThrownTheta, locDeltaTheta); |
637 | dHistDeque_DeltaPhiVsP[locStepIndex][locPID]->Fill(locThrownP, locDeltaPhi); |
638 | dHistDeque_DeltaPhiVsTheta[locStepIndex][locPID]->Fill(locThrownTheta, locDeltaPhi); |
639 | dHistDeque_DeltaTVsTheta[locStepIndex][locPID]->Fill(locThrownTheta, locDeltaT); |
640 | dHistDeque_DeltaTVsP[locStepIndex][locPID]->Fill(locThrownP, locDeltaT); |
641 | dHistDeque_DeltaVertexZVsTheta[locStepIndex][locPID]->Fill(locThrownTheta, locDeltaVertexZ); |
642 | |
643 | if(locCovarianceMatrix != nullptr) |
644 | { |
645 | for(size_t loc_j = 0; loc_j < dPullTypes.size(); ++loc_j) |
646 | { |
647 | if((dPullTypes[loc_j] >= d_PxPull) && (dPullTypes[loc_j] <= d_PzPull)) |
648 | continue; |
649 | double locPull = 0.0; |
650 | if(dPullTypes[loc_j] == d_EPull) |
651 | locPull = locEPull; |
652 | else if((dPullTypes[loc_j] >= d_XxPull) && (dPullTypes[loc_j] <= d_XzPull)) |
653 | { |
654 | int locIndex = int(dPullTypes[loc_j] - d_XxPull); |
655 | locPull = (locNeutralParticleHypothesis->position()(locIndex) - locMCThrown->position()(locIndex))/sqrt((*locCovarianceMatrix)(locIndex + 3, locIndex + 3)); |
656 | } |
657 | else if(dPullTypes[loc_j] == d_TPull) |
658 | locPull = (locNeutralParticleHypothesis->time() - locMCThrown->time())/sqrt((*locCovarianceMatrix)(6, 6)); |
659 | (dHistDeque_Pulls[locStepIndex][locPID])[dPullTypes[loc_j]]->Fill(locPull); |
660 | (dHistDeque_PullsVsP[locStepIndex][locPID])[dPullTypes[loc_j]]->Fill(locThrownP, locPull); |
661 | (dHistDeque_PullsVsTheta[locStepIndex][locPID])[dPullTypes[loc_j]]->Fill(locThrownTheta, locPull); |
662 | } |
663 | } |
664 | } |
665 | Unlock_Action(); |
666 | } |
667 | |
668 | void DHistogramAction_ThrownParticleKinematics::Initialize(JEventLoop* locEventLoop) |
669 | { |
670 | string locHistName, locHistTitle, locParticleName, locParticleROOTName; |
671 | Particle_t locPID; |
672 | |
673 | |
674 | |
675 | japp->RootWriteLock(); |
676 | { |
677 | CreateAndChangeTo_ActionDirectory(); |
678 | |
679 | |
680 | { |
681 | locPID = Gamma; |
682 | locParticleName = string("MCGENBeamParticle_") + ParticleType(locPID); |
683 | locParticleROOTName = ParticleName_ROOT(locPID); |
684 | CreateAndChangeTo_Directory(locParticleName, locParticleName); |
685 | |
686 | locHistName = "Momentum"; |
687 | locHistTitle = string("MCGEN Thrown Beam ") + locParticleROOTName + string(";p (GeV/c)"); |
688 | dMCGENBeamParticle_P = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumPBins, dMinP, dMaxP); |
689 | |
690 | locHistName = "Time"; |
691 | locHistTitle = string("MCGEN Thrown Beam ") + locParticleROOTName + string(";t (ns)"); |
692 | dMCGENBeamParticle_Time = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumTBins, dMinT, dMaxT); |
693 | |
694 | gDirectory->cd(".."); |
695 | } |
696 | |
697 | |
698 | { |
699 | locPID = Gamma; |
700 | locParticleName = string("TRUTHBeamParticles_") + ParticleType(locPID); |
701 | locParticleROOTName = ParticleName_ROOT(locPID); |
702 | CreateAndChangeTo_Directory(locParticleName, locParticleName); |
703 | |
704 | locHistName = "Momentum"; |
705 | locHistTitle = string("TRUTH Thrown Beam ") + locParticleROOTName + string(";p (GeV/c)"); |
706 | dAllBeamParticle_P = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumPBins, dMinP, dMaxP); |
707 | |
708 | locHistName = "Time"; |
709 | locHistTitle = string("TRUTH Thrown Beam ") + locParticleROOTName + string(";t (ns)"); |
710 | dAllBeamParticle_Time = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumTBins, dMinT, dMaxT); |
711 | |
712 | gDirectory->cd(".."); |
713 | } |
714 | |
715 | for(size_t loc_i = 0; loc_i < dFinalStatePIDs.size(); ++loc_i) |
716 | { |
717 | locPID = dFinalStatePIDs[loc_i]; |
718 | locParticleName = ParticleType(locPID); |
719 | locParticleROOTName = ParticleName_ROOT(locPID); |
720 | CreateAndChangeTo_Directory(locParticleName, locParticleName); |
721 | |
722 | |
723 | locHistName = "Momentum"; |
724 | locHistTitle = string("Thrown ") + locParticleROOTName + string(";p (GeV/c)"); |
725 | dHistMap_P[locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumPBins, dMinP, dMaxP); |
726 | |
727 | |
728 | locHistName = "Theta"; |
729 | locHistTitle = string("Thrown ") + locParticleROOTName + string(";#theta#circ"); |
730 | dHistMap_Theta[locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumThetaBins, dMinTheta, dMaxTheta); |
731 | |
732 | |
733 | locHistName = "Phi"; |
734 | locHistTitle = string("Thrown ") + locParticleROOTName + string(";#phi#circ"); |
735 | dHistMap_Phi[locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumPhiBins, dMinPhi, dMaxPhi); |
736 | |
737 | |
738 | locHistName = "PVsTheta"; |
739 | locHistTitle = string("Thrown ") + locParticleROOTName + string(";#theta#circ;p (GeV/c)"); |
740 | dHistMap_PVsTheta[locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DThetaBins, dMinTheta, dMaxTheta, dNum2DPBins, dMinP, dMaxP); |
741 | |
742 | |
743 | locHistName = "PhiVsTheta"; |
744 | locHistTitle = string("Thrown ") + locParticleROOTName + string(";#theta#circ;#phi#circ"); |
745 | dHistMap_PhiVsTheta[locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DThetaBins, dMinTheta, dMaxTheta, dNum2DPhiBins, dMinPhi, dMaxPhi); |
746 | |
747 | |
748 | locHistName = "VertexZ"; |
749 | locHistTitle = string("Thrown ") + locParticleROOTName + string(";Vertex-Z (cm)"); |
750 | dHistMap_VertexZ[locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumVertexZBins, dMinVertexZ, dMaxVertexZ); |
751 | |
752 | |
753 | locHistName = "VertexYVsX"; |
754 | locHistTitle = string("Thrown ") + locParticleROOTName + string(";Vertex-X (cm);Vertex-Y (cm)"); |
755 | dHistMap_VertexYVsX[locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNumVertexXYBins, dMinVertexXY, dMaxVertexXY, dNumVertexXYBins, dMinVertexXY, dMaxVertexXY); |
756 | |
757 | |
758 | locHistName = "VertexT"; |
759 | locHistTitle = string("Thrown ") + locParticleROOTName + string(";Vertex-T (ns)"); |
760 | dHistMap_VertexT[locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumTBins, dMinT, dMaxT); |
761 | |
762 | gDirectory->cd(".."); |
763 | } |
764 | |
765 | |
766 | ChangeTo_BaseDirectory(); |
767 | } |
768 | japp->RootUnLock(); |
769 | } |
770 | |
771 | bool DHistogramAction_ThrownParticleKinematics::Perform_Action(JEventLoop* locEventLoop, const DParticleCombo* locParticleCombo) |
772 | { |
773 | vector<const DMCThrown*> locMCThrowns, locMCThrowns_Decaying; |
774 | locEventLoop->Get(locMCThrowns, "FinalState"); |
775 | locEventLoop->Get(locMCThrowns_Decaying, "Decaying"); |
776 | locMCThrowns.insert(locMCThrowns.begin(), locMCThrowns_Decaying.begin(), locMCThrowns_Decaying.end()); |
777 | if(locMCThrowns.empty()) |
778 | return true; |
779 | |
780 | if(Get_CalledPriorWithComboFlag()) |
781 | return true; |
782 | |
783 | Particle_t locPID; |
784 | const DMCThrown* locMCThrown; |
785 | |
786 | vector<const DBeamPhoton*> locMCGENBeamPhotons; |
787 | locEventLoop->Get(locMCGENBeamPhotons, "MCGEN"); |
788 | |
789 | vector<const DBeamPhoton*> locBeamPhotons; |
790 | locEventLoop->Get(locBeamPhotons, "TRUTH"); |
791 | |
792 | |
793 | |
794 | |
795 | Lock_Action(); |
796 | { |
797 | for(size_t loc_i = 0; loc_i < locMCGENBeamPhotons.size(); ++loc_i) |
798 | { |
799 | dMCGENBeamParticle_P->Fill(locMCGENBeamPhotons[loc_i]->energy()); |
800 | dMCGENBeamParticle_Time->Fill(locMCGENBeamPhotons[loc_i]->time()); |
801 | } |
802 | for(size_t loc_i = 0; loc_i < locBeamPhotons.size(); ++loc_i) |
803 | { |
804 | dAllBeamParticle_P->Fill(locBeamPhotons[loc_i]->energy()); |
805 | dAllBeamParticle_Time->Fill(locBeamPhotons[loc_i]->time()); |
806 | } |
807 | } |
808 | Unlock_Action(); |
809 | |
810 | for(size_t loc_i = 0; loc_i < locMCThrowns.size(); ++loc_i) |
811 | { |
812 | locMCThrown = locMCThrowns[loc_i]; |
813 | locPID = (Particle_t)locMCThrown->type; |
814 | if(dHistMap_P.find(locPID) == dHistMap_P.end()) |
815 | continue; |
816 | |
817 | DVector3 locMomentum = locMCThrown->momentum(); |
818 | double locPhi = locMomentum.Phi()*180.0/TMath::Pi(); |
819 | double locTheta = locMomentum.Theta()*180.0/TMath::Pi(); |
820 | double locP = locMomentum.Mag(); |
821 | |
822 | |
823 | |
824 | |
825 | Lock_Action(); |
826 | { |
827 | dHistMap_P[locPID]->Fill(locP); |
828 | dHistMap_Phi[locPID]->Fill(locPhi); |
829 | dHistMap_Theta[locPID]->Fill(locTheta); |
830 | dHistMap_PVsTheta[locPID]->Fill(locTheta, locP); |
831 | dHistMap_PhiVsTheta[locPID]->Fill(locTheta, locPhi); |
832 | dHistMap_VertexZ[locPID]->Fill(locMCThrown->position().Z()); |
833 | dHistMap_VertexYVsX[locPID]->Fill(locMCThrown->position().X(), locMCThrown->position().Y()); |
834 | dHistMap_VertexT[locPID]->Fill(locMCThrown->time()); |
835 | } |
836 | Unlock_Action(); |
837 | } |
838 | return true; |
839 | } |
840 | |
841 | void DHistogramAction_ReconnedThrownKinematics::Initialize(JEventLoop* locEventLoop) |
842 | { |
843 | string locHistName, locHistTitle, locParticleName, locParticleROOTName; |
844 | Particle_t locPID; |
845 | |
846 | Run_Update(locEventLoop); |
847 | |
848 | |
849 | |
850 | japp->RootWriteLock(); |
851 | { |
852 | |
853 | CreateAndChangeTo_ActionDirectory(); |
854 | |
855 | |
856 | locPID = Gamma; |
857 | locParticleName = string("Beam_") + ParticleType(locPID); |
858 | locParticleROOTName = ParticleName_ROOT(locPID); |
859 | CreateAndChangeTo_Directory(locParticleName, locParticleName); |
860 | |
861 | locHistName = "Momentum"; |
862 | locHistTitle = string("Thrown Beam ") + locParticleROOTName + string(";p (GeV/c)"); |
863 | dBeamParticle_P = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumPBins, dMinP, dMaxP); |
864 | gDirectory->cd(".."); |
865 | |
866 | |
867 | CreateAndChangeTo_Directory("PID", "PID"); |
868 | { |
869 | |
870 | locHistName = "BetaVsP_Q+"; |
871 | locHistTitle = "q^{+};p (GeV/c);#beta"; |
872 | dHistMap_QBetaVsP[1] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DPBins, dMinP, dMaxP, dNumBetaBins, dMinBeta, dMaxBeta); |
873 | |
874 | locHistName = "BetaVsP_Q-"; |
875 | locHistTitle = "q^{-};p (GeV/c);#beta"; |
876 | dHistMap_QBetaVsP[-1] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DPBins, dMinP, dMaxP, dNumBetaBins, dMinBeta, dMaxBeta); |
877 | } |
878 | gDirectory->cd(".."); |
879 | |
880 | for(size_t loc_i = 0; loc_i < dFinalStatePIDs.size(); ++loc_i) |
881 | { |
882 | locPID = dFinalStatePIDs[loc_i]; |
883 | locParticleName = ParticleType(locPID); |
884 | locParticleROOTName = ParticleName_ROOT(locPID); |
885 | CreateAndChangeTo_Directory(locParticleName, locParticleName); |
886 | |
887 | |
888 | locHistName = "Momentum"; |
889 | locHistTitle = string("Thrown ") + locParticleROOTName + string(";p (GeV/c)"); |
890 | dHistMap_P[locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumPBins, dMinP, dMaxP); |
891 | |
892 | |
893 | locHistName = "Theta"; |
894 | locHistTitle = string("Thrown ") + locParticleROOTName + string(";#theta#circ"); |
895 | dHistMap_Theta[locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumThetaBins, dMinTheta, dMaxTheta); |
896 | |
897 | |
898 | locHistName = "Phi"; |
899 | locHistTitle = string("Thrown ") + locParticleROOTName + string(";#phi#circ"); |
900 | dHistMap_Phi[locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumPhiBins, dMinPhi, dMaxPhi); |
901 | |
902 | |
903 | locHistName = "PVsTheta"; |
904 | locHistTitle = string("Thrown ") + locParticleROOTName + string(";#theta#circ;p (GeV/c)"); |
905 | dHistMap_PVsTheta[locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DThetaBins, dMinTheta, dMaxTheta, dNum2DPBins, dMinP, dMaxP); |
906 | |
907 | |
908 | locHistName = "PhiVsTheta"; |
909 | locHistTitle = string("Thrown ") + locParticleROOTName + string(";#theta#circ;#phi#circ"); |
910 | dHistMap_PhiVsTheta[locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DThetaBins, dMinTheta, dMaxTheta, dNum2DPhiBins, dMinPhi, dMaxPhi); |
911 | |
912 | |
913 | locHistName = "VertexZ"; |
914 | locHistTitle = string("Thrown ") + locParticleROOTName + string(";Vertex-Z (cm)"); |
915 | dHistMap_VertexZ[locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumVertexZBins, dMinVertexZ, dMaxVertexZ); |
916 | |
917 | |
918 | locHistName = "VertexYVsX"; |
919 | locHistTitle = string("Thrown ") + locParticleROOTName + string(";Vertex-X (cm);Vertex-Y (cm)"); |
920 | dHistMap_VertexYVsX[locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNumVertexXYBins, dMinVertexXY, dMaxVertexXY, dNumVertexXYBins, dMinVertexXY, dMaxVertexXY); |
921 | |
922 | |
923 | locHistName = "VertexT"; |
924 | locHistTitle = string("Thrown ") + locParticleROOTName + string(";Vertex-T (ns)"); |
925 | dHistMap_VertexT[locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumTBins, dMinT, dMaxT); |
926 | |
927 | gDirectory->cd(".."); |
928 | } |
929 | |
930 | |
931 | ChangeTo_BaseDirectory(); |
932 | } |
933 | japp->RootUnLock(); |
934 | } |
935 | |
936 | void DHistogramAction_ReconnedThrownKinematics::Run_Update(JEventLoop* locEventLoop) |
937 | { |
938 | const DAnalysisUtilities* locAnalysisUtilities = NULL; |
939 | locEventLoop->GetSingle(locAnalysisUtilities); |
940 | dAnalysisUtilities = locAnalysisUtilities; |
941 | } |
942 | |
943 | bool DHistogramAction_ReconnedThrownKinematics::Perform_Action(JEventLoop* locEventLoop, const DParticleCombo* locParticleCombo) |
944 | { |
945 | vector<const DMCThrown*> locMCThrowns, locMCThrowns_Decaying; |
946 | locEventLoop->Get(locMCThrowns, "FinalState"); |
947 | locEventLoop->Get(locMCThrowns_Decaying, "Decaying"); |
948 | locMCThrowns.insert(locMCThrowns.begin(), locMCThrowns_Decaying.begin(), locMCThrowns_Decaying.end()); |
949 | if(locMCThrowns.empty()) |
950 | return true; |
951 | |
952 | if(Get_CalledPriorWithComboFlag()) |
953 | return true; |
954 | |
955 | const DMCThrownMatching* locMCThrownMatching = NULL; |
956 | locEventLoop->GetSingle(locMCThrownMatching); |
957 | |
958 | vector<const DBeamPhoton*> locBeamPhotons; |
959 | locEventLoop->Get(locBeamPhotons); |
960 | |
961 | |
962 | |
963 | |
964 | Lock_Action(); |
965 | { |
966 | for(size_t loc_i = 0; loc_i < locBeamPhotons.size(); ++loc_i) |
967 | dBeamParticle_P->Fill(locBeamPhotons[loc_i]->energy()); |
968 | } |
969 | Unlock_Action(); |
970 | |
971 | for(size_t loc_i = 0; loc_i < locMCThrowns.size(); ++loc_i) |
972 | { |
973 | const DMCThrown* locMCThrown = locMCThrowns[loc_i]; |
974 | Particle_t locPID = (Particle_t)locMCThrown->type; |
975 | |
976 | double locMatchFOM = 0.0; |
977 | double locBeta_Timing = 0.0; |
978 | if(ParticleCharge(locPID) != 0) |
979 | { |
980 | const DChargedTrackHypothesis* locChargedTrackHypothesis = locMCThrownMatching->Get_MatchingChargedHypothesis(locMCThrown, locMatchFOM); |
981 | if(locChargedTrackHypothesis == NULL) |
982 | continue; |
983 | locBeta_Timing = locChargedTrackHypothesis->measuredBeta(); |
984 | } |
985 | else |
986 | { |
987 | const DNeutralParticleHypothesis* locNeutralParticleHypothesis = locMCThrownMatching->Get_MatchingNeutralHypothesis(locMCThrown, locMatchFOM); |
988 | if(locNeutralParticleHypothesis == NULL) |
989 | continue; |
990 | locBeta_Timing = locNeutralParticleHypothesis->measuredBeta(); |
991 | } |
992 | |
993 | DVector3 locMomentum = locMCThrown->momentum(); |
994 | double locPhi = locMomentum.Phi()*180.0/TMath::Pi(); |
995 | double locTheta = locMomentum.Theta()*180.0/TMath::Pi(); |
996 | double locP = locMomentum.Mag(); |
997 | int locCharge = ParticleCharge(locPID); |
998 | |
999 | |
1000 | |
1001 | |
1002 | Lock_Action(); |
1003 | { |
1004 | if(dHistMap_QBetaVsP.find(locCharge) != dHistMap_QBetaVsP.end()) |
1005 | dHistMap_QBetaVsP[locCharge]->Fill(locP, locBeta_Timing); |
1006 | if(dHistMap_P.find(locPID) != dHistMap_P.end()) |
1007 | { |
1008 | dHistMap_P[locPID]->Fill(locP); |
1009 | dHistMap_Phi[locPID]->Fill(locPhi); |
1010 | dHistMap_Theta[locPID]->Fill(locTheta); |
1011 | dHistMap_PVsTheta[locPID]->Fill(locTheta, locP); |
1012 | dHistMap_PhiVsTheta[locPID]->Fill(locTheta, locPhi); |
1013 | dHistMap_VertexZ[locPID]->Fill(locMCThrown->position().Z()); |
1014 | dHistMap_VertexYVsX[locPID]->Fill(locMCThrown->position().X(), locMCThrown->position().Y()); |
1015 | dHistMap_VertexT[locPID]->Fill(locMCThrown->time()); |
1016 | } |
1017 | } |
1018 | Unlock_Action(); |
1019 | } |
1020 | return true; |
1021 | } |
1022 | |
1023 | void DHistogramAction_GenReconTrackComparison::Initialize(JEventLoop* locEventLoop) |
1024 | { |
1025 | string locHistName, locHistTitle, locParticleName, locParticleROOTName; |
1026 | Particle_t locPID; |
1027 | |
1028 | Run_Update(locEventLoop); |
1029 | |
1030 | |
1031 | |
1032 | japp->RootWriteLock(); |
1033 | { |
1034 | CreateAndChangeTo_ActionDirectory(); |
1035 | |
1036 | locHistName = "DeltaT_RFBeamBunch"; |
1037 | dRFBeamBunchDeltaT_Hist = GetOrCreate_Histogram<TH1I>(locHistName, ";RF #Deltat (Reconstructed - Thrown)", dNumRFDeltaTBins, dMinRFDeltaT, dMaxRFDeltaT); |
1038 | |
1039 | deque<string> locPullNames(8, ""); |
1040 | locPullNames[0] = "E"; locPullNames[1] = "Px"; locPullNames[2] = "Py"; locPullNames[3] = "Pz"; |
1041 | locPullNames[4] = "Xx"; locPullNames[5] = "Xy"; locPullNames[6] = "Xz"; locPullNames[7] = "T"; |
1042 | |
1043 | deque<string> locPullTitles(8, ""); |
1044 | locPullTitles[0] = "E"; locPullTitles[1] = "p_{x}"; locPullTitles[2] = "p_{y}"; locPullTitles[3] = "p_{z}"; |
1045 | locPullTitles[4] = "x_{x}"; locPullTitles[5] = "x_{y}"; locPullTitles[6] = "x_{z}"; locPullTitles[7] = "t"; |
1046 | |
1047 | for(size_t loc_i = 0; loc_i < dFinalStatePIDs.size(); ++loc_i) |
1048 | { |
1049 | locPID = dFinalStatePIDs[loc_i]; |
1050 | locParticleName = ParticleType(locPID); |
1051 | locParticleROOTName = ParticleName_ROOT(locPID); |
1052 | CreateAndChangeTo_Directory(locParticleName, locParticleName); |
1053 | |
1054 | |
1055 | locHistName = string("MatchFOM"); |
1056 | locHistTitle = locParticleROOTName + string(";Thrown/Reconstructed Matching FOM"); |
1057 | dHistMap_MatchFOM[locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumMCMatchingFOMBins, 0.0, 1.0); |
1058 | |
1059 | |
1060 | locHistName = string("DeltaPOverP"); |
1061 | locHistTitle = locParticleROOTName + string(";#Deltap/p (Reconstructed - Thrown)"); |
1062 | dHistMap_DeltaPOverP[locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumDeltaPOverPBins, dMinDeltaPOverP, dMaxDeltaPOverP); |
1063 | |
1064 | |
1065 | locHistName = string("DeltaTheta"); |
1066 | locHistTitle = locParticleROOTName + string(";#Delta#theta#circ (Reconstructed - Thrown)"); |
1067 | dHistMap_DeltaTheta[locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumDeltaThetaBins, dMinDeltaTheta, dMaxDeltaTheta); |
1068 | |
1069 | |
1070 | locHistName = string("DeltaPhi"); |
1071 | locHistTitle = locParticleROOTName + string(";#Delta#phi#circ (Reconstructed - Thrown)"); |
1072 | dHistMap_DeltaPhi[locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumDeltaPhiBins, dMinDeltaPhi, dMaxDeltaPhi); |
1073 | |
1074 | |
1075 | locHistName = string("DeltaT"); |
1076 | locHistTitle = locParticleROOTName + string(";#Deltat (ns) (Reconstructed - Thrown)"); |
1077 | dHistMap_DeltaT[locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumDeltaTBins, dMinDeltaT, dMaxDeltaT); |
1078 | |
1079 | |
1080 | locHistName = string("DeltaT_BCAL"); |
1081 | locHistTitle = locParticleROOTName + string(" in BCAL;#Deltat (ns) (Reconstructed - Thrown)"); |
1082 | dHistMap_DeltaT_BCAL[locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumDeltaTBins, dMinDeltaT, dMaxDeltaT); |
1083 | |
1084 | |
1085 | if(ParticleCharge(locPID) != 0) |
1086 | { |
1087 | locHistName = string("DeltaT_TOF"); |
1088 | locHistTitle = locParticleROOTName + string(" in TOF;#Deltat (ns) (Reconstructed - Thrown)"); |
1089 | dHistMap_DeltaT_TOF[locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumDeltaTBins, dMinDeltaT, dMaxDeltaT); |
1090 | } |
1091 | |
1092 | |
1093 | if(ParticleCharge(locPID) == 0) |
1094 | { |
1095 | locHistName = string("DeltaT_FCAL"); |
1096 | locHistTitle = locParticleROOTName + string(" in FCAL;#Deltat (ns) (Reconstructed - Thrown)"); |
1097 | dHistMap_DeltaT_FCAL[locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumDeltaTBins, dMinDeltaT, dMaxDeltaT); |
1098 | } |
1099 | |
1100 | |
1101 | locHistName = string("DeltaVertexZ"); |
1102 | locHistTitle = locParticleROOTName + string(";#DeltaVertex-Z (cm) (Reconstructed - Thrown)"); |
1103 | dHistMap_DeltaVertexZ[locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumDeltaVertexZBins, dMinDeltaVertexZ, dMaxDeltaVertexZ); |
1104 | |
1105 | |
1106 | locHistName = string("DeltaPOverPVsP"); |
1107 | locHistTitle = locParticleROOTName + string(";p (GeV/c);#Deltap/p (Reconstructed - Thrown)"); |
1108 | dHistMap_DeltaPOverPVsP[locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DPBins, dMinP, dMaxP, dNumDeltaPOverPBins, dMinDeltaPOverP, dMaxDeltaPOverP); |
1109 | |
1110 | |
1111 | locHistName = string("DeltaPOverPVsTheta"); |
1112 | locHistTitle = locParticleROOTName + string(";#theta#circ;#Deltap/p (Reconstructed - Thrown)"); |
1113 | dHistMap_DeltaPOverPVsTheta[locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DThetaBins, dMinTheta, dMaxTheta, dNumDeltaPOverPBins, dMinDeltaPOverP, dMaxDeltaPOverP); |
1114 | |
1115 | |
1116 | locHistName = string("DeltaThetaVsP"); |
1117 | locHistTitle = locParticleROOTName + string(";p (GeV/c);#Delta#theta#circ (Reconstructed - Thrown)"); |
1118 | dHistMap_DeltaThetaVsP[locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DPBins, dMinP, dMaxP, dNumDeltaThetaBins, dMinDeltaTheta, dMaxDeltaTheta); |
1119 | |
1120 | |
1121 | locHistName = string("DeltaThetaVsTheta"); |
1122 | locHistTitle = locParticleROOTName + string(";#theta#circ;#Delta#theta#circ (Reconstructed - Thrown)"); |
1123 | dHistMap_DeltaThetaVsTheta[locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DThetaBins, dMinTheta, dMaxTheta, dNumDeltaThetaBins, dMinDeltaTheta, dMaxDeltaTheta); |
1124 | |
1125 | |
1126 | locHistName = string("DeltaPhiVsP"); |
1127 | locHistTitle = locParticleROOTName + string(";p (GeV/c);#Delta#phi#circ (Reconstructed - Thrown)"); |
1128 | dHistMap_DeltaPhiVsP[locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DPBins, dMinP, dMaxP, dNumDeltaPhiBins, dMinDeltaPhi, dMaxDeltaPhi); |
1129 | |
1130 | |
1131 | locHistName = string("DeltaPhiVsTheta"); |
1132 | locHistTitle = locParticleROOTName + string(";#theta#circ;#Delta#phi#circ (Reconstructed - Thrown)"); |
1133 | dHistMap_DeltaPhiVsTheta[locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DThetaBins, dMinTheta, dMaxTheta, dNumDeltaPhiBins, dMinDeltaPhi, dMaxDeltaPhi); |
1134 | |
1135 | |
1136 | locHistName = string("DeltaTVsTheta"); |
1137 | locHistTitle = locParticleROOTName + string(";#theta#circ;#Deltat (ns) (Reconstructed - Thrown)"); |
1138 | dHistMap_DeltaTVsTheta[locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DThetaBins, dMinTheta, dMaxTheta, dNumDeltaTBins, dMinDeltaT, dMaxDeltaT); |
1139 | |
1140 | |
1141 | locHistName = string("DeltaTVsP"); |
1142 | locHistTitle = locParticleROOTName + string(";p (GeV/c);#Deltat (ns) (Reconstructed - Thrown)"); |
1143 | dHistMap_DeltaTVsP[locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DPBins, dMinP, dMaxP, dNumDeltaTBins, dMinDeltaT, dMaxDeltaT); |
1144 | |
1145 | |
1146 | locHistName = string("DeltaVertexZVsTheta"); |
1147 | locHistTitle = locParticleROOTName + string(";#theta#circ;#DeltaVertex-Z (cm) (Reconstructed - Thrown)"); |
1148 | dHistMap_DeltaVertexZVsTheta[locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DThetaBins, dMinTheta, dMaxTheta, dNumDeltaVertexZBins, dMinDeltaVertexZ, dMaxDeltaVertexZ); |
1149 | |
1150 | |
1151 | locHistName = "PVsTheta_LargeDeltaT"; |
1152 | locHistTitle = locParticleROOTName + string(";#theta#circ;p (GeV/c)"); |
1153 | dHistMap_PVsTheta_LargeDeltaT[locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DThetaBins, dMinTheta, dMaxTheta, dNum2DPBins, dMinP, dMaxP); |
1154 | |
1155 | |
1156 | |
1157 | CreateAndChangeTo_Directory("Pulls", "Pulls"); |
1158 | for(size_t loc_j = 0; loc_j < dPullTypes.size(); ++loc_j) |
1159 | { |
1160 | if((ParticleCharge(locPID) != 0) && (dPullTypes[loc_j] == d_EPull)) |
1161 | continue; |
1162 | if((ParticleCharge(locPID) == 0) && ((dPullTypes[loc_j] >= d_PxPull) && (dPullTypes[loc_j] <= d_PzPull))) |
1163 | continue; |
1164 | |
1165 | |
1166 | locHistName = locPullNames[loc_j] + string("Pull"); |
1167 | locHistTitle = locParticleROOTName + string(";#Delta") + locPullTitles[loc_j] + string("/#sigma_{") + locPullTitles[loc_j] + string("} (Reconstructed - Thrown)"); |
1168 | dHistMap_Pulls[locPID][dPullTypes[loc_j]] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumPullBins, -10.0, 10.0); |
1169 | |
1170 | |
1171 | locHistName = locPullNames[loc_j] + string("PullVsP"); |
1172 | locHistTitle = locParticleROOTName + string(";p (GeV/c);#Delta") + locPullTitles[loc_j] + string("/#sigma_{") + locPullTitles[loc_j] + string("} (Reconstructed - Thrown)"); |
1173 | dHistMap_PullsVsP[locPID][dPullTypes[loc_j]] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DPBins, dMinP, dMaxP, dNum2DPullBins, -10.0, 10.0); |
1174 | |
1175 | |
1176 | locHistName = locPullNames[loc_j] + string("PullVsTheta"); |
1177 | locHistTitle = locParticleROOTName + string(";#theta#circ;#Delta") + locPullTitles[loc_j] + string("/#sigma_{") + locPullTitles[loc_j] + string("} (Reconstructed - Thrown)"); |
1178 | dHistMap_PullsVsTheta[locPID][dPullTypes[loc_j]] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DThetaBins, dMinTheta, dMaxTheta, dNum2DPullBins, -10.0, 10.0); |
1179 | } |
1180 | |
1181 | |
1182 | if(ParticleCharge(locPID) != 0) |
1183 | { |
1184 | |
1185 | locHistName = "TimePull_CDC"; |
1186 | locHistTitle = locParticleROOTName + string(";#Deltat/#sigma_{#Deltat}"); |
1187 | dHistMap_TimePull_CDC[locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumPullBins, -10.0, 10.0); |
1188 | |
1189 | locHistName = "TimePullVsTheta_CDC"; |
1190 | locHistTitle = locParticleROOTName + string(";#theta#circ;#Deltat/#sigma_{#Deltat}"); |
1191 | dHistMap_TimePullVsTheta_CDC[locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DThetaBins, dMinTheta, dMaxTheta, dNum2DPullBins, -10.0, 10.0); |
1192 | |
1193 | locHistName = "TimePullVsP_CDC"; |
1194 | locHistTitle = locParticleROOTName + string(";p (GeV/c);#Deltat/#sigma_{#Deltat}"); |
1195 | dHistMap_TimePullVsP_CDC[locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DPBins, dMinP, dMaxP, dNum2DPullBins, -10.0, 10.0); |
1196 | |
1197 | |
1198 | locHistName = "TimePull_ST"; |
1199 | locHistTitle = locParticleROOTName + string(";#Deltat/#sigma_{#Deltat}"); |
1200 | dHistMap_TimePull_ST[locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumPullBins, -10.0, 10.0); |
1201 | |
1202 | locHistName = "TimePullVsTheta_ST"; |
1203 | locHistTitle = locParticleROOTName + string(";#theta#circ;#Deltat/#sigma_{#Deltat}"); |
1204 | dHistMap_TimePullVsTheta_ST[locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DThetaBins, dMinTheta, dMaxTheta, dNum2DPullBins, -10.0, 10.0); |
1205 | |
1206 | locHistName = "TimePullVsP_ST"; |
1207 | locHistTitle = locParticleROOTName + string(";p (GeV/c);#Deltat/#sigma_{#Deltat}"); |
1208 | dHistMap_TimePullVsP_ST[locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DPBins, dMinP, dMaxP, dNum2DPullBins, -10.0, 10.0); |
1209 | } |
1210 | |
1211 | |
1212 | locHistName = "TimePull_BCAL"; |
1213 | locHistTitle = locParticleROOTName + string(";#Deltat/#sigma_{#Deltat}"); |
1214 | dHistMap_TimePull_BCAL[locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumPullBins, -10.0, 10.0); |
1215 | |
1216 | locHistName = "TimePullVsTheta_BCAL"; |
1217 | locHistTitle = locParticleROOTName + string(";#theta#circ;#Deltat/#sigma_{#Deltat}"); |
1218 | dHistMap_TimePullVsTheta_BCAL[locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DThetaBins, dMinTheta, dMaxTheta, dNum2DPullBins, -10.0, 10.0); |
1219 | |
1220 | locHistName = "TimePullVsP_BCAL"; |
1221 | locHistTitle = locParticleROOTName + string(";p (GeV/c);#Deltat/#sigma_{#Deltat}"); |
1222 | dHistMap_TimePullVsP_BCAL[locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DPBins, dMinP, dMaxP, dNum2DPullBins, -10.0, 10.0); |
1223 | |
1224 | |
1225 | if(ParticleCharge(locPID) != 0) |
1226 | { |
1227 | locHistName = "TimePull_TOF"; |
1228 | locHistTitle = locParticleROOTName + string(";#Deltat/#sigma_{#Deltat}"); |
1229 | dHistMap_TimePull_TOF[locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumPullBins, -10.0, 10.0); |
1230 | |
1231 | locHistName = "TimePullVsP_TOF"; |
1232 | locHistTitle = locParticleROOTName + string(";p (GeV/c);#Deltat/#sigma_{#Deltat}"); |
1233 | dHistMap_TimePullVsP_TOF[locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DPBins, dMinP, dMaxP, dNum2DPullBins, -10.0, 10.0); |
1234 | } |
1235 | |
1236 | |
1237 | locHistName = "TimePull_FCAL"; |
1238 | locHistTitle = locParticleROOTName + string(";#Deltat/#sigma_{#Deltat}"); |
1239 | dHistMap_TimePull_FCAL[locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumPullBins, -10.0, 10.0); |
1240 | |
1241 | locHistName = "TimePullVsP_FCAL"; |
1242 | locHistTitle = locParticleROOTName + string(";p (GeV/c);#Deltat/#sigma_{#Deltat}"); |
1243 | dHistMap_TimePullVsP_FCAL[locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNum2DPBins, dMinP, dMaxP, dNum2DPullBins, -10.0, 10.0); |
1244 | |
1245 | gDirectory->cd(".."); |
1246 | |
1247 | gDirectory->cd(".."); |
1248 | } |
1249 | |
1250 | |
1251 | ChangeTo_BaseDirectory(); |
1252 | } |
1253 | japp->RootUnLock(); |
1254 | } |
1255 | |
1256 | void DHistogramAction_GenReconTrackComparison::Run_Update(JEventLoop* locEventLoop) |
1257 | { |
1258 | DApplication* locApplication = dynamic_cast<DApplication*>(locEventLoop->GetJApplication()); |
1259 | DGeometry *locGeometry = locApplication->GetDGeometry(locEventLoop->GetJEvent().GetRunNumber()); |
1260 | locGeometry->GetTargetZ(dTargetZCenter); |
1261 | } |
1262 | |
1263 | bool DHistogramAction_GenReconTrackComparison::Perform_Action(JEventLoop* locEventLoop, const DParticleCombo* locParticleCombo) |
1264 | { |
1265 | vector<const DMCThrown*> locMCThrowns; |
1266 | locEventLoop->Get(locMCThrowns); |
1267 | if(locMCThrowns.empty()) |
1268 | return true; |
1269 | |
1270 | if(Get_CalledPriorWithComboFlag()) |
1271 | return true; |
1272 | |
1273 | Particle_t locPID; |
1274 | double locDeltaPOverP, locDeltaTheta, locDeltaPhi, locDeltaVertexZ; |
1275 | double locThrownP, locThrownTheta, locDeltaT; |
1276 | |
1277 | vector<const DMCThrownMatching*> locMCThrownMatchingVector; |
1278 | locEventLoop->Get(locMCThrownMatchingVector); |
1279 | if(locMCThrownMatchingVector.empty()) |
1280 | return true; |
1281 | const DMCThrownMatching* locMCThrownMatching = locMCThrownMatchingVector[0]; |
1282 | |
1283 | const DEventRFBunch* locThrownEventRFBunch = NULL; |
1284 | locEventLoop->GetSingle(locThrownEventRFBunch, "Thrown"); |
1285 | |
1286 | |
1287 | vector<const DEventRFBunch*> locEventRFBunches; |
1288 | locEventLoop->Get(locEventRFBunches); |
1289 | const DEventRFBunch* locEventRFBunch = locEventRFBunches[0]; |
1290 | double locRFTime = locEventRFBunch->dTime; |
1291 | double locRFDeltaT = locRFTime - locThrownEventRFBunch->dTime; |
1292 | |
1293 | |
1294 | |
1295 | |
1296 | Lock_Action(); |
1297 | { |
1298 | dRFBeamBunchDeltaT_Hist->Fill(locRFDeltaT); |
1299 | } |
1300 | Unlock_Action(); |
1301 | |
1302 | |
1303 | map<const DMCThrown*, pair<const DChargedTrack*, double> > locThrownToChargedMap; |
1304 | locMCThrownMatching->Get_ThrownToChargedMap(locThrownToChargedMap); |
1305 | map<const DMCThrown*, pair<const DChargedTrack*, double> >::iterator locChargedIterator = locThrownToChargedMap.begin(); |
1306 | for(; locChargedIterator != locThrownToChargedMap.end(); ++locChargedIterator) |
1307 | { |
1308 | const DMCThrown* locMCThrown = locChargedIterator->first; |
1309 | locPID = (Particle_t)locMCThrown->type; |
1310 | if(dHistMap_DeltaPOverP.find(locPID) == dHistMap_DeltaPOverP.end()) |
1311 | continue; |
1312 | |
1313 | double locMatchFOM = locChargedIterator->second.second; |
1314 | const DChargedTrackHypothesis* locChargedTrackHypothesis = locChargedIterator->second.first->Get_Hypothesis(locPID); |
1315 | if(locChargedTrackHypothesis == NULL) |
1316 | locChargedTrackHypothesis = locChargedIterator->second.first->Get_BestFOM(); |
1317 | |
1318 | locThrownP = locMCThrown->momentum().Mag(); |
1319 | locThrownTheta = locMCThrown->momentum().Theta()*180.0/TMath::Pi(); |
1320 | locDeltaPOverP = (locChargedTrackHypothesis->momentum().Mag() - locThrownP)/locThrownP; |
1321 | locDeltaTheta = locChargedTrackHypothesis->momentum().Theta()*180.0/TMath::Pi() - locThrownTheta; |
1322 | locDeltaPhi = locChargedTrackHypothesis->momentum().Phi()*180.0/TMath::Pi() - locMCThrown->momentum().Phi()*180.0/TMath::Pi(); |
1323 | locDeltaT = locChargedTrackHypothesis->time() - locMCThrown->time(); |
1324 | locDeltaVertexZ = locChargedTrackHypothesis->position().Z() - locMCThrown->position().Z(); |
1325 | const TMatrixDSym& locCovarianceMatrix = *(locChargedTrackHypothesis->errorMatrix().get()); |
1326 | |
1327 | const DTrackTimeBased* locTrackTimeBased = locChargedTrackHypothesis->Get_TrackTimeBased(); |
1328 | |
1329 | double locStartTime = locThrownEventRFBunch->dTime + (locMCThrown->z() - dTargetZCenter)/29.9792458; |
1330 | double locTimePull = (locStartTime - locChargedTrackHypothesis->time())/sqrt(locCovarianceMatrix(6, 6)); |
1331 | double locT0Pull = (locStartTime - locChargedTrackHypothesis->t0())/locChargedTrackHypothesis->t0_err(); |
1332 | |
1333 | |
1334 | |
1335 | |
1336 | Lock_Action(); |
1337 | { |
1338 | dHistMap_MatchFOM[locPID]->Fill(locMatchFOM); |
1339 | dHistMap_DeltaPOverP[locPID]->Fill(locDeltaPOverP); |
1340 | dHistMap_DeltaTheta[locPID]->Fill(locDeltaTheta); |
1341 | dHistMap_DeltaPhi[locPID]->Fill(locDeltaPhi); |
1342 | dHistMap_DeltaT[locPID]->Fill(locDeltaT); |
1343 | if(locChargedTrackHypothesis->t0_detector() == SYS_START) |
1344 | { |
1345 | dHistMap_TimePull_ST[locPID]->Fill(locT0Pull); |
1346 | dHistMap_TimePullVsTheta_ST[locPID]->Fill(locThrownTheta, locT0Pull); |
1347 | dHistMap_TimePullVsP_ST[locPID]->Fill(locThrownP, locT0Pull); |
1348 | } |
1349 | if(locChargedTrackHypothesis->t0_detector() == SYS_CDC) |
1350 | { |
1351 | dHistMap_TimePull_CDC[locPID]->Fill(locT0Pull); |
1352 | dHistMap_TimePullVsTheta_CDC[locPID]->Fill(locThrownTheta, locT0Pull); |
1353 | dHistMap_TimePullVsP_CDC[locPID]->Fill(locThrownP, locT0Pull); |
1354 | } |
1355 | else if(locChargedTrackHypothesis->t1_detector() == SYS_CDC) |
1356 | { |
1357 | dHistMap_TimePull_CDC[locPID]->Fill(locTimePull); |
1358 | dHistMap_TimePullVsTheta_CDC[locPID]->Fill(locThrownTheta, locTimePull); |
1359 | dHistMap_TimePullVsP_CDC[locPID]->Fill(locThrownP, locTimePull); |
1360 | } |
1361 | if(locChargedTrackHypothesis->t1_detector() == SYS_BCAL) |
1362 | { |
1363 | dHistMap_DeltaT_BCAL[locPID]->Fill(locDeltaT); |
1364 | dHistMap_TimePull_BCAL[locPID]->Fill(locTimePull); |
1365 | dHistMap_TimePullVsTheta_BCAL[locPID]->Fill(locThrownTheta, locTimePull); |
1366 | dHistMap_TimePullVsP_BCAL[locPID]->Fill(locThrownP, locTimePull); |
1367 | } |
1368 | else if(locChargedTrackHypothesis->t1_detector() == SYS_TOF) |
1369 | { |
1370 | dHistMap_DeltaT_TOF[locPID]->Fill(locDeltaT); |
1371 | dHistMap_TimePull_TOF[locPID]->Fill(locTimePull); |
1372 | dHistMap_TimePullVsP_TOF[locPID]->Fill(locThrownP, locTimePull); |
1373 | } |
1374 | else if(locChargedTrackHypothesis->t1_detector() == SYS_FCAL) |
1375 | { |
1376 | dHistMap_TimePull_FCAL[locPID]->Fill(locTimePull); |
1377 | dHistMap_TimePullVsP_FCAL[locPID]->Fill(locThrownP, locTimePull); |
1378 | } |
1379 | dHistMap_DeltaVertexZ[locPID]->Fill(locDeltaVertexZ); |
1380 | dHistMap_DeltaPOverPVsP[locPID]->Fill(locThrownP, locDeltaPOverP); |
1381 | dHistMap_DeltaPOverPVsTheta[locPID]->Fill(locThrownTheta, locDeltaPOverP); |
1382 | dHistMap_DeltaThetaVsP[locPID]->Fill(locThrownP, locDeltaTheta); |
1383 | dHistMap_DeltaThetaVsTheta[locPID]->Fill(locThrownTheta, locDeltaTheta); |
1384 | dHistMap_DeltaPhiVsP[locPID]->Fill(locThrownP, locDeltaPhi); |
1385 | dHistMap_DeltaPhiVsTheta[locPID]->Fill(locThrownTheta, locDeltaPhi); |
1386 | dHistMap_DeltaTVsTheta[locPID]->Fill(locThrownTheta, locDeltaT); |
1387 | dHistMap_DeltaTVsP[locPID]->Fill(locThrownP, locDeltaT); |
1388 | dHistMap_DeltaVertexZVsTheta[locPID]->Fill(locThrownTheta, locDeltaVertexZ); |
1389 | if((locTrackTimeBased->FOM > 0.01) && (locDeltaT >= 1.002)) |
1390 | dHistMap_PVsTheta_LargeDeltaT[locPID]->Fill(locThrownTheta, locThrownP); |
1391 | |
1392 | for(size_t loc_j = 0; loc_j < dPullTypes.size(); ++loc_j) |
1393 | { |
1394 | if(dPullTypes[loc_j] == d_EPull) |
1395 | continue; |
1396 | double locPull = 0.0; |
1397 | if((dPullTypes[loc_j] >= d_PxPull) && (dPullTypes[loc_j] <= d_PzPull)) |
1398 | { |
1399 | int locIndex = int(dPullTypes[loc_j] - d_PxPull); |
1400 | locPull = (locChargedTrackHypothesis->momentum()(locIndex) - locMCThrown->momentum()(locIndex))/sqrt(locCovarianceMatrix(locIndex, locIndex)); |
1401 | } |
1402 | else if((dPullTypes[loc_j] >= d_XxPull) && (dPullTypes[loc_j] <= d_XzPull)) |
1403 | { |
1404 | int locIndex = int(dPullTypes[loc_j] - d_XxPull); |
1405 | locPull = (locChargedTrackHypothesis->position()(locIndex) - locMCThrown->position()(locIndex))/sqrt(locCovarianceMatrix(locIndex + 3, locIndex + 3)); |
1406 | } |
1407 | else if(dPullTypes[loc_j] == d_TPull) |
1408 | locPull = (locChargedTrackHypothesis->time() - locMCThrown->time())/sqrt(locCovarianceMatrix(6, 6)); |
1409 | (dHistMap_Pulls[locPID])[dPullTypes[loc_j]]->Fill(locPull); |
1410 | (dHistMap_PullsVsP[locPID])[dPullTypes[loc_j]]->Fill(locThrownP, locPull); |
1411 | (dHistMap_PullsVsTheta[locPID])[dPullTypes[loc_j]]->Fill(locThrownTheta, locPull); |
1412 | } |
1413 | } |
1414 | Unlock_Action(); |
1415 | } |
1416 | |
1417 | |
1418 | map<const DMCThrown*, pair<const DNeutralParticle*, double> > locThrownToNeutralMap; |
1419 | locMCThrownMatching->Get_ThrownToNeutralMap(locThrownToNeutralMap); |
1420 | map<const DMCThrown*, pair<const DNeutralParticle*, double> >::iterator locNeutralIterator = locThrownToNeutralMap.begin(); |
1421 | for(; locNeutralIterator != locThrownToNeutralMap.end(); ++locNeutralIterator) |
1422 | { |
1423 | const DMCThrown* locMCThrown = locNeutralIterator->first; |
1424 | locPID = (Particle_t)locMCThrown->type; |
1425 | if(dHistMap_DeltaPOverP.find(locPID) == dHistMap_DeltaPOverP.end()) |
1426 | continue; |
1427 | |
1428 | double locMatchFOM = locNeutralIterator->second.second; |
1429 | const DNeutralParticleHypothesis* locNeutralParticleHypothesis = locNeutralIterator->second.first->Get_Hypothesis(locPID); |
1430 | if(locNeutralParticleHypothesis == NULL) |
1431 | locNeutralParticleHypothesis = locNeutralIterator->second.first->Get_BestFOM(); |
1432 | |
1433 | const DNeutralShower* locNeutralShower = locNeutralParticleHypothesis->Get_NeutralShower(); |
1434 | |
1435 | locThrownP = locMCThrown->momentum().Mag(); |
1436 | locThrownTheta = locMCThrown->momentum().Theta()*180.0/TMath::Pi(); |
1437 | locDeltaPOverP = (locNeutralParticleHypothesis->momentum().Mag() - locThrownP)/locThrownP; |
1438 | locDeltaTheta = locNeutralParticleHypothesis->momentum().Theta()*180.0/TMath::Pi() - locThrownTheta; |
1439 | locDeltaPhi = locNeutralParticleHypothesis->momentum().Phi()*180.0/TMath::Pi() - locMCThrown->momentum().Phi()*180.0/TMath::Pi(); |
1440 | locDeltaT = locNeutralParticleHypothesis->time() - locMCThrown->time(); |
1441 | locDeltaVertexZ = locNeutralParticleHypothesis->position().Z() - locMCThrown->position().Z(); |
1442 | const TMatrixDSym& locCovarianceMatrix = *(locNeutralParticleHypothesis->errorMatrix().get()); |
1443 | |
1444 | double locStartTime = locThrownEventRFBunch->dTime + (locMCThrown->z() - dTargetZCenter)/29.9792458; |
1445 | double locTimePull = (locStartTime - locNeutralParticleHypothesis->time())/sqrt(locCovarianceMatrix(6, 6)); |
1446 | |
1447 | |
1448 | |
1449 | |
1450 | Lock_Action(); |
1451 | { |
1452 | dHistMap_MatchFOM[locPID]->Fill(locMatchFOM); |
1453 | dHistMap_DeltaPOverP[locPID]->Fill(locDeltaPOverP); |
1454 | dHistMap_DeltaTheta[locPID]->Fill(locDeltaTheta); |
1455 | dHistMap_DeltaPhi[locPID]->Fill(locDeltaPhi); |
1456 | dHistMap_DeltaT[locPID]->Fill(locDeltaT); |
1457 | if(locNeutralParticleHypothesis->t1_detector() == SYS_BCAL) |
1458 | { |
1459 | dHistMap_DeltaT_BCAL[locPID]->Fill(locDeltaT); |
1460 | dHistMap_TimePull_BCAL[locPID]->Fill(locTimePull); |
1461 | dHistMap_TimePullVsTheta_BCAL[locPID]->Fill(locThrownTheta, locTimePull); |
1462 | dHistMap_TimePullVsP_BCAL[locPID]->Fill(locThrownP, locTimePull); |
1463 | } |
1464 | else if(locNeutralParticleHypothesis->t1_detector() == SYS_FCAL) |
1465 | { |
1466 | dHistMap_DeltaT_FCAL[locPID]->Fill(locDeltaT); |
1467 | dHistMap_TimePull_FCAL[locPID]->Fill(locTimePull); |
1468 | dHistMap_TimePullVsP_FCAL[locPID]->Fill(locThrownP, locTimePull); |
1469 | } |
1470 | |
1471 | dHistMap_DeltaVertexZ[locPID]->Fill(locDeltaVertexZ); |
1472 | dHistMap_DeltaPOverPVsP[locPID]->Fill(locThrownP, locDeltaPOverP); |
1473 | dHistMap_DeltaPOverPVsTheta[locPID]->Fill(locThrownTheta, locDeltaPOverP); |
1474 | dHistMap_DeltaThetaVsP[locPID]->Fill(locThrownP, locDeltaTheta); |
1475 | dHistMap_DeltaThetaVsTheta[locPID]->Fill(locThrownTheta, locDeltaTheta); |
1476 | dHistMap_DeltaPhiVsP[locPID]->Fill(locThrownP, locDeltaPhi); |
1477 | dHistMap_DeltaPhiVsTheta[locPID]->Fill(locThrownTheta, locDeltaPhi); |
1478 | dHistMap_DeltaTVsTheta[locPID]->Fill(locThrownTheta, locDeltaT); |
1479 | dHistMap_DeltaTVsP[locPID]->Fill(locThrownP, locDeltaT); |
1480 | dHistMap_DeltaVertexZVsTheta[locPID]->Fill(locThrownTheta, locDeltaVertexZ); |
1481 | if(locDeltaT >= 1.002) |
1482 | dHistMap_PVsTheta_LargeDeltaT[locPID]->Fill(locThrownTheta, locThrownP); |
1483 | |
1484 | for(size_t loc_j = 0; loc_j < dPullTypes.size(); ++loc_j) |
1485 | { |
1486 | if((dPullTypes[loc_j] >= d_PxPull) && (dPullTypes[loc_j] <= d_PzPull)) |
1487 | continue; |
1488 | double locPull = 0.0; |
1489 | if(dPullTypes[loc_j] == d_EPull) |
1490 | locPull = (locNeutralShower->dEnergy - locMCThrown->energy())/sqrt((*(locNeutralShower->dCovarianceMatrix))(0, 0)); |
1491 | else if((dPullTypes[loc_j] >= d_XxPull) && (dPullTypes[loc_j] <= d_XzPull)) |
1492 | { |
1493 | int locIndex = int(dPullTypes[loc_j] - d_XxPull); |
1494 | locPull = (locNeutralParticleHypothesis->position()(locIndex) - locMCThrown->position()(locIndex))/sqrt(locCovarianceMatrix(locIndex + 3, locIndex + 3)); |
1495 | } |
1496 | else if(dPullTypes[loc_j] == d_TPull) |
1497 | locPull = (locNeutralParticleHypothesis->time() - locMCThrown->time())/sqrt(locCovarianceMatrix(6, 6)); |
1498 | (dHistMap_Pulls[locPID])[dPullTypes[loc_j]]->Fill(locPull); |
1499 | (dHistMap_PullsVsP[locPID])[dPullTypes[loc_j]]->Fill(locThrownP, locPull); |
1500 | (dHistMap_PullsVsTheta[locPID])[dPullTypes[loc_j]]->Fill(locThrownTheta, locPull); |
1501 | } |
1502 | |
1503 | } |
1504 | Unlock_Action(); |
1505 | } |
1506 | return true; |
1507 | } |
1508 | |
1509 | void DHistogramAction_TruePID::Initialize(JEventLoop* locEventLoop) |
1510 | { |
1511 | string locStepName, locStepROOTName, locHistTitle, locHistName, locParticleName, locParticleROOTName; |
1512 | |
1513 | size_t locNumSteps = Get_Reaction()->Get_NumReactionSteps(); |
1514 | dHistDeque_P_CorrectID.resize(locNumSteps); |
1515 | dHistDeque_P_IncorrectID.resize(locNumSteps); |
1516 | dHistDeque_PVsTheta_CorrectID.resize(locNumSteps); |
1517 | dHistDeque_PVsTheta_IncorrectID.resize(locNumSteps); |
1518 | |
1519 | Run_Update(locEventLoop); |
1520 | |
1521 | |
1522 | |
1523 | japp->RootWriteLock(); |
1524 | { |
1525 | CreateAndChangeTo_ActionDirectory(); |
1526 | |
1527 | for(size_t loc_i = 0; loc_i < locNumSteps; ++loc_i) |
1528 | { |
1529 | auto locDetectedPIDs = Get_Reaction()->Get_FinalPIDs(loc_i, false, false, d_AllCharges, false); |
1530 | if(locDetectedPIDs.empty()) |
1531 | continue; |
1532 | |
1533 | const DReactionStep* locReactionStep = Get_Reaction()->Get_ReactionStep(loc_i); |
1534 | locStepName = DAnalysis::Get_StepName(locReactionStep, true, false); |
1535 | locStepROOTName = DAnalysis::Get_StepName(locReactionStep, true, true); |
1536 | CreateAndChangeTo_Directory(locStepName, locStepName); |
1537 | |
1538 | for(auto locPID : locDetectedPIDs) |
1539 | { |
1540 | locParticleName = ParticleType(locPID); |
1541 | locParticleROOTName = ParticleName_ROOT(locPID); |
1542 | |
1543 | if(dHistDeque_P_CorrectID[loc_i].find(locPID) != dHistDeque_P_CorrectID[loc_i].end()) |
1544 | continue; |
1545 | |
1546 | |
1547 | locHistName = string("Momentum_CorrectID_") + locParticleName; |
1548 | locHistTitle = string("Correct ") + locParticleROOTName + string(" ID, ") + locStepROOTName + string(";p (GeV/c)"); |
1549 | dHistDeque_P_CorrectID[loc_i][locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumPBins, dMinP, dMaxP); |
1550 | |
1551 | |
1552 | locHistName = string("Momentum_IncorrectID_") + locParticleName; |
1553 | locHistTitle = string("Incorrect ") + locParticleROOTName + string(" ID, ") + locStepROOTName + string(";p (GeV/c)"); |
1554 | dHistDeque_P_IncorrectID[loc_i][locPID] = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, dNumPBins, dMinP, dMaxP); |
1555 | |
1556 | |
1557 | locHistName = string("PVsTheta_CorrectID_") + locParticleName; |
1558 | locHistTitle = string("Correct ") + locParticleROOTName + string(" ID, ") + locStepROOTName + string(";#theta#circ;p (GeV/c)"); |
1559 | dHistDeque_PVsTheta_CorrectID[loc_i][locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNumThetaBins, dMinTheta, dMaxTheta, dNum2DPBins, dMinP, dMaxP); |
1560 | |
1561 | |
1562 | locHistName = string("PVsTheta_IncorrectID_") + locParticleName; |
1563 | locHistTitle = string("Incorrect ") + locParticleROOTName + string(" ID, ") + locStepROOTName + string(";#theta#circ;p (GeV/c)"); |
1564 | dHistDeque_PVsTheta_IncorrectID[loc_i][locPID] = GetOrCreate_Histogram<TH2I>(locHistName, locHistTitle, dNumThetaBins, dMinTheta, dMaxTheta, dNum2DPBins, dMinP, dMaxP); |
1565 | } |
1566 | gDirectory->cd(".."); |
1567 | } |
1568 | |
1569 | |
1570 | locHistName = "Combo_TruePIDStatus"; |
1571 | locHistTitle = Get_Reaction()->Get_ReactionName() + string(";# Combos;All Combo Particles True PID Status"); |
1572 | dHist_TruePIDStatus = GetOrCreate_Histogram<TH1I>(locHistName, locHistTitle, 2, -0.5, 1.5); |
1573 | |
1574 | |
1575 | ChangeTo_BaseDirectory(); |
1576 | } |
1577 | japp->RootUnLock(); |
1578 | } |
1579 | |
1580 | void DHistogramAction_TruePID::Run_Update(JEventLoop* locEventLoop) |
1581 | { |
1582 | const DAnalysisUtilities* locAnalysisUtilities = NULL; |
1583 | locEventLoop->GetSingle(locAnalysisUtilities); |
1584 | dAnalysisUtilities = locAnalysisUtilities; |
1585 | } |
1586 | |
1587 | bool DHistogramAction_TruePID::Perform_Action(JEventLoop* locEventLoop, const DParticleCombo* locParticleCombo) |
1588 | { |
1589 | vector<const DMCThrownMatching*> locMCThrownMatchingVector; |
1590 | locEventLoop->Get(locMCThrownMatchingVector); |
| 1 | Calling 'JEventLoop::Get' | |
|
1591 | if(locMCThrownMatchingVector.empty()) |
1592 | return true; |
1593 | const DMCThrownMatching* locMCThrownMatching = locMCThrownMatchingVector[0]; |
1594 | double locP, locTheta; |
1595 | const DMCThrown* locMCThrown; |
1596 | Particle_t locPID; |
1597 | |
1598 | int locComboTruePIDStatus = 1; |
1599 | for(size_t loc_i = 0; loc_i < locParticleCombo->Get_NumParticleComboSteps(); ++loc_i) |
1600 | { |
1601 | const DParticleComboStep* locParticleComboStep = locParticleCombo->Get_ParticleComboStep(loc_i); |
1602 | auto locParticles = locParticleComboStep->Get_FinalParticles_Measured(Get_Reaction()->Get_ReactionStep(loc_i)); |
1603 | for(size_t loc_j = 0; loc_j < locParticles.size(); ++loc_j) |
1604 | { |
1605 | locPID = locParticles[loc_j]->PID(); |
1606 | |
1607 | double locMatchFOM = 0.0; |
1608 | if(ParticleCharge(locPID) == 0) |
1609 | locMCThrown = locMCThrownMatching->Get_MatchingMCThrown(static_cast<const DNeutralParticleHypothesis*>(locParticles[loc_j]), locMatchFOM); |
1610 | else |
1611 | locMCThrown = locMCThrownMatching->Get_MatchingMCThrown(static_cast<const DChargedTrackHypothesis*>(locParticles[loc_j]), locMatchFOM); |
1612 | |
1613 | bool locCutResult = (locMCThrown == NULL) ? false : (((Particle_t)locMCThrown->type) == locPID); |
1614 | if(!locCutResult) |
1615 | locComboTruePIDStatus = 0; |
1616 | |
1617 | |
1618 | const JObject* locSourceObject = Get_FinalParticle_SourceObject(locParticles[loc_j]); |
1619 | pair<Particle_t, const JObject*> locParticleInfo(locParticles[loc_j]->PID(), locSourceObject); |
1620 | pair<size_t, pair<Particle_t, const JObject*> > locHistInfo(loc_i, locParticleInfo); |
1621 | if(dPreviouslyHistogrammedParticles.find(locHistInfo) != dPreviouslyHistogrammedParticles.end()) |
1622 | continue; |
1623 | dPreviouslyHistogrammedParticles.insert(locHistInfo); |
1624 | |
1625 | locP = locParticles[loc_j]->momentum().Mag(); |
1626 | locTheta = locParticles[loc_j]->momentum().Theta()*180.0/TMath::Pi(); |
1627 | |
1628 | |
1629 | |
1630 | |
1631 | Lock_Action(); |
1632 | { |
1633 | if(locCutResult) |
1634 | { |
1635 | dHistDeque_P_CorrectID[loc_i][locPID]->Fill(locP); |
1636 | dHistDeque_PVsTheta_CorrectID[loc_i][locPID]->Fill(locTheta, locP); |
1637 | } |
1638 | else |
1639 | { |
1640 | dHistDeque_P_IncorrectID[loc_i][locPID]->Fill(locP); |
1641 | dHistDeque_PVsTheta_IncorrectID[loc_i][locPID]->Fill(locTheta, locP); |
1642 | } |
1643 | } |
1644 | Unlock_Action(); |
1645 | } |
1646 | } |
1647 | |
1648 | |
1649 | |
1650 | |
1651 | Lock_Action(); |
1652 | { |
1653 | dHist_TruePIDStatus->Fill(locComboTruePIDStatus); |
1654 | } |
1655 | Unlock_Action(); |
1656 | |
1657 | return true; |
1658 | } |
1659 | |
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | #ifndef _JEventLoop_ |
9 | #define _JEventLoop_ |
10 | |
11 | #include <sys/time.h> |
12 | |
13 | #include <vector> |
14 | #include <list> |
15 | #include <string> |
16 | #include <utility> |
17 | #include <typeinfo> |
18 | #include <string.h> |
19 | #include <map> |
20 | #include <utility> |
21 | using std::vector; |
22 | using std::list; |
23 | using std::string; |
24 | using std::type_info; |
25 | |
26 | #include <JANA/jerror.h> |
27 | #include <JANA/JObject.h> |
28 | #include <JANA/JException.h> |
29 | #include <JANA/JEvent.h> |
30 | #include <JANA/JThread.h> |
31 | #include <JANA/JFactory_base.h> |
32 | #include <JANA/JCalibration.h> |
33 | #include <JANA/JGeometry.h> |
34 | #include <JANA/JResourceManager.h> |
35 | #include <JANA/JStreamLog.h> |
36 | |
37 | |
38 | #include "cint.h" |
39 | |
40 | |
41 | |
42 | namespace jana{ |
43 | |
44 | |
45 | template<class T> class JFactory; |
46 | class JApplication; |
47 | class JEventProcessor; |
48 | |
49 | |
50 | class JEventLoop{ |
51 | public: |
52 | |
53 | friend class JApplication; |
54 | |
55 | enum data_source_t{ |
56 | DATA_NOT_AVAILABLE = 1, |
57 | DATA_FROM_CACHE, |
58 | DATA_FROM_SOURCE, |
59 | DATA_FROM_FACTORY |
60 | }; |
61 | |
62 | typedef struct{ |
63 | string caller_name; |
64 | string caller_tag; |
65 | string callee_name; |
66 | string callee_tag; |
67 | double start_time; |
68 | double end_time; |
69 | data_source_t data_source; |
70 | }call_stack_t; |
71 | |
72 | typedef struct{ |
73 | const char* factory_name; |
74 | string tag; |
75 | const char* filename; |
76 | int line; |
77 | }error_call_stack_t; |
78 | |
79 | JEventLoop(JApplication *app); |
80 | virtual ~JEventLoop(); |
81 | virtual const char* className(void){return static_className();} |
82 | static const char* static_className(void){return "JEventLoop";} |
83 | |
84 | JApplication* GetJApplication(void) const {return app;} |
85 | void RefreshProcessorListFromJApplication(void); |
86 | virtual jerror_t AddFactory(JFactory_base* factory); |
87 | jerror_t RemoveFactory(JFactory_base* factory); |
88 | JFactory_base* GetFactory(const string data_name, const char *tag="", bool allow_deftag=true); |
89 | vector<JFactory_base*> GetFactories(void) const {return factories;} |
90 | void GetFactoryNames(vector<string> &factorynames); |
91 | void GetFactoryNames(map<string,string> &factorynames); |
92 | map<string,string> GetDefaultTags(void) const {return default_tags;} |
93 | jerror_t ClearFactories(void); |
94 | jerror_t PrintFactories(int sparsify=0); |
95 | jerror_t Print(const string data_name, const char *tag=""); |
96 | |
97 | JCalibration* GetJCalibration(); |
98 | template<class T> bool GetCalib(string namepath, map<string,T> &vals); |
99 | template<class T> bool GetCalib(string namepath, vector<T> &vals); |
100 | template<class T> bool GetCalib(string namepath, T &val); |
101 | |
102 | JGeometry* GetJGeometry(); |
103 | template<class T> bool GetGeom(string namepath, map<string,T> &vals); |
104 | template<class T> bool GetGeom(string namepath, T &val); |
105 | |
106 | JResourceManager* GetJResourceManager(void); |
107 | string GetResource(string namepath); |
108 | template<class T> bool GetResource(string namepath, T vals, int event_number=0); |
109 | |
110 | void Initialize(void); |
111 | jerror_t Loop(void); |
112 | jerror_t OneEvent(uint64_t event_number); |
113 | jerror_t OneEvent(void); |
114 | inline void Pause(void){pause = 1;} |
115 | inline void Resume(void){pause = 0;} |
116 | inline void Quit(void){quit = 1;} |
117 | inline bool GetQuit(void) const {return quit;} |
118 | void QuitProgram(void); |
119 | |
120 | |
121 | bool HasRandomAccess(void); |
122 | void AddToEventQueue(uint64_t event_number){ next_events_to_process.push_back(event_number); } |
123 | void AddToEventQueue(list<uint64_t> &event_numbers) { next_events_to_process.insert(next_events_to_process.end(), event_numbers.begin(), event_numbers.end()); } |
124 | list<uint64_t> GetEventQueue(void){ return next_events_to_process; } |
125 | void ClearEventQueue(void){ next_events_to_process.clear(); } |
126 | |
127 | template<class T> JFactory<T>* GetSingle(const T* &t, const char *tag="", bool exception_if_not_one=true); |
128 | template<class T> JFactory<T>* Get(vector<const T*> &t, const char *tag="", bool allow_deftag=true); |
129 | template<class T> JFactory<T>* GetFromFactory(vector<const T*> &t, const char *tag="", data_source_t &data_source=null_data_source, bool allow_deftag=true); |
130 | template<class T> jerror_t GetFromSource(vector<const T*> &t, JFactory_base *factory=NULL); |
131 | inline JEvent& GetJEvent(void){return event;} |
132 | inline void SetJEvent(JEvent *event){this->event = *event;} |
133 | inline void SetAutoFree(int auto_free){this->auto_free = auto_free;} |
134 | inline pthread_t GetPThreadID(void) const {return pthread_id;} |
135 | double GetInstantaneousRate(void) const {return rate_instantaneous;} |
136 | double GetIntegratedRate(void) const {return rate_integrated;} |
137 | double GetLastEventProcessingTime(void) const {return delta_time_single;} |
138 | unsigned int GetNevents(void) const {return Nevents;} |
139 | |
140 | inline bool CheckEventBoundary(uint64_t event_numberA, uint64_t event_numberB); |
141 | |
142 | inline bool GetCallStackRecordingStatus(void){ return record_call_stack; } |
143 | inline void DisableCallStackRecording(void){ record_call_stack = false; } |
144 | inline void EnableCallStackRecording(void){ record_call_stack = true; } |
145 | inline void CallStackStart(JEventLoop::call_stack_t &cs, const string &caller_name, const string &caller_tag, const string callee_name, const string callee_tag); |
146 | inline void CallStackEnd(JEventLoop::call_stack_t &cs); |
147 | inline vector<call_stack_t> GetCallStack(void){return call_stack;} |
148 | inline void AddToCallStack(call_stack_t &cs){if(record_call_stack) call_stack.push_back(cs);} |
149 | inline void AddToErrorCallStack(error_call_stack_t &cs){error_call_stack.push_back(cs);} |
150 | inline vector<error_call_stack_t> GetErrorCallStack(void){return error_call_stack;} |
151 | void PrintErrorCallStack(void); |
152 | |
153 | const JObject* FindByID(JObject::oid_t id); |
154 | template<class T> const T* FindByID(JObject::oid_t id); |
155 | JFactory_base* FindOwner(const JObject *t); |
156 | JFactory_base* FindOwner(JObject::oid_t id); |
157 | |
158 | |
159 | template<class T> void SetRef(T *t); |
160 | template<class T> T* GetRef(void); |
161 | template<class T> vector<T*> GetRefsT(void); |
162 | vector<pair<const char*, void*> > GetRefs(void){ return user_refs; } |
163 | template<class T> void RemoveRef(T *t); |
164 | |
165 | |
166 | uint64_t GetStatus(void){return event.GetStatus();} |
167 | bool GetStatusBit(uint32_t bit){return event.GetStatusBit(bit);} |
168 | bool SetStatusBit(uint32_t bit, bool val=true){return event.SetStatusBit(bit, val);} |
169 | bool ClearStatusBit(uint32_t bit){return event.ClearStatusBit(bit);} |
170 | void ClearStatus(void){event.ClearStatus();} |
171 | void SetStatusBitDescription(uint32_t bit, string description){event.SetStatusBitDescription(bit, description);} |
172 | string GetStatusBitDescription(uint32_t bit){return event.GetStatusBitDescription(bit);} |
173 | void GetStatusBitDescriptions(map<uint32_t, string> &status_bit_descriptions){return event.GetStatusBitDescriptions(status_bit_descriptions);} |
174 | string StatusWordToString(void); |
175 | |
176 | private: |
177 | JEvent event; |
178 | vector<JFactory_base*> factories; |
179 | vector<JEventProcessor*> processors; |
180 | vector<error_call_stack_t> error_call_stack; |
181 | vector<call_stack_t> call_stack; |
182 | JApplication *app; |
183 | JThread *jthread; |
184 | bool initialized; |
185 | bool print_parameters_called; |
186 | int pause; |
187 | int quit; |
188 | int auto_free; |
189 | pthread_t pthread_id; |
190 | map<string, string> default_tags; |
191 | vector<pair<string,string> > auto_activated_factories; |
192 | bool record_call_stack; |
193 | string caller_name; |
194 | string caller_tag; |
195 | vector<uint64_t> event_boundaries; |
196 | int32_t event_boundaries_run; |
197 | list<uint64_t> next_events_to_process; |
198 | |
199 | uint64_t Nevents; |
200 | uint64_t Nevents_rate; |
201 | double delta_time_single; |
202 | double delta_time_rate; |
203 | double delta_time; |
204 | double rate_instantaneous; |
205 | double rate_integrated; |
206 | |
207 | static data_source_t null_data_source; |
208 | |
209 | vector<pair<const char*, void*> > user_refs; |
210 | }; |
211 | |
212 | |
213 | |
214 | #ifdef G__DICTIONARY |
215 | typedef JEventLoop::call_stack_t call_stack_t; |
216 | typedef JEventLoop::error_call_stack_t error_call_stack_t; |
217 | #endif |
218 | |
219 | #if !defined(__CINT__) && !defined(__CLING__) |
220 | |
221 | |
222 | |
223 | |
224 | template<class T> |
225 | JFactory<T>* JEventLoop::GetSingle(const T* &t, const char *tag, bool exception_if_not_one) |
226 | { |
227 | |
228 | |
229 | |
230 | |
231 | |
232 | |
233 | |
234 | |
235 | |
236 | |
237 | |
238 | vector<const T*> v; |
239 | JFactory<T> *fac = Get(v, tag); |
240 | |
241 | if(v.size()!=1){ |
242 | t = NULL; |
243 | if(exception_if_not_one) throw v.size(); |
244 | } |
245 | |
246 | t = v[0]; |
247 | |
248 | return fac; |
249 | } |
250 | |
251 | |
252 | |
253 | |
254 | template<class T> |
255 | JFactory<T>* JEventLoop::Get(vector<const T*> &t, const char *tag, bool allow_deftag) |
256 | { |
257 | |
258 | |
259 | |
260 | |
261 | |
262 | |
263 | |
264 | |
265 | |
266 | |
267 | |
268 | |
269 | |
270 | |
271 | |
272 | |
273 | |
274 | |
275 | |
276 | |
277 | |
278 | |
279 | |
280 | |
281 | |
282 | |
283 | |
284 | |
285 | |
286 | |
287 | |
288 | |
289 | |
290 | const char *mytag = tag==NULL ? "":tag; |
| |
291 | if(strlen(mytag)==0 && allow_deftag){ |
| |
292 | map<string, string>::const_iterator iter = default_tags.find(T::static_className()); |
293 | if(iter!=default_tags.end())tag = iter->second.c_str(); |
| 4 | | Assuming the condition is true | |
|
| |
| |
294 | } |
295 | |
296 | |
297 | |
298 | |
299 | |
300 | |
301 | call_stack_t cs; |
302 | |
303 | |
304 | if(record_call_stack) CallStackStart(cs, caller_name, caller_tag, T::static_className(), tag); |
| 7 | | Assuming field 'record_call_stack' is false | |
|
| |
305 | |
306 | |
307 | JFactory<T>* factory=NULL; |
308 | try{ |
309 | factory = GetFromFactory(t, tag, cs.data_source, allow_deftag); |
| 9 | | Passing value via 2nd parameter 'tag' | |
|
| 10 | | Calling 'JEventLoop::GetFromFactory' | |
|
310 | if(!factory){ |
311 | |
312 | |
313 | |
314 | |
315 | |
316 | |
317 | |
318 | string p; |
319 | try{ |
320 | gPARMS->GetParameter("JANA:AUTOFACTORYCREATE", p); |
321 | }catch(...){} |
322 | if(p.size()==0){ |
323 | jout<<std::endl; |
324 | _DBG__; |
325 | jout<<"No factory of type \""<<T::static_className()<<"\" with tag \""<<tag<<"\" exists."<<std::endl; |
326 | jout<<"If you are reading objects from a file, I can auto-create a factory"<<std::endl; |
327 | jout<<"of the appropriate type to hold the objects, but this feature is turned"<<std::endl; |
328 | jout<<"off by default. To turn it on, set the \"JANA:AUTOFACTORYCREATE\""<<std::endl; |
329 | jout<<"configuration parameter. This can usually be done by passing the"<<std::endl; |
330 | jout<<"following argument to the program from the command line:"<<std::endl; |
331 | jout<<std::endl; |
332 | jout<<" -PJANA:AUTOFACTORYCREATE=1"<<std::endl; |
333 | jout<<std::endl; |
334 | jout<<"Note that since the most commonly expected occurance of this situation."<<std::endl; |
335 | jout<<"is an error, the program will now throw an exception so that the factory."<<std::endl; |
336 | jout<<"call stack can be printed."<<std::endl; |
337 | jout<<std::endl; |
338 | throw exception(); |
339 | }else{ |
340 | AddFactory(new JFactory<T>(tag)); |
341 | jout<<__FILE__<<":"<<__LINE__<<" Auto-created "<<T::static_className()<<":"<<tag<<" factory"<<std::endl; |
342 | |
343 | |
344 | |
345 | factory = GetFromFactory(t, tag, cs.data_source, allow_deftag); |
346 | } |
347 | } |
348 | }catch(exception &e){ |
349 | |
350 | |
351 | error_call_stack_t ecs; |
352 | ecs.factory_name = T::static_className(); |
353 | ecs.tag = tag; |
354 | ecs.filename = NULL; |
355 | error_call_stack.push_back(ecs); |
356 | throw e; |
357 | } |
358 | |
359 | |
360 | if(record_call_stack) CallStackEnd(cs); |
361 | |
362 | return factory; |
363 | } |
364 | |
365 | |
366 | |
367 | |
368 | template<class T> |
369 | JFactory<T>* JEventLoop::GetFromFactory(vector<const T*> &t, const char *tag, data_source_t &data_source, bool allow_deftag) |
370 | { |
371 | |
372 | |
373 | vector<JFactory_base*>::iterator iter=factories.begin(); |
374 | JFactory<T> *factory = NULL; |
375 | string className(T::static_className()); |
376 | |
377 | |
378 | |
379 | const char *mytag = tag==NULL ? "":tag; |
| 11 | | Assuming 'tag' is equal to NULL | |
|
| 12 | | Assuming pointer value is null | |
|
| |
380 | if(strlen(mytag)==0 && allow_deftag){ |
| |
381 | map<string, string>::const_iterator iter = default_tags.find(className); |
382 | if(iter!=default_tags.end())tag = iter->second.c_str(); |
| 15 | | Assuming the condition is false | |
|
| |
383 | } |
384 | |
385 | for(; iter!=factories.end(); iter++){ |
| 17 | | Calling 'operator!=<jana::JFactory_base **, std::vector<jana::JFactory_base *>>' | |
|
| 20 | | Returning from 'operator!=<jana::JFactory_base **, std::vector<jana::JFactory_base *>>' | |
|
| 21 | | Loop condition is true. Entering loop body | |
|
386 | |
387 | |
388 | |
389 | |
390 | |
391 | |
392 | |
393 | |
394 | |
395 | if(className == (*iter)->GetDataClassName())factory = (JFactory<T>*)(*iter); |
| |
396 | if(factory == NULL)continue; |
| 23 | | Assuming 'factory' is not equal to NULL | |
|
| |
397 | const char *factag = factory->Tag()==NULL ? "":factory->Tag(); |
| 25 | | Assuming the condition is true | |
|
| |
398 | if(!strcmp(factag, tag)){ |
| 27 | | Null pointer passed to 2nd parameter expecting 'nonnull' |
|
399 | break; |
400 | }else{ |
401 | factory=NULL; |
402 | } |
403 | } |
404 | |
405 | |
406 | if(!factory){ |
407 | data_source = DATA_NOT_AVAILABLE; |
408 | return NULL; |
409 | } |
410 | |
411 | |
412 | |
413 | |
414 | if(factory->evnt_was_called()){ |
415 | factory->CopyFrom(t); |
416 | data_source = DATA_FROM_CACHE; |
417 | return factory; |
418 | } |
419 | |
420 | |
421 | if(factory->GetCheckSourceFirst()){ |
422 | |
423 | |
424 | |
425 | |
426 | |
427 | jerror_t err = GetFromSource(t, factory); |
428 | if(err == NOERROR){ |
429 | |
430 | |
431 | |
432 | |
433 | |
434 | |
435 | |
436 | |
437 | |
438 | |
439 | |
440 | |
441 | |
442 | |
443 | factory->SetFactoryPointers(); |
444 | data_source = DATA_FROM_SOURCE; |
445 | |
446 | return factory; |
447 | } |
448 | } |
449 | |
450 | |
451 | |
452 | factory->Get(t); |
453 | factory->SetFactoryPointers(); |
454 | data_source = DATA_FROM_FACTORY; |
455 | |
456 | return factory; |
457 | } |
458 | |
459 | |
460 | |
461 | |
462 | template<class T> |
463 | jerror_t JEventLoop::GetFromSource(vector<const T*> &t, JFactory_base *factory) |
464 | { |
465 | |
466 | |
467 | |
468 | |
469 | |
470 | |
471 | |
472 | |
473 | |
474 | |
475 | if(!factory)throw OBJECT_NOT_AVAILABLE; |
476 | |
477 | return event.GetObjects(t, factory); |
478 | } |
479 | |
480 | |
481 | |
482 | |
483 | inline void JEventLoop::CallStackStart(JEventLoop::call_stack_t &cs, const string &caller_name, const string &caller_tag, const string callee_name, const string callee_tag) |
484 | { |
485 | |
486 | |
487 | |
488 | |
489 | |
490 | |
491 | struct itimerval tmr; |
492 | getitimer(ITIMER_PROF, &tmr); |
493 | |
494 | cs.caller_name = this->caller_name; |
495 | cs.caller_tag = this->caller_tag; |
496 | this->caller_name = cs.callee_name = callee_name; |
497 | this->caller_tag = cs.callee_tag = callee_tag; |
498 | cs.start_time = tmr.it_value.tv_sec + tmr.it_value.tv_usec/1.0E6; |
499 | } |
500 | |
501 | |
502 | |
503 | |
504 | inline void JEventLoop::CallStackEnd(JEventLoop::call_stack_t &cs) |
505 | { |
506 | |
507 | |
508 | |
509 | |
510 | struct itimerval tmr; |
511 | getitimer(ITIMER_PROF, &tmr); |
512 | cs.end_time = tmr.it_value.tv_sec + tmr.it_value.tv_usec/1.0E6; |
513 | caller_name = cs.caller_name; |
514 | caller_tag = cs.caller_tag; |
515 | call_stack.push_back(cs); |
516 | } |
517 | |
518 | |
519 | |
520 | |
521 | inline bool JEventLoop::CheckEventBoundary(uint64_t event_numberA, uint64_t event_numberB) |
522 | { |
523 | |
524 | |
525 | |
526 | |
527 | |
528 | |
529 | |
530 | |
531 | |
532 | |
533 | |
534 | if(event.GetRunNumber()!=event_boundaries_run){ |
535 | event_boundaries.clear(); |
536 | JCalibration *jcalib = GetJCalibration(); |
537 | if(jcalib)jcalib->GetEventBoundaries(event_boundaries); |
538 | event_boundaries_run = event.GetRunNumber(); |
539 | } |
540 | |
541 | |
542 | for(unsigned int i=0; i<event_boundaries.size(); i++){ |
543 | uint64_t eb = event_boundaries[i]; |
544 | if((eb - event_numberA)*(eb - event_numberB) < 0.0 || eb==event_numberA){ |
545 | |
546 | return true; |
547 | } |
548 | } |
549 | |
550 | return false; |
551 | } |
552 | |
553 | |
554 | |
555 | |
556 | template<class T> |
557 | const T* JEventLoop::FindByID(JObject::oid_t id) |
558 | { |
559 | |
560 | |
561 | |
562 | |
563 | |
564 | |
565 | |
566 | |
567 | |
568 | |
569 | |
570 | |
571 | |
572 | |
573 | |
574 | for(unsigned int i=0; i<factories.size(); i++){ |
575 | if(factories[i]->GetDataClassName() != T::static_className())continue; |
576 | |
577 | |
578 | |
579 | const JObject *my_obj = factories[i]->GetByID(id); |
580 | if(my_obj)return dynamic_cast<const T*>(my_obj); |
581 | } |
582 | |
583 | return NULL; |
584 | } |
585 | |
586 | |
587 | |
588 | |
589 | template<class T> |
590 | bool JEventLoop::GetCalib(string namepath, map<string,T> &vals) |
591 | { |
592 | |
593 | |
594 | |
595 | |
596 | |
597 | |
598 | |
599 | vals.clear(); |
600 | |
601 | JCalibration *calib = GetJCalibration(); |
602 | if(!calib){ |
603 | _DBG_<<"Unable to get JCalibration object for run "<<event.GetRunNumber()<<std::endl; |
604 | return true; |
605 | } |
606 | |
607 | return calib->Get(namepath, vals, event.GetEventNumber()); |
608 | } |
609 | |
610 | |
611 | |
612 | |
613 | template<class T> bool JEventLoop::GetCalib(string namepath, vector<T> &vals) |
614 | { |
615 | |
616 | |
617 | |
618 | vals.clear(); |
619 | |
620 | JCalibration *calib = GetJCalibration(); |
621 | if(!calib){ |
622 | _DBG_<<"Unable to get JCalibration object for run "<<event.GetRunNumber()<<std::endl; |
623 | return true; |
624 | } |
625 | |
626 | return calib->Get(namepath, vals, event.GetEventNumber()); |
627 | } |
628 | |
629 | |
630 | |
631 | |
632 | template<class T> bool JEventLoop::GetCalib(string namepath, T &val) |
633 | { |
634 | |
635 | |
636 | |
637 | |
638 | |
639 | |
640 | vector<T> vals; |
641 | bool ret = GetCalib(namepath, vals); |
642 | if(vals.empty()) return true; |
643 | val = vals[0]; |
644 | |
645 | return ret; |
646 | } |
647 | |
648 | |
649 | |
650 | |
651 | template<class T> |
652 | bool JEventLoop::GetGeom(string namepath, map<string,T> &vals) |
653 | { |
654 | |
655 | |
656 | |
657 | |
658 | |
659 | |
660 | |
661 | vals.clear(); |
662 | |
663 | JGeometry *geom = GetJGeometry(); |
664 | if(!geom){ |
665 | _DBG_<<"Unable to get JGeometry object for run "<<event.GetRunNumber()<<std::endl; |
666 | return true; |
667 | } |
668 | |
669 | return geom->Get(namepath, vals); |
670 | } |
671 | |
672 | |
673 | |
674 | |
675 | template<class T> bool JEventLoop::GetGeom(string namepath, T &val) |
676 | { |
677 | |
678 | |
679 | |
680 | JGeometry *geom = GetJGeometry(); |
681 | if(!geom){ |
682 | _DBG_<<"Unable to get JGeometry object for run "<<event.GetRunNumber()<<std::endl; |
683 | return true; |
684 | } |
685 | |
686 | return geom->Get(namepath, val); |
687 | } |
688 | |
689 | |
690 | |
691 | |
692 | template<class T> |
693 | void JEventLoop::SetRef(T *t) |
694 | { |
695 | pair<const char*, void*> p(typeid(T).name(), (void*)t); |
696 | user_refs.push_back(p); |
697 | } |
698 | |
699 | |
700 | |
701 | |
702 | template<class T> bool JEventLoop::GetResource(string namepath, T vals, int event_number) |
703 | { |
704 | JResourceManager *resource_manager = GetJResourceManager(); |
705 | if(!resource_manager){ |
706 | string mess = string("Unable to get the JResourceManager object (namepath=\"")+namepath+"\")"; |
707 | throw JException(mess); |
708 | } |
709 | |
710 | return resource_manager->Get(namepath, vals, event_number); |
711 | } |
712 | |
713 | |
714 | |
715 | |
716 | template<class T> |
717 | T* JEventLoop::GetRef(void) |
718 | { |
719 | |
720 | for(unsigned int i=0; i<user_refs.size(); i++){ |
721 | if(user_refs[i].first == typeid(T).name()) return (T*)user_refs[i].second; |
722 | } |
723 | |
724 | return NULL; |
725 | } |
726 | |
727 | |
728 | |
729 | |
730 | template<class T> |
731 | vector<T*> JEventLoop::GetRefsT(void) |
732 | { |
733 | vector<T*> refs; |
734 | for(unsigned int i=0; i<user_refs.size(); i++){ |
735 | if(user_refs[i].first == typeid(T).name()){ |
736 | refs.push_back((T*)user_refs[i].second); |
737 | } |
738 | } |
739 | |
740 | return refs; |
741 | } |
742 | |
743 | |
744 | |
745 | |
746 | template<class T> |
747 | void JEventLoop::RemoveRef(T *t) |
748 | { |
749 | vector<pair<const char*, void*> >::iterator iter; |
750 | for(iter=user_refs.begin(); iter!= user_refs.end(); iter++){ |
751 | if(iter->second == (void*)t){ |
752 | user_refs.erase(iter); |
753 | return; |
754 | } |
755 | } |
756 | _DBG_<<" Attempt to remove user reference not in event loop!" << std::endl; |
757 | } |
758 | |
759 | |
760 | #endif //__CINT__ __CLING__ |
761 | |
762 | } |
763 | |
764 | |
765 | |
766 | #endif // _JEventLoop_ |
767 | |
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | |
27 | |
28 | |
29 | |
30 | |
31 | |
32 | |
33 | |
34 | |
35 | |
36 | |
37 | |
38 | |
39 | |
40 | |
41 | |
42 | |
43 | |
44 | |
45 | |
46 | |
47 | |
48 | |
49 | |
50 | |
51 | |
52 | |
53 | |
54 | |
55 | |
56 | |
57 | |
58 | |
59 | |
60 | #ifndef _STL_ITERATOR_H |
61 | #define _STL_ITERATOR_H 1 |
62 | |
63 | #include <bits/cpp_type_traits.h> |
64 | #include <ext/type_traits.h> |
65 | #include <bits/move.h> |
66 | |
67 | namespace std _GLIBCXX_VISIBILITY(default) |
68 | { |
69 | _GLIBCXX_BEGIN_NAMESPACE_VERSION |
70 | |
71 | |
72 | |
73 | |
74 | |
75 | |
76 | |
77 | |
78 | |
79 | |
80 | |
81 | |
82 | |
83 | |
84 | |
85 | |
86 | |
87 | |
88 | |
89 | |
90 | |
91 | |
92 | |
93 | |
94 | |
95 | template<typename _Iterator> |
96 | class reverse_iterator |
97 | : public iterator<typename iterator_traits<_Iterator>::iterator_category, |
98 | typename iterator_traits<_Iterator>::value_type, |
99 | typename iterator_traits<_Iterator>::difference_type, |
100 | typename iterator_traits<_Iterator>::pointer, |
101 | typename iterator_traits<_Iterator>::reference> |
102 | { |
103 | protected: |
104 | _Iterator current; |
105 | |
106 | typedef iterator_traits<_Iterator> __traits_type; |
107 | |
108 | public: |
109 | typedef _Iterator iterator_type; |
110 | typedef typename __traits_type::difference_type difference_type; |
111 | typedef typename __traits_type::pointer pointer; |
112 | typedef typename __traits_type::reference reference; |
113 | |
114 | |
115 | |
116 | |
117 | |
118 | |
119 | |
120 | reverse_iterator() : current() { } |
121 | |
122 | |
123 | |
124 | |
125 | explicit |
126 | reverse_iterator(iterator_type __x) : current(__x) { } |
127 | |
128 | |
129 | |
130 | |
131 | reverse_iterator(const reverse_iterator& __x) |
132 | : current(__x.current) { } |
133 | |
134 | |
135 | |
136 | |
137 | |
138 | template<typename _Iter> |
139 | reverse_iterator(const reverse_iterator<_Iter>& __x) |
140 | : current(__x.base()) { } |
141 | |
142 | |
143 | |
144 | |
145 | iterator_type |
146 | base() const |
147 | { return current; } |
148 | |
149 | |
150 | |
151 | |
152 | |
153 | |
154 | |
155 | |
156 | |
157 | |
158 | |
159 | reference |
160 | operator*() const |
161 | { |
162 | _Iterator __tmp = current; |
163 | return *--__tmp; |
164 | } |
165 | |
166 | |
167 | |
168 | |
169 | |
170 | |
171 | pointer |
172 | operator->() const |
173 | { return &(operator*()); } |
174 | |
175 | |
176 | |
177 | |
178 | |
179 | |
180 | reverse_iterator& |
181 | operator++() |
182 | { |
183 | --current; |
184 | return *this; |
185 | } |
186 | |
187 | |
188 | |
189 | |
190 | |
191 | |
192 | reverse_iterator |
193 | operator++(int) |
194 | { |
195 | reverse_iterator __tmp = *this; |
196 | --current; |
197 | return __tmp; |
198 | } |
199 | |
200 | |
201 | |
202 | |
203 | |
204 | |
205 | reverse_iterator& |
206 | operator--() |
207 | { |
208 | ++current; |
209 | return *this; |
210 | } |
211 | |
212 | |
213 | |
214 | |
215 | |
216 | |
217 | reverse_iterator |
218 | operator--(int) |
219 | { |
220 | reverse_iterator __tmp = *this; |
221 | ++current; |
222 | return __tmp; |
223 | } |
224 | |
225 | |
226 | |
227 | |
228 | |
229 | |
230 | reverse_iterator |
231 | operator+(difference_type __n) const |
232 | { return reverse_iterator(current - __n); } |
233 | |
234 | |
235 | |
236 | |
237 | |
238 | |
239 | |
240 | reverse_iterator& |
241 | operator+=(difference_type __n) |
242 | { |
243 | current -= __n; |
244 | return *this; |
245 | } |
246 | |
247 | |
248 | |
249 | |
250 | |
251 | |
252 | reverse_iterator |
253 | operator-(difference_type __n) const |
254 | { return reverse_iterator(current + __n); } |
255 | |
256 | |
257 | |
258 | |
259 | |
260 | |
261 | |
262 | reverse_iterator& |
263 | operator-=(difference_type __n) |
264 | { |
265 | current += __n; |
266 | return *this; |
267 | } |
268 | |
269 | |
270 | |
271 | |
272 | |
273 | |
274 | reference |
275 | operator[](difference_type __n) const |
276 | { return *(*this + __n); } |
277 | }; |
278 | |
279 | |
280 | |
281 | |
282 | |
283 | |
284 | |
285 | |
286 | |
287 | |
288 | |
289 | template<typename _Iterator> |
290 | inline bool |
291 | operator==(const reverse_iterator<_Iterator>& __x, |
292 | const reverse_iterator<_Iterator>& __y) |
293 | { return __x.base() == __y.base(); } |
294 | |
295 | template<typename _Iterator> |
296 | inline bool |
297 | operator<(const reverse_iterator<_Iterator>& __x, |
298 | const reverse_iterator<_Iterator>& __y) |
299 | { return __y.base() < __x.base(); } |
300 | |
301 | template<typename _Iterator> |
302 | inline bool |
303 | operator!=(const reverse_iterator<_Iterator>& __x, |
304 | const reverse_iterator<_Iterator>& __y) |
305 | { return !(__x == __y); } |
306 | |
307 | template<typename _Iterator> |
308 | inline bool |
309 | operator>(const reverse_iterator<_Iterator>& __x, |
310 | const reverse_iterator<_Iterator>& __y) |
311 | { return __y < __x; } |
312 | |
313 | template<typename _Iterator> |
314 | inline bool |
315 | operator<=(const reverse_iterator<_Iterator>& __x, |
316 | const reverse_iterator<_Iterator>& __y) |
317 | { return !(__y < __x); } |
318 | |
319 | template<typename _Iterator> |
320 | inline bool |
321 | operator>=(const reverse_iterator<_Iterator>& __x, |
322 | const reverse_iterator<_Iterator>& __y) |
323 | { return !(__x < __y); } |
324 | |
325 | template<typename _Iterator> |
326 | inline typename reverse_iterator<_Iterator>::difference_type |
327 | operator-(const reverse_iterator<_Iterator>& __x, |
328 | const reverse_iterator<_Iterator>& __y) |
329 | { return __y.base() - __x.base(); } |
330 | |
331 | template<typename _Iterator> |
332 | inline reverse_iterator<_Iterator> |
333 | operator+(typename reverse_iterator<_Iterator>::difference_type __n, |
334 | const reverse_iterator<_Iterator>& __x) |
335 | { return reverse_iterator<_Iterator>(__x.base() - __n); } |
336 | |
337 | |
338 | |
339 | template<typename _IteratorL, typename _IteratorR> |
340 | inline bool |
341 | operator==(const reverse_iterator<_IteratorL>& __x, |
342 | const reverse_iterator<_IteratorR>& __y) |
343 | { return __x.base() == __y.base(); } |
344 | |
345 | template<typename _IteratorL, typename _IteratorR> |
346 | inline bool |
347 | operator<(const reverse_iterator<_IteratorL>& __x, |
348 | const reverse_iterator<_IteratorR>& __y) |
349 | { return __y.base() < __x.base(); } |
350 | |
351 | template<typename _IteratorL, typename _IteratorR> |
352 | inline bool |
353 | operator!=(const reverse_iterator<_IteratorL>& __x, |
354 | const reverse_iterator<_IteratorR>& __y) |
355 | { return !(__x == __y); } |
356 | |
357 | template<typename _IteratorL, typename _IteratorR> |
358 | inline bool |
359 | operator>(const reverse_iterator<_IteratorL>& __x, |
360 | const reverse_iterator<_IteratorR>& __y) |
361 | { return __y < __x; } |
362 | |
363 | template<typename _IteratorL, typename _IteratorR> |
364 | inline bool |
365 | operator<=(const reverse_iterator<_IteratorL>& __x, |
366 | const reverse_iterator<_IteratorR>& __y) |
367 | { return !(__y < __x); } |
368 | |
369 | template<typename _IteratorL, typename _IteratorR> |
370 | inline bool |
371 | operator>=(const reverse_iterator<_IteratorL>& __x, |
372 | const reverse_iterator<_IteratorR>& __y) |
373 | { return !(__x < __y); } |
374 | |
375 | template<typename _IteratorL, typename _IteratorR> |
376 | #if __cplusplus >= 201103L |
377 | |
378 | inline auto |
379 | operator-(const reverse_iterator<_IteratorL>& __x, |
380 | const reverse_iterator<_IteratorR>& __y) |
381 | -> decltype(__y.base() - __x.base()) |
382 | #else |
383 | inline typename reverse_iterator<_IteratorL>::difference_type |
384 | operator-(const reverse_iterator<_IteratorL>& __x, |
385 | const reverse_iterator<_IteratorR>& __y) |
386 | #endif |
387 | { return __y.base() - __x.base(); } |
388 | |
389 | |
390 | |
391 | |
392 | |
393 | |
394 | |
395 | |
396 | |
397 | |
398 | |
399 | |
400 | |
401 | template<typename _Container> |
402 | class back_insert_iterator |
403 | : public iterator<output_iterator_tag, void, void, void, void> |
404 | { |
405 | protected: |
406 | _Container* container; |
407 | |
408 | public: |
409 | |
410 | typedef _Container container_type; |
411 | |
412 | |
413 | explicit |
414 | back_insert_iterator(_Container& __x) : container(&__x) { } |
415 | |
416 | |
417 | |
418 | |
419 | |
420 | |
421 | |
422 | |
423 | |
424 | |
425 | |
426 | |
427 | #if __cplusplus < 201103L |
428 | back_insert_iterator& |
429 | operator=(typename _Container::const_reference __value) |
430 | { |
431 | container->push_back(__value); |
432 | return *this; |
433 | } |
434 | #else |
435 | back_insert_iterator& |
436 | operator=(const typename _Container::value_type& __value) |
437 | { |
438 | container->push_back(__value); |
439 | return *this; |
440 | } |
441 | |
442 | back_insert_iterator& |
443 | operator=(typename _Container::value_type&& __value) |
444 | { |
445 | container->push_back(std::move(__value)); |
446 | return *this; |
447 | } |
448 | #endif |
449 | |
450 | |
451 | back_insert_iterator& |
452 | operator*() |
453 | { return *this; } |
454 | |
455 | |
456 | back_insert_iterator& |
457 | operator++() |
458 | { return *this; } |
459 | |
460 | |
461 | back_insert_iterator |
462 | operator++(int) |
463 | { return *this; } |
464 | }; |
465 | |
466 | |
467 | |
468 | |
469 | |
470 | |
471 | |
472 | |
473 | |
474 | |
475 | |
476 | |
477 | template<typename _Container> |
478 | inline back_insert_iterator<_Container> |
479 | back_inserter(_Container& __x) |
480 | { return back_insert_iterator<_Container>(__x); } |
481 | |
482 | |
483 | |
484 | |
485 | |
486 | |
487 | |
488 | |
489 | |
490 | |
491 | |
492 | template<typename _Container> |
493 | class front_insert_iterator |
494 | : public iterator<output_iterator_tag, void, void, void, void> |
495 | { |
496 | protected: |
497 | _Container* container; |
498 | |
499 | public: |
500 | |
501 | typedef _Container container_type; |
502 | |
503 | |
504 | explicit front_insert_iterator(_Container& __x) : container(&__x) { } |
505 | |
506 | |
507 | |
508 | |
509 | |
510 | |
511 | |
512 | |
513 | |
514 | |
515 | |
516 | |
517 | #if __cplusplus < 201103L |
518 | front_insert_iterator& |
519 | operator=(typename _Container::const_reference __value) |
520 | { |
521 | container->push_front(__value); |
522 | return *this; |
523 | } |
524 | #else |
525 | front_insert_iterator& |
526 | operator=(const typename _Container::value_type& __value) |
527 | { |
528 | container->push_front(__value); |
529 | return *this; |
530 | } |
531 | |
532 | front_insert_iterator& |
533 | operator=(typename _Container::value_type&& __value) |
534 | { |
535 | container->push_front(std::move(__value)); |
536 | return *this; |
537 | } |
538 | #endif |
539 | |
540 | |
541 | front_insert_iterator& |
542 | operator*() |
543 | { return *this; } |
544 | |
545 | |
546 | front_insert_iterator& |
547 | operator++() |
548 | { return *this; } |
549 | |
550 | |
551 | front_insert_iterator |
552 | operator++(int) |
553 | { return *this; } |
554 | }; |
555 | |
556 | |
557 | |
558 | |
559 | |
560 | |
561 | |
562 | |
563 | |
564 | |
565 | |
566 | |
567 | template<typename _Container> |
568 | inline front_insert_iterator<_Container> |
569 | front_inserter(_Container& __x) |
570 | { return front_insert_iterator<_Container>(__x); } |
571 | |
572 | |
573 | |
574 | |
575 | |
576 | |
577 | |
578 | |
579 | |
580 | |
581 | |
582 | |
583 | |
584 | |
585 | |
586 | template<typename _Container> |
587 | class insert_iterator |
588 | : public iterator<output_iterator_tag, void, void, void, void> |
589 | { |
590 | protected: |
591 | _Container* container; |
592 | typename _Container::iterator iter; |
593 | |
594 | public: |
595 | |
596 | typedef _Container container_type; |
597 | |
598 | |
599 | |
600 | |
601 | |
602 | insert_iterator(_Container& __x, typename _Container::iterator __i) |
603 | : container(&__x), iter(__i) {} |
604 | |
605 | |
606 | |
607 | |
608 | |
609 | |
610 | |
611 | |
612 | |
613 | |
614 | |
615 | |
616 | |
617 | |
618 | |
619 | |
620 | |
621 | |
622 | |
623 | |
624 | |
625 | |
626 | |
627 | |
628 | #if __cplusplus < 201103L |
629 | insert_iterator& |
630 | operator=(typename _Container::const_reference __value) |
631 | { |
632 | iter = container->insert(iter, __value); |
633 | ++iter; |
634 | return *this; |
635 | } |
636 | #else |
637 | insert_iterator& |
638 | operator=(const typename _Container::value_type& __value) |
639 | { |
640 | iter = container->insert(iter, __value); |
641 | ++iter; |
642 | return *this; |
643 | } |
644 | |
645 | insert_iterator& |
646 | operator=(typename _Container::value_type&& __value) |
647 | { |
648 | iter = container->insert(iter, std::move(__value)); |
649 | ++iter; |
650 | return *this; |
651 | } |
652 | #endif |
653 | |
654 | |
655 | insert_iterator& |
656 | operator*() |
657 | { return *this; } |
658 | |
659 | |
660 | insert_iterator& |
661 | operator++() |
662 | { return *this; } |
663 | |
664 | |
665 | insert_iterator& |
666 | operator++(int) |
667 | { return *this; } |
668 | }; |
669 | |
670 | |
671 | |
672 | |
673 | |
674 | |
675 | |
676 | |
677 | |
678 | |
679 | |
680 | |
681 | template<typename _Container, typename _Iterator> |
682 | inline insert_iterator<_Container> |
683 | inserter(_Container& __x, _Iterator __i) |
684 | { |
685 | return insert_iterator<_Container>(__x, |
686 | typename _Container::iterator(__i)); |
687 | } |
688 | |
689 | |
690 | |
691 | _GLIBCXX_END_NAMESPACE_VERSION |
692 | } |
693 | |
694 | namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) |
695 | { |
696 | _GLIBCXX_BEGIN_NAMESPACE_VERSION |
697 | |
698 | |
699 | |
700 | |
701 | |
702 | |
703 | |
704 | |
705 | using std::iterator_traits; |
706 | using std::iterator; |
707 | template<typename _Iterator, typename _Container> |
708 | class __normal_iterator |
709 | { |
710 | protected: |
711 | _Iterator _M_current; |
712 | |
713 | typedef iterator_traits<_Iterator> __traits_type; |
714 | |
715 | public: |
716 | typedef _Iterator iterator_type; |
717 | typedef typename __traits_type::iterator_category iterator_category; |
718 | typedef typename __traits_type::value_type value_type; |
719 | typedef typename __traits_type::difference_type difference_type; |
720 | typedef typename __traits_type::reference reference; |
721 | typedef typename __traits_type::pointer pointer; |
722 | |
723 | _GLIBCXX_CONSTEXPR __normal_iterator() : _M_current(_Iterator()) { } |
724 | |
725 | explicit |
726 | __normal_iterator(const _Iterator& __i) : _M_current(__i) { } |
727 | |
728 | |
729 | template<typename _Iter> |
730 | __normal_iterator(const __normal_iterator<_Iter, |
731 | typename __enable_if< |
732 | (std::__are_same<_Iter, typename _Container::pointer>::__value), |
733 | _Container>::__type>& __i) |
734 | : _M_current(__i.base()) { } |
735 | |
736 | |
737 | reference |
738 | operator*() const |
739 | { return *_M_current; } |
740 | |
741 | pointer |
742 | operator->() const |
743 | { return _M_current; } |
744 | |
745 | __normal_iterator& |
746 | operator++() |
747 | { |
748 | ++_M_current; |
749 | return *this; |
750 | } |
751 | |
752 | __normal_iterator |
753 | operator++(int) |
754 | { return __normal_iterator(_M_current++); } |
755 | |
756 | |
757 | __normal_iterator& |
758 | operator--() |
759 | { |
760 | --_M_current; |
761 | return *this; |
762 | } |
763 | |
764 | __normal_iterator |
765 | operator--(int) |
766 | { return __normal_iterator(_M_current--); } |
767 | |
768 | |
769 | reference |
770 | operator[](const difference_type& __n) const |
771 | { return _M_current[__n]; } |
772 | |
773 | __normal_iterator& |
774 | operator+=(const difference_type& __n) |
775 | { _M_current += __n; return *this; } |
776 | |
777 | __normal_iterator |
778 | operator+(const difference_type& __n) const |
779 | { return __normal_iterator(_M_current + __n); } |
780 | |
781 | __normal_iterator& |
782 | operator-=(const difference_type& __n) |
783 | { _M_current -= __n; return *this; } |
784 | |
785 | __normal_iterator |
786 | operator-(const difference_type& __n) const |
787 | { return __normal_iterator(_M_current - __n); } |
788 | |
789 | const _Iterator& |
790 | base() const |
791 | { return _M_current; } |
792 | }; |
793 | |
794 | |
795 | |
796 | |
797 | |
798 | |
799 | |
800 | |
801 | |
802 | |
803 | template<typename _IteratorL, typename _IteratorR, typename _Container> |
804 | inline bool |
805 | operator==(const __normal_iterator<_IteratorL, _Container>& __lhs, |
806 | const __normal_iterator<_IteratorR, _Container>& __rhs) |
807 | { return __lhs.base() == __rhs.base(); } |
808 | |
809 | template<typename _Iterator, typename _Container> |
810 | inline bool |
811 | operator==(const __normal_iterator<_Iterator, _Container>& __lhs, |
812 | const __normal_iterator<_Iterator, _Container>& __rhs) |
813 | { return __lhs.base() == __rhs.base(); } |
814 | |
815 | template<typename _IteratorL, typename _IteratorR, typename _Container> |
816 | inline bool |
817 | operator!=(const __normal_iterator<_IteratorL, _Container>& __lhs, |
818 | const __normal_iterator<_IteratorR, _Container>& __rhs) |
819 | { return __lhs.base() != __rhs.base(); } |
820 | |
821 | template<typename _Iterator, typename _Container> |
822 | inline bool |
823 | operator!=(const __normal_iterator<_Iterator, _Container>& __lhs, |
824 | const __normal_iterator<_Iterator, _Container>& __rhs) |
825 | { return __lhs.base() != __rhs.base(); } |
| 18 | | Assuming the condition is true | |
|
| 19 | | Returning the value 1, which participates in a condition later | |
|
826 | |
827 | |
828 | template<typename _IteratorL, typename _IteratorR, typename _Container> |
829 | inline bool |
830 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, |
831 | const __normal_iterator<_IteratorR, _Container>& __rhs) |
832 | { return __lhs.base() < __rhs.base(); } |
833 | |
834 | template<typename _Iterator, typename _Container> |
835 | inline bool |
836 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, |
837 | const __normal_iterator<_Iterator, _Container>& __rhs) |
838 | { return __lhs.base() < __rhs.base(); } |
839 | |
840 | template<typename _IteratorL, typename _IteratorR, typename _Container> |
841 | inline bool |
842 | operator>(const __normal_iterator<_IteratorL, _Container>& __lhs, |
843 | const __normal_iterator<_IteratorR, _Container>& __rhs) |
844 | { return __lhs.base() > __rhs.base(); } |
845 | |
846 | template<typename _Iterator, typename _Container> |
847 | inline bool |
848 | operator>(const __normal_iterator<_Iterator, _Container>& __lhs, |
849 | const __normal_iterator<_Iterator, _Container>& __rhs) |
850 | { return __lhs.base() > __rhs.base(); } |
851 | |
852 | template<typename _IteratorL, typename _IteratorR, typename _Container> |
853 | inline bool |
854 | operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs, |
855 | const __normal_iterator<_IteratorR, _Container>& __rhs) |
856 | { return __lhs.base() <= __rhs.base(); } |
857 | |
858 | template<typename _Iterator, typename _Container> |
859 | inline bool |
860 | operator<=(const __normal_iterator<_Iterator, _Container>& __lhs, |
861 | const __normal_iterator<_Iterator, _Container>& __rhs) |
862 | { return __lhs.base() <= __rhs.base(); } |
863 | |
864 | template<typename _IteratorL, typename _IteratorR, typename _Container> |
865 | inline bool |
866 | operator>=(const __normal_iterator<_IteratorL, _Container>& __lhs, |
867 | const __normal_iterator<_IteratorR, _Container>& __rhs) |
868 | { return __lhs.base() >= __rhs.base(); } |
869 | |
870 | template<typename _Iterator, typename _Container> |
871 | inline bool |
872 | operator>=(const __normal_iterator<_Iterator, _Container>& __lhs, |
873 | const __normal_iterator<_Iterator, _Container>& __rhs) |
874 | { return __lhs.base() >= __rhs.base(); } |
875 | |
876 | |
877 | |
878 | |
879 | |
880 | template<typename _IteratorL, typename _IteratorR, typename _Container> |
881 | #if __cplusplus >= 201103L |
882 | |
883 | inline auto |
884 | operator-(const __normal_iterator<_IteratorL, _Container>& __lhs, |
885 | const __normal_iterator<_IteratorR, _Container>& __rhs) |
886 | -> decltype(__lhs.base() - __rhs.base()) |
887 | #else |
888 | inline typename __normal_iterator<_IteratorL, _Container>::difference_type |
889 | operator-(const __normal_iterator<_IteratorL, _Container>& __lhs, |
890 | const __normal_iterator<_IteratorR, _Container>& __rhs) |
891 | #endif |
892 | { return __lhs.base() - __rhs.base(); } |
893 | |
894 | template<typename _Iterator, typename _Container> |
895 | inline typename __normal_iterator<_Iterator, _Container>::difference_type |
896 | operator-(const __normal_iterator<_Iterator, _Container>& __lhs, |
897 | const __normal_iterator<_Iterator, _Container>& __rhs) |
898 | { return __lhs.base() - __rhs.base(); } |
899 | |
900 | template<typename _Iterator, typename _Container> |
901 | inline __normal_iterator<_Iterator, _Container> |
902 | operator+(typename __normal_iterator<_Iterator, _Container>::difference_type |
903 | __n, const __normal_iterator<_Iterator, _Container>& __i) |
904 | { return __normal_iterator<_Iterator, _Container>(__i.base() + __n); } |
905 | |
906 | _GLIBCXX_END_NAMESPACE_VERSION |
907 | } |
908 | |
909 | #if __cplusplus >= 201103L |
910 | |
911 | namespace std _GLIBCXX_VISIBILITY(default) |
912 | { |
913 | _GLIBCXX_BEGIN_NAMESPACE_VERSION |
914 | |
915 | |
916 | |
917 | |
918 | |
919 | |
920 | |
921 | |
922 | |
923 | |
924 | |
925 | |
926 | |
927 | |
928 | |
929 | template<typename _Iterator> |
930 | class move_iterator |
931 | { |
932 | protected: |
933 | _Iterator _M_current; |
934 | |
935 | typedef iterator_traits<_Iterator> __traits_type; |
936 | |
937 | public: |
938 | typedef _Iterator iterator_type; |
939 | typedef typename __traits_type::iterator_category iterator_category; |
940 | typedef typename __traits_type::value_type value_type; |
941 | typedef typename __traits_type::difference_type difference_type; |
942 | |
943 | typedef _Iterator pointer; |
944 | typedef value_type&& reference; |
945 | |
946 | move_iterator() |
947 | : _M_current() { } |
948 | |
949 | explicit |
950 | move_iterator(iterator_type __i) |
951 | : _M_current(__i) { } |
952 | |
953 | template<typename _Iter> |
954 | move_iterator(const move_iterator<_Iter>& __i) |
955 | : _M_current(__i.base()) { } |
956 | |
957 | iterator_type |
958 | base() const |
959 | { return _M_current; } |
960 | |
961 | reference |
962 | operator*() const |
963 | { return std::move(*_M_current); } |
964 | |
965 | pointer |
966 | operator->() const |
967 | { return _M_current; } |
968 | |
969 | move_iterator& |
970 | operator++() |
971 | { |
972 | ++_M_current; |
973 | return *this; |
974 | } |
975 | |
976 | move_iterator |
977 | operator++(int) |
978 | { |
979 | move_iterator __tmp = *this; |
980 | ++_M_current; |
981 | return __tmp; |
982 | } |
983 | |
984 | move_iterator& |
985 | operator--() |
986 | { |
987 | --_M_current; |
988 | return *this; |
989 | } |
990 | |
991 | move_iterator |
992 | operator--(int) |
993 | { |
994 | move_iterator __tmp = *this; |
995 | --_M_current; |
996 | return __tmp; |
997 | } |
998 | |
999 | move_iterator |
1000 | operator+(difference_type __n) const |
1001 | { return move_iterator(_M_current + __n); } |
1002 | |
1003 | move_iterator& |
1004 | operator+=(difference_type __n) |
1005 | { |
1006 | _M_current += __n; |
1007 | return *this; |
1008 | } |
1009 | |
1010 | move_iterator |
1011 | operator-(difference_type __n) const |
1012 | { return move_iterator(_M_current - __n); } |
1013 | |
1014 | move_iterator& |
1015 | operator-=(difference_type __n) |
1016 | { |
1017 | _M_current -= __n; |
1018 | return *this; |
1019 | } |
1020 | |
1021 | reference |
1022 | operator[](difference_type __n) const |
1023 | { return std::move(_M_current[__n]); } |
1024 | }; |
1025 | |
1026 | |
1027 | |
1028 | |
1029 | template<typename _IteratorL, typename _IteratorR> |
1030 | inline bool |
1031 | operator==(const move_iterator<_IteratorL>& __x, |
1032 | const move_iterator<_IteratorR>& __y) |
1033 | { return __x.base() == __y.base(); } |
1034 | |
1035 | template<typename _Iterator> |
1036 | inline bool |
1037 | operator==(const move_iterator<_Iterator>& __x, |
1038 | const move_iterator<_Iterator>& __y) |
1039 | { return __x.base() == __y.base(); } |
1040 | |
1041 | template<typename _IteratorL, typename _IteratorR> |
1042 | inline bool |
1043 | operator!=(const move_iterator<_IteratorL>& __x, |
1044 | const move_iterator<_IteratorR>& __y) |
1045 | { return !(__x == __y); } |
1046 | |
1047 | template<typename _Iterator> |
1048 | inline bool |
1049 | operator!=(const move_iterator<_Iterator>& __x, |
1050 | const move_iterator<_Iterator>& __y) |
1051 | { return !(__x == __y); } |
1052 | |
1053 | template<typename _IteratorL, typename _IteratorR> |
1054 | inline bool |
1055 | operator<(const move_iterator<_IteratorL>& __x, |
1056 | const move_iterator<_IteratorR>& __y) |
1057 | { return __x.base() < __y.base(); } |
1058 | |
1059 | template<typename _Iterator> |
1060 | inline bool |
1061 | operator<(const move_iterator<_Iterator>& __x, |
1062 | const move_iterator<_Iterator>& __y) |
1063 | { return __x.base() < __y.base(); } |
1064 | |
1065 | template<typename _IteratorL, typename _IteratorR> |
1066 | inline bool |
1067 | operator<=(const move_iterator<_IteratorL>& __x, |
1068 | const move_iterator<_IteratorR>& __y) |
1069 | { return !(__y < __x); } |
1070 | |
1071 | template<typename _Iterator> |
1072 | inline bool |
1073 | operator<=(const move_iterator<_Iterator>& __x, |
1074 | const move_iterator<_Iterator>& __y) |
1075 | { return !(__y < __x); } |
1076 | |
1077 | template<typename _IteratorL, typename _IteratorR> |
1078 | inline bool |
1079 | operator>(const move_iterator<_IteratorL>& __x, |
1080 | const move_iterator<_IteratorR>& __y) |
1081 | { return __y < __x; } |
1082 | |
1083 | template<typename _Iterator> |
1084 | inline bool |
1085 | operator>(const move_iterator<_Iterator>& __x, |
1086 | const move_iterator<_Iterator>& __y) |
1087 | { return __y < __x; } |
1088 | |
1089 | template<typename _IteratorL, typename _IteratorR> |
1090 | inline bool |
1091 | operator>=(const move_iterator<_IteratorL>& __x, |
1092 | const move_iterator<_IteratorR>& __y) |
1093 | { return !(__x < __y); } |
1094 | |
1095 | template<typename _Iterator> |
1096 | inline bool |
1097 | operator>=(const move_iterator<_Iterator>& __x, |
1098 | const move_iterator<_Iterator>& __y) |
1099 | { return !(__x < __y); } |
1100 | |
1101 | |
1102 | template<typename _IteratorL, typename _IteratorR> |
1103 | inline auto |
1104 | operator-(const move_iterator<_IteratorL>& __x, |
1105 | const move_iterator<_IteratorR>& __y) |
1106 | -> decltype(__x.base() - __y.base()) |
1107 | { return __x.base() - __y.base(); } |
1108 | |
1109 | template<typename _Iterator> |
1110 | inline auto |
1111 | operator-(const move_iterator<_Iterator>& __x, |
1112 | const move_iterator<_Iterator>& __y) |
1113 | -> decltype(__x.base() - __y.base()) |
1114 | { return __x.base() - __y.base(); } |
1115 | |
1116 | template<typename _Iterator> |
1117 | inline move_iterator<_Iterator> |
1118 | operator+(typename move_iterator<_Iterator>::difference_type __n, |
1119 | const move_iterator<_Iterator>& __x) |
1120 | { return __x + __n; } |
1121 | |
1122 | template<typename _Iterator> |
1123 | inline move_iterator<_Iterator> |
1124 | make_move_iterator(_Iterator __i) |
1125 | { return move_iterator<_Iterator>(__i); } |
1126 | |
1127 | template<typename _Iterator, typename _ReturnType |
1128 | = typename conditional<__move_if_noexcept_cond |
1129 | <typename iterator_traits<_Iterator>::value_type>::value, |
1130 | _Iterator, move_iterator<_Iterator>>::type> |
1131 | inline _ReturnType |
1132 | __make_move_if_noexcept_iterator(_Iterator __i) |
1133 | { return _ReturnType(__i); } |
1134 | |
1135 | |
1136 | |
1137 | _GLIBCXX_END_NAMESPACE_VERSION |
1138 | } |
1139 | |
1140 | #define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) std::make_move_iterator(_Iter) |
1141 | #define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) \ |
1142 | std::__make_move_if_noexcept_iterator(_Iter) |
1143 | #else |
1144 | #define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) (_Iter) |
1145 | #define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) (_Iter) |
1146 | #endif // C++11 |
1147 | |
1148 | #endif |