]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTriggerLut.cxx
Missing new line...
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerLut.cxx
CommitLineData
a9e2aefa 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 **************************************************************************/
cbc57deb 15
88cb7938 16/* $Id$ */
c1651df4 17
3d1463c8 18//-----------------------------------------------------------------------------
19/// \class AliMUONTriggerLut
20///
6ae22475 21/// Local Trigger Look Up Table
22/// reading interface LUT data is stored into TH3S histograms and readout
23/// from the Local Trigger algorithm
890cc210 24///
25/// Histograms structure is :
26/// X 234 bins, 1 to 235 = local board number
27/// Y 31 bins, 0 to 31 = x strip
28/// Z 31 bins, 0 to 31 = x deviation
29/// content = Short_t = y strip mask
30///
31/// overflow bin is used !
32///
3d1463c8 33/// \author Philippe Crochet
34//-----------------------------------------------------------------------------
d1525c79 35
a9e2aefa 36#include "AliMUONTriggerLut.h"
9afd2481 37
8c343c7c 38#include "AliLog.h"
a9e2aefa 39
890cc210 40#include <TFile.h>
41#include <TH3.h>
42#include <TMap.h>
43#include <TObjString.h>
9afd2481 44
5398f946 45/// \cond CLASSIMP
a9e2aefa 46ClassImp(AliMUONTriggerLut)
5398f946 47/// \endcond
a9e2aefa 48
49//----------------------------------------------------------------------
30178c30 50AliMUONTriggerLut::AliMUONTriggerLut()
1657f946 51 : TNamed(),
52 fLptPlus(0),
53 fLptMinu(0),
54 fLptUnde(0),
55 fHptPlus(0),
56 fHptMinu(0),
57 fHptUnde(0),
58 fAptPlus(0),
59 fAptMinu(0),
890cc210 60 fAptUnde(0),
61 fMap(0x0)
30178c30 62{
3d1463c8 63/// ctor
a9e2aefa 64}
1657f946 65
a9e2aefa 66//----------------------------------------------------------------------
9afd2481 67AliMUONTriggerLut::~AliMUONTriggerLut()
68{
5398f946 69/// Destructor
70
a9e2aefa 71 delete fLptPlus;
72 delete fLptMinu;
73 delete fLptUnde;
74 delete fHptPlus;
75 delete fHptMinu;
76 delete fHptUnde;
77 delete fAptPlus;
78 delete fAptMinu;
79 delete fAptUnde;
890cc210 80 delete fMap;
81}
82
83//----------------------------------------------------------------------
84Int_t
85AliMUONTriggerLut::Compare(TH3* h1, TH3* h2) const
86{
87/// Return 0 if both histograms are strictly equal (at the bin-by-bin level)
88
89 AliDebug(1,Form("h1 %s h2 %s",h1 ? h1->GetName() : "null", h2 ? h2->GetName() : "null"));
90
91 if (!h1 || !h2)
92 {
93 return 0;
94 }
95
96 for ( Int_t i = 0; i < h1->GetBufferSize(); ++i )
97 {
98 Double_t x1 = h1->GetBinContent(i);
99 Double_t x2 = h2->GetBinContent(i);
100 if ( x1 != x2 ) return 0;
101 }
102
103 AliDebug(1,"same");
104
105 return 1;
106}
107
108//----------------------------------------------------------------------
109Int_t
110AliMUONTriggerLut::Compare(const TObject* object) const
111{
112/// Return 0 if the two luts are strictly equal
113
114 const AliMUONTriggerLut* lut = static_cast<const AliMUONTriggerLut*>(object);
115
116 Int_t rvLpt(0);
117
118 rvLpt += Compare(fLptPlus,lut->fLptPlus);
119 rvLpt += Compare(fLptMinu,lut->fLptMinu);
120 rvLpt += Compare(fLptUnde,lut->fLptUnde);
121
122 Int_t rvHpt(0);
123
124 rvHpt += Compare(fHptPlus,lut->fHptPlus);
125 rvHpt += Compare(fHptMinu,lut->fHptMinu);
126 rvHpt += Compare(fHptUnde,lut->fHptUnde);
127
128 Int_t rv(0);
129
130 rv += Compare(fAptPlus,lut->fAptPlus);
131 rv += Compare(fAptMinu,lut->fAptMinu);
132 rv += Compare(fAptUnde,lut->fAptUnde);
133
134 AliDebug(1,Form("Same Lpt %d Hpt %d Apt %d",rvLpt,rvHpt,rv));
135
136 if ( rvLpt == 3 && rvHpt == 3 )
137 {
138 return 0;
139 }
140
141 return 1;
a9e2aefa 142}
143
71a2d3aa 144//----------------------------------------------------------------------
145void AliMUONTriggerLut::ReadFromFile(const char* filename)
9afd2481 146{
5398f946 147/// Return output of LuT for corresponding TH3S
148
9afd2481 149 TFile f(filename);
150
151 if ( f.IsZombie() )
152 {
153 AliFatal(Form("Could not open file %s",filename));
154 }
155
1c29e5aa 156 AliDebug(1,Form("filename=%s",filename));
157
1c29e5aa 158 fLptPlus = (TH3*)(f.Get("LptPlus"));
159 fLptMinu = (TH3*)(f.Get("LptMinu"));
160 fLptUnde = (TH3*)(f.Get("LptUnde"));
161 fHptPlus = (TH3*)(f.Get("HptPlus"));
162 fHptMinu = (TH3*)(f.Get("HptMinu"));
163 fHptUnde = (TH3*)(f.Get("HptUnde"));
164 fAptPlus = (TH3*)(f.Get("AptPlus"));
165 fAptMinu = (TH3*)(f.Get("AptMinu"));
166 fAptUnde = (TH3*)(f.Get("AptUnde"));
167
9afd2481 168 // insure we "detach" those histograms from file f
169 fLptPlus->SetDirectory(0);
170 fLptMinu->SetDirectory(0);
171 fLptUnde->SetDirectory(0);
172 fHptPlus->SetDirectory(0);
173 fHptMinu->SetDirectory(0);
174 fHptUnde->SetDirectory(0);
175 fAptPlus->SetDirectory(0);
176 fAptMinu->SetDirectory(0);
177 fAptUnde->SetDirectory(0);
890cc210 178
179 RegisterHistos();
180}
181
182//----------------------------------------------------------------------
183void
184AliMUONTriggerLut::RegisterHistos()
185{
186/// Add histos to our internal map
187
188 Add(fLptPlus);
189 Add(fLptMinu);
190 Add(fLptUnde);
191
192 Add(fHptPlus);
193 Add(fHptMinu);
194 Add(fHptUnde);
195
196 Add(fAptPlus);
197 Add(fAptMinu);
198 Add(fAptUnde);
199}
200
201//----------------------------------------------------------------------
202void
203AliMUONTriggerLut::Add(TH3* h)
204{
205 /// Update internal map
206 if (!fMap)
207 {
208 fMap = new TMap;
209 fMap->SetOwner(kTRUE);
210 }
211
212 if (h) fMap->Add(new TObjString(h->GetName()),h);
213}
214
215//----------------------------------------------------------------------
216void
217AliMUONTriggerLut::SetContent(const char* hname, Int_t icirc, UChar_t istripX,
218 UChar_t idev, Short_t value)
219{
220 /// Set the content of one bin of one histogram
221
222 if (!fMap)
223 {
224 //..........................................circuit/stripX/deviation
225 fLptPlus = new TH3S("LptPlus","LptPlus",234,0,234,31,0,31,31,0,31);
226 fLptMinu = new TH3S("LptMinu","LptMinu",234,0,234,31,0,31,31,0,31);
227 fLptUnde = new TH3S("LptUnde","LptUnde",234,0,234,31,0,31,31,0,31);
228
229 fHptPlus = new TH3S("HptPlus","HptPlus",234,0,234,31,0,31,31,0,31);
230 fHptMinu = new TH3S("HptMinu","HptMinu",234,0,234,31,0,31,31,0,31);
231 fHptUnde = new TH3S("HptUnde","HptUnde",234,0,234,31,0,31,31,0,31);
232
233 RegisterHistos();
234 }
235
236 TH3* h = static_cast<TH3*>(fMap->GetValue(hname));
237
238 Int_t bin = h->GetBin(icirc,istripX,idev);
239 h->SetBinContent(bin,value);
9afd2481 240}
241
a9e2aefa 242//----------------------------------------------------------------------
243void AliMUONTriggerLut::GetLutOutput(Int_t circuit, Int_t xstrip, Int_t idev,
890cc210 244 Int_t ystrip, Int_t lutLpt[2],
245 Int_t lutHpt[2]) const
9afd2481 246{
5398f946 247/// Return output of LuT for corresponding TH3S
d56db588 248
9afd2481 249 if ( !fLptPlus )
250 {
890cc210 251 AliError("LUT not initialized");
252// ReadFromFile("$(ALICE_ROOT)/MUON/data/MUONTriggerLut.root");
d56db588 253 }
9afd2481 254
a9e2aefa 255 Int_t bin;
256 Short_t binc;
257 Int_t mask = GetMask(ystrip); // get ystrip mask
258
259 // Low pt..............................................
9afd2481 260 bin = fLptPlus->GetBin(circuit,xstrip,idev);
261 binc = (Short_t)fLptPlus->GetBinContent(bin);
a9e2aefa 262 if ((binc & mask)!=0) lutLpt[1]=1;
263
9afd2481 264 bin = fLptMinu->GetBin(circuit,xstrip,idev);
265 binc = (Short_t)fLptMinu->GetBinContent(bin);
a9e2aefa 266 if ((binc & mask)!=0) lutLpt[0]=1;
267
9afd2481 268 bin = fLptUnde->GetBin(circuit,xstrip,idev);
269 binc = (Short_t)fLptUnde->GetBinContent(bin);
a9e2aefa 270 if ((binc & mask)!=0) lutLpt[0]=lutLpt[1]=1;
271
272 // High pt.............................................
9afd2481 273 bin = fHptPlus->GetBin(circuit,xstrip,idev);
274 binc = (Short_t)fHptPlus->GetBinContent(bin);
a9e2aefa 275 if ((binc & mask)!=0) lutHpt[1]=1;
276
9afd2481 277 bin = fHptMinu->GetBin(circuit,xstrip,idev);
278 binc = (Short_t)fHptMinu->GetBinContent(bin);
a9e2aefa 279 if ((binc & mask)!=0) lutHpt[0]=1;
280
9afd2481 281 bin = fHptUnde->GetBin(circuit,xstrip,idev);
282 binc = (Short_t)fHptUnde->GetBinContent(bin);
a9e2aefa 283 if ((binc & mask)!=0) lutHpt[0]=lutHpt[1]=1;
6ae22475 284/*
a9e2aefa 285 // All pts.............................................
9afd2481 286 bin = fAptPlus->GetBin(circuit,xstrip,idev);
287 binc = (Short_t)fAptPlus->GetBinContent(bin);
a9e2aefa 288 if ((binc & mask)!=0) lutApt[1]=1;
289
9afd2481 290 bin = fAptMinu->GetBin(circuit,xstrip,idev);
291 binc = (Short_t)fAptMinu->GetBinContent(bin);
a9e2aefa 292 if ((binc & mask)!=0) lutApt[0]=1;
293
9afd2481 294 bin = fAptUnde->GetBin(circuit,xstrip,idev);
295 binc = (Short_t)fAptUnde->GetBinContent(bin);
a9e2aefa 296 if ((binc & mask)!=0) lutApt[0]=lutApt[1]=1;
6ae22475 297*/
a9e2aefa 298}
299
300//----------------------------------------------------------------------
890cc210 301Int_t AliMUONTriggerLut::GetMask(Int_t ystrip) const
9afd2481 302{
5398f946 303/// Return the mask corresponding to ystrip
304
058fe239 305 return (Int_t)(1<<ystrip);
a9e2aefa 306}
307
a9e2aefa 308
309
310
311