CbmRoot
PairAnalysisMixedEvent.cxx
Go to the documentation of this file.
1 // //
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 
15 #include <TExMap.h>
16 #include <TObjArray.h>
17 #include <TProcessID.h>
18 
19 #include "PairAnalysisTrack.h"
20 
21 #include "PairAnalysisMixedEvent.h"
22 
24 
26  : PairAnalysisMixedEvent("mixedevent", "mixed event") {
27  //
28  // Default Constructor
29  //
30 }
31 
32 //______________________________________________
34  const char* title)
35  : TNamed(name, title), fArrTrackP(), fArrTrackN() {
36  //
37  // Named Constructor
38  //
39  for (Int_t i = 0; i < PairAnalysisVarManager::kNMaxValuesMC; ++i)
40  fEventData[i] = 0.;
41 }
42 
43 //______________________________________________
45  //
46  // Default Destructor
47  //
48  fArrTrackP.Delete();
49  fArrTrackN.Delete();
50 }
51 
52 //______________________________________________
53 void PairAnalysisMixedEvent::SetTracks(const TObjArray& arrP,
54  const TObjArray& arrN) {
55  //
56  // Setup PairAnalysisPairs
57  // assumes that the objects in arrP and arrN are
58  //
59 
60  //Clear out old entries before filling new ones
61  Clear(); // check if this can be improved, by calling clear instead of removeat
62 
63  // we keep the tracks buffered to minimise new / delete operations
64  fNTracksN = 0;
65  fNTracksP = 0;
66 
67  //check size of the arrays
68  if (fArrTrackP.GetSize() < arrP.GetSize()) {
69  fArrTrackP.Expand(arrP.GetSize());
70  }
71  if (fArrTrackN.GetSize() < arrN.GetSize()) {
72  fArrTrackN.Expand(arrN.GetSize());
73  }
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 =
81  dynamic_cast<PairAnalysisTrack*>(arrP.At(itrack));
82  if (!track) continue;
83 
84  // buffer track
85  // PairAnalysisTrack *ctrack = new (fArrTrackP[tracks]) PairAnalysisTrack(*track);
86  new (fArrTrackP[tracks]) PairAnalysisTrack(*track);
87 
88  ++tracks;
89  }
90  fNTracksP = tracks;
91 
92  tracks = 0;
93  for (Int_t itrack = 0; itrack < arrN.GetEntriesFast(); ++itrack) {
94  PairAnalysisTrack* track =
95  dynamic_cast<PairAnalysisTrack*>(arrN.At(itrack));
96  if (!track) continue;
97 
98  //buffer track
99  // PairAnalysisTrack *ctrack = new (fArrTrackN[tracks]) PairAnalysisTrack(*track);
100  new (fArrTrackN[tracks]) PairAnalysisTrack(*track);
101 
102  ++tracks;
103  }
104  fNTracksN = tracks;
105 }
106 
107 //______________________________________________
108 void PairAnalysisMixedEvent::Clear(Option_t* opt) {
109  //
110  // clear arrays
111  //
112  fArrTrackP.Clear(opt);
113  fArrTrackN.Clear(opt);
114 }
115 
116 //______________________________________________
117 void PairAnalysisMixedEvent::Set(Int_t size) {
118  //
119  // set size of array
120  //
121  fArrTrackP.SetClass("PairAnalysisTrack", size);
122  fArrTrackN.SetClass("PairAnalysisTrack", size);
123 }
124 
125 //______________________________________________
127  const Double_t data[PairAnalysisVarManager::kNMaxValuesMC]) {
128  //
129  // copy only evnet variables
130  //
131  for (Int_t i = PairAnalysisVarManager::kPairMax;
133  ++i)
134  fEventData[i] = data[i];
135 }
136 
137 //______________________________________________
139  //
140  // Custom function to assign a uid to an object with an own process id
141  // to avoid problems buffering the vertices
142  //
143  UInt_t uid = 1;
144  if (fPID->GetObjects()) uid = fPID->GetObjects()->GetEntriesFast();
145  uid += (fPIDIndex << 24);
146  obj->SetBit(kIsReferenced);
147  obj->SetUniqueID(uid);
148  fPID->PutObjectWithID(obj);
149 }
PairAnalysisVarManager::kPairMax
@ kPairMax
Definition: PairAnalysisVarManager.h:239
PairAnalysisVarManager::kNMaxValuesMC
@ kNMaxValuesMC
Definition: PairAnalysisVarManager.h:343
PairAnalysisMixedEvent::fArrTrackN
TClonesArray fArrTrackN
Definition: PairAnalysisMixedEvent.h:51
PairAnalysisMixedEvent::fNTracksP
Int_t fNTracksP
Definition: PairAnalysisMixedEvent.h:53
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
PairAnalysisMixedEvent::fPID
TProcessID * fPID
Definition: PairAnalysisMixedEvent.h:60
PairAnalysisTrack
Definition: PairAnalysisTrack.h:37
tracks
TClonesArray * tracks
Definition: Analyze_matching.h:17
PairAnalysisMixedEvent::fEventData
Double_t fEventData[PairAnalysisVarManager::kNMaxValuesMC]
Definition: PairAnalysisMixedEvent.h:58
PairAnalysisMixedEvent::SetTracks
void SetTracks(const TObjArray &arrP, const TObjArray &arrN)
Definition: PairAnalysisMixedEvent.cxx:53
ClassImp
ClassImp(PairAnalysisMixedEvent) PairAnalysisMixedEvent
Definition: PairAnalysisMixedEvent.cxx:23
PairAnalysisMixedEvent::Set
void Set(Int_t size=100)
Definition: PairAnalysisMixedEvent.cxx:117
PairAnalysisMixedEvent::Clear
virtual void Clear(Option_t *opt="C")
Definition: PairAnalysisMixedEvent.cxx:108
PairAnalysisMixedEvent::fPIDIndex
UInt_t fPIDIndex
internal PID for references to buffered objects
Definition: PairAnalysisMixedEvent.h:61
PairAnalysisMixedEvent
Definition: PairAnalysisMixedEvent.h:24
PairAnalysisTrack.h
PairAnalysisMixedEvent::fNTracksN
Int_t fNTracksN
Definition: PairAnalysisMixedEvent.h:54
PairAnalysisMixedEvent::~PairAnalysisMixedEvent
virtual ~PairAnalysisMixedEvent()
Definition: PairAnalysisMixedEvent.cxx:44
PairAnalysisMixedEvent::fArrTrackP
TClonesArray fArrTrackP
Definition: PairAnalysisMixedEvent.h:50
PairAnalysisMixedEvent.h
PairAnalysisMixedEvent::SetEventData
void SetEventData(const Double_t data[PairAnalysisVarManager::kNMaxValuesMC])
Definition: PairAnalysisMixedEvent.cxx:126
PairAnalysisMixedEvent::PairAnalysisMixedEvent
PairAnalysisMixedEvent()
PairAnalysisMixedEvent::AssignID
void AssignID(TObject *obj)
Definition: PairAnalysisMixedEvent.cxx:138