]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONTrigger.cxx
Update of ACORDE-QA-Raw data histograms (now they go from -0.5 to 59.5)
[u/mrichter/AliRoot.git] / MUON / AliMUONTrigger.cxx
index 00e7e659e5b99f5e4868e2cbccdab8b86faced4b..074ff7ffe6bd22633adb189fd1defb9a08242ce6 100644 (file)
 
 /* $Id$ */
 
+#include "AliMUONTrigger.h"
+
 #include "AliLog.h"
+#include "AliMUONGlobalTrigger.h"
+#include "AliMUONVTriggerStore.h"
 #include "AliRun.h"
 #include "AliRunLoader.h"
 #include "AliTriggerInput.h"
 
-#include "AliMUON.h"
-#include "AliMUONLoader.h"
-#include "AliMUONData.h"
-#include "AliMUONDigit.h"
-#include "AliMUONTriggerDecision.h"
-#include "AliMUONTrigger.h"
+
+//-----------------------------------------------------------------------------
+/// \class AliMUONTrigger
+///
+/// Implementation of AliTriggerDetector for MUON detector
+///
+/// So far, the inputs are taken from AliMUONTriggerDecision object
+/// April 06, E.L.T.
+/// May 06, taken info from Global Trigger branch (Ch.F)
+///
+/// \author E. Lopez Torres
+//-----------------------------------------------------------------------------
 
 //----------------------------------------------------------------------
+/// \cond CLASSIMP
 ClassImp(AliMUONTrigger)
+/// \endcond
 
 //----------------------------------------------------------------------
 AliMUONTrigger::AliMUONTrigger()
-  : AliTriggerDetector() 
+  : AliTriggerDetector(), fTriggerStore(0x0)
 {
+/// Default constructor
+
    SetName("MUON");
    CreateInputs();
 }
 
