]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONTriggerLut.cxx
New class of global trigger boards
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerLut.cxx
index 8b3081ea6e8b8ec8a85ed647c15cac7af10ec783..f6a9ccef4ae133779965805ea68629510e798736 100644 (file)
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
-/*
 
+/* $Id$ */
+
+#include <TMath.h>
+#include <TFile.h>
+#include <TROOT.h>
+#include <TH3.h>
 
-*/
 #include "AliMUONTriggerLut.h"
-#include "TTree.h"
+#include "AliMUONTriggerCircuit.h"
 #include "AliRun.h"
 #include "AliMUON.h"
-#include "AliMUONPoints.h"
-#include "TMath.h"
-#include "TFile.h"
-#include "TH3.h"
-#include "iostream.h"
+#include "AliLog.h"
 
 ClassImp(AliMUONTriggerLut)
 
 //----------------------------------------------------------------------
-AliMUONTriggerLut::AliMUONTriggerLut() {
+AliMUONTriggerLut::AliMUONTriggerLut() 
+  : TNamed()
+{
 // constructor
   fLptPlus = fLptMinu = fLptUnde = 0;
   fHptPlus = fHptMinu = fHptUnde = 0;
@@ -53,16 +55,25 @@ AliMUONTriggerLut::~AliMUONTriggerLut() {
 }
 
 //----------------------------------------------------------------------
-AliMUONTriggerLut::AliMUONTriggerLut (const AliMUONTriggerLut& MUONTriggerLut)
+AliMUONTriggerLut::AliMUONTriggerLut (const AliMUONTriggerLut& theMUONTriggerLut)
+  : TNamed(theMUONTriggerLut)
 {
-// Dummy copy constructor
+// Protected copy constructor
+
+  AliFatal("Not implemented.");
 }
 
 //----------------------------------------------------------------------
-AliMUONTriggerLut & AliMUONTriggerLut::operator=(const AliMUONTriggerLut& MUONTriggerLut)
+AliMUONTriggerLut & 
+AliMUONTriggerLut::operator=(const AliMUONTriggerLut& rhs)
 {
-// Dummy assignment operator
-    return *this;
+// Protected assignement operator
+
+  if (this == &rhs) return *this;
+
+  AliFatal( "Not implemented.");
+    
+  return *this;  
 }
 
 //----------------------------------------------------------------------
@@ -73,23 +84,42 @@ void AliMUONTriggerLut::GetLutOutput(Int_t circuit, Int_t xstrip, Int_t idev,
 
   static TFile *fileLut;
   static Bool_t first=kTRUE;  
+  static TH3S *lptPlus;
+  static TH3S *lptMinu;
+  static TH3S *lptUnde;
+  static TH3S *hptPlus;
+  static TH3S *hptMinu;
+  static TH3S *hptUnde;
+  static TH3S *aptPlus;
+  static TH3S *aptMinu;
+  static TH3S *aptUnde;
+
   if(first) {
-    cout << " opening MUONTriggerLut.root " << "\n";
-    fileLut = new TFile("$(ALICE_ROOT)/MUON/MUONTriggerLut.root","READ");
     first=kFALSE;
-  }
-  fileLut->cd();
-
+    //    printf(" opening MUONTriggerLut.root \n");
+    fileLut = new TFile("$(ALICE_ROOT)/MUON/data/MUONTriggerLut.root","READ");
 // get the pointers to the TH3S objects of the file
-  TH3S *lptPlus = (TH3S*)gROOT->FindObject("LptPlus");  
-  TH3S *lptMinu = (TH3S*)gROOT->FindObject("LptMinu");
-  TH3S *lptUnde = (TH3S*)gROOT->FindObject("LptUnde");
-  TH3S *hptPlus = (TH3S*)gROOT->FindObject("HptPlus");  
-  TH3S *hptMinu = (TH3S*)gROOT->FindObject("HptMinu");
-  TH3S *hptUnde = (TH3S*)gROOT->FindObject("HptUnde");
-  TH3S *aptPlus = (TH3S*)gROOT->FindObject("AptPlus");  
-  TH3S *aptMinu = (TH3S*)gROOT->FindObject("AptMinu");
-  TH3S *aptUnde = (TH3S*)gROOT->FindObject("AptUnde");
+    lptPlus = (TH3S*)gROOT->FindObject("LptPlus");  
+    lptMinu = (TH3S*)gROOT->FindObject("LptMinu");
+    lptUnde = (TH3S*)gROOT->FindObject("LptUnde");
+    hptPlus = (TH3S*)gROOT->FindObject("HptPlus");  
+    hptMinu = (TH3S*)gROOT->FindObject("HptMinu");
+    hptUnde = (TH3S*)gROOT->FindObject("HptUnde");
+    aptPlus = (TH3S*)gROOT->FindObject("AptPlus");  
+    aptMinu = (TH3S*)gROOT->FindObject("AptMinu");
+    aptUnde = (TH3S*)gROOT->FindObject("AptUnde");
+
+    lptPlus->SetDirectory(0);
+    lptMinu->SetDirectory(0);
+    lptUnde->SetDirectory(0);
+    hptPlus->SetDirectory(0);
+    hptMinu->SetDirectory(0);
+    hptUnde->SetDirectory(0);
+    aptPlus->SetDirectory(0);
+    aptMinu->SetDirectory(0);
+    aptUnde->SetDirectory(0);
+    delete fileLut;    
+  }
 
   Int_t bin;
   Short_t binc; 
@@ -134,11 +164,6 @@ void AliMUONTriggerLut::GetLutOutput(Int_t circuit, Int_t xstrip, Int_t idev,
   binc   = (Short_t)aptUnde->GetBinContent(bin);
   if ((binc & mask)!=0) lutApt[0]=lutApt[1]=1;
 
-// get back to the first file
-  TTree *tK = gAlice->TreeK();
-  TFile *file1 = 0;
-  if (tK) file1 = tK->GetCurrentFile();
-  file1->cd();
 }
 
 //----------------------------------------------------------------------
@@ -148,7 +173,7 @@ Int_t AliMUONTriggerLut::GetMask(Int_t ystrip){
   Int_t mask=0;
   tabMask[ystrip]=1;
   for (Int_t i=0; i<16; i++) {          
-    mask=mask+Int_t(tabMask[i]*pow(2,i));   
+    mask=mask+Int_t(tabMask[i]<<i); 
   }
   return mask;
 }
@@ -163,8 +188,8 @@ void AliMUONTriggerLut::LoadLut(){
 // 4) store histos in a file
 
   char fileName[60];
-  sprintf(fileName,"$(ALICE_ROOT)/MUON/MUONTriggerLut.root");
-  cout << " file name is " << fileName << "\n";
+  sprintf(fileName,"$(ALICE_ROOT)/MUON/data/MUONTriggerLut.root");
+  printf(" file name is %s\n",fileName);
 
 // open output file containing histos  
   TFile *hfile = new TFile(fileName,"RECREATE","Trigger Look Up Table");
@@ -189,7 +214,7 @@ void AliMUONTriggerLut::LoadLut(){
   AliMUONTriggerCircuit* triggerCircuit;
 
   for (Int_t icirc=0; icirc<234; icirc++) {
-    cout << " Loading LuT for circuit " << icirc << " of 234 " << "\n";
+    printf(" Loading LuT for circuit %d \n",icirc);
     triggerCircuit = &(pMUON->TriggerCircuit(icirc));                
 
     for (Int_t istripX=0; istripX<31; istripX++) {
@@ -206,18 +231,18 @@ void AliMUONTriggerLut::LoadLut(){
          Float_t pt=triggerCircuit->PtCal(istripX,idev,istripY);
          
          if (pt>lptTreshold) {
-           if (idev<15)       iLptMinu=iLptMinu+Int_t(pow(2,istripY));
-           else if (idev==15) iLptUnde=iLptUnde+Int_t(pow(2,istripY));
-           else if (idev>15)  iLptPlus=iLptPlus+Int_t(pow(2,istripY));
+           if (idev<15)       iLptMinu=iLptMinu+Int_t(TMath::Power(2,istripY));
+           else if (idev==15) iLptUnde=iLptUnde+Int_t(TMath::Power(2,istripY));
+           else if (idev>15)  iLptPlus=iLptPlus+Int_t(TMath::Power(2,istripY));
          }
          if (pt>hptTreshold) {
-           if (idev<15)       iHptMinu=iHptMinu+Int_t(pow(2,istripY));
-           else if (idev==15) iHptUnde=iHptUnde+Int_t(pow(2,istripY));
-           else if (idev>15)  iHptPlus=iHptPlus+Int_t(pow(2,istripY));
+           if (idev<15)       iHptMinu=iHptMinu+Int_t(TMath::Power(2,istripY));
+           else if (idev==15) iHptUnde=iHptUnde+Int_t(TMath::Power(2,istripY));
+           else if (idev>15)  iHptPlus=iHptPlus+Int_t(TMath::Power(2,istripY));
          }
-         if (idev<15)       iAptMinu=iAptMinu+Int_t(pow(2,istripY));
-         else if (idev==15) iAptUnde=iAptUnde+Int_t(pow(2,istripY));
-         else if (idev>15)  iAptPlus=iAptPlus+Int_t(pow(2,istripY));
+         if (idev<15)       iAptMinu=iAptMinu+Int_t(TMath::Power(2,istripY));
+         else if (idev==15) iAptUnde=iAptUnde+Int_t(TMath::Power(2,istripY));
+         else if (idev>15)  iAptPlus=iAptPlus+Int_t(TMath::Power(2,istripY));
 
        } // loop on istripY