]>
Commit | Line | Data |
---|---|---|
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 | |
30178c30 | 18 | #include <TMath.h> |
19 | #include <TFile.h> | |
20 | #include <TROOT.h> | |
21 | #include <TH3.h> | |
22 | ||
a9e2aefa | 23 | #include "AliMUONTriggerLut.h" |
30178c30 | 24 | #include "AliMUONTriggerCircuit.h" |
a9e2aefa | 25 | #include "AliRun.h" |
26 | #include "AliMUON.h" | |
8c343c7c | 27 | #include "AliLog.h" |
a9e2aefa | 28 | |
29 | ClassImp(AliMUONTriggerLut) | |
30 | ||
31 | //---------------------------------------------------------------------- | |
30178c30 | 32 | AliMUONTriggerLut::AliMUONTriggerLut() |
33 | : TNamed() | |
34 | { | |
a9e2aefa | 35 | // constructor |
36 | fLptPlus = fLptMinu = fLptUnde = 0; | |
37 | fHptPlus = fHptMinu = fHptUnde = 0; | |
38 | fAptPlus = fAptMinu = fAptUnde = 0; | |
39 | } | |
40 | //---------------------------------------------------------------------- | |
41 | AliMUONTriggerLut::~AliMUONTriggerLut() { | |
42 | // destructor | |
43 | delete fLptPlus; | |
44 | delete fLptMinu; | |
45 | delete fLptUnde; | |
46 | delete fHptPlus; | |
47 | delete fHptMinu; | |
48 | delete fHptUnde; | |
49 | delete fAptPlus; | |
50 | delete fAptMinu; | |
51 | delete fAptUnde; | |
52 | fLptPlus = fLptMinu = fLptUnde = 0; | |
53 | fHptPlus = fHptMinu = fHptUnde = 0; | |
54 | fAptPlus = fAptMinu = fAptUnde = 0; | |
55 | } | |
56 | ||
57 | //---------------------------------------------------------------------- | |
30178c30 | 58 | AliMUONTriggerLut::AliMUONTriggerLut (const AliMUONTriggerLut& theMUONTriggerLut) |
59 | : TNamed(theMUONTriggerLut) | |
a9e2aefa | 60 | { |
30178c30 | 61 | // Protected copy constructor |
62 | ||
8c343c7c | 63 | AliFatal("Not implemented."); |
a9e2aefa | 64 | } |
65 | ||
66 | //---------------------------------------------------------------------- | |
30178c30 | 67 | AliMUONTriggerLut & |
68 | AliMUONTriggerLut::operator=(const AliMUONTriggerLut& rhs) | |
a9e2aefa | 69 | { |
30178c30 | 70 | // Protected assignement operator |
71 | ||
72 | if (this == &rhs) return *this; | |
73 | ||
8c343c7c | 74 | AliFatal( "Not implemented."); |
30178c30 | 75 | |
76 | return *this; | |
a9e2aefa | 77 | } |
78 | ||
79 | //---------------------------------------------------------------------- | |
80 | void AliMUONTriggerLut::GetLutOutput(Int_t circuit, Int_t xstrip, Int_t idev, | |
81 | Int_t ystrip, Int_t lutLpt[2], | |
82 | Int_t lutHpt[2], Int_t lutApt[2]){ | |
83 | // return output of LuT for corresponding TH3S | |
84 | ||
85 | static TFile *fileLut; | |
86 | static Bool_t first=kTRUE; | |
d56db588 | 87 | static TH3S *lptPlus; |
88 | static TH3S *lptMinu; | |
89 | static TH3S *lptUnde; | |
90 | static TH3S *hptPlus; | |
91 | static TH3S *hptMinu; | |
92 | static TH3S *hptUnde; | |
93 | static TH3S *aptPlus; | |
94 | static TH3S *aptMinu; | |
95 | static TH3S *aptUnde; | |
96 | ||
a9e2aefa | 97 | if(first) { |
d56db588 | 98 | first=kFALSE; |
19dd5b2f | 99 | // printf(" opening MUONTriggerLut.root \n"); |
fbf24ab4 | 100 | fileLut = new TFile("$(ALICE_ROOT)/MUON/data/MUONTriggerLut.root","READ"); |
a9e2aefa | 101 | // get the pointers to the TH3S objects of the file |
d56db588 | 102 | lptPlus = (TH3S*)gROOT->FindObject("LptPlus"); |
103 | lptMinu = (TH3S*)gROOT->FindObject("LptMinu"); | |
104 | lptUnde = (TH3S*)gROOT->FindObject("LptUnde"); | |
105 | hptPlus = (TH3S*)gROOT->FindObject("HptPlus"); | |
106 | hptMinu = (TH3S*)gROOT->FindObject("HptMinu"); | |
107 | hptUnde = (TH3S*)gROOT->FindObject("HptUnde"); | |
108 | aptPlus = (TH3S*)gROOT->FindObject("AptPlus"); | |
109 | aptMinu = (TH3S*)gROOT->FindObject("AptMinu"); | |
110 | aptUnde = (TH3S*)gROOT->FindObject("AptUnde"); | |
111 | ||
112 | lptPlus->SetDirectory(0); | |
113 | lptMinu->SetDirectory(0); | |
114 | lptUnde->SetDirectory(0); | |
115 | hptPlus->SetDirectory(0); | |
116 | hptMinu->SetDirectory(0); | |
117 | hptUnde->SetDirectory(0); | |
118 | aptPlus->SetDirectory(0); | |
119 | aptMinu->SetDirectory(0); | |
120 | aptUnde->SetDirectory(0); | |
121 | delete fileLut; | |
122 | } | |
a9e2aefa | 123 | |
124 | Int_t bin; | |
125 | Short_t binc; | |
126 | Int_t mask = GetMask(ystrip); // get ystrip mask | |
127 | ||
128 | // Low pt.............................................. | |
129 | bin = lptPlus->GetBin(circuit,xstrip,idev); | |
130 | binc = (Short_t)lptPlus->GetBinContent(bin); | |
131 | if ((binc & mask)!=0) lutLpt[1]=1; | |
132 | ||
133 | bin = lptMinu->GetBin(circuit,xstrip,idev); | |
134 | binc = (Short_t)lptMinu->GetBinContent(bin); | |
135 | if ((binc & mask)!=0) lutLpt[0]=1; | |
136 | ||
137 | bin = lptUnde->GetBin(circuit,xstrip,idev); | |
138 | binc = (Short_t)lptUnde->GetBinContent(bin); | |
139 | if ((binc & mask)!=0) lutLpt[0]=lutLpt[1]=1; | |
140 | ||
141 | // High pt............................................. | |
142 | bin = hptPlus->GetBin(circuit,xstrip,idev); | |
143 | binc = (Short_t)hptPlus->GetBinContent(bin); | |
144 | if ((binc & mask)!=0) lutHpt[1]=1; | |
145 | ||
146 | bin = hptMinu->GetBin(circuit,xstrip,idev); | |
147 | binc = (Short_t)hptMinu->GetBinContent(bin); | |
148 | if ((binc & mask)!=0) lutHpt[0]=1; | |
149 | ||
150 | bin = hptUnde->GetBin(circuit,xstrip,idev); | |
151 | binc = (Short_t)hptUnde->GetBinContent(bin); | |
152 | if ((binc & mask)!=0) lutHpt[0]=lutHpt[1]=1; | |
153 | ||
154 | // All pts............................................. | |
155 | bin = aptPlus->GetBin(circuit,xstrip,idev); | |
156 | binc = (Short_t)aptPlus->GetBinContent(bin); | |
157 | if ((binc & mask)!=0) lutApt[1]=1; | |
158 | ||
159 | bin = aptMinu->GetBin(circuit,xstrip,idev); | |
160 | binc = (Short_t)aptMinu->GetBinContent(bin); | |
161 | if ((binc & mask)!=0) lutApt[0]=1; | |
162 | ||
163 | bin = aptUnde->GetBin(circuit,xstrip,idev); | |
164 | binc = (Short_t)aptUnde->GetBinContent(bin); | |
165 | if ((binc & mask)!=0) lutApt[0]=lutApt[1]=1; | |
166 | ||
a9e2aefa | 167 | } |
168 | ||
169 | //---------------------------------------------------------------------- | |
170 | Int_t AliMUONTriggerLut::GetMask(Int_t ystrip){ | |
171 | // returns the mask corresponding to ystrip | |
172 | Int_t tabMask[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; | |
173 | Int_t mask=0; | |
174 | tabMask[ystrip]=1; | |
175 | for (Int_t i=0; i<16; i++) { | |
a04ce845 | 176 | mask=mask+Int_t(tabMask[i]<<i); |
a9e2aefa | 177 | } |
178 | return mask; | |
179 | } | |
180 | ||
181 | //---------------------------------------------------------------------- | |
182 | void AliMUONTriggerLut::LoadLut(){ | |
183 | // !!!!!!! This is dummy version of the LoadLut method !!!!!!! | |
184 | // !!!!!!! calibration to be done !!!!!!! | |
185 | // 1) Loop on circuit/Xstrip1/deviation/Ystrip | |
186 | // 2) get corresponding ptCal from AliMUONTriggerCircuit | |
187 | // 3) fill histos with cuts on deviation, ptLow and ptHigh | |
188 | // 4) store histos in a file | |
189 | ||
190 | char fileName[60]; | |
fbf24ab4 | 191 | sprintf(fileName,"$(ALICE_ROOT)/MUON/data/MUONTriggerLut.root"); |
cbc57deb | 192 | printf(" file name is %s\n",fileName); |
a9e2aefa | 193 | |
194 | // open output file containing histos | |
195 | TFile *hfile = new TFile(fileName,"RECREATE","Trigger Look Up Table"); | |
196 | ||
197 | //..........................................circuit/stripX/deviation | |
198 | TH3S *fLptPlus=new TH3S("LptPlus","LptPlus",234,0,234,31,0,31,31,0,31); | |
199 | TH3S *fLptMinu=new TH3S("LptMinu","LptMinu",234,0,234,31,0,31,31,0,31); | |
200 | TH3S *fLptUnde=new TH3S("LptUnde","LptUnde",234,0,234,31,0,31,31,0,31); | |
201 | ||
202 | TH3S *fHptPlus=new TH3S("HptPlus","HptPlus",234,0,234,31,0,31,31,0,31); | |
203 | TH3S *fHptMinu=new TH3S("HptMinu","HptMinu",234,0,234,31,0,31,31,0,31); | |
204 | TH3S *fHptUnde=new TH3S("HptUnde","HptUnde",234,0,234,31,0,31,31,0,31); | |
205 | ||
206 | TH3S *fAptPlus=new TH3S("AptPlus","AptPlus",234,0,234,31,0,31,31,0,31); | |
207 | TH3S *fAptMinu=new TH3S("AptMinu","AptMinu",234,0,234,31,0,31,31,0,31); | |
208 | TH3S *fAptUnde=new TH3S("AptUnde","AptUnde",234,0,234,31,0,31,31,0,31); | |
209 | ||
210 | Float_t lptTreshold=0.75; | |
211 | Float_t hptTreshold=1.75; | |
212 | ||
213 | AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON"); | |
214 | AliMUONTriggerCircuit* triggerCircuit; | |
215 | ||
216 | for (Int_t icirc=0; icirc<234; icirc++) { | |
cbc57deb | 217 | printf(" Loading LuT for circuit %d \n",icirc); |
a9e2aefa | 218 | triggerCircuit = &(pMUON->TriggerCircuit(icirc)); |
219 | ||
220 | for (Int_t istripX=0; istripX<31; istripX++) { | |
221 | for (Int_t idev=0; idev<31; idev++) { | |
222 | ||
223 | Short_t iLptPlus, iLptMinu, iLptUnde; | |
224 | Short_t iHptPlus, iHptMinu, iHptUnde; | |
225 | Short_t iAptPlus, iAptMinu, iAptUnde; | |
226 | iLptPlus = iLptMinu = iLptUnde = 0; | |
227 | iHptPlus = iHptMinu = iHptUnde = 0; | |
228 | iAptPlus = iAptMinu = iAptUnde = 0; | |
229 | ||
230 | for (Int_t istripY=0; istripY<16; istripY++) { | |
231 | Float_t pt=triggerCircuit->PtCal(istripX,idev,istripY); | |
232 | ||
233 | if (pt>lptTreshold) { | |
c1651df4 | 234 | if (idev<15) iLptMinu=iLptMinu+Int_t(TMath::Power(2,istripY)); |
235 | else if (idev==15) iLptUnde=iLptUnde+Int_t(TMath::Power(2,istripY)); | |
236 | else if (idev>15) iLptPlus=iLptPlus+Int_t(TMath::Power(2,istripY)); | |
a9e2aefa | 237 | } |
238 | if (pt>hptTreshold) { | |
c1651df4 | 239 | if (idev<15) iHptMinu=iHptMinu+Int_t(TMath::Power(2,istripY)); |
240 | else if (idev==15) iHptUnde=iHptUnde+Int_t(TMath::Power(2,istripY)); | |
241 | else if (idev>15) iHptPlus=iHptPlus+Int_t(TMath::Power(2,istripY)); | |
a9e2aefa | 242 | } |
c1651df4 | 243 | if (idev<15) iAptMinu=iAptMinu+Int_t(TMath::Power(2,istripY)); |
244 | else if (idev==15) iAptUnde=iAptUnde+Int_t(TMath::Power(2,istripY)); | |
245 | else if (idev>15) iAptPlus=iAptPlus+Int_t(TMath::Power(2,istripY)); | |
a9e2aefa | 246 | |
247 | } // loop on istripY | |
248 | ||
249 | Int_t bin; | |
250 | ||
251 | bin = fLptMinu->GetBin(icirc,istripX,idev); | |
252 | fLptMinu->SetBinContent(bin,iLptMinu); | |
253 | bin = fLptUnde->GetBin(icirc,istripX,idev); | |
254 | fLptUnde->SetBinContent(bin,iLptUnde); | |
255 | bin = fLptPlus->GetBin(icirc,istripX,idev); | |
256 | fLptPlus->SetBinContent(bin,iLptPlus); | |
257 | ||
258 | bin = fHptMinu->GetBin(icirc,istripX,idev); | |
259 | fHptMinu->SetBinContent(bin,iHptMinu); | |
260 | bin = fHptUnde->GetBin(icirc,istripX,idev); | |
261 | fHptUnde->SetBinContent(bin,iHptUnde); | |
262 | bin = fHptPlus->GetBin(icirc,istripX,idev); | |
263 | fHptPlus->SetBinContent(bin,iHptPlus); | |
264 | ||
265 | bin = fAptMinu->GetBin(icirc,istripX,idev); | |
266 | fAptMinu->SetBinContent(bin,iAptMinu); | |
267 | bin = fAptUnde->GetBin(icirc,istripX,idev); | |
268 | fAptUnde->SetBinContent(bin,iAptUnde); | |
269 | bin = fAptPlus->GetBin(icirc,istripX,idev); | |
270 | fAptPlus->SetBinContent(bin,iAptPlus); | |
271 | ||
272 | } // loop on idev | |
273 | } // loop on istripX | |
274 | } // loop on circuit | |
275 | ||
276 | hfile->Write(); | |
277 | hfile->Close(); | |
278 | } | |
279 | ||
280 | ||
281 | ||
282 | ||
283 | ||
284 | ||
285 |