]>
Commit | Line | Data |
---|---|---|
9d0c6289 | 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 | |
bb90bd84 | 5 | // |
9d0c6289 | 6 | // (*1) here /data/run/ must contain subfolders rawX (be sure to have the last "/" !!) |
bb90bd84 | 7 | |
8 | #if !defined (__CINT__) || defined (__MAKECINT__) | |
9 | ||
10 | #include <iostream> | |
11 | #include <stdlib.h> | |
12 | #include <fstream> | |
dded75b4 | 13 | #include <algorithm> |
bb90bd84 | 14 | |
15 | #include "TString.h" | |
16 | #include "TMath.h" | |
17 | ||
18 | #include "AliHLTSystem.h" | |
19 | #include "AliHLTPluginBase.h" | |
20 | #include "AliLog.h" | |
21 | #include "AliReconstruction.h" | |
22 | #include "AliHLTDataTypes.h" | |
23 | #include "AliHLTConfiguration.h" | |
24 | ||
25 | #include <valgrind/callgrind.h> | |
26 | #include <sys/time.h> | |
27 | #include "TSystem.h" | |
9d0c6289 | 28 | #include "TFile.h" |
29 | #include "TGrid.h" | |
30 | #include "TGridResult.h" | |
bb90bd84 | 31 | |
9d0c6289 | 32 | #include "AliCDBManager.h" |
33 | #include "AliCDBEntry.h" | |
34 | #include "AliTriggerConfiguration.h" | |
35 | #include "AliTriggerClass.h" | |
36 | #include "AliExternalTrackParam.h" | |
bb90bd84 | 37 | #endif |
38 | ||
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) |
58 | TString chains="TRD-CalibFile"; | |
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 | ||
66 | // Is the TRD full? (this is only important if ddl files should be read) | |
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 | ||
9d0c6289 | 72 | // Use custom arguments for components? i.e.: not reading OCDB arguments |
73 | Bool_t customArgs=kTRUE; | |
74 | ||
75 | // Disable HLT flag? | |
76 | Bool_t disableHLTflag=kFALSE; | |
bb90bd84 | 77 | |
78 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
79 | // | |
9d0c6289 | 80 | // init the HLT system |
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 | ||
126 | AliHLTSystem* gHLT=AliHLTPluginBase::GetInstance(); | |
127 | ||
bb90bd84 | 128 | Int_t usedModules=0; |
129 | if(fullTRD){ | |
130 | usedModules = 18; | |
131 | for(int i=0; i<18; i++) | |
132 | TRDmodules[i]=i; | |
133 | }else{ | |
dded75b4 | 134 | #if !defined (__CINT__) || defined (__MAKECINT__) |
9d0c6289 | 135 | std::sort((UInt_t*)TRDmodules, ((UInt_t*)TRDmodules) + 18); |
dded75b4 | 136 | #endif |
bb90bd84 | 137 | for(int i=0; i<18; i++) |
9d0c6289 | 138 | if(TRDmodules[i]>-1)usedModules++; |
bb90bd84 | 139 | } |
140 | ||
9d0c6289 | 141 | TString option="libAliHLTUtil.so libAliHLTTRD.so libAliHLTMUON.so libAliHLTGlobal.so libAliHLTTrigger.so loglevel=0x7f chains="; |
bb90bd84 | 142 | option+=chains; |
9d0c6289 | 143 | TString afterTr, afterTrOff, afterCf; |
bb90bd84 | 144 | |
145 | for (int module = 0; module < usedModules; module++) | |
146 | { | |
147 | TString arg, publisher, cf, tr, trOff; | |
148 | // raw data publisher components | |
9d0c6289 | 149 | publisher.Form("TRD-RP_%02d", TRDmodules[module]); |
150 | arg.Form("-minid %d -datatype 'DDL_RAW ' 'TRD ' -dataspec %i -verbose", TRDmodules[module]+1024, (int)TMath::Power(2,TRDmodules[module])); | |
bb90bd84 | 151 | AliHLTConfiguration pubConf(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data()); |
152 | ||
153 | // Clusterizer | |
9d0c6289 | 154 | arg = ""; |
155 | if(customArgs || disableHLTflag){ | |
156 | arg="output_percentage 700 -lowflux -experiment -tailcancellation -faststreamer -yPosMethod LUT"; | |
157 | if(disableHLTflag) | |
158 | arg+=" -HLTflag no"; | |
159 | } | |
160 | ||
161 | cf.Form("TRD-CF_%02d", TRDmodules[module]); | |
162 | AliHLTConfiguration cfConf(cf.Data(), "TRDClusterizer", publisher.Data(), arg.Data()); | |
163 | ||
164 | if (afterCf.Length()>0) afterCf+=" "; | |
165 | afterCf+=cf; | |
bb90bd84 | 166 | |
167 | // Tracker | |
9d0c6289 | 168 | arg=""; |
169 | if(customArgs || disableHLTflag){ | |
170 | arg="output_percentage 100 -lowflux -PIDmethod NN"; | |
171 | if(disableHLTflag) | |
172 | arg+=" -HLTflag no"; | |
173 | } | |
174 | ||
175 | tr.Form("TRD-TR_%02d", TRDmodules[module]); | |
bb90bd84 | 176 | AliHLTConfiguration trConf(tr.Data(), "TRDTrackerV1", cf.Data(), arg.Data()); |
177 | ||
9d0c6289 | 178 | if (afterTr.Length()>0) afterTr+=" "; |
179 | afterTr+=tr; | |
180 | ||
181 | // Offline Tracker (for debug purposes only) | |
182 | arg=""; | |
183 | if(customArgs || disableHLTflag){ | |
184 | arg="output_percentage 100 -lowflux -PIDmethod NN -highLevelOutput yes -emulateHLTTracks yes"; | |
185 | if(disableHLTflag) | |
186 | arg+=" -HLTflag no"; | |
187 | } | |
bb90bd84 | 188 | |
9d0c6289 | 189 | trOff.Form("TRD-TROFF_%02d", TRDmodules[module]); |
bb90bd84 | 190 | AliHLTConfiguration trOffConf(trOff.Data(), "TRDOfflineTrackerV1", cf.Data(), arg.Data()); |
191 | ||
9d0c6289 | 192 | if (afterTrOff.Length()>0) afterTrOff+=" "; |
193 | afterTrOff+=trOff; | |
bb90bd84 | 194 | |
195 | } | |
196 | ||
9d0c6289 | 197 | // cluster histogramm |
198 | AliHLTConfiguration histoConf("TRD-ClHisto", "TRDClusterHisto", afterCf.Data(), ""); | |
199 | AliHLTConfiguration writerHistoConf( "TRD-ClHistoFile", "ROOTFileWriter", "TRD-ClHisto", "-directory hlt-trd-histo/ -datafile histo.root -concatenate-events -concatenate-blocks"); | |
200 | ||
201 | // calibration (you may use tr or trOff here) | |
202 | AliHLTConfiguration calibConf("TRD-Calib", "TRDCalibration", afterTr.Data(), "-TrgStr hi -rejectTrgStr"); | |
203 | AliHLTConfiguration writerCalibConf( "TRD-CalibFile", "ROOTFileWriter", "TRD-Calib", "-directory hlt-trd-calib/ -datafile calib.root -concatenate-events -concatenate-blocks -write-all-events"); | |
bb90bd84 | 204 | |
205 | // esd converter | |
9d0c6289 | 206 | AliHLTConfiguration esdConf("TRD-Esd", "GlobalEsdConverter", afterTr.Data(), "-notree"); |
bb90bd84 | 207 | |
208 | // root file writer | |
209 | AliHLTConfiguration writerConf("TRD-EsdFile", "EsdCollector", "TRD-Esd", "-directory hlt-trd-esd/"); | |
210 | ||
9d0c6289 | 211 | // root file writer (with esd friends) (you may use tr or trOff here) |
212 | AliHLTConfiguration writerOffConf("TRD-OffEsdFile", "TRDEsdWriter", afterTr.Data(), "-concatenate-events -concatenate-blocks"); | |
213 | ||
214 | ||
215 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
216 | // | |
217 | // Init CDBManager and trigger | |
218 | // | |
219 | AliCDBManager * man = AliCDBManager::Instance(); | |
220 | Int_t run = ExtractRunNumber(filename); | |
221 | if(bRealData){ | |
222 | man->SetDefaultStorage("alien://folder=/alice/data/2009/OCDB"); | |
223 | }else{ | |
224 | man->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); | |
225 | man->SetSpecificStorage("GRP/GRP/Data", Form("local://%s",dataPath.Data())); | |
226 | //rec.SetSpecificStorage("GRP/GRP/Data", Form("local://%s",gSystem->pwd())); | |
227 | } | |
228 | man->SetRun(run); | |
229 | ||
230 | if(bCosmics){ | |
231 | // no magnetic field | |
232 | AliExternalTrackParam::SetMostProbablePt(8.); | |
233 | } | |
234 | ||
235 | // Find TRD triggers | |
236 | TString filestring = filename; | |
237 | if(useOnlyTRDtrigger){ | |
238 | AliCDBEntry *grp_ctp = man->Get("GRP/CTP/Config"); | |
239 | AliTriggerConfiguration *trg_conf = (AliTriggerConfiguration *)grp_ctp->GetObject(); | |
240 | trg_conf->Print(); | |
241 | TObjArray trg_masks = trg_conf->GetClasses(); // Reference!!! | |
242 | std::vector<unsigned char> triggerconfs; | |
243 | for(Int_t iobj = 0; iobj < trg_masks.GetEntriesFast(); iobj++){ | |
244 | ||
245 | AliTriggerClass * trg_class = (AliTriggerClass*)trg_masks.UncheckedAt(iobj); | |
246 | AliTriggerCluster * trg_clust = (AliTriggerCluster *)trg_class->GetCluster(); | |
247 | ||
248 | printf("ioj[%d]\n", iobj); trg_class->Print(0x0); | |
249 | ||
250 | if(TString(trg_class->GetName()).Contains("TRD")){ // cosmic run 2009 | |
251 | triggerconfs.push_back(trg_class->GetMask()); | |
252 | } | |
253 | } | |
254 | ||
255 | Int_t itrg = 0; | |
256 | printf("Number of Trigger Clusters including TRD: %d\n", (Int_t)triggerconfs.size()); | |
257 | for(std::vector<unsigned char>::iterator it = triggerconfs.begin(); it < triggerconfs.end(); it++) | |
258 | printf("Trigger Mask %d for TRD: %d\n", itrg++, *it); | |
259 | filestring += "?EventType=7"; | |
260 | char triggerbuf[256]; | |
261 | Int_t triggerval = 0; | |
262 | for(std::vector<unsigned char>::iterator it = triggerconfs.begin(); it < triggerconfs.end(); it++) | |
263 | triggerval += *it; | |
264 | sprintf(triggerbuf, "?Trigger=%d", triggerval); | |
265 | filestring += triggerbuf; // This line does the trigger selection. It has to be uncommented if one wants to apply trigger selection | |
266 | } | |
267 | printf("Filename: %s\n", filestring.Data()); | |
bb90bd84 | 268 | |
269 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
270 | // | |
271 | // Init and run the reconstruction | |
bb90bd84 | 272 | // |
273 | AliReconstruction rec; | |
9d0c6289 | 274 | rec.SetInput(filestring.Data()); |
bb90bd84 | 275 | rec.SetRunVertexFinder(kFALSE); |
276 | rec.SetRunLocalReconstruction("HLT"); | |
277 | rec.SetRunTracking(":"); | |
278 | rec.SetLoadAlignFromCDB(0); | |
279 | rec.SetFillESD(""); | |
280 | rec.SetRunQA(":"); | |
281 | rec.SetRunGlobalQA(kFALSE); | |
282 | rec.SetFillTriggerESD(kFALSE); | |
bb90bd84 | 283 | |
284 | rec.SetOption("HLT", option); | |
285 | rec.Run(); | |
9d0c6289 | 286 | |
287 | return 0; | |
288 | } | |
289 | ||
290 | Int_t ExtractRunNumber(const TString str){ | |
291 | TObjArray *ptoks = (TObjArray *)str.Tokenize("?"); | |
292 | TString path = ((TObjString *)ptoks->UncheckedAt(0))->String(); | |
293 | TObjArray *toks = (TObjArray *)path.Tokenize("/"); | |
294 | TString fname = ((TObjString *)(toks->UncheckedAt(toks->GetEntriesFast() - 1)))->String(); | |
295 | TString rstr = fname(2,9); | |
296 | return rstr.Atoi(); | |
bb90bd84 | 297 | } |