]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG1/TRD/AliTRDpwg1Helper.cxx
From P. Gonzales: Adding Dalitz task, updates accordingly
[u/mrichter/AliRoot.git] / PWG1 / TRD / AliTRDpwg1Helper.cxx
CommitLineData
61f6b45e 1////////////////////////////////////////////////////////////////////////////
2// //
3// Helper class for PWG1 TRD train //
4// //
5// Authors: //
6// Markus Fasel <M.Fasel@gsi.de> //
7// //
8////////////////////////////////////////////////////////////////////////////
9
7f1490fc 10#include <Rtypes.h>
11#include <TError.h>
12#include <TObjArray.h>
13#include <TObjString.h>
14#include <TRandom.h>
15#include <TString.h>
16#include <TSystem.h>
17
18#include <cstring>
19#include <fstream>
20
21#include "AliTRDpwg1Helper.h"
22
99535225 23const Char_t * AliTRDpwg1Helper::fgkTRDtaskClassName[AliTRDpwg1Helper::kNTRDTASKS] = {
7f1490fc 24 "AliTRDcheckESD"
25 ,"AliTRDinfoGen"
26 ,"AliTRDcheckDET"
27 ,"AliTRDefficiency"
28 ,"AliTRDresolution"
29 ,"AliTRDcheckPID"
30 ,"AliTRDv0Monitor"
31 ,"AliTRDcalibration"
32 ,"AliTRDefficiencyMC"
33 ,"AliTRDalignmentTask"
34 ,"AliTRDpidRefMaker"
35 ,"AliTRDclusterResolution"
36 ,"AliTRDmultiplicity"
37};
38
99535225 39const Char_t * AliTRDpwg1Helper::fgkTRDtaskOpt[AliTRDpwg1Helper::kNTRDTASKS+1] = {
7f1490fc 40 "ESD"
41 ,"GEN"
42 ,"DET"
43 ,"EFF"
44 ,"RES"
45 ,"PID"
46 ,"V0"
47 ,"CAL"
48 ,"EFFC"
49 ,"ALGN"
50 ,"PIDR"
51 ,"CLRES"
52 ,"MULT"
53 ,"ALL"
54};
55
56//______________________________________________________
61f6b45e 57Int_t AliTRDpwg1Helper::ParseOptions(Char_t *trd)
58{
59// Parse space separated options.
60// Possible options are:
61// "ALL" : [default] all performance (no calibration) tasks
62// ------- Performance tasks ----------
63// "ESD" : Basic TRD Detector checks on ESD only (no TRD tracks analysed)
64// "DET" : Basic TRD Detector checks
65// "RES" : TRD tracking Resolution
66// "EFF" : TRD Tracking Efficiency
67// "PID" : TRD PID - pion efficiency
68// "V0" : monitor V0 performance for use in TRD PID calibration
69// ------- Calibration tasks ----------
70// "EFFC" : TRD Tracking Efficiency Combined (barrel + stand alone) - only in case of simulations
71// "MULT" : TRD single track selection
72// "CLRES": clusters Resolution
73// "CAL" : TRD calibration
74// "ALGN" : TRD alignment
75// "PIDR" : TRD PID - reference data
76// ------- SPECIAL OPTIONS -----------
77// "NOFR" : Data set does not have AliESDfriends.root
78// "NOMC" : Data set does not have Monte Carlo Informations (default have MC),
79
8ee59659 80 Int_t fSteerTask = 0;
7f1490fc 81 TObjArray *tasksArray = TString(trd).Tokenize(" ");
82 for(Int_t isel = 0; isel < tasksArray->GetEntriesFast(); isel++){
83 TString s = (dynamic_cast<TObjString *>(tasksArray->UncheckedAt(isel)))->String();
84 if(s.CompareTo("ALL") == 0){
85 for(Int_t itask = 0; itask < kNTRDQATASKS; itask++) SETBIT(fSteerTask, itask);
86 continue;
87 } else if(s.CompareTo("NOMC") == 0 || s.CompareTo("NOFR") == 0){
88 continue; // taken care by special functions
89 } else {
90 Bool_t foundOpt = kFALSE;
91 for(Int_t itask = 0; itask < kNTRDTASKS; itask++){
92 if(s.CompareTo(fgkTRDtaskOpt[itask]) != 0) continue;
93 SETBIT(fSteerTask, itask);
94 if(itask>1) SETBIT(fSteerTask, kInfoGen);
95 foundOpt = kTRUE;
96 break;
97 }
98 if(!foundOpt) Info("ParseOptions()", Form("TRD task %s not implemented (yet).", s.Data()));
99 }
100 }
101 // extra rules for calibration tasks
102 if(TESTBIT(fSteerTask, kCalibration)) SETBIT(fSteerTask, kCheckDET);
103 if(TESTBIT(fSteerTask, kMultiplicity)) SETBIT(fSteerTask, kEfficiency);
104 if(TESTBIT(fSteerTask, kEfficiencyMC)) SETBIT(fSteerTask, kEfficiency);
105 if(TESTBIT(fSteerTask, kClErrParam)) SETBIT(fSteerTask, kResolution);
106 if(TESTBIT(fSteerTask, kAlignment)) SETBIT(fSteerTask, kResolution);
107 if(TESTBIT(fSteerTask, kPIDRefMaker)) SETBIT(fSteerTask, kCheckPID);
108 if(TESTBIT(fSteerTask, kV0Monitor)) SETBIT(fSteerTask, kCheckPID);
109
110 return fSteerTask;
111
112}
113
114//______________________________________________________
115void AliTRDpwg1Helper::MergeProd(const Char_t *mark, const Char_t *files, const Int_t nBatch = 20)
116{
61f6b45e 117// Merge Output files named "mark" from list in "files"
7f1490fc 118
61f6b45e 119 Char_t lMERGE[8]; sprintf(lMERGE, "%d.lst", (Int_t)gRandom->Uniform(9999.));
120 Char_t lPURGE[8]; sprintf(lPURGE, "%d.lst", (Int_t)gRandom->Uniform(9999.));
7f1490fc 121 gSystem->Exec("mkdir -p merge; rm -rf merge/*");
122
123 // purge file list
124 std::string filename;
125 std::ifstream file(files);
126 Int_t iline(0);
127 while(getline(file, filename)){
128 if(Int_t(filename.find(mark)) < 0) continue;
61f6b45e 129 gSystem->Exec(Form("echo %s >> %s", filename.c_str(), lPURGE));
7f1490fc 130 iline++;
131 }
132 Int_t nBatches(iline/nBatch);
133
134 for(Int_t ibatch(0); ibatch<nBatches; ibatch++){
135 Int_t first(ibatch*nBatch);
61f6b45e 136 if(!gSystem->Exec(Form("root.exe -b -q \'$ALICE_ROOT/PWG1/TRD/macros/mergeBatch.C(\"%s\", \"%s\", %d, %d)\'", mark, lPURGE, nBatch, first))) continue;
7f1490fc 137 gSystem->Exec(Form("mv %d_%s merge/", first, mark));
61f6b45e 138 gSystem->Exec(Form("echo %s/merge/%d_%s >> %s", gSystem->ExpandPathName("$PWD"), first, mark, lMERGE));
7f1490fc 139 }
61f6b45e 140 gSystem->Exec(Form("root.exe -b -q \'$ALICE_ROOT/PWG1/TRD/macros/mergeBatch.C(\"%s\", \"%s\", %d, 0, kFALSE, kTRUE)\'", mark, lMERGE, nBatches));
7f1490fc 141 gSystem->Exec(Form("mv 0_%s %s", mark, mark));
142
61f6b45e 143 gSystem->Exec(Form("rm -rfv %s %s merge", lMERGE, lPURGE));
7f1490fc 144}
145
8ee59659 146//______________________________________________________
61f6b45e 147Int_t AliTRDpwg1Helper::GetTaskIndex(const Char_t *name)
148{
149// Give index in TRD train of task class "name"
8ee59659 150 for(Int_t it(0); it<kNTRDTASKS; it++){
151 if(strcmp(fgkTRDtaskClassName[it], name)==0) return it;
152 }
153 return -1;
154}
155
7f1490fc 156//______________________________________________________
61f6b45e 157Bool_t AliTRDpwg1Helper::HasReadMCData(Char_t *opt)
158{
159// Use MC data option
7f1490fc 160 return !(Bool_t)strstr(opt, "NOMC");
161}
162
163//____________________________________________
61f6b45e 164Bool_t AliTRDpwg1Helper::HasReadFriendData(Char_t *opt)
165{
166// Use friends data option
7f1490fc 167 return !(Bool_t)strstr(opt, "NOFR");
168}
169