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