]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
From Martin: Added possibity to set the debug level per class via: AliAnalysisManager...
authoragheata <agheata@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 30 Apr 2012 08:35:29 +0000 (08:35 +0000)
committeragheata <agheata@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 30 Apr 2012 08:35:29 +0000 (08:35 +0000)
or: \n   mgr->AddClassDebug(AliAODEvent,AliLog::kInfo);

ANALYSIS/AliAnalysisManager.cxx
ANALYSIS/AliAnalysisManager.h

index 542225c029df41524f25cf8d9ca46ccbf6a40829..fcf81d8bdd42ab7df6fcb75d79310091e436d177 100644 (file)
@@ -82,6 +82,7 @@ AliAnalysisManager::AliAnalysisManager(const char *name, const char *title)
                     fInputs(NULL),
                     fOutputs(NULL),
                     fParamCont(NULL),
+                    fDebugOptions(NULL),
                     fCommonInput(NULL),
                     fCommonOutput(NULL),
                     fSelector(NULL),
@@ -136,6 +137,7 @@ AliAnalysisManager::AliAnalysisManager(const AliAnalysisManager& other)
                     fInputs(NULL),
                     fOutputs(NULL),
                     fParamCont(NULL),
+                    fDebugOptions(NULL),
                     fCommonInput(NULL),
                     fCommonOutput(NULL),
                     fSelector(NULL),
@@ -187,6 +189,7 @@ AliAnalysisManager& AliAnalysisManager::operator=(const AliAnalysisManager& othe
       fInputs     = new TObjArray(*other.fInputs);
       fOutputs    = new TObjArray(*other.fOutputs);
       fParamCont  = new TObjArray(*other.fParamCont);
+      fDebugOptions = NULL;
       fCommonInput = NULL;
       fCommonOutput = NULL;
       fSelector   = NULL;
@@ -218,6 +221,7 @@ AliAnalysisManager::~AliAnalysisManager()
    if (fInputs) delete fInputs;
    if (fOutputs) delete fOutputs;
    if (fParamCont) delete fParamCont;
+   if (fDebugOptions) delete fDebugOptions;
    if (fGridHandler) delete fGridHandler;
    if (fInputEventHandler) delete fInputEventHandler;
    if (fOutputEventHandler) delete fOutputEventHandler;
@@ -355,6 +359,10 @@ void AliAnalysisManager::SlaveBegin(TTree *tree)
   // When running with PROOF SlaveBegin() is called on each slave server.
   // The tree argument is deprecated (on PROOF 0 is passed).
    if (fDebug > 1) printf("->AliAnalysisManager::SlaveBegin()\n");
+
+   // Apply debug options
+   ApplyDebugOptions();
+   
    if (!CheckTasks()) Fatal("SlaveBegin", "Not all needed libraries were loaded");
    static Bool_t isCalled = kFALSE;
    Bool_t init = kFALSE;
@@ -2551,3 +2559,50 @@ Double_t AliAnalysisManager::GetGlobalDbl(const char *key, Bool_t &valid)
    TString s = value->GetName();
    return s.Atof();
 }
+
+//______________________________________________________________________________
+void AliAnalysisManager::AddClassDebug(const char *className, Int_t debugLevel)
+{
+// Sets Class debug level
+
+   if (!fDebugOptions) {
+      fDebugOptions = new TObjArray();
+      fDebugOptions->SetOwner(kTRUE);
+   }
+
+   // substracting DebugOffset, beacuse of AliLog::SetClassDebugLevel()
+   debugLevel -= AliLog::kDebug-1;
+
+   TNamed *debugOpt = (TNamed*)fDebugOptions->FindObject(className);
+   if (!debugOpt) {
+     AliInfo(TString::Format("Adding debug level %d for class %s",debugLevel+AliLog::kDebug-1,className).Data());
+     fDebugOptions->Add(new TNamed(className,TString::Format("%d",debugLevel).Data()));
+   } else {
+      TString oldDebugStr = debugOpt->GetTitle();
+      Int_t oldDebug = oldDebugStr.Atoi();
+      if (debugLevel > oldDebug) {
+         AliWarning(TString::Format("Overwriting debug level to %d class %s, because it is higher then previously set (%d).",debugLevel+AliLog::kDebug-1,className,oldDebug+AliLog::kDebug-1).Data());
+         debugOpt->SetTitle(TString::Format("%d",debugLevel).Data());
+      } else {
+         AliWarning(TString::Format("Ignoring debug level to %d class %s, because it is smaller then previously set (%d).",debugLevel+AliLog::kDebug-1,className,oldDebug+AliLog::kDebug-1).Data());
+      }
+   }
+}
+
+//______________________________________________________________________________
+void AliAnalysisManager::ApplyDebugOptions()
+{
+// Apply debug options
+
+   if (!fDebugOptions) return;
+   
+   TIter next(fDebugOptions);
+   TNamed *debug;
+   TString debugLevel;
+   while ((debug=dynamic_cast<TNamed*>(next()))) {
+      debugLevel = debug->GetTitle();
+      AliInfo(TString::Format("ApplyDebugOptions : Class=%s debulLevel=%d",debug->GetName(),debugLevel.Atoi()+AliLog::kDebug-1).Data());
+      AliLog::SetClassDebugLevel(debug->GetName(), debugLevel.Atoi());
+   }
+}
+
index e1dabb24b4530e5c2021700533970bdebc3d1dcd..0ff257c6f67fbc40bce60261fc183de7eb1cac3a 100644 (file)
@@ -204,6 +204,9 @@ enum EAliAnalysisFlags {
    
    static const char*   GetOADBPath();
 
+   void                 ApplyDebugOptions();
+   void                 AddClassDebug(const char *className, Int_t debugLevel);
+
 protected:
    void                 ImportWrappers(TList *source);
    void                 SetEventLoop(Bool_t flag=kTRUE) {TObject::SetBit(kEventLoop,flag);}
@@ -230,6 +233,7 @@ private:
    TObjArray              *fInputs;              // List of containers with input data
    TObjArray              *fOutputs;             // List of containers with results
    TObjArray              *fParamCont;           // List of containers with results
+   TObjArray              *fDebugOptions;        // List of debug options
    AliAnalysisDataContainer *fCommonInput;       // Common input container
    AliAnalysisDataContainer *fCommonOutput;      // Common output container
    AliAnalysisSelector    *fSelector;            //! Current selector
@@ -247,6 +251,6 @@ private:
    TMap                   *fGlobals;             // Map with global variables
    static TString          fgCommonFileName;     //! Common output file name (not streamed)
    static AliAnalysisManager *fgAnalysisManager; //! static pointer to object instance
-   ClassDef(AliAnalysisManager,15)  // Analysis manager class
+   ClassDef(AliAnalysisManager,16)  // Analysis manager class
 };   
 #endif