1 // This macro is used to simulate the HLT::TRD 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 copy into folder and aliroot rec-hlt-trd.cxx reconstruct raw.root in pwd
5 // (*1) here /data/run/ must contain subfolders rawX (be sure to have the last "/" !!)
7 #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 #include "readCDBentry.h"
40 int rec_hlt_trd(const TString input ="raw.root", TString outPath=gSystem->pwd());
41 Int_t ExtractRunNumber(const TString str);
42 int main(int argc, char** argv)
44 if(argc==2) return rec_hlt_trd(argv[1]);
45 else if(argc==3) return rec_hlt_trd(argv[1],argv[2]);
46 else return rec_hlt_trd();
49 int rec_hlt_trd(const TString filename, TString outPath)
52 ///////////////////////////////////////////////////////////////////////////////////////////////////
54 // define the analysis chain to be run
57 // What chains should be run? (usually would be: TRD-OffEsdFile)
58 TString chains="TRD-OffEsdFile";
61 Bool_t bCosmics=kFALSE;
63 // look only in data containing TRD triggers?
64 Bool_t useOnlyTRDtrigger=kFALSE;
67 Bool_t fullTRD=kFALSE;
69 // If not use these SMs:
70 Int_t TRDmodules[18] = {0,1,7,8,9,10,17,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
72 // Use custom arguments for components?
73 Bool_t customArgs=kFALSE;
76 Bool_t disableHLTflag=kFALSE;
78 ///////////////////////////////////////////////////////////////////////////////////////////////////
82 TString dataPath = outPath;
83 dataPath.Resize(dataPath.Last('/')+1);
84 if(!dataPath.Length()){
85 dataPath=gSystem->pwd();
87 outPath.Prepend(dataPath);
90 TString extInput = filename;
92 dataPath.Resize(dataPath.Last('/')+1);
93 if(!dataPath.Length()){
94 dataPath=gSystem->pwd();
96 extInput.Prepend(dataPath);
99 printf("File path %s\n",dataPath.Data());
100 printf("Processing file %s\n",extInput.Data());
101 printf("Output to %s\n",outPath.Data());
103 if(!gSystem->AccessPathName("galice.root")){
104 cerr << "please delete the galice.root or run at different place." << endl;
108 Bool_t bRealData=kFALSE;
109 if(filename.Contains(".root") && !filename.Contains("raw.root")){
111 printf("processing real data\n");
114 printf("processing simulated data\n");
117 if(filename.Contains("alien://") || bRealData){
118 TGrid::Connect("alien://");
121 if(filename.Contains(".root") && !TFile::Open(filename))return -1;
123 gSystem->mkdir(outPath.Data());
124 gSystem->ChangeDirectory(outPath.Data());
126 ///////////////////////////////////////////////////////////////////////////////////////////////////
128 // init the HLT system
130 AliHLTSystem* gHLT=AliHLTPluginBase::GetInstance();
135 for(int i=0; i<18; i++)
138 #if !defined (__CINT__) || defined (__MAKECINT__)
139 std::sort((UInt_t*)TRDmodules, ((UInt_t*)TRDmodules) + 18);
141 for(int i=0; i<18; i++)
142 if(TRDmodules[i]>-1)usedModules++;
145 TString option="libAliHLTUtil.so libAliHLTTRD.so libAliHLTMUON.so libAliHLTGlobal.so libAliHLTTrigger.so loglevel=0x7f chains=";
147 TString afterTr, afterTrOff, afterCf;
149 for (int module = 0; module < usedModules; module++)
151 TString arg, publisher, cf, tr, trOff;
152 // raw data publisher components
153 publisher.Form("TRD-RP_%02d", TRDmodules[module]);
154 arg.Form("-minid %d -datatype 'DDL_RAW ' 'TRD ' -dataspec %i -verbose", TRDmodules[module]+1024, (int)TMath::Power(2,TRDmodules[module]));
155 AliHLTConfiguration pubConf(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
159 if(customArgs || disableHLTflag){
160 arg = readCDBentry("HLT/ConfigTRD/ClusterizerComponent"); //output_percentage 100 -lowflux -experiment -tailcancellation -faststreamer -yPosMethod LUT
164 arg += " -HLTflag no";
167 cf.Form("TRD-CF_%02d", TRDmodules[module]);
168 AliHLTConfiguration cfConf(cf.Data(), "TRDClusterizer", publisher.Data(), arg.Data());
170 if (afterCf.Length()>0) afterCf+=" ";
175 if(customArgs || disableHLTflag){
176 arg = readCDBentry("HLT/ConfigTRD/TrackerV1Component"); //"output_percentage 100 -lowflux -NTimeBins 24";
180 arg += " -HLTflag no";
183 tr.Form("TRD-TR_%02d", TRDmodules[module]);
184 AliHLTConfiguration trConf(tr.Data(), "TRDTrackerV1", cf.Data(), arg.Data());
186 if (afterTr.Length()>0) afterTr+=" ";
189 // Offline Tracker (for debug purposes only)
190 arg = readCDBentry("HLT/ConfigTRD/TrackerV1Component"); //"output_percentage 100 -lowflux -NTimeBins 24";
192 arg += " -highLevelOutput yes -emulateHLToutput no";
196 trOff.Form("TRD-TROFF_%02d", TRDmodules[module]);
197 AliHLTConfiguration trOffConf(trOff.Data(), "TRDOfflineTrackerV1", cf.Data(), arg.Data());
199 if (afterTrOff.Length()>0) afterTrOff+=" ";
204 // cluster histogramm
205 AliHLTConfiguration histoConf("TRD-ClHisto", "TRDClusterHisto", afterCf.Data(), "");
206 AliHLTConfiguration writerHistoConf( "TRD-ClHistoFile", "ROOTFileWriter", "TRD-ClHisto", "-directory hlt-trd-histo/ -datafile histo.root -concatenate-events -concatenate-blocks");
208 // calibration (you may use tr or trOff here)
209 AliHLTConfiguration calibConf("TRD-Calib", "TRDCalibration", afterTr.Data(), "-TrgStr hi -rejectTrgStr");
210 AliHLTConfiguration writerCalibConf( "TRD-CalibFile", "ROOTFileWriter", "TRD-Calib", "-directory hlt-trd-calib/ -datafile calib.root -concatenate-events -concatenate-blocks -write-all-events");
213 AliHLTConfiguration esdConf("TRD-Esd", "GlobalEsdConverter", afterTr.Data(), "-notree");
216 AliHLTConfiguration writerConf("TRD-EsdFile", "EsdCollector", "TRD-Esd", "-directory hlt-trd-esd/");
218 // root file writer (with esd friends) (you may use tr or trOff here)
219 AliHLTConfiguration writerOffConf("TRD-OffEsdFile", "TRDEsdWriter", afterTr.Data(), "-concatenate-events -concatenate-blocks");
221 ///////////////////////////////////////////////////////////////////////////////////////////////////
223 // Init CDBManager and trigger
225 AliCDBManager * man = AliCDBManager::Instance();
228 man->SetDefaultStorage("alien://folder=/alice/data/2009/OCDB");
229 //man->SetDefaultStorage("alien://folder=/alice/data/2009/OCDB?cacheFold=/lustre/alice/local/alice/data/2009/OCDB");
230 //man->SetSpecificStorage("GRP/GRP/Data","alien://folder=/alice/data/2009/OCDB?cacheFold=/lustre/alice/local/alice/data/2009/OCDB");
231 man->SetSpecificStorage("HLT/*","local://$ALICE_ROOT/OCDB");
232 run = ExtractRunNumber(filename);
234 man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
235 man->SetSpecificStorage("GRP/GRP/Data", Form("local://%s",dataPath.Data()));
241 AliExternalTrackParam::SetMostProbablePt(8.);
245 TString filestring = filename;
246 if(useOnlyTRDtrigger){
247 AliCDBEntry *grp_ctp = man->Get("GRP/CTP/Config");
248 AliTriggerConfiguration *trg_conf = (AliTriggerConfiguration *)grp_ctp->GetObject();
250 TObjArray trg_masks = trg_conf->GetClasses(); // Reference!!!
251 std::vector<unsigned char> triggerconfs;
252 for(Int_t iobj = 0; iobj < trg_masks.GetEntriesFast(); iobj++){
254 AliTriggerClass * trg_class = (AliTriggerClass*)trg_masks.UncheckedAt(iobj);
255 AliTriggerCluster * trg_clust = (AliTriggerCluster *)trg_class->GetCluster();
257 printf("ioj[%d]\n", iobj); trg_class->Print(0x0);
260 // if(TString(trg_class->GetName()).Contains("TRD")){
261 // triggerconfs.push_back(trg_class->GetMask());
265 if(TString(trg_class->GetName()).Contains("CINT1B-ABCE-NOPF-ALL")){
266 triggerconfs.push_back(trg_class->GetMask());
272 printf("Number of Trigger Clusters including TRD: %d\n", (Int_t)triggerconfs.size());
273 for(std::vector<unsigned char>::iterator it = triggerconfs.begin(); it < triggerconfs.end(); it++)
274 printf("Trigger Mask %d for TRD: %d\n", itrg++, *it);
275 filestring += "?EventType=7";
276 char triggerbuf[256];
277 Int_t triggerval = 0;
278 for(std::vector<unsigned char>::iterator it = triggerconfs.begin(); it < triggerconfs.end(); it++)
280 sprintf(triggerbuf, "?Trigger=%d", triggerval);
281 filestring += triggerbuf; // This line does the trigger selection. It has to be uncommented if one wants to apply trigger selection
283 printf("Filename: %s\n", filestring.Data());
285 ///////////////////////////////////////////////////////////////////////////////////////////////////
287 // init and run the reconstruction
289 AliReconstruction rec;
290 rec.SetInput(filestring.Data());
291 rec.SetRunVertexFinder(kFALSE);
292 rec.SetRunLocalReconstruction("HLT");
293 rec.SetRunTracking(":");
296 rec.SetRunGlobalQA(kFALSE);
297 rec.SetFillTriggerESD(kFALSE);
299 rec.SetOption("HLT", option);
305 Int_t ExtractRunNumber(const TString str){
306 TObjArray *ptoks = (TObjArray *)str.Tokenize("?");
307 TString path = ((TObjString *)ptoks->UncheckedAt(0))->String();
308 TObjArray *toks = (TObjArray *)path.Tokenize("/");
309 TString fname = ((TObjString *)(toks->UncheckedAt(toks->GetEntriesFast() - 1)))->String();
310 TString rstr = fname(2,9);