]>
Commit | Line | Data |
---|---|---|
b04a8120 | 1 | // This macro is used to simulate the HLT::TRD reconstruction |
9d0c6289 | 2 | // usage: aliroot rec-hlt-trd.cxx("/data/run/raw.root") reconstruct local raw root file (you might add "alien://" to reconstruct remotely) |
9d0c6289 | 3 | // or copy into folder and aliroot rec-hlt-trd.cxx reconstruct raw.root in pwd |
bb90bd84 | 4 | // |
9d0c6289 | 5 | // (*1) here /data/run/ must contain subfolders rawX (be sure to have the last "/" !!) |
bb90bd84 | 6 | |
7 | #if !defined (__CINT__) || defined (__MAKECINT__) | |
8 | ||
9 | #include <iostream> | |
10 | #include <stdlib.h> | |
11 | #include <fstream> | |
dded75b4 | 12 | #include <algorithm> |
bb90bd84 | 13 | |
14 | #include "TString.h" | |
15 | #include "TMath.h" | |
16 | ||
17 | #include "AliHLTSystem.h" | |
18 | #include "AliHLTPluginBase.h" | |
19 | #include "AliLog.h" | |
20 | #include "AliReconstruction.h" | |
21 | #include "AliHLTDataTypes.h" | |
22 | #include "AliHLTConfiguration.h" | |
23 | ||
24 | #include <valgrind/callgrind.h> | |
25 | #include <sys/time.h> | |
26 | #include "TSystem.h" | |
9d0c6289 | 27 | #include "TFile.h" |
28 | #include "TGrid.h" | |
29 | #include "TGridResult.h" | |
bb90bd84 | 30 | |
9d0c6289 | 31 | #include "AliCDBManager.h" |
32 | #include "AliCDBEntry.h" | |
33 | #include "AliTriggerConfiguration.h" | |
34 | #include "AliTriggerClass.h" | |
35 | #include "AliExternalTrackParam.h" | |
bb90bd84 | 36 | #endif |
37 | ||
b04a8120 | 38 | #include "readCDBentry.h" |
dded75b4 | 39 | |
9d0c6289 | 40 | int rec_hlt_trd(const TString input ="raw.root", TString outPath=gSystem->pwd()); |
41 | Int_t ExtractRunNumber(const TString str); | |
bb90bd84 | 42 | int main(int argc, char** argv) |
43 | { | |
9d0c6289 | 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(); | |
bb90bd84 | 47 | } |
48 | ||
9d0c6289 | 49 | int rec_hlt_trd(const TString filename, TString outPath) |
bb90bd84 | 50 | { |
51 | ||
52 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
53 | // | |
54 | // define the analysis chain to be run | |
55 | // | |
56 | ||
9d0c6289 | 57 | // What chains should be run? (usually would be: TRD-OffEsdFile) |
b04a8120 | 58 | TString chains="TRD-OffEsdFile"; |
9d0c6289 | 59 | |
60 | // cosmics or not | |
61 | Bool_t bCosmics=kFALSE; | |
62 | ||
63 | // look only in data containing TRD triggers? | |
64 | Bool_t useOnlyTRDtrigger=kFALSE; | |
65 | ||
dcddf77b | 66 | // Is the TRD full? |
dded75b4 | 67 | Bool_t fullTRD=kFALSE; |
bb90bd84 | 68 | |
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}; | |
71 | ||
7fdbc17b | 72 | // Use custom arguments for components? |
b04a8120 | 73 | Bool_t customArgs=kFALSE; |
9d0c6289 | 74 | |
75 | // Disable HLT flag? | |
76 | Bool_t disableHLTflag=kFALSE; | |
bb90bd84 | 77 | |
78 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
79 | // | |
579d2e0a | 80 | // set paths |
bb90bd84 | 81 | // |
9d0c6289 | 82 | TString dataPath = outPath; |
83 | dataPath.Resize(dataPath.Last('/')+1); | |
84 | if(!dataPath.Length()){ | |
85 | dataPath=gSystem->pwd(); | |
86 | dataPath+="/"; | |
87 | outPath.Prepend(dataPath); | |
88 | } | |
89 | ||
90 | TString extInput = filename; | |
91 | dataPath = filename; | |
92 | dataPath.Resize(dataPath.Last('/')+1); | |
93 | if(!dataPath.Length()){ | |
94 | dataPath=gSystem->pwd(); | |
95 | dataPath+="/"; | |
96 | extInput.Prepend(dataPath); | |
97 | } | |
98 | ||
99 | printf("File path %s\n",dataPath.Data()); | |
100 | printf("Processing file %s\n",extInput.Data()); | |
101 | printf("Output to %s\n",outPath.Data()); | |
102 | ||
bb90bd84 | 103 | if(!gSystem->AccessPathName("galice.root")){ |
104 | cerr << "please delete the galice.root or run at different place." << endl; | |
9d0c6289 | 105 | return -1; |
bb90bd84 | 106 | } |
107 | ||
9d0c6289 | 108 | Bool_t bRealData=kFALSE; |
109 | if(filename.Contains(".root") && !filename.Contains("raw.root")){ | |
110 | bRealData = kTRUE; | |
111 | printf("processing real data\n"); | |
112 | }else{ | |
113 | bRealData = kFALSE; | |
114 | printf("processing simulated data\n"); | |
115 | } | |
116 | ||
117 | if(filename.Contains("alien://") || bRealData){ | |
118 | TGrid::Connect("alien://"); | |
119 | } | |
120 | ||
121 | if(filename.Contains(".root") && !TFile::Open(filename))return -1; | |
bb90bd84 | 122 | |
9d0c6289 | 123 | gSystem->mkdir(outPath.Data()); |
124 | gSystem->ChangeDirectory(outPath.Data()); | |
125 | ||
579d2e0a | 126 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
127 | // | |
128 | // init the HLT system | |
129 | // | |
9d0c6289 | 130 | AliHLTSystem* gHLT=AliHLTPluginBase::GetInstance(); |
131 | ||
bb90bd84 | 132 | Int_t usedModules=0; |
133 | if(fullTRD){ | |
134 | usedModules = 18; | |
135 | for(int i=0; i<18; i++) | |
136 | TRDmodules[i]=i; | |
137 | }else{ | |
dded75b4 | 138 | #if !defined (__CINT__) || defined (__MAKECINT__) |
9d0c6289 | 139 | std::sort((UInt_t*)TRDmodules, ((UInt_t*)TRDmodules) + 18); |
dded75b4 | 140 | #endif |
bb90bd84 | 141 | for(int i=0; i<18; i++) |
9d0c6289 | 142 | if(TRDmodules[i]>-1)usedModules++; |
bb90bd84 | 143 | } |
144 | ||
9d0c6289 | 145 | TString option="libAliHLTUtil.so libAliHLTTRD.so libAliHLTMUON.so libAliHLTGlobal.so libAliHLTTrigger.so loglevel=0x7f chains="; |
bb90bd84 | 146 | option+=chains; |
9d0c6289 | 147 | TString afterTr, afterTrOff, afterCf; |
bb90bd84 | 148 | |
149 | for (int module = 0; module < usedModules; module++) | |
150 | { | |
151 | TString arg, publisher, cf, tr, trOff; | |
152 | // raw data publisher components | |
9d0c6289 | 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])); | |
bb90bd84 | 155 | AliHLTConfiguration pubConf(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data()); |
156 | ||
157 | // Clusterizer | |
9d0c6289 | 158 | arg = ""; |
159 | if(customArgs || disableHLTflag){ | |
b04a8120 | 160 | arg = readCDBentry("HLT/ConfigTRD/ClusterizerComponent"); //output_percentage 100 -lowflux -experiment -tailcancellation -faststreamer -yPosMethod LUT |
7fdbc17b | 161 | if(customArgs) |
162 | arg += ""; | |
9d0c6289 | 163 | if(disableHLTflag) |
b04a8120 | 164 | arg += " -HLTflag no"; |
9d0c6289 | 165 | } |
166 | ||
167 | cf.Form("TRD-CF_%02d", TRDmodules[module]); | |
168 | AliHLTConfiguration cfConf(cf.Data(), "TRDClusterizer", publisher.Data(), arg.Data()); | |
169 | ||
170 | if (afterCf.Length()>0) afterCf+=" "; | |
171 | afterCf+=cf; | |
bb90bd84 | 172 | |
173 | // Tracker | |
9d0c6289 | 174 | arg=""; |
175 | if(customArgs || disableHLTflag){ | |
b04a8120 | 176 | arg = readCDBentry("HLT/ConfigTRD/TrackerV1Component"); //"output_percentage 100 -lowflux -NTimeBins 24"; |
7fdbc17b | 177 | if(customArgs) |
178 | arg += ""; | |
9d0c6289 | 179 | if(disableHLTflag) |
b04a8120 | 180 | arg += " -HLTflag no"; |
9d0c6289 | 181 | } |
182 | ||
183 | tr.Form("TRD-TR_%02d", TRDmodules[module]); | |
bb90bd84 | 184 | AliHLTConfiguration trConf(tr.Data(), "TRDTrackerV1", cf.Data(), arg.Data()); |
185 | ||
9d0c6289 | 186 | if (afterTr.Length()>0) afterTr+=" "; |
187 | afterTr+=tr; | |
188 | ||
189 | // Offline Tracker (for debug purposes only) | |
b04a8120 | 190 | arg = readCDBentry("HLT/ConfigTRD/TrackerV1Component"); //"output_percentage 100 -lowflux -NTimeBins 24"; |
7fdbc17b | 191 | if(customArgs) |
192 | arg += " -highLevelOutput yes -emulateHLToutput no"; | |
b04a8120 | 193 | if(disableHLTflag) |
194 | arg+=" -HLTflag no"; | |
bb90bd84 | 195 | |
9d0c6289 | 196 | trOff.Form("TRD-TROFF_%02d", TRDmodules[module]); |
bb90bd84 | 197 | AliHLTConfiguration trOffConf(trOff.Data(), "TRDOfflineTrackerV1", cf.Data(), arg.Data()); |
198 | ||
9d0c6289 | 199 | if (afterTrOff.Length()>0) afterTrOff+=" "; |
200 | afterTrOff+=trOff; | |
bb90bd84 | 201 | |
202 | } | |
203 | ||
9d0c6289 | 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"); | |
207 | ||
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"); | |
bb90bd84 | 211 | |
212 | // esd converter | |
9d0c6289 | 213 | AliHLTConfiguration esdConf("TRD-Esd", "GlobalEsdConverter", afterTr.Data(), "-notree"); |
bb90bd84 | 214 | |
215 | // root file writer | |
216 | AliHLTConfiguration writerConf("TRD-EsdFile", "EsdCollector", "TRD-Esd", "-directory hlt-trd-esd/"); | |
217 | ||
9d0c6289 | 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"); | |
220 | ||
9d0c6289 | 221 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
222 | // | |
223 | // Init CDBManager and trigger | |
224 | // | |
225 | AliCDBManager * man = AliCDBManager::Instance(); | |
579d2e0a | 226 | Int_t run = 0; |
9d0c6289 | 227 | if(bRealData){ |
228 | man->SetDefaultStorage("alien://folder=/alice/data/2009/OCDB"); | |
7fdbc17b | 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"); | |
dcddf77b | 231 | man->SetSpecificStorage("HLT/*","local://$ALICE_ROOT/OCDB"); |
579d2e0a | 232 | run = ExtractRunNumber(filename); |
9d0c6289 | 233 | }else{ |
234 | man->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); | |
235 | man->SetSpecificStorage("GRP/GRP/Data", Form("local://%s",dataPath.Data())); | |
9d0c6289 | 236 | } |
237 | man->SetRun(run); | |
7fdbc17b | 238 | |
9d0c6289 | 239 | if(bCosmics){ |
240 | // no magnetic field | |
241 | AliExternalTrackParam::SetMostProbablePt(8.); | |
242 | } | |
243 | ||
244 | // Find TRD triggers | |
245 | TString filestring = filename; | |
246 | if(useOnlyTRDtrigger){ | |
247 | AliCDBEntry *grp_ctp = man->Get("GRP/CTP/Config"); | |
248 | AliTriggerConfiguration *trg_conf = (AliTriggerConfiguration *)grp_ctp->GetObject(); | |
249 | trg_conf->Print(); | |
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++){ | |
253 | ||
254 | AliTriggerClass * trg_class = (AliTriggerClass*)trg_masks.UncheckedAt(iobj); | |
255 | AliTriggerCluster * trg_clust = (AliTriggerCluster *)trg_class->GetCluster(); | |
256 | ||
257 | printf("ioj[%d]\n", iobj); trg_class->Print(0x0); | |
7fdbc17b | 258 | |
579d2e0a | 259 | // cosmic run 2009 |
260 | // if(TString(trg_class->GetName()).Contains("TRD")){ | |
261 | // triggerconfs.push_back(trg_class->GetMask()); | |
262 | // } | |
263 | ||
264 | // pp run 2009 | |
265 | if(TString(trg_class->GetName()).Contains("CINT1B-ABCE-NOPF-ALL")){ | |
7fdbc17b | 266 | triggerconfs.push_back(trg_class->GetMask()); |
9d0c6289 | 267 | } |
579d2e0a | 268 | |
9d0c6289 | 269 | } |
270 | ||
271 | Int_t itrg = 0; | |
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++) | |
279 | triggerval += *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 | |
282 | } | |
283 | printf("Filename: %s\n", filestring.Data()); | |
bb90bd84 | 284 | |
285 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
286 | // | |
579d2e0a | 287 | // init and run the reconstruction |
bb90bd84 | 288 | // |
289 | AliReconstruction rec; | |
9d0c6289 | 290 | rec.SetInput(filestring.Data()); |
bb90bd84 | 291 | rec.SetRunVertexFinder(kFALSE); |
292 | rec.SetRunLocalReconstruction("HLT"); | |
293 | rec.SetRunTracking(":"); | |
bb90bd84 | 294 | rec.SetFillESD(""); |
7fdbc17b | 295 | rec.SetRunQA(":"); |
bb90bd84 | 296 | rec.SetRunGlobalQA(kFALSE); |
297 | rec.SetFillTriggerESD(kFALSE); | |
bb90bd84 | 298 | |
299 | rec.SetOption("HLT", option); | |
300 | rec.Run(); | |
9d0c6289 | 301 | |
302 | return 0; | |
303 | } | |
304 | ||
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); | |
311 | return rstr.Atoi(); | |
bb90bd84 | 312 | } |