]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/global/ReadFlatESD.C
added constructors to ReadFlatESD.C, fixed bugs in FlatESDConverter concerning timing...
[u/mrichter/AliRoot.git] / HLT / global / ReadFlatESD.C
CommitLineData
251a2c81 1/**
2 * >> Testing Macro to read FlatESDEvent from output file <<
3 **
4 * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli
5 *
6 * Usage:
7 * aliroot -b -l -q LoadLibs.C ReadFlatESD.C++
8 *
9 **************************************************************************/
10
11#if !defined(__CINT__) || defined(__MAKECINT__)
12#include "AliESDEvent.h"
13#include "AliESD.h"
14#include "AliESDfriend.h"
15#include <TFile.h>
16#include <TTree.h>
17#include <TSystem.h>
18#include "./AliFlatESDEvent.h"
19#include "./AliFlatESDTrack.h"
20#include "./AliFlatTPCCluster.h"
21#include "./AliFlatExternalTrackParam.h"
22#include "Riostream.h"
23#endif
24
6eb01754 25void ReadFlatESD(const char* filename="outFlatESD.dat", Bool_t verbose=kFALSE) {
251a2c81 26
27 ifstream is(filename, std::ifstream::binary | std::ifstream::in);
28 if (is){
6eb01754 29 std::cout << "ifstream available"<<endl;
251a2c81 30 is.seekg (0, is.end);
31 int length = is.tellg();
32 is.seekg (0, is.beg);
d3b8c07f 33 std::cout << "length "<<length<<endl;
251a2c81 34 char * buffer = new char [length];
35
36 std::cout << "Reading " << length << " characters... ";
37
38 is.read (buffer,length);
39 if (is)
40 std::cout << "all characters read successfully." << endl;
41 else
42 std::cout << "error: only " << is.gcount() << " could be read";
43 is.close();
44
45 // ...buffer contains the entire file...
46
47 char *curr = buffer;
48 char *endBuff = buffer+length;
49 int iEvent = 0;
d3b8c07f 50
251a2c81 51 while( curr < endBuff ){
d3b8c07f 52 cout<<endl<<"Reading event "<<iEvent<<":"<<endl;
53 Printf("curr: %p \t endBuff: %p \t diff %p ", curr, endBuff, endBuff-curr);
251a2c81 54 AliFlatESDEvent *flatEsd = reinterpret_cast<AliFlatESDEvent *>(curr);
9e363878 55 new (flatEsd) AliFlatESDEvent(1);
56
d3b8c07f 57
58cout<<"vtx SPD: "<<(Bool_t) flatEsd->GetPrimaryVertexSPD()
251a2c81 59 <<" vtx tracks: "<<(Bool_t) flatEsd->GetPrimaryVertexTracks()
60 <<" ntracks: "<<flatEsd->GetNumberOfTracks()
61 <<" nV0's: "<<flatEsd->GetNumberOfV0s()
62 <<endl;
6eb01754 63
64
65
66
67// compare tracks
68if(verbose){
69 static const int nExt = 4;
70 AliFlatESDTrack *track = flatEsd->GetTracks();
d3b8c07f 71 new (track)AliFlatESDTrack(1);
6eb01754 72 for (Int_t idxTrack = 0; idxTrack < flatEsd->GetNumberOfTracks() && track; ++idxTrack) {
73
74 AliFlatExternalTrackParam* ext[nExt] ={
75
76 track->GetTrackParamRefitted(),
77 track->GetTrackParamIp(),
78 track->GetTrackParamTPCInner(),
79 track->GetTrackParamOp(),
80
81 };
82
83 //Printf(" TEST: FlatTrack1 %d > FlatExternalTrackParam1 > %p %p %p %p", idxTrack, exp11, exp21, exp31, exp41);
84 //Printf(" TEST: FlatTrack2 %d > FlatExternalTrackParam2 > %p %p %p %p", idxTrack, exp12, exp22, exp32, exp42);
85
86
87 for(int iExt=0; iExt<nExt; ++iExt){
88cout<<endl<<iExt<<endl;
89 if(!ext[iExt]){
90 // cout<<"DIFFERENCE!: ";
91 cout<<" ext"<<iExt<<" not set"<<endl;
92 }
93
94
95 cout<<" alpha"<<iExt<<" :" << (ext[iExt] ? ext[iExt]->GetAlpha() : -9999) <<endl;
6eb01754 96cout<<" GetX"<<iExt<<" :" << (ext[iExt] ? ext[iExt]->GetX(): -9999) <<endl;
6eb01754 97 cout<<" 1/pt"<<iExt<<" :" << (ext[iExt] ? ext[iExt]->GetSigned1Pt(): -9999) <<endl;
98
99
100}
101
102 cout<<" nTPCclusters: "<<track->GetNumberOfTPCClusters()<< endl;
d3b8c07f 103 cout<<" nITSclusters: "<<track->GetNumberOfITSClusters()<< endl;
6eb01754 104
d3b8c07f 105// read clusters
6eb01754 106
d3b8c07f 107 Int_t nCl = track->GetNumberOfTPCClusters();
108 if(nCl && verbose > 1){
109
110 for (Int_t idxRow = 0; idxRow < nCl; idxRow++){
111 cout<<"rowNr "<< idxRow<<endl;
112
113 AliFlatTPCCluster * cl = track->GetTPCCluster(idxRow);
114
115 cout<<" idx fX fY fZ fSigmaY2 fSigmaZ2 fCharge fQMax fPadRow" <<endl;
116 if(cl) cout<< idxRow <<" "<< cl->GetX()<<" "<< cl->GetY()<<" "<< cl->GetZ()<<" "<< cl->GetSigmaY2()<<" "<< cl->GetSigmaZ2()<<" "<< cl->GetCharge()<<" "<< cl->GetQMax() <<" "<< cl->GetPadRow()<<endl;
117 else cout <<"----------------------------------------------------"<<endl;
118 }
119 }
6eb01754 120
d3b8c07f 121 cout<<"get next track"<<endl;
6eb01754 122 track = track->GetNextTrack();
d3b8c07f 123 new (track)AliFlatESDTrack(1);
6eb01754 124
125
126 }
127}
128
d3b8c07f 129 Printf("curr: %p \t + %d = %p , diff:%p", curr, flatEsd->GetSize() ,curr+ flatEsd->GetSize(), endBuff-(curr+ flatEsd->GetSize()) );
251a2c81 130 curr=curr+ flatEsd->GetSize();
131 iEvent++;
132 }
133
6eb01754 134
251a2c81 135 delete[] buffer;
136 }
137 else {
d5b8cffe 138 cout << "File "<<filename<<" could not be read" << endl;
251a2c81 139 }
140 return;
141}