]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONTriggerDecision.cxx
Suppressed warning from fkSegmentation->PadByPosition(...)
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerDecision.cxx
index fb29af618e42f9717f68ff639122ae85ab5c0430..8a487c182fdc9bee118dcf29978a3e4444fd00c7 100644 (file)
@@ -29,6 +29,7 @@
 #include "AliRunLoader.h"
 #include "AliLoader.h"
 #include "AliRawReader.h" // for raw data
+#include "AliLog.h"
 
 
 //----------------------------------------------------------------------
@@ -90,15 +91,11 @@ AliMUONTriggerDecision::AliMUONTriggerDecision(AliLoader* loader, Int_t iprint,
   fLoader = loader;
 
   // initialize container
-  if (data == 0)
-    Error("TriggerDecision","No MUONdata for trigger\n");
-  else
+  if (data == 0){
+    AliError("No MUONdata for trigger");
+  }else{
     fMUONData = data;
-
-  // Loading AliRun master
-  AliRunLoader* runloader = fLoader->GetRunLoader();
-  if (runloader->GetAliRun() == 0x0) runloader->LoadgAlice();
-  gAlice = runloader->GetAliRun();
+  }
 
   // getting MUON
   fMUON = (AliMUON*) gAlice->GetDetector("MUON");
@@ -114,6 +111,7 @@ AliMUONTriggerDecision::AliMUONTriggerDecision(AliLoader* loader, Int_t iprint,
   fDigits = new TObjArray(AliMUONConstants::NCh()); //NTriggerCh
   for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) 
     fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),i);
+  fDigitIndices = new TArrayI[AliMUONConstants::NCh()];
 }
 
 //----------------------------------------------------------------------
@@ -125,6 +123,7 @@ AliMUONTriggerDecision::AliMUONTriggerDecision()
     fMUON(0)
 {
 // Default constructor
+  fDigitIndices = NULL;
 }
 
 //----------------------------------------------------------------------
@@ -133,14 +132,17 @@ AliMUONTriggerDecision::AliMUONTriggerDecision(const AliMUONTriggerDecision& rhs
 {
 // Protected copy constructor
 
-  Fatal("AliMUONTriggerDecision", "Not implemented.");
+  AliFatal("Not implemented.");
 }
 
 //----------------------------------------------------------------------
 void AliMUONTriggerDecision::ClearDigits()
 {
-  for ( int i=0;i<AliMUONConstants::NCh();i++ ) 
+  for ( int i=0;i<AliMUONConstants::NCh();i++ )
+  {
     if ((*fDigits)[i]) ((TClonesArray*)fDigits->At(i))->Clear();
+    fDigitIndices[i].Set(0);
+  };
 }
 
 //----------------------------------------------------------------------
@@ -154,13 +156,21 @@ TClonesArray* AliMUONTriggerDecision::Digits(Int_t DetectionPlane)
 }
 
 //_____________________________________________________________________________
-void AliMUONTriggerDecision::AddDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
+void AliMUONTriggerDecision::AddDigit(
+               Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits,
+               Int_t digitindex
+       )
 {
   //
   // Add a MUON digit to the list of Digits of the detection plane id
+  // Also adds the digit index to the corresponding fDigitIndices arrays.
   //
   TClonesArray &ldigits = *Digits(id); 
   new(ldigits[ldigits.GetEntriesFast()]) AliMUONDigit(tracks,charges,digits);
+
+  TArrayI& indices = fDigitIndices[id];
+  indices.Set(indices.GetSize() + 1);
+  indices[indices.GetSize() - 1] = digitindex;
 }
 
 //----------------------------------------------------------------------
@@ -179,6 +189,8 @@ AliMUONTriggerDecision::~AliMUONTriggerDecision()
     delete fDigits;
   }
 
+  if (fDigitIndices)
+    delete [] fDigitIndices;
 }
 
 //----------------------------------------------------------------------
@@ -189,7 +201,7 @@ AliMUONTriggerDecision::operator=(const AliMUONTriggerDecision& rhs)
 
   if (this == &rhs) return *this;
 
-  Fatal("operator=", "Not implemented.");
+  AliFatal("Not implemented.");
     
   return *this;  
 }    
