]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONDigitMaker.cxx
Fix histo name
[u/mrichter/AliRoot.git] / MUON / AliMUONDigitMaker.cxx
index c8de1ccf91928732548f40efc2cb8f1ccf1bcd28..5bc70b373b69062f0a485d318c53628414959876 100644 (file)
@@ -44,7 +44,6 @@
 
 #include "AliMUONDigitMaker.h"
 
-#include "AliLog.h"
 #include "AliMUONDDLTrigger.h"
 #include "AliMUONDarcHeader.h"
 #include "AliMUONVDigit.h"
 #include "AliMUONGlobalTrigger.h"
 #include "AliMUONLocalStruct.h"
 #include "AliMUONLocalTrigger.h"
-#include "AliMUONRawStreamTracker.h"
-#include "AliMUONRawStreamTrigger.h"
+#include "AliMUONLogger.h"
+#include "AliMUONRawStreamTrackerHP.h"
+#include "AliMUONRawStreamTriggerHP.h"
 #include "AliMUONRegHeader.h"
 #include "AliMUONTriggerCircuit.h"
+#include "AliMUONVTriggerStore.h"
+#include "AliMpDetElement.h"
 #include "AliMpTriggerCrate.h"
 #include "AliMpLocalBoard.h"
-#include "AliMUONVTriggerStore.h"
 #include "AliMpCathodType.h"
 #include "AliMpDDLStore.h"
 #include "AliMpDEManager.h"
 #include "AliMpPad.h"
 #include "AliMpSegmentation.h"
 #include "AliMpVSegmentation.h"
+#include "AliCodeTimer.h"
+#include "AliLog.h"
 #include "AliRawReader.h"
 #include <TArrayS.h>
 
@@ -73,32 +76,63 @@ ClassImp(AliMUONDigitMaker) // Class implementation in ROOT context
 /// \endcond
 
 //__________________________________________________________________________
-AliMUONDigitMaker::AliMUONDigitMaker(Bool_t enableErrorLogger)
-  : TObject(),
+AliMUONDigitMaker::AliMUONDigitMaker(Bool_t enableErrorLogger, Bool_t a, Bool_t b) :
+TObject(),
+fScalerEvent(kFALSE),
+fMakeTriggerDigits(kFALSE),
+fRawStreamTracker(new AliMUONRawStreamTrackerHP),
+fRawStreamTrigger(new AliMUONRawStreamTriggerHP),
+fDigitStore(0x0),
+fTriggerStore(0x0),
+fLogger(new AliMUONLogger(10000))
+{
+  /// ctor 
+  
+  if  ( !a || !b ) AliFatal("no longer supported");
+  
+  AliDebug(1,"");
+  
+  // Standard Constructor
+  if (enableErrorLogger) 
+  {
+    fRawStreamTracker->EnabbleErrorLogger();
+    fRawStreamTrigger->EnabbleErrorLogger();
+  }
+  else
+  {
+    fRawStreamTracker->DisableWarnings();
+  }
+  
+  SetMakeTriggerDigits();
+  
+}
+
+//__________________________________________________________________________
+AliMUONDigitMaker::AliMUONDigitMaker(Bool_t enableErrorLogger) :
+TObject(),
     fScalerEvent(kFALSE),
     fMakeTriggerDigits(kFALSE),
-    fRawStreamTracker(new AliMUONRawStreamTracker()),    
-    fRawStreamTrigger(new AliMUONRawStreamTrigger()),    
-    fTrackerTimer(),
-    fTriggerTimer(),
-    fMappingTimer(),
+    fRawStreamTracker(new AliMUONRawStreamTrackerHP),
+    fRawStreamTrigger(new AliMUONRawStreamTriggerHP),
     fDigitStore(0x0),
