]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Bug fix for https://savannah.cern.ch/bugs/?61603
authoraszostak <aszostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 26 Jan 2010 01:18:41 +0000 (01:18 +0000)
committeraszostak <aszostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 26 Jan 2010 01:18:41 +0000 (01:18 +0000)
HLT/MUON/OfflineInterface/AliHLTMUONAgent.cxx
HLT/MUON/OfflineInterface/AliHLTMUONAgent.h

index 0b946ce81d9591a7478b51cf3664d246bd232f33..0b6586d7f41d6444b805a2ab2c0e6e8febdc5b9b 100644 (file)
 #include "AliHLTOUTHandlerChain.h"
 #include "AliRawReader.h"
 #include "AliRunLoader.h"
+#include "AliRun.h"
+#include "AliMUON.h"
 #include "TSystem.h"
+#include "TObjArray.h"
 #include "TString.h"
 
 // The single global instance of the dimuon HLT agent.
@@ -50,11 +53,43 @@ AliHLTMUONAgent AliHLTMUONAgent::fgkInstance;
 
 AliHLTOUTHandlerChain AliHLTMUONAgent::fgkESDMakerChain("libAliHLTMUON.so chains=dHLT-make-esd");
 AliHLTOUTHandlerChain AliHLTMUONAgent::fgkRootifyDumpChain("libAliHLTMUON.so chains=dHLT-rootify-and-dump");
+Int_t AliHLTMUONAgent::fgMuonModuleLoaded = 0;
 
 
 ClassImp(AliHLTMUONAgent);
 
 
+bool AliHLTMUONAgent::IsMuonModuleLoaded()
+{
+       // Checks to see if the MUON module is loaded or not.
+
+       // If the check was already done then use the cached value.
+       if (fgMuonModuleLoaded > 0) return true;
+       if (fgMuonModuleLoaded < 0) return false;
+       
+       bool haveMuonModule = false;
+       if (gAlice != NULL)
+       {
+               // Search for a module in gAlice deriving from AliMUON.
+               TIter next(gAlice->Modules());
+               TObject* mod = NULL;
+               while ((mod = next()) != NULL)
+               {
+                       if (mod->IsA() == AliMUON::Class())
+                       {
+                               fgMuonModuleLoaded = 1;
+                               return true;
+                       }
+               }
+       }
+       else
+       {
+               fgMuonModuleLoaded = -1;
+               return false;
+       }
+}
+
+
 AliHLTMUONAgent::AliHLTMUONAgent() : AliHLTModuleAgent("MUON")
 {
        ///
@@ -110,7 +145,10 @@ const char* AliHLTMUONAgent::GetReconstructionChains(AliRawReader* rawReader,
        
        if (runloader != NULL)
        {
-               if (runloader->GetLoader("MUONLoader") != NULL)
+               // IsMuonModuleLoaded() is used to check if the muon module was loaded
+               // If there is no AliMUON module in the simulation then do not run the
+               // MUON HLT chain.
+               if (IsMuonModuleLoaded() and runloader->GetLoader("MUONLoader") != NULL)
                        return "dHLT-sim";
        }
        
@@ -316,7 +354,7 @@ int AliHLTMUONAgent::CreateConfigurations(
                handler->CreateConfiguration("dHLT-sim-fromRaw-fullTracker", "BlockFilter", outputSrcsFull, "");
        }
        
-       if (runloader != NULL)
+       if (IsMuonModuleLoaded() and runloader != NULL)
        {
                // Implement the dHLT-sim dHLT simulation chain reading from
                // simulated digits.
index 8b699eb116dcd8b1ef6fd37096c0273366ff7ed7..6c473006e585477b91358c7362958da3a626ebc6 100644 (file)
@@ -91,6 +91,11 @@ public:
         * @param pInstance      pointer to handler
         */
        virtual int DeleteOutputHandler(AliHLTOUTHandler* pInstance);
+
+       /**
+        * \returns true if a MUON module was added to gAlice.
+        */
+       static bool IsMuonModuleLoaded();
        
 private:
        // The following instance is used for automatic agent and component registration.
@@ -99,6 +104,8 @@ private:
        static AliHLTOUTHandlerChain  fgkESDMakerChain;  ///< Chain handler for converting dHLT raw data to ESD format.
        static AliHLTOUTHandlerChain  fgkRootifyDumpChain;  ///< Chain handler for converting dHLT raw data to ROOT objects and dumping to file.
 
+       static Int_t fgMuonModuleLoaded; ///< Cached flag for indicating if the MUON module was loaded for a simulation.
+
        ClassDef(AliHLTMUONAgent, 0); // Dimuon HLT module agent which handles processing configurations.
 };