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", Bool_t verbose=kFALSE) {
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;
50 while( curr < endBuff ){
51 cout<<"Reading event "<<iEvent<<":"<<endl;
52 AliFlatESDEvent *flatEsd = reinterpret_cast<AliFlatESDEvent *>(curr);
53 new (flatEsd) AliFlatESDEvent(1);
55 cout<<"vtx SPD: "<<(Bool_t) flatEsd->GetPrimaryVertexSPD()
56 <<" vtx tracks: "<<(Bool_t) flatEsd->GetPrimaryVertexTracks()
57 <<" ntracks: "<<flatEsd->GetNumberOfTracks()
58 <<" nV0's: "<<flatEsd->GetNumberOfV0s()
66 static const int nExt = 4;
67 AliFlatESDTrack *track = flatEsd->GetTracks();
68 for (Int_t idxTrack = 0; idxTrack < flatEsd->GetNumberOfTracks() && track; ++idxTrack) {
70 AliFlatExternalTrackParam* ext[nExt] ={
72 track->GetTrackParamRefitted(),
73 track->GetTrackParamIp(),
74 track->GetTrackParamTPCInner(),
75 track->GetTrackParamOp(),
79 //Printf(" TEST: FlatTrack1 %d > FlatExternalTrackParam1 > %p %p %p %p", idxTrack, exp11, exp21, exp31, exp41);
80 //Printf(" TEST: FlatTrack2 %d > FlatExternalTrackParam2 > %p %p %p %p", idxTrack, exp12, exp22, exp32, exp42);
83 for(int iExt=0; iExt<nExt; ++iExt){
84 cout<<endl<<iExt<<endl;
86 // cout<<"DIFFERENCE!: ";
87 cout<<" ext"<<iExt<<" not set"<<endl;
91 cout<<" alpha"<<iExt<<" :" << (ext[iExt] ? ext[iExt]->GetAlpha() : -9999) <<endl;
95 cout<<" GetX"<<iExt<<" :" << (ext[iExt] ? ext[iExt]->GetX(): -9999) <<endl;
99 cout<<" 1/pt"<<iExt<<" :" << (ext[iExt] ? ext[iExt]->GetSigned1Pt(): -9999) <<endl;
104 cout<<" nTPCclusters: "<<track->GetNumberOfTPCClusters()<< endl;
106 cout<<" nITSclusters: "<<track->GetNumberOfITSClusters()<< endl;
110 if( track->GetNumberOfTPCClusters()){
111 for (Int_t idxCluster = 0; idxCluster < track->GetNumberOfTPCClusters(); ++idxCluster){
112 AliFlatTPCCluster * cl = track->GetTPCCluster(idxCluster);
114 cout<<" clusterNr fX fY fZ fPadRow fSigmaY2 fSigmaZ2 fCharge fQMax" <<endl;
115 cout<< idxCluster<<" "<< cl->GetX()<<" "<< cl->GetY()<<" "<< cl->GetZ()<<" "<< cl->GetPadRow()<<" "<< cl->GetSigmaY2()<<" "<< cl->GetSigmaZ2()<<" "<< cl->GetCharge()<<" "<< cl->GetQMax() <<endl;
120 track = track->GetNextTrack();
136 curr=curr+ flatEsd->GetSize();
153 cout << "File "<<filename<<" could not be read" << endl;