-Added base Calo QA class.
[u/mrichter/AliRoot.git] / PWG1 / TRD / macros / helper.C
CommitLineData
1ee39b3a 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"
8#include <fstream>
9#endif
10
11#ifndef HELPER_C
12#define HELPER_C
13
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){
22 for(Int_t itask = 0; itask < NTRDQATASKS; itask++) SETBITT(fSteerTask, itask);
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;
28 SETBITT(fSteerTask, itask); SETBITT(fSteerTask, kInfoGen);
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
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, kPIDRefMaker)) SETBITT(fSteerTask, kCheckPID);
42
43 return fSteerTask;
44}
45
46//______________________________________________________
47void mergeProd(const Char_t *mark, const Char_t *files, const Int_t kBatch = 20)
48{
49 TFileMerger *fFM = 0x0;
50 Bool_t kSVN = kFALSE;
51
52 Int_t jbatch = 0, nbatch = 0;
f0cc7f57 53 std::string filename;
54 std::ifstream file(files);
1ee39b3a 55 while(getline(file, filename)){
56 if(Int_t(filename.find(mark)) < 0) continue;
57 if(!nbatch){
58 if(fFM){
59 delete fFM;
60 fFM = new TFileMerger(kTRUE);
61 } else fFM = new TFileMerger(kTRUE);
62 fFM->OutputFile(Form("%s/%d_%s", gSystem->ExpandPathName("$PWD"), jbatch, mark));
63 }
64 if(!kSVN){ // download SVN info for trending
65 string base=filename.substr(0, filename.find_last_of('/'));
66 if(gSystem->Exec(Form("cp -v %s/svnInfo.log .", base.c_str())) == 0) kSVN=kTRUE;
67 }
68 fFM->AddFile(filename.c_str()); nbatch++;
69 if(nbatch==kBatch){
70 printf("MERGING BATCH %d [%d] ... \n", jbatch, nbatch);
71 fFM->Merge(); jbatch++;
72 nbatch=0;
73 }
74 }
75 if(nbatch){
76 printf("MERGING INCOMPLETE BATCH %d [%d] ... \n", jbatch, nbatch);
77 fFM->Merge(); jbatch++;
78 }
79 if(!jbatch){
80 delete fFM;
81 return;
82 }
83
84 new(fFM) TFileMerger(kTRUE);
85 fFM->OutputFile(Form("%s/%s", gSystem->ExpandPathName("$PWD"), mark));
86 for(Int_t ib=jbatch; ib--;){
87 fFM->AddFile(Form("%s/%d_%s", gSystem->ExpandPathName("$PWD"), ib, mark));
88 gSystem->Exec(Form("rm -f %s/%d_%s", gSystem->ExpandPathName("$PWD"), ib, mark));
89 }
90 fFM->Merge();
91 delete fFM;
92}
93
94#endif