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"
28 ClassImp(AliMUONTriggerLut)
30 //----------------------------------------------------------------------
31 AliMUONTriggerLut::AliMUONTriggerLut()
35 fLptPlus = fLptMinu = fLptUnde = 0;
36 fHptPlus = fHptMinu = fHptUnde = 0;
37 fAptPlus = fAptMinu = fAptUnde = 0;
39 //----------------------------------------------------------------------
40 AliMUONTriggerLut::~AliMUONTriggerLut() {
51 fLptPlus = fLptMinu = fLptUnde = 0;
52 fHptPlus = fHptMinu = fHptUnde = 0;
53 fAptPlus = fAptMinu = fAptUnde = 0;
56 //----------------------------------------------------------------------
57 AliMUONTriggerLut::AliMUONTriggerLut (const AliMUONTriggerLut& theMUONTriggerLut)
58 : TNamed(theMUONTriggerLut)
60 // Protected copy constructor
62 Fatal("AliMUONTriggerLut", "Not implemented.");
65 //----------------------------------------------------------------------
67 AliMUONTriggerLut::operator=(const AliMUONTriggerLut& rhs)
69 // Protected assignement operator
71 if (this == &rhs) return *this;
73 Fatal("operator=", "Not implemented.");
78 //----------------------------------------------------------------------
79 void 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
84 static TFile *fileLut;
85 static Bool_t first=kTRUE;
87 // printf(" opening MUONTriggerLut.root \n");
88 fileLut = new TFile("$(ALICE_ROOT)/MUON/MUONTriggerLut.root","READ");
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");
106 Int_t mask = GetMask(ystrip); // get ystrip mask
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;
113 bin = lptMinu->GetBin(circuit,xstrip,idev);
114 binc = (Short_t)lptMinu->GetBinContent(bin);
115 if ((binc & mask)!=0) lutLpt[0]=1;
117 bin = lptUnde->GetBin(circuit,xstrip,idev);
118 binc = (Short_t)lptUnde->GetBinContent(bin);
119 if ((binc & mask)!=0) lutLpt[0]=lutLpt[1]=1;
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;
126 bin = hptMinu->GetBin(circuit,xstrip,idev);
127 binc = (Short_t)hptMinu->GetBinContent(bin);
128 if ((binc & mask)!=0) lutHpt[0]=1;
130 bin = hptUnde->GetBin(circuit,xstrip,idev);
131 binc = (Short_t)hptUnde->GetBinContent(bin);
132 if ((binc & mask)!=0) lutHpt[0]=lutHpt[1]=1;
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;
139 bin = aptMinu->GetBin(circuit,xstrip,idev);
140 binc = (Short_t)aptMinu->GetBinContent(bin);
141 if ((binc & mask)!=0) lutApt[0]=1;
143 bin = aptUnde->GetBin(circuit,xstrip,idev);
144 binc = (Short_t)aptUnde->GetBinContent(bin);
145 if ((binc & mask)!=0) lutApt[0]=lutApt[1]=1;
147 // get back to the first file
148 /* no need for this with NewIO
149 TTree *tK = gAlice->TreeK();
151 if (tK) file1 = tK->GetCurrentFile();
156 //----------------------------------------------------------------------
157 Int_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};
162 for (Int_t i=0; i<16; i++) {
163 mask=mask+Int_t(tabMask[i]*TMath::Power(2,i));
168 //----------------------------------------------------------------------
169 void 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
178 sprintf(fileName,"$(ALICE_ROOT)/MUON/MUONTriggerLut.root");
179 printf(" file name is %s\n",fileName);
181 // open output file containing histos
182 TFile *hfile = new TFile(fileName,"RECREATE","Trigger Look Up Table");
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);
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);
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);
197 Float_t lptTreshold=0.75;
198 Float_t hptTreshold=1.75;
200 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
201 AliMUONTriggerCircuit* triggerCircuit;
203 for (Int_t icirc=0; icirc<234; icirc++) {
204 printf(" Loading LuT for circuit %d \n",icirc);
205 triggerCircuit = &(pMUON->TriggerCircuit(icirc));
207 for (Int_t istripX=0; istripX<31; istripX++) {
208 for (Int_t idev=0; idev<31; idev++) {
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;
217 for (Int_t istripY=0; istripY<16; istripY++) {
218 Float_t pt=triggerCircuit->PtCal(istripX,idev,istripY);
220 if (pt>lptTreshold) {
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));
225 if (pt>hptTreshold) {
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));
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));
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);
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);
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);