Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
TwoTrackAnaChain.cxx
1/*
2 * TwoTrackAnaChain.cxx
3 *
4 * Created on: 26 sie 2016
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9
10#include "TwoTrackAnaChain.h"
11
12#include "Cout.h"
13#include "CutContainer.h"
14#include "DataFormatManager.h"
15#include "EventAna.h"
16#include "EventVirtualCut.h"
17#include "MemoryMapManager.h"
18#include "Package.h"
19#include "Parameter.h"
20#include "Std.h"
21#include "TrackVirtualCut.h"
22#include "TwoTrack.h"
23#include "TwoTrackVirtualCut.h"
24
25#include <TFile.h>
26#include <TString.h>
27
28
29namespace Hal {
30 TwoTrackAnaChain::TwoTrackAnaChain(Bool_t use_background) : TwoTrackAna(use_background), fTaskNo(0), fTask(NULL) {
31 if (use_background) { fBackgroundMode = kMixedPairs; }
32 }
33
34 TwoTrackAnaChain::TwoTrackAnaChain() : fTaskNo(0), fTask(NULL) {}
35
36 void TwoTrackAnaChain::RemoveTask(Int_t no) {
37 TwoTrackAna** temp = fTask;
38 fTask = new TwoTrackAna*[fTaskNo - 1];
39 Int_t n = 0;
40 for (int i = 0; i < fTaskNo; i++) {
41 if (i == no) continue;
42 fTask[n] = temp[i];
43 n++;
44 }
45 delete temp[no];
46 fTaskNo--;
47 delete[] temp;
48 }
49
51 for (int i = 0; i < fTaskNo; i++) {
53 }
55 }
56
58 Package* pack = EventAna::Report();
59 for (int i = 0; i < fTaskNo; i++) {
60 pack->AddObject(new ParameterString("Subtask name", fTask[i]->ClassName()));
61 }
62 return pack;
63 }
64
66 for (int i = 0; i < fTaskNo; i++) {
68 fTask[i]->ProcessTrack();
69 }
70 }
71
73 if (!ana->InheritsFrom("Hal::TwoTrackAna")) {
74 Cout::PrintInfo("Tasks that doesn't inherit from TwoTrackAna cannot be processed "
75 "vy this task",
76 EInfo::kWarning);
77 }
78 if (ana->fTiers != fTiers) {
79 Cout::PrintInfo(Form("Task that is added must have the same trier %s will not be added", ana->ClassName()),
80 EInfo::kWarning);
81 return;
82 }
83 if (fTask == NULL) {
84 fTask = new TwoTrackAna*[1];
85 ana->MarkAsInChain();
86 fTask[0] = ana;
87 fTaskNo++;
88 } else {
89 for (int i = 0; i < fTaskNo; i++) {
90 if (ana == fTask[i]) {
91 Cout::PrintInfo("Task already added", EInfo::kError);
92 return;
93 }
94 }
95 TwoTrackAna** temp = fTask;
96 fTask = new TwoTrackAna*[fTaskNo + 1];
97 for (int i = 0; i < fTaskNo; i++) {
98 fTask[i] = temp[i];
99 }
100 ana->MarkAsInChain();
101 fTask[fTaskNo] = ana;
102 fTaskNo++;
103 delete[] temp;
104 }
105 }
106
108 Package* pack = Report();
109 Package* metadata_new = new Package();
110 metadata_new->SetName("RunInfo");
111 metadata_new->AddObject(new ParameterString("Software ver", HAL_PHYSICALANALYSYS_VER));
112 metadata_new->AddObject(new ParameterString("Date", Hal::Std::GetDate(), 'f'));
113 metadata_new->AddObject(new ParameterString("Time", Hal::Std::GetTime(), 'f'));
114 metadata_new->AddObject(new ParameterUInt("Processed_events", fProcessedEvents, '+'));
115 metadata_new->AddObject(new ParameterString("Input file", GetInputFileName(), 'f'));
116 GoToDir("HalInfo");
117 TDirectory* dir = (TDirectory*) gFile;
118 TDirectory* metadatata = (TDirectory*) dir->Get("HalInfo");
119 if (metadatata->Get("RunInfo")) {
120 delete metadata_new;
121 } else {
122 metadata_new->Write("RunInfo");
123 }
124 GoToDir("HalPhysics");
125 pack->Write(Form("AnaPackage_%i", GetTaskID()));
126 if (pack) { delete pack; }
127 for (int i = 0; i < fTaskNo; i++) {
128 SynchronizeCutContainers(fTask[i], kFALSE);
129 Package* subtask_pack = fTask[i]->Report();
130 subtask_pack->Write(Form("AnaPackage_%i", fTask[i]->GetTaskID()));
131 delete subtask_pack;
132 }
133 gFile->cd();
134 Cout::PrintInfo(Form("%s done, writing results", this->ClassName()), EInfo::kInfo);
135 }
136
137 Task::EInitFlag TwoTrackAnaChain::Init() {
138 Task::EInitFlag stat = TwoTrackAna::Init();
139 if (stat == Task::EInitFlag::kSUCCESS) {
141 for (int i = 0; i < fTaskNo; i++) {
142 fTask[i]->SetFormat(dataManager->GetNewEvent(GetTaskID()));
143 SynchronizeCutContainers(fTask[i], kTRUE);
144 if (Task::EInitFlag::kFATAL == fTask[i]->Init()) {
145 RemoveTask(i);
146 i--;
147 continue;
148 }
149 LinkTask(fTask[i]);
150 }
151 return Task::EInitFlag::kSUCCESS;
152 }
153 return Task::EInitFlag::kFATAL;
154 }
155
157 for (int i = 0; i < fTaskNo; i++) {
159 fTask[i]->ProcessPair();
160 }
161 }
162
164 for (int i = 0; i < fTaskNo; i++) {
166 fTask[i]->ProcessPair2();
167 }
168 }
169
171 for (int i = 0; i < fTaskNo; i++) {
173 fTask[i]->ProcessPair_Mixed();
174 }
175 }
176
178 for (int i = 0; i < fTaskNo; i++) {
180 fTask[i]->ProcessPair2_Mixed();
181 }
182 }
183
185 for (int i = 0; i < fTaskNo; i++) {
187 fTask[i]->ProcessPair_Perfect();
188 }
189 }
190
192 for (int i = 0; i < fTaskNo; i++) {
194 fTask[i]->ProcessPair2_Perfect();
195 }
196 }
197
199 for (int i = 0; i < fTaskNo; i++) {
201 fTask[i]->ProcessPair_Rotated();
202 }
203 }
204
206 for (int i = 0; i < fTaskNo; i++) {
208 fTask[i]->ProcessPair2_Rotated();
209 }
210 }
211
213 for (int i = 0; i < fTaskNo; i++) {
215 fTask[i]->ProcessPair_Hemisphere();
216 }
217 }
218
220 for (int i = 0; i < fTaskNo; i++) {
222 fTask[i]->ProcessPair2_Hemisphere();
223 }
224 }
225
227 for (int i = 0; i < fTaskNo; i++) {
229 fTask[i]->ProcessPair_ChargedId();
230 }
231 }
232
234 for (int i = 0; i < fTaskNo; i++) {
236 fTask[i]->ProcessPair_ChargedNId();
237 }
238 }
239
241 for (int i = 0; i < fTaskNo; i++) {
243 fTask[i]->ProcessPair_Charged2();
244 }
245 }
246
248 for (int i = 0; i < fTaskNo; i++) {
250 fTask[i]->ProcessPair2_Charged2();
251 }
252 }
253
255 for (int i = 0; i < fTaskNo; i++) {
257 fTask[i]->ProcessPair_Charged3();
258 }
259 }
260
262 for (int i = 0; i < fTaskNo; i++) {
264 fTask[i]->ProcessPair2_Charged3();
265 }
266 }
267
269 fCurrentTrack1CollectionNo = fCurrentTrackCollectionID;
270 fCurrentTrack2CollectionNo = fCurrentTrackCollectionID + 1;
271 Int_t tr1 = fMemoryMap->GetTracksNo(fCurrentEventCollectionID, fCurrentTrack1CollectionNo);
272 Int_t tr2 = fMemoryMap->GetTracksNo(fCurrentEventCollectionID, fCurrentTrack2CollectionNo);
273 if (tr1 == 0 || tr2 == 0) {
275 return;
276 }
277 for (int i = 0; i < fTaskNo; i++) {
278 fTask[i]->fCurrentTrack1CollectionNo = fCurrentTrack1CollectionNo;
279 fTask[i]->fCurrentTrack2CollectionNo = fCurrentTrack2CollectionNo;
281 }
282 switch (fBackgroundMode) {
283 case kPerfectPairsNID: {
284 MakePairs2();
285 MakePairs2_Perfect();
286 } break;
287 case kMixedPairsNID: {
288 MakePairs2();
289 if (fMemoryMap->IsReadyToMixing(fCurrentEventCollectionID)) { MakePairs2_Mixed(); }
290 } break;
291 case kRotatedPairsNID: {
292 MakePairs2();
293 MakePairs2_Rotated();
294 } break;
295 case kHemispherePairsNID: {
296 MakePairs2();
297 MakePairs2_Hemisphere();
298 } break;
299 case kNoBackgroundNID: {
300 MakePairs2();
301 } break;
302 case kChargedNID2: {
303 MakePairs2();
304 // AB AA + BB
305 MakePairs2_Charged2();
306 } break;
307 case kChargedNID3: {
308 MakePairs2();
309 // AB // CC
311 for (int i = 0; i < fTaskNo; i++) {
312 fTask[i]->fCurrentTrack1CollectionNo = fCurrentTrack1CollectionNo;
313 fTask[i]->fCurrentTrack2CollectionNo = fCurrentTrack2CollectionNo;
315 }
317 MakePairs2_Charged3();
318 } break;
319 default: Cout::PrintInfo("Unknown Background mode", EInfo::kCriticalError); break;
320 }
321 }
322
326 return;
327 }
328 for (int i = 0; i < fTaskNo; i++) {
329 fTask[i]->fCurrentTrack1CollectionNo = fCurrentTrack1CollectionNo;
330 fTask[i]->fCurrentTrack2CollectionNo = fCurrentTrack2CollectionNo;
332 }
333 switch (fBackgroundMode) {
334 case kPerfectPairsID: {
335 MakePairs();
336 MakePairs_Perfect();
337 } break;
338 case kMixedPairsID: {
339 MakePairs();
340 if (fMemoryMap->IsReadyToMixing(fCurrentEventCollectionID)) { MakePairs_Mixed(); }
341 } break;
342 case kRotatedPairsID: {
343 MakePairs();
344 MakePairs_Rotated();
345 } break;
346 case kHemispherePairsID: {
347 MakePairs();
348 MakePairs_Hemisphere();
349 } break;
350 case kNoBackgroundID: {
351 MakePairs();
352 } break;
353 case kChargedID2: {
354 MakePairs();
355 // AA AB
356 fCurrentTrack1CollectionNo = fCurrentTrackCollectionID;
357 fCurrentTrack2CollectionNo = fCurrentTrackCollectionID + 1;
358 for (int i = 0; i < fTaskNo; i++) {
359 fTask[i]->fCurrentTrack1CollectionNo = fCurrentTrack1CollectionNo;
360 fTask[i]->fCurrentTrack2CollectionNo = fCurrentTrack2CollectionNo;
362 }
363 if (fMemoryMap->GetTracksNo(fCurrentEventCollectionID, fCurrentTrack1CollectionNo) == 0) return;
364 if (fMemoryMap->GetTracksNo(fCurrentEventCollectionID, fCurrentTrack2CollectionNo) == 0) return;
365 MakePairs_Charged2();
366 } break;
367 case kChargedID3: {
368 MakePairs();
369 // AA BC
370 fCurrentTrack1CollectionNo = fCurrentTrackCollectionID + 1;
371 fCurrentTrack2CollectionNo = fCurrentTrackCollectionID + 2;
372 for (int i = 0; i < fTaskNo; i++) {
373 fTask[i]->fCurrentTrack1CollectionNo = fCurrentTrack1CollectionNo;
374 fTask[i]->fCurrentTrack2CollectionNo = fCurrentTrack2CollectionNo;
376 }
377 if (fMemoryMap->GetTracksNo(fCurrentEventCollectionID, fCurrentTrack1CollectionNo) == 0) return;
378 if (fMemoryMap->GetTracksNo(fCurrentEventCollectionID, fCurrentTrack2CollectionNo) == 0) return;
379 MakePairs_Charged3();
380 } break;
381 default: Cout::PrintInfo("Unknown Background mode", EInfo::kCriticalError); break;
382 }
383 }
384
386 delete ana->fMemoryMap;
387 ana->fMemoryMap = fMemoryMap;
390 ana->fCurrentTrack1 = fCurrentTrack1;
391 ana->fCurrentTrack2 = fCurrentTrack2;
393 delete ana->fCurrentBackgroundPair;
395 }
396 delete ana->fCurrentSignalPair;
399 }
400
402 ana->fMemoryMap = nullptr;
403 ana->fCurrentEvent = nullptr;
404 ana->fCurrentTrack = nullptr;
405 ana->fCurrentTrack1 = nullptr;
406 ana->fCurrentTrack2 = nullptr;
407 ana->fCurrentBackgroundPair = nullptr;
408 ana->fCurrentSignalPair = nullptr;
409 }
410
412 ana->AddCut(EventVirtualCut(), Form("{%ix1}", fEventCollectionsNo));
413 ana->fCutContainer->MakeDummyCopies(ECutUpdate::kEvent, fCutContainer, kTRUE);
414 ana->AddCut(TrackVirtualCut(), Form("{%ix1}", fTrackCollectionsNo));
415 ana->fCutContainer->MakeDummyCopies(ECutUpdate::kTrack, fCutContainer, kTRUE);
416 ana->AddCut(TwoTrackVirtualCut(), Form("{%ix1}+sig", fTwoTrackCollectionsNo));
417 ana->fCutContainer->MakeDummyCopies(ECutUpdate::kTwoTrack, fCutContainer, kTRUE);
419 ana->AddCut(TwoTrackVirtualCut(), Form("{%ix1}+bckg", fTwoTrackCollectionsNo));
420 ana->fCutContainer->MakeDummyCopies(ECutUpdate::kTwoTrackBackground, fCutContainer, kTRUE);
421 }
422 ana->SetMixSize(fMixSize);
423 }
424
425 TwoTrackAnaChain::~TwoTrackAnaChain() {
426 for (int i = 0; i < fTaskNo; i++) {
427 UnlinkTask(fTask[i]);
428 delete fTask[i];
429 }
430 delete[] fTask;
431 }
432} // namespace Hal
static void PrintInfo(TString text, Hal::EInfo status)
Definition Cout.cxx:370
void MakeDummyCopies(ECutUpdate update, CutContainer *other, Bool_t copy_link)
static DataFormatManager * Instance()
Event * GetNewEvent(Int_t task_id, EFormatDepth format_depth=EFormatDepth::kAll) const
CutContainer * fCutContainer
Definition EventAna.h:78
Int_t fEventCollectionsNo
Definition EventAna.h:61
Int_t GetTaskID() const
Definition EventAna.h:155
void MarkAsInChain()
Definition EventAna.h:133
Int_t fMixSize
Definition EventAna.h:57
Event * fCurrentEvent
Definition EventAna.h:86
TString GetInputFileName() const
Definition EventAna.h:99
UInt_t fProcessedEvents
Definition EventAna.h:53
MemoryMapManager * fMemoryMap
Definition EventAna.h:82
const ECutUpdate fTiers
Definition EventAna.h:70
virtual void AddCut(const Cut &cut, Option_t *opt="")
Definition EventAna.cxx:322
virtual Package * Report() const
Definition EventAna.cxx:259
Int_t fCurrentEventCollectionID
Definition EventAna.h:65
virtual void SetFormat(Event *format, EFormatDepth depth=EFormatDepth::kAll)
Definition EventAna.cxx:210
Int_t GetTracksNo(Int_t event_collection, Int_t track_collection) const
void RejectLastEvent(Int_t event_collection)
Bool_t IsReadyToMixing(Int_t collection) const
virtual void ProcessTrack()
void SetName(TString name)
Definition Package.cxx:298
void AddObject(TObject *object)
Definition Package.cxx:209
void GoToDir(TString name)
Definition Task.cxx:28
Track * fCurrentTrack
Definition TrackAna.h:42
Int_t fCurrentTrackCollectionID
Definition TrackAna.h:34
Int_t fTrackCollectionsNo
Definition TrackAna.h:30
virtual void SynchronizeCutContainers(TwoTrackAna *ana, Bool_t end) const
virtual void UnlinkTask(TwoTrackAna *ana) const
virtual void FinishEventNonIdentical()
virtual void FinishEventIdentical()
virtual void LinkTask(TwoTrackAna *ana) const
virtual void AddAnalysis(TwoTrackAna *ana)
virtual Package * Report() const
virtual Task::EInitFlag Init()
TwoTrack * fCurrentSignalPair
virtual void ProcessPair2_Charged2()
virtual void ProcessPair2_Charged3()
TwoTrack * fCurrentBackgroundPair
Int_t fTwoTrackCollectionsNo
virtual void ProcessPair_ChargedNId()
virtual Package * Report() const
virtual void ProcessEvent()
virtual void ProcessPair_Charged2()
virtual void ProcessPair2_Perfect()
EAnaMode fBackgroundMode
virtual void ProcessPair_Perfect()
virtual void ProcessPair2()
virtual void ProcessPair2_Hemisphere()
Int_t fCurrentPairCollectionID
@ kHemispherePairsID
kHemispherePairsID
Definition TwoTrackAna.h:45
@ kChargedID2
kChargedID2
Definition TwoTrackAna.h:51
@ kRotatedPairsID
kRotatedPairsID
Definition TwoTrackAna.h:42
@ kNoBackgroundNID
kNoBackgroundNID
Definition TwoTrackAna.h:48
@ kHemispherePairsNID
kHemispherePairsNID
Definition TwoTrackAna.h:46
@ kNoBackgroundID
kNoBackgroundID
Definition TwoTrackAna.h:47
@ kRotatedPairsNID
kRotatedPairsNID
Definition TwoTrackAna.h:43
@ kMixedPairs
kMixedPairs
Definition TwoTrackAna.h:38
@ kChargedNID2
kChargedNID2
Definition TwoTrackAna.h:53
@ kMixedPairsNID
kMixedPairsNID
Definition TwoTrackAna.h:40
@ kPerfectPairsID
kPerfectPairsID
Definition TwoTrackAna.h:36
@ kNoBackground
kNoBackground
Definition TwoTrackAna.h:49
@ kChargedID3
kChargedID3
Definition TwoTrackAna.h:52
@ kPerfectPairsNID
kPerfectPairsNID
Definition TwoTrackAna.h:37
@ kMixedPairsID
kMixedPairsID
Definition TwoTrackAna.h:39
@ kChargedNID3
kChargedNID3
Definition TwoTrackAna.h:54
virtual void ProcessPair_Mixed()
TwoTrackAna(Bool_t use_background=kFALSE)
virtual void ProcessPair_ChargedId()
virtual void ProcessPair2_Mixed()
virtual void ProcessPair2_Rotated()
virtual void ProcessPair_Hemisphere()
virtual void ProcessPair_Charged3()
virtual void ProcessPair_Rotated()
virtual void ProcessPair()
void SetMixSize(Int_t mixsize)
virtual Task::EInitFlag Init()