-    fTriggerStore(0x0)
+    fTriggerStore(0x0),
+  fLogger(new AliMUONLogger(10000))
 {
   /// ctor 
 
   AliDebug(1,"");
-
+  
   // Standard Constructor
-  if (enableErrorLogger) {
+  if (enableErrorLogger) 
+  {
     fRawStreamTracker->EnabbleErrorLogger();
     fRawStreamTrigger->EnabbleErrorLogger();
   }
+  else
+  {
+    fRawStreamTracker->DisableWarnings();
+  }
 
-  fTrackerTimer.Start(kTRUE); fTrackerTimer.Stop();
-  fTriggerTimer.Start(kTRUE); fTriggerTimer.Stop();
-  fMappingTimer.Start(kTRUE); fMappingTimer.Stop();
-  
   SetMakeTriggerDigits();
 
 }
@@ -111,21 +145,29 @@ AliMUONDigitMaker::~AliMUONDigitMaker()
 
   delete fRawStreamTracker;
   delete fRawStreamTrigger;
+  delete fLogger;
+}
+
+//____________________________________________________________________
+void
+AliMUONDigitMaker::Print(Option_t*) const
+{
+  /// Printout
 
-  AliDebug(1, Form("Execution time for MUON tracker : R:%.2fs C:%.2fs",
-               fTrackerTimer.RealTime(),fTrackerTimer.CpuTime()));
-  AliDebug(1, Form("   Execution time for MUON tracker (mapping calls part) "
-               ": R:%.2fs C:%.2fs",
-               fMappingTimer.RealTime(),fMappingTimer.CpuTime()));
-  AliDebug(1, Form("Execution time for MUON trigger : R:%.2fs C:%.2fs",
-               fTriggerTimer.RealTime(),fTriggerTimer.CpuTime()));
+  cout << "RawStreamerTracker class=" << fRawStreamTracker->ClassName()
+       << " MakeTriggerDigits=" << fMakeTriggerDigits
+       << " ScalerEvent=" << fScalerEvent
+       << " DigitStore=" << fDigitStore
+       << " TriggerStore=" << fTriggerStore << endl;
 
+  if ( fLogger ) fLogger->Print();
 }
 
 //____________________________________________________________________
-Int_t AliMUONDigitMaker::Raw2Digits(AliRawReader* rawReader, 
-                                    AliMUONVDigitStore* digitStore,
-                                    AliMUONVTriggerStore* triggerStore)
+Int_t
+AliMUONDigitMaker::Raw2Digits(AliRawReader* rawReader, 
+                                        AliMUONVDigitStore* digitStore,
+                                        AliMUONVTriggerStore* triggerStore)
 {
   /// Main method to creates digit
   /// for tracker 
@@ -139,14 +181,17 @@ Int_t AliMUONDigitMaker::Raw2Digits(AliRawReader* rawReader,
   
   if (!fDigitStore && !fTriggerStore)
   {
-    AliError("No digit or trigger store given. Nothing to do...");
-    return kFALSE;
+    fLogger->Log("No digit or trigger store given. Nothing to do...");
+    return kTriggerBAD & kTrackerBAD;
   }
   
+  Int_t tracker(kOK);
+  Int_t trigger(kOK);
+  
   if ( fDigitStore ) 
   {
     fDigitStore->Clear(); // insure we start with an empty container
-    ReadTrackerDDL(rawReader);
+    tracker = ReadTrackerDDL(rawReader);
   }
   
   if ( fTriggerStore || fMakeTriggerDigits ) 
@@ -154,26 +199,27 @@ Int_t AliMUONDigitMaker::Raw2Digits(AliRawReader* rawReader,
     if ( fTriggerStore ) fTriggerStore->Clear();
     if ( fMakeTriggerDigits && !fDigitStore ) 
     {
-      AliError("Asking for trigger digits but digitStore is null");
+      fLogger->Log("Asking for trigger digits but digitStore is null");
     }
     else
     {
-      ReadTriggerDDL(rawReader);
+      trigger = ReadTriggerDDL(rawReader);
     }
   }
   
-  return kTRUE;
+  return tracker | trigger;
 }
 
 //____________________________________________________________________
-Int_t AliMUONDigitMaker::ReadTrackerDDL(AliRawReader* rawReader)
+Int_t
+AliMUONDigitMaker::ReadTrackerDDL(AliRawReader* rawReader)
 {
   /// Reading tracker DDL
   /// filling the fDigitStore container, which must not be null
 
   AliDebug(1,"");
   
-  fTrackerTimer.Start(kFALSE);
+  AliCodeTimerAuto("");
 
   // elex info
   Int_t    buspatchId;
@@ -184,71 +230,88 @@ Int_t AliMUONDigitMaker::ReadTrackerDDL(AliRawReader* rawReader)
   fRawStreamTracker->SetReader(rawReader);
   fRawStreamTracker->First();
   
-  while ( fRawStreamTracker->Next(buspatchId,manuId,channelId,charge) )
+  while ( fRawStreamTracker->Next(buspatchId,manuId,channelId,charge,kTRUE) )
   {    
     // getting DE from buspatch
     Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(buspatchId);
 
+    AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
+
+    if (!de)
+      {
+       fLogger->Log(Form("DE %04d does not exist !"));
+       continue;
+      }
+
+    if (!de->IsConnectedChannel(manuId,channelId))
+      {
+       // non connected pad, do nothing (this is not an error !)
+       continue;
+      }
+
     const AliMpVSegmentation* seg 
       = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId, 
                                                                       manuId);  
 
-    AliMp::CathodType cathodeType = AliMpDEManager::GetCathod(detElemId, 
-                                                              seg->PlaneType());
-
-    AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,channelId),kFALSE);
+    if (!seg)
+    {
+      fLogger->Log(Form("(DE,MANUID)=(%04d,%04d) is not valid",detElemId,manuId));
+      continue;
+    }
     
