clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -main-file-name DEventWriterROOT.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/DEventWriterROOT.cc
1 | #include "DEventWriterROOT.h" |
2 | |
3 | static bool BCAL_VERBOSE_OUTPUT = false; |
4 | static bool FCAL_VERBOSE_OUTPUT = false; |
5 | static bool CCAL_VERBOSE_OUTPUT = false; |
6 | static bool DIRC_OUTPUT = true; |
7 | |
8 | static bool STORE_PULL_INFO = false; |
9 | static bool STORE_ERROR_MATRIX_INFO = false; |
10 | |
11 | |
12 | void DEventWriterROOT::Initialize(JEventLoop* locEventLoop) |
13 | { |
14 | dInitNumThrownArraySize = 20; |
15 | dInitNumBeamArraySize = 20; |
16 | dInitNumTrackArraySize = 50; |
17 | dInitNumNeutralArraySize = 15; |
18 | dInitNumComboArraySize = 100; |
19 | dThrownTreeInterface = NULL; |
20 | |
21 | locEventLoop->GetSingle(dAnalysisUtilities); |
22 | |
23 | auto locReactions = DAnalysis::Get_Reactions(locEventLoop); |
24 | |
25 | |
26 | for(size_t loc_i = 0; loc_i < locReactions.size(); ++loc_i) |
27 | { |
28 | if(!locReactions[loc_i]->Get_EnableTTreeOutputFlag()) |
29 | continue; |
30 | |
31 | dCutActionMap_ThrownTopology[locReactions[loc_i]] = new DCutAction_ThrownTopology(locReactions[loc_i], true); |
32 | dCutActionMap_ThrownTopology[locReactions[loc_i]]->Initialize(locEventLoop); |
33 | |
34 | dCutActionMap_TrueCombo[locReactions[loc_i]] = new DCutAction_TrueCombo(locReactions[loc_i], -1.0, true); |
35 | dCutActionMap_TrueCombo[locReactions[loc_i]]->Initialize(locEventLoop); |
36 | |
37 | dCutActionMap_BDTSignalCombo[locReactions[loc_i]] = new DCutAction_BDTSignalCombo(locReactions[loc_i], 5.73303E-7, true, true); |
38 | dCutActionMap_BDTSignalCombo[locReactions[loc_i]]->Initialize(locEventLoop); |
39 | } |
40 | |
41 | |
42 | vector<const DMCThrown*> locMCThrowns; |
43 | locEventLoop->Get(locMCThrowns); |
44 | |
45 | vector<const DReactionVertexInfo*> locVertexInfos; |
46 | locEventLoop->Get(locVertexInfos); |
47 | |
48 | |
49 | DApplication* locApplication = dynamic_cast<DApplication*>(locEventLoop->GetJApplication()); |
50 | DGeometry* locGeometry = locApplication->GetDGeometry(locEventLoop->GetJEvent().GetRunNumber()); |
51 | dTargetCenterZ = 65.0; |
52 | locGeometry->GetTargetZ(dTargetCenterZ); |
53 | |
54 | |
55 | for(auto& locVertexInfo : locVertexInfos) |
56 | { |
57 | auto locVertexReactions = locVertexInfo->Get_Reactions(); |
58 | for(auto& locReaction : locVertexReactions) |
59 | { |
60 | dVertexInfoMap.emplace(locReaction, locVertexInfo); |
61 | if(locReaction->Get_EnableTTreeOutputFlag()) |
62 | Create_DataTree(locReaction, locEventLoop, !locMCThrowns.empty()); |
63 | } |
64 | } |
65 | } |
66 | |
67 | void DEventWriterROOT::Run_Update(JEventLoop* locEventLoop) |
68 | { |
69 | locEventLoop->GetSingle(dAnalysisUtilities); |
| 1 | Calling 'JEventLoop::GetSingle' | |
|
70 | |
71 | |
72 | DApplication* locApplication = dynamic_cast<DApplication*>(locEventLoop->GetJApplication()); |
73 | DGeometry* locGeometry = locApplication->GetDGeometry(locEventLoop->GetJEvent().GetRunNumber()); |
74 | dTargetCenterZ = 65.0; |
75 | locGeometry->GetTargetZ(dTargetCenterZ); |
76 | |
77 | |
78 | for(auto& locMapPair : dCutActionMap_ThrownTopology) |
79 | locMapPair.second->Run_Update(locEventLoop); |
80 | for(auto& locMapPair : dCutActionMap_TrueCombo) |
81 | locMapPair.second->Run_Update(locEventLoop); |
82 | for(auto& locMapPair : dCutActionMap_BDTSignalCombo) |
83 | locMapPair.second->Run_Update(locEventLoop); |
84 | } |
85 | |
86 | DEventWriterROOT::~DEventWriterROOT(void) |
87 | { |
88 | |
89 | for(auto& locMapPair : dTreeInterfaceMap) |
90 | delete locMapPair.second; |
91 | if(dThrownTreeInterface != NULL) |
92 | delete dThrownTreeInterface; |
93 | |
94 | for(auto& locMapPair : dTreeFillDataMap) |
95 | delete locMapPair.second; |
96 | |
97 | |
98 | for(auto& locMapPair : dCutActionMap_ThrownTopology) |
99 | delete locMapPair.second; |
100 | for(auto& locMapPair : dCutActionMap_TrueCombo) |
101 | delete locMapPair.second; |
102 | for(auto& locMapPair : dCutActionMap_BDTSignalCombo) |
103 | delete locMapPair.second; |
104 | } |
105 | |
106 | void DEventWriterROOT::Create_ThrownTree(JEventLoop* locEventLoop, string locOutputFileName) const |
107 | { |
108 | if(dThrownTreeInterface != nullptr) |
109 | return; |
110 | dThrownTreeInterface = DTreeInterface::Create_DTreeInterface("Thrown_Tree", locOutputFileName); |
111 | if(dThrownTreeInterface->Get_BranchesCreatedFlag()) |
112 | return; |
113 | |
114 | |
115 | DTreeBranchRegister locBranchRegister; |
116 | |
117 | |
118 | const DMCReaction* locMCReaction = NULL; |
119 | locEventLoop->GetSingle(locMCReaction); |
120 | Particle_t locTargetPID = locMCReaction->target.PID(); |
121 | |
122 | |
123 | Create_UserTargetInfo(locBranchRegister, locTargetPID); |
124 | |
125 | |
126 | locBranchRegister.Register_Single<UInt_t>("RunNumber"); |
127 | locBranchRegister.Register_Single<ULong64_t>("EventNumber"); |
128 | |
129 | |
130 | Create_Branches_Thrown(locBranchRegister, true); |
131 | |
132 | |
133 | Create_CustomBranches_ThrownTree(locBranchRegister, locEventLoop); |
134 | |
135 | |
136 | dThrownTreeInterface->Create_Branches(locBranchRegister); |
137 | dThrownTreeInterface->Set_TreeIndexBranchNames("RunNumber", "EventNumber"); |
138 | } |
139 | |
140 | void DEventWriterROOT::Create_DataTree(const DReaction* locReaction, JEventLoop* locEventLoop, bool locIsMCDataFlag) |
141 | { |
142 | string locReactionName = locReaction->Get_ReactionName(); |
143 | string locOutputFileName = locReaction->Get_TTreeOutputFileName(); |
144 | string locTreeName = locReactionName + string("_Tree"); |
145 | |
146 | |
147 | dTreeFillDataMap[locReaction] = new DTreeFillData(); |
148 | |
149 | |
150 | DTreeInterface* locTreeInterface = DTreeInterface::Create_DTreeInterface(locTreeName, locOutputFileName); |
151 | dTreeInterfaceMap[locReaction] = locTreeInterface; |
152 | if(locTreeInterface->Get_BranchesCreatedFlag()) |
153 | return; |
154 | |
155 | |
156 | DTreeBranchRegister locBranchRegister; |
157 | |
158 | |
159 | TMap* locPositionToNameMap = Create_UserInfoMaps(locBranchRegister, locEventLoop, locReaction); |
160 | |
161 | |
162 | |
163 | |
164 | locBranchRegister.Register_Single<UInt_t>("RunNumber"); |
165 | locBranchRegister.Register_Single<ULong64_t>("EventNumber"); |
166 | locBranchRegister.Register_Single<UInt_t>("L1TriggerBits"); |
167 | |
168 | |
169 | locBranchRegister.Register_Single<TLorentzVector>("X4_Production"); |
170 | |
171 | |
172 | if(locIsMCDataFlag) |
173 | { |
174 | Create_Branches_Thrown(locBranchRegister, false); |
175 | locBranchRegister.Register_Single<Bool_t>("IsThrownTopology"); |
176 | } |
177 | |
178 | bool locBeamUsedFlag = DAnalysis::Get_IsFirstStepBeam(locReaction); |
179 | |
180 | |
181 | if(locBeamUsedFlag) |
182 | Create_Branches_Beam(locBranchRegister, locIsMCDataFlag); |
183 | Create_Branches_NeutralHypotheses(locBranchRegister, locIsMCDataFlag); |
184 | Create_Branches_ChargedHypotheses(locBranchRegister, locIsMCDataFlag); |
185 | |
186 | |
187 | locBranchRegister.Register_Single<UChar_t>("NumUnusedTracks"); |
188 | Create_Branches_Combo(locBranchRegister, locReaction, locIsMCDataFlag, locPositionToNameMap); |
189 | |
190 | |
191 | Create_Branches_KinFitData(locBranchRegister, locEventLoop, locReaction, locIsMCDataFlag); |
192 | |
193 | |
194 | Create_CustomBranches_DataTree(locBranchRegister, locEventLoop, locReaction, locIsMCDataFlag); |
195 | |
196 | |
197 | locTreeInterface->Create_Branches(locBranchRegister); |
198 | locTreeInterface->Set_TreeIndexBranchNames("RunNumber", "EventNumber"); |
199 | } |
200 | |
201 | TMap* DEventWriterROOT::Create_UserInfoMaps(DTreeBranchRegister& locBranchRegister, JEventLoop* locEventLoop, const DReaction* locReaction) const |
202 | { |
203 | auto locReactionVertexInfo = dVertexInfoMap.find(locReaction)->second; |
204 | |
205 | |
206 | DKinFitType locKinFitType = locReaction->Get_KinFitType(); |
207 | |
208 | |
209 | TList* locUserInfo = locBranchRegister.Get_UserInfo(); |
210 | TMap* locNameToPIDMap = new TMap(); |
211 | locNameToPIDMap->SetName("NameToPIDMap"); |
212 | locUserInfo->Add(locNameToPIDMap); |
213 | |
214 | TMap* locNameToPositionMap = new TMap(); |
215 | locNameToPositionMap->SetName("NameToPositionMap"); |
216 | locUserInfo->Add(locNameToPositionMap); |
217 | |
218 | TMap* locPositionToNameMap = new TMap(); |
219 | locPositionToNameMap->SetName("PositionToNameMap"); |
220 | locUserInfo->Add(locPositionToNameMap); |
221 | |
222 | TMap* locPositionToPIDMap = new TMap(); |
223 | locPositionToPIDMap->SetName("PositionToPIDMap"); |
224 | locUserInfo->Add(locPositionToPIDMap); |
225 | |
226 | TMap* locDecayProductMap = new TMap(); |
227 | locDecayProductMap->SetName("DecayProductMap"); |
228 | locUserInfo->Add(locDecayProductMap); |
229 | |
230 | TMap* locMiscInfoMap = new TMap(); |
231 | locMiscInfoMap->SetName("MiscInfoMap"); |
232 | locUserInfo->Add(locMiscInfoMap); |
233 | |
234 | TList* locParticleNameList = new TList(); |
235 | locParticleNameList->SetName("ParticleNameList"); |
236 | locUserInfo->Add(locParticleNameList); |
237 | |
238 | |
239 | ostringstream locKinFitTypeStream; |
240 | locKinFitTypeStream << locKinFitType; |
241 | locMiscInfoMap->Add(new TObjString("KinFitType"), new TObjString(locKinFitTypeStream.str().c_str())); |
242 | |
243 | string ANALYSIS_VERSION_STRING = ""; |
244 | if(gPARMS->Exists("ANALYSIS:DATAVERSIONSTRING")) |
245 | gPARMS->GetParameter("ANALYSIS:DATAVERSIONSTRING", ANALYSIS_VERSION_STRING); |
246 | if(ANALYSIS_VERSION_STRING != "") |
247 | locMiscInfoMap->Add(new TObjString("ANALYSIS:DATAVERSIONSTRING"), new TObjString(ANALYSIS_VERSION_STRING.c_str())); |
248 | |
249 | string HDDM_DATA_VERSION_STRING = ""; |
250 | if(gPARMS->Exists("REST:DATAVERSIONSTRING")) |
251 | gPARMS->GetParameter("REST:DATAVERSIONSTRING", HDDM_DATA_VERSION_STRING); |
252 | if(HDDM_DATA_VERSION_STRING != "") |
253 | locMiscInfoMap->Add(new TObjString("REST:DATAVERSIONSTRING"), new TObjString(HDDM_DATA_VERSION_STRING.c_str())); |
254 | |
255 | string REST_JANA_CALIB_CONTEXT = ""; |
256 | if(gPARMS->Exists("REST:JANACALIBCONTEXT")) |
257 | gPARMS->GetParameter("REST:JANACALIBCONTEXT", REST_JANA_CALIB_CONTEXT); |
258 | if(REST_JANA_CALIB_CONTEXT == "") |
259 | gPARMS->GetParameter("JANA_CALIB_CONTEXT", REST_JANA_CALIB_CONTEXT); |
260 | if(REST_JANA_CALIB_CONTEXT != "") |
261 | locMiscInfoMap->Add(new TObjString("REST:JANACALIBCONTEXT"), new TObjString(REST_JANA_CALIB_CONTEXT.c_str())); |
262 | |
263 | |
264 | if(gPARMS->Exists("ANALYSIS:BCAL_VERBOSE_ROOT_OUTPUT")) |
265 | gPARMS->GetParameter("ANALYSIS:BCAL_VERBOSE_ROOT_OUTPUT", BCAL_VERBOSE_OUTPUT); |
266 | if(gPARMS->Exists("ANALYSIS:FCAL_VERBOSE_ROOT_OUTPUT")) |
267 | gPARMS->GetParameter("ANALYSIS:FCAL_VERBOSE_ROOT_OUTPUT", FCAL_VERBOSE_OUTPUT); |
268 | if(gPARMS->Exists("ANALYSIS:CCAL_VERBOSE_ROOT_OUTPUT")) |
269 | gPARMS->GetParameter("ANALYSIS:CCAL_VERBOSE_ROOT_OUTPUT", CCAL_VERBOSE_OUTPUT); |
270 | if(gPARMS->Exists("ANALYSIS:DIRC_ROOT_OUTPUT")) |
271 | gPARMS->GetParameter("ANALYSIS:DIRC_ROOT_OUTPUT", DIRC_OUTPUT); |
272 | if(gPARMS->Exists("ANALYSIS:STORE_PULL_INFO")) |
273 | gPARMS->GetParameter("ANALYSIS:STORE_PULL_INFO",STORE_PULL_INFO); |
274 | if(gPARMS->Exists("ANALYSIS:STORE_ERROR_MATRIX_INFO")) |
275 | gPARMS->GetParameter("ANALYSIS:STORE_ERROR_MATRIX_INFO",STORE_ERROR_MATRIX_INFO); |
276 | |
277 | if(locKinFitType != d_NoFit) |
278 | { |
279 | DKinFitUtils_GlueX locKinFitUtils(locEventLoop); |
280 | size_t locNumConstraints = 0, locNumUnknowns = 0; |
281 | string locConstraintString = locKinFitUtils.Get_ConstraintInfo(locReactionVertexInfo, locReaction, locNumConstraints, locNumUnknowns); |
282 | locMiscInfoMap->Add(new TObjString("KinFitConstraints"), new TObjString(locConstraintString.c_str())); |
283 | |
284 | ostringstream locKinFitInfoStream; |
285 | locKinFitInfoStream << locNumConstraints; |
286 | locMiscInfoMap->Add(new TObjString("NumKinFitConstraints"), new TObjString(locKinFitInfoStream.str().c_str())); |
287 | |
288 | locKinFitInfoStream.str(""); |
289 | locKinFitInfoStream << locNumUnknowns; |
290 | locMiscInfoMap->Add(new TObjString("NumKinFitUnknowns"), new TObjString(locKinFitInfoStream.str().c_str())); |
291 | } |
292 | |
293 | |
294 | map<Particle_t, unsigned int> locParticleNumberMap; |
295 | map<Particle_t, unsigned int> locDecayingParticleNumberMap; |
296 | map<Particle_t, unsigned int> locTargetParticleNumberMap; |
297 | for(size_t loc_i = 0; loc_i < locReaction->Get_NumReactionSteps(); ++loc_i) |
298 | { |
299 | const DReactionStep* locReactionStep = locReaction->Get_ReactionStep(loc_i); |
300 | auto locFinalParticleIDs = locReactionStep->Get_FinalPIDs(); |
301 | |
302 | auto locTargetPID = locReactionStep->Get_TargetPID(); |
303 | if(locTargetPID != Unknown) |
304 | { |
305 | if(locTargetParticleNumberMap.find(locTargetPID) == locTargetParticleNumberMap.end()) |
306 | locTargetParticleNumberMap[locTargetPID] = 1; |
307 | else |
308 | ++locTargetParticleNumberMap[locTargetPID]; |
309 | } |
310 | |
311 | for(size_t loc_j = 0; loc_j < locFinalParticleIDs.size(); ++loc_j) |
312 | { |
313 | if(locReactionStep->Get_MissingParticleIndex() == int(loc_j)) |
314 | continue; |
315 | Particle_t locPID = locFinalParticleIDs[loc_j]; |
316 | |
317 | |
318 | int locDecayStepIndex = DAnalysis::Get_DecayStepIndex(locReaction, loc_i, loc_j); |
319 | if(locDecayStepIndex >= 0) |
320 | { |
321 | if(locDecayingParticleNumberMap.find(locPID) == locDecayingParticleNumberMap.end()) |
322 | locDecayingParticleNumberMap[locPID] = 1; |
323 | else |
324 | ++locDecayingParticleNumberMap[locPID]; |
325 | } |
326 | else |
327 | { |
328 | if(locParticleNumberMap.find(locPID) == locParticleNumberMap.end()) |
329 | locParticleNumberMap[locPID] = 1; |
330 | else |
331 | ++locParticleNumberMap[locPID]; |
332 | } |
333 | } |
334 | } |
335 | |
336 | |
337 | map<Particle_t, unsigned int> locParticleNumberMap_Current, locDecayingParticleNumberMap_Current, locTargetParticleNumberMap_Current; |
338 | Particle_t locTargetPID = Unknown; |
339 | TObjString *locObjString_PID, *locObjString_Position, *locObjString_ParticleName; |
340 | map<int, string> locDecayingParticleNames; |
341 | for(size_t loc_i = 0; loc_i < locReaction->Get_NumReactionSteps(); ++loc_i) |
342 | { |
343 | const DReactionStep* locReactionStep = locReaction->Get_ReactionStep(loc_i); |
344 | |
345 | |
346 | { |
347 | ostringstream locPIDStream, locPositionStream, locParticleNameStream; |
348 | Particle_t locPID = locReactionStep->Get_InitialPID(); |
349 | locPIDStream << PDGtype(locPID); |
350 | locObjString_PID = new TObjString(locPIDStream.str().c_str()); |
351 | |
352 | locPositionStream << loc_i << "_" << -1; |
353 | locObjString_Position = new TObjString(locPositionStream.str().c_str()); |
354 | |
355 | locPositionToPIDMap->Add(locObjString_Position, locObjString_PID); |
356 | if((loc_i == 0) && ((locPID == Gamma) || (locPID == Electron) || (locPID == Positron))) |
357 | { |
358 | locParticleNameStream << "ComboBeam"; |
359 | locObjString_ParticleName = new TObjString(locParticleNameStream.str().c_str()); |
360 | locNameToPIDMap->Add(locObjString_ParticleName, locObjString_PID); |
361 | locParticleNameList->AddLast(locObjString_ParticleName); |
362 | } |
363 | else |
364 | { |
365 | if(loc_i == 0) |
366 | locParticleNameStream << "Decaying" << Convert_ToBranchName(ParticleType(locPID)); |
367 | else |
368 | locParticleNameStream << locDecayingParticleNames[loc_i]; |
369 | locObjString_ParticleName = new TObjString(locParticleNameStream.str().c_str()); |
370 | if(loc_i == 0) |
371 | { |
372 | locNameToPIDMap->Add(locObjString_ParticleName, locObjString_PID); |
373 | locParticleNameList->AddLast(locObjString_ParticleName); |
374 | } |
375 | } |
376 | locPositionToNameMap->Add(locObjString_Position, locObjString_ParticleName); |
377 | locNameToPositionMap->Add(locObjString_ParticleName, locObjString_Position); |
378 | } |
379 | |
380 | |
381 | Particle_t locTempTargetPID = locReactionStep->Get_TargetPID(); |
382 | if(locTempTargetPID != Unknown) |
383 | { |
384 | locTargetPID = locTempTargetPID; |
385 | |
386 | if(locTargetParticleNumberMap_Current.find(locTargetPID) == locTargetParticleNumberMap_Current.end()) |
387 | locTargetParticleNumberMap_Current[locTargetPID] = 1; |
388 | else |
389 | ++locTargetParticleNumberMap_Current[locTargetPID]; |
390 | |
391 | ostringstream locPIDStream, locPositionStream, locParticleNameStream; |
392 | locPIDStream << PDGtype(locTargetPID); |
393 | locObjString_PID = new TObjString(locPIDStream.str().c_str()); |
394 | |
395 | locPositionStream << loc_i << "_" << -2; |
396 | locObjString_Position = new TObjString(locPositionStream.str().c_str()); |
397 | |
398 | locPositionToPIDMap->Add(locObjString_Position, locObjString_PID); |
399 | |
400 | locParticleNameStream << "Target"; |
401 | if(locTargetParticleNumberMap[locTargetPID] > 1) |
402 | locParticleNameStream << locTargetParticleNumberMap_Current[locTargetPID]; |
403 | locObjString_ParticleName = new TObjString(locParticleNameStream.str().c_str()); |
404 | |
405 | locNameToPositionMap->Add(locObjString_ParticleName, locObjString_Position); |
406 | locNameToPIDMap->Add(locObjString_ParticleName, locObjString_PID); |
407 | locPositionToNameMap->Add(locObjString_Position, locObjString_ParticleName); |
408 | |
409 | locParticleNameList->AddLast(locObjString_ParticleName); |
410 | } |
411 | |
412 | |
413 | auto locFinalParticleIDs = locReactionStep->Get_FinalPIDs(); |
414 | for(size_t loc_j = 0; loc_j < locFinalParticleIDs.size(); ++loc_j) |
415 | { |
416 | ostringstream locPIDStream, locPositionStream; |
417 | Particle_t locPID = locFinalParticleIDs[loc_j]; |
418 | locPIDStream << PDGtype(locPID); |
419 | locObjString_PID = new TObjString(locPIDStream.str().c_str()); |
420 | |
421 | locPositionStream << loc_i << "_" << loc_j; |
422 | locObjString_Position = new TObjString(locPositionStream.str().c_str()); |
423 | |
424 | if(locReactionStep->Get_MissingParticleIndex() == int(loc_j)) |
425 | { |
426 | ostringstream locParticleNameStream; |
427 | locParticleNameStream << "Missing" << Convert_ToBranchName(ParticleType(locPID)); |
428 | locObjString_ParticleName = new TObjString(locParticleNameStream.str().c_str()); |
429 | locNameToPositionMap->Add(locObjString_ParticleName, locObjString_Position); |
430 | locPositionToNameMap->Add(locObjString_Position, locObjString_ParticleName); |
431 | locNameToPIDMap->Add(locObjString_ParticleName, locObjString_PID); |
432 | string locPIDName = locParticleNameStream.str() + string("__PID"); |
433 | locMiscInfoMap->Add(new TObjString(locPIDName.c_str()), locObjString_PID); |
434 | ostringstream locMassStream; |
435 | locMassStream << ParticleMass(locPID); |
436 | string locMassName = locParticleNameStream.str() + string("__Mass"); |
437 | locMiscInfoMap->Add(new TObjString(locMassName.c_str()), new TObjString(locMassStream.str().c_str())); |
438 | locParticleNameList->AddLast(locObjString_ParticleName); |
439 | continue; |
440 | } |
441 | |
442 | |
443 | ostringstream locParticleNameStream; |
444 | |
445 | int locDecayStepIndex = DAnalysis::Get_DecayStepIndex(locReaction, loc_i, loc_j); |
446 | if(locDecayStepIndex >= 0) |
447 | { |
448 | if(locDecayingParticleNumberMap_Current.find(locPID) == locDecayingParticleNumberMap_Current.end()) |
449 | locDecayingParticleNumberMap_Current[locPID] = 1; |
450 | else |
451 | ++locDecayingParticleNumberMap_Current[locPID]; |
452 | |
453 | locParticleNameStream << "Decaying" << Convert_ToBranchName(ParticleType(locPID)); |
454 | if(locDecayingParticleNumberMap[locPID] > 1) |
455 | locParticleNameStream << locDecayingParticleNumberMap_Current[locPID]; |
456 | locDecayingParticleNames[locDecayStepIndex] = locParticleNameStream.str(); |
457 | } |
458 | else |
459 | { |
460 | if(locParticleNumberMap_Current.find(locPID) == locParticleNumberMap_Current.end()) |
461 | locParticleNumberMap_Current[locPID] = 1; |
462 | else |
463 | ++locParticleNumberMap_Current[locPID]; |
464 | |
465 | locParticleNameStream << Convert_ToBranchName(ParticleType(locPID)); |
466 | if(locParticleNumberMap[locPID] > 1) |
467 | locParticleNameStream << locParticleNumberMap_Current[locPID]; |
468 | } |
469 | |
470 | locObjString_ParticleName = new TObjString(locParticleNameStream.str().c_str()); |
471 | locParticleNameList->AddLast(locObjString_ParticleName); |
472 | |
473 | locPositionToPIDMap->Add(locObjString_Position, locObjString_PID); |
474 | locNameToPositionMap->Add(locObjString_ParticleName, locObjString_Position); |
475 | locPositionToNameMap->Add(locObjString_Position, locObjString_ParticleName); |
476 | locNameToPIDMap->Add(locObjString_ParticleName, locObjString_PID); |
477 | if(locDecayStepIndex >= 0) |
478 | { |
479 | ostringstream locMassStream; |
480 | locMassStream << ParticleMass(locPID); |
481 | string locMassName = locParticleNameStream.str() + string("__Mass"); |
482 | locMiscInfoMap->Add(new TObjString(locMassName.c_str()), new TObjString(locMassStream.str().c_str())); |
483 | } |
484 | } |
485 | } |
486 | |
487 | |
488 | Create_UserTargetInfo(locBranchRegister, locTargetPID); |
489 | |
490 | |
491 | deque<size_t> locSavedSteps; |
492 | for(size_t loc_i = 0; loc_i < locReaction->Get_NumReactionSteps(); ++loc_i) |
493 | { |
494 | const DReactionStep* locReactionStep = locReaction->Get_ReactionStep(loc_i); |
495 | |
496 | |
497 | Particle_t locPID = locReactionStep->Get_InitialPID(); |
498 | if(loc_i == 0) |
499 | continue; |
500 | if(!IsFixedMass(locPID)) |
501 | continue; |
502 | |
503 | |
504 | bool locStepAlreadySavedFlag = false; |
505 | for(size_t loc_j = 0; loc_j < locSavedSteps.size(); ++loc_j) |
506 | { |
507 | if(locSavedSteps[loc_j] != loc_i) |
508 | continue; |
509 | locStepAlreadySavedFlag = true; |
510 | break; |
511 | } |
512 | if(locStepAlreadySavedFlag) |
513 | continue; |
514 | |
515 | |
516 | ostringstream locParticleNameStream; |
517 | locParticleNameStream << locDecayingParticleNames[loc_i]; |
518 | locObjString_ParticleName = new TObjString(locParticleNameStream.str().c_str()); |
519 | |
520 | TList* locDecayProductNames = NULL; |
521 | Get_DecayProductNames(locReaction, loc_i, locPositionToNameMap, locDecayProductNames, locSavedSteps); |
522 | locDecayProductMap->Add(locObjString_ParticleName, locDecayProductNames); |
523 | } |
524 | |
525 | return locPositionToNameMap; |
526 | } |
527 | |
528 | void DEventWriterROOT::Get_DecayProductNames(const DReaction* locReaction, size_t locReactionStepIndex, TMap* locPositionToNameMap, TList*& locDecayProductNames, deque<size_t>& locSavedSteps) const |
529 | { |
530 | const DReactionStep* locReactionStep = locReaction->Get_ReactionStep(locReactionStepIndex); |
531 | |
532 | if(locDecayProductNames == NULL) |
533 | locDecayProductNames = new TList(); |
534 | |
535 | auto locFinalParticleIDs = locReactionStep->Get_FinalPIDs(); |
536 | for(size_t loc_j = 0; loc_j < locFinalParticleIDs.size(); ++loc_j) |
537 | { |
538 | |
539 | int locDecayStepIndex = DAnalysis::Get_DecayStepIndex(locReaction, locReactionStepIndex, loc_j); |
540 | if(locDecayStepIndex < 0) |
541 | { |
542 | ostringstream locPositionStream; |
543 | locPositionStream << locReactionStepIndex << "_" << loc_j; |
544 | locDecayProductNames->AddLast(locPositionToNameMap->GetValue(locPositionStream.str().c_str())); |
545 | continue; |
546 | } |
547 | |
548 | |
549 | Get_DecayProductNames(locReaction, locDecayStepIndex, locPositionToNameMap, locDecayProductNames, locSavedSteps); |
550 | } |
551 | |
552 | locSavedSteps.push_back(locReactionStepIndex); |
553 | } |
554 | |
555 | void DEventWriterROOT::Create_UserTargetInfo(DTreeBranchRegister& locBranchRegister, Particle_t locTargetPID) const |
556 | { |
557 | TList* locUserInfo = locBranchRegister.Get_UserInfo(); |
558 | TMap* locMiscInfoMap = (TMap*)locUserInfo->FindObject("MiscInfoMap"); |
559 | if(locMiscInfoMap == NULL) |
560 | { |
561 | locMiscInfoMap = new TMap(); |
562 | locMiscInfoMap->SetName("MiscInfoMap"); |
563 | locUserInfo->Add(locMiscInfoMap); |
564 | } |
565 | |
566 | |
567 | ostringstream locPIDStream; |
568 | locPIDStream << PDGtype(locTargetPID); |
569 | locMiscInfoMap->Add(new TObjString("Target__PID"), new TObjString(locPIDStream.str().c_str())); |
570 | |
571 | |
572 | ostringstream locMassStream; |
573 | locMassStream << ParticleMass(locTargetPID); |
574 | locMiscInfoMap->Add(new TObjString("Target__Mass"), new TObjString(locMassStream.str().c_str())); |
575 | |
576 | |
577 | ostringstream locZeroStream; |
578 | locZeroStream << 0.0; |
579 | TObjString* locObjString_Zero = new TObjString(locZeroStream.str().c_str()); |
580 | locMiscInfoMap->Add(new TObjString("Target__CenterX"), locObjString_Zero); |
581 | locMiscInfoMap->Add(new TObjString("Target__CenterY"), locObjString_Zero); |
582 | |
583 | |
584 | ostringstream locPositionStream; |
585 | locPositionStream << dTargetCenterZ; |
586 | TObjString* locObjString_Position = new TObjString(locPositionStream.str().c_str()); |
587 | locMiscInfoMap->Add(new TObjString("Target__CenterZ"), locObjString_Position); |
588 | } |
589 | |
590 | void DEventWriterROOT::Create_Branches_Thrown(DTreeBranchRegister& locBranchRegister, bool locIsOnlyThrownFlag) const |
591 | { |
592 | |
593 | locBranchRegister.Register_Single<Int_t>(Build_BranchName("ThrownBeam", "PID")); |
594 | locBranchRegister.Register_Single<TLorentzVector>(Build_BranchName("ThrownBeam", "X4")); |
595 | locBranchRegister.Register_Single<TLorentzVector>(Build_BranchName("ThrownBeam", "P4")); |
596 | locBranchRegister.Register_Single<Float_t>(Build_BranchName("ThrownBeam", "GeneratedEnergy")); |
597 | |
598 | |
599 | locBranchRegister.Register_Single<ULong64_t>("NumPIDThrown_FinalState"); |
600 | locBranchRegister.Register_Single<ULong64_t>("PIDThrown_Decaying"); |
601 | locBranchRegister.Register_Single<Float_t>("MCWeight"); |
602 | |
603 | |
604 | Create_Branches_ThrownParticles(locBranchRegister, locIsOnlyThrownFlag); |
605 | } |
606 | |
607 | void DEventWriterROOT::Create_Branches_ThrownParticles(DTreeBranchRegister& locBranchRegister, bool locIsOnlyThrownFlag) const |
608 | { |
609 | string locParticleBranchName = "Thrown"; |
610 | |
611 | string locArraySizeString = "NumThrown"; |
612 | locBranchRegister.Register_Single<UInt_t>(locArraySizeString); |
613 | |
614 | |
615 | locBranchRegister.Register_FundamentalArray<Int_t>(Build_BranchName(locParticleBranchName, "ParentIndex"), locArraySizeString, dInitNumThrownArraySize); |
616 | locBranchRegister.Register_FundamentalArray<Int_t>(Build_BranchName(locParticleBranchName, "PID"), locArraySizeString, dInitNumThrownArraySize); |
617 | if(!locIsOnlyThrownFlag) |
618 | { |
619 | locBranchRegister.Register_FundamentalArray<Int_t>(Build_BranchName(locParticleBranchName, "MatchID"), locArraySizeString, dInitNumThrownArraySize); |
620 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "MatchFOM"), locArraySizeString, dInitNumThrownArraySize); |
621 | } |
622 | |
623 | |
624 | locBranchRegister.Register_ClonesArray<TLorentzVector>(Build_BranchName(locParticleBranchName, "X4"), dInitNumThrownArraySize); |
625 | locBranchRegister.Register_ClonesArray<TLorentzVector>(Build_BranchName(locParticleBranchName, "P4"), dInitNumThrownArraySize); |
626 | } |
627 | |
628 | void DEventWriterROOT::Create_Branches_Beam(DTreeBranchRegister& locBranchRegister, bool locIsMCDataFlag) const |
629 | { |
630 | string locArraySizeString = "NumBeam"; |
631 | locBranchRegister.Register_Single<UInt_t>(locArraySizeString); |
632 | |
633 | string locParticleBranchName = "Beam"; |
634 | |
635 | |
636 | locBranchRegister.Register_FundamentalArray<Int_t>(Build_BranchName(locParticleBranchName, "PID"), locArraySizeString, dInitNumBeamArraySize); |
637 | if(locIsMCDataFlag) |
638 | locBranchRegister.Register_FundamentalArray<Bool_t>(Build_BranchName(locParticleBranchName, "IsGenerator"), locArraySizeString, dInitNumBeamArraySize); |
639 | |
640 | |
641 | locBranchRegister.Register_ClonesArray<TLorentzVector>(Build_BranchName(locParticleBranchName, "X4_Measured"), dInitNumThrownArraySize); |
642 | locBranchRegister.Register_ClonesArray<TLorentzVector>(Build_BranchName(locParticleBranchName, "P4_Measured"), dInitNumThrownArraySize); |
643 | } |
644 | |
645 | void DEventWriterROOT::Create_Branches_ChargedHypotheses(DTreeBranchRegister& locBranchRegister, bool locIsMCDataFlag) const |
646 | { |
647 | string locArraySizeString = "NumChargedHypos"; |
648 | locBranchRegister.Register_Single<UInt_t>(locArraySizeString); |
649 | |
650 | string locParticleBranchName = "ChargedHypo"; |
651 | |
652 | |
653 | locBranchRegister.Register_FundamentalArray<Int_t>(Build_BranchName(locParticleBranchName, "TrackID"), locArraySizeString, dInitNumTrackArraySize); |
654 | locBranchRegister.Register_FundamentalArray<Int_t>(Build_BranchName(locParticleBranchName, "PID"), locArraySizeString, dInitNumTrackArraySize); |
655 | if(locIsMCDataFlag) |
656 | locBranchRegister.Register_FundamentalArray<Int_t>(Build_BranchName(locParticleBranchName, "ThrownIndex"), locArraySizeString, dInitNumTrackArraySize); |
657 | |
658 | |
659 | locBranchRegister.Register_ClonesArray<TLorentzVector>(Build_BranchName(locParticleBranchName, "X4_Measured"), dInitNumTrackArraySize); |
660 | locBranchRegister.Register_ClonesArray<TLorentzVector>(Build_BranchName(locParticleBranchName, "P4_Measured"), dInitNumTrackArraySize); |
661 | |
662 | |
663 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "PIDFOM"), locArraySizeString, dInitNumTrackArraySize); |
664 | |
665 | |
666 | locBranchRegister.Register_FundamentalArray<UInt_t>(Build_BranchName(locParticleBranchName, "NDF_Tracking"), locArraySizeString, dInitNumTrackArraySize); |
667 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "ChiSq_Tracking"), locArraySizeString, dInitNumTrackArraySize); |
668 | locBranchRegister.Register_FundamentalArray<UInt_t>(Build_BranchName(locParticleBranchName, "NDF_DCdEdx"), locArraySizeString, dInitNumTrackArraySize); |
669 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "ChiSq_DCdEdx"), locArraySizeString, dInitNumTrackArraySize); |
670 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "dEdx_CDC"), locArraySizeString, dInitNumTrackArraySize); |
671 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "dEdx_CDC_integral"), locArraySizeString, dInitNumTrackArraySize); |
672 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "dEdx_FDC"), locArraySizeString, dInitNumTrackArraySize); |
673 | |
674 | |
675 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "HitTime"), locArraySizeString, dInitNumTrackArraySize); |
676 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "RFDeltaTVar"), locArraySizeString, dInitNumTrackArraySize); |
677 | |
678 | |
679 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "Beta_Timing"), locArraySizeString, dInitNumTrackArraySize); |
680 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "ChiSq_Timing"), locArraySizeString, dInitNumTrackArraySize); |
681 | locBranchRegister.Register_FundamentalArray<UInt_t>(Build_BranchName(locParticleBranchName, "NDF_Timing"), locArraySizeString, dInitNumTrackArraySize); |
682 | |
683 | |
684 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "dEdx_TOF"), locArraySizeString, dInitNumTrackArraySize); |
685 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "dEdx_ST"), locArraySizeString, dInitNumTrackArraySize); |
686 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "Energy_BCAL"), locArraySizeString, dInitNumNeutralArraySize); |
687 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "Energy_BCALPreshower"), locArraySizeString, dInitNumNeutralArraySize); |
688 | if(BCAL_VERBOSE_OUTPUT) { |
689 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "Energy_BCALLayer2"), locArraySizeString, dInitNumNeutralArraySize); |
690 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "Energy_BCALLayer3"), locArraySizeString, dInitNumNeutralArraySize); |
691 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "Energy_BCALLayer4"), locArraySizeString, dInitNumNeutralArraySize); |
692 | } |
693 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "SigLong_BCAL"), locArraySizeString, dInitNumNeutralArraySize); |
694 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "SigTheta_BCAL"), locArraySizeString, dInitNumNeutralArraySize); |
695 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "SigTrans_BCAL"), locArraySizeString, dInitNumNeutralArraySize); |
696 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "RMSTime_BCAL"), locArraySizeString, dInitNumNeutralArraySize); |
697 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "Energy_FCAL"), locArraySizeString, dInitNumNeutralArraySize); |
698 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "E1E9_FCAL"), locArraySizeString, dInitNumNeutralArraySize); |
699 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "E9E25_FCAL"), locArraySizeString, dInitNumNeutralArraySize); |
700 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "SumU_FCAL"), locArraySizeString, dInitNumNeutralArraySize); |
701 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "SumV_FCAL"), locArraySizeString, dInitNumNeutralArraySize); |
702 | |
703 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "Energy_CCAL"), locArraySizeString, dInitNumNeutralArraySize); |
704 | |
705 | |
706 | |
707 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "TrackBCAL_DeltaPhi"), locArraySizeString, dInitNumTrackArraySize); |
708 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "TrackBCAL_DeltaZ"), locArraySizeString, dInitNumTrackArraySize); |
709 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "TrackFCAL_DOCA"), locArraySizeString, dInitNumTrackArraySize); |
710 | |
711 | |
712 | if(DIRC_OUTPUT) { |
713 | locBranchRegister.Register_FundamentalArray<Int_t>(Build_BranchName(locParticleBranchName, "NumPhotons_DIRC"), locArraySizeString, dInitNumTrackArraySize); |
714 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "ExtrapolatedX_DIRC"), locArraySizeString, dInitNumTrackArraySize); |
715 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "ExtrapolatedY_DIRC"), locArraySizeString, dInitNumTrackArraySize); |
716 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "ThetaC_DIRC"), locArraySizeString, dInitNumTrackArraySize); |
717 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "Lele_DIRC"), locArraySizeString, dInitNumTrackArraySize); |
718 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "Lpi_DIRC"), locArraySizeString, dInitNumTrackArraySize); |
719 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "Lk_DIRC"), locArraySizeString, dInitNumTrackArraySize); |
720 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "Lp_DIRC"), locArraySizeString, dInitNumTrackArraySize); |
721 | } |
722 | } |
723 | |
724 | void DEventWriterROOT::Create_Branches_NeutralHypotheses(DTreeBranchRegister& locBranchRegister, bool locIsMCDataFlag) const |
725 | { |
726 | string locArraySizeString = "NumNeutralHypos"; |
727 | string locParticleBranchName = "NeutralHypo"; |
728 | locBranchRegister.Register_Single<UInt_t>(locArraySizeString); |
729 | |
730 | |
731 | locBranchRegister.Register_FundamentalArray<Int_t>(Build_BranchName(locParticleBranchName, "NeutralID"), locArraySizeString, dInitNumNeutralArraySize); |
732 | locBranchRegister.Register_FundamentalArray<Int_t>(Build_BranchName(locParticleBranchName, "PID"), locArraySizeString, dInitNumNeutralArraySize); |
733 | if(locIsMCDataFlag) |
734 | locBranchRegister.Register_FundamentalArray<Int_t>(Build_BranchName(locParticleBranchName, "ThrownIndex"), locArraySizeString, dInitNumNeutralArraySize); |
735 | |
736 | |
737 | locBranchRegister.Register_ClonesArray<TLorentzVector>(Build_BranchName(locParticleBranchName, "X4_Measured"), dInitNumNeutralArraySize); |
738 | locBranchRegister.Register_ClonesArray<TLorentzVector>(Build_BranchName(locParticleBranchName, "P4_Measured"), dInitNumNeutralArraySize); |
739 | |
740 | |
741 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "Beta_Timing"), locArraySizeString, dInitNumNeutralArraySize); |
742 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "ChiSq_Timing"), locArraySizeString, dInitNumNeutralArraySize); |
743 | locBranchRegister.Register_FundamentalArray<UInt_t>(Build_BranchName(locParticleBranchName, "NDF_Timing"), locArraySizeString, dInitNumNeutralArraySize); |
744 | |
745 | |
746 | locBranchRegister.Register_ClonesArray<TLorentzVector>(Build_BranchName(locParticleBranchName, "X4_Shower"), dInitNumNeutralArraySize); |
747 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "ShowerQuality"), locArraySizeString, dInitNumNeutralArraySize); |
748 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "Energy_BCAL"), locArraySizeString, dInitNumNeutralArraySize); |
749 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "Energy_BCALPreshower"), locArraySizeString, dInitNumNeutralArraySize); |
750 | if(BCAL_VERBOSE_OUTPUT) { |
751 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "Energy_BCALLayer2"), locArraySizeString, dInitNumNeutralArraySize); |
752 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "Energy_BCALLayer3"), locArraySizeString, dInitNumNeutralArraySize); |
753 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "Energy_BCALLayer4"), locArraySizeString, dInitNumNeutralArraySize); |
754 | } |
755 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "SigLong_BCAL"), locArraySizeString, dInitNumNeutralArraySize); |
756 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "SigTheta_BCAL"), locArraySizeString, dInitNumNeutralArraySize); |
757 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "SigTrans_BCAL"), locArraySizeString, dInitNumNeutralArraySize); |
758 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "RMSTime_BCAL"), locArraySizeString, dInitNumNeutralArraySize); |
759 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "Energy_FCAL"), locArraySizeString, dInitNumNeutralArraySize); |
760 | if(FCAL_VERBOSE_OUTPUT) { |
761 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "E1E9_FCAL"), locArraySizeString, dInitNumNeutralArraySize); |
762 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "E9E25_FCAL"), locArraySizeString, dInitNumNeutralArraySize); |
763 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "SumU_FCAL"), locArraySizeString, dInitNumNeutralArraySize); |
764 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "SumV_FCAL"), locArraySizeString, dInitNumNeutralArraySize); |
765 | } |
766 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "Energy_CCAL"), locArraySizeString, dInitNumNeutralArraySize); |
767 | |
768 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "TrackBCAL_DeltaPhi"), locArraySizeString, dInitNumNeutralArraySize); |
769 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "TrackBCAL_DeltaZ"), locArraySizeString, dInitNumNeutralArraySize); |
770 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "TrackFCAL_DOCA"), locArraySizeString, dInitNumNeutralArraySize); |
771 | |
772 | |
773 | |
774 | |
775 | |
776 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "PhotonRFDeltaTVar"), locArraySizeString, dInitNumNeutralArraySize); |
777 | } |
778 | |
779 | void DEventWriterROOT::Create_Branches_Combo(DTreeBranchRegister& locBranchRegister, const DReaction* locReaction, bool locIsMCDataFlag, TMap* locPositionToNameMap) const |
780 | { |
781 | auto locReactionVertexInfo = dVertexInfoMap.find(locReaction)->second; |
782 | string locNumComboString = "NumCombos"; |
783 | locBranchRegister.Register_Single<UInt_t>(locNumComboString); |
784 | |
785 | |
786 | DKinFitType locKinFitType = locReaction->Get_KinFitType(); |
787 | bool locKinFitFlag = (locKinFitType != d_NoFit); |
788 | bool locVertexKinFitFlag = locKinFitFlag && (locKinFitType != d_P4Fit); |
789 | |
790 | |
791 | locBranchRegister.Register_FundamentalArray<Bool_t>("IsComboCut", locNumComboString, dInitNumComboArraySize); |
792 | |
793 | |
794 | if(locIsMCDataFlag) |
795 | { |
796 | locBranchRegister.Register_FundamentalArray<Bool_t>("IsTrueCombo", locNumComboString, dInitNumComboArraySize); |
797 | locBranchRegister.Register_FundamentalArray<Bool_t>("IsBDTSignalCombo", locNumComboString, dInitNumComboArraySize); |
798 | } |
799 | |
800 | locBranchRegister.Register_FundamentalArray<Float_t>("RFTime_Measured", locNumComboString, dInitNumComboArraySize); |
801 | if(locKinFitFlag) |
802 | { |
803 | locBranchRegister.Register_FundamentalArray<Float_t>("ChiSq_KinFit", locNumComboString, dInitNumComboArraySize); |
804 | locBranchRegister.Register_FundamentalArray<UInt_t>("NDF_KinFit", locNumComboString, dInitNumComboArraySize); |
805 | if((locKinFitType == d_SpacetimeFit) || (locKinFitType == d_P4AndSpacetimeFit)) |
806 | locBranchRegister.Register_FundamentalArray<Float_t>("RFTime_KinFit", locNumComboString, dInitNumComboArraySize); |
807 | } |
808 | locBranchRegister.Register_FundamentalArray<UChar_t>("NumUnusedShowers", locNumComboString, dInitNumComboArraySize); |
809 | locBranchRegister.Register_FundamentalArray<Float_t>("Energy_UnusedShowers", locNumComboString, dInitNumComboArraySize); |
810 | locBranchRegister.Register_FundamentalArray<UChar_t>("NumUnusedShowers_Quality", locNumComboString, dInitNumComboArraySize); |
811 | locBranchRegister.Register_FundamentalArray<Float_t>("Energy_UnusedShowers_Quality", locNumComboString, dInitNumComboArraySize); |
812 | locBranchRegister.Register_FundamentalArray<Float_t>("SumPMag_UnusedTracks", locNumComboString, dInitNumComboArraySize); |
813 | locBranchRegister.Register_ClonesArray<TVector3>("SumP3_UnusedTracks", dInitNumComboArraySize); |
814 | |
815 | map<Particle_t, unsigned int> locParticleNumberMap_Current; |
816 | for(size_t loc_i = 0; loc_i < locReaction->Get_NumReactionSteps(); ++loc_i) |
817 | { |
818 | const DReactionStep* locReactionStep = locReaction->Get_ReactionStep(loc_i); |
819 | |
820 | |
821 | Particle_t locInitialPID = locReactionStep->Get_InitialPID(); |
822 | |
823 | if((loc_i == 0) && (locReactionStep->Get_InitialPID() != Unknown)) |
824 | Create_Branches_BeamComboParticle(locBranchRegister, locInitialPID, locKinFitType); |
825 | else |
826 | { |
827 | |
828 | ostringstream locPositionStream; |
829 | locPositionStream << loc_i << "_-1"; |
830 | TObjString* locObjString = (TObjString*)locPositionToNameMap->GetValue(locPositionStream.str().c_str()); |
831 | string locParticleBranchName = (const char*)(locObjString->GetString()); |
832 | |
833 | if(IsFixedMass(locInitialPID) && locReactionStep->Get_KinFitConstrainInitMassFlag() && ((locKinFitType == d_P4Fit) || (locKinFitType == d_P4AndVertexFit) || (locKinFitType == d_P4AndSpacetimeFit))) |
834 | locBranchRegister.Register_ClonesArray<TLorentzVector>(Build_BranchName(locParticleBranchName, "P4_KinFit"), dInitNumComboArraySize); |
835 | if((loc_i == 0) || IsDetachedVertex(locInitialPID)) |
836 | locBranchRegister.Register_ClonesArray<TLorentzVector>(Build_BranchName(locParticleBranchName, "X4"), dInitNumComboArraySize); |
837 | |
838 | auto locStepVertexInfo = locReactionVertexInfo->Get_StepVertexInfo(loc_i); |
839 | auto locParentVertexInfo = locStepVertexInfo->Get_ParentVertexInfo(); |
840 | if(IsDetachedVertex(locInitialPID) && locVertexKinFitFlag && (locParentVertexInfo != nullptr) && locStepVertexInfo->Get_FittableVertexFlag() && locParentVertexInfo->Get_FittableVertexFlag()) |
841 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "PathLengthSigma"), locNumComboString, dInitNumComboArraySize); |
842 | } |
843 | |
844 | |
845 | auto locFinalParticleIDs = locReactionStep->Get_FinalPIDs(); |
846 | for(size_t loc_j = 0; loc_j < locFinalParticleIDs.size(); ++loc_j) |
847 | { |
848 | int locDecayStepIndex = DAnalysis::Get_DecayStepIndex(locReaction, loc_i, loc_j); |
849 | if(locDecayStepIndex >= 0) |
850 | continue; |
851 | |
852 | |
853 | ostringstream locPositionStream; |
854 | locPositionStream << loc_i << "_" << loc_j; |
855 | TObjString* locObjString = (TObjString*)locPositionToNameMap->GetValue(locPositionStream.str().c_str()); |
856 | string locParticleBranchName = (const char*)(locObjString->GetString()); |
857 | |
858 | |
859 | if(locReactionStep->Get_MissingParticleIndex() == int(loc_j)) |
860 | { |
861 | |
862 | if((locKinFitType == d_P4Fit) || (locKinFitType == d_P4AndVertexFit) || (locKinFitType == d_P4AndSpacetimeFit)) |
863 | locBranchRegister.Register_ClonesArray<TLorentzVector>(Build_BranchName(locParticleBranchName, "P4_KinFit"), dInitNumComboArraySize); |
864 | continue; |
865 | } |
866 | |
867 | Particle_t locPID = locFinalParticleIDs[loc_j]; |
868 | if(ParticleCharge(locPID) == 0) |
869 | Create_Branches_ComboNeutral(locBranchRegister, locParticleBranchName, locKinFitType); |
870 | else |
871 | Create_Branches_ComboTrack(locBranchRegister, locParticleBranchName, locKinFitType); |
872 | } |
873 | } |
874 | } |
875 | |
876 | void DEventWriterROOT::Create_Branches_BeamComboParticle(DTreeBranchRegister& locBranchRegister, Particle_t locBeamPID, DKinFitType locKinFitType) const |
877 | { |
878 | string locParticleBranchName = "ComboBeam"; |
879 | string locArraySizeString = "NumCombos"; |
880 | |
881 | |
882 | locBranchRegister.Register_FundamentalArray<Int_t>(Build_BranchName(locParticleBranchName, "BeamIndex"), locArraySizeString, dInitNumComboArraySize); |
883 | |
884 | |
885 | if(locKinFitType != d_NoFit) |
886 | { |
887 | if(((locKinFitType != d_VertexFit) && (locKinFitType != d_SpacetimeFit)) || (ParticleCharge(locBeamPID) != 0)) |
888 | locBranchRegister.Register_ClonesArray<TLorentzVector>(Build_BranchName(locParticleBranchName, "P4_KinFit"), dInitNumComboArraySize); |
889 | if(locKinFitType != d_P4Fit) |
890 | locBranchRegister.Register_ClonesArray<TLorentzVector>(Build_BranchName(locParticleBranchName, "X4_KinFit"), dInitNumComboArraySize); |
891 | } |
892 | } |
893 | |
894 | void DEventWriterROOT::Create_Branches_ComboTrack(DTreeBranchRegister& locBranchRegister, string locParticleBranchName, DKinFitType locKinFitType) const |
895 | { |
896 | string locArraySizeString = "NumCombos"; |
897 | |
898 | |
899 | locBranchRegister.Register_FundamentalArray<Int_t>(Build_BranchName(locParticleBranchName, "ChargedIndex"), locArraySizeString, dInitNumComboArraySize); |
900 | |
901 | |
902 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "Beta_Timing_Measured"), locArraySizeString, dInitNumComboArraySize); |
903 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "ChiSq_Timing_Measured"), locArraySizeString, dInitNumComboArraySize); |
904 | |
905 | |
906 | if((locKinFitType != d_NoFit) && (locKinFitType != d_SpacetimeFit) && (locKinFitType != d_P4AndSpacetimeFit)) |
907 | { |
908 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "Beta_Timing_KinFit"), locArraySizeString, dInitNumComboArraySize); |
909 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "ChiSq_Timing_KinFit"), locArraySizeString, dInitNumComboArraySize); |
910 | } |
911 | |
912 | |
913 | if(locKinFitType != d_NoFit) |
914 | { |
915 | |
916 | locBranchRegister.Register_ClonesArray<TLorentzVector>(Build_BranchName(locParticleBranchName, "P4_KinFit"), dInitNumComboArraySize); |
917 | if(locKinFitType != d_P4Fit) |
918 | locBranchRegister.Register_ClonesArray<TLorentzVector>(Build_BranchName(locParticleBranchName, "X4_KinFit"), dInitNumComboArraySize); |
919 | } |
920 | } |
921 | |
922 | void DEventWriterROOT::Create_Branches_ComboNeutral(DTreeBranchRegister& locBranchRegister, string locParticleBranchName, DKinFitType locKinFitType) const |
923 | { |
924 | string locArraySizeString = "NumCombos"; |
925 | |
926 | |
927 | locBranchRegister.Register_FundamentalArray<Int_t>(Build_BranchName(locParticleBranchName, "NeutralIndex"), locArraySizeString, dInitNumComboArraySize); |
928 | |
929 | |
930 | locBranchRegister.Register_ClonesArray<TLorentzVector>(Build_BranchName(locParticleBranchName, "X4_Measured"), dInitNumComboArraySize); |
931 | locBranchRegister.Register_ClonesArray<TLorentzVector>(Build_BranchName(locParticleBranchName, "P4_Measured"), dInitNumComboArraySize); |
932 | |
933 | |
934 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "Beta_Timing_Measured"), locArraySizeString, dInitNumComboArraySize); |
935 | if(locParticleBranchName.substr(0, 6) == "Photon") |
936 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "ChiSq_Timing_Measured"), locArraySizeString, dInitNumComboArraySize); |
937 | |
938 | |
939 | if((locKinFitType != d_NoFit) && (locKinFitType != d_SpacetimeFit) && (locKinFitType != d_P4AndSpacetimeFit)) |
940 | { |
941 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "Beta_Timing_KinFit"), locArraySizeString, dInitNumComboArraySize); |
942 | if(locParticleBranchName.substr(0, 6) == "Photon") |
943 | locBranchRegister.Register_FundamentalArray<Float_t>(Build_BranchName(locParticleBranchName, "ChiSq_Timing_KinFit"), locArraySizeString, dInitNumComboArraySize); |
944 | } |
945 | |
946 | |
947 | if(locKinFitType != d_NoFit) |
948 | { |
949 | locBranchRegister.Register_ClonesArray<TLorentzVector>(Build_BranchName(locParticleBranchName, "P4_KinFit"), dInitNumComboArraySize); |
950 | if(locKinFitType != d_P4Fit) |
951 | locBranchRegister.Register_ClonesArray<TLorentzVector>(Build_BranchName(locParticleBranchName, "X4_KinFit"), dInitNumComboArraySize); |
952 | } |
953 | } |
954 | |
955 | void DEventWriterROOT::Create_Branches_KinFitData(DTreeBranchRegister& locBranchRegister, JEventLoop* locEventLoop, const DReaction* locReaction, bool locIsMCDataFlag) const |
956 | { |
957 | |
958 | if(!STORE_PULL_INFO && !STORE_ERROR_MATRIX_INFO) |
959 | return; |
960 | |
961 | |
962 | DKinFitType kfitType = locReaction->Get_KinFitType(); |
963 | |
964 | vector<Particle_t> finalchargedPIDs,finalneutralPIDs; |
965 | size_t nReactionSteps = locReaction->Get_NumReactionSteps(); |
966 | int nFinalChargedParticles,nFinalNeutralParticles; |
967 | |
968 | vector<string> pidVector = getPIDinReaction(locReaction); |
969 | map<Particle_t,int> assignMap = getNameForParticle(locReaction,pidVector); |
970 | |
971 | |
972 | int sumAllChargedParticles = 0; |
973 | int sumAllNeutralParticles = 0; |
974 | |
975 | |
976 | |
977 | for(size_t loc_i=0;loc_i<nReactionSteps;loc_i++){ |
978 | |
979 | |
980 | finalchargedPIDs = locReaction->Get_ReactionStep(loc_i)->Get_FinalPIDs(true,d_Charged,true); |
981 | nFinalChargedParticles = finalchargedPIDs.size(); |
982 | sumAllChargedParticles += nFinalChargedParticles; |
983 | |
984 | |
985 | finalneutralPIDs = locReaction->Get_ReactionStep(loc_i)->Get_FinalPIDs(true,d_Neutral,true); |
986 | nFinalNeutralParticles = finalneutralPIDs.size(); |
987 | sumAllNeutralParticles += nFinalNeutralParticles; |
988 | } |
989 | |
990 | |
991 | if(sumAllChargedParticles == 1 && (kfitType == d_VertexFit || kfitType == d_P4AndVertexFit)){ |
992 | STORE_PULL_INFO = false; |
993 | jout <<" "<< endl; |
994 | jout <<">>> WARNING: Only one charged track in the final state! No vertex fit possible! No pulls will be stored... <<<"<< endl; |
995 | jout <<" "<< endl; |
996 | } |
997 | |
998 | if(sumAllNeutralParticles > 0 && kfitType == d_VertexFit){ |
999 | STORE_PULL_INFO = false; |
1000 | jout <<" "<< endl; |
1001 | jout <<">>> WARNING: Neutral particles involved in pure vertex fit! No pulls will be stored... <<<"<< endl; |
1002 | jout <<" "<< endl; |
1003 | } |
1004 | |
1005 | if(kfitType == d_NoFit){ |
1006 | STORE_PULL_INFO = false; |
1007 | jout <<" "<< endl; |
1008 | jout <<">>> WARNING: No fit specified! No pulls will be stored... <<<"<< endl; |
1009 | jout <<" "<< endl; |
1010 | } |
1011 | |
1012 | setPullFlag(locReaction,STORE_PULL_INFO); |
1013 | |
1014 | |
1015 | |
1016 | |
1017 | string particleCovM = "numEntries_ParticleErrM"; |
1018 | string showerCovM = "numEntries_ShowerErrM"; |
1019 | string decayCovM = "numEntries_DecayErrM"; |
1020 | if(STORE_ERROR_MATRIX_INFO){ |
1021 | locBranchRegister.Register_Single<Int_t>(particleCovM); |
1022 | locBranchRegister.Register_Single<Int_t>(showerCovM); |
1023 | } |
1024 | |
1025 | |
1026 | if(STORE_PULL_INFO) |
1027 | setTreePullBranches(locBranchRegister,"ComboBeam",kfitType,dInitNumComboArraySize,true); |
1028 | if(STORE_ERROR_MATRIX_INFO) |
1029 | locBranchRegister.Register_FundamentalArray< Float_t >(Build_BranchName("ComboBeam","ErrMatrix"),particleCovM,nEntriesParticleCov); |
1030 | |
1031 | |
1032 | for(size_t loc_i=0;loc_i<nReactionSteps;loc_i++){ |
1033 | |
1034 | |
1035 | finalchargedPIDs = locReaction->Get_ReactionStep(loc_i)->Get_FinalPIDs(true,d_Charged,true); |
1036 | nFinalChargedParticles = finalchargedPIDs.size(); |
1037 | |
1038 | for(int loc_j=0;loc_j<nFinalChargedParticles;loc_j++){ |
1039 | |
1040 | string branchName = assignName(finalchargedPIDs.at(loc_j),assignMap); |
1041 | assignMap[finalchargedPIDs.at(loc_j)]--; |
1042 | if(branchName != "nada"){ |
1043 | if(STORE_PULL_INFO) setTreePullBranches(locBranchRegister,branchName,kfitType,dInitNumComboArraySize,false); |
1044 | if(STORE_ERROR_MATRIX_INFO) locBranchRegister.Register_FundamentalArray< Float_t >(Build_BranchName(branchName,"ErrMatrix"),particleCovM,nEntriesParticleCov); |
1045 | } |
1046 | } |
1047 | |
1048 | |
1049 | |
1050 | finalneutralPIDs = locReaction->Get_ReactionStep(loc_i)->Get_FinalPIDs(true,d_Neutral,true); |
1051 | nFinalNeutralParticles = finalneutralPIDs.size(); |
1052 | |
1053 | for(int loc_j=0;loc_j<nFinalNeutralParticles;loc_j++){ |
1054 | |
1055 | string branchName = assignName(finalneutralPIDs.at(loc_j),assignMap); |
1056 | assignMap[finalneutralPIDs.at(loc_j)]--; |
1057 | if(branchName != "nada"){ |
1058 | if(STORE_PULL_INFO) setTreePullBranches(locBranchRegister,branchName,kfitType,dInitNumComboArraySize,true); |
1059 | if(finalneutralPIDs.at(loc_j) == Gamma && STORE_ERROR_MATRIX_INFO) locBranchRegister.Register_FundamentalArray< Float_t >(Build_BranchName(branchName,"ErrMatrix"),showerCovM,nEntriesShowerCov); |
1060 | } |
1061 | } |
1062 | |
1063 | } |
1064 | |
1065 | |
1066 | assignMap.clear(); |
1067 | abundanceMap.clear(); |
1068 | } |
1069 | |
1070 | void DEventWriterROOT::Fill_ThrownTree(JEventLoop* locEventLoop) const |
1071 | { |
1072 | vector<const DMCThrown*> locMCThrowns_FinalState; |
1073 | locEventLoop->Get(locMCThrowns_FinalState, "FinalState"); |
1074 | |
1075 | vector<const DMCThrown*> locMCThrowns_Decaying; |
1076 | locEventLoop->Get(locMCThrowns_Decaying, "Decaying"); |
1077 | |
1078 | const DMCReaction* locMCReaction = NULL; |
1079 | locEventLoop->GetSingle(locMCReaction); |
1080 | |
1081 | ULong64_t locNumPIDThrown_FinalState = 0, locPIDThrown_Decaying = 0; |
1082 | Compute_ThrownPIDInfo(locMCThrowns_FinalState, locMCThrowns_Decaying, locNumPIDThrown_FinalState, locPIDThrown_Decaying); |
1083 | |
1084 | vector<const DMCThrown*> locMCThrownsToSave; |
1085 | map<const DMCThrown*, unsigned int> locThrownIndexMap; |
1086 | Group_ThrownParticles(locMCThrowns_FinalState, locMCThrowns_Decaying, locMCThrownsToSave, locThrownIndexMap); |
1087 | |
1088 | vector<const DBeamPhoton*> locTaggedMCGenBeams; |
1089 | locEventLoop->Get(locTaggedMCGenBeams, "TAGGEDMCGEN"); |
1090 | |
1091 | vector<const DBeamPhoton*> locMCGenBeams; |
1092 | locEventLoop->Get(locMCGenBeams, "MCGEN"); |
1093 | |
1094 | const DBeamPhoton* locTaggedMCGenBeam = locTaggedMCGenBeams.empty() ? locMCGenBeams[0] : locTaggedMCGenBeams[0]; |
1095 | |
1096 | japp->RootWriteLock(); |
1097 | |
1098 | |
1099 | dThrownTreeFillData.Fill_Single<UInt_t>("RunNumber", locEventLoop->GetJEvent().GetRunNumber()); |
1100 | dThrownTreeFillData.Fill_Single<ULong64_t>("EventNumber", locEventLoop->GetJEvent().GetEventNumber()); |
1101 | |
1102 | |
1103 | Fill_ThrownInfo(&dThrownTreeFillData, locMCReaction, locTaggedMCGenBeam, locMCThrownsToSave, locThrownIndexMap, locNumPIDThrown_FinalState, locPIDThrown_Decaying); |
1104 | |
1105 | |
1106 | Fill_CustomBranches_ThrownTree(&dThrownTreeFillData, locEventLoop, locMCReaction, locMCThrownsToSave); |
1107 | |
1108 | |
1109 | dThrownTreeInterface->Fill(dThrownTreeFillData); |
1110 | |
1111 | |
1112 | japp->RootUnLock(); |
1113 | |
1114 | } |
1115 | |
1116 | void DEventWriterROOT::Fill_DataTrees(JEventLoop* locEventLoop, string locDReactionTag) const |
1117 | { |
1118 | if(locDReactionTag == "Thrown") |
1119 | { |
1120 | cout << "WARNING: CANNOT FILL THROWN TREE WITH THIS FUNCTION." << endl; |
1121 | return; |
1122 | } |
1123 | |
1124 | vector<const DAnalysisResults*> locAnalysisResultsVector; |
1125 | locEventLoop->Get(locAnalysisResultsVector); |
1126 | |
1127 | vector<const DReaction*> locReactionsWithTag; |
1128 | locEventLoop->Get(locReactionsWithTag, locDReactionTag.c_str()); |
1129 | |
1130 | for(size_t loc_i = 0; loc_i < locAnalysisResultsVector.size(); ++loc_i) |
1131 | { |
1132 | deque<const DParticleCombo*> locPassedParticleCombos; |
1133 | locAnalysisResultsVector[loc_i]->Get_PassedParticleCombos(locPassedParticleCombos); |
1134 | if(locPassedParticleCombos.empty()) |
1135 | continue; |
1136 | |
1137 | const DReaction* locReaction = locAnalysisResultsVector[loc_i]->Get_Reaction(); |
1138 | if(!locReaction->Get_EnableTTreeOutputFlag()) |
1139 | continue; |
1140 | |
1141 | bool locReactionFoundFlag = false; |
1142 | for(size_t loc_j = 0; loc_j < locReactionsWithTag.size(); ++loc_j) |
1143 | { |
1144 | if(locReactionsWithTag[loc_j] != locReaction) |
1145 | continue; |
1146 | locReactionFoundFlag = true; |
1147 | break; |
1148 | } |
1149 | if(!locReactionFoundFlag) |
1150 | continue; |
1151 | |
1152 | Fill_DataTree(locEventLoop, locReaction, locPassedParticleCombos); |
1153 | } |
1154 | } |
1155 | |
1156 | void DEventWriterROOT::Fill_DataTree(JEventLoop* locEventLoop, const DReaction* locReaction, deque<const DParticleCombo*>& locParticleCombos) const |
1157 | { |
1158 | if(locReaction->Get_ReactionName() == "Thrown") |
1159 | { |
1160 | cout << "WARNING: CANNOT FILL THROWN TREE WITH THIS FUNCTION." << endl; |
1161 | return; |
1162 | } |
1163 | |
1164 | if(!locReaction->Get_EnableTTreeOutputFlag()) |
1165 | { |
1166 | cout << "WARNING: ROOT TTREE OUTPUT NOT ENABLED FOR THIS DREACTION (" << locReaction->Get_ReactionName() << ")" << endl; |
1167 | return; |
1168 | } |
1169 | |
1170 | |
1171 | |
1172 | vector<const DMCThrown*> locMCThrowns_FinalState; |
1173 | locEventLoop->Get(locMCThrowns_FinalState, "FinalState"); |
1174 | |
1175 | vector<const DMCThrown*> locMCThrowns_Decaying; |
1176 | locEventLoop->Get(locMCThrowns_Decaying, "Decaying"); |
1177 | |
1178 | vector<const DMCThrownMatching*> locMCThrownMatchingVector; |
1179 | locEventLoop->Get(locMCThrownMatchingVector); |
1180 | const DMCThrownMatching* locMCThrownMatching = locMCThrownMatchingVector.empty() ? NULL : locMCThrownMatchingVector[0]; |
1181 | |
1182 | vector<const DMCReaction*> locMCReactions; |
1183 | locEventLoop->Get(locMCReactions); |
1184 | const DMCReaction* locMCReaction = locMCReactions.empty() ? NULL : locMCReactions[0]; |
1185 | |
1186 | vector<const DBeamPhoton*> locTaggedMCGenBeams; |
1187 | locEventLoop->Get(locTaggedMCGenBeams, "TAGGEDMCGEN"); |
1188 | |
1189 | vector<const DBeamPhoton*> locMCGenBeams; |
1190 | locEventLoop->Get(locMCGenBeams, "MCGEN"); |
1191 | |
1192 | const DBeamPhoton* locTaggedMCGenBeam = nullptr; |
1193 | |
1194 | if (locTaggedMCGenBeams.empty()){ |
1195 | if ( !locMCGenBeams.empty() ) locTaggedMCGenBeam = locMCGenBeams[0]; |
1196 | } |
1197 | else locTaggedMCGenBeam = locTaggedMCGenBeams[0]; |
1198 | |
1199 | |
1200 | ULong64_t locNumPIDThrown_FinalState = 0, locPIDThrown_Decaying = 0; |
1201 | Compute_ThrownPIDInfo(locMCThrowns_FinalState, locMCThrowns_Decaying, locNumPIDThrown_FinalState, locPIDThrown_Decaying); |
1202 | |
1203 | |
1204 | vector<const DMCThrown*> locMCThrownsToSave; |
1205 | map<const DMCThrown*, unsigned int> locThrownIndexMap; |
1206 | Group_ThrownParticles(locMCThrowns_FinalState, locMCThrowns_Decaying, locMCThrownsToSave, locThrownIndexMap); |
1207 | |
1208 | |
1209 | |
1210 | bool locSaveUnusedFlag = locReaction->Get_SaveUnusedFlag(); |
1211 | |
1212 | |
1213 | auto locDetectedPIDs = locReaction->Get_FinalPIDs(-1, false, false, d_AllCharges, false); |
1214 | set<Particle_t> locReactionPIDs; |
1215 | for(size_t loc_j = 0; loc_j < locDetectedPIDs.size(); ++loc_j) |
1216 | locReactionPIDs.insert(locDetectedPIDs[loc_j]); |
1217 | |
1218 | |
1219 | vector<const DChargedTrackHypothesis*> locChargedTrackHypotheses; |
1220 | vector<const DNeutralParticleHypothesis*> locNeutralParticleHypotheses; |
1221 | if(locSaveUnusedFlag) |
1222 | { |
1223 | locChargedTrackHypotheses = Get_ChargedHypotheses(locEventLoop); |
1224 | locNeutralParticleHypotheses = Get_NeutralHypotheses(locEventLoop, locReactionPIDs); |
1225 | } |
1226 | else |
1227 | { |
1228 | locChargedTrackHypotheses = Get_ChargedHypotheses_Used(locEventLoop, locReaction, locParticleCombos); |
1229 | locNeutralParticleHypotheses = Get_NeutralHypotheses_Used(locEventLoop, locReaction, locReactionPIDs, locParticleCombos); |
1230 | } |
1231 | |
1232 | |
1233 | bool locBeamUsedFlag = DAnalysis::Get_IsFirstStepBeam(locReaction); |
1234 | vector<const DBeamPhoton*> locBeamPhotons = Get_BeamPhotons(locParticleCombos); |
1235 | |
1236 | |
1237 | |
1238 | |
1239 | |
1240 | |
1241 | map<pair<oid_t, Particle_t>, size_t> locObjectToArrayIndexMap; |
1242 | for(size_t loc_i = 0; loc_i < locBeamPhotons.size(); ++loc_i) |
1243 | { |
1244 | pair<oid_t, Particle_t> locBeamPair(locBeamPhotons[loc_i]->id, locBeamPhotons[loc_i]->PID()); |
1245 | locObjectToArrayIndexMap[locBeamPair] = loc_i; |
1246 | } |
1247 | |
1248 | |
1249 | for(size_t loc_i = 0; loc_i < locChargedTrackHypotheses.size(); ++loc_i) |
1250 | { |
1251 | const DTrackTimeBased* locTrackTimeBased = locChargedTrackHypotheses[loc_i]->Get_TrackTimeBased(); |
1252 | pair<oid_t, Particle_t> locTrackPair(locTrackTimeBased->id, locTrackTimeBased->PID()); |
1253 | locObjectToArrayIndexMap[locTrackPair] = loc_i; |
1254 | } |
1255 | |
1256 | |
1257 | for(size_t loc_i = 0; loc_i < locNeutralParticleHypotheses.size(); ++loc_i) |
1258 | { |
1259 | const DNeutralShower* locNeutralShower = locNeutralParticleHypotheses[loc_i]->Get_NeutralShower(); |
1260 | pair<oid_t, Particle_t> locShowerPair(locNeutralShower->id, locNeutralParticleHypotheses[loc_i]->PID()); |
1261 | locObjectToArrayIndexMap[locShowerPair] = loc_i; |
1262 | } |
1263 | |
1264 | |
1265 | |
1266 | |
1267 | const DDetectorMatches* locDetectorMatches = NULL; |
1268 | locEventLoop->GetSingle(locDetectorMatches); |
1269 | |
1270 | |
1271 | const DVertex* locVertex = NULL; |
1272 | locEventLoop->GetSingle(locVertex); |
1273 | |
1274 | |
1275 | const DTrigger* locTrigger = NULL; |
1276 | locEventLoop->GetSingle(locTrigger); |
1277 | |
1278 | |
1279 | |
1280 | japp->RootWriteLock(); |
1281 | |
1282 | Bool_t locIsThrownTopologyFlag = kFALSE; |
1283 | vector<Bool_t> locIsTrueComboFlags; |
1284 | vector<Bool_t> locIsBDTSignalComboFlags; |
1285 | if(locMCReaction != NULL) |
1286 | { |
1287 | DCutAction_ThrownTopology* locThrownTopologyAction = dCutActionMap_ThrownTopology.find(locReaction)->second; |
1288 | locIsThrownTopologyFlag = (*locThrownTopologyAction)(locEventLoop, NULL); |
1289 | for(size_t loc_i = 0; loc_i < locParticleCombos.size(); ++loc_i) |
1290 | { |
1291 | DCutAction_TrueCombo* locTrueComboAction = dCutActionMap_TrueCombo.find(locReaction)->second; |
1292 | locIsTrueComboFlags.push_back((*locTrueComboAction)(locEventLoop, locParticleCombos[loc_i])); |
1293 | |
1294 | DCutAction_BDTSignalCombo* locBDTSignalComboAction = dCutActionMap_BDTSignalCombo.find(locReaction)->second; |
1295 | locIsBDTSignalComboFlags.push_back((*locBDTSignalComboAction)(locEventLoop, locParticleCombos[loc_i])); |
1296 | } |
1297 | } |
1298 | |
1299 | |
1300 | |
1301 | |
1302 | DTreeFillData* locTreeFillData = dTreeFillDataMap.find(locReaction)->second; |
1303 | |
1304 | |
1305 | locTreeFillData->Fill_Single<UInt_t>("RunNumber", locEventLoop->GetJEvent().GetRunNumber()); |
1306 | locTreeFillData->Fill_Single<ULong64_t>("EventNumber", locEventLoop->GetJEvent().GetEventNumber()); |
1307 | locTreeFillData->Fill_Single<UInt_t>("L1TriggerBits", locTrigger->Get_L1TriggerBits()); |
1308 | |
1309 | |
1310 | DLorentzVector locProductionX4 = locVertex->dSpacetimeVertex; |
1311 | TLorentzVector locProductionTX4(locProductionX4.X(), locProductionX4.Y(), locProductionX4.Z(), locProductionX4.T()); |
1312 | locTreeFillData->Fill_Single<TLorentzVector>("X4_Production", locProductionTX4); |
1313 | |
1314 | |
1315 | if(locMCReaction != NULL) |
1316 | { |
1317 | Fill_ThrownInfo(locTreeFillData, locMCReaction, locTaggedMCGenBeam, locMCThrownsToSave, locThrownIndexMap, locNumPIDThrown_FinalState, locPIDThrown_Decaying, locMCThrownMatching); |
1318 | locTreeFillData->Fill_Single<Bool_t>("IsThrownTopology", locIsThrownTopologyFlag); |
1319 | } |
1320 | |
1321 | |
1322 | if(locBeamUsedFlag) |
1323 | { |
1324 | |
1325 | locTreeFillData->Fill_Single<UInt_t>("NumBeam", UInt_t(locBeamPhotons.size())); |
1326 | for(size_t loc_i = 0; loc_i < locBeamPhotons.size(); ++loc_i) |
1327 | Fill_BeamData(locTreeFillData, loc_i, locBeamPhotons[loc_i], locVertex, locMCThrownMatching); |
1328 | } |
1329 | |
1330 | |
1331 | locTreeFillData->Fill_Single<UInt_t>("NumChargedHypos", UInt_t(locChargedTrackHypotheses.size())); |
1332 | for(size_t loc_i = 0; loc_i < locChargedTrackHypotheses.size(); ++loc_i) |
1333 | Fill_ChargedHypo(locTreeFillData, loc_i, locChargedTrackHypotheses[loc_i], locMCThrownMatching, locThrownIndexMap, locDetectorMatches); |
1334 | |
1335 | |
1336 | locTreeFillData->Fill_Single<UInt_t>("NumNeutralHypos", UInt_t(locNeutralParticleHypotheses.size())); |
1337 | for(size_t loc_i = 0; loc_i < locNeutralParticleHypotheses.size(); ++loc_i) |
1338 | Fill_NeutralHypo(locTreeFillData, loc_i, locNeutralParticleHypotheses[loc_i], locMCThrownMatching, locThrownIndexMap, locDetectorMatches); |
1339 | |
1340 | |
1341 | double locSumPMag_UnusedTracks = 0.0; |
1342 | TVector3 locSumP3_UnusedTracks; |
1343 | int locNumUnusedTracks = dAnalysisUtilities->Calc_Momentum_UnusedTracks(locEventLoop, locParticleCombos[0], locSumPMag_UnusedTracks, locSumP3_UnusedTracks); |
1344 | locTreeFillData->Fill_Single<UChar_t>("NumUnusedTracks", locNumUnusedTracks); |
1345 | |
1346 | |
1347 | locTreeFillData->Fill_Single<UInt_t>("NumCombos", UInt_t(locParticleCombos.size())); |
1348 | for(size_t loc_i = 0; loc_i < locParticleCombos.size(); ++loc_i) |
1349 | { |
1350 | Fill_ComboData(locTreeFillData, locReaction, locParticleCombos[loc_i], loc_i, locObjectToArrayIndexMap); |
1351 | |
1352 | |
1353 | double locEnergy_UnusedShowers = 0.; |
1354 | double locEnergy_UnusedShowers_Quality = 0.; |
1355 | int locNumber_UnusedShowers_Quality = 0; |
1356 | int locNumber_UnusedShowers = dAnalysisUtilities->Calc_Energy_UnusedShowers(locEventLoop, locParticleCombos[loc_i], locEnergy_UnusedShowers, locNumber_UnusedShowers_Quality, locEnergy_UnusedShowers_Quality); |
1357 | locTreeFillData->Fill_Array<UChar_t>("NumUnusedShowers", locNumber_UnusedShowers, loc_i); |
1358 | locTreeFillData->Fill_Array<Float_t>("Energy_UnusedShowers", locEnergy_UnusedShowers, loc_i); |
1359 | locTreeFillData->Fill_Array<UChar_t>("NumUnusedShowers_Quality", locNumber_UnusedShowers_Quality, loc_i); |
1360 | locTreeFillData->Fill_Array<Float_t>("Energy_UnusedShowers_Quality", locEnergy_UnusedShowers_Quality, loc_i); |
1361 | |
1362 | |
1363 | double locSumPMag_UnusedTracks = 0; |
1364 | TVector3 locSumP3_UnusedTracks; |
1365 | dAnalysisUtilities->Calc_Momentum_UnusedTracks(locEventLoop, locParticleCombos[loc_i], locSumPMag_UnusedTracks, locSumP3_UnusedTracks); |
1366 | locTreeFillData->Fill_Array<Float_t>("SumPMag_UnusedTracks", locSumPMag_UnusedTracks, loc_i); |
1367 | locTreeFillData->Fill_Array<TVector3>("SumP3_UnusedTracks", locSumP3_UnusedTracks, loc_i); |
1368 | |
1369 | if(locMCReaction != NULL) |
1370 | { |
1371 | locTreeFillData->Fill_Array<Bool_t>("IsTrueCombo", locIsTrueComboFlags[loc_i], loc_i); |
1372 | locTreeFillData->Fill_Array<Bool_t>("IsBDTSignalCombo", locIsTrueComboFlags[loc_i], loc_i); |
1373 | } |
1374 | } |
1375 | |
1376 | |
1377 | Fill_KinFitData(locTreeFillData, locEventLoop, locReaction, locMCReaction, locMCThrownsToSave, locMCThrownMatching, locDetectorMatches, locBeamPhotons, locChargedTrackHypotheses, locNeutralParticleHypotheses, locParticleCombos); |
1378 | |
1379 | |
1380 | Fill_CustomBranches_DataTree(locTreeFillData, locEventLoop, locReaction, locMCReaction, locMCThrownsToSave, locMCThrownMatching, locDetectorMatches, locBeamPhotons, locChargedTrackHypotheses, locNeutralParticleHypotheses, locParticleCombos); |
1381 | |
1382 | |
1383 | DTreeInterface* locTreeInterface = dTreeInterfaceMap.find(locReaction)->second; |
1384 | locTreeInterface->Fill(*locTreeFillData); |
1385 | |
1386 | japp->RootUnLock(); |
1387 | |
1388 | } |
1389 | |
1390 | vector<const DBeamPhoton*> DEventWriterROOT::Get_BeamPhotons(const deque<const DParticleCombo*>& locParticleCombos) const |
1391 | { |
1392 | |
1393 | set<const DBeamPhoton*> locBeamPhotonSet; |
1394 | vector<const DBeamPhoton*> locBeamPhotons; |
1395 | for(size_t loc_j = 0; loc_j < locParticleCombos.size(); ++loc_j) |
1396 | { |
1397 | const DParticleComboStep* locParticleComboStep = locParticleCombos[loc_j]->Get_ParticleComboStep(0); |
1398 | const DKinematicData* locKinematicData = locParticleComboStep->Get_InitialParticle_Measured(); |
1399 | if(locKinematicData == NULL) |
1400 | continue; |
1401 | const DBeamPhoton* locBeamPhoton = dynamic_cast<const DBeamPhoton*>(locKinematicData); |
1402 | if(locBeamPhoton == NULL) |
1403 | continue; |
1404 | if(locBeamPhotonSet.find(locBeamPhoton) != locBeamPhotonSet.end()) |
1405 | continue; |
1406 | locBeamPhotonSet.insert(locBeamPhoton); |
1407 | locBeamPhotons.push_back(locBeamPhoton); |
1408 | } |
1409 | |
1410 | return locBeamPhotons; |
1411 | } |
1412 | |
1413 | vector<const DChargedTrackHypothesis*> DEventWriterROOT::Get_ChargedHypotheses(JEventLoop* locEventLoop) const |
1414 | { |
1415 | |
1416 | |
1417 | |
1418 | |
1419 | vector<const DChargedTrack*> locChargedTracks; |
1420 | locEventLoop->Get(locChargedTracks, "Combo"); |
1421 | |
1422 | vector<const DChargedTrackHypothesis*> locChargedHyposToSave; |
1423 | for(auto& locChargedTrack : locChargedTracks) |
1424 | locChargedHyposToSave.insert(locChargedHyposToSave.end(), locChargedTrack->dChargedTrackHypotheses.begin(), locChargedTrack->dChargedTrackHypotheses.end()); |
1425 | |
1426 | return locChargedHyposToSave; |
1427 | } |
1428 | |
1429 | vector<const DChargedTrackHypothesis*> DEventWriterROOT::Get_ChargedHypotheses_Used(JEventLoop* locEventLoop, const DReaction* locReaction, const deque<const DParticleCombo*>& locParticleCombos) const |
1430 | { |
1431 | |
1432 | vector<const DChargedTrackHypothesis*> locAllHypos = Get_ChargedHypotheses(locEventLoop); |
1433 | |
1434 | |
1435 | set<const DTrackTimeBased*> locUsedTimeBasedTracks; |
1436 | for(auto& locCombo : locParticleCombos) |
1437 | { |
1438 | auto locChargedParticles = locCombo->Get_FinalParticles_Measured(locReaction, d_Charged); |
1439 | for(auto& locParticle : locChargedParticles) |
1440 | locUsedTimeBasedTracks.insert(static_cast<const DChargedTrackHypothesis*>(locParticle)->Get_TrackTimeBased()); |
1441 | } |
1442 | |
1443 | |
1444 | for(auto locIterator = locAllHypos.begin(); locIterator != locAllHypos.end();) |
1445 | { |
1446 | const DTrackTimeBased* locTrackTimeBased = (*locIterator)->Get_TrackTimeBased(); |
1447 | if(locUsedTimeBasedTracks.find(locTrackTimeBased) != locUsedTimeBasedTracks.end()) |
1448 | ++locIterator; |
1449 | else |
1450 | locIterator = locAllHypos.erase(locIterator); |
1451 | } |
1452 | |
1453 | return locAllHypos; |
1454 | } |
1455 | |
1456 | vector<const DNeutralParticleHypothesis*> DEventWriterROOT::Get_NeutralHypotheses(JEventLoop* locEventLoop, const set<Particle_t>& locReactionPIDs) const |
1457 | { |
1458 | |
1459 | |
1460 | |
1461 | |
1462 | vector<const DNeutralParticle*> locNeutralParticles; |
1463 | locEventLoop->Get(locNeutralParticles, "Combo"); |
1464 | |
1465 | vector<const DNeutralParticleHypothesis*> locNeutralHyposToSave; |
1466 | for(auto& locNeutralParticle : locNeutralParticles) |
1467 | locNeutralHyposToSave.insert(locNeutralHyposToSave.end(), locNeutralParticle->dNeutralParticleHypotheses.begin(), locNeutralParticle->dNeutralParticleHypotheses.end()); |
1468 | |
1469 | return locNeutralHyposToSave; |
1470 | } |
1471 | |
1472 | vector<const DNeutralParticleHypothesis*> DEventWriterROOT::Get_NeutralHypotheses_Used(JEventLoop* locEventLoop, const DReaction* locReaction, const set<Particle_t>& locReactionPIDs, const deque<const DParticleCombo*>& locParticleCombos) const |
1473 | { |
1474 | |
1475 | vector<const DNeutralParticleHypothesis*> locAllHypos = Get_NeutralHypotheses(locEventLoop, locReactionPIDs); |
1476 | |
1477 | |
1478 | set<pair<const DNeutralShower*, Particle_t> > locUsedNeutralShowers; |
1479 | for(auto& locCombo : locParticleCombos) |
1480 | { |
1481 | auto locNeutralParticles = locCombo->Get_FinalParticles_Measured(locReaction, d_Neutral); |
1482 | for(auto& locParticle : locNeutralParticles) |
1483 | { |
1484 | const DNeutralShower* locNeutralShower = static_cast<const DNeutralParticleHypothesis*>(locParticle)->Get_NeutralShower(); |
1485 | pair<const DNeutralShower*, Particle_t> locShowerPair(locNeutralShower, locParticle->PID()); |
1486 | locUsedNeutralShowers.insert(locShowerPair); |
1487 | } |
1488 | } |
1489 | |
1490 | |
1491 | for(auto locIterator = locAllHypos.begin(); locIterator != locAllHypos.end();) |
1492 | { |
1493 | const DNeutralShower* locNeutralShower = (*locIterator)->Get_NeutralShower(); |
1494 | pair<const DNeutralShower*, Particle_t> locShowerPair(locNeutralShower, (*locIterator)->PID()); |
1495 | if(locUsedNeutralShowers.find(locShowerPair) == locUsedNeutralShowers.end()) |
1496 | locIterator = locAllHypos.erase(locIterator); |
1497 | else |
1498 | ++locIterator; |
1499 | } |
1500 | |
1501 | return locAllHypos; |
1502 | } |
1503 | |
1504 | ULong64_t DEventWriterROOT::Calc_ParticleMultiplexID(Particle_t locPID) const |
1505 | { |
1506 | int locPower = ParticleMultiplexPower(locPID); |
1507 | if(locPower == -1) |
1508 | return 0; |
1509 | |
1510 | int locIsFinalStateInt = Is_FinalStateParticle(locPID); |
1511 | if(locPID == Pi0) |
1512 | locIsFinalStateInt = 1; |
1513 | |
1514 | if(locIsFinalStateInt == 1) |
1515 | { |
1516 | ULong64_t locParticleMultiplexID = 1; |
1517 | for(int loc_i = 0; loc_i < locPower; ++loc_i) |
1518 | locParticleMultiplexID *= ULong64_t(10); |
1519 | return locParticleMultiplexID; |
1520 | } |
1521 | |
1522 | return (ULong64_t(1) << ULong64_t(locPower)); |
1523 | } |
1524 | |
1525 | void DEventWriterROOT::Compute_ThrownPIDInfo(const vector<const DMCThrown*>& locMCThrowns_FinalState, const vector<const DMCThrown*>& locMCThrowns_Decaying, ULong64_t& locNumPIDThrown_FinalState, ULong64_t& locPIDThrown_Decaying) const |
1526 | { |
1527 | |
1528 | locNumPIDThrown_FinalState = 0; |
1529 | for(size_t loc_i = 0; loc_i < locMCThrowns_FinalState.size(); ++loc_i) |
1530 | { |
1531 | Particle_t locPID = locMCThrowns_FinalState[loc_i]->PID(); |
1532 | ULong64_t locPIDMultiplexID = Calc_ParticleMultiplexID(locPID); |
1533 | if(locPIDMultiplexID == 0) |
1534 | continue; |
1535 | unsigned int locCurrentNumParticles = (locNumPIDThrown_FinalState / locPIDMultiplexID) % ULong64_t(10); |
1536 | if(locCurrentNumParticles != 9) |
1537 | locNumPIDThrown_FinalState += locPIDMultiplexID; |
1538 | } |
1539 | |
1540 | locPIDThrown_Decaying = 0; |
1541 | for(size_t loc_i = 0; loc_i < locMCThrowns_Decaying.size(); ++loc_i) |
1542 | { |
1543 | Particle_t locPID = locMCThrowns_Decaying[loc_i]->PID(); |
1544 | ULong64_t locPIDMultiplexID = Calc_ParticleMultiplexID(locPID); |
1545 | if(locPIDMultiplexID == 0) |
1546 | continue; |
1547 | if(locPID != Pi0) |
1548 | locPIDThrown_Decaying |= locPIDMultiplexID; |
1549 | else |
1550 | { |
1551 | unsigned int locCurrentNumParticles = (locNumPIDThrown_FinalState / locPIDMultiplexID) % ULong64_t(10); |
1552 | if(locCurrentNumParticles != 9) |
1553 | locNumPIDThrown_FinalState += locPIDMultiplexID; |
1554 | } |
1555 | } |
1556 | } |
1557 | |
1558 | void DEventWriterROOT::Group_ThrownParticles(const vector<const DMCThrown*>& locMCThrowns_FinalState, const vector<const DMCThrown*>& locMCThrowns_Decaying, vector<const DMCThrown*>& locMCThrownsToSave, map<const DMCThrown*, unsigned int>& locThrownIndexMap) const |
1559 | { |
1560 | locMCThrownsToSave.clear(); |
1561 | locMCThrownsToSave.insert(locMCThrownsToSave.end(), locMCThrowns_FinalState.begin(), locMCThrowns_FinalState.end()); |
1562 | locMCThrownsToSave.insert(locMCThrownsToSave.end(), locMCThrowns_Decaying.begin(), locMCThrowns_Decaying.end()); |
1563 | |
1564 | |
1565 | locThrownIndexMap.clear(); |
1566 | for(size_t loc_i = 0; loc_i < locMCThrownsToSave.size(); ++loc_i) |
1567 | locThrownIndexMap[locMCThrownsToSave[loc_i]] = loc_i; |
1568 | } |
1569 | |
1570 | void DEventWriterROOT::Fill_ThrownInfo(DTreeFillData* locTreeFillData, const DMCReaction* locMCReaction, const DBeamPhoton* locTaggedMCGenBeam, const vector<const DMCThrown*>& locMCThrowns, const map<const DMCThrown*, unsigned int>& locThrownIndexMap, ULong64_t locNumPIDThrown_FinalState, ULong64_t locPIDThrown_Decaying, const DMCThrownMatching* locMCThrownMatching) const |
1571 | { |
1572 | |
1573 | |
1574 | |
1575 | locTreeFillData->Fill_Single<Float_t>("MCWeight", locMCReaction->weight); |
1576 | |
1577 | |
1578 | locTreeFillData->Fill_Single<Int_t>(Build_BranchName("ThrownBeam", "PID"), PDGtype(locMCReaction->beam.PID())); |
1579 | locTreeFillData->Fill_Single<Float_t>(Build_BranchName("ThrownBeam", "GeneratedEnergy"), locMCReaction->beam.energy()); |
1580 | |
1581 | DVector3 locThrownBeamX3 = locMCReaction->beam.position(); |
1582 | TLorentzVector locThrownBeamTX4(locThrownBeamX3.X(), locThrownBeamX3.Y(), locThrownBeamX3.Z(), locMCReaction->beam.time()); |
1583 | locTreeFillData->Fill_Single<TLorentzVector>(Build_BranchName("ThrownBeam", "X4"), locThrownBeamTX4); |
1584 | |
1585 | DLorentzVector locThrownBeamP4 = locTaggedMCGenBeam->lorentzMomentum(); |
1586 | TLorentzVector locThrownBeamTP4(locThrownBeamP4.Px(), locThrownBeamP4.Py(), locThrownBeamP4.Pz(), locThrownBeamP4.E()); |
1587 | locTreeFillData->Fill_Single<TLorentzVector>(Build_BranchName("ThrownBeam", "P4"), locThrownBeamTP4); |
1588 | |
1589 | |
1590 | locTreeFillData->Fill_Single<UInt_t>("NumThrown", locMCThrowns.size()); |
1591 | for(size_t loc_i = 0; loc_i < locMCThrowns.size(); ++loc_i) |
1592 | Fill_ThrownParticleData(locTreeFillData, loc_i, locMCThrowns[loc_i], locThrownIndexMap, locMCThrownMatching); |
1593 | |
1594 | |
1595 | locTreeFillData->Fill_Single<ULong64_t>("NumPIDThrown_FinalState", locNumPIDThrown_FinalState); |
1596 | locTreeFillData->Fill_Single<ULong64_t>("PIDThrown_Decaying", locPIDThrown_Decaying); |
1597 | } |
1598 | |
1599 | void DEventWriterROOT::Fill_ThrownParticleData(DTreeFillData* locTreeFillData, unsigned int locArrayIndex, const DMCThrown* locMCThrown, const map<const DMCThrown*, unsigned int>& locThrownIndexMap, const DMCThrownMatching* locMCThrownMatching) const |
1600 | { |
1601 | string locParticleBranchName = "Thrown"; |
1602 | |
1603 | |
1604 | int locParentIndex = -1; |
1605 | map<const DMCThrown*, unsigned int>::const_iterator locIterator; |
1606 | for(locIterator = locThrownIndexMap.begin(); locIterator != locThrownIndexMap.end(); ++locIterator) |
1607 | { |
1608 | if(locIterator->first->myid != locMCThrown->parentid) |
1609 | continue; |
1610 | locParentIndex = locIterator->second; |
1611 | break; |
1612 | } |
1613 | locTreeFillData->Fill_Array<Int_t>(Build_BranchName(locParticleBranchName, "ParentIndex"), locParentIndex, locArrayIndex); |
1614 | locTreeFillData->Fill_Array<Int_t>(Build_BranchName(locParticleBranchName, "PID"), locMCThrown->pdgtype, locArrayIndex); |
1615 | |
1616 | |
1617 | if(locMCThrownMatching != NULL) |
1618 | { |
1619 | Int_t locMatchID = -1; |
1620 | double locMatchFOM = -1.0; |
1621 | if(ParticleCharge(locMCThrown->PID()) != 0) |
1622 | { |
1623 | const DChargedTrack* locChargedTrack = locMCThrownMatching->Get_MatchingChargedTrack(locMCThrown, locMatchFOM); |
1624 | if(locChargedTrack != NULL) |
1625 | locMatchID = locChargedTrack->candidateid; |
1626 | } |
1627 | else |
1628 | { |
1629 | |
1630 | |
1631 | const DNeutralShower* locNeutralShower = locMCThrownMatching->Get_MatchingNeutralShower(locMCThrown, locMatchFOM); |
1632 | if(locNeutralShower != NULL) |
1633 | locMatchID = locNeutralShower->dShowerID; |
1634 | } |
1635 | locTreeFillData->Fill_Array<Int_t>(Build_BranchName(locParticleBranchName, "MatchID"), locMatchID, locArrayIndex); |
1636 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "MatchFOM"), locMatchFOM, locArrayIndex); |
1637 | } |
1638 | |
1639 | |
1640 | TLorentzVector locX4_Thrown(locMCThrown->position().X(), locMCThrown->position().Y(), locMCThrown->position().Z(), locMCThrown->time()); |
1641 | locTreeFillData->Fill_Array<TLorentzVector>(Build_BranchName(locParticleBranchName, "X4"), locX4_Thrown, locArrayIndex); |
1642 | TLorentzVector locP4_Thrown(locMCThrown->momentum().X(), locMCThrown->momentum().Y(), locMCThrown->momentum().Z(), locMCThrown->energy()); |
1643 | locTreeFillData->Fill_Array<TLorentzVector>(Build_BranchName(locParticleBranchName, "P4"), locP4_Thrown, locArrayIndex); |
1644 | } |
1645 | |
1646 | void DEventWriterROOT::Fill_BeamData(DTreeFillData* locTreeFillData, unsigned int locArrayIndex, const DBeamPhoton* locBeamPhoton, const DVertex* locVertex, const DMCThrownMatching* locMCThrownMatching) const |
1647 | { |
1648 | string locParticleBranchName = "Beam"; |
1649 | |
1650 | |
1651 | locTreeFillData->Fill_Array<Int_t>(Build_BranchName(locParticleBranchName, "PID"), PDGtype(locBeamPhoton->PID()), locArrayIndex); |
1652 | |
1653 | |
1654 | if(locMCThrownMatching != NULL) |
1655 | { |
1656 | |
1657 | const DBeamPhoton* locBeamPhotonTaggedMCGEN = locMCThrownMatching->Get_TaggedMCGENBeamPhoton(); |
1658 | Bool_t locIsGeneratorFlag = kFALSE; |
1659 | if (locBeamPhotonTaggedMCGEN != NULL) |
1660 | locIsGeneratorFlag = (locBeamPhotonTaggedMCGEN->energy() == locBeamPhoton->energy() && locBeamPhotonTaggedMCGEN->dCounter == locBeamPhoton->dCounter && locBeamPhotonTaggedMCGEN->time() == locBeamPhoton->time()) ? kTRUE : kFALSE; |
1661 | locTreeFillData->Fill_Array<Bool_t>(Build_BranchName(locParticleBranchName, "IsGenerator"), locIsGeneratorFlag, locArrayIndex); |
1662 | } |
1663 | |
1664 | |
1665 | |
1666 | |
1667 | DVector3 locTargetCenter = locBeamPhoton->position(); |
1668 | DVector3 locProductionVertex = locVertex->dSpacetimeVertex.Vect(); |
1669 | double locDeltaPath = (locProductionVertex - locTargetCenter).Mag(); |
1670 | bool locDownstreamFlag = ((locProductionVertex.Z() - locTargetCenter.Z()) > 0.0); |
1671 | double locDeltaT = locDownstreamFlag ? locDeltaPath/29.9792458 : -1.0*locDeltaPath/29.9792458; |
1672 | double locTime = locBeamPhoton->time() + locDeltaT; |
1673 | |
1674 | TLorentzVector locX4_Measured(locProductionVertex.X(), locProductionVertex.Y(), locProductionVertex.Z(), locTime); |
1675 | locTreeFillData->Fill_Array<TLorentzVector>(Build_BranchName(locParticleBranchName, "X4_Measured"), locX4_Measured, locArrayIndex); |
1676 | |
1677 | DLorentzVector locDP4 = locBeamPhoton->lorentzMomentum(); |
1678 | TLorentzVector locP4_Measured(locDP4.Px(), locDP4.Py(), locDP4.Pz(), locDP4.E()); |
1679 | locTreeFillData->Fill_Array<TLorentzVector>(Build_BranchName(locParticleBranchName, "P4_Measured"), locP4_Measured, locArrayIndex); |
1680 | } |
1681 | |
1682 | void DEventWriterROOT::Fill_ChargedHypo(DTreeFillData* locTreeFillData, unsigned int locArrayIndex, const DChargedTrackHypothesis* locChargedTrackHypothesis, const DMCThrownMatching* locMCThrownMatching, const map<const DMCThrown*, unsigned int>& locThrownIndexMap, const DDetectorMatches* locDetectorMatches) const |
1683 | { |
1684 | string locParticleBranchName = "ChargedHypo"; |
1685 | |
1686 | |
1687 | auto locTrackTimeBased = locChargedTrackHypothesis->Get_TrackTimeBased(); |
1688 | |
1689 | const DBCALShower* locBCALShower = NULL; |
1690 | if(locChargedTrackHypothesis->Get_BCALShowerMatchParams() != NULL) |
1691 | locBCALShower = locChargedTrackHypothesis->Get_BCALShowerMatchParams()->dBCALShower; |
1692 | |
1693 | const DFCALShower* locFCALShower = NULL; |
1694 | if(locChargedTrackHypothesis->Get_FCALShowerMatchParams() != NULL) |
1695 | locFCALShower = locChargedTrackHypothesis->Get_FCALShowerMatchParams()->dFCALShower; |
1696 | |
1697 | |
1698 | locTreeFillData->Fill_Array<Int_t>(Build_BranchName(locParticleBranchName, "TrackID"), locTrackTimeBased->candidateid, locArrayIndex); |
1699 | locTreeFillData->Fill_Array<Int_t>(Build_BranchName(locParticleBranchName, "PID"), PDGtype(locChargedTrackHypothesis->PID()), locArrayIndex); |
1700 | |
1701 | |
1702 | if(locMCThrownMatching != NULL) |
1703 | { |
1704 | Int_t locThrownIndex = -1; |
1705 | double locMatchFOM = 0.0; |
1706 | const DMCThrown* locMCThrown = locMCThrownMatching->Get_MatchingMCThrown(locChargedTrackHypothesis, locMatchFOM); |
1707 | if(locMCThrown != NULL) |
1708 | locThrownIndex = locThrownIndexMap.find(locMCThrown)->second; |
1709 | locTreeFillData->Fill_Array<Int_t>(Build_BranchName(locParticleBranchName, "ThrownIndex"), locThrownIndex, locArrayIndex); |
1710 | } |
1711 | |
1712 | |
1713 | DVector3 locPosition = locChargedTrackHypothesis->position(); |
1714 | TLorentzVector locTX4_Measured(locPosition.X(), locPosition.Y(), locPosition.Z(), locChargedTrackHypothesis->time()); |
1715 | locTreeFillData->Fill_Array<TLorentzVector>(Build_BranchName(locParticleBranchName, "X4_Measured"), locTX4_Measured, locArrayIndex); |
1716 | |
1717 | DLorentzVector locDP4 = locChargedTrackHypothesis->lorentzMomentum(); |
1718 | TLorentzVector locP4_Measured(locDP4.Px(), locDP4.Py(), locDP4.Pz(), locDP4.E()); |
1719 | locTreeFillData->Fill_Array<TLorentzVector>(Build_BranchName(locParticleBranchName, "P4_Measured"), locP4_Measured, locArrayIndex); |
1720 | |
1721 | |
1722 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "PIDFOM"), locChargedTrackHypothesis->Get_FOM(), locArrayIndex); |
1723 | |
1724 | |
1725 | locTreeFillData->Fill_Array<UInt_t>(Build_BranchName(locParticleBranchName, "NDF_Tracking"), locTrackTimeBased->Ndof, locArrayIndex); |
1726 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "ChiSq_Tracking"), locTrackTimeBased->chisq, locArrayIndex); |
1727 | locTreeFillData->Fill_Array<UInt_t>(Build_BranchName(locParticleBranchName, "NDF_DCdEdx"), locChargedTrackHypothesis->Get_NDF_DCdEdx(), locArrayIndex); |
1728 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "ChiSq_DCdEdx"), locChargedTrackHypothesis->Get_ChiSq_DCdEdx(), locArrayIndex); |
1729 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "dEdx_CDC"), locTrackTimeBased->ddEdx_CDC_amp, locArrayIndex); |
1730 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "dEdx_CDC_integral"), locTrackTimeBased->ddEdx_CDC, locArrayIndex); |
1731 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "dEdx_FDC"), locTrackTimeBased->ddEdx_FDC, locArrayIndex); |
1732 | |
1733 | |
1734 | double locTOFdEdx = (locChargedTrackHypothesis->Get_TOFHitMatchParams() != NULL) ? locChargedTrackHypothesis->Get_TOFHitMatchParams()->dEdx : 0.0; |
1735 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "dEdx_TOF"), locTOFdEdx, locArrayIndex); |
1736 | double locSCdEdx = (locChargedTrackHypothesis->Get_SCHitMatchParams() != NULL) ? locChargedTrackHypothesis->Get_SCHitMatchParams()->dEdx : 0.0; |
1737 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "dEdx_ST"), locSCdEdx, locArrayIndex); |
1738 | double locBCALEnergy = (locBCALShower != NULL) ? locBCALShower->E : 0.0; |
1739 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "Energy_BCAL"), locBCALEnergy, locArrayIndex); |
1740 | double locBCALPreshowerEnergy = (locBCALShower != NULL) ? locBCALShower->E_preshower : 0.0; |
1741 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "Energy_BCALPreshower"), locBCALPreshowerEnergy, locArrayIndex); |
1742 | if(BCAL_VERBOSE_OUTPUT) { |
1743 | double locBCALLayer2Energy = (locBCALShower != NULL) ? locBCALShower->E_L2 : 0.0; |
1744 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "Energy_BCALLayer2"), locBCALLayer2Energy, locArrayIndex); |
1745 | double locBCALLayer3Energy = (locBCALShower != NULL) ? locBCALShower->E_L3 : 0.0; |
1746 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "Energy_BCALLayer3"), locBCALLayer3Energy, locArrayIndex); |
1747 | double locBCALLayer4Energy = (locBCALShower != NULL) ? locBCALShower->E_L4 : 0.0; |
1748 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "Energy_BCALLayer4"), locBCALLayer4Energy, locArrayIndex); |
1749 | } |
1750 | |
1751 | double locFCALEnergy = (locFCALShower != NULL) ? locFCALShower->getEnergy() : 0.0; |
1752 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "Energy_FCAL"), locFCALEnergy, locArrayIndex); |
1753 | |
1754 | |
1755 | |
1756 | |
1757 | |
1758 | double locSigLongBCAL = (locBCALShower != NULL) ? locBCALShower->sigLong : 0.0; |
1759 | double locSigThetaBCAL = (locBCALShower != NULL) ? locBCALShower->sigTheta : 0.0; |
1760 | double locSigTransBCAL = (locBCALShower != NULL) ? locBCALShower->sigTrans : 0.0; |
1761 | double locRMSTimeBCAL = (locBCALShower != NULL) ? locBCALShower->rmsTime : 0.0; |
1762 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "SigLong_BCAL"), locSigLongBCAL, locArrayIndex); |
1763 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "SigTheta_BCAL"), locSigThetaBCAL, locArrayIndex); |
1764 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "SigTrans_BCAL"), locSigTransBCAL, locArrayIndex); |
1765 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "RMSTime_BCAL"), locRMSTimeBCAL, locArrayIndex); |
1766 | |
1767 | double locE1E9FCAL = (locFCALShower != NULL) ? locFCALShower->getE1E9() : 0.0; |
1768 | double locE9E25FCAL = (locFCALShower != NULL) ? locFCALShower->getE9E25() : 0.0; |
1769 | double locSumUFCAL = (locFCALShower != NULL) ? locFCALShower->getSumU() : 0.0; |
1770 | double locSumVFCAL = (locFCALShower != NULL) ? locFCALShower->getSumV() : 0.0; |
1771 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "E1E9_FCAL"), locE1E9FCAL, locArrayIndex); |
1772 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "E9E25_FCAL"), locE9E25FCAL, locArrayIndex); |
1773 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "SumU_FCAL"), locSumUFCAL, locArrayIndex); |
1774 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "SumV_FCAL"), locSumVFCAL, locArrayIndex); |
1775 | |
1776 | |
1777 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "HitTime"), locChargedTrackHypothesis->t1(), locArrayIndex); |
1778 | double locStartTimeError = locChargedTrackHypothesis->t0_err(); |
1779 | double locRFDeltaTVariance = (*locChargedTrackHypothesis->errorMatrix())(6, 6) + locStartTimeError*locStartTimeError; |
1780 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "RFDeltaTVar"), locRFDeltaTVariance, locArrayIndex); |
1781 | |
1782 | |
1783 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "Beta_Timing"), locChargedTrackHypothesis->measuredBeta(), locArrayIndex); |
1784 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "ChiSq_Timing"), locChargedTrackHypothesis->Get_ChiSq_Timing(), locArrayIndex); |
1785 | locTreeFillData->Fill_Array<UInt_t>(Build_BranchName(locParticleBranchName, "NDF_Timing"), locChargedTrackHypothesis->Get_NDF_Timing(), locArrayIndex); |
1786 | |
1787 | |
1788 | double locTrackBCAL_DeltaPhi = 999.0, locTrackBCAL_DeltaZ = 999.0; |
1789 | if(locChargedTrackHypothesis->Get_BCALShowerMatchParams() != NULL) |
1790 | { |
1791 | locTrackBCAL_DeltaPhi = locChargedTrackHypothesis->Get_BCALShowerMatchParams()->dDeltaPhiToShower; |
1792 | locTrackBCAL_DeltaZ = locChargedTrackHypothesis->Get_BCALShowerMatchParams()->dDeltaZToShower; |
1793 | } |
1794 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "TrackBCAL_DeltaPhi"), locTrackBCAL_DeltaPhi, locArrayIndex); |
1795 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "TrackBCAL_DeltaZ"), locTrackBCAL_DeltaZ, locArrayIndex); |
1796 | |
1797 | |
1798 | double locDOCAToShower_FCAL = 999.0; |
1799 | if(locChargedTrackHypothesis->Get_FCALShowerMatchParams() != NULL) |
1800 | locDOCAToShower_FCAL = locChargedTrackHypothesis->Get_FCALShowerMatchParams()->dDOCAToShower; |
1801 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "TrackFCAL_DOCA"), locDOCAToShower_FCAL, locArrayIndex); |
1802 | |
1803 | |
1804 | if(DIRC_OUTPUT) { |
1805 | int locDIRCNumPhotons = 0; |
1806 | double locDIRCExtrapolatedX = 999; |
1807 | double locDIRCExtrapolatedY = 999; |
1808 | double locDIRCThetaC = 999.; |
1809 | double locDIRCLele = 999.; |
1810 | double locDIRCLpi = 999.; |
1811 | double locDIRCLk = 999.; |
1812 | double locDIRCLp = 999.; |
1813 | auto locDIRCMatchParams = locChargedTrackHypothesis->Get_DIRCMatchParams(); |
1814 | if(locDIRCMatchParams != NULL) { |
1815 | locDIRCExtrapolatedX = locDIRCMatchParams->dExtrapolatedPos.X(); |
1816 | locDIRCExtrapolatedY = locDIRCMatchParams->dExtrapolatedPos.Y(); |
1817 | locDIRCNumPhotons = locDIRCMatchParams->dNPhotons; |
1818 | locDIRCThetaC = locDIRCMatchParams->dThetaC; |
1819 | locDIRCLele = locDIRCMatchParams->dLikelihoodElectron; |
1820 | locDIRCLpi = locDIRCMatchParams->dLikelihoodPion; |
1821 | locDIRCLk = locDIRCMatchParams->dLikelihoodKaon; |
1822 | locDIRCLp = locDIRCMatchParams->dLikelihoodProton; |
1823 | } |
1824 | locTreeFillData->Fill_Array<Int_t>(Build_BranchName(locParticleBranchName, "NumPhotons_DIRC"), locDIRCNumPhotons, locArrayIndex); |
1825 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "ExtrapolatedX_DIRC"), locDIRCExtrapolatedX, locArrayIndex); |
1826 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "ExtrapolatedY_DIRC"), locDIRCExtrapolatedY, locArrayIndex); |
1827 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "ThetaC_DIRC"), locDIRCThetaC, locArrayIndex); |
1828 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "Lele_DIRC"), locDIRCLele, locArrayIndex); |
1829 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "Lpi_DIRC"), locDIRCLpi, locArrayIndex); |
1830 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "Lk_DIRC"), locDIRCLk, locArrayIndex); |
1831 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "Lp_DIRC"), locDIRCLp, locArrayIndex); |
1832 | } |
1833 | } |
1834 | |
1835 | void DEventWriterROOT::Fill_NeutralHypo(DTreeFillData* locTreeFillData, unsigned int locArrayIndex, const DNeutralParticleHypothesis* locNeutralParticleHypothesis, const DMCThrownMatching* locMCThrownMatching, const map<const DMCThrown*, unsigned int>& locThrownIndexMap, const DDetectorMatches* locDetectorMatches) const |
1836 | { |
1837 | string locParticleBranchName = "NeutralHypo"; |
1838 | const DNeutralShower* locNeutralShower = locNeutralParticleHypothesis->Get_NeutralShower(); |
1839 | |
1840 | |
1841 | const DBCALShower* locBCALShower = NULL; |
1842 | locNeutralShower->GetSingle(locBCALShower); |
1843 | const DFCALShower* locFCALShower = NULL; |
1844 | locNeutralShower->GetSingle(locFCALShower); |
1845 | const DCCALShower* locCCALShower = NULL; |
1846 | locNeutralShower->GetSingle(locCCALShower); |
1847 | |
1848 | |
1849 | Particle_t locPID = locNeutralParticleHypothesis->PID(); |
1850 | locTreeFillData->Fill_Array<Int_t>(Build_BranchName(locParticleBranchName, "NeutralID"), locNeutralShower->dShowerID, locArrayIndex); |
1851 | locTreeFillData->Fill_Array<Int_t>(Build_BranchName(locParticleBranchName, "PID"), PDGtype(locPID), locArrayIndex); |
1852 | |
1853 | |
1854 | if(locMCThrownMatching != NULL) |
1855 | { |
1856 | Int_t locThrownIndex = -1; |
1857 | double locMatchFOM = 0.0; |
1858 | const DMCThrown* locMCThrown = locMCThrownMatching->Get_MatchingMCThrown(locNeutralParticleHypothesis, locMatchFOM); |
1859 | if(locMCThrown != NULL) |
1860 | locThrownIndex = locThrownIndexMap.find(locMCThrown)->second; |
1861 | locTreeFillData->Fill_Array<Int_t>(Build_BranchName(locParticleBranchName, "ThrownIndex"), locThrownIndex, locArrayIndex); |
1862 | } |
1863 | |
1864 | |
1865 | DVector3 locPosition = locNeutralParticleHypothesis->position(); |
1866 | TLorentzVector locX4_Measured(locPosition.X(), locPosition.Y(), locPosition.Z(), locNeutralParticleHypothesis->time()); |
1867 | locTreeFillData->Fill_Array<TLorentzVector>(Build_BranchName(locParticleBranchName, "X4_Measured"), locX4_Measured, locArrayIndex); |
1868 | |
1869 | DLorentzVector locDP4 = locNeutralParticleHypothesis->lorentzMomentum(); |
1870 | TLorentzVector locP4_Measured(locDP4.Px(), locDP4.Py(), locDP4.Pz(), locDP4.E()); |
1871 | locTreeFillData->Fill_Array<TLorentzVector>(Build_BranchName(locParticleBranchName, "P4_Measured"), locP4_Measured, locArrayIndex); |
1872 | |
1873 | |
1874 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "Beta_Timing"), locNeutralParticleHypothesis->measuredBeta(), locArrayIndex); |
1875 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "ChiSq_Timing"), locNeutralParticleHypothesis->Get_ChiSq(), locArrayIndex); |
1876 | locTreeFillData->Fill_Array<UInt_t>(Build_BranchName(locParticleBranchName, "NDF_Timing"), locNeutralParticleHypothesis->Get_NDF(), locArrayIndex); |
1877 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "ShowerQuality"), locNeutralShower->dQuality, locArrayIndex); |
1878 | |
1879 | |
1880 | DetectorSystem_t locDetector = locNeutralShower->dDetectorSystem; |
1881 | double locBCALEnergy = (locDetector == SYS_BCAL) ? locNeutralShower->dEnergy : 0.0; |
1882 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "Energy_BCAL"), locBCALEnergy, locArrayIndex); |
1883 | double locBCALPreshowerEnergy = (locDetector == SYS_BCAL) ? static_cast<const DBCALShower*>(locNeutralShower->dBCALFCALShower)->E_preshower : 0.0; |
1884 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "Energy_BCALPreshower"), locBCALPreshowerEnergy, locArrayIndex); |
1885 | if(BCAL_VERBOSE_OUTPUT) { |
1886 | double locBCALLayer2Energy = (locBCALShower != NULL) ? locBCALShower->E_L2 : 0.0; |
1887 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "Energy_BCALLayer2"), locBCALLayer2Energy, locArrayIndex); |
1888 | double locBCALLayer3Energy = (locBCALShower != NULL) ? locBCALShower->E_L3 : 0.0; |
1889 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "Energy_BCALLayer3"), locBCALLayer3Energy, locArrayIndex); |
1890 | double locBCALLayer4Energy = (locBCALShower != NULL) ? locBCALShower->E_L4 : 0.0; |
1891 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "Energy_BCALLayer4"), locBCALLayer4Energy, locArrayIndex); |
1892 | } |
1893 | |
1894 | double locFCALEnergy = (locDetector == SYS_FCAL) ? locNeutralShower->dEnergy : 0.0; |
1895 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "Energy_FCAL"), locFCALEnergy, locArrayIndex); |
1896 | |
1897 | double locCCALEnergy = (locDetector == SYS_CCAL) ? locNeutralShower->dEnergy : 0.0; |
1898 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "Energy_CCAL"), locCCALEnergy, locArrayIndex); |
1899 | |
1900 | |
1901 | DLorentzVector locHitDX4 = locNeutralShower->dSpacetimeVertex; |
1902 | TLorentzVector locTX4_Shower(locHitDX4.X(), locHitDX4.Y(), locHitDX4.Z(), locHitDX4.T()); |
1903 | locTreeFillData->Fill_Array<TLorentzVector>(Build_BranchName(locParticleBranchName, "X4_Shower"), locTX4_Shower, locArrayIndex); |
1904 | |
1905 | |
1906 | double locSigLongBCAL = (locBCALShower != NULL) ? locBCALShower->sigLong : 0.0; |
1907 | double locSigThetaBCAL = (locBCALShower != NULL) ? locBCALShower->sigTheta : 0.0; |
1908 | double locSigTransBCAL = (locBCALShower != NULL) ? locBCALShower->sigTrans : 0.0; |
1909 | double locRMSTimeBCAL = (locBCALShower != NULL) ? locBCALShower->rmsTime : 0.0; |
1910 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "SigLong_BCAL"), locSigLongBCAL, locArrayIndex); |
1911 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "SigTheta_BCAL"), locSigThetaBCAL, locArrayIndex); |
1912 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "SigTrans_BCAL"), locSigTransBCAL, locArrayIndex); |
1913 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "RMSTime_BCAL"), locRMSTimeBCAL, locArrayIndex); |
1914 | |
1915 | if(FCAL_VERBOSE_OUTPUT) { |
1916 | double locE1E9FCAL = (locFCALShower != NULL) ? locFCALShower->getE1E9() : 0.0; |
1917 | double locE9E25FCAL = (locFCALShower != NULL) ? locFCALShower->getE9E25() : 0.0; |
1918 | double locSumUFCAL = (locFCALShower != NULL) ? locFCALShower->getSumU() : 0.0; |
1919 | double locSumVFCAL = (locFCALShower != NULL) ? locFCALShower->getSumV() : 0.0; |
1920 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "E1E9_FCAL"), locE1E9FCAL, locArrayIndex); |
1921 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "E9E25_FCAL"), locE9E25FCAL, locArrayIndex); |
1922 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "SumU_FCAL"), locSumUFCAL, locArrayIndex); |
1923 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "SumV_FCAL"), locSumVFCAL, locArrayIndex); |
1924 | } |
1925 | |
1926 | |
1927 | double locNearestTrackBCALDeltaPhi = 999.0, locNearestTrackBCALDeltaZ = 999.0; |
1928 | if(locBCALShower != NULL) |
1929 | { |
1930 | if(!locDetectorMatches->Get_DistanceToNearestTrack(locBCALShower, locNearestTrackBCALDeltaPhi, locNearestTrackBCALDeltaZ)) |
1931 | { |
1932 | locNearestTrackBCALDeltaPhi = 999.0; |
1933 | locNearestTrackBCALDeltaZ = 999.0; |
1934 | } |
1935 | else if((locNearestTrackBCALDeltaPhi > 999.0) || (locNearestTrackBCALDeltaZ > 999.0)) |
1936 | { |
1937 | locNearestTrackBCALDeltaPhi = 999.0; |
1938 | locNearestTrackBCALDeltaZ = 999.0; |
1939 | } |
1940 | } |
1941 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "TrackBCAL_DeltaPhi"), locNearestTrackBCALDeltaPhi, locArrayIndex); |
1942 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "TrackBCAL_DeltaZ"), locNearestTrackBCALDeltaZ, locArrayIndex); |
1943 | |
1944 | |
1945 | double locDistanceToNearestTrack_FCAL = 999.0; |
1946 | if(locFCALShower != NULL) |
1947 | { |
1948 | if(!locDetectorMatches->Get_DistanceToNearestTrack(locFCALShower, locDistanceToNearestTrack_FCAL)) |
1949 | locDistanceToNearestTrack_FCAL = 999.0; |
1950 | if(locDistanceToNearestTrack_FCAL > 999.0) |
1951 | locDistanceToNearestTrack_FCAL = 999.0; |
1952 | } |
1953 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "TrackFCAL_DOCA"), locDistanceToNearestTrack_FCAL, locArrayIndex); |
1954 | |
1955 | |
1956 | double locStartTimeError = locNeutralParticleHypothesis->t0_err(); |
1957 | double locPhotonRFDeltaTVar = (*locNeutralParticleHypothesis->errorMatrix())(6, 6) + locStartTimeError*locStartTimeError; |
1958 | if(locPID != Gamma) |
1959 | locPhotonRFDeltaTVar = 0.0; |
1960 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "PhotonRFDeltaTVar"), locPhotonRFDeltaTVar, locArrayIndex); |
1961 | } |
1962 | |
1963 | void DEventWriterROOT::Fill_ComboData(DTreeFillData* locTreeFillData, const DReaction* locReaction, const DParticleCombo* locParticleCombo, unsigned int locComboIndex, const map<pair<oid_t, Particle_t>, size_t>& locObjectToArrayIndexMap) const |
1964 | { |
1965 | |
1966 | const DKinFitResults* locKinFitResults = locParticleCombo->Get_KinFitResults(); |
1967 | const DEventRFBunch* locEventRFBunch = locParticleCombo->Get_EventRFBunch(); |
1968 | |
1969 | |
1970 | locTreeFillData->Fill_Array<Bool_t>("IsComboCut", kFALSE, locComboIndex); |
1971 | |
1972 | |
1973 | double locRFTime = (locEventRFBunch != NULL) ? locEventRFBunch->dTime : numeric_limits<double>::quiet_NaN(); |
1974 | locTreeFillData->Fill_Array<Float_t>("RFTime_Measured", locRFTime, locComboIndex); |
1975 | |
1976 | |
1977 | DKinFitType locKinFitType = locReaction->Get_KinFitType(); |
1978 | bool locKinFitFlag = (locKinFitType != d_NoFit); |
1979 | if(locKinFitFlag) |
1980 | { |
1981 | if(locKinFitResults != NULL) |
1982 | { |
1983 | locTreeFillData->Fill_Array<Float_t>("ChiSq_KinFit", locKinFitResults->Get_ChiSq(), locComboIndex); |
1984 | locTreeFillData->Fill_Array<UInt_t>("NDF_KinFit", locKinFitResults->Get_NDF(), locComboIndex); |
1985 | if((locKinFitType == d_SpacetimeFit) || (locKinFitType == d_P4AndSpacetimeFit)) |
1986 | { |
1987 | double locRFTime_KinFit = -9.9E9; |
1988 | locTreeFillData->Fill_Array<Float_t>("RFTime_KinFit", locRFTime_KinFit, locComboIndex); |
1989 | } |
1990 | } |
1991 | else |
1992 | { |
1993 | locTreeFillData->Fill_Array<Float_t>("ChiSq_KinFit", 0.0, locComboIndex); |
1994 | locTreeFillData->Fill_Array<UInt_t>("NDF_KinFit", 0, locComboIndex); |
1995 | if((locKinFitType == d_SpacetimeFit) || (locKinFitType == d_P4AndSpacetimeFit)) |
1996 | locTreeFillData->Fill_Array<Float_t>("RFTime_KinFit", -9.9E9, locComboIndex); |
1997 | } |
1998 | } |
1999 | |
2000 | |
2001 | for(size_t loc_i = 0; loc_i < locParticleCombo->Get_NumParticleComboSteps(); ++loc_i) |
2002 | Fill_ComboStepData(locTreeFillData, locReaction, locParticleCombo, loc_i, locComboIndex, locKinFitType, locObjectToArrayIndexMap); |
2003 | } |
2004 | |
2005 | void DEventWriterROOT::Fill_ComboStepData(DTreeFillData* locTreeFillData, const DReaction* locReaction, const DParticleCombo* locParticleCombo, unsigned int locStepIndex, unsigned int locComboIndex, DKinFitType locKinFitType, const map<pair<oid_t, Particle_t>, size_t>& locObjectToArrayIndexMap) const |
2006 | { |
2007 | auto locReactionVertexInfo = dVertexInfoMap.find(locReaction)->second; |
2008 | auto locReactionStep = locReaction->Get_ReactionStep(locStepIndex); |
2009 | const TList* locUserInfo = dTreeInterfaceMap.find(locReaction)->second->Get_UserInfo(); |
2010 | const TMap* locPositionToNameMap = (TMap*)locUserInfo->FindObject("PositionToNameMap"); |
2011 | |
2012 | auto locParticleComboStep = locParticleCombo->Get_ParticleComboStep(locStepIndex); |
2013 | DLorentzVector locStepX4 = locParticleComboStep->Get_SpacetimeVertex(); |
2014 | TLorentzVector locStepTX4(locStepX4.X(), locStepX4.Y(), locStepX4.Z(), locStepX4.T()); |
2015 | |
2016 | |
2017 | Particle_t locInitialPID = locReactionStep->Get_InitialPID(); |
2018 | const DKinematicData* locInitialParticle = locParticleComboStep->Get_InitialParticle(); |
2019 | const DBeamPhoton* locBeamPhoton = dynamic_cast<const DBeamPhoton*>(locInitialParticle); |
2020 | if(locBeamPhoton != NULL) |
2021 | { |
2022 | const DKinematicData* locInitParticleMeasured = locParticleComboStep->Get_InitialParticle_Measured(); |
2023 | const DBeamPhoton* locMeasuredBeamPhoton = dynamic_cast<const DBeamPhoton*>(locInitParticleMeasured); |
2024 | |
2025 | |
2026 | pair<oid_t, Particle_t> locBeamPair(locMeasuredBeamPhoton->id, locMeasuredBeamPhoton->PID()); |
2027 | size_t locBeamIndex = locObjectToArrayIndexMap.find(locBeamPair)->second; |
2028 | |
2029 | Fill_ComboBeamData(locTreeFillData, locComboIndex, locBeamPhoton, locBeamIndex, locKinFitType); |
2030 | } |
2031 | else |
2032 | { |
2033 | |
2034 | ostringstream locPositionStream; |
2035 | locPositionStream << locStepIndex << "_-1"; |
2036 | TObjString* locObjString = (TObjString*)locPositionToNameMap->GetValue(locPositionStream.str().c_str()); |
2037 | string locParticleBranchName = (const char*)(locObjString->GetString()); |
2038 | |
2039 | auto locP4FitFlag = ((locKinFitType == d_P4Fit) || (locKinFitType == d_P4AndVertexFit) || (locKinFitType == d_P4AndSpacetimeFit)); |
2040 | if(IsFixedMass(locInitialPID) && locReactionStep->Get_KinFitConstrainInitMassFlag() && locP4FitFlag) |
2041 | { |
2042 | TLorentzVector locDecayP4; |
2043 | if(locInitialParticle == NULL) |
2044 | { |
2045 | |
2046 | DLorentzVector locDecayDP4 = dAnalysisUtilities->Calc_FinalStateP4(locReaction, locParticleCombo, locStepIndex, false); |
2047 | locDecayDP4.SetE(sqrt(locDecayDP4.Vect().Mag2() + ParticleMass(locInitialPID)*ParticleMass(locInitialPID))); |
2048 | locDecayP4.SetPxPyPzE(locDecayDP4.Px(), locDecayDP4.Py(), locDecayDP4.Pz(), locDecayDP4.E()); |
2049 | } |
2050 | else |
2051 | locDecayP4.SetPxPyPzE(locInitialParticle->momentum().X(), locInitialParticle->momentum().Y(), locInitialParticle->momentum().Z(), locInitialParticle->energy()); |
2052 | locTreeFillData->Fill_Array<TLorentzVector>(Build_BranchName(locParticleBranchName, "P4_KinFit"), locDecayP4, locComboIndex); |
2053 | } |
2054 | |
2055 | if((locStepIndex == 0) || IsDetachedVertex(locInitialPID)) |
2056 | locTreeFillData->Fill_Array<TLorentzVector>(Build_BranchName(locParticleBranchName, "X4"), locStepTX4, locComboIndex); |
2057 | |
2058 | auto locStepVertexInfo = locReactionVertexInfo->Get_StepVertexInfo(locStepIndex); |
2059 | auto locParentVertexInfo = locStepVertexInfo->Get_ParentVertexInfo(); |
2060 | auto locVertexKinFitFlag = ((locKinFitType != d_P4Fit) && (locKinFitType != d_NoFit)); |
2061 | if(IsDetachedVertex(locInitialPID) && locVertexKinFitFlag && (locParentVertexInfo != nullptr) && locStepVertexInfo->Get_FittableVertexFlag() && locParentVertexInfo->Get_FittableVertexFlag()) |
2062 | { |
2063 | auto locKinFitParticle = locParticleComboStep->Get_InitialKinFitParticle(); |
2064 | auto locPathLengthSigma = locKinFitParticle->Get_PathLengthUncertainty(); |
2065 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "PathLengthSigma"), locPathLengthSigma, locComboIndex); |
2066 | } |
2067 | } |
2068 | |
2069 | |
2070 | for(size_t loc_i = 0; loc_i < locParticleComboStep->Get_NumFinalParticles(); ++loc_i) |
2071 | { |
2072 | Particle_t locPID = locReactionStep->Get_FinalPID(loc_i); |
2073 | const DKinematicData* locKinematicData = locParticleComboStep->Get_FinalParticle(loc_i); |
2074 | const DKinematicData* locKinematicData_Measured = locParticleComboStep->Get_FinalParticle_Measured(loc_i); |
2075 | |
2076 | |
2077 | if(DAnalysis::Get_DecayStepIndex(locReaction, locStepIndex, loc_i) >= 0) |
2078 | continue; |
2079 | |
2080 | |
2081 | ostringstream locPositionStream; |
2082 | locPositionStream << locStepIndex << "_" << loc_i; |
2083 | TObjString* locObjString = (TObjString*)locPositionToNameMap->GetValue(locPositionStream.str().c_str()); |
2084 | string locParticleBranchName = (const char*)(locObjString->GetString()); |
2085 | |
2086 | |
2087 | if(locReactionStep->Get_MissingParticleIndex() == int(loc_i)) |
2088 | { |
2089 | if((locKinFitType == d_P4Fit) || (locKinFitType == d_P4AndVertexFit) || (locKinFitType == d_P4AndSpacetimeFit)) |
2090 | { |
2091 | TLorentzVector locMissingP4; |
2092 | if(locKinematicData == NULL) |
2093 | { |
2094 | |
2095 | DLorentzVector locMissingDP4 = dAnalysisUtilities->Calc_MissingP4(locReaction, locParticleCombo, false); |
2096 | locMissingDP4.SetE(sqrt(locMissingDP4.Vect().Mag2() + ParticleMass(locPID)*ParticleMass(locPID))); |
2097 | locMissingP4.SetPxPyPzE(locMissingDP4.Px(), locMissingDP4.Py(), locMissingDP4.Pz(), locMissingDP4.E()); |
2098 | } |
2099 | else |
2100 | locMissingP4.SetPxPyPzE(locKinematicData->momentum().X(), locKinematicData->momentum().Y(), locKinematicData->momentum().Z(), locKinematicData->energy()); |
2101 | |
2102 | locTreeFillData->Fill_Array<TLorentzVector>(Build_BranchName(locParticleBranchName, "P4_KinFit"), locMissingP4, locComboIndex); |
2103 | } |
2104 | continue; |
2105 | } |
2106 | |
2107 | |
2108 | if(ParticleCharge(locPID) == 0) |
2109 | { |
2110 | const DNeutralParticleHypothesis* locNeutralHypo = dynamic_cast<const DNeutralParticleHypothesis*>(locKinematicData); |
2111 | const DNeutralParticleHypothesis* locMeasuredNeutralHypo = dynamic_cast<const DNeutralParticleHypothesis*>(locKinematicData_Measured); |
2112 | |
2113 | |
2114 | const DNeutralShower* locNeutralShower = locNeutralHypo->Get_NeutralShower(); |
2115 | pair<oid_t, Particle_t> locNeutralPair(locNeutralShower->id, locNeutralHypo->PID()); |
2116 | size_t locNeutralIndex = locObjectToArrayIndexMap.find(locNeutralPair)->second; |
2117 | |
2118 | Fill_ComboNeutralData(locTreeFillData, locComboIndex, locParticleBranchName, locMeasuredNeutralHypo, locNeutralHypo, locNeutralIndex, locKinFitType); |
2119 | } |
2120 | else |
2121 | { |
2122 | const DChargedTrackHypothesis* locChargedHypo = dynamic_cast<const DChargedTrackHypothesis*>(locKinematicData); |
2123 | const DChargedTrackHypothesis* locMeasuredChargedHypo = dynamic_cast<const DChargedTrackHypothesis*>(locKinematicData_Measured); |
2124 | |
2125 | |
2126 | const DTrackTimeBased* locTrackTimeBased = locChargedHypo->Get_TrackTimeBased(); |
2127 | pair<oid_t, Particle_t> locTrackPair(locTrackTimeBased->id, locChargedHypo->PID()); |
2128 | size_t locChargedIndex = locObjectToArrayIndexMap.find(locTrackPair)->second; |
2129 | |
2130 | Fill_ComboChargedData(locTreeFillData, locComboIndex, locParticleBranchName, locMeasuredChargedHypo, locChargedHypo, locChargedIndex, locKinFitType); |
2131 | } |
2132 | } |
2133 | } |
2134 | |
2135 | void DEventWriterROOT::Fill_ComboBeamData(DTreeFillData* locTreeFillData, unsigned int locComboIndex, const DBeamPhoton* locBeamPhoton, size_t locBeamIndex, DKinFitType locKinFitType) const |
2136 | { |
2137 | string locParticleBranchName = "ComboBeam"; |
2138 | |
2139 | |
2140 | locTreeFillData->Fill_Array<Int_t>(Build_BranchName(locParticleBranchName, "BeamIndex"), locBeamIndex, locComboIndex); |
2141 | |
2142 | |
2143 | if(locKinFitType != d_NoFit) |
2144 | { |
2145 | if(locKinFitType != d_P4Fit) |
2146 | { |
2147 | DVector3 locPosition = locBeamPhoton->position(); |
2148 | TLorentzVector locX4_KinFit(locPosition.X(), locPosition.Y(), locPosition.Z(), locBeamPhoton->time()); |
2149 | locTreeFillData->Fill_Array<TLorentzVector>(Build_BranchName(locParticleBranchName, "X4_KinFit"), locX4_KinFit, locComboIndex); |
2150 | } |
2151 | |
2152 | |
2153 | if(((locKinFitType != d_VertexFit) && (locKinFitType != d_SpacetimeFit)) || (ParticleCharge(locBeamPhoton->PID()) != 0)) |
2154 | { |
2155 | DLorentzVector locDP4 = locBeamPhoton->lorentzMomentum(); |
2156 | TLorentzVector locP4_KinFit(locDP4.Px(), locDP4.Py(), locDP4.Pz(), locDP4.E()); |
2157 | locTreeFillData->Fill_Array<TLorentzVector>(Build_BranchName(locParticleBranchName, "P4_KinFit"), locP4_KinFit, locComboIndex); |
2158 | } |
2159 | } |
2160 | } |
2161 | |
2162 | void DEventWriterROOT::Fill_ComboChargedData(DTreeFillData* locTreeFillData, unsigned int locComboIndex, string locParticleBranchName, const DChargedTrackHypothesis* locMeasuredChargedHypo, const DChargedTrackHypothesis* locChargedHypo, size_t locChargedIndex, DKinFitType locKinFitType) const |
2163 | { |
2164 | |
2165 | locTreeFillData->Fill_Array<Int_t>(Build_BranchName(locParticleBranchName, "ChargedIndex"), locChargedIndex, locComboIndex); |
2166 | |
2167 | |
2168 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "Beta_Timing_Measured"), locMeasuredChargedHypo->measuredBeta(), locComboIndex); |
2169 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "ChiSq_Timing_Measured"), locMeasuredChargedHypo->Get_ChiSq_Timing(), locComboIndex); |
2170 | |
2171 | |
2172 | if((locKinFitType != d_NoFit) && (locKinFitType != d_SpacetimeFit) && (locKinFitType != d_P4AndSpacetimeFit)) |
2173 | { |
2174 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "Beta_Timing_KinFit"), locChargedHypo->measuredBeta(), locComboIndex); |
2175 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "ChiSq_Timing_KinFit"), locChargedHypo->Get_ChiSq_Timing(), locComboIndex); |
2176 | } |
2177 | |
2178 | |
2179 | if(locKinFitType != d_NoFit) |
2180 | { |
2181 | |
2182 | if(locKinFitType != d_P4Fit) |
2183 | { |
2184 | DVector3 locPosition = locChargedHypo->position(); |
2185 | TLorentzVector locX4_KinFit(locPosition.X(), locPosition.Y(), locPosition.Z(), locChargedHypo->time()); |
2186 | locTreeFillData->Fill_Array<TLorentzVector>(Build_BranchName(locParticleBranchName, "X4_KinFit"), locX4_KinFit, locComboIndex); |
2187 | } |
2188 | |
2189 | |
2190 | DLorentzVector locDP4 = locChargedHypo->lorentzMomentum(); |
2191 | TLorentzVector locP4_KinFit(locDP4.Px(), locDP4.Py(), locDP4.Pz(), locDP4.E()); |
2192 | locTreeFillData->Fill_Array<TLorentzVector>(Build_BranchName(locParticleBranchName, "P4_KinFit"), locP4_KinFit, locComboIndex); |
2193 | } |
2194 | } |
2195 | |
2196 | void DEventWriterROOT::Fill_ComboNeutralData(DTreeFillData* locTreeFillData, unsigned int locComboIndex, string locParticleBranchName, const DNeutralParticleHypothesis* locMeasuredNeutralHypo, const DNeutralParticleHypothesis* locNeutralHypo, size_t locNeutralIndex, DKinFitType locKinFitType) const |
2197 | { |
2198 | |
2199 | locTreeFillData->Fill_Array<Int_t>(Build_BranchName(locParticleBranchName, "NeutralIndex"), locNeutralIndex, locComboIndex); |
2200 | |
2201 | |
2202 | DVector3 locPosition = locMeasuredNeutralHypo->position(); |
2203 | TLorentzVector locX4_Measured(locPosition.X(), locPosition.Y(), locPosition.Z(), locMeasuredNeutralHypo->time()); |
2204 | locTreeFillData->Fill_Array<TLorentzVector>(Build_BranchName(locParticleBranchName, "X4_Measured"), locX4_Measured, locComboIndex); |
2205 | |
2206 | DLorentzVector locDP4 = locMeasuredNeutralHypo->lorentzMomentum(); |
2207 | TLorentzVector locP4_Measured(locDP4.Px(), locDP4.Py(), locDP4.Pz(), locDP4.E()); |
2208 | locTreeFillData->Fill_Array<TLorentzVector>(Build_BranchName(locParticleBranchName, "P4_Measured"), locP4_Measured, locComboIndex); |
2209 | |
2210 | |
2211 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "Beta_Timing_Measured"), locMeasuredNeutralHypo->measuredBeta(), locComboIndex); |
2212 | if(locParticleBranchName.substr(0, 6) == "Photon") |
2213 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "ChiSq_Timing_Measured"), locMeasuredNeutralHypo->Get_ChiSq(), locComboIndex); |
2214 | |
2215 | |
2216 | if((locKinFitType != d_NoFit) && (locKinFitType != d_SpacetimeFit) && (locKinFitType != d_P4AndSpacetimeFit)) |
2217 | { |
2218 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "Beta_Timing_KinFit"), locNeutralHypo->measuredBeta(), locComboIndex); |
2219 | if(locParticleBranchName.substr(0, 6) == "Photon") |
2220 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(locParticleBranchName, "ChiSq_Timing_KinFit"), locNeutralHypo->Get_ChiSq(), locComboIndex); |
2221 | } |
2222 | |
2223 | |
2224 | if(locKinFitType != d_NoFit) |
2225 | { |
2226 | |
2227 | if(locKinFitType != d_P4Fit) |
2228 | { |
2229 | DVector3 locPosition = locNeutralHypo->position(); |
2230 | TLorentzVector locX4_KinFit(locPosition.X(), locPosition.Y(), locPosition.Z(), locNeutralHypo->time()); |
2231 | locTreeFillData->Fill_Array<TLorentzVector>(Build_BranchName(locParticleBranchName, "X4_KinFit"), locX4_KinFit, locComboIndex); |
2232 | } |
2233 | |
2234 | |
2235 | DLorentzVector locDP4 = locNeutralHypo->lorentzMomentum(); |
2236 | TLorentzVector locP4_KinFit(locDP4.Px(), locDP4.Py(), locDP4.Pz(), locDP4.E()); |
2237 | locTreeFillData->Fill_Array<TLorentzVector>(Build_BranchName(locParticleBranchName, "P4_KinFit"), locP4_KinFit, locComboIndex); |
2238 | } |
2239 | } |
2240 | |
2241 | void DEventWriterROOT::Fill_KinFitData(DTreeFillData* locTreeFillData, JEventLoop* locEventLoop, const DReaction* locReaction, const DMCReaction* locMCReaction, const vector<const DMCThrown*>& locMCThrowns, |
2242 | const DMCThrownMatching* locMCThrownMatching, const DDetectorMatches* locDetectorMatches, |
2243 | const vector<const DBeamPhoton*>& locBeamPhotons, const vector<const DChargedTrackHypothesis*>& locChargedHypos, |
2244 | const vector<const DNeutralParticleHypothesis*>& locNeutralHypos, const deque<const DParticleCombo*>& locParticleCombos) const |
2245 | { |
2246 | if(!STORE_PULL_INFO && !STORE_ERROR_MATRIX_INFO) |
2247 | return; |
2248 | |
2249 | if(STORE_ERROR_MATRIX_INFO){ |
2250 | locTreeFillData->Fill_Single<Int_t>("numEntries_ParticleErrM", nEntriesParticleCov); |
2251 | locTreeFillData->Fill_Single<Int_t>("numEntries_ShowerErrM", nEntriesShowerCov); |
2252 | } |
2253 | bool writeOutPulls = getPullFlag( locReaction ); |
2254 | |
2255 | |
2256 | |
2257 | DKinFitType kfitType = locReaction->Get_KinFitType(); |
2258 | |
2259 | |
2260 | int nParticleCombos = locParticleCombos.size(); |
2261 | int nMeasuredFinalParticles; |
2262 | double currentCharge; |
2263 | Particle_t currentPID; |
2264 | |
2265 | |
2266 | for(int iPC=0;iPC<nParticleCombos;iPC++){ |
2267 | Get_PullsFromFit(locParticleCombos.at(iPC)); |
2268 | |
2269 | vector<string> pidVector = getPIDinReaction(locReaction); |
2270 | map<Particle_t,int> assignMap = getNameForParticle(locReaction,pidVector); |
2271 | |
2272 | |
2273 | |
2274 | |
2275 | const DParticleComboStep* locParticleComboStep = locParticleCombos[iPC]->Get_ParticleComboStep(0); |
2276 | const DKinematicData* beamPhoton = locParticleComboStep->Get_InitialParticle_Measured(); |
2277 | |
2278 | if(kfitType == d_P4Fit || kfitType == d_P4AndVertexFit){ |
2279 | if(writeOutPulls){ |
2280 | map<DKinFitPullType, double> someBeamMap = getPulls(beamPhoton,NULL,kfitType); |
2281 | fillTreePullBranches(locTreeFillData,"ComboBeam",kfitType,someBeamMap,iPC,true); |
2282 | someBeamMap.clear(); |
2283 | } |
2284 | } |
2285 | |
2286 | |
2287 | |
2288 | |
2289 | vector<const DKinematicData*> finalParticlesMeasured = locParticleCombos.at(iPC)->Get_FinalParticles_Measured(locReaction, d_AllCharges); |
2290 | vector<const DKinematicData*> finalParticles = locParticleCombos.at(iPC)->Get_FinalParticles(locReaction, d_AllCharges); |
2291 | |
2292 | vector<const JObject*> finalParticleObjects = locParticleCombos.at(iPC)->Get_FinalParticle_SourceObjects(d_AllCharges); |
2293 | nMeasuredFinalParticles = finalParticlesMeasured.size(); |
2294 | |
2295 | |
2296 | for(int iFP=0;iFP<nMeasuredFinalParticles;iFP++){ |
2297 | const DKinematicData* part = finalParticlesMeasured.at(iFP); |
2298 | const DKinematicData* partFit = finalParticles.at(iFP); |
2299 | const DNeutralShower* sh = dynamic_cast<const DNeutralShower*>(finalParticleObjects.at(iFP)); |
2300 | bool isNeutral = false; |
2301 | |
2302 | map<DKinFitPullType, double> someMap; |
2303 | if(writeOutPulls) someMap = getPulls(part,sh,kfitType); |
2304 | |
2305 | if(sh == NULL){ |
2306 | currentCharge = part->charge(); |
2307 | currentPID = part->PID(); |
2308 | }else{ |
2309 | currentCharge = 0.0; |
2310 | currentPID = Gamma; |
2311 | } |
2312 | |
2313 | if(currentCharge == 0) isNeutral = true; |
2314 | |
2315 | |
2316 | string branchName = assignName(currentPID,assignMap); |
2317 | assignMap[currentPID]--; |
2318 | |
2319 | if(branchName != "nada"){ |
2320 | if(STORE_PULL_INFO){ |
2321 | fillTreePullBranches(locTreeFillData,branchName,kfitType,someMap,iPC,isNeutral); |
2322 | fillTreeTrackPullBranches(locTreeFillData,branchName,kfitType,someMap,iPC,isNeutral,part,partFit); |
2323 | } |
2324 | if(STORE_ERROR_MATRIX_INFO) |
2325 | fillTreeErrMBranches(locTreeFillData,branchName,kfitType,part,sh,isNeutral); |
2326 | } |
2327 | |
2328 | if(STORE_PULL_INFO) someMap.clear(); |
2329 | } |
2330 | |
2331 | |
2332 | |
2333 | myPullsMap.clear(); |
2334 | assignMap.clear(); |
2335 | abundanceMap.clear(); |
2336 | |
2337 | } |
2338 | |
2339 | } |
2340 | |
2341 | |
2342 | |
2343 | |
2344 | vector<string> DEventWriterROOT::getPIDinReaction(const DReaction* locReaction)const |
2345 | { |
2346 | vector <string> myVector; |
2347 | vector<Particle_t> particle = locReaction->Get_FinalPIDs(-1,false,false,d_AllCharges,true); |
2348 | int nParticleIDs = particle.size(); |
2349 | |
2350 | for(int k=0;k<nParticleIDs;k++){ |
2351 | myVector.push_back(EnumString(particle.at(k))); |
2352 | } |
2353 | |
2354 | return myVector; |
2355 | } |
2356 | |
2357 | map<Particle_t, int> DEventWriterROOT::getNameForParticle(const DReaction* someReaction, vector<string> someVector)const |
2358 | { |
2359 | map <Particle_t,int> myMap; |
2360 | vector<Particle_t> particle = someReaction->Get_FinalPIDs(-1,false,false,d_AllCharges,true); |
2361 | int nParticleIDs = particle.size(); |
2362 | int currentCounter = 0; |
2363 | int nEl = someVector.size(); |
2364 | |
2365 | for(int k=0;k<nParticleIDs;k++){ |
2366 | currentCounter = 0; |
2367 | |
2368 | |
2369 | for(int j=0;j<nEl;j++){ |
2370 | if(EnumString(particle.at(k)) == someVector.at(j)){ |
2371 | currentCounter++; |
2372 | someVector.at(j) = ""; |
2373 | } |
2374 | } |
2375 | |
2376 | if(currentCounter > 0){ |
2377 | abundanceMap[particle.at(k)] = currentCounter; |
2378 | myMap[particle.at(k)] = currentCounter; |
2379 | } |
2380 | } |
2381 | |
2382 | return myMap; |
2383 | } |
2384 | |
2385 | string DEventWriterROOT::assignName(Particle_t someParticle, map<Particle_t,int> someMap)const |
2386 | { |
2387 | string myName = "nada"; |
2388 | int abundance = abundanceMap.find(someParticle)->second; |
2389 | if(abundance == 1) { |
2390 | myName = EnumString(someParticle); |
2391 | } else if(abundance > 1) { |
2392 | int index = abundance - someMap.find(someParticle)->second +1; |
2393 | string addName; |
2394 | ostringstream convert; |
2395 | convert << index; |
2396 | addName = convert.str(); |
2397 | if(strcmp(EnumString(someParticle),"Gamma")==0) { |
2398 | myName = "Photon" + addName; |
2399 | } else { |
2400 | myName = EnumString(someParticle) + addName; |
2401 | } |
2402 | } |
2403 | |
2404 | return myName; |
2405 | } |
2406 | |
2407 | void DEventWriterROOT::Get_PullsFromFit(const DParticleCombo* particleCombos) const |
2408 | { |
2409 | const DKinFitResults* fitResults = particleCombos->Get_KinFitResults(); |
2410 | if(fitResults != NULL){ |
2411 | fitResults->Get_Pulls(myPullsMap); |
2412 | } |
2413 | } |
2414 | |
2415 | map<DKinFitPullType, double> DEventWriterROOT::getPulls(const JObject* particle, const JObject* shower, DKinFitType yourFitType) const{ |
2416 | map<DKinFitPullType, double> myMap; |
2417 | |
2418 | if(particle != NULL || shower != NULL) { |
2419 | |
2420 | if(yourFitType == d_P4Fit || yourFitType == d_VertexFit) { |
2421 | myMap = myPullsMap.find(particle)->second; |
2422 | }else if(yourFitType == d_P4AndVertexFit ){ |
2423 | if(shower == NULL) { |
2424 | myMap = myPullsMap.find(particle)->second; |
2425 | } else myMap = myPullsMap.find(shower)->second; |
2426 | } |
2427 | } |
2428 | |
2429 | return myMap; |
2430 | } |
2431 | |
2432 | |
2433 | |
2434 | void DEventWriterROOT::setTreePullBranches(DTreeBranchRegister& locBranchRegister,string yourBranchName,DKinFitType yourFitType, int yourNCombos, bool isNeutral) const |
2435 | { |
2436 | string locArraySizeString = "NumCombos"; |
2437 | |
2438 | if(yourFitType == d_P4Fit){ |
2439 | |
2440 | locBranchRegister.Register_FundamentalArray<Double_t>(Build_BranchName(yourBranchName,"Px_Pull"),locArraySizeString, yourNCombos); |
2441 | locBranchRegister.Register_FundamentalArray<Double_t>(Build_BranchName(yourBranchName,"Py_Pull"),locArraySizeString, yourNCombos); |
2442 | locBranchRegister.Register_FundamentalArray<Double_t>(Build_BranchName(yourBranchName,"Pz_Pull"),locArraySizeString, yourNCombos); |
2443 | |
2444 | |
2445 | locBranchRegister.Register_FundamentalArray<Double_t>(Build_BranchName(yourBranchName,"QPt_Pull"),locArraySizeString, yourNCombos); |
2446 | locBranchRegister.Register_FundamentalArray<Double_t>(Build_BranchName(yourBranchName,"Phi_Pull"),locArraySizeString, yourNCombos); |
2447 | locBranchRegister.Register_FundamentalArray<Double_t>(Build_BranchName(yourBranchName,"tanLambda_Pull"),locArraySizeString, yourNCombos); |
2448 | locBranchRegister.Register_FundamentalArray<Double_t>(Build_BranchName(yourBranchName,"D_Pull"),locArraySizeString, yourNCombos); |
2449 | |
2450 | }else if(yourFitType == d_P4AndVertexFit){ |
2451 | |
2452 | if(isNeutral){ |
2453 | locBranchRegister.Register_FundamentalArray<Double_t>(Build_BranchName(yourBranchName,"E_Pull"),locArraySizeString, yourNCombos); |
2454 | locBranchRegister.Register_FundamentalArray<Double_t>(Build_BranchName(yourBranchName,"Xx_Pull"),locArraySizeString, yourNCombos); |
2455 | locBranchRegister.Register_FundamentalArray<Double_t>(Build_BranchName(yourBranchName,"Xy_Pull"),locArraySizeString, yourNCombos); |
2456 | locBranchRegister.Register_FundamentalArray<Double_t>(Build_BranchName(yourBranchName,"Xz_Pull"),locArraySizeString, yourNCombos); |
2457 | }else{ |
2458 | |
2459 | locBranchRegister.Register_FundamentalArray<Double_t>(Build_BranchName(yourBranchName,"Px_Pull"),locArraySizeString, yourNCombos); |
2460 | locBranchRegister.Register_FundamentalArray<Double_t>(Build_BranchName(yourBranchName,"Py_Pull"),locArraySizeString, yourNCombos); |
2461 | locBranchRegister.Register_FundamentalArray<Double_t>(Build_BranchName(yourBranchName,"Pz_Pull"),locArraySizeString, yourNCombos); |
2462 | locBranchRegister.Register_FundamentalArray<Double_t>(Build_BranchName(yourBranchName,"Xx_Pull"),locArraySizeString, yourNCombos); |
2463 | locBranchRegister.Register_FundamentalArray<Double_t>(Build_BranchName(yourBranchName,"Xy_Pull"),locArraySizeString, yourNCombos); |
2464 | locBranchRegister.Register_FundamentalArray<Double_t>(Build_BranchName(yourBranchName,"Xz_Pull"),locArraySizeString, yourNCombos); |
2465 | |
2466 | |
2467 | locBranchRegister.Register_FundamentalArray<Double_t>(Build_BranchName(yourBranchName,"QPt_Pull"),locArraySizeString, yourNCombos); |
2468 | locBranchRegister.Register_FundamentalArray<Double_t>(Build_BranchName(yourBranchName,"Phi_Pull"),locArraySizeString, yourNCombos); |
2469 | locBranchRegister.Register_FundamentalArray<Double_t>(Build_BranchName(yourBranchName,"tanLambda_Pull"),locArraySizeString, yourNCombos); |
2470 | locBranchRegister.Register_FundamentalArray<Double_t>(Build_BranchName(yourBranchName,"D_Pull"),locArraySizeString, yourNCombos); |
2471 | } |
2472 | |
2473 | }else if(yourFitType == d_VertexFit && !isNeutral){ |
2474 | locBranchRegister.Register_FundamentalArray<Double_t>(Build_BranchName(yourBranchName,"Xx_Pull"),locArraySizeString, yourNCombos); |
2475 | locBranchRegister.Register_FundamentalArray<Double_t>(Build_BranchName(yourBranchName,"Xy_Pull"),locArraySizeString, yourNCombos); |
2476 | locBranchRegister.Register_FundamentalArray<Double_t>(Build_BranchName(yourBranchName,"Xz_Pull"),locArraySizeString, yourNCombos); |
2477 | } |
2478 | } |
2479 | |
2480 | |
2481 | void DEventWriterROOT::fillTreePullBranches(DTreeFillData* locTreeFillData,string yourBranchName,DKinFitType yourFitType,map<DKinFitPullType, double> yourPullsMap, int yourIndex, bool isNeutral) const |
2482 | { |
2483 | |
2484 | if(yourFitType == d_P4Fit){ |
2485 | locTreeFillData->Fill_Array<Double_t>(Build_BranchName(yourBranchName, "Px_Pull"), yourPullsMap.find(d_PxPull)->second,yourIndex); |
2486 | locTreeFillData->Fill_Array<Double_t>(Build_BranchName(yourBranchName, "Py_Pull"), yourPullsMap.find(d_PyPull)->second,yourIndex); |
2487 | locTreeFillData->Fill_Array<Double_t>(Build_BranchName(yourBranchName, "Pz_Pull"), yourPullsMap.find(d_PzPull)->second,yourIndex); |
2488 | |
2489 | }else if(yourFitType == d_P4AndVertexFit){ |
2490 | |
2491 | if(isNeutral){ |
2492 | locTreeFillData->Fill_Array<Double_t>(Build_BranchName(yourBranchName, "E_Pull"), yourPullsMap.find(d_EPull)->second,yourIndex); |
2493 | locTreeFillData->Fill_Array<Double_t>(Build_BranchName(yourBranchName, "Xx_Pull"), yourPullsMap.find(d_XxPull)->second,yourIndex); |
2494 | locTreeFillData->Fill_Array<Double_t>(Build_BranchName(yourBranchName, "Xy_Pull"), yourPullsMap.find(d_XyPull)->second,yourIndex); |
2495 | locTreeFillData->Fill_Array<Double_t>(Build_BranchName(yourBranchName, "Xz_Pull"), yourPullsMap.find(d_XzPull)->second,yourIndex); |
2496 | }else{ |
2497 | locTreeFillData->Fill_Array<Double_t>(Build_BranchName(yourBranchName, "Px_Pull"), yourPullsMap.find(d_PxPull)->second,yourIndex); |
2498 | locTreeFillData->Fill_Array<Double_t>(Build_BranchName(yourBranchName, "Py_Pull"), yourPullsMap.find(d_PyPull)->second,yourIndex); |
2499 | locTreeFillData->Fill_Array<Double_t>(Build_BranchName(yourBranchName, "Pz_Pull"), yourPullsMap.find(d_PzPull)->second,yourIndex); |
2500 | locTreeFillData->Fill_Array<Double_t>(Build_BranchName(yourBranchName, "Xx_Pull"), yourPullsMap.find(d_XxPull)->second,yourIndex); |
2501 | locTreeFillData->Fill_Array<Double_t>(Build_BranchName(yourBranchName, "Xy_Pull"), yourPullsMap.find(d_XyPull)->second,yourIndex); |
2502 | locTreeFillData->Fill_Array<Double_t>(Build_BranchName(yourBranchName, "Xz_Pull"), yourPullsMap.find(d_XzPull)->second,yourIndex); |
2503 | } |
2504 | |
2505 | }else if(yourFitType == d_VertexFit && !isNeutral){ |
2506 | locTreeFillData->Fill_Array<Double_t>(Build_BranchName(yourBranchName, "Xx_Pull"), yourPullsMap.find(d_XxPull)->second,yourIndex); |
2507 | locTreeFillData->Fill_Array<Double_t>(Build_BranchName(yourBranchName, "Xy_Pull"), yourPullsMap.find(d_XyPull)->second,yourIndex); |
2508 | locTreeFillData->Fill_Array<Double_t>(Build_BranchName(yourBranchName, "Xz_Pull"), yourPullsMap.find(d_XzPull)->second,yourIndex); |
2509 | } |
2510 | } |
2511 | |
2512 | |
2513 | void DEventWriterROOT::setPullFlag(const DReaction* currentReaction, bool myFlag) const |
2514 | { |
2515 | writePulls[currentReaction] = myFlag; |
2516 | } |
2517 | |
2518 | bool DEventWriterROOT::getPullFlag(const DReaction* currentReaction) const |
2519 | { |
2520 | bool outFlag = writePulls.find(currentReaction)->second; |
2521 | return outFlag; |
2522 | } |
2523 | |
2524 | |
2525 | void DEventWriterROOT::fillTreeErrMBranches(DTreeFillData* locTreeFillData,string yourBranchName,DKinFitType yourFitType, const DKinematicData* particle, const DNeutralShower* shower, bool isNeutral) const |
2526 | { |
2527 | if(yourFitType == d_P4Fit) { |
2528 | fillTreeParticleErrMBranches(locTreeFillData,yourBranchName,particle); |
2529 | } else if(yourFitType == d_P4AndVertexFit) { |
2530 | if(isNeutral) { |
2531 | fillTreeShowerErrMBranches(locTreeFillData,yourBranchName,shower); |
2532 | } else { |
2533 | fillTreeParticleErrMBranches(locTreeFillData,yourBranchName,particle); |
2534 | } |
2535 | } else if(yourFitType == d_VertexFit && !isNeutral) { |
2536 | fillTreeParticleErrMBranches(locTreeFillData,yourBranchName,particle); |
2537 | } |
2538 | } |
2539 | |
2540 | |
2541 | void DEventWriterROOT::fillTreeParticleErrMBranches(DTreeFillData* locTreeFillData,string yourBranchName, const DKinematicData* particle) const |
2542 | { |
2543 | if(particle != NULL){ |
2544 | const TMatrixTSym<float> errMatrix = *( particle->errorMatrix() ); |
2545 | |
2546 | int mIndex = 0; |
2547 | float matrixEl = 0.0; |
2548 | for(int row=0;row<7;row++){ |
2549 | for(int col=0;col<7;col++){ |
2550 | if(col >= row){ |
2551 | matrixEl = errMatrix[row][col]; |
2552 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(yourBranchName, "ErrMatrix"),matrixEl,mIndex); |
2553 | mIndex++; |
2554 | } |
2555 | } |
2556 | } |
2557 | |
2558 | } |
2559 | } |
2560 | |
2561 | |
2562 | void DEventWriterROOT::fillTreeShowerErrMBranches(DTreeFillData* locTreeFillData,string yourBranchName, const DNeutralShower* shower) const |
2563 | { |
2564 | if(shower != NULL){ |
2565 | const TMatrixTSym <float> errMatrix = *( shower->dCovarianceMatrix ); |
2566 | float matrixEl = 0.0; |
2567 | |
2568 | int mIndex = 0; |
2569 | for(int row=0;row<5;row++){ |
2570 | for(int col=0;col<5;col++){ |
2571 | if(col >= row){ |
2572 | matrixEl = errMatrix[row][col]; |
2573 | locTreeFillData->Fill_Array<Float_t>(Build_BranchName(yourBranchName, "ErrMatrix"),matrixEl,mIndex); |
2574 | mIndex++; |
2575 | } |
2576 | } |
2577 | } |
2578 | |
2579 | } |
2580 | } |
2581 | |
2582 | |
2583 | |
2584 | |
2585 | double DEventWriterROOT::getDiffSquaredErrP_Component(double yourRecComponent,double yourFitComponent,double yourPull) const |
2586 | { |
2587 | double diff = yourRecComponent - yourFitComponent; |
2588 | double error_component = 0.0; |
2589 | |
2590 | if(diff != 0.0 && yourPull != 0.0){ |
2591 | error_component = diff*diff / (yourPull*yourPull); |
2592 | } |
2593 | |
2594 | return error_component; |
2595 | } |
2596 | |
2597 | |
2598 | vector< vector<double> > DEventWriterROOT::getSquaredErrX(const DKinematicData* particle, const DKinematicData* particleFit, map<DKinFitPullType, double> yourPullsMap) const{ |
2599 | |
2600 | double x_pull = yourPullsMap.find(d_XxPull)->second; |
2601 | double y_pull = yourPullsMap.find(d_XyPull)->second; |
2602 | |
2603 | double x_rec = particle->x(); |
2604 | double x_fit = particleFit->x(); |
2605 | |
2606 | double y_rec = particle->y(); |
2607 | double y_fit = particleFit->y(); |
2608 | |
2609 | double error_x = getDiffSquaredErrP_Component(x_rec,x_fit,x_pull); |
2610 | double error_y = getDiffSquaredErrP_Component(y_rec,y_fit,y_pull); |
2611 | |
2612 | const TMatrixTSym<float> errMatrix = *( particle->errorMatrix() ); |
2613 | double error_x_rec = errMatrix[3][3]; |
2614 | double error_y_rec = errMatrix[4][4]; |
2615 | |
2616 | double error_x_fit = error_x_rec - error_x; |
2617 | double error_y_fit = error_y_rec - error_y; |
2618 | |
2619 | vector <double> xComponent; |
2620 | vector <double> yComponent; |
2621 | |
2622 | xComponent.push_back(error_x_rec); |
2623 | xComponent.push_back(error_x_fit); |
2624 | |
2625 | yComponent.push_back(error_y_rec); |
2626 | yComponent.push_back(error_y_fit); |
2627 | |
2628 | vector < vector<double> > myErrors; |
2629 | myErrors.push_back(xComponent); |
2630 | myErrors.push_back(yComponent); |
2631 | |
2632 | return myErrors; |
2633 | |
2634 | } |
2635 | |
2636 | |
2637 | vector< vector<double> > DEventWriterROOT::getSquaredErrP(const DKinematicData* particle, const DKinematicData* particleFit, map<DKinFitPullType, double> yourPullsMap) const |
2638 | { |
2639 | |
2640 | double px_pull = yourPullsMap.find(d_PxPull)->second; |
2641 | double py_pull = yourPullsMap.find(d_PyPull)->second; |
2642 | double pz_pull = yourPullsMap.find(d_PzPull)->second; |
2643 | |
2644 | double px_rec = particle->px(); |
2645 | double px_fit = particleFit->px(); |
2646 | |
2647 | double py_rec = particle->py(); |
2648 | double py_fit = particleFit->py(); |
2649 | |
2650 | double pz_rec = particle->pz(); |
2651 | double pz_fit = particleFit->pz(); |
2652 | |
2653 | double error_x = getDiffSquaredErrP_Component(px_rec,px_fit,px_pull); |
2654 | double error_y = getDiffSquaredErrP_Component(py_rec,py_fit,py_pull); |
2655 | double error_z = getDiffSquaredErrP_Component(pz_rec,pz_fit,pz_pull); |
2656 | |
2657 | const TMatrixTSym<float> errMatrix = *( particle->errorMatrix() ); |
2658 | double error_x_rec = errMatrix[0][0]; |
2659 | double error_y_rec = errMatrix[1][1]; |
2660 | double error_z_rec = errMatrix[2][2]; |
2661 | |
2662 | double error_x_fit = error_x_rec - error_x; |
2663 | double error_y_fit = error_y_rec - error_y; |
2664 | double error_z_fit = error_z_rec - error_z; |
2665 | |
2666 | vector <double> xComponent; |
2667 | vector <double> yComponent; |
2668 | vector <double> zComponent; |
2669 | |
2670 | xComponent.push_back(error_x_rec); |
2671 | xComponent.push_back(error_x_fit); |
2672 | |
2673 | yComponent.push_back(error_y_rec); |
2674 | yComponent.push_back(error_y_fit); |
2675 | |
2676 | zComponent.push_back(error_z_rec); |
2677 | zComponent.push_back(error_z_fit); |
2678 | |
2679 | vector < vector<double> > myErrors; |
2680 | myErrors.push_back(xComponent); |
2681 | myErrors.push_back(yComponent); |
2682 | myErrors.push_back(zComponent); |
2683 | |
2684 | return myErrors; |
2685 | } |
2686 | |
2687 | |
2688 | |
2689 | double DEventWriterROOT::getPhiError(const DKinematicData* particle, vector< vector<double> > yourErrorMatrix, int isFitted) const |
2690 | { |
2691 | double myPhiError = 0.0; |
2692 | double myPx = particle->px(); |
2693 | double myPy = particle->py(); |
2694 | |
2695 | |
2696 | if(myPy != 0.0){ |
2697 | |
2698 | double myDPx = yourErrorMatrix[0][isFitted]; |
2699 | double myDPy = yourErrorMatrix[1][isFitted]; |
2700 | |
2701 | double arg = myPx / myPy; |
2702 | double factor1 = 1.0 / pow( myPy*(1.0 + arg*arg), 2); |
2703 | double factor2 = (myDPx + arg*arg*myDPy); |
2704 | |
2705 | myPhiError = factor1*factor2; |
2706 | } |
2707 | |
2708 | return myPhiError; |
2709 | } |
2710 | |
2711 | |
2712 | |
2713 | double DEventWriterROOT::getPhiPull(const DKinematicData* particle, const DKinematicData* particleFit, vector< vector<double> > yourErrorMatrix) const |
2714 | { |
2715 | double myPhiPull = -100.0; |
2716 | |
2717 | double phi_rec = ( particle->momentum() ).Phi(); |
2718 | double phi_fit = ( particleFit->momentum() ).Phi(); |
2719 | |
2720 | double dPhi_rec = getPhiError(particle,yourErrorMatrix,0); |
2721 | double dPhi_fit = getPhiError(particleFit,yourErrorMatrix,1); |
2722 | |
2723 | double pull_norm = dPhi_rec - dPhi_fit; |
2724 | |
2725 | if(pull_norm > 0.0){ |
2726 | myPhiPull = (phi_rec - phi_fit) / sqrt(pull_norm); |
2727 | } |
2728 | |
2729 | return myPhiPull; |
2730 | } |
2731 | |
2732 | |
2733 | |
2734 | double DEventWriterROOT::getLambdaError(const DKinematicData* particle, vector< vector<double> > yourErrorMatrix, int isFitted) const |
2735 | { |
2736 | double myTanLambdaError = 0.0; |
2737 | |
2738 | |
2739 | double myPx = particle->px(); |
2740 | double myPy = particle->py(); |
2741 | double myPz = particle->pz(); |
2742 | |
2743 | double myDPx = yourErrorMatrix[0][isFitted]; |
2744 | double myDPy = yourErrorMatrix[1][isFitted]; |
2745 | double myDPz = yourErrorMatrix[2][isFitted]; |
2746 | |
2747 | double r2 = myPx*myPx + myPy*myPy + myPz*myPz; |
2748 | double lambda = 0.5*M_PI - ( particle->momentum() ).Theta(); |
2749 | |
2750 | if(r2 > 0.0 && cos(lambda) != 0.0){ |
2751 | double r = sqrt(r2); |
2752 | double factor1 = 1.0 / ( pow(r,6) * pow(cos(lambda),4) ); |
2753 | double sum1 = myPx*myPz; |
2754 | double sum2 = myPy*myPz; |
2755 | double sum3 = (r - myPz*myPz); |
2756 | double factor2 = sum1*sum1*myDPx + sum2*sum2*myDPy + sum3*sum3*myDPz; |
2757 | |
2758 | myTanLambdaError = factor1*factor2; |
2759 | } |
2760 | |
2761 | |
2762 | |
2763 | return myTanLambdaError; |
2764 | } |
2765 | |
2766 | |
2767 | |
2768 | double DEventWriterROOT::getTanLambdaPull(const DKinematicData* particle, const DKinematicData* particleFit, vector< vector<double> > yourErrorMatrix) const |
2769 | { |
2770 | double myTanLambdaPull = -100.0; |
2771 | |
2772 | |
2773 | double lambda_rec = 0.5*M_PI - ( particle->momentum() ).Theta(); |
2774 | double tanLambda_rec = tan(lambda_rec); |
2775 | double dtanLambda_rec = getLambdaError(particle,yourErrorMatrix,0); |
2776 | |
2777 | |
2778 | double lambda_fit = 0.5*M_PI - ( particleFit->momentum() ).Theta(); |
2779 | double tanLambda_fit = tan(lambda_fit); |
2780 | double dtanLambda_fit = getLambdaError(particleFit,yourErrorMatrix,1); |
2781 | |
2782 | double pull_norm = dtanLambda_rec-dtanLambda_fit; |
2783 | |
2784 | if(pull_norm > 0.0){ |
2785 | myTanLambdaPull = (tanLambda_rec-tanLambda_fit) / sqrt(pull_norm); |
2786 | } |
2787 | |
2788 | |
2789 | return myTanLambdaPull; |
2790 | } |
2791 | |
2792 | |
2793 | |
2794 | double DEventWriterROOT::getQPTError(const DKinematicData* particle, vector< vector<double> > yourErrorMatrix, int isFitted) const |
2795 | { |
2796 | double myQPTError = 0.0; |
2797 | double myPx = particle->px(); |
2798 | double myPy = particle->py(); |
2799 | double r2 = myPx*myPx + myPy*myPy; |
2800 | |
2801 | double myDPx = yourErrorMatrix[0][isFitted]; |
2802 | double myDPy = yourErrorMatrix[1][isFitted]; |
2803 | |
2804 | if(r2 > 0.0){ |
2805 | double q = particle->charge(); |
2806 | double factor1 = q*q / pow(r2,3); |
2807 | double factor2 = (myPx*myPx*myDPx + myPy*myPy*myDPy); |
2808 | |
2809 | myQPTError = factor1*factor2; |
2810 | } |
2811 | |
2812 | |
2813 | return myQPTError; |
2814 | } |
2815 | |
2816 | |
2817 | |
2818 | double DEventWriterROOT::getQPTPull(const DKinematicData* particle, const DKinematicData* particleFit, vector< vector<double> > yourErrorMatrix) const |
2819 | { |
2820 | double myPTPull = -100.0; |
2821 | |
2822 | double particle_charge = particle->charge(); |
2823 | |
2824 | double myPx_rec = particle->px(); |
2825 | double myPy_rec = particle->py(); |
2826 | double r_rec = myPx_rec*myPx_rec + myPy_rec*myPy_rec; |
2827 | |
2828 | double myPx_fit = particleFit->px(); |
2829 | double myPy_fit = particleFit->py(); |
2830 | double r_fit = myPx_fit*myPx_fit + myPy_fit*myPy_fit; |
2831 | |
2832 | |
2833 | if(r_rec > 0.0 && r_fit > 0.0){ |
2834 | double qpt_rec = particle_charge/sqrt(r_rec); |
2835 | double dqpt_rec = getQPTError(particle,yourErrorMatrix,0); |
2836 | |
2837 | double qpt_fit = particle_charge/sqrt(r_fit); |
2838 | double dqpt_fit = getQPTError(particleFit,yourErrorMatrix,1); |
2839 | |
2840 | double pull_norm = dqpt_rec-dqpt_fit; |
2841 | |
2842 | if(pull_norm > 0.0){ |
2843 | myPTPull = (qpt_rec-qpt_fit)/sqrt(pull_norm); |
2844 | } |
2845 | |
2846 | } |
2847 | |
2848 | |
2849 | |
2850 | return myPTPull; |
2851 | } |
2852 | |
2853 | |
2854 | |
2855 | double DEventWriterROOT::getDError(const DKinematicData* particle, vector< vector<double> > yourErrorMatrix, int isFitted) const |
2856 | { |
2857 | |
2858 | double myDsq=particle->position().Perp2()+1e-8; |
2859 | double myx=particle->x(); |
2860 | double myy=particle->y(); |
2861 | |
2862 | double myVarX=yourErrorMatrix[0][isFitted]; |
2863 | double myVarY=yourErrorMatrix[1][isFitted]; |
2864 | double myDError=(myx*myx*myVarX+myy*myy*myVarY)/myDsq; |
2865 | |
2866 | return myDError; |
2867 | } |
2868 | |
2869 | |
2870 | double DEventWriterROOT::getDPull(const DKinematicData* particle, const DKinematicData* particleFit, vector< vector<double> > yourErrorMatrix) const |
2871 | { |
2872 | double myDPull=-100.0; |
2873 | |
2874 | |
2875 | double D_rec=particle->position().Perp(); |
2876 | double dx_rec=particle->x(); |
2877 | double dy_rec=particle->y(); |
2878 | double phi_rec=particle->momentum().Phi(); |
2879 | double cosphi_rec=cos(phi_rec); |
2880 | double sinphi_rec=sin(phi_rec); |
2881 | if ((dx_rec>0.0 && sinphi_rec>0.0) || (dy_rec<0.0 && cosphi_rec>0.0) |
2882 | || (dy_rec>0.0 && cosphi_rec<0.0) || (dx_rec<0.0 && sinphi_rec<0.0)) |
2883 | D_rec*=-1.; |
2884 | double dD_rec=getDError(particle,yourErrorMatrix,0); |
2885 | |
2886 | |
2887 | double D_fit=particleFit->position().Perp(); |
2888 | double dx_fit=particleFit->x(); |
2889 | double dy_fit=particleFit->y(); |
2890 | double phi_fit=particleFit->momentum().Phi(); |
2891 | double cosphi_fit=cos(phi_fit); |
2892 | double sinphi_fit=sin(phi_fit); |
2893 | if ((dx_fit>0.0 && sinphi_fit>0.0) || (dy_fit<0.0 && cosphi_fit>0.0) |
2894 | || (dy_fit>0.0 && cosphi_fit<0.0) || (dx_fit<0.0 && sinphi_fit<0.0)) |
2895 | D_fit*=-1.; |
2896 | double dD_fit=getDError(particle,yourErrorMatrix,1); |
2897 | |
2898 | double pull_norm = dD_rec-dD_fit; |
2899 | |
2900 | if(pull_norm > 0.0){ |
2901 | myDPull = (D_rec-D_fit) / sqrt(pull_norm); |
2902 | } |
2903 | |
2904 | |
2905 | return myDPull; |
2906 | } |
2907 | |
2908 | |
2909 | vector<double> DEventWriterROOT::collectTrackingPulls(const DKinematicData* particle, const DKinematicData* particleFit, map<DKinFitPullType, double> yourPullsMap) const |
2910 | { |
2911 | |
2912 | vector< vector<double> > myErrors = getSquaredErrP(particle,particleFit,yourPullsMap); |
2913 | vector< vector<double> > myXErrors = getSquaredErrX(particle,particleFit,yourPullsMap); |
2914 | |
2915 | |
2916 | |
2917 | double qpt_pull = getQPTPull(particle,particleFit,myErrors); |
2918 | |
2919 | double phi_pull = getPhiPull(particle,particleFit,myErrors); |
2920 | |
2921 | double tanLambda_pull = getTanLambdaPull(particle,particleFit,myErrors); |
2922 | |
2923 | double D_pull = getDPull(particle,particleFit,myXErrors); |
2924 | |
2925 | |
2926 | vector<double> myTrackingPulls; |
2927 | myTrackingPulls.push_back(qpt_pull); |
2928 | myTrackingPulls.push_back(phi_pull); |
2929 | myTrackingPulls.push_back(tanLambda_pull); |
2930 | myTrackingPulls.push_back(D_pull); |
2931 | |
2932 | return myTrackingPulls; |
2933 | } |
2934 | |
2935 | |
2936 | void DEventWriterROOT::fillTreeTrackPullBranches(DTreeFillData* locTreeFillData,string yourBranchName,DKinFitType yourFitType,map<DKinFitPullType, double> yourPullsMap, int yourIndex, bool isNeutral, const DKinematicData* particle, const DKinematicData* particleFit) const |
2937 | { |
2938 | if( !isNeutral && (yourFitType == d_P4Fit || yourFitType == d_P4AndVertexFit) ){ |
2939 | |
2940 | vector<double> myTrackingPulls = collectTrackingPulls(particle,particleFit,yourPullsMap); |
2941 | |
2942 | |
2943 | locTreeFillData->Fill_Array<Double_t>(Build_BranchName(yourBranchName, "QPt_Pull"),myTrackingPulls[0],yourIndex); |
2944 | locTreeFillData->Fill_Array<Double_t>(Build_BranchName(yourBranchName, "Phi_Pull"),myTrackingPulls[1],yourIndex); |
2945 | locTreeFillData->Fill_Array<Double_t>(Build_BranchName(yourBranchName, "tanLambda_Pull"),myTrackingPulls[2],yourIndex); |
2946 | locTreeFillData->Fill_Array<Double_t>(Build_BranchName(yourBranchName, "D_Pull"),myTrackingPulls[3],yourIndex); |
2947 | } |
2948 | } |
2949 | |