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 **************************************************************************/
17 Revision 1.5 2000/10/02 21:28:09 fca
18 Removal of useless dependecies via forward declarations
20 Revision 1.4 2000/10/02 16:58:29 egangler
21 Cleaning of the code :
24 -> some useless includes removed or replaced by "class" statement
26 Revision 1.3 2000/06/25 16:47:43 pcrochet
27 pow replaced by TMath::Power
31 #include "AliMUONTriggerCircuit.h"
32 #include "AliMUONTriggerLut.h"
42 ClassImp(AliMUONTriggerLut)
44 //----------------------------------------------------------------------
45 AliMUONTriggerLut::AliMUONTriggerLut() {
47 fLptPlus = fLptMinu = fLptUnde = 0;
48 fHptPlus = fHptMinu = fHptUnde = 0;
49 fAptPlus = fAptMinu = fAptUnde = 0;
51 //----------------------------------------------------------------------
52 AliMUONTriggerLut::~AliMUONTriggerLut() {
63 fLptPlus = fLptMinu = fLptUnde = 0;
64 fHptPlus = fHptMinu = fHptUnde = 0;
65 fAptPlus = fAptMinu = fAptUnde = 0;
68 //----------------------------------------------------------------------
69 AliMUONTriggerLut::AliMUONTriggerLut (const AliMUONTriggerLut& MUONTriggerLut)
71 // Dummy copy constructor
74 //----------------------------------------------------------------------
75 AliMUONTriggerLut & AliMUONTriggerLut::operator=(const AliMUONTriggerLut& MUONTriggerLut)
77 // Dummy assignment operator
81 //----------------------------------------------------------------------
82 void AliMUONTriggerLut::GetLutOutput(Int_t circuit, Int_t xstrip, Int_t idev,
83 Int_t ystrip, Int_t lutLpt[2],
84 Int_t lutHpt[2], Int_t lutApt[2]){
85 // return output of LuT for corresponding TH3S
87 static TFile *fileLut;
88 static Bool_t first=kTRUE;
90 cout << " opening MUONTriggerLut.root " << "\n";
91 fileLut = new TFile("$(ALICE_ROOT)/MUON/MUONTriggerLut.root","READ");
96 // get the pointers to the TH3S objects of the file
97 TH3S *lptPlus = (TH3S*)gROOT->FindObject("LptPlus");
98 TH3S *lptMinu = (TH3S*)gROOT->FindObject("LptMinu");
99 TH3S *lptUnde = (TH3S*)gROOT->FindObject("LptUnde");
100 TH3S *hptPlus = (TH3S*)gROOT->FindObject("HptPlus");
101 TH3S *hptMinu = (TH3S*)gROOT->FindObject("HptMinu");
102 TH3S *hptUnde = (TH3S*)gROOT->FindObject("HptUnde");
103 TH3S *aptPlus = (TH3S*)gROOT->FindObject("AptPlus");
104 TH3S *aptMinu = (TH3S*)gROOT->FindObject("AptMinu");
105 TH3S *aptUnde = (TH3S*)gROOT->FindObject("AptUnde");
109 Int_t mask = GetMask(ystrip); // get ystrip mask
111 // Low pt..............................................
112 bin = lptPlus->GetBin(circuit,xstrip,idev);
113 binc = (Short_t)lptPlus->GetBinContent(bin);
114 if ((binc & mask)!=0) lutLpt[1]=1;
116 bin = lptMinu->GetBin(circuit,xstrip,idev);
117 binc = (Short_t)lptMinu->GetBinContent(bin);
118 if ((binc & mask)!=0) lutLpt[0]=1;
120 bin = lptUnde->GetBin(circuit,xstrip,idev);
121 binc = (Short_t)lptUnde->GetBinContent(bin);
122 if ((binc & mask)!=0) lutLpt[0]=lutLpt[1]=1;
124 // High pt.............................................
125 bin = hptPlus->GetBin(circuit,xstrip,idev);
126 binc = (Short_t)hptPlus->GetBinContent(bin);
127 if ((binc & mask)!=0) lutHpt[1]=1;
129 bin = hptMinu->GetBin(circuit,xstrip,idev);
130 binc = (Short_t)hptMinu->GetBinContent(bin);
131 if ((binc & mask)!=0) lutHpt[0]=1;
133 bin = hptUnde->GetBin(circuit,xstrip,idev);
134 binc = (Short_t)hptUnde->GetBinContent(bin);
135 if ((binc & mask)!=0) lutHpt[0]=lutHpt[1]=1;
137 // All pts.............................................
138 bin = aptPlus->GetBin(circuit,xstrip,idev);
139 binc = (Short_t)aptPlus->GetBinContent(bin);
140 if ((binc & mask)!=0) lutApt[1]=1;
142 bin = aptMinu->GetBin(circuit,xstrip,idev);
143 binc = (Short_t)aptMinu->GetBinContent(bin);
144 if ((binc & mask)!=0) lutApt[0]=1;
146 bin = aptUnde->GetBin(circuit,xstrip,idev);
147 binc = (Short_t)aptUnde->GetBinContent(bin);
148 if ((binc & mask)!=0) lutApt[0]=lutApt[1]=1;
150 // get back to the first file
151 TTree *tK = gAlice->TreeK();
153 if (tK) file1 = tK->GetCurrentFile();
157 //----------------------------------------------------------------------
158 Int_t AliMUONTriggerLut::GetMask(Int_t ystrip){
159 // returns the mask corresponding to ystrip
160 Int_t tabMask[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
163 for (Int_t i=0; i<16; i++) {
164 mask=mask+Int_t(tabMask[i]*TMath::Power(2,i));
169 //----------------------------------------------------------------------
170 void AliMUONTriggerLut::LoadLut(){
171 // !!!!!!! This is dummy version of the LoadLut method !!!!!!!
172 // !!!!!!! calibration to be done !!!!!!!
173 // 1) Loop on circuit/Xstrip1/deviation/Ystrip
174 // 2) get corresponding ptCal from AliMUONTriggerCircuit
175 // 3) fill histos with cuts on deviation, ptLow and ptHigh
176 // 4) store histos in a file
179 sprintf(fileName,"$(ALICE_ROOT)/MUON/MUONTriggerLut.root");
180 cout << " file name is " << fileName << "\n";
182 // open output file containing histos
183 TFile *hfile = new TFile(fileName,"RECREATE","Trigger Look Up Table");
185 //..........................................circuit/stripX/deviation
186 TH3S *fLptPlus=new TH3S("LptPlus","LptPlus",234,0,234,31,0,31,31,0,31);
187 TH3S *fLptMinu=new TH3S("LptMinu","LptMinu",234,0,234,31,0,31,31,0,31);
188 TH3S *fLptUnde=new TH3S("LptUnde","LptUnde",234,0,234,31,0,31,31,0,31);
190 TH3S *fHptPlus=new TH3S("HptPlus","HptPlus",234,0,234,31,0,31,31,0,31);
191 TH3S *fHptMinu=new TH3S("HptMinu","HptMinu",234,0,234,31,0,31,31,0,31);
192 TH3S *fHptUnde=new TH3S("HptUnde","HptUnde",234,0,234,31,0,31,31,0,31);
194 TH3S *fAptPlus=new TH3S("AptPlus","AptPlus",234,0,234,31,0,31,31,0,31);
195 TH3S *fAptMinu=new TH3S("AptMinu","AptMinu",234,0,234,31,0,31,31,0,31);
196 TH3S *fAptUnde=new TH3S("AptUnde","AptUnde",234,0,234,31,0,31,31,0,31);
198 Float_t lptTreshold=0.75;
199 Float_t hptTreshold=1.75;
201 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
202 AliMUONTriggerCircuit* triggerCircuit;
204 for (Int_t icirc=0; icirc<234; icirc++) {
205 cout << " Loading LuT for circuit " << icirc << " of 234 " << "\n";
206 triggerCircuit = &(pMUON->TriggerCircuit(icirc));
208 for (Int_t istripX=0; istripX<31; istripX++) {
209 for (Int_t idev=0; idev<31; idev++) {
211 Short_t iLptPlus, iLptMinu, iLptUnde;
212 Short_t iHptPlus, iHptMinu, iHptUnde;
213 Short_t iAptPlus, iAptMinu, iAptUnde;
214 iLptPlus = iLptMinu = iLptUnde = 0;
215 iHptPlus = iHptMinu = iHptUnde = 0;
216 iAptPlus = iAptMinu = iAptUnde = 0;
218 for (Int_t istripY=0; istripY<16; istripY++) {
219 Float_t pt=triggerCircuit->PtCal(istripX,idev,istripY);
221 if (pt>lptTreshold) {
222 if (idev<15) iLptMinu=iLptMinu+Int_t(TMath::Power(2,istripY));
223 else if (idev==15) iLptUnde=iLptUnde+Int_t(TMath::Power(2,istripY));
224 else if (idev>15) iLptPlus=iLptPlus+Int_t(TMath::Power(2,istripY));
226 if (pt>hptTreshold) {
227 if (idev<15) iHptMinu=iHptMinu+Int_t(TMath::Power(2,istripY));
228 else if (idev==15) iHptUnde=iHptUnde+Int_t(TMath::Power(2,istripY));
229 else if (idev>15) iHptPlus=iHptPlus+Int_t(TMath::Power(2,istripY));
231 if (idev<15) iAptMinu=iAptMinu+Int_t(TMath::Power(2,istripY));
232 else if (idev==15) iAptUnde=iAptUnde+Int_t(TMath::Power(2,istripY));
233 else if (idev>15) iAptPlus=iAptPlus+Int_t(TMath::Power(2,istripY));
239 bin = fLptMinu->GetBin(icirc,istripX,idev);
240 fLptMinu->SetBinContent(bin,iLptMinu);
241 bin = fLptUnde->GetBin(icirc,istripX,idev);
242 fLptUnde->SetBinContent(bin,iLptUnde);
243 bin = fLptPlus->GetBin(icirc,istripX,idev);
244 fLptPlus->SetBinContent(bin,iLptPlus);
246 bin = fHptMinu->GetBin(icirc,istripX,idev);
247 fHptMinu->SetBinContent(bin,iHptMinu);
248 bin = fHptUnde->GetBin(icirc,istripX,idev);
249 fHptUnde->SetBinContent(bin,iHptUnde);
250 bin = fHptPlus->GetBin(icirc,istripX,idev);
251 fHptPlus->SetBinContent(bin,iHptPlus);
253 bin = fAptMinu->GetBin(icirc,istripX,idev);
254 fAptMinu->SetBinContent(bin,iAptMinu);
255 bin = fAptUnde->GetBin(icirc,istripX,idev);
256 fAptUnde->SetBinContent(bin,iAptUnde);
257 bin = fAptPlus->GetBin(icirc,istripX,idev);
258 fAptPlus->SetBinContent(bin,iAptPlus);