Some debug printout hidden behind if(gDebug)
[u/mrichter/AliRoot.git] / ANALYSIS / WriteAOD.C
CommitLineData
dd2b6810 1#if 0
2 #include "$(ALICE_ROOT)/TPC/alles.h"
3 #include "AliReader.h"
4 #include "AliReaderKineTree.h"
0317f8c1 5 #include "AliReaderESDTree.h"
dd2b6810 6 #include "AliAODParticleCut.h"
7 #include "AliAOD.h"
8 #include "AliAODPairCut.h"
9 #include "TSystem.h"
10 #include "TObjString.h"
11 #include "TString.h"
12 #include "AliPDG.h"
13#endif
14
15
efdb0cc9 16void WriteAOD(Option_t* datatype, Int_t first = -1,Int_t last = -1,
17 Option_t* processopt="TracksAndParticles",
dd2b6810 18 char *outfile = "AOD.root")
19 {
20//datatype defines type of data to be read
21// Kine - analyzes Kine Tree: simulated particles
22// ESD
23// AOD
24
25// default: TracksAndParticles - process both recontructed tracks and sim. particles corresponding to them
26// Tracks - process only recontructed tracks
27// Particles - process only simulated particles
28
29//Reads data from diroctories from first to last(including)
30// For examples if first=3 and last=5 it reads from
31// ./3/
32// ./4/
33// ./5/
34//if first or last is negative (or both), it reads from current directory
35//
36//these names I use when analysis is done directly from CASTOR files via RFIO
37
d9122a01 38 Bool_t multcheck = kTRUE;
39
dd2b6810 40 const char* basedir=".";
41 const char* serie="";
42 const char* field = "";
43 cout<<"WriteAOD.C: datatype is "<<datatype<<" dir is basedir"<<endl;
44 // Dynamically link some shared libs
45
46 cout<<"WriteAOD.C: Loading ANALYSIS .....\n";
47 gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libANALYSIS");
48 cout<<"WriteAOD.C: ..... Loaded\n";
49
d9122a01 50 Int_t PID[11];
51 PID[0]=kProton;
52 PID[1]=kProtonBar;
53 PID[2]=kKPlus;
54 PID[3]=kKMinus;
55 PID[4]=kPiPlus;
56 PID[5]=kPiMinus;
57 PID[6]=kElectron;
58 PID[7]=kPositron;
59 PID[8]=kMuonMinus;
60 PID[9]=kMuonPlus;
61 PID[10]=0;//Last must be 0!!!!!!!!!!!!!!!!!!
62
63 Float_t PIDprob[11];
64 PIDprob[0] = 0.5;
65 PIDprob[1] = 0.5;
66 PIDprob[2] = 0.5;
67 PIDprob[3] = 0.5;
68 PIDprob[4] = 0.5;
69 PIDprob[5] = 0.5;
70 PIDprob[6] = 0.5;
71 PIDprob[7] = 0.5;
72 PIDprob[8] = 0.5;
73 PIDprob[9] = 0.5;
74 PIDprob[10] = 0.5;
dd2b6810 75 /***********************************************************/
76
77 AliReader* reader;
78 Int_t kine = strcmp(datatype,"Kine");
79 Int_t ESD = strcmp(datatype,"ESD");
0317f8c1 80 Int_t ESDMuon = strcmp(datatype,"ESDMuon");
dd2b6810 81 Int_t intern = strcmp(datatype,"AOD");
82
83 if(!kine)
84 {
85 reader = new AliReaderKineTree();
86 processopt="Particles"; //this reader by definition reads only simulated particles
87 multcheck = kFALSE;
88 }
89 else if(!ESD)
90 {
91 AliReaderESD* esdreader = new AliReaderESD();
92 esdreader->ReadSimulatedData(kTRUE);
d9122a01 93 esdreader->SetNumberOfTrackPoints(5,30.);//5 points every 30 cm
94 esdreader->SetITSTrackPoints(kTRUE);
95 esdreader->SetClusterMap(kTRUE);
96
dd2b6810 97 reader = esdreader;
98 multcheck = kTRUE;
99 }
100
101 else if(!intern)
102 {
103 reader = new AliHBTReaderAOD("AOD.root");
104 multcheck = kTRUE;
105 }
0317f8c1 106
107 else if (!ESDMuon)
108 {
109 // set reader for ESD
110 AliReaderESDTree* muonreader = new AliReaderESDTree("AliESDs.root");
111 // active muon ESD reader
112 muonreader->SetReadMuon(kTRUE);
113 // disable central barrel (default = kTRUE)
114 muonreader->SetReadCentralBarrel(kFALSE);
115 // disable simulated data (not implemented yet)
116 muonreader->ReadSimulatedData(kFALSE);
117
118 reader = muonreader;
119 multcheck = kFALSE;
120 }
dd2b6810 121 else
122 {
123 cerr<<"Option "<<datatype<<" not recognized. Exiting"<<endl;
124 return;
125 }
126
127 TObjArray* dirs=0;
128 if ( (first >= 0) && (last>=0) && ( (last-first)>=0 ) )
129 {//read from many dirs dirs
130 cout<<"WriteAOD.C: ..... Setting dirs first="<<first<<" last="<<last<<"\n";
131 char buff[50];
132 dirs = new TObjArray(last-first+1);
133 dirs->SetOwner();
134 for (Int_t i = first; i<=last; i++)
135 {
136 sprintf(buff,"%s/%s/%s/%d",basedir,field,serie,i);
137 TObjString *odir= new TObjString(buff);
138 dirs->Add(odir);
139 }
140 }
141
2e8abbcc 142 reader->SetDirs(dirs);
d9122a01 143
144 AliAODParticleCut* readerpartcut= new AliAODParticleCut();
145
146 Int_t l = 0;
147 while (PID[l] != 0)
148 {
149 cout<<"WriteAOD.C: Adding PID = "<<PID[l]<<" l = "<<l<<endl;
150 readerpartcut->SetPID(PID[l]);
151 AliAODParticleCut * pcut = (AliAODParticleCut*)readerpartcut->Clone();
152 AliAODPIDCut* pidcut = new AliAODPIDCut(PID[l],PIDprob[l]);
153 pcut->AddBasePartCut(pidcut);
154 reader->AddParticleCut(pcut);//read this particle type with this cut
155 delete pcut;
156 l++;
157 }
158
159// readerpartcut->SetPtRange(0.0,1.2);
dd2b6810 160
161 cout<<"WriteAOD.C: P R O C S E S S I N G .....\n\n";
beb1c41d 162 AliReaderAOD::WriteAOD(reader,outfile,"AliAODParticle",multcheck);
dd2b6810 163 cout<<"\n\nWriteAOD.C: F I N I S H E D\n";
164
165 if (dirs) delete dirs;
166 delete reader;
167 }
168