]>
Commit | Line | Data |
---|---|---|
251a2c81 | 1 | /** |
2 | * >> Testing Macro to fill FlatESDEvent from ALiESDEvent << | |
3 | ** | |
4 | * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli | |
5 | * | |
6 | * Usage: | |
7 | * aliroot -b -l -q LoadLibs.C FlatESDConverter.C++ | |
8 | * | |
9 | **************************************************************************/ | |
10 | ||
11 | #if !defined(__CINT__) || defined(__MAKECINT__) | |
12 | #include "AliESDEvent.h" | |
13 | #include "AliESD.h" | |
14 | #include "AliESDfriend.h" | |
6eb01754 | 15 | #include "AliESDfriendTrack.h" |
16 | #include "../TPC/Rec/AliTPCseed.h" | |
251a2c81 | 17 | #include <TFile.h> |
18 | #include <TTree.h> | |
19 | #include <TSystem.h> | |
20 | #include "./AliFlatESDEvent.h" | |
21 | #include "./AliFlatESDTrack.h" | |
22 | #include "./AliFlatTPCCluster.h" | |
23 | #include "./AliFlatExternalTrackParam.h" | |
24 | #include "Riostream.h" | |
d3b8c07f | 25 | #include "AliSysInfo.h" |
251a2c81 | 26 | #endif |
27 | ||
6eb01754 | 28 | void FlatESDConverter(const char* filename="AliESDs.root", const char* filenameFriends="AliESDfriends.root",const char* filenameOut="out.dat", Bool_t useESDFriends = kTRUE, Bool_t useHLTtree = kFALSE,Int_t verbose = 0) { |
251a2c81 | 29 | // -- Convert AliESDEvent to AliFlatESDEvent |
30 | ||
d5b8cffe | 31 | ofstream outFile(Form("%s",filenameOut), std::ifstream::binary | std::ifstream::out); |
251a2c81 | 32 | //ofstream outFile("outFlatESD.dat"); |
33 | ||
34 | TFile *file = new TFile(Form("%s", filename)); | |
8f658767 | 35 | |
36 | TTree *esdTree = useHLTtree? dynamic_cast<TTree*>(file->Get("HLTesdTree")) : dynamic_cast<TTree*>(file->Get("esdTree")); | |
37 | ||
251a2c81 | 38 | |
39 | // -- Connect ESD | |
40 | AliESDEvent *esd = new AliESDEvent; | |
41 | esd->ReadFromTree(esdTree); | |
42 | ||
43 | // -- Connect ESD friend | |
44 | AliESDfriend *esdFriend = NULL; | |
45 | if (useESDFriends && !esdTree->FindBranch("ESDfriend.")) { | |
d5b8cffe | 46 | esdTree->AddFriend("esdFriendTree", Form("%s", filenameFriends)); |
251a2c81 | 47 | esdTree->SetBranchStatus("ESDfriend.", 1); |
48 | ||
49 | esdFriend = dynamic_cast<AliESDfriend*>((const_cast<AliESDEvent*>(esd))->FindListObject("AliESDfriend")); | |
50 | if (esdFriend) | |
51 | esdTree->SetBranchAddress("ESDfriend.", &esdFriend); | |
52 | } // if (!esdTree->FindBranch("ESDfriend.")) { | |
53 | ||
54 | AliFlatESDEvent *flatEsd = NULL; | |
55 | ||
56 | // -- Event Loop | |
8f658767 | 57 | for (Int_t idxEvent = 0; idxEvent < esdTree->GetEntries(); idxEvent++) { |
f009a562 | 58 | Printf("Processing event nr %d", idxEvent); |
59 | ||
6eb01754 | 60 | |
d3b8c07f | 61 | AliSysInfo::AddStamp("getEntry",0,0,idxEvent); |
251a2c81 | 62 | esdTree->GetEntry(idxEvent); |
63 | // -- Book memory for AliFlatESDEvent | |
64 | // -- TEST >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | |
65 | ||
66 | Byte_t *mem = new Byte_t[AliFlatESDEvent::EstimateSize(esd, useESDFriends)]; | |
6eb01754 | 67 | |
d3b8c07f | 68 | AliSysInfo::AddStamp("DoEvent.Start",0,0,idxEvent); |
251a2c81 | 69 | |
f009a562 | 70 | |
71 | Printf("getting event from memory"); | |
72 | flatEsd = reinterpret_cast<AliFlatESDEvent*>(mem); | |
73 | Printf("calling special constructor"); | |
74 | new (flatEsd) AliFlatESDEvent; | |
75 | ||
76 | Printf("filling event"); | |
251a2c81 | 77 | // -- Fill AliFlatESDEvent |
78 | flatEsd->Fill(esd, useESDFriends); | |
6eb01754 | 79 | |
80 | ||
d3b8c07f | 81 | AliSysInfo::AddStamp("DoEvent.Stop",0,flatEsd->GetSize(),idxEvent); |
f009a562 | 82 | |
83 | ||
84 | ||
85 | ||
6eb01754 | 86 | if(verbose){ |
251a2c81 | 87 | Printf("TEST: Event %d || Tracks %d | FRIEND Tracks %d || estimated size %llu || sizeof(AliFlatESDEvent) %llu", |
88 | idxEvent, esd->GetNumberOfTracks(), esdFriend->GetNumberOfTracks(), | |
89 | AliFlatESDEvent::EstimateSize(esd, useESDFriends), flatEsd->GetSize()); | |
90 | ||
8f658767 | 91 | |
251a2c81 | 92 | AliFlatESDTrack *track = flatEsd->GetTracks(); |
93 | for (Int_t idxTrack = 0; idxTrack < flatEsd->GetNumberOfTracks(); ++idxTrack) { | |
6eb01754 | 94 | AliESDtrack *esdTrack = esd->GetTrack(idxTrack); |
95 | AliESDfriendTrack *friendTrack = esdFriend->GetTrack(idxTrack) ; | |
251a2c81 | 96 | |
97 | if (track && !esdTrack) { | |
98 | Printf("ERROR THIS SHOULD NOT HAPPEN AT ALL !!! TRACK %d HAS NO ESD TRACK!!!", idxTrack); | |
99 | return; | |
100 | } | |
101 | ||
6eb01754 | 102 | if (track ) { |
103 | ||
f009a562 | 104 | |
251a2c81 | 105 | AliFlatExternalTrackParam* exp1 = track->GetTrackParamCp(); |
106 | AliFlatExternalTrackParam* exp2 = track->GetTrackParamIp(); | |
107 | AliFlatExternalTrackParam* exp3 = track->GetTrackParamTPCInner(); | |
108 | AliFlatExternalTrackParam* exp4 = track->GetTrackParamOp(); | |
109 | ||
110 | Float_t alphaFLAT[4] = {0., 0., 0., 0.}; | |
111 | if (exp1) alphaFLAT[0] = exp1->GetAlpha(); | |
112 | if (exp2) alphaFLAT[1] = exp2->GetAlpha(); | |
113 | if (exp3) alphaFLAT[2] = exp3->GetAlpha(); | |
114 | if (exp4) alphaFLAT[3] = exp4->GetAlpha(); | |
115 | ||
116 | Float_t alphaOLD[4] = {0., 0., 0., 0.}; | |
117 | if (esdTrack->GetConstrainedParam()) alphaOLD[0] = esdTrack->GetConstrainedParam()->GetAlpha(); | |
118 | if (esdTrack->GetInnerParam()) alphaOLD[1] = esdTrack->GetInnerParam()->GetAlpha(); | |
119 | if (esdTrack->GetTPCInnerParam()) alphaOLD[2] = esdTrack->GetTPCInnerParam()->GetAlpha(); | |
120 | if (esdTrack->GetOuterParam()) alphaOLD[3] = esdTrack->GetOuterParam()->GetAlpha(); | |
121 | ||
122 | Printf(" TEST: FlatTrack %d > FlatExternalTrackParam > %p %p %p %p", idxTrack, exp1, exp2, exp3, exp4); | |
123 | Printf(" TEST: FlatTrack %d > Alpha %f %f %f %f", idxTrack, alphaFLAT[0], alphaFLAT[1], alphaFLAT[2], alphaFLAT[3]); | |
124 | Printf(" TEST: Old Track %d > Alpha %f %f %f %f", idxTrack, alphaOLD[0], alphaOLD[1], alphaOLD[2], alphaOLD[3]); | |
125 | Printf(" TEST: Diff %d > Alpha %f %f %f %f", idxTrack, | |
126 | alphaFLAT[0]-alphaOLD[0], alphaFLAT[1]-alphaOLD[1], alphaFLAT[2]-alphaOLD[2], alphaFLAT[3]-alphaOLD[3]); | |
f009a562 | 127 | |
251a2c81 | 128 | |
6eb01754 | 129 | Int_t nCl = track->GetNumberOfTPCClusters(); |
130 | Printf(" TEST: FlatTrack %d has %d FlatClusters", idxTrack, nCl ); | |
f009a562 | 131 | if(nCl && useESDFriends && verbose > 1){ |
6eb01754 | 132 | |
133 | TObject* calibObject = NULL; | |
134 | AliTPCseed* seed = NULL; | |
135 | ||
136 | for (Int_t idx = 0; (calibObject = friendTrack->GetCalibObject(idx)); ++idx) { | |
137 | if ((seed = dynamic_cast<AliTPCseed*>(calibObject))) break; | |
138 | } | |
251a2c81 | 139 | |
6eb01754 | 140 | // -- Fill cluster |
141 | if (seed) { | |
a1ca763e | 142 | |
143 | Int_t idxRow2=0; | |
6eb01754 | 144 | for (Int_t idxRow = 0; idxRow < nCl; idxRow++){ |
145 | AliFlatTPCCluster * cl = track->GetTPCCluster(idxRow); | |
6eb01754 | 146 | cout<<" idx fX fY fZ fSigmaY2 fSigmaZ2 fCharge fQMax fPadRow" <<endl; |
f009a562 | 147 | if(cl){ |
148 | cout<< idxRow <<" "<< cl->GetX()<<" "<< cl->GetY()<<" "<< cl->GetZ()<<" "<< cl->GetSigmaY2()<<" "<< cl->GetSigmaZ2()<<" "<< cl->GetCharge()<<" "<< cl->GetQMax() <<" "<< cl->GetPadRow()<<endl; | |
149 | } | |
150 | else{ | |
151 | cout<<idxRow<<"---------------------------------"<<endl<<endl; | |
152 | } | |
a1ca763e | 153 | AliTPCclusterMI* cl2 = NULL; |
154 | while(!cl2 && idxRow2<160){ | |
155 | cl2 = seed->GetClusterPointer(idxRow2++); | |
156 | } | |
6eb01754 | 157 | if (cl2) { |
158 | //cout<<" normalCl fX fY fZ fPadRow fSigmaY2 fSigmaZ2 fCharge fQMax" <<endl; | |
d3b8c07f | 159 | cout<< idxRow <<" "<< cl2->GetX()<<" "<< cl2->GetY()<<" "<< cl2->GetZ()<<" "<< cl2->GetSigmaY2()<<" "<< cl2->GetSigmaZ2()<<" "<< cl2->GetQ()<<" "<< cl2->GetMax()<<" "<< cl2->GetRow() <<endl<<endl; |
6eb01754 | 160 | } |
161 | else | |
162 | cout<<idxRow<<"---------------------------------"<<endl<<endl; | |
163 | } | |
164 | } | |
165 | } | |
166 | ||
251a2c81 | 167 | } |
168 | track = track->GetNextTrack(); | |
169 | } | |
6eb01754 | 170 | } |
251a2c81 | 171 | |
172 | outFile.write(reinterpret_cast<char*>(mem), flatEsd->GetSize()); | |
173 | ||
174 | delete[] mem; | |
175 | ||
176 | } // for (Int_t idxEvent = 1; idxEvent < 2; idxEvent++) { | |
177 | ||
178 | outFile.close(); | |
179 | ||
180 | return; | |
181 | } |