Macro for converting data into internal format ~DST
[u/mrichter/AliRoot.git] / HBTAN / hbtanalysis.C
CommitLineData
e477958c 1void hbtanalysis(Option_t* datatype, Option_t* processopt="TracksAndParticles",
2 Int_t first = -1,Int_t last = -1,
3 char *outfile = "hbtanalysis.root")
0a6dde4c 4 {
5//HBT Anlysis Macro
6//Anlyzes TPC recontructed tracks and simulated particles that corresponds to them
e477958c 7
8//datatype defines type of data to be read
9// Kine - analyzes Kine Tree: simulated particles
10// TPC - analyzes TPC tracking + particles corresponding to these tracks
11// ITSv1 - analyzes ITSv1 ----------------------//--------------------------
12// ITSv2 - analyzes ITSv2 ----------------------//--------------------------
13
14//processopt defines option passed to AliHBTAnlysis::Process method
15// default: TracksAndParticles - process both recontructed tracks and sim. particles corresponding to them
16// Tracks - process only recontructed tracks
17// Particles - process only simulated particles
18
0a6dde4c 19//Reads data from diroctories from first to last(including)
20// For examples if first=3 and last=5 it reads from
21// ./3/
22// ./4/
23// ./5/
24//if first or last is negative (or both), it reads from current directory
25//
26//these names I use when analysis is done directly from CASTOR files via RFIO
27// const char* basedir="rfio:/castor/cern.ch/user/s/skowron/";
28// const char* serie="standard";
29// const char* field = "0.4";
30 const char* basedir=".";
31 const char* serie="";
32 const char* field = "";
33
34 // Dynamically link some shared libs
35 gROOT->LoadMacro("loadlibs.C");
36 loadlibs();
37
71094efa 38 gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libHBTAN");
0a6dde4c 39
40
41 /***********************************************************/
42 //Create analysis and reader
43 AliHBTAnalysis * analysis = new AliHBTAnalysis();
44
45 AliHBTReader* reader;
e477958c 46 Int_t kine = strcmp(datatype,"Kine");
47 Int_t TPC = strcmp(datatype,"TPC");
48 Int_t ITSv1 = strcmp(datatype,"ITSv1");
49 Int_t ITSv2 = strcmp(datatype,"ITSv2");
50
51 if(!kine)
52 {
53 reader = new AliHBTReaderKineTree();
54 processopt="Particles"; //this reader by definition reads only simulated particles
55 }
56 else if(!TPC)
57 {
58 reader = new AliHBTReaderTPC();
59 }
60 else if(!ITSv1)
61 {
62 reader = new AliHBTReaderITSv1();
63 }
64 else if(!ITSv2)
65 {
66 reader = new AliHBTReaderITSv2();
67 }
68 else
69 {
70 cerr<<"Option "<<datatype<<" not recognized. Exiting"<<endl;
71 return;
72 }
73
0a6dde4c 74 TObjArray* dirs=0;
e477958c 75 if ( (first >= 0) && (last>=0) && ( (last-first)>=0 ) )
76 {//read from many dirs dirs
77 char buff[50];
78 dirs = new TObjArray(last-first+1);
79 for (Int_t i = first; i<=last; i++)
80 {
71094efa 81 if(i == 24) continue;
e477958c 82 sprintf(buff,"%s/%s/%s/%d",basedir,field,serie,i);
83 TObjString *odir= new TObjString(buff);
84 dirs->Add(odir);
85 }
0a6dde4c 86 }
e477958c 87 reader->SetDirs(dirs);
0a6dde4c 88
89 /***********************************************************/
90
91 //we want have only low pt pi+ so set a cut to reader
92 AliHBTParticleCut* readerpartcut= new AliHBTParticleCut();
e4e0ed45 93 readerpartcut->SetPtRange(0.0,1.5);
0a6dde4c 94 readerpartcut->SetPID(kPiPlus);
95 reader->AddParticleCut(readerpartcut);//read this particle type with this cut
96
97 analysis->SetReader(reader);
98 /************************************************************/
99
d4ebbc5f 100 AliHBTPairCut *paircut = new AliHBTPairCut();
101 paircut->SetQInvRange(0.0,0.20);
102 analysis->SetGlobalPairCut(paircut);
0a6dde4c 103
e4e0ed45 104 AliHBTQInvCorrelFctn * qinvcfT= new AliHBTQInvCorrelFctn();
105 AliHBTQInvCorrelFctn * qinvcfP= new AliHBTQInvCorrelFctn();
0a6dde4c 106
107 analysis->AddTrackFunction(qinvcfT);
108 analysis->AddParticleFunction(qinvcfP);
109
e477958c 110 analysis->Process(processopt);
0a6dde4c 111
112 qinvcfP->Rename("qinvcfP","Particle (simulated) Qinv CF \\pi^{+} \\pi^{+}");
113 qinvcfT->Rename("qinvcfT","Track (recontructed) Qinv CF \\pi^{+} \\pi^{+}");
114
115 TFile histoOutput(outfile,"recreate");
116 analysis->WriteFunctions();
117 histoOutput.Close();
118
119 delete qinvcfP;
120 delete qinvcfT;
d4ebbc5f 121 delete paircut;
0a6dde4c 122 delete readerpartcut;
123 if (dirs)
124 {
125 dirs->SetOwner();
126 delete dirs;
127 }
128 delete reader;
129 delete analysis;
130
131 }
132