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