+//----------------------------------------------------------------------
+AliMUONTrigger::~AliMUONTrigger()
+{
+  /// Destructor
+  delete fTriggerStore;
+}
+
 //----------------------------------------------------------------------
 void AliMUONTrigger::CreateInputs()
 {
-   // inputs 
+   /// inputs 
    
    // Do not create inputs again!!
    if( fInputs.GetEntriesFast() > 0 ) return;
    
-   fInputs.AddLast( new AliTriggerInput( "MUON_SPlus_LPt_L0", "Single Plus Low Pt",  0x01 ) );
-   fInputs.AddLast( new AliTriggerInput( "MUON_SPlus_HPt_L0", "Single Plus High Pt", 0x02 ) );
-   fInputs.AddLast( new AliTriggerInput( "MUON_SPlus_All_L0", "Single Plus All",     0x04 ) );
-
-   fInputs.AddLast( new AliTriggerInput( "MUON_SMinus_LPt_L0", "Single Minus Low Pt",  0x08 ) );
-   fInputs.AddLast( new AliTriggerInput( "MUON_SMinus_HPt_L0", "Single Minus High Pt", 0x10 ) );
-   fInputs.AddLast( new AliTriggerInput( "MUON_SMinus_All_L0", "Single Minus All",     0x20 ) );
-
-   fInputs.AddLast( new AliTriggerInput( "MUON_SUndef_LPt_L0", "Single Undefined Low Pt",  0x40 ) );
-   fInputs.AddLast( new AliTriggerInput( "MUON_SUndef_HPt_L0", "Single Undefined High Pt", 0x80 ) );
-   fInputs.AddLast( new AliTriggerInput( "MUON_SUndef_All_L0", "Single Undefined All",     0x100 ) );
+   fInputs.AddLast( new AliTriggerInput( "0MSL", "MUONTRG",  0 ) );
+   fInputs.AddLast( new AliTriggerInput( "0MSH", "MUONTRG", 0 ) );
 
-   fInputs.AddLast( new AliTriggerInput( "MUON_Unlike_LPt_L0", "Single Unlike Sign pair Low Pt",  0x200 ) );
-   fInputs.AddLast( new AliTriggerInput( "MUON_Unlike_HPt_L0", "Single Unlike Sign pair High Pt", 0x400 ) );
-   fInputs.AddLast( new AliTriggerInput( "MUON_Unlike_All_L0", "Single Unlike Sign pair All",     0x800 ) );
+   fInputs.AddLast( new AliTriggerInput( "0MUL", "MUONTRG",  0 ) );
+   fInputs.AddLast( new AliTriggerInput( "0MUH", "MUONTRG", 0 ) );
 
-   fInputs.AddLast( new AliTriggerInput( "MUON_Like_LPt_L0", "Single Like Sign pair Low Pt",  0x1000 ) );
-   fInputs.AddLast( new AliTriggerInput( "MUON_Like_HPt_L0", "Single Like Sign pair High Pt", 0x2000 ) );
-   fInputs.AddLast( new AliTriggerInput( "MUON_Like_All_L0", "Single Like Sign pair All",     0x4000 ) );
+   fInputs.AddLast( new AliTriggerInput( "0MLL", "MUONTRG",  0 ) );
+   fInputs.AddLast( new AliTriggerInput( "0MLH", "MUONTRG", 0 ) );
 }
 
 //----------------------------------------------------------------------
 void AliMUONTrigger::Trigger()
 {
+  /// sets the trigger inputs
 
+   AliRunLoader* runLoader = AliRunLoader::Instance();
+  
+   AliLoader * muonLoader = runLoader->GetDetectorLoader("MUON");
+   muonLoader->LoadDigits("READ");
 
-   AliRunLoader* runLoader = gAlice->GetRunLoader();
-
-   AliLoader * MUONLoader = runLoader->GetLoader("MUONLoader");
-   MUONLoader->LoadDigits("READ");
-   // Creating MUON data container
-   AliMUONData* MUONData = new AliMUONData(MUONLoader,"MUON","MUON");
-   MUONData->SetTreeAddress("D");
-   MUONData->GetDigits();
-   Int_t idebug = 1;
-   // Creating MUONTriggerDecision
-   AliMUONTriggerDecision* decision = new AliMUONTriggerDecision(MUONLoader ,idebug,MUONData);
-   AliMUONDigit * mDigit;
-   Int_t tracks[10];
-   Int_t charges[10];
-   Int_t digits[7];
-
-   for(Int_t ichamber=10; ichamber<14; ichamber++) {
-      Int_t idigit, ndigits;
-      ndigits = (Int_t) MUONData->Digits(ichamber)->GetEntriesFast();
-//            printf(">>> Chamber Cathode ndigits %d %d %d\n",ichamber,icathode,ndigits);
-      for(idigit=0; idigit<ndigits; idigit++) {
-         mDigit = static_cast<AliMUONDigit*>(MUONData->Digits(ichamber)->At(idigit));
-         digits[0] = mDigit->PadX();
-         digits[1] = mDigit->PadY();
-         digits[2] = mDigit->Cathode();
-         digits[3] = mDigit->Signal();
-         digits[4] = mDigit->Physics();
-         digits[5] = mDigit->Hit();
-         digits[6] = mDigit->DetElemId();
-
-         Int_t digitindex = 0 ;
-  //       printf("ichamber ix iy %d %d %d \n",ichamber,mDigit->PadX(),mDigit->PadY());
-
-         decision->AddDigit(ichamber, tracks, charges, digits, digitindex );
-      } // loop on digits
-   } // loop on chambers
-   MUONData->ResetDigits();
-   decision->Trigger();
-   decision->ClearDigits();
-
-   // Set the trigger inputs = "global decision" 
-   Int_t singlePlus[3];  // tot num of single plus
-   Int_t singleMinus[3]; // tot num of single minus
-   Int_t singleUndef[3]; // tot num of single undefined
-   Int_t pairUnlike[3];  // tot num of unlike-sign pairs
-   Int_t pairLike[3];    // tot num of like-sign pairs
-   decision->GetGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
-
-   if( singlePlus[0] )  SetInput("MUON_SPlus_LPt_L0");
-   if( singlePlus[1] )  SetInput("MUON_SPlus_HPt_L0");
-   if( singlePlus[2] )  SetInput("MUON_SPlus_All_L0");
+   TTree* treeD = muonLoader->TreeD();
    
-   if( singleMinus[0] ) SetInput("MUON_SMinus_LPt_L0");
-   if( singleMinus[1] ) SetInput("MUON_SMinus_HPt_L0");
-   if( singleMinus[2] ) SetInput("MUON_SMinus_All_L0");
+   if (!treeD)
+   {
+     AliError("No TreeD available. Cannot make trigger");
+     return;
+   }
    
-   if( singleUndef[0] ) SetInput("MUON_SUndef_LPt_L0");
-   if( singleUndef[1] ) SetInput("MUON_SUndef_HPt_L0");
-   if( singleUndef[2] ) SetInput("MUON_SUndef_All_L0");
+   if (!fTriggerStore) 
+   {  
+     fTriggerStore = AliMUONVTriggerStore::Create(*treeD);
+     if (!fTriggerStore)
+     {
+       AliError("Could not create triggerStore from treeD");
+       return;
+     }     
+   }
+
+   Bool_t ok = fTriggerStore->Connect(*treeD,kTRUE);
+
+   if (!ok)
+   {
+     AliError("Could not read trigger from TreeD !");
+     return;
+   }
    
-   if( pairUnlike[0] )  SetInput("MUON_Unlike_LPt_L0");
-   if( pairUnlike[1] )  SetInput("MUON_Unlike_HPt_L0");
-   if( pairUnlike[2] )  SetInput("MUON_Unlike_All_L0");
+   treeD->GetEvent(0);
    
-   if( pairLike[0] )    SetInput("MUON_Like_LPt_L0");
-   if( pairLike[1] )    SetInput("MUON_Like_HPt_L0");
-   if( pairLike[2] )    SetInput("MUON_Like_All_L0");
+   AliMUONGlobalTrigger* globalTrigger = fTriggerStore->Global();
+   if (globalTrigger == 0x0) 
+   { 
+     AliWarning("No Global Trigger available");
+   }
+   else
+   {
+     // set CTP
+     if (globalTrigger->SingleLpt())      SetInput("0MSL");
+     if (globalTrigger->SingleHpt())      SetInput("0MSH");
+     
+     if (globalTrigger->PairUnlikeLpt())  SetInput("0MUL");
+     if (globalTrigger->PairUnlikeHpt())  SetInput("0MUH");
+     
+     if (globalTrigger->PairLikeLpt())    SetInput("0MLL");
+     if (globalTrigger->PairLikeHpt())    SetInput("0MLH");
+   }
+   muonLoader->UnloadDigits();
+   fTriggerStore->Clear();
 }