]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONTriggerLut.cxx
Coding conventions (Philippe)
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerLut.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 // -----------------------------------
19 // Class AliMUONTriggerLut
20 // -----------------------------------
21 // Local Trigger Look Up Table - reading interface
22 // LUT data is stored into TH3S histograms and readout 
23 // from the Local Trigger algorithm.
24
25 #include "AliMUONTriggerLut.h"
26
27 #include "AliLog.h"
28
29 #include "TFile.h"
30 #include "TH3.h"
31
32 ClassImp(AliMUONTriggerLut)
33
34 //----------------------------------------------------------------------
35 AliMUONTriggerLut::AliMUONTriggerLut() 
36   : TNamed()
37 {
38 // constructor
39   fLptPlus = fLptMinu = fLptUnde = 0;
40   fHptPlus = fHptMinu = fHptUnde = 0;
41   fAptPlus = fAptMinu = fAptUnde = 0;
42 }
43 //----------------------------------------------------------------------
44 AliMUONTriggerLut::~AliMUONTriggerLut() 
45 {
46   // destructor
47   delete fLptPlus;  
48   delete fLptMinu;
49   delete fLptUnde;
50   delete fHptPlus;  
51   delete fHptMinu;
52   delete fHptUnde;
53   delete fAptPlus;  
54   delete fAptMinu;
55   delete fAptUnde;
56 }
57
58 //----------------------------------------------------------------------
59 AliMUONTriggerLut::AliMUONTriggerLut (const AliMUONTriggerLut& theMUONTriggerLut)
60   : TNamed(theMUONTriggerLut)
61 {
62 // Protected copy constructor
63
64   AliFatal("Not implemented.");
65 }
66
67 //----------------------------------------------------------------------
68 AliMUONTriggerLut & 
69 AliMUONTriggerLut::operator=(const AliMUONTriggerLut& rhs)
70 {
71 // Protected assignement operator
72
73   if (this == &rhs) return *this;
74
75   AliFatal( "Not implemented.");
76     
77   return *this;  
78 }
79
80 void
81 AliMUONTriggerLut::ReadFromFile(const char* filename)
82 {
83 // return output of LuT for corresponding TH3S  
84   TFile f(filename);
85   
86   if ( f.IsZombie() )
87   {
88     AliFatal(Form("Could not open file %s",filename));
89   }
90   
91   fLptPlus = (TH3*)(f.Get("LptPlus")->Clone());  
92   fLptMinu = (TH3*)(f.Get("LptMinu")->Clone());
93   fLptUnde = (TH3*)(f.Get("LptUnde")->Clone());
94   fHptPlus = (TH3*)(f.Get("HptPlus")->Clone());  
95   fHptMinu = (TH3*)(f.Get("HptMinu")->Clone());
96   fHptUnde = (TH3*)(f.Get("HptUnde")->Clone());
97   fAptPlus = (TH3*)(f.Get("AptPlus")->Clone());  
98   fAptMinu = (TH3*)(f.Get("AptMinu")->Clone());
99   fAptUnde = (TH3*)(f.Get("AptUnde")->Clone());
100
101   // insure we "detach" those histograms from file f
102   fLptPlus->SetDirectory(0);
103   fLptMinu->SetDirectory(0);
104   fLptUnde->SetDirectory(0);
105   fHptPlus->SetDirectory(0);
106   fHptMinu->SetDirectory(0);
107   fHptUnde->SetDirectory(0);
108   fAptPlus->SetDirectory(0);
109   fAptMinu->SetDirectory(0);
110   fAptUnde->SetDirectory(0);
111 }
112
113 //----------------------------------------------------------------------
114 void AliMUONTriggerLut::GetLutOutput(Int_t circuit, Int_t xstrip, Int_t idev,
115                                      Int_t ystrip, Int_t lutLpt[2], 
116                                      Int_t lutHpt[2], Int_t lutApt[2])
117 {
118   // return output of LuT for corresponding TH3S  
119
120   if ( !fLptPlus )
121   {
122     ReadFromFile("$(ALICE_ROOT)/MUON/data/MUONTriggerLut.root");
123   }
124   
125   Int_t bin;
126   Short_t binc; 
127   Int_t mask = GetMask(ystrip);        // get ystrip mask
128   
129   // Low pt.............................................. 
130   bin    =          fLptPlus->GetBin(circuit,xstrip,idev);
131   binc   = (Short_t)fLptPlus->GetBinContent(bin);
132   if ((binc & mask)!=0) lutLpt[1]=1;
133
134   bin    =          fLptMinu->GetBin(circuit,xstrip,idev);
135   binc   = (Short_t)fLptMinu->GetBinContent(bin);
136   if ((binc & mask)!=0) lutLpt[0]=1;
137   
138   bin    =          fLptUnde->GetBin(circuit,xstrip,idev);
139   binc   = (Short_t)fLptUnde->GetBinContent(bin);
140   if ((binc & mask)!=0) lutLpt[0]=lutLpt[1]=1;
141
142   // High pt.............................................
143   bin    =          fHptPlus->GetBin(circuit,xstrip,idev);
144   binc   = (Short_t)fHptPlus->GetBinContent(bin);
145   if ((binc & mask)!=0) lutHpt[1]=1;
146
147   bin    =          fHptMinu->GetBin(circuit,xstrip,idev);
148   binc   = (Short_t)fHptMinu->GetBinContent(bin);
149   if ((binc & mask)!=0) lutHpt[0]=1;
150
151   bin    =          fHptUnde->GetBin(circuit,xstrip,idev);
152   binc   = (Short_t)fHptUnde->GetBinContent(bin);
153   if ((binc & mask)!=0) lutHpt[0]=lutHpt[1]=1;
154
155   // All pts.............................................
156   bin    =          fAptPlus->GetBin(circuit,xstrip,idev);
157   binc   = (Short_t)fAptPlus->GetBinContent(bin);
158   if ((binc & mask)!=0) lutApt[1]=1;
159
160   bin    =          fAptMinu->GetBin(circuit,xstrip,idev);
161   binc   = (Short_t)fAptMinu->GetBinContent(bin);
162   if ((binc & mask)!=0) lutApt[0]=1;
163
164   bin    =          fAptUnde->GetBin(circuit,xstrip,idev);
165   binc   = (Short_t)fAptUnde->GetBinContent(bin);
166   if ((binc & mask)!=0) lutApt[0]=lutApt[1]=1;
167
168 }
169
170 //----------------------------------------------------------------------
171 Int_t AliMUONTriggerLut::GetMask(Int_t ystrip)
172 {
173   // returns the mask corresponding to ystrip
174   Int_t tabMask[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
175   Int_t mask=0;
176   tabMask[ystrip]=1;
177   for (Int_t i=0; i<16; i++) 
178   {          
179     mask += tabMask[i]<<i; 
180   }
181   return mask;
182 }
183
184
185
186
187