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.6 2001/03/20 13:32:37 egangler
20 Revision 1.5 2000/10/02 21:28:09 fca
21 Removal of useless dependecies via forward declarations
23 Revision 1.4 2000/10/02 16:58:29 egangler
24 Cleaning of the code :
27 -> some useless includes removed or replaced by "class" statement
29 Revision 1.3 2000/06/25 16:47:43 pcrochet
30 pow replaced by TMath::Power
34 #include "AliMUONTriggerCircuit.h"
35 #include "AliMUONTriggerLut.h"
43 #include <Riostream.h>
45 ClassImp(AliMUONTriggerLut)
47 //----------------------------------------------------------------------
48 AliMUONTriggerLut::AliMUONTriggerLut() {
50 fLptPlus = fLptMinu = fLptUnde = 0;
51 fHptPlus = fHptMinu = fHptUnde = 0;
52 fAptPlus = fAptMinu = fAptUnde = 0;
54 //----------------------------------------------------------------------
55 AliMUONTriggerLut::~AliMUONTriggerLut() {
66 fLptPlus = fLptMinu = fLptUnde = 0;
67 fHptPlus = fHptMinu = fHptUnde = 0;
68 fAptPlus = fAptMinu = fAptUnde = 0;
71 //----------------------------------------------------------------------
72 AliMUONTriggerLut::AliMUONTriggerLut (const AliMUONTriggerLut& MUONTriggerLut)
74 // Dummy copy constructor
77 //----------------------------------------------------------------------
78 AliMUONTriggerLut & AliMUONTriggerLut::operator=(const AliMUONTriggerLut& MUONTriggerLut)
80 // Dummy assignment operator
84 //----------------------------------------------------------------------
85 void 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
90 static TFile *fileLut;
91 static Bool_t first=kTRUE;
93 cout << " opening MUONTriggerLut.root " << "\n";
94 fileLut = new TFile("$(ALICE_ROOT)/MUON/MUONTriggerLut.root","READ");
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");
112 Int_t mask = GetMask(ystrip); // get ystrip mask
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;
119 bin = lptMinu->GetBin(circuit,xstrip,idev);
120 binc = (Short_t)lptMinu->GetBinContent(bin);
121 if ((binc & mask)!=0) lutLpt[0]=1;
123 bin = lptUnde->GetBin(circuit,xstrip,idev);
124 binc = (Short_t)lptUnde->GetBinContent(bin);
125 if ((binc & mask)!=0) lutLpt[0]=lutLpt[1]=1;
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;
132 bin = hptMinu->GetBin(circuit,xstrip,idev);
133 binc = (Short_t)hptMinu->GetBinContent(bin);
134 if ((binc & mask)!=0) lutHpt[0]=1;
136 bin = hptUnde->GetBin(circuit,xstrip,idev);
137 binc = (Short_t)hptUnde->GetBinContent(bin);
138 if ((binc & mask)!=0) lutHpt[0]=lutHpt[1]=1;
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;
145 bin = aptMinu->GetBin(circuit,xstrip,idev);
146 binc = (Short_t)aptMinu->GetBinContent(bin);
147 if ((binc & mask)!=0) lutApt[0]=1;
149 bin = aptUnde->GetBin(circuit,xstrip,idev);
150 binc = (Short_t)aptUnde->GetBinContent(bin);
151 if ((binc & mask)!=0) lutApt[0]=lutApt[1]=1;
153 // get back to the first file
154 TTree *tK = gAlice->TreeK();
156 if (tK) file1 = tK->GetCurrentFile();
160 //----------------------------------------------------------------------
161 Int_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};
166 for (Int_t i=0; i<16; i++) {
167 mask=mask+Int_t(tabMask[i]*TMath::Power(2,i));
172 //----------------------------------------------------------------------
173 void 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
182 sprintf(fileName,"$(ALICE_ROOT)/MUON/MUONTriggerLut.root");
183 cout << " file name is " << fileName << "\n";
185 // open output file containing histos
186 TFile *hfile = new TFile(fileName,"RECREATE","Trigger Look Up Table");
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);
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);
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);
201 Float_t lptTreshold=0.75;
202 Float_t hptTreshold=1.75;
204 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
205 AliMUONTriggerCircuit* triggerCircuit;
207 for (Int_t icirc=0; icirc<234; icirc++) {
208 cout << " Loading LuT for circuit " << icirc << " of 234 " << "\n";
209 triggerCircuit = &(pMUON->TriggerCircuit(icirc));
211 for (Int_t istripX=0; istripX<31; istripX++) {
212 for (Int_t idev=0; idev<31; idev++) {
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;
221 for (Int_t istripY=0; istripY<16; istripY++) {
222 Float_t pt=triggerCircuit->PtCal(istripX,idev,istripY);
224 if (pt>lptTreshold) {
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));
229 if (pt>hptTreshold) {
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));
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));
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);
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);
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);