]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONDigitizer.cxx
Logging of Debug, Info and Error Messages follwing AliRoot Standard http://aliweb...
[u/mrichter/AliRoot.git] / MUON / AliMUONDigitizer.cxx
index b2a7c1e271f168d9952c7d4d9795eb2ef8a206f3..971cce6e05a01d66b96daf8324b0c8993c8894bc 100644 (file)
@@ -30,6 +30,8 @@
 #include "AliMUONDigitizer.h"
 #include "AliMUONTransientDigit.h"
 #include "AliMUONHitMapA1.h"
+#include "AliMUONTriggerDecision.h"
+#include "AliLog.h"
 
 
 /////////////////////////////////////////////////////////////////////////////////////
@@ -62,6 +64,7 @@ AliMUONDigitizer::AliMUONDigitizer() :
        fGime = NULL;
        fMUON = NULL;
        fMUONData = NULL;
+       fTrigDec = NULL;
 };
 
 //___________________________________________
@@ -81,6 +84,7 @@ AliMUONDigitizer::AliMUONDigitizer(AliRunDigitizer* manager) :
        fGime = NULL;
        fMUON = NULL;
        fMUONData = NULL;
+       fTrigDec = NULL;
 };
 
 //___________________________________________
@@ -89,14 +93,18 @@ AliMUONDigitizer::AliMUONDigitizer(const AliMUONDigitizer& rhs)
 {
 // Protected copy constructor
 
-  Fatal("AliMUONDigitizer", "Not implemented.");
+  AliFatal("Not implemented.");
 }
 
 //___________________________________________
 AliMUONDigitizer::~AliMUONDigitizer() 
 {
 // Destructor
-  delete fMUONData;
+  if (fMUONData)
+    delete fMUONData;
+
+  if (fTrigDec)
+    delete fTrigDec;
 }
 
 //-------------------------------------------------------------------
@@ -107,7 +115,7 @@ AliMUONDigitizer::operator=(const AliMUONDigitizer& rhs)
 
   if (this == &rhs) return *this;
 
-  Fatal("operator=", "Not implemented.");
+  AliFatal("Not implemented.");
     
   return *this;  
 }    
@@ -129,30 +137,30 @@ void AliMUONDigitizer::Exec(Option_t* option)
 // 2) Loop over the generated transient digits and write them to the output
 //    stream. Done in CreateDigits()
 
-       if (GetDebug() > 0) Info("Exec", "Running digitiser.");
+       AliDebug(1, "Running digitiser.");
        ParseOptions(option);
 
        if (fManager->GetNinputs() == 0)
        {
-               Warning("Exec", "No inputs set, nothing to do.");
+               AliWarning("No inputs set, nothing to do.");
                return;
        };
 
-       if (! FetchLoaders(fManager->GetInputFolderName(0), fRunLoader, fGime) ) return;
+       if (!FetchLoaders(fManager->GetInputFolderName(0), fRunLoader, fGime) ) return;
        if (! FetchGlobalPointers(fRunLoader) ) return;
+       if (! FetchTriggerPointer(fGime) ) return;
 
        InitArrays();
        
-       if (GetDebug() > 1) Info("Exec", "Event Number is %d.", fManager->GetOutputEventNr());
+       AliDebug(2, Form("Event Number is %d.", fManager->GetOutputEventNr()));
 
        // Loop over files to merge and to digitize
        fSignal = kTRUE;
        for (Int_t inputFile = 0; inputFile < fManager->GetNinputs(); inputFile++)
        {
                fMask = fManager->GetMask(inputFile);
-               if (GetDebug() > 1) 
-                       Info("Exec", "Digitising folder %d, with fMask = %d: %s", inputFile, fMask,
-                            (const char*)fManager->GetInputFolderName(inputFile));
+               AliDebug(2, Form("Digitising folder %d, with fMask = %d: %s", inputFile, fMask,
+                            (const char*)fManager->GetInputFolderName(inputFile)));
 
                if (inputFile != 0)
                        // If this is the first file then we already have the loaders loaded.
@@ -170,9 +178,11 @@ void AliMUONDigitizer::Exec(Option_t* option)
        Bool_t ok = FetchLoaders(fManager->GetOutputFolderName(), fRunLoader, fGime);
        if (ok) ok = InitOutputData(fGime);
        if (ok) CreateDigits();
+       if (ok) CreateTrigger();
        if (ok) CleanupOutputData(fGime);
 
        CleanupArrays();
+       CleanupTriggerArrays();
 };
 
 //--------------------------------------------------------------------------