+    AliMp::CathodType cathodeType = de->GetCathodType(seg->PlaneType());
+
+    AliMpPad pad = seg->PadByLocation(manuId,channelId,kFALSE);
+
     if (!pad.IsValid())
     {
-      AliError(Form("No pad for detElemId: %d, manuId: %d, channelId: %d",
+      fLogger->Log(Form("No pad for detElemId: %d, manuId: %d, channelId: %d",
                     detElemId, manuId, channelId));
       continue;
     } 
-    
+
     AliMUONVDigit* digit = fDigitStore->Add(detElemId,manuId,channelId,cathodeType,
                                             AliMUONVDigitStore::kDeny);
+
     if (!digit)
     {
-      AliError(Form("Digit DE %04d Manu %04d Channel %02d could not be added",
+      fLogger->Log(Form("Digit DE %04d Manu %04d Channel %02d could not be added",
                     detElemId, manuId, channelId));
       continue;
     }
     
-    digit->SetPadXY(pad.GetIndices().GetFirst(),
-                   pad.GetIndices().GetSecond());
+    digit->SetPadXY(pad.GetIx(),pad.GetIy());
     
-         digit->SetADC(charge);
+    digit->SetADC(charge);
 
   }
   
-  fTrackerTimer.Stop();
-
-  return kTRUE;
+  if ( fRawStreamTracker->IsErrorMessage() ) 
+  {
+    return kTrackerBAD;
+  }
+  
+  return kOK;
 }
 
 //____________________________________________________________________
-Int_t AliMUONDigitMaker::ReadTriggerDDL(AliRawReader* rawReader)
+Int_t
+AliMUONDigitMaker::ReadTriggerDDL(AliRawReader* rawReader)
 {
-  /// reading tracker DDL
+  /// reading tracker DDL like ReadTriggerDDL but with fast decoder interface.
   /// filling the fTriggerStore container, which must not be null
 
-  AliDebug(1,"");
-  
-  AliMUONDDLTrigger*       ddlTrigger      = 0x0;
-  AliMUONDarcHeader*       darcHeader      = 0x0;
-  AliMUONRegHeader*        regHeader       = 0x0;
-  AliMUONLocalStruct*      localStruct     = 0x0;
+  const AliMUONRawStreamTriggerHP::AliHeader*          darcHeader  = 0x0;
+  const AliMUONRawStreamTriggerHP::AliRegionalHeader*  regHeader   = 0x0;
+  const AliMUONRawStreamTriggerHP::AliLocalStruct*     localStruct = 0x0;
 
   Int_t loCircuit;
 
-  fTriggerTimer.Start(kFALSE);
-
   fRawStreamTrigger->SetReader(rawReader);
 
-  while (fRawStreamTrigger->NextDDL()) 
+  while (fRawStreamTrigger->NextDDL())
   {
-    ddlTrigger = fRawStreamTrigger->GetDDLTrigger();
-    darcHeader = ddlTrigger->GetDarcHeader();
+    darcHeader = fRawStreamTrigger->GetHeaders();
     
     // fill global trigger information
     if (fTriggerStore) 
@@ -257,11 +320,12 @@ Int_t AliMUONDigitMaker::ReadTriggerDDL(AliRawReader* rawReader)
       {
           AliMUONGlobalTrigger globalTrigger;
           globalTrigger.SetFromGlobalResponse(darcHeader->GetGlobalOutput());
+          globalTrigger.SetFromGlobalInput(darcHeader->GetGlobalHeader()->fInput);
           fTriggerStore->SetGlobal(globalTrigger);
       }
     }
     
-    Int_t nReg = darcHeader->GetRegHeaderEntries();
+    Int_t nReg = fRawStreamTrigger->GetRegionalHeaderCount();
     
     for(Int_t iReg = 0; iReg < nReg ;iReg++)
     {   //reg loop
@@ -272,16 +336,16 @@ Int_t AliMUONDigitMaker::ReadTriggerDDL(AliRawReader* rawReader)
                                 GetTriggerCrate(fRawStreamTrigger->GetDDL(), iReg);
       
       if (!crate) 
-        AliWarning(Form("Missing crate number %d in DDL %d\n", iReg, fRawStreamTrigger->GetDDL()));
+        fLogger->Log(Form("Missing crate number %d in DDL %d\n", iReg, fRawStreamTrigger->GetDDL()));
      
       
-      regHeader =  darcHeader->GetRegHeaderEntry(iReg);
+      regHeader =  fRawStreamTrigger->GetRegionalHeader(iReg);
       
-      Int_t nLocal = regHeader->GetLocalEntries();
+      Int_t nLocal = regHeader->GetLocalStructCount();
       for(Int_t iLocal = 0; iLocal < nLocal; iLocal++) 
-      {  
+      {
         
-        localStruct = regHeader->GetLocalEntry(iLocal);
+        localStruct = regHeader->GetLocalStruct(iLocal);
         
         // if card exist
         if (localStruct) {
@@ -290,19 +354,34 @@ Int_t AliMUONDigitMaker::ReadTriggerDDL(AliRawReader* rawReader)
 
          if ( !loCircuit ) continue; // empty slot
 
-         AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(loCircuit, false);
+         AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(loCircuit, kTRUE);
 
          // skip copy cards
          if( !localBoard->IsNotified()) 
             continue;
           
-          if (fTriggerStore) 
+          if (fTriggerStore)
           {
             // fill local trigger
             AliMUONLocalTrigger localTrigger;
-            localTrigger.SetLocalStruct(loCircuit, *localStruct);
+            localTrigger.SetLoCircuit(loCircuit);
+            localTrigger.SetLoStripX((Int_t)localStruct->GetXPos());
+            localTrigger.SetLoStripY((Int_t)localStruct->GetYPos());
+            localTrigger.SetLoDev((Int_t)localStruct->GetXDev());
+            localTrigger.SetLoSdev((Int_t)localStruct->GetSXDev());
+            localTrigger.SetLoTrigY((Int_t)localStruct->GetTrigY());
+            localTrigger.SetLoLpt(localStruct->GetLpt());
+            localTrigger.SetLoHpt(localStruct->GetHpt());
+            localTrigger.SetX1Pattern(localStruct->GetX1());
+            localTrigger.SetX2Pattern(localStruct->GetX2());
+            localTrigger.SetX3Pattern(localStruct->GetX3());
+            localTrigger.SetX4Pattern(localStruct->GetX4());
+            localTrigger.SetY1Pattern(localStruct->GetY1());
+            localTrigger.SetY2Pattern(localStruct->GetY2());
+            localTrigger.SetY3Pattern(localStruct->GetY3());
+            localTrigger.SetY4Pattern(localStruct->GetY4());
             fTriggerStore->Add(localTrigger);
-          } 
+          }
           
           if ( fMakeTriggerDigits )
           {
@@ -313,16 +392,13 @@ Int_t AliMUONDigitMaker::ReadTriggerDDL(AliRawReader* rawReader)
            localStruct->GetYPattern(xyPattern[1]);
             
             TriggerDigits(loCircuit, xyPattern, *fDigitStore);
-          }          
+          }
         } // if triggerY
       } // iLocal
     } // iReg
   } // NextDDL
   
-  fTriggerTimer.Stop();
-
-  return kTRUE;
-
+  return kOK;
 }
 
 //____________________________________________________________________
