CbmRoot
Loading...
Searching...
No Matches
PairAnalysisMixedEvent.cxx
Go to the documentation of this file.
1
2// //
3// //
4// Authors:
5// * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
6// Julian Book <Julian.Book@cern.ch>
7/*
8
9 Small event keeping holding track arrays and the event data.
10
11*/
12// //
14
16
17#include <TExMap.h>
18#include <TObjArray.h>
19#include <TProcessID.h>
20
21#include "PairAnalysisTrack.h"
22
24
26 : PairAnalysisMixedEvent("mixedevent", "mixed event")
27{
28 //
29 // Default Constructor
30 //
31}
32
33//______________________________________________
34PairAnalysisMixedEvent::PairAnalysisMixedEvent(const char* name, const char* title)
35 : TNamed(name, title)
36 , fArrTrackP()
37 , fArrTrackN()
38{
39 //
40 // Named Constructor
41 //
42 for (Int_t i = 0; i < PairAnalysisVarManager::kNMaxValuesMC; ++i)
43 fEventData[i] = 0.;
44}
45
46//______________________________________________
48{
49 //
50 // Default Destructor
51 //
52 fArrTrackP.Delete();
53 fArrTrackN.Delete();
54}
55
56//______________________________________________
57void PairAnalysisMixedEvent::SetTracks(const TObjArray& arrP, const TObjArray& arrN)
58{
59 //
60 // Setup PairAnalysisPairs
61 // assumes that the objects in arrP and arrN are
62 //
63
64 //Clear out old entries before filling new ones
65 Clear(); // check if this can be improved, by calling clear instead of removeat
66
67 // we keep the tracks buffered to minimise new / delete operations
68 fNTracksN = 0;
69 fNTracksP = 0;
70
71 //check size of the arrays
72 if (fArrTrackP.GetSize() < arrP.GetSize()) { fArrTrackP.Expand(arrP.GetSize()); }
73 if (fArrTrackN.GetSize() < arrN.GetSize()) { fArrTrackN.Expand(arrN.GetSize()); }
74
75 TExMap mapStoredVertices;
76 fPIDIndex = TProcessID::GetPIDs()->IndexOf(fPID);
77 // fill particles
78 Int_t tracks = 0;
79 for (Int_t itrack = 0; itrack < arrP.GetEntriesFast(); ++itrack) {
80 PairAnalysisTrack* track = dynamic_cast<PairAnalysisTrack*>(arrP.At(itrack));
81 if (!track) continue;
82
83 // buffer track
84 // PairAnalysisTrack *ctrack = new (fArrTrackP[tracks]) PairAnalysisTrack(*track);
85 new (fArrTrackP[tracks]) PairAnalysisTrack(*track);
86
87 ++tracks;
88 }
90
91 tracks = 0;
92 for (Int_t itrack = 0; itrack < arrN.GetEntriesFast(); ++itrack) {
93 PairAnalysisTrack* track = dynamic_cast<PairAnalysisTrack*>(arrN.At(itrack));
94 if (!track) continue;
95
96 //buffer track
97 // PairAnalysisTrack *ctrack = new (fArrTrackN[tracks]) PairAnalysisTrack(*track);
98 new (fArrTrackN[tracks]) PairAnalysisTrack(*track);
99
100 ++tracks;
101 }
103}
104
105//______________________________________________
107{
108 //
109 // clear arrays
110 //
111 fArrTrackP.Clear(opt);
112 fArrTrackN.Clear(opt);
113}
114
115//______________________________________________
117{
118 //
119 // set size of array
120 //
121 fArrTrackP.SetClass("PairAnalysisTrack", size);
122 fArrTrackN.SetClass("PairAnalysisTrack", size);
123}
124
125//______________________________________________
127{
128 //
129 // copy only evnet variables
130 //
132 fEventData[i] = data[i];
133}
134
135//______________________________________________
137{
138 //
139 // Custom function to assign a uid to an object with an own process id
140 // to avoid problems buffering the vertices
141 //
142 UInt_t uid = 1;
143 if (fPID->GetObjects()) uid = fPID->GetObjects()->GetEntriesFast();
144 uid += (fPIDIndex << 24);
145 obj->SetBit(kIsReferenced);
146 obj->SetUniqueID(uid);
147 fPID->PutObjectWithID(obj);
148}
TClonesArray * tracks
static constexpr size_t size()
Definition KfSimdPseudo.h:2
ClassImp(PairAnalysisMixedEvent) PairAnalysisMixedEvent
virtual void Clear(Option_t *opt="C")
void SetTracks(const TObjArray &arrP, const TObjArray &arrN)
void SetEventData(const Double_t data[PairAnalysisVarManager::kNMaxValuesMC])
UInt_t fPIDIndex
internal PID for references to buffered objects
Double_t fEventData[PairAnalysisVarManager::kNMaxValuesMC]