@@ -196,8 +206,7 @@ void AliMUONDigitizer::UpdateTransientDigit(AliMUONTransientDigit* mTD)
 // Update the transient digit that is already in the fTDList by adding the new
 // transient digits charges and track lists to the existing one.
 
-       if (GetDebug() > 3)
-               Info("UpdateTransientDigit", "Updating transient digit 0x%X", (void*)mTD);
+       AliDebug(4,Form( "Updating transient digit 0x%X", (void*)mTD));
        // Choosing the maping of the cathode plane of the chamber:
        Int_t iNchCpl= mTD->Chamber() + (mTD->Cathode()-1) * AliMUONConstants::NCh();
        AliMUONTransientDigit *pdigit = 
@@ -211,13 +220,10 @@ void AliMUONDigitizer::UpdateTransientDigit(AliMUONTransientDigit* mTD)
        Int_t ntracks = mTD->GetNTracks();
        if (ntracks > kMAXTRACKS)  // Truncate the number of tracks to kMAXTRACKS if we have to.
        {
-               if (GetDebug() > 0)
-               {
-                       Warning("UpdateTransientDigit", 
-                               "TransientDigit returned the number of tracks to be %d, which is bigger than kMAXTRACKS.",
-                               ntracks);
-                       Warning("UpdateTransientDigit", "Reseting the number of tracks to be %d.", kMAXTRACKS);
-               }
+               AliDebug(1,Form( 
+                       "TransientDigit returned the number of tracks to be %d, which is bigger than kMAXTRACKS.",
+                       ntracks));
+               AliDebug(1,Form( "Reseting the number of tracks to be %d.", kMAXTRACKS));
                ntracks = kMAXTRACKS;
        };
        
@@ -233,8 +239,7 @@ void AliMUONDigitizer::AddTransientDigit(AliMUONTransientDigit* mTD)
 // Adds the transient digit to the fTDList and sets the appropriate entry
 // in the fHitMap arrays. 
 
-       if (GetDebug() > 3)
-               Info("AddTransientDigit", "Adding transient digit 0x%X", (void*)mTD);
+       AliDebug(4,Form( "Adding transient digit 0x%X", (void*)mTD));
        // Choosing the maping of the cathode plane of the chamber:
        Int_t iNchCpl= mTD->Chamber() + (mTD->Cathode()-1) * AliMUONConstants::NCh();
        fTDList->AddAtAndExpand(mTD, fTDCounter);
@@ -260,7 +265,7 @@ void AliMUONDigitizer::CreateDigits()
 // Loops over the fTDList for each cathode, gets the correct signal for the 
 // digit and adds the new digit to the output stream.
 
-       if (GetDebug() > 1) Info("CreateDigits", "Creating digits...");
+       AliDebug(2, "Creating digits...");
        for (Int_t icat = 0; icat < 2; icat++)
        {
                //
@@ -275,8 +280,7 @@ void AliMUONDigitizer::CreateDigits()
                        // of digits from both cathodes.
                        if (icat != td->Cathode() - 1) continue;
                        
-                       if (GetDebug() > 2)
-                               Info("CreateDigits", "Creating digit from transient digit 0x%X", (void*)td);
+                       AliDebug(3,Form( "Creating digit from transient digit 0x%X", (void*)td));
 
                        Int_t q = GetSignalFrom(td);
                        if (q > 0) AddDigit(td, q);
@@ -311,13 +315,10 @@ void AliMUONDigitizer::AddDigit(AliMUONTransientDigit* td, Int_t responseCharge)
        Int_t nptracks = td->GetNTracks();
        if (nptracks > kMAXTRACKS)
        {
-               if (GetDebug() > 0)
-               {
-                       Warning("AddDigit", 
-                               "TransientDigit returned the number of tracks to be %d, which is bigger than kMAXTRACKS.",
-                               nptracks);
-                       Warning("AddDigit", "Reseting the number of tracks to be %d.", kMAXTRACKS);
-               }
+               AliDebug(1, Form(
+                       "TransientDigit returned the number of tracks to be %d, which is bigger than kMAXTRACKS.",
+                       nptracks));
+               AliDebug(1, Form("Reseting the number of tracks to be %d.", kMAXTRACKS));
                nptracks = kMAXTRACKS;
        };
        
@@ -339,10 +340,11 @@ void AliMUONDigitizer::AddDigit(AliMUONTransientDigit* td, Int_t responseCharge)
                };
        };
 
