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