2 * >> Testing Macro to read FlatESDEvent from output file <<
4 * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli
7 * aliroot -b -l -q LoadLibs.C ReadFlatESD.C++
9 **************************************************************************/
11 #if !defined(__CINT__) || defined(__MAKECINT__)
12 #include "AliESDEvent.h"
14 #include "AliESDfriend.h"
18 #include "./AliFlatESDEvent.h"
19 #include "./AliFlatESDTrack.h"
20 #include "./AliFlatTPCCluster.h"
21 #include "./AliFlatExternalTrackParam.h"
22 #include "Riostream.h"
25 void ReadFlatESD(const char* filename="outFlatESD.dat", Int_t verbose=0) {
27 ifstream is(filename, std::ifstream::binary | std::ifstream::in);
29 std::cout << "ifstream available"<<endl;
31 int length = is.tellg();
33 std::cout << "length "<<length<<endl;
34 char * buffer = new char [length];
36 std::cout << "Reading " << length << " characters... ";
38 is.read (buffer,length);
40 std::cout << "all characters read successfully." << endl;
42 std::cout << "error: only " << is.gcount() << " could be read";
45 // ...buffer contains the entire file...
48 char *endBuff = buffer+length;
51 while( curr < endBuff ){
52 cout<<endl<<"Reading event "<<iEvent<<":"<<endl;
53 Printf("curr: %p \t endBuff: %p \t diff %p ", curr, endBuff, endBuff-curr);
54 AliFlatESDEvent *flatEsd = reinterpret_cast<AliFlatESDEvent *>(curr);
55 flatEsd->Reinitialize();
58 cout<<"vtx SPD: "<<(Bool_t) flatEsd->GetPrimaryVertexSPD()
59 <<" vtx tracks: "<<(Bool_t) flatEsd->GetPrimaryVertexTracks()
60 <<" ntracks: "<<flatEsd->GetNumberOfTracks()
61 <<" nV0's: "<<flatEsd->GetNumberOfV0s()
66 static const int nExt = 4;
67 AliFlatESDTrack *track = flatEsd->GetTracks();
68 //new (track)AliFlatESDTrack(1);
69 for (Int_t idxTrack = 0; idxTrack < flatEsd->GetNumberOfTracks() && track; ++idxTrack) {
71 cout<<"track nr "<<idxTrack<<endl;
73 AliFlatExternalTrackParam* ext[nExt] ={
75 track->GetTrackParamRefitted(),
76 track->GetTrackParamIp(),
77 track->GetTrackParamTPCInner(),
78 track->GetTrackParamOp(),
82 //Printf(" TEST: FlatTrack1 %d > FlatExternalTrackParam1 > %p %p %p %p", idxTrack, exp11, exp21, exp31, exp41);
83 //Printf(" TEST: FlatTrack2 %d > FlatExternalTrackParam2 > %p %p %p %p", idxTrack, exp12, exp22, exp32, exp42);
86 for(int iExt=0; iExt<nExt; ++iExt){
87 cout<<endl<<iExt<<endl;
89 // cout<<"DIFFERENCE!: ";
90 cout<<" ext"<<iExt<<" not set"<<endl;
94 cout<<" alpha"<<iExt<<" :" << (ext[iExt] ? ext[iExt]->GetAlpha() : -9999) <<endl;
95 cout<<" GetX"<<iExt<<" :" << (ext[iExt] ? ext[iExt]->GetX(): -9999) <<endl;
96 cout<<" 1/pt"<<iExt<<" :" << (ext[iExt] ? ext[iExt]->GetSigned1Pt(): -9999) <<endl;
101 cout<<" nTPCclusters: "<<track->GetNumberOfTPCClusters()<< endl;
102 cout<<" nITSclusters: "<<track->GetNumberOfITSClusters()<< endl;
106 Int_t nCl = track->GetNumberOfTPCClusters();
107 if(nCl && verbose > 1){
109 for (Int_t idxRow = 0; idxRow < nCl; idxRow++){
110 cout<<"rowNr "<< idxRow<<endl;
112 AliFlatTPCCluster * cl = track->GetTPCCluster(idxRow);
114 cout<<" idx fX fY fZ fSigmaY2 fSigmaZ2 fCharge fQMax fPadRow" <<endl;
116 cout<< idxRow <<" "<< cl->GetX()<<" "<< cl->GetY()<<" "<< cl->GetZ()<<" "<< cl->GetSigmaY2()<<" "<< cl->GetSigmaZ2()<<" "<< cl->GetCharge()<<" "<< cl->GetQMax() <<" "<< cl->GetPadRow()<<endl;
119 else cout <<"----------------------------------------------------"<<endl;
122 track = track->GetNextTrack();
128 Printf("curr: %p \t + %d = %p , diff:%p", curr, flatEsd->GetSize() ,curr+ flatEsd->GetSize(), endBuff-(curr+ flatEsd->GetSize()) );
129 curr=curr+ flatEsd->GetSize();
137 cout << "File "<<filename<<" could not be read" << endl;