@@ -291,13 +303,10 @@ void AliMUONTriggerDecision::SetBit(){
   AliMUONTriggerCircuit* triggerCircuit;
 
   for (Int_t chamber = 11; chamber < 15; chamber++){
-    //    for (Int_t cathode=1; cathode<3; cathode++){  
-    //     fMUONData->GetCathode(cathode-1);
 
       TClonesArray *muonDigits = Digits(chamber-1);
       Int_t ndigits = muonDigits->GetEntriesFast();
-      if (fDebug>=3)
-       printf("\nFound %d digits in %p %d \n", ndigits, (void*)muonDigits,chamber-1);
+      AliDebug(3,Form("Found %d digits in %p %d", ndigits, (void*)muonDigits,chamber-1));
 
       AliMUONDigit  *mdig;
       
@@ -307,8 +316,7 @@ void AliMUONTriggerDecision::SetBit(){
        Int_t ix=mdig->PadX();
        Int_t iy=mdig->PadY();
        cathode = mdig->Cathode() + 1;
-       if (fDebug>=3)
-       printf("cathode %d ix %d iy %d \n",cathode,ix,iy);
+       AliDebug(3,Form("cathode %d ix %d iy %d ",cathode,ix,iy));
 
 // get the sum of the coded charge 
 // see coding convention in AliMUONChamberTrigger::DisIntegration      
@@ -316,6 +324,7 @@ void AliMUONTriggerDecision::SetBit(){
        for (Int_t icharge=0; icharge<10; icharge++) {
          sumCharge=sumCharge+mdig->TrackCharge(icharge);
        }
+
 // apply condition on soft background  
        Int_t testCharge=sumCharge-(Int_t(sumCharge/10))*10;    
        if(sumCharge<=10||testCharge>0) {         
@@ -327,6 +336,11 @@ void AliMUONTriggerDecision::SetBit(){
          Int_t istrip;
          Int_t nStrip;
 
+          // If I want to fetch the digits as in MUONCheck.C then I need to
+          // know the correct digit index. These were stored in fDigitIndices
+          // by the digitizer so we just need to fetch the correct value.
+          Int_t digitindex = fDigitIndices[chamber-1][digit];
+
          if (cathode==1) {
            switch (chamber)
              {
@@ -334,8 +348,11 @@ void AliMUONTriggerDecision::SetBit(){
                for (icirc=0; icirc<234; icirc++) {               
                  triggerCircuit = (AliMUONTriggerCircuit*) fTriggerCircuit->At(icirc);  
                  for (istrip=0; istrip<16; istrip++) {
-                   if (triggerCircuit->GetXcode(0,istrip)==code) 
+                   if (triggerCircuit->GetXcode(0,istrip)==code)
+                    {
                      fXbit11[icirc][istrip]=1;
+                      DigitFiredCircuit(icirc, cathode-1, chamber-1, digitindex);
+                    };
                  }
                }
                break;
@@ -344,7 +361,10 @@ void AliMUONTriggerDecision::SetBit(){
                  triggerCircuit = (AliMUONTriggerCircuit*)fTriggerCircuit->At(icirc);
                  for (istrip=0; istrip<16; istrip++) {
                    if (triggerCircuit->GetXcode(1,istrip)==code) 
+                    {
                      fXbit12[icirc][istrip]=1;
+                      DigitFiredCircuit(icirc, cathode-1, chamber-1, digitindex);
+                    };
                  }
                }
                break;
@@ -353,7 +373,10 @@ void AliMUONTriggerDecision::SetBit(){
                  triggerCircuit = (AliMUONTriggerCircuit*)fTriggerCircuit->At(icirc); 
                  for (istrip=0; istrip<32; istrip++) {
                    if (triggerCircuit->GetXcode(2,istrip)==code) 
+                    {
                      fXbit21[icirc][istrip]=1;
+                      DigitFiredCircuit(icirc, cathode-1, chamber-1, digitindex);
+                    };
                  }
                }
                break;
@@ -362,7 +385,10 @@ void AliMUONTriggerDecision::SetBit(){
                  triggerCircuit = (AliMUONTriggerCircuit*)fTriggerCircuit->At(icirc);
                  for (istrip=0; istrip<32; istrip++) {
                    if (triggerCircuit->GetXcode(3,istrip)==code) 
+                    {
                      fXbit22[icirc][istrip]=1;             
+                      DigitFiredCircuit(icirc, cathode-1, chamber-1, digitindex);
+                    };
                  }
                }               
                break;
@@ -377,7 +403,10 @@ void AliMUONTriggerDecision::SetBit(){
                  nStrip=triggerCircuit->GetNstripY();
                  for (istrip=0; istrip<nStrip; istrip++) {
                    if (triggerCircuit->GetYcode(0,istrip)==code) 
+                    {
                      fYbit11[icirc][istrip]=1;
+                      DigitFiredCircuit(icirc, cathode-1, chamber-1, digitindex);
+                    };
                  }
                }
                break;
@@ -387,7 +416,10 @@ void AliMUONTriggerDecision::SetBit(){
                  nStrip=triggerCircuit->GetNstripY(); 
                  for (istrip=0; istrip<nStrip; istrip++) {
                    if (triggerCircuit->GetYcode(1,istrip)==code) 
+                    {
                      fYbit12[icirc][istrip]=1;
+                      DigitFiredCircuit(icirc, cathode-1, chamber-1, digitindex);
+                    };
                  }
                }
                break;
@@ -397,7 +429,10 @@ void AliMUONTriggerDecision::SetBit(){
                  nStrip=triggerCircuit->GetNstripY();    
                  for (istrip=0; istrip<nStrip; istrip++) {
                    if (triggerCircuit->GetYcode(2,istrip)==code) 
+                    {
                      fYbit21[icirc][istrip]=1;
+                      DigitFiredCircuit(icirc, cathode-1, chamber-1, digitindex);
+                    };
                  }
                }
                break;
@@ -407,7 +442,10 @@ void AliMUONTriggerDecision::SetBit(){
                  nStrip=triggerCircuit->GetNstripY();    
                  for (istrip=0; istrip<nStrip; istrip++) {
                    if (triggerCircuit->GetYcode(3,istrip)==code) 
+                    {
                      fYbit22[icirc][istrip]=1;                          
+                      DigitFiredCircuit(icirc, cathode-1, chamber-1, digitindex);
+                    };
                  }
                }               
                break;
@@ -416,7 +454,7 @@ void AliMUONTriggerDecision::SetBit(){
        }  // remove soft background
       }   // end loop on digit
       fMUONData->ResetDigits();
-      //    }    // end loop on cathode
+//  }    // end loop on cathode
   }     // end loop on chamber
 }  
 
@@ -742,8 +780,8 @@ void AliMUONTriggerDecision::TrigX(Int_t ch1q[16], Int_t ch2q[16],
  // compare Left & Right deviations
  Int_t tmpLeftDev=0, tmpRightDev=0;
  for (j=0; j<5; j++){
-   tmpLeftDev  = tmpLeftDev + Int_t(leftDev[j]*TMath::Power(2,j)); 
-   tmpRightDev = tmpRightDev + Int_t(rightDev[j]*TMath::Power(2,j)); 
+   tmpLeftDev  = tmpLeftDev + Int_t(leftDev[j]<<j); 
+   tmpRightDev = tmpRightDev + Int_t(rightDev[j]<<j); 
  }
 
  // assign mimimum deviation do dev[][]
@@ -873,8 +911,8 @@ void AliMUONTriggerDecision::Sort2x5(Int_t dev1[6], Int_t dev2[6],
 // returns minimun between dev1 and dev2
  Int_t tmpDev1=0, tmpDev2=0;
  for (Int_t j=0; j<5; j++){
-   tmpDev1 = tmpDev1 + Int_t(dev1[j]*TMath::Power(2,j)); 
-   tmpDev2 = tmpDev2 + Int_t(dev2[j]*TMath::Power(2,j)); 
+   tmpDev1 = tmpDev1 + Int_t(dev1[j]<<j); 
+   tmpDev2 = tmpDev2 + Int_t(dev2[j]<<j); 
  }
  if (tmpDev1 <= tmpDev2 ){
    for (Int_t j=0; j<=5; j++) { minDev[j]=dev1[j];}
@@ -1121,17 +1159,17 @@ void AliMUONTriggerDecision::LocalTrigger(Int_t icirc,
   Int_t signDev=minDev[4];   
   Int_t deviation=0;
   for (i=0; i<4; i++) {          // extract deviation
-    deviation = deviation+Int_t(minDev[i]*TMath::Power(2,i));   
+    deviation = deviation+Int_t(minDev[i]<<i);   
   }
   
   Int_t istripX1Circ=0;
   for (i=0; i<5; i++) {          // extract X1 strip fired 
-    istripX1Circ = istripX1Circ+Int_t(minDevStrip[i]*TMath::Power(2,i));   
+    istripX1Circ = istripX1Circ+Int_t(minDevStrip[i]<<i);   
   }
   
   Int_t iStripY=0;
   for (i=0; i<4; i++) {          // extract Y strip fired 
-    iStripY = iStripY+Int_t(coordY[i]*TMath::Power(2,i));   
+      iStripY = iStripY+Int_t(coordY[i]<<i);   
   }
 
 // trigger or not 
@@ -1396,6 +1434,7 @@ void AliMUONTriggerDecision::GetGlobalTrigger(Int_t singlePlus[3],
 void AliMUONTriggerDecision::Digits2Trigger(){
 // call the Trigger Algorithm and fill TreeD
 
+  ClearDigitNumbers();
 
   fMUONData->ResetTrigger();
   Trigger();   
@@ -1415,9 +1454,9 @@ void AliMUONTriggerDecision::Digits2Trigger(){
       localtr[2] = GetDev(icirc);
       localtr[3] = GetStripY11(icirc);
       for (Int_t i = 0; i < 2; i++) {    // convert the Lut output in 1 digit 
-       localtr[4] += Int_t(loLpt[i]*TMath::Power(2,i));
-       localtr[5] += Int_t(loHpt[i]*TMath::Power(2,i));
-       localtr[6] += Int_t(loApt[i]*TMath::Power(2,i));
+       localtr[4] += Int_t(loLpt[i]<<i);
+       localtr[5] += Int_t(loHpt[i]<<i);
+       localtr[6] += Int_t(loApt[i]<<i);
       }
 
       for (Int_t i = 0; i < 16; i++) {    // convert X/Y bit in bit pattern
@@ -1434,26 +1473,34 @@ void AliMUONTriggerDecision::Digits2Trigger(){
        localtr[14] |= (fYbit22[icirc][i] << i);
       }
 
-      AliMUONLocalTrigger* pLocTrig = new AliMUONLocalTrigger(localtr);
+      AliMUONLocalTrigger* pLocTrig = new AliMUONLocalTrigger(localtr, fDigitNumbers[icirc]);
       fMUONData->AddLocalTrigger(*pLocTrig);  // add a local trigger in the list
     }
   }
 }
 
 //_______________________________________________________________________
-void AliMUONTriggerDecision::Trigger2Trigger() 
+void AliMUONTriggerDecision::ClearDigitNumbers()
 {
-// copy trigger from TreeD to TreeR
+// Clears the fDigitNumbers arrays so that they are all empty.
 
-  fMUONData->SetTreeAddress("GLT");
-  fMUONData->GetTriggerD();
+       for (Int_t i = 0; i < AliMUONConstants::NTriggerCircuit(); i++)
+               fDigitNumbers[i].Set(0);
 }
 
 //_______________________________________________________________________
-void AliMUONTriggerDecision::Trigger2Trigger(AliRawReader* /*rawReader*/) 
+void AliMUONTriggerDecision::DigitFiredCircuit(
+               Int_t circuit, Int_t cathode,
+               Int_t chamber, Int_t digit
+       )
 {
-// call the Trigger Algorithm from raw data and fill TreeR 
-
-   Fatal("Trigger2Trigger","Trigger not implemented for raw data input");
-
+// Registers that the specified digit fired the specified circuit.
+// This digit gets added to an array which will be copied to
+// AliMUONLocalTrigger when such an object is created for each circuit.
+
+       Int_t digitnumber = AliMUONLocalTrigger::EncodeDigitNumber(chamber, cathode, digit);
+       Int_t last = fDigitNumbers[circuit].GetSize();
+       fDigitNumbers[circuit].Set(last + 1);
+       fDigitNumbers[circuit][last] = digitnumber;
 }
+