1 // This macro is used to simulate the HLT reconstruction
2 // usage: aliroot rec-hlt-trd.cxx("/data/run/raw.root") reconstruct local raw root file (you might add "alien://" to reconstruct remotely)
3 // or: aliroot rec-hlt-trd.cxx("/data/run/") reconstruct local raw ddls *1
4 // or copy into folder and aliroot rec-hlt-trd.cxx reconstruct raw.root in pwd
6 // (*1) here /data/run/ must contain subfolders rawX (be sure to have the last "/" !!)
8 #if !defined (__CINT__) || defined (__MAKECINT__)
17 #include "AliHLTSystem.h"
18 #include "AliHLTPluginBase.h"
20 #include "AliReconstruction.h"
21 #include "AliHLTDataTypes.h"
22 #include "AliHLTConfiguration.h"
24 #include <valgrind/callgrind.h>
29 #include "TGridResult.h"
31 #include "AliCDBManager.h"
32 #include "AliCDBEntry.h"
33 #include "AliTriggerConfiguration.h"
34 #include "AliTriggerClass.h"
35 #include "AliExternalTrackParam.h"
38 int rec_hlt_trd(const TString input ="raw.root", TString outPath=gSystem->pwd());
39 Int_t ExtractRunNumber(const TString str);
40 int main(int argc, char** argv)
42 if(argc==2) return rec_hlt_trd(argv[1]);
43 else if(argc==3) return rec_hlt_trd(argv[1],argv[2]);
44 else return rec_hlt_trd();
47 int rec_hlt_trd(const TString filename, TString outPath)
50 ///////////////////////////////////////////////////////////////////////////////////////////////////
52 // define the analysis chain to be run
55 // What chains should be run? (usually would be: TRD-OffEsdFile)
56 TString chains="TRD-CalibFile";
59 Bool_t bCosmics=kFALSE;
61 // look only in data containing TRD triggers?
62 Bool_t useOnlyTRDtrigger=kFALSE;
64 // Is the TRD full? (this is only important if ddl files should be read)
67 // If not use these SMs:
68 Int_t TRDmodules[18] = {0,1,7,8,9,10,17,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
70 // Use custom arguments for components? i.e.: not reading OCDB arguments
71 Bool_t customArgs=kTRUE;
74 Bool_t disableHLTflag=kFALSE;
76 ///////////////////////////////////////////////////////////////////////////////////////////////////
78 // init the HLT system
80 TString dataPath = outPath;
81 dataPath.Resize(dataPath.Last('/')+1);
82 if(!dataPath.Length()){
83 dataPath=gSystem->pwd();
85 outPath.Prepend(dataPath);
88 TString extInput = filename;
90 dataPath.Resize(dataPath.Last('/')+1);
91 if(!dataPath.Length()){
92 dataPath=gSystem->pwd();
94 extInput.Prepend(dataPath);
97 printf("File path %s\n",dataPath.Data());
98 printf("Processing file %s\n",extInput.Data());
99 printf("Output to %s\n",outPath.Data());
101 if(!gSystem->AccessPathName("galice.root")){
102 cerr << "please delete the galice.root or run at different place." << endl;
106 Bool_t bRealData=kFALSE;
107 if(filename.Contains(".root") && !filename.Contains("raw.root")){
109 printf("processing real data\n");
112 printf("processing simulated data\n");
115 if(filename.Contains("alien://") || bRealData){
116 TGrid::Connect("alien://");
119 if(filename.Contains(".root") && !TFile::Open(filename))return -1;
121 gSystem->mkdir(outPath.Data());
122 gSystem->ChangeDirectory(outPath.Data());
124 AliHLTSystem* gHLT=AliHLTPluginBase::GetInstance();
129 for(int i=0; i<18; i++)
132 std::sort((UInt_t*)TRDmodules, ((UInt_t*)TRDmodules) + 18);
133 for(int i=0; i<18; i++)
134 if(TRDmodules[i]>-1)usedModules++;
137 TString option="libAliHLTUtil.so libAliHLTTRD.so libAliHLTMUON.so libAliHLTGlobal.so libAliHLTTrigger.so loglevel=0x7f chains=";
139 TString afterTr, afterTrOff, afterCf;
141 for (int module = 0; module < usedModules; module++)
143 TString arg, publisher, cf, tr, trOff;
144 // raw data publisher components
145 publisher.Form("TRD-RP_%02d", TRDmodules[module]);
146 arg.Form("-minid %d -datatype 'DDL_RAW ' 'TRD ' -dataspec %i -verbose", TRDmodules[module]+1024, (int)TMath::Power(2,TRDmodules[module]));
147 AliHLTConfiguration pubConf(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
151 if(customArgs || disableHLTflag){
152 arg="output_percentage 700 -lowflux -experiment -tailcancellation -faststreamer -yPosMethod LUT";
157 cf.Form("TRD-CF_%02d", TRDmodules[module]);
158 AliHLTConfiguration cfConf(cf.Data(), "TRDClusterizer", publisher.Data(), arg.Data());
160 if (afterCf.Length()>0) afterCf+=" ";
165 if(customArgs || disableHLTflag){
166 arg="output_percentage 100 -lowflux -PIDmethod NN";
171 tr.Form("TRD-TR_%02d", TRDmodules[module]);
172 AliHLTConfiguration trConf(tr.Data(), "TRDTrackerV1", cf.Data(), arg.Data());
174 if (afterTr.Length()>0) afterTr+=" ";
177 // Offline Tracker (for debug purposes only)
179 if(customArgs || disableHLTflag){
180 arg="output_percentage 100 -lowflux -PIDmethod NN -highLevelOutput yes -emulateHLTTracks yes";
185 trOff.Form("TRD-TROFF_%02d", TRDmodules[module]);
186 AliHLTConfiguration trOffConf(trOff.Data(), "TRDOfflineTrackerV1", cf.Data(), arg.Data());
188 if (afterTrOff.Length()>0) afterTrOff+=" ";
193 // cluster histogramm
194 AliHLTConfiguration histoConf("TRD-ClHisto", "TRDClusterHisto", afterCf.Data(), "");
195 AliHLTConfiguration writerHistoConf( "TRD-ClHistoFile", "ROOTFileWriter", "TRD-ClHisto", "-directory hlt-trd-histo/ -datafile histo.root -concatenate-events -concatenate-blocks");
197 // calibration (you may use tr or trOff here)
198 AliHLTConfiguration calibConf("TRD-Calib", "TRDCalibration", afterTr.Data(), "-TrgStr hi -rejectTrgStr");
199 AliHLTConfiguration writerCalibConf( "TRD-CalibFile", "ROOTFileWriter", "TRD-Calib", "-directory hlt-trd-calib/ -datafile calib.root -concatenate-events -concatenate-blocks -write-all-events");
202 AliHLTConfiguration esdConf("TRD-Esd", "GlobalEsdConverter", afterTr.Data(), "-notree");
205 AliHLTConfiguration writerConf("TRD-EsdFile", "EsdCollector", "TRD-Esd", "-directory hlt-trd-esd/");
207 // root file writer (with esd friends) (you may use tr or trOff here)
208 AliHLTConfiguration writerOffConf("TRD-OffEsdFile", "TRDEsdWriter", afterTr.Data(), "-concatenate-events -concatenate-blocks");
211 ///////////////////////////////////////////////////////////////////////////////////////////////////
213 // Init CDBManager and trigger
215 AliCDBManager * man = AliCDBManager::Instance();
216 Int_t run = ExtractRunNumber(filename);
218 man->SetDefaultStorage("alien://folder=/alice/data/2009/OCDB");
220 man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
221 man->SetSpecificStorage("GRP/GRP/Data", Form("local://%s",dataPath.Data()));
222 //rec.SetSpecificStorage("GRP/GRP/Data", Form("local://%s",gSystem->pwd()));
228 AliExternalTrackParam::SetMostProbablePt(8.);
232 TString filestring = filename;
233 if(useOnlyTRDtrigger){
234 AliCDBEntry *grp_ctp = man->Get("GRP/CTP/Config");
235 AliTriggerConfiguration *trg_conf = (AliTriggerConfiguration *)grp_ctp->GetObject();
237 TObjArray trg_masks = trg_conf->GetClasses(); // Reference!!!
238 std::vector<unsigned char> triggerconfs;
239 for(Int_t iobj = 0; iobj < trg_masks.GetEntriesFast(); iobj++){
241 AliTriggerClass * trg_class = (AliTriggerClass*)trg_masks.UncheckedAt(iobj);
242 AliTriggerCluster * trg_clust = (AliTriggerCluster *)trg_class->GetCluster();
244 printf("ioj[%d]\n", iobj); trg_class->Print(0x0);
246 if(TString(trg_class->GetName()).Contains("TRD")){ // cosmic run 2009
247 triggerconfs.push_back(trg_class->GetMask());
252 printf("Number of Trigger Clusters including TRD: %d\n", (Int_t)triggerconfs.size());
253 for(std::vector<unsigned char>::iterator it = triggerconfs.begin(); it < triggerconfs.end(); it++)
254 printf("Trigger Mask %d for TRD: %d\n", itrg++, *it);
255 filestring += "?EventType=7";
256 char triggerbuf[256];
257 Int_t triggerval = 0;
258 for(std::vector<unsigned char>::iterator it = triggerconfs.begin(); it < triggerconfs.end(); it++)
260 sprintf(triggerbuf, "?Trigger=%d", triggerval);
261 filestring += triggerbuf; // This line does the trigger selection. It has to be uncommented if one wants to apply trigger selection
263 printf("Filename: %s\n", filestring.Data());
265 ///////////////////////////////////////////////////////////////////////////////////////////////////
267 // Init and run the reconstruction
269 AliReconstruction rec;
270 rec.SetInput(filestring.Data());
271 rec.SetRunVertexFinder(kFALSE);
272 rec.SetRunLocalReconstruction("HLT");
273 rec.SetRunTracking(":");
274 rec.SetLoadAlignFromCDB(0);
277 rec.SetRunGlobalQA(kFALSE);
278 rec.SetFillTriggerESD(kFALSE);
280 rec.SetOption("HLT", option);
286 Int_t ExtractRunNumber(const TString str){
287 TObjArray *ptoks = (TObjArray *)str.Tokenize("?");
288 TString path = ((TObjString *)ptoks->UncheckedAt(0))->String();
289 TObjArray *toks = (TObjArray *)path.Tokenize("/");
290 TString fname = ((TObjString *)(toks->UncheckedAt(toks->GetEntriesFast() - 1)))->String();
291 TString rstr = fname(2,9);