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