]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/MUON/OfflineInterface/AliHLTMUONAgent.cxx
409602e3b3ce6d6541dab6a4c38250da7cd1f481
[u/mrichter/AliRoot.git] / HLT / MUON / OfflineInterface / AliHLTMUONAgent.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 ///
19 /// @file   AliHLTMUONAgent.cxx
20 /// @author Artur Szostak <artursz@iafrica.com>
21 /// @date   28 May 2007
22 /// @brief  Implementation of the AliHLTMUONAgent class.
23 ///
24
25 #include "AliHLTMUONAgent.h"
26 #include "AliHLTMUONConstants.h"
27 #include "AliHLTMUONRecHitsSource.h"
28 #include "AliHLTMUONTriggerRecordsSource.h"
29 #include "AliHLTMUONDigitPublisherComponent.h"
30 #include "AliHLTMUONRootifierComponent.h"
31 #include "AliHLTMUONHitReconstructorComponent.h"
32 #include "AliHLTMUONTriggerReconstructorComponent.h"
33 #include "AliHLTMUONMansoTrackerFSMComponent.h"
34 #include "AliHLTMUONDecisionComponent.h"
35 #include "AliHLTMUONESDMaker.h"
36 #include "AliHLTMUONEmptyEventFilterComponent.h"
37 #include "AliHLTMUONDataCheckerComponent.h"
38 #include "AliRawReader.h"
39 #include "AliRunLoader.h"
40 #include "TSystem.h"
41 #include "TString.h"
42
43 // The single global instance of the dimuon HLT agent.
44 AliHLTMUONAgent AliHLTMUONAgent::fgkInstance;
45
46 ClassImp(AliHLTMUONAgent);
47
48
49 AliHLTMUONAgent::AliHLTMUONAgent() : AliHLTModuleAgent("MUON")
50 {
51         ///
52         /// Default constructor.
53         ///
54 }
55
56 AliHLTMUONAgent::~AliHLTMUONAgent()
57 {
58         ///
59         /// Default destructor.
60         ///
61 }
62
63 const char* AliHLTMUONAgent::GetReconstructionChains(AliRawReader* rawReader,
64                                                      AliRunLoader* runloader
65         ) const
66 {
67         ///
68         /// Inherited from AliHLTModuleAgent.
69         /// Returns the top processing chain configurations for local event
70         /// reconstruction.
71         /// @param rawReader  [in] AliRoot rawreader instance.
72         /// @param runloader  [in] AliRoot runloader
73         /// @return string containing the top configurations separated by blanks.
74         ///
75         /// If rawReader is not NULL then the standard dHLT chain is run taking
76         /// data from raw DDL data. Otherwise runloader is checked and if it is
77         /// not NULL then a dHLT chain is run with input data from digits.
78         
79         if (rawReader != NULL)
80         {
81                 // Check if there is any data from the tracker and trigger.
82                 bool dataFromTracker = false;
83                 bool dataFromTrigger = false;
84                 rawReader->Select("MUONTRK", 0, 19);
85                 for (Int_t i = 0; i < 20; i++)
86                 {
87                         if (rawReader->ReadHeader()) dataFromTracker = true;
88                 }
89                 rawReader->Select("MUONTRG", 0, 1);
90                 for (Int_t i = 0; i < 2; i++)
91                 {
92                         if (rawReader->ReadHeader()) dataFromTrigger = true;
93                 }
94                 rawReader->RewindEvents();
95                 
96                 // If raw data was found for our detector then select the
97                 // appropriate chain.
98                 if (dataFromTracker and dataFromTrigger)
99                         return "dHLT-sim-fromRaw";
100         }
101         
102         if (runloader != NULL)
103         {
104                 if (runloader->GetLoader("MUONLoader") != NULL)
105                         return "dHLT-sim";
106         }
107         
108         return "";
109 }
110
111 const char* AliHLTMUONAgent::GetRequiredComponentLibraries() const
112 {
113         ///
114         /// Inherited from AliHLTModuleAgent.
115         /// Returns a list of libraries which the configurations registered by
116         /// this module agent depend on.
117         /// @return list of component libraries as a blank-separated string.
118         ///
119         
120         // List of libraries that we depend on.
121         static const char* libs[] =
122         {
123                 "libCore.so",
124                 "libCint.so",
125                 "libGraf.so",
126                 "libRIO.so",
127                 "libNet.so",
128                 "libHist.so",
129                 "libMatrix.so",
130                 "libMathCore.so",
131                 "libMinuit.so",
132                 "libTree.so",
133                 "libGraf3d.so",
134                 "libGpad.so",
135                 "libPhysics.so",
136                 "libGui.so",
137                 "libProofPlayer.so",
138                 "libProof.so",
139                 "libThread.so",
140                 "libGeom.so",
141                 "libEG.so",
142                 "libTreePlayer.so",
143                 "libXMLIO.so",
144                 "libVMC.so",
145                 "libESD.so",
146                 "libCDB.so",
147                 "libSTEERBase.so",
148                 "libSTEER.so",
149                 "libGui.so",
150                 "libRAWDatasim.so",
151                 "libRAWDatarec.so",
152                 "libRAWDatabase.so",
153                 "libMUONcore.so",
154                 "libMUONraw.so",
155                 "libMUONbase.so",
156                 "libMUONgeometry.so",
157                 "libMUONmapping.so",
158                 "libMUONcalib.so",
159                 "libMUONsim.so",
160                 "libMUONtrigger.so",
161                 "libMUONevaluation.so",
162                 "libMUONrec.so",
163                 "libHLTbase.so",
164                 "libAliHLTUtil.so",
165                 NULL
166         };
167         
168         // First check if the library is not already loaded. If it is then we have
169         // no reason to declare it as needed, so that we do not load it again.
170         static TString result;
171         for (const char** lib = libs; *lib != NULL; lib++)
172         {
173                 const char* list = gSystem->GetLibraries(*lib, "", kFALSE);
174                 if (list == NULL) continue;
175                 // Check if not found, i.e. result was an empty string.
176                 // If so then add the library to the required list.
177                 if (list[0] == '\0')
178                 {
179                         result += *lib;
180                         result += " ";
181                 }
182         }
183         return result.Data();
184 }
185
186
187 int AliHLTMUONAgent::CreateConfigurations(
188                 AliHLTConfigurationHandler* handler,
189                 AliRawReader* rawReader,
190                 AliRunLoader* runloader
191         ) const
192 {
193         /// Register all processing configurations belonging to the dimuon HLT
194         /// library with the AliHLTConfigurationHandler.
195         /// @param handler      the configuration handler
196         /// @param rawReader  [in] AliRoot rawreader instance.
197         /// @param runloader    AliRoot runloader
198         /// @return Zero on success and error code if failed.
199         ///
200         /// Chains available:
201         /// dHLT-sim          - standard dHLT simulation chain.
202         /// dHLT-sim-fromRaw  - standard dHLT chain taking raw DDL data as input.
203         /// dHLT-sim-fromMC   - dHLT chain taking Monte Carlo hit data as input.
204         ///                     So hit reconstruction is not checked, just the tracker.
205         
206         if (handler == NULL) return 0;
207         
208         const char* trackerId = AliHLTMUONConstants::MansoTrackerFSMId();
209         const char* decCompId = AliHLTMUONConstants::DecisionComponentId();
210         
211         if (rawReader != NULL)
212         {
213                 // Implement the dHLT-sim-fromRaw dHLT simulation chain reading
214                 // from raw data.
215                 const char* rawPubComp = "AliRawReaderPublisher";
216                 const char* cmd13 = "-minid 2572 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x001000";
217                 const char* cmd14 = "-minid 2573 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x002000";
218                 const char* cmd15 = "-minid 2574 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x004000";
219                 const char* cmd16 = "-minid 2575 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x008000";
220                 const char* cmd17 = "-minid 2576 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x010000";
221                 const char* cmd18 = "-minid 2577 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x020000";
222                 const char* cmd19 = "-minid 2578 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x040000";
223                 const char* cmd20 = "-minid 2579 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x080000";
224                 const char* cmd21 = "-minid 2816 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x100000";
225                 const char* cmd22 = "-minid 2817 -datatype 'DDL_RAW ' 'MUON' -dataspec 0x200000";
226                 handler->CreateConfiguration("RawDDL13", rawPubComp, NULL, cmd13);
227                 handler->CreateConfiguration("RawDDL14", rawPubComp, NULL, cmd14);
228                 handler->CreateConfiguration("RawDDL15", rawPubComp, NULL, cmd15);
229                 handler->CreateConfiguration("RawDDL16", rawPubComp, NULL, cmd16);
230                 handler->CreateConfiguration("RawDDL17", rawPubComp, NULL, cmd17);
231                 handler->CreateConfiguration("RawDDL18", rawPubComp, NULL, cmd18);
232                 handler->CreateConfiguration("RawDDL19", rawPubComp, NULL, cmd19);
233                 handler->CreateConfiguration("RawDDL20", rawPubComp, NULL, cmd20);
234                 handler->CreateConfiguration("RawDDL21", rawPubComp, NULL, cmd21);
235                 handler->CreateConfiguration("RawDDL22", rawPubComp, NULL, cmd22);
236                 const char* hrId = AliHLTMUONConstants::HitReconstructorId();
237                 const char* trId = AliHLTMUONConstants::TriggerReconstructorId();
238                 handler->CreateConfiguration("RecoRawDDL13", hrId, "RawDDL13", "-ddl 13 -cdb");
239                 handler->CreateConfiguration("RecoRawDDL14", hrId, "RawDDL14", "-ddl 14 -cdb");
240                 handler->CreateConfiguration("RecoRawDDL15", hrId, "RawDDL15", "-ddl 15 -cdb");
241                 handler->CreateConfiguration("RecoRawDDL16", hrId, "RawDDL16", "-ddl 16 -cdb");
242                 handler->CreateConfiguration("RecoRawDDL17", hrId, "RawDDL17", "-ddl 17 -cdb");
243                 handler->CreateConfiguration("RecoRawDDL18", hrId, "RawDDL18", "-ddl 18 -cdb");
244                 handler->CreateConfiguration("RecoRawDDL19", hrId, "RawDDL19", "-ddl 19 -cdb");
245                 handler->CreateConfiguration("RecoRawDDL20", hrId, "RawDDL20", "-ddl 20 -cdb");
246                 handler->CreateConfiguration("RecoRawDDL21", trId, "RawDDL21", "-ddl 21 -cdb -suppress_partial_triggers");
247                 handler->CreateConfiguration("RecoRawDDL22", trId, "RawDDL22", "-ddl 22 -cdb -suppress_partial_triggers");
248                 
249                 const char* recoSrcs = "RecoRawDDL13 RecoRawDDL14 RecoRawDDL15 RecoRawDDL16 RecoRawDDL17"
250                         " RecoRawDDL18 RecoRawDDL19 RecoRawDDL20 RecoRawDDL21 RecoRawDDL22";
251                 handler->CreateConfiguration("MansoTrackerForRaw", trackerId, recoSrcs, "");
252                 
253                 handler->CreateConfiguration("DecisionForRaw", decCompId, "MansoTrackerForRaw", "");
254                 
255                 TString outputSrcs = "DecisionForRaw MansoTrackerForRaw ";
256                 outputSrcs += recoSrcs;
257                 handler->CreateConfiguration("dHLT-sim-fromRaw", "BlockFilter", outputSrcs, "");
258         }
259         
260         if (runloader != NULL)
261         {
262                 // Implement the dHLT-sim dHLT simulation chain reading from
263                 // simulated digits.
264                 const char* digitPub = AliHLTMUONConstants::DigitPublisherId();
265                 handler->CreateConfiguration("DigitDDL13", digitPub, NULL, "-simdata -ddl 13");
266                 handler->CreateConfiguration("DigitDDL14", digitPub, NULL, "-simdata -ddl 14");
267                 handler->CreateConfiguration("DigitDDL15", digitPub, NULL, "-simdata -ddl 15");
268                 handler->CreateConfiguration("DigitDDL16", digitPub, NULL, "-simdata -ddl 16");
269                 handler->CreateConfiguration("DigitDDL17", digitPub, NULL, "-simdata -ddl 17");
270                 handler->CreateConfiguration("DigitDDL18", digitPub, NULL, "-simdata -ddl 18");
271                 handler->CreateConfiguration("DigitDDL19", digitPub, NULL, "-simdata -ddl 19");
272                 handler->CreateConfiguration("DigitDDL20", digitPub, NULL, "-simdata -ddl 20");
273                 handler->CreateConfiguration("DigitDDL21", digitPub, NULL, "-simdata -ddl 21");
274                 handler->CreateConfiguration("DigitDDL22", digitPub, NULL, "-simdata -ddl 22");
275                 const char* hrId = AliHLTMUONConstants::HitReconstructorId();
276                 const char* trId = AliHLTMUONConstants::TriggerReconstructorId();
277                 handler->CreateConfiguration("RecoDDL13", hrId, "DigitDDL13", "-ddl 13 -cdb");
278                 handler->CreateConfiguration("RecoDDL14", hrId, "DigitDDL14", "-ddl 14 -cdb");
279                 handler->CreateConfiguration("RecoDDL15", hrId, "DigitDDL15", "-ddl 15 -cdb");
280                 handler->CreateConfiguration("RecoDDL16", hrId, "DigitDDL16", "-ddl 16 -cdb");
281                 handler->CreateConfiguration("RecoDDL17", hrId, "DigitDDL17", "-ddl 17 -cdb");
282                 handler->CreateConfiguration("RecoDDL18", hrId, "DigitDDL18", "-ddl 18 -cdb");
283                 handler->CreateConfiguration("RecoDDL19", hrId, "DigitDDL19", "-ddl 19 -cdb");
284                 handler->CreateConfiguration("RecoDDL20", hrId, "DigitDDL20", "-ddl 20 -cdb");
285                 handler->CreateConfiguration("RecoDDL21", trId, "DigitDDL21", "-ddl 21 -cdb -suppress_partial_triggers");
286                 handler->CreateConfiguration("RecoDDL22", trId, "DigitDDL22", "-ddl 22 -cdb -suppress_partial_triggers");
287                 
288                 const char* recoSrcs = "RecoDDL13 RecoDDL14 RecoDDL15 RecoDDL16 RecoDDL17"
289                         " RecoDDL18 RecoDDL19 RecoDDL20 RecoDDL21 RecoDDL22";
290                 handler->CreateConfiguration("MansoTracker", trackerId, recoSrcs, "");
291                 
292                 handler->CreateConfiguration("Decision", decCompId, "MansoTracker", "");
293                 
294                 TString outputSrcs = "Decision MansoTracker ";
295                 outputSrcs += recoSrcs;
296                 handler->CreateConfiguration("dHLT-sim", "BlockFilter", outputSrcs.Data(), "");
297         
298                 // Implement the dHLT-sim-fromMC dHLT simulation chain reading
299                 // Monte Carlo geant hits and putting those into a tracker component.
300                 const char* rhsId = AliHLTMUONConstants::RecHitsSourceId();
301                 const char* trsId = AliHLTMUONConstants::TriggerRecordsSourceId();
302                 handler->CreateConfiguration("HitsDDL13", rhsId, NULL, "-simdata -plane left  -chamber 7");
303                 handler->CreateConfiguration("HitsDDL14", rhsId, NULL, "-simdata -plane right -chamber 7");
304                 handler->CreateConfiguration("HitsDDL15", rhsId, NULL, "-simdata -plane left  -chamber 8");
305                 handler->CreateConfiguration("HitsDDL16", rhsId, NULL, "-simdata -plane right -chamber 8");
306                 handler->CreateConfiguration("HitsDDL17", rhsId, NULL, "-simdata -plane left  -chamber 9");
307                 handler->CreateConfiguration("HitsDDL18", rhsId, NULL, "-simdata -plane right -chamber 9");
308                 handler->CreateConfiguration("HitsDDL19", rhsId, NULL, "-simdata -plane left  -chamber 10");
309                 handler->CreateConfiguration("HitsDDL20", rhsId, NULL, "-simdata -plane right -chamber 10");
310                 handler->CreateConfiguration("TrigRecsDDL21", trsId, NULL, "-hitdata -plane left");
311                 handler->CreateConfiguration("TrigRecsDDL22", trsId, NULL, "-hitdata -plane right");
312                 
313                 const char* dataSrcs = "HitsDDL13 HitsDDL14 HitsDDL15 HitsDDL16 HitsDDL17"
314                         " HitsDDL18 HitsDDL19 HitsDDL20 TrigRecsDDL21 TrigRecsDDL22";
315                 handler->CreateConfiguration("MansoTrackerForMC", trackerId, dataSrcs, "");
316                 
317                 handler->CreateConfiguration("DecisionForMC", decCompId, "MansoTrackerForMC", "");
318                 
319                 outputSrcs = "DecisionForMC MansoTrackerForMC ";
320                 outputSrcs += dataSrcs;
321                 handler->CreateConfiguration("dHLT-sim-fromMC", "BlockFilter", outputSrcs.Data(), "");
322         }
323         
324         return 0;
325 }
326
327
328 int AliHLTMUONAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
329 {
330         ///
331         /// Registers all available components of this module.
332         /// @param pHandler  [in] instance of the component handler.
333         ///
334         
335         if (pHandler == NULL) return -EINVAL;
336         pHandler->AddComponent(new AliHLTMUONRecHitsSource);
337         pHandler->AddComponent(new AliHLTMUONTriggerRecordsSource);
338         pHandler->AddComponent(new AliHLTMUONDigitPublisherComponent);
339         pHandler->AddComponent(new AliHLTMUONRootifierComponent);
340         pHandler->AddComponent(new AliHLTMUONHitReconstructorComponent);
341         pHandler->AddComponent(new AliHLTMUONTriggerReconstructorComponent);
342         pHandler->AddComponent(new AliHLTMUONMansoTrackerFSMComponent);
343         pHandler->AddComponent(new AliHLTMUONDecisionComponent);
344         pHandler->AddComponent(new AliHLTMUONESDMaker);
345         pHandler->AddComponent(new AliHLTMUONEmptyEventFilterComponent);
346         pHandler->AddComponent(new AliHLTMUONDataCheckerComponent);
347         return 0;
348 }
349