1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-----------------------------------------------------------------------------
19 /// \class AliMUONTriggerLut
21 /// Local Trigger Look Up Table
22 /// reading interface LUT data is stored into TH3S histograms and readout
23 /// from the Local Trigger algorithm
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
31 /// overflow bin is used !
33 /// \author Philippe Crochet
34 //-----------------------------------------------------------------------------
36 #include "AliMUONTriggerLut.h"
43 #include <TObjString.h>
46 ClassImp(AliMUONTriggerLut)
49 //----------------------------------------------------------------------
50 AliMUONTriggerLut::AliMUONTriggerLut()
66 //----------------------------------------------------------------------
67 AliMUONTriggerLut::~AliMUONTriggerLut()
83 //----------------------------------------------------------------------
85 AliMUONTriggerLut::Compare(TH3* h1, TH3* h2) const
87 /// Return 0 if both histograms are strictly equal (at the bin-by-bin level)
89 AliDebug(1,Form("h1 %s h2 %s",h1 ? h1->GetName() : "null", h2 ? h2->GetName() : "null"));
96 for ( Int_t i = 0; i < h1->GetBufferSize(); ++i )
98 Double_t x1 = h1->GetBinContent(i);
99 Double_t x2 = h2->GetBinContent(i);
100 if ( x1 != x2 ) return 0;
108 //----------------------------------------------------------------------
110 AliMUONTriggerLut::Compare(const TObject* object) const
112 /// Return 0 if the two luts are strictly equal
114 const AliMUONTriggerLut* lut = static_cast<const AliMUONTriggerLut*>(object);
118 rvLpt += Compare(fLptPlus,lut->fLptPlus);
119 rvLpt += Compare(fLptMinu,lut->fLptMinu);
120 rvLpt += Compare(fLptUnde,lut->fLptUnde);
124 rvHpt += Compare(fHptPlus,lut->fHptPlus);
125 rvHpt += Compare(fHptMinu,lut->fHptMinu);
126 rvHpt += Compare(fHptUnde,lut->fHptUnde);
130 rv += Compare(fAptPlus,lut->fAptPlus);
131 rv += Compare(fAptMinu,lut->fAptMinu);
132 rv += Compare(fAptUnde,lut->fAptUnde);
134 AliDebug(1,Form("Same Lpt %d Hpt %d Apt %d",rvLpt,rvHpt,rv));
136 if ( rvLpt == 3 && rvHpt == 3 )
144 //----------------------------------------------------------------------
145 void AliMUONTriggerLut::ReadFromFile(const char* filename)
147 /// Return output of LuT for corresponding TH3S
153 AliFatal(Form("Could not open file %s",filename));
156 AliDebug(1,Form("filename=%s",filename));
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"));
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);
182 //----------------------------------------------------------------------
184 AliMUONTriggerLut::RegisterHistos()
186 /// Add histos to our internal map
201 //----------------------------------------------------------------------
203 AliMUONTriggerLut::Add(TH3* h)
205 /// Update internal map
209 fMap->SetOwner(kTRUE);
212 if (h) fMap->Add(new TObjString(h->GetName()),h);
215 //----------------------------------------------------------------------
217 AliMUONTriggerLut::SetContent(const char* hname, Int_t icirc, UChar_t istripX,
218 UChar_t idev, Short_t value)
220 /// Set the content of one bin of one histogram
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);
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);
236 TH3* h = static_cast<TH3*>(fMap->GetValue(hname));
238 Int_t bin = h->GetBin(icirc,istripX,idev);
239 h->SetBinContent(bin,value);
242 //----------------------------------------------------------------------
243 void AliMUONTriggerLut::GetLutOutput(Int_t circuit, Int_t xstrip, Int_t idev,
244 Int_t ystrip, Int_t lutLpt[2],
245 Int_t lutHpt[2]) const
247 /// Return output of LuT for corresponding TH3S
251 AliError("LUT not initialized");
252 // ReadFromFile("$(ALICE_ROOT)/MUON/data/MUONTriggerLut.root");
257 Int_t mask = GetMask(ystrip); // get ystrip mask
259 // Low pt..............................................
260 bin = fLptPlus->GetBin(circuit,xstrip,idev);
261 binc = (Short_t)fLptPlus->GetBinContent(bin);
262 if ((binc & mask)!=0) lutLpt[1]=1;
264 bin = fLptMinu->GetBin(circuit,xstrip,idev);
265 binc = (Short_t)fLptMinu->GetBinContent(bin);
266 if ((binc & mask)!=0) lutLpt[0]=1;
268 bin = fLptUnde->GetBin(circuit,xstrip,idev);
269 binc = (Short_t)fLptUnde->GetBinContent(bin);
270 if ((binc & mask)!=0) lutLpt[0]=lutLpt[1]=1;
272 // High pt.............................................
273 bin = fHptPlus->GetBin(circuit,xstrip,idev);
274 binc = (Short_t)fHptPlus->GetBinContent(bin);
275 if ((binc & mask)!=0) lutHpt[1]=1;
277 bin = fHptMinu->GetBin(circuit,xstrip,idev);
278 binc = (Short_t)fHptMinu->GetBinContent(bin);
279 if ((binc & mask)!=0) lutHpt[0]=1;
281 bin = fHptUnde->GetBin(circuit,xstrip,idev);
282 binc = (Short_t)fHptUnde->GetBinContent(bin);
283 if ((binc & mask)!=0) lutHpt[0]=lutHpt[1]=1;
285 // All pts.............................................
286 bin = fAptPlus->GetBin(circuit,xstrip,idev);
287 binc = (Short_t)fAptPlus->GetBinContent(bin);
288 if ((binc & mask)!=0) lutApt[1]=1;
290 bin = fAptMinu->GetBin(circuit,xstrip,idev);
291 binc = (Short_t)fAptMinu->GetBinContent(bin);
292 if ((binc & mask)!=0) lutApt[0]=1;
294 bin = fAptUnde->GetBin(circuit,xstrip,idev);
295 binc = (Short_t)fAptUnde->GetBinContent(bin);
296 if ((binc & mask)!=0) lutApt[0]=lutApt[1]=1;
300 //----------------------------------------------------------------------
301 Int_t AliMUONTriggerLut::GetMask(Int_t ystrip) const
303 /// Return the mask corresponding to ystrip
305 return (Int_t)(1<<ystrip);