]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/exa/sampleCalibrationProcessor.C
adding an example calibration component and corresponding macro
[u/mrichter/AliRoot.git] / HLT / exa / sampleCalibrationProcessor.C
1 // $Id$
2 /**
3  * @file sampleCalibrationProcessor.C
4  * @brief Run the SampleCalibration component (AliHLTSampleCalibrationComponent)
5  *
6  * <pre>
7  * Usage: aliroot -b -q -l \
8  *     sampleCalibrationProcessor.C'("file", "cdb", minEvent, maxEvent)'
9  *
10  * Examples:
11  *     sampleCalibrationProcessor.C'("alien:///alice/data/2009/.../....root")' 
12  *     sampleCalibrationProcessor.C'("raw.root", "local://$PWD", minEvent, MaxEvent)'
13  *
14  * Defaults
15  *     cdb="local://$ALICE_ROOT/OCDB"  -> take local OCDB
16  *     minEvent=-1   -> no lower event selection
17  *     maxEvent=-1   -> no upper event selection
18  *
19  * </pre>
20  *
21  * An HLT chain is set up with one publisher for raw data which the calibration
22  * component subscribes to. The output of the component is directed to a
23  * ROOTFileWriter producing the file 'calibdata.root'. Another FileWriter
24  * writes the data block designated for storage in the FXS. 
25  * The HLT chain is run in the context of AliReconstruction.
26  * 
27  * The input file can be a file on the grid, indicated by the tag
28  * 'alien://'.
29  * If either the file or the OCDB is taken from the GRID, the macros
30  * connects to the Grid in the beginning.
31  * Note: You need a valid GRID token, use 'alien-token-init' of your
32  * alien installation.
33  *
34  * This example uses the local OCDB as default, but other locations can
35  * be specified, like e.g. "raw://".
36  *
37  * @author Matthias.Richter@ift.uib.no
38  * @ingroup alihlt_tutorial
39  */
40 void sampleCalibrationProcessor(const char *filename,
41                   const char *cdbURI,
42                   int minEvent=-1,
43                   int maxEvent=-1)
44 {
45   // connect to the GRID if we use a file or OCDB from the GRID
46   TString struri=cdbURI;
47   TString strfile=filename;
48   if (struri.BeginsWith("raw://") ||
49       strfile.Contains("://") && !strfile.Contains("local://")) {
50     TGrid::Connect("alien");
51   }
52
53   // Set the CDB storage location
54   AliCDBManager * man = AliCDBManager::Instance();
55   man->SetDefaultStorage(cdbURI);
56   if (struri.BeginsWith("local://") && !gSystem->AccessPathName("GRP/GRP/Data")) {
57     // set specific storage for GRP entry according to the default simulation
58     man->SetSpecificStorage("GRP/GRP/Data", "local://$PWD");
59   } else if (struri.BeginsWith("local://") && !gSystem->AccessPathName("../GRP/GRP/Data")) {
60     // set specific storage for GRP entry according to the default simulation
61     man->SetSpecificStorage("GRP/GRP/Data", "local://$PWD/../");
62   }
63
64   // Reconstruction settings
65   AliReconstruction rec;
66
67   if (minEvent>=0 || maxEvent>minEvent) {
68     if (minEvent<0) minEvent=0;
69     if (maxEvent<minEvent) maxEvent=minEvent;
70     rec.SetEventRange(minEvent,maxEvent);
71   }
72
73   rec.SetRunReconstruction("HLT");
74
75   // QA options
76   rec.SetRunQA(":") ;
77
78   // AliReconstruction settings
79   rec.SetWriteESDfriend(kFALSE);
80   rec.SetInput(filename);
81
82   rec.SetRunPlaneEff(kFALSE);
83   rec.SetRunVertexFinder(kFALSE);
84
85   // switch off cleanESD
86   rec.SetCleanESD(kFALSE);
87
88   // setup the HLT chain
89   AliHLTSystem* pHLT=AliHLTPluginBase::GetInstance();
90   
91   // publisher for raw data
92   AliHLTConfiguration rawpub("rawpub", "AliRawReaderPublisher", "", "-minid 768 -maxid 983 -datatype 'DDL_RAW ' SMPL");
93
94   // the configuration of the calibration component
95   // send the produced object not more than once every 2 sec
96   AliHLTConfiguration smplcalib("smplcalib", "SampleCalibration", "rawpub", "-pushback-period=2");
97
98   // writer for data objects produced by the calibration component during
99   // ProcessCalibration, 
100   AliHLTConfiguration eventwriter("eventwriter", "ROOTFileWriter", "smplcalib", "-datafile calibdata.root -concatenate-events -overwrite -write-all-events");
101
102   // filter the output of the smplcalib component and forward only the blocks
103   // of type 'FXS_CAL ' designated for storage by the FXSSubscriber
104   AliHLTConfiguration fxsfilter("fxsfilter", "BlockFilter", "smplcalib", "-typeid 'FXS_CAL ' ");
105   // write the block, a file like 'EOR_*HLT:FXS_CAL' will be written containing the
106   // binary data block of the FXS header and the streamed object
107   AliHLTConfiguration fxswriter("fxswriter", "FileWriter", "fxsfilter", "-write-all-events");
108
109   rec.SetOption("HLT", "loglevel=0x7c ignore-hltout libAliHLTUtil.so libAliHLTSample.so chains=fxswriter,eventwriter");
110
111   AliLog::Flush();
112   rec.Run();
113
114 }
115
116 void sampleCalibrationProcessor(const char *filename,
117                   int minEvent=-1,
118                   int maxEvent=-1)
119 {
120   sampleCalibrationProcessor(filename, "local://$ALICE_ROOT/OCDB", minEvent, maxEvent);
121 }
122
123 void sampleCalibrationProcessor()
124 {
125   cout << "sampleCalibrationProcessor: Run AliRoot reconstruction locally" << endl;
126   cout << " Usage: aliroot -b -q -l \\" << endl;
127   cout << "     sampleCalibrationProcessor.C'(\"file\", \"cdb\", minEvent, maxEvent)'" << endl;
128   cout << "" << endl;
129   cout << " Examples:" << endl;
130   cout << "     sampleCalibrationProcessor.C'(\"alien:///alice/data/2009/.../....root\")' " << endl;
131   cout << "     sampleCalibrationProcessor.C'(\"raw.root\", \"local://$PWD\", minEvent, MaxEvent)'" << endl;
132   cout << "" << endl;
133   cout << " Defaults" << endl;
134   cout << "     cdb=\"local://$ALICE_ROOT/OCDB\"  -> take local OCDB " << endl;
135   cout << "     minEvent=-1   -> no lower event selection" << endl;
136   cout << "     maxEvent=-1   -> no upper event selection" << endl;
137 }