1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
23 #include "AliMUONTriggerLut.h"
24 #include "AliMUONTriggerCircuit.h"
29 ClassImp(AliMUONTriggerLut)
31 //----------------------------------------------------------------------
32 AliMUONTriggerLut::AliMUONTriggerLut()
36 fLptPlus = fLptMinu = fLptUnde = 0;
37 fHptPlus = fHptMinu = fHptUnde = 0;
38 fAptPlus = fAptMinu = fAptUnde = 0;
40 //----------------------------------------------------------------------
41 AliMUONTriggerLut::~AliMUONTriggerLut() {
52 fLptPlus = fLptMinu = fLptUnde = 0;
53 fHptPlus = fHptMinu = fHptUnde = 0;
54 fAptPlus = fAptMinu = fAptUnde = 0;
57 //----------------------------------------------------------------------
58 AliMUONTriggerLut::AliMUONTriggerLut (const AliMUONTriggerLut& theMUONTriggerLut)
59 : TNamed(theMUONTriggerLut)
61 // Protected copy constructor
63 AliFatal("Not implemented.");
66 //----------------------------------------------------------------------
68 AliMUONTriggerLut::operator=(const AliMUONTriggerLut& rhs)
70 // Protected assignement operator
72 if (this == &rhs) return *this;
74 AliFatal( "Not implemented.");
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
85 static TFile *fileLut;
86 static Bool_t first=kTRUE;
99 // printf(" opening MUONTriggerLut.root \n");
100 fileLut = new TFile("$(ALICE_ROOT)/MUON/data/MUONTriggerLut.root","READ");
101 // get the pointers to the TH3S objects of the file
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");
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);
126 Int_t mask = GetMask(ystrip); // get ystrip mask
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;
133 bin = lptMinu->GetBin(circuit,xstrip,idev);
134 binc = (Short_t)lptMinu->GetBinContent(bin);
135 if ((binc & mask)!=0) lutLpt[0]=1;
137 bin = lptUnde->GetBin(circuit,xstrip,idev);
138 binc = (Short_t)lptUnde->GetBinContent(bin);
139 if ((binc & mask)!=0) lutLpt[0]=lutLpt[1]=1;
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;
146 bin = hptMinu->GetBin(circuit,xstrip,idev);
147 binc = (Short_t)hptMinu->GetBinContent(bin);
148 if ((binc & mask)!=0) lutHpt[0]=1;
150 bin = hptUnde->GetBin(circuit,xstrip,idev);
151 binc = (Short_t)hptUnde->GetBinContent(bin);
152 if ((binc & mask)!=0) lutHpt[0]=lutHpt[1]=1;
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;
159 bin = aptMinu->GetBin(circuit,xstrip,idev);
160 binc = (Short_t)aptMinu->GetBinContent(bin);
161 if ((binc & mask)!=0) lutApt[0]=1;
163 bin = aptUnde->GetBin(circuit,xstrip,idev);
164 binc = (Short_t)aptUnde->GetBinContent(bin);
165 if ((binc & mask)!=0) lutApt[0]=lutApt[1]=1;
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};
175 for (Int_t i=0; i<16; i++) {
176 mask=mask+Int_t(tabMask[i]<<i);
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
191 sprintf(fileName,"$(ALICE_ROOT)/MUON/data/MUONTriggerLut.root");
192 printf(" file name is %s\n",fileName);
194 // open output file containing histos
195 TFile *hfile = new TFile(fileName,"RECREATE","Trigger Look Up Table");
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);
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);
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);
210 Float_t lptTreshold=0.75;
211 Float_t hptTreshold=1.75;
213 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
214 AliMUONTriggerCircuit* triggerCircuit;
216 for (Int_t icirc=0; icirc<234; icirc++) {
217 printf(" Loading LuT for circuit %d \n",icirc);
218 triggerCircuit = &(pMUON->TriggerCircuit(icirc));
220 for (Int_t istripX=0; istripX<31; istripX++) {
221 for (Int_t idev=0; idev<31; idev++) {
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;
230 for (Int_t istripY=0; istripY<16; istripY++) {
231 Float_t pt=triggerCircuit->PtCal(istripX,idev,istripY);
233 if (pt>lptTreshold) {
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));
238 if (pt>hptTreshold) {
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));
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));
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);
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);
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);