]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/global/ReadFlatESD.C
da1e80662c7ed7ae2f92bd0c2fbcc44b46d5f36a
[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", Bool_t verbose=kFALSE) {
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     while( curr < endBuff ){
51       cout<<"Reading event "<<iEvent<<":"<<endl;
52       AliFlatESDEvent *flatEsd = reinterpret_cast<AliFlatESDEvent *>(curr);
53                         new (flatEsd) AliFlatESDEvent(1);
54
55       cout<<"vtx SPD: "<<(Bool_t) flatEsd->GetPrimaryVertexSPD()
56           <<" vtx tracks: "<<(Bool_t) flatEsd->GetPrimaryVertexTracks() 
57           <<" ntracks: "<<flatEsd->GetNumberOfTracks()
58           <<" nV0's: "<<flatEsd->GetNumberOfV0s()
59           <<endl;
60
61
62
63
64 // compare tracks
65 if(verbose){
66         static const int nExt = 4;
67           AliFlatESDTrack *track = flatEsd->GetTracks();
68     for (Int_t idxTrack = 0; idxTrack < flatEsd->GetNumberOfTracks() && track; ++idxTrack) { 
69
70                 AliFlatExternalTrackParam* ext[nExt] ={
71                         
72                                 track->GetTrackParamRefitted(),
73                                 track->GetTrackParamIp(),
74                                 track->GetTrackParamTPCInner(),
75                                 track->GetTrackParamOp(),
76                 
77                 };
78         
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);
81
82
83         for(int iExt=0; iExt<nExt; ++iExt){
84 cout<<endl<<iExt<<endl;         
85                 if(!ext[iExt]){
86                 //      cout<<"DIFFERENCE!: ";
87                         cout<<" ext"<<iExt<<" not set"<<endl;
88                 }       
89
90
91                 cout<<" alpha"<<iExt<<" :"  << (ext[iExt] ? ext[iExt]->GetAlpha() : -9999) <<endl;
92                         
93
94                 
95 cout<<" GetX"<<iExt<<" :"  << (ext[iExt] ? ext[iExt]->GetX(): -9999) <<endl;
96
97
98                 
99         cout<<" 1/pt"<<iExt<<" :"  <<  (ext[iExt] ? ext[iExt]->GetSigned1Pt(): -9999)  <<endl;
100                         
101
102 }
103         
104                 cout<<" nTPCclusters: "<<track->GetNumberOfTPCClusters()<< endl;
105
106                 cout<<" nITSclusters: "<<track->GetNumberOfITSClusters()<< endl;
107
108
109 // compare clusters
110         if(  track->GetNumberOfTPCClusters()){
111                 for (Int_t idxCluster = 0; idxCluster < track->GetNumberOfTPCClusters(); ++idxCluster){
112                         AliFlatTPCCluster * cl = track->GetTPCCluster(idxCluster);
113
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;
116                                 
117                 }
118           }
119      
120       track = track->GetNextTrack();
121           
122           
123           }
124 }
125
126
127
128
129
130
131
132
133
134
135
136       curr=curr+ flatEsd->GetSize();
137       iEvent++;
138     }
139
140
141
142
143
144
145
146
147
148
149
150     delete[] buffer;
151   }
152   else {
153     cout << "File "<<filename<<" could not be read" << endl;
154   }
155   return;
156 }