-       if (GetDebug() > 3) Info("AddDigit", "Adding digit with charge %d.", responseCharge);
+       AliDebug(4,Form( "Adding digit with charge %d.", responseCharge));
 
        OnWriteTransientDigit(td);
        AddDigit(td->Chamber(), tracks, charges, digits);
+       AddDigitTrigger(td->Chamber(), tracks, charges, digits);
 };
 
 //------------------------------------------------------------------------
@@ -370,22 +372,22 @@ Bool_t AliMUONDigitizer::FetchLoaders(const char* foldername, AliRunLoader*& run
 // The muon loader is then loaded from the fetched run loader. 
 // kTRUE is returned if no error occurred otherwise kFALSE is returned. 
 
-       if (GetDebug() > 2)
-               Info("FetchLoaders", "Fetching run loader and muon loader from folder: %s", foldername);
+       AliDebug(3, Form("Fetching run loader and muon loader from folder: %s", foldername));
 
        runloader = AliRunLoader::GetRunLoader(foldername);
        if (runloader == NULL)
        {
-               Error("FetchLoaders", "RunLoader not found in folder: %s", foldername);
+               AliError(Form("RunLoader not found in folder: %s", foldername));
                return kFALSE; 
        }                                                                                       
        muonloader = (AliMUONLoader*) runloader->GetLoader("MUONLoader");
        if (muonloader == NULL) 
        {
-               Error("FetchLoaders", "MUONLoader not found in folder: %s", foldername);
+               AliError(Form("MUONLoader not found in folder: %s", foldername));
                return kFALSE; 
        }
        return kTRUE;
+
 };
 
 //------------------------------------------------------------------------
@@ -397,29 +399,28 @@ Bool_t AliMUONDigitizer::FetchGlobalPointers(AliRunLoader* runloader)
 // AliMUONData fetched from the MUON module. 
 // kTRUE is returned if no error occurred otherwise kFALSE is returned. 
 
-        if (GetDebug() > 2)
-               Info("FetchGlobalPointers", "Fetching gAlice, MUON module and AliMUONData from runloader 0x%X.",
+        AliDebug(3, Form("Fetching gAlice, MUON module and AliMUONData from runloader 0x%X.",
                        (void*)runloader
-                   );
+                   ));
 
        if (runloader->GetAliRun() == NULL) runloader->LoadgAlice();
        gAlice = runloader->GetAliRun();
        if (gAlice == NULL)
        {
-               Error("FetchGlobalPointers", "Could not find the AliRun object in runloader 0x%X.", (void*)runloader);
+               AliError(Form("Could not find the AliRun object in runloader 0x%X.", (void*)runloader));
                return kFALSE;
        };
        fMUON = (AliMUON*) gAlice->GetDetector("MUON");
        if (fMUON == NULL)
        {
-               Error("FetchGlobalPointers", "Could not find the MUON module in runloader 0x%X.", (void*)runloader);
+               AliError(Form("Could not find the MUON module in runloader 0x%X.", (void*)runloader));
                return kFALSE;
        };
 
        AliMUONLoader *muonloader = (AliMUONLoader*) runloader->GetLoader("MUONLoader");
        if (muonloader == NULL) 
        {
-               Error("FetchGlobalPointers", "MUONLoader not found ");
+               AliError( "MUONLoader not found ");
                return kFALSE; 
        }
 
@@ -427,12 +428,25 @@ Bool_t AliMUONDigitizer::FetchGlobalPointers(AliRunLoader* runloader)
        if (fMUONData == NULL) fMUONData = new AliMUONData(muonloader,"MUON","MUON");
        if (fMUONData == NULL)
        {
-               Error("FetchGlobalPointers", "Could not find AliMUONData object in runloader 0x%X.", (void*)runloader);
+               AliError(Form("Could not find AliMUONData object in runloader 0x%X.", (void*)runloader));
                return kFALSE;
        };
