]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/global/ReadFlatESD.C
adopting ReadFlatESD to new functions
[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
52b5e706 25void ReadFlatESD(const char* filename="outFlatESD.dat", Int_t verbose=0) {
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);
f009a562 55 flatEsd->Reinitialize();
9e363878 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
6eb01754 64// compare tracks
65if(verbose){
66 static const int nExt = 4;
b904048c 67 AliFlatESDTrack *track = const_cast<AliFlatESDTrack*> ( flatEsd->GetTracks() );
52b5e706 68 //new (track)AliFlatESDTrack(1);
6eb01754 69 for (Int_t idxTrack = 0; idxTrack < flatEsd->GetNumberOfTracks() && track; ++idxTrack) {
70
82852ab2 71 cout<<"track nr "<<idxTrack<<endl;
72
6eb01754 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){
87cout<<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;
6eb01754 95cout<<" GetX"<<iExt<<" :" << (ext[iExt] ? ext[iExt]->GetX(): -9999) <<endl;
6eb01754 96 cout<<" 1/pt"<<iExt<<" :" << (ext[iExt] ? ext[iExt]->GetSigned1Pt(): -9999) <<endl;
97
98
99}
100
101 cout<<" nTPCclusters: "<<track->GetNumberOfTPCClusters()<< endl;
d3b8c07f 102 cout<<" nITSclusters: "<<track->GetNumberOfITSClusters()<< endl;
6eb01754 103
d3b8c07f 104// read clusters
b904048c 105#if 0
d3b8c07f 106 Int_t nCl = track->GetNumberOfTPCClusters();
107 if(nCl && verbose > 1){
108
b904048c 109 for (Int_t idxRow = 0; idxRow < nCl; idxRow++){
110 cout<<"rowNr "<< idxRow<<endl;
d3b8c07f 111
b904048c 112 AliFlatTPCCluster * cl = track->GetTPCCluster(idxRow);
d3b8c07f 113
114 cout<<" idx fX fY fZ fSigmaY2 fSigmaZ2 fCharge fQMax fPadRow" <<endl;
82852ab2 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 }
d3b8c07f 119 else cout <<"----------------------------------------------------"<<endl;
b904048c 120 }
d3b8c07f 121 }
b904048c 122#endif
123
124
125 track = const_cast<AliFlatESDTrack*> (track->GetNextTrack());
6eb01754 126
127
128 }
129}
130
d3b8c07f 131 Printf("curr: %p \t + %d = %p , diff:%p", curr, flatEsd->GetSize() ,curr+ flatEsd->GetSize(), endBuff-(curr+ flatEsd->GetSize()) );
251a2c81 132 curr=curr+ flatEsd->GetSize();
133 iEvent++;
134 }
135
6eb01754 136
251a2c81 137 delete[] buffer;
138 }
139 else {
d5b8cffe 140 cout << "File "<<filename<<" could not be read" << endl;
251a2c81 141 }
142 return;
143}