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