+
        return kTRUE;
 }
-
+//-----------------------------------------------------------------------
+Bool_t  AliMUONDigitizer::FetchTriggerPointer(AliMUONLoader* loader)
+{
+  if (fMUONData == NULL) {
+    AliError("MUONData not found");
+    return kFALSE;
+  }
+
+  if (fTrigDec == NULL) 
+      fTrigDec = new AliMUONTriggerDecision(loader,0,fMUONData);
+  
+  return kTRUE;
+}
 //------------------------------------------------------------------------
 void AliMUONDigitizer::ParseOptions(Option_t* options)
 {
@@ -449,7 +463,7 @@ void AliMUONDigitizer::ParseOptions(Option_t* options)
                optionString.Data() == "deb"   // maintained for compatability.
           )
        {
-               Info("ParseOptions", "Called with option \"debug\".");
+               AliInfo("Called with option \"debug\".");
                SetDebug(99);
        };
 };
@@ -464,8 +478,8 @@ void AliMUONDigitizer::InitArrays()
 //
 // Note: the fTDList and fHitMap arrays must be NULL before calling this method.
 
-       if (GetDebug() > 1) Info("InitArrays", "Initialising internal arrays.");
-       if (GetDebug() > 3) Info("InitArrays", "Creating transient digits list.");
+       AliDebug(2, "Initialising internal arrays.");
+       AliDebug(4, "Creating transient digits list.");
        fTDList = new TObjArray;
        
        // Array of pointer of the AliMUONHitMapA1:
@@ -475,11 +489,11 @@ void AliMUONDigitizer::InitArrays()
        // Loop over chambers for the definition AliMUONHitMap
        for (Int_t i = 0; i < AliMUONConstants::NCh(); i++) 
        {
-               if (GetDebug() > 3) Info("InitArrays", "Creating hit map for chamber %d, cathode 1.", i+1);
+               AliDebug(4,Form( "Creating hit map for chamber %d, cathode 1.", i+1));
                AliMUONChamber* chamber = &(fMUON->Chamber(i));
                AliSegmentation* c1Segmentation = chamber->SegmentationModel(1); // Cathode plane 1
                fHitMap[i] = new AliMUONHitMapA1(c1Segmentation, fTDList);
-               if (GetDebug() > 3) Info("InitArrays", "Creating hit map for chamber %d, cathode 2.", i+1);
+               AliDebug(4,Form( "Creating hit map for chamber %d, cathode 2.", i+1));
                AliSegmentation* c2Segmentation = chamber->SegmentationModel(2); // Cathode plane 2
                fHitMap[i+AliMUONConstants::NCh()] = new AliMUONHitMapA1(c2Segmentation, fTDList);
        };
@@ -490,20 +504,21 @@ void AliMUONDigitizer::CleanupArrays()
 {
 // The arrays fTDList and fHitMap are deleted and the pointers set to NULL.
 
-       if (GetDebug() > 1) Info("CleanupArrays", "Deleting internal arrays.");
+       AliDebug(2, "Deleting internal arrays.");
        for(Int_t i = 0; i < 2*AliMUONConstants::NCh(); i++)
        {
-               if (GetDebug() > 3) Info("CleanupArrays", "Deleting hit map for chamber %d, cathode %d.", 
-                       i%AliMUONConstants::NCh()+1, i/AliMUONConstants::NCh()+1);
+               AliDebug(4,Form( "Deleting hit map for chamber %d, cathode %d.", 
+                       i%AliMUONConstants::NCh()+1, i/AliMUONConstants::NCh()+1));
                delete fHitMap[i];
        };
        delete [] fHitMap;
        fHitMap = NULL;
        
-       if (GetDebug() > 3) Info("CleanupArrays", "Deleting transient digits list.");
+       AliDebug(4, "Deleting transient digits list.");
        fTDList->Delete();
        delete fTDList;
        fTDList = NULL;
+
 };
 
 //------------------------------------------------------------------------