@@ -332,6 +408,8 @@ Int_t AliMUONDigitMaker::TriggerDigits(Int_t nBoard,
 {
   /// make digits for trigger from pattern, and add them to digitStore
 
+  AliCodeTimerAuto("");
+  
   Int_t detElemId;
 
   AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(nBoard);
@@ -362,17 +440,17 @@ Int_t AliMUONDigitMaker::TriggerDigits(Int_t nBoard,
             Int_t offset = 0;
             if (iCath && localBoard->GetSwitch(6)) offset = -8;
             
-            AliMpPad pad = seg->PadByLocation(AliMpIntPair(nBoard,ibitxy+offset),kTRUE);
+            AliMpPad pad = seg->PadByLocation(nBoard,ibitxy+offset,kTRUE);
                         
             if (!pad.IsValid()) 
             {
-              AliWarning(Form("No pad for detElemId: %d, nboard %d, ibitxy: %d\n",
+              fLogger->Log(Form("No pad for detElemId: %d, nboard %d, ibitxy: %d\n",
                               detElemId, nBoard, ibitxy));
               continue;
             }
 
-            n = pad.GetLocation(0).GetFirst(); // always take first location so that digits are not inserted several times
-           b = pad.GetLocation(0).GetSecond();
+            n = pad.GetLocalBoardId(0); // always take first location so that digits are not inserted several times
+           b = pad.GetLocalBoardChannel(0);
 
            AliDebug(1,Form("Using localBoard %d ixy %d instead of %d,%d",
                            n,b,nBoard,ibitxy));
@@ -386,8 +464,8 @@ Int_t AliMUONDigitMaker::TriggerDigits(Int_t nBoard,
                continue;
             }
             
-            Int_t padX = pad.GetIndices().GetFirst();
-            Int_t padY = pad.GetIndices().GetSecond();
+            Int_t padX = pad.GetIx();
+            Int_t padY = pad.GetIy();
             
             // fill digit
             digit->SetPadXY(padX,padY);
@@ -398,4 +476,32 @@ Int_t AliMUONDigitMaker::TriggerDigits(Int_t nBoard,
   } // ichamber
   
   return kTRUE;
-} 
+}
+
+//______________________________________________________________________________
+Bool_t 
+AliMUONDigitMaker::TriggerToDigitsStore(const AliMUONVTriggerStore& triggerStore,
+                                       AliMUONVDigitStore& digitStore) const
+{
+  //
+  /// make (S)Digit for trigger
+  //
+  
+  digitStore.Clear();
+  
+  AliMUONLocalTrigger* locTrg;
+  TIter next(triggerStore.CreateLocalIterator());
+  
+  while ( ( locTrg = static_cast<AliMUONLocalTrigger*>(next()) ) ) 
+  {
+    if (locTrg->IsNull()) continue;
+   
+    TArrayS xyPattern[2];
+    locTrg->GetXPattern(xyPattern[0]);
+    locTrg->GetYPattern(xyPattern[1]);
+
+    Int_t nBoard = locTrg->LoCircuit();
+    TriggerDigits(nBoard, xyPattern, digitStore);
+  }
+  return kTRUE;
+}