fix broken compilation
[u/mrichter/AliRoot.git] / TRD / qaRec / macros / helper.C
CommitLineData
199fb43b 1#if ! defined (__CINT__) || defined (__MAKECINT__)
2#include "TFileMerger.h"
3#include "TSystem.h"
4#include "TString.h"
5#include "TObjString.h"
6#include "TObjArray.h"
7#include "TError.h"
c82c70b6 8#include <fstream>
199fb43b 9#endif
10
77dcc19a 11#ifndef HELPER_C
12#define HELPER_C
13
199fb43b 14//____________________________________________
15Int_t ParseOptions(Char_t *trd)
16{
17 Int_t fSteerTask = 1;
18 TObjArray *tasksArray = TString(trd).Tokenize(" ");
19 for(Int_t isel = 0; isel < tasksArray->GetEntriesFast(); isel++){
20 TString s = (dynamic_cast<TObjString *>(tasksArray->UncheckedAt(isel)))->String();
21 if(s.CompareTo("ALL") == 0){
a3e9af3c 22 for(Int_t itask = 0; itask < NTRDQATASKS; itask++) SETBITT(fSteerTask, itask);
199fb43b 23 continue;
24 } else {
25 Bool_t foundOpt = kFALSE;
26 for(Int_t itask = 2; itask < NTRDTASKS; itask++){
27 if(s.CompareTo(fgkTRDtaskOpt[itask]) != 0) continue;
a3e9af3c 28 SETBITT(fSteerTask, itask); SETBITT(fSteerTask, kInfoGen);
199fb43b 29 foundOpt = kTRUE;
30 break;
31 }
32 if(!foundOpt) Info("ParseOptions()", Form("TRD task %s not implemented (yet).", s.Data()));
33 }
34 }
35 // extra rules for calibration tasks
a3e9af3c 36 if(TSTBIT(fSteerTask, kCalibration)) SETBITT(fSteerTask, kCheckDET);
37 if(TSTBIT(fSteerTask, kMultiplicity)) SETBITT(fSteerTask, kEfficiency);
38 if(TSTBIT(fSteerTask, kEfficiencyMC)) SETBITT(fSteerTask, kEfficiency);
39 if(TSTBIT(fSteerTask, kClErrParam)) SETBITT(fSteerTask, kResolution);
40 if(TSTBIT(fSteerTask, kAlignment)) SETBITT(fSteerTask, kResolution);
41 if(TSTBIT(fSteerTask, kPIDRefMakerNN)) SETBITT(fSteerTask, kCheckPID);
42 if(TSTBIT(fSteerTask, kPIDRefMakerLQ)) SETBITT(fSteerTask, kCheckPID);
199fb43b 43
44 return fSteerTask;
45}
46
c82c70b6 47//______________________________________________________
199fb43b 48void mergeProd(const Char_t *mark, const Char_t *files, const Int_t kBatch = 20)
49{
50 TFileMerger *fFM = 0x0;
51
52 Int_t jbatch = 0, nbatch = 0;
53 string filename;
54 ifstream file(files);
55 while(getline(file, filename)){
56 if(Int_t(filename.find(mark)) < 0) continue;
57 if(!nbatch){
77dcc19a 58 if(fFM){
59 delete fFM;
60 fFM = new TFileMerger(kTRUE);
61 } else fFM = new TFileMerger(kTRUE);
199fb43b 62 fFM->OutputFile(Form("%s/%d_%s", gSystem->ExpandPathName("$PWD"), jbatch, mark));
63 }
64 fFM->AddFile(filename.c_str()); nbatch++;
65 if(nbatch==kBatch){
66 printf("MERGING BATCH %d [%d] ... \n", jbatch, nbatch);
67 fFM->Merge(); jbatch++;
68 nbatch=0;
69 }
70 }
71 if(nbatch){
72 printf("MERGING INCOMPLETE BATCH %d [%d] ... \n", jbatch, nbatch);
73 fFM->Merge(); jbatch++;
74 }
75 if(!jbatch){
76 delete fFM;
77 return;
78 }
79
80 new(fFM) TFileMerger(kTRUE);
81 fFM->OutputFile(Form("%s/%s", gSystem->ExpandPathName("$PWD"), mark));
82 for(Int_t ib=jbatch; ib--;){
83 fFM->AddFile(Form("%s/%d_%s", gSystem->ExpandPathName("$PWD"), ib, mark));
84 gSystem->Exec(Form("rm -f %s/%d_%s", gSystem->ExpandPathName("$PWD"), ib, mark));
85 }
86 fFM->Merge();
87 delete fFM;
88}
77dcc19a 89
90#endif