]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/global/ReadFlatESD.C
fixed bug in special constructor
[u/mrichter/AliRoot.git] / HLT / global / ReadFlatESD.C
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
25 void ReadFlatESD(const char* filename="outFlatESD.dat", Int_t verbose=0) {
26
27   ifstream is(filename, std::ifstream::binary | std::ifstream::in);
28   if (is){
29     std::cout << "ifstream available"<<endl;
30     is.seekg (0, is.end);
31     int length = is.tellg();
32     is.seekg (0, is.beg);
33     std::cout << "length "<<length<<endl;
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;
50     
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();
56
57       
58 cout<<"vtx SPD: "<<(Bool_t) flatEsd->GetPrimaryVertexSPD()
59           <<" vtx tracks: "<<(Bool_t) flatEsd->GetPrimaryVertexTracks() 
60           <<" ntracks: "<<flatEsd->GetNumberOfTracks()
61           <<" nV0's: "<<flatEsd->GetNumberOfV0s()
62           <<endl;
63
64 // compare tracks
65 if(verbose){
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) { 
70
71         cout<<"track nr "<<idxTrack<<endl;
72
73                 AliFlatExternalTrackParam* ext[nExt] ={
74                         
75                                 track->GetTrackParamRefitted(),
76                                 track->GetTrackParamIp(),
77                                 track->GetTrackParamTPCInner(),
78                                 track->GetTrackParamOp(),
79                 
80                 };
81         
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);
84
85
86         for(int iExt=0; iExt<nExt; ++iExt){
87 cout<<endl<<iExt<<endl;         
88                 if(!ext[iExt]){
89                 //      cout<<"DIFFERENCE!: ";
90                         cout<<" ext"<<iExt<<" not set"<<endl;
91                 }       
92
93
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;
97                         
98
99 }
100         
101                 cout<<" nTPCclusters: "<<track->GetNumberOfTPCClusters()<< endl;
102                 cout<<" nITSclusters: "<<track->GetNumberOfITSClusters()<< endl;
103
104 // read clusters
105
106         Int_t nCl = track->GetNumberOfTPCClusters();
107         if(nCl && verbose > 1){
108         
109       for (Int_t idxRow = 0; idxRow <  nCl; idxRow++){
110       cout<<"rowNr "<< idxRow<<endl;
111       
112       AliFlatTPCCluster * cl = track->GetTPCCluster(idxRow);
113
114                                 cout<<" idx fX fY fZ  fSigmaY2 fSigmaZ2 fCharge fQMax fPadRow" <<endl;
115                                 if(cl) {
116                                 cout<< idxRow <<" "<< cl->GetX()<<" "<< cl->GetY()<<" "<< cl->GetZ()<<" "<< cl->GetSigmaY2()<<" "<< cl->GetSigmaZ2()<<" "<< cl->GetCharge()<<" "<< cl->GetQMax() <<" "<< cl->GetPadRow()<<endl;
117                                 
118                                 }
119                                 else cout <<"----------------------------------------------------"<<endl;
120     }
121         }
122       track = track->GetNextTrack();
123           
124           
125           }
126 }
127
128     Printf("curr: %p \t + %d = %p , diff:%p", curr, flatEsd->GetSize() ,curr+ flatEsd->GetSize(), endBuff-(curr+ flatEsd->GetSize())   );
129       curr=curr+ flatEsd->GetSize();
130       iEvent++;
131     }
132
133
134     delete[] buffer;
135   }
136   else {
137     cout << "File "<<filename<<" could not be read" << endl;
138   }
139   return;
140 }