]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/global/ReadFlatESD.C
fix AliHLTGlobalEsdConverterComponent
[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"
c2374f56 22#include "./AliFlatESDTrigger.h"
0d3e34a2 23#include "./AliFlatESDV0.h"
251a2c81 24#include "Riostream.h"
25#endif
26
52b5e706 27void ReadFlatESD(const char* filename="outFlatESD.dat", Int_t verbose=0) {
251a2c81 28
29 ifstream is(filename, std::ifstream::binary | std::ifstream::in);
30 if (is){
6eb01754 31 std::cout << "ifstream available"<<endl;
251a2c81 32 is.seekg (0, is.end);
33 int length = is.tellg();
34 is.seekg (0, is.beg);
d3b8c07f 35 std::cout << "length "<<length<<endl;
251a2c81 36 char * buffer = new char [length];
37
38 std::cout << "Reading " << length << " characters... ";
39
40 is.read (buffer,length);
41 if (is)
42 std::cout << "all characters read successfully." << endl;
43 else
44 std::cout << "error: only " << is.gcount() << " could be read";
45 is.close();
46
47 // ...buffer contains the entire file...
48
49 char *curr = buffer;
50 char *endBuff = buffer+length;
51 int iEvent = 0;
d3b8c07f 52
251a2c81 53 while( curr < endBuff ){
d3b8c07f 54 cout<<endl<<"Reading event "<<iEvent<<":"<<endl;
5ec8009a 55 // Printf("curr: %p \t endBuff: %p \t diff %p ", curr, endBuff, endBuff-curr);
251a2c81 56 AliFlatESDEvent *flatEsd = reinterpret_cast<AliFlatESDEvent *>(curr);
f009a562 57 flatEsd->Reinitialize();
9e363878 58
d3b8c07f 59
5ec8009a 60cout<<"vtx SPD: "<<(Bool_t) flatEsd->GetFlatPrimaryVertexSPD()
61 <<" vtx tracks: "<<(Bool_t) flatEsd->GetFlatPrimaryVertexTracks()
251a2c81 62 <<" ntracks: "<<flatEsd->GetNumberOfTracks()
63 <<" nV0's: "<<flatEsd->GetNumberOfV0s()
64 <<endl;
6eb01754 65
6eb01754 66// compare tracks
c2374f56 67if(verbose){/*
6eb01754 68 static const int nExt = 4;
b904048c 69 AliFlatESDTrack *track = const_cast<AliFlatESDTrack*> ( flatEsd->GetTracks() );
52b5e706 70 //new (track)AliFlatESDTrack(1);
6eb01754 71 for (Int_t idxTrack = 0; idxTrack < flatEsd->GetNumberOfTracks() && track; ++idxTrack) {
72
82852ab2 73 cout<<"track nr "<<idxTrack<<endl;
74
5ec8009a 75 const AliFlatExternalTrackParam* ext[nExt] ={
6eb01754 76
5ec8009a 77 track->GetFlatTrackParamRefitted(),
78 track->GetFlatTrackParamIp(),
79 track->GetFlatTrackParamTPCInner(),
80 track->GetFlatTrackParamOp(),
6eb01754 81
82 };
83
84 //Printf(" TEST: FlatTrack1 %d > FlatExternalTrackParam1 > %p %p %p %p", idxTrack, exp11, exp21, exp31, exp41);
85 //Printf(" TEST: FlatTrack2 %d > FlatExternalTrackParam2 > %p %p %p %p", idxTrack, exp12, exp22, exp32, exp42);
86
87
88 for(int iExt=0; iExt<nExt; ++iExt){
89cout<<endl<<iExt<<endl;
90 if(!ext[iExt]){
91 // cout<<"DIFFERENCE!: ";
92 cout<<" ext"<<iExt<<" not set"<<endl;
93 }
94
95
96 cout<<" alpha"<<iExt<<" :" << (ext[iExt] ? ext[iExt]->GetAlpha() : -9999) <<endl;
6eb01754 97cout<<" GetX"<<iExt<<" :" << (ext[iExt] ? ext[iExt]->GetX(): -9999) <<endl;
6eb01754 98 cout<<" 1/pt"<<iExt<<" :" << (ext[iExt] ? ext[iExt]->GetSigned1Pt(): -9999) <<endl;
99
100
c2374f56 101}
b904048c 102 track = const_cast<AliFlatESDTrack*> (track->GetNextTrack());
6eb01754 103
104
105 }
c2374f56 106
107*/
108
109
110 // compare triggers
111
0d3e34a2 112 /*
c2374f56 113 cout<<"------------------\ntriggers\n------------------\n";
114 AliFlatESDTrigger * trigger =const_cast<AliFlatESDTrigger*>(flatEsd->GetTriggerClasses() ) ;
115 for( Int_t i = 0; i < flatEsd->GetNumberOfTriggerClasses() ; i++ ){
116 cout<<"\nnew trigger\n";
117 cout<<"AliFlatESDTrigger::GetSize"<<trigger->GetSize()<<endl;
118 cout<<"AliFlatESDTrigger::GetTriggerIndex"<<trigger->GetTriggerIndex()<<endl;
119 cout<< "AliFlatESDTrigger::GetTriggerClassName"<<trigger->GetTriggerClassName()<<endl;
120
121 trigger= trigger->GetNextTriggerNonConst();
122 }
0d3e34a2 123 **/
c2374f56 124
0d3e34a2 125 // compare v0s
c2374f56 126
127
0d3e34a2 128 if(flatEsd->GetNumberOfV0s() ){
129 cout<<"------------------\nv0s\n------------------\n";
130
131 AliFlatESDV0 * v0 = const_cast<AliFlatESDV0*>(flatEsd->GetV0s() ) ;
132 for( Int_t i = 0; i < flatEsd->GetNumberOfV0s(); i++ ){
133 cout<<"\nnew v0\n";
134 cout<<"AliFlatESDV0::GetSize "<<v0->GetSize()<<endl;
135 cout<<"AliFlatESDV0::GetNegTrackID "<<v0->GetNegTrackID()<<endl ;
136 cout<<"AliFlatESDV0::GetPosTrackID "<<v0->GetPosTrackID()<<endl;
137
138 v0 = v0->GetNextV0NonConst();
139 }
140 }
141
142
143
144
c2374f56 145
6eb01754 146}
147
5ec8009a 148 // Printf("curr: %p \t + %d = %p , diff:%p", curr, flatEsd->GetSize() ,curr+ flatEsd->GetSize(), endBuff-(curr+ flatEsd->GetSize()) );
251a2c81 149 curr=curr+ flatEsd->GetSize();
150 iEvent++;
151 }
152
6eb01754 153
251a2c81 154 delete[] buffer;
155 }
156 else {
d5b8cffe 157 cout << "File "<<filename<<" could not be read" << endl;
251a2c81 158 }
159 return;
160}