AliRoot Core  da88d91 (da88d91)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MUONReCalcGlobalTrigger.C
Go to the documentation of this file.
1 
18 #if !defined(__CINT__) || defined(__MAKECINT__)
19 
20 #include "AliCDBManager.h"
21 #include "AliMpCDB.h"
22 #include "AliMUONCalibrationData.h"
25 #include "AliMUONDataInterface.h"
26 #include "AliMUONLocalTrigger.h"
27 #include "AliMUONVTriggerStore.h"
28 #include "AliMUONTriggerCrate.h"
34 #include "AliMUONVCalibParam.h"
35 #include "AliMUONTriggerBoard.h"
36 
37 #include <TArrayS.h>
38 #include <TObjArray.h>
39 #include <TMath.h>
40 
41 #endif
42 
43 UShort_t locResp[235];
44 
50 
51 TIterator *cratesIterator;
52 
53 Int_t debug;
54 
55 //___________________________________________________________________________
56 void PrintPattBin(Short_t s) {
58 
59  printf(" ");
60  Int_t mask = 0;
61  for (Int_t i = 15; i >= 0; i--) {
62  mask = (Int_t)TMath::Power(2,i);
63  printf("%1d",(s & mask) >> i);
64  }
65  printf(" \n");
66 
67 }
68 
69 //___________________________________________________________________________
70 void PrintGloBin(UShort_t s) {
72 
73  Int_t mask = 0;
74  for (Int_t i = 5; i >= 0; i--) {
75  mask = (Int_t)TMath::Power(2,i);
76  printf("%1d",(s & mask) >> i);
77  }
78  printf(" \n");
79 
80 }
81 
82 //___________________________________________________________________________
83 Bool_t ReCalcGlobalTrigger(TIter *nextCrates) {
85 
86  Int_t loLpt, loHpt;
88 
89  // regional response
90 
91  nextCrates->Reset();
92 
93  Int_t irb(0);
94 
95  while ( ( cr = static_cast<AliMUONTriggerCrate*>(nextCrates->Next()) ) ) {
96 
97  if (debug) printf("Crate nr = %2d \n",++irb);
98 
99  TObjArray *boards = cr->Boards();
100 
102  regb->Reset();
103 
104  Int_t nrBoard = 0;
105 
106  UShort_t regLocResp[16]; for (Int_t j=0; j<16; j++) regLocResp[j] = 0;
107 
108  for (Int_t j = 1; j < boards->GetEntries(); j++) {
109 
110  TObject *o = boards->At(j);
111 
113 
114  if (board->GetNumber() == 0) continue;
115 
116  if (debug) {
117  printf("...Board nr = %2d : ",++nrBoard);
118  printf("%3d %s in slot %2d of crate %s \n",board->GetNumber(),board->GetName(),j,cr->GetName());
119  }
120 
121  UShort_t response = locResp[board->GetNumber()];
122 
123  if (debug) printf("......Response = %x \n",response);
124 
125  if (response != 0) {
126  loLpt = response & 3;
127  loHpt = (response & 12) >> 2;
128  //printf("Response loLpt = %02b loHpt = %02b \n",loLpt,loHpt);
129  }
130 
131  regLocResp[j-1] = response;
132 
133  } // local board loop
134 
135  AliMUONTriggerCrateConfig* crateConfig = regionalConfig->FindTriggerCrate(cr->GetName());
136  UShort_t rmask= crateConfig->GetMask();
137  regb->Mask(rmask);
138  regb->SetLocalResponse(regLocResp);
139  regb->Response();
140  //for (Int_t j=0; j<16; j++) printf("%3d ",regLocResp[j]);
141  //printf("Reg %2d Response %3d mask %4x\n",irb,regb->GetResponse(),rmask);
142 
143  irb++;
144 
145  } // crate loop
146 
147  // global response
148 
149  fGlobalTriggerBoard->Reset();
150 
151  if (!globalConfig)
152  printf("No valid trigger crate configuration in CDB\n");
153 
154  UInt_t gmask = 0;
155 
156  for (Int_t i = 0; i < 4; i++) {
157  gmask = globalConfig->GetGlobalMask(i);
158  fGlobalTriggerBoard->Mask(i,gmask);
159  }
160 
161  nextCrates->Reset();
162 
163  UShort_t regional[16];
164  irb = 0;
165 
166  if ( !fCrates->NumberOfCrates() >= 16 ) {
167  printf("Something is wrong : too many crates %d",fCrates->NumberOfCrates());
168  return kFALSE;
169  }
170 
171  for (Int_t iSide = 0; iSide < 2; iSide++) // right & left side
172  {
173  for (Int_t iReg = 0; iReg < 8; iReg++) // 8 crates/regional boards for each side.
174  {
175  cr = fCrates->Crate(iSide, iReg);
176 
177  AliMUONTriggerBoard* rb =
178  static_cast<AliMUONTriggerBoard*>(cr->Boards()->At(0));
179  regional[irb] = rb->GetResponse();
180  ++irb;
181  }
182  }
183 
184  fGlobalTriggerBoard->SetRegionalResponse(regional);
185  fGlobalTriggerBoard->Response();
186 
187  if (fGlobalTriggerBoard->GetResponse() != 0) {
188  fGlobalTriggerBoard->Scan("");
189  printf("Global trigger response = ");
190  PrintGloBin(fGlobalTriggerBoard->GetResponse());
191  return kTRUE;
192  }
193 
194  return kFALSE;
195 
196 }
197 
198 //___________________________________________________________________________
199 void MUONReCalcGlobalTrigger(const char* input) {
202 
203  debug = 0;
204 
205  Int_t runNumber = 0;
206 
207  AliCDBManager* man = AliCDBManager::Instance();
208  man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
209  man->SetRun(runNumber);
211 
212  calibData = new AliMUONCalibrationData(runNumber);
213 
214  regionalConfig = calibData->RegionalTriggerConfig();
215  globalConfig = calibData->GlobalTriggerCrateConfig();
216 
217  fCrates = new AliMUONTriggerCrateStore;
218  fCrates->ReadFromFile(calibData);
219  cratesIterator = fCrates->CreateCrateIterator();
220  fGlobalTriggerBoard = new AliMUONGlobalTriggerBoard;
221 
222  TIter nextCrates(cratesIterator);
223 
224  AliMUONDataInterface diRec(input);
225 
226  printf("Number of events = %d \n",diRec.NumberOfEvents());
227  Int_t nEvents = diRec.NumberOfEvents();
228 
229  AliMUONLocalTrigger* localTrig;
230  Int_t circ, loLpt, loHpt, lutLpt[2], lutHpt[2];
231  TArrayS xPattern[235];
232  TArrayS yPattern[235];
233 
234  for (Int_t ievent = 0; ievent < nEvents; ++ievent) {
235 
236  for (Int_t i = 0; i < 234; i++) {
237  locResp[i] = 0;
238  }
239 
240  AliMUONVTriggerStore* triggerStore = diRec.TriggerStore(ievent,"R");
241  TIter nextLocal(triggerStore->CreateLocalIterator());
242  while ( (localTrig = static_cast<AliMUONLocalTrigger*>( nextLocal() )) ) {
243 
244  if (localTrig->IsNull()) continue;
245 
246  circ = localTrig->LoCircuit();
247 
248  loLpt = localTrig->LoLpt();
249  loHpt = localTrig->LoHpt();
250 
251  lutLpt[0] = loLpt & 1;
252  lutLpt[1] = (loLpt & 2) >> 1;
253  lutHpt[0] = loHpt & 1;
254  lutHpt[1] = (loHpt & 2) >> 1;
255 
256  locResp[circ] = lutLpt[0] +
257  static_cast<int>(lutLpt[1]<<1) +
258  static_cast<int>(lutHpt[0]<<2) +
259  static_cast<int>(lutHpt[1]<<3);
260 
261  localTrig->GetXPattern(xPattern[circ]);
262  localTrig->GetYPattern(yPattern[circ]);
263 
264  if (debug) {
265  printf("Event %4d circ %3d loLpt %1d loHpt %1d resp %3d\n",ievent,circ,loLpt,loHpt,locResp[circ]);
266  }
267 
268  } // local trigger loop
269 
270  if (ReCalcGlobalTrigger(&nextCrates)) {
271  printf("............ for event %5d \n",ievent);
272  for (Int_t ic = 1; ic <= 234; ic++) {
273  if (locResp[ic] != 0) {
274  UShort_t response = locResp[ic];
275  loLpt = response & 3;
276  loHpt = (response & 12) >> 2;
277  printf("............ in circuit %3d loLpt %1d loHpt %1d resp %3d\n",ic,loLpt,loHpt,response);
278 
279  printf(" Pattern X:\n");
280  PrintPattBin(xPattern[ic].At(0));
281  PrintPattBin(xPattern[ic].At(1));
282  PrintPattBin(xPattern[ic].At(2));
283  PrintPattBin(xPattern[ic].At(3));
284  printf(" Pattern Y:\n");
285  PrintPattBin(yPattern[ic].At(0));
286  PrintPattBin(yPattern[ic].At(1));
287  PrintPattBin(yPattern[ic].At(2));
288  PrintPattBin(yPattern[ic].At(3));
289 
290  }
291  }
292  printf("\n\n");
293  }
294 
295  } // event loop
296 
297  delete fGlobalTriggerBoard;
298  delete fCrates;
299  delete calibData;
300 
301 }
302 
void GetYPattern(TArrayS &array) const
return Y pattern array
void PrintGloBin(UShort_t s)
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
void ReadFromFile(AliMUONCalibrationData *calibData)
The class defines the configuration of global crate.
The class defines the configuration of trigger crate.
virtual TIterator * CreateLocalIterator() const =0
Create iterator on local trigger.
AliMUONRegionalTriggerConfig * RegionalTriggerConfig() const
Get the config for regional trigger.
UShort_t locResp[235]
UInt_t GetGlobalMask(Int_t index) const
Get mask for the global input.
virtual void Scan(Option_t *option) const
scan response of regional boards
#define TObjArray
An easy to use interface to MUON data.
void GetXPattern(TArrayS &array) const
return X pattern array
Int_t LoLpt() const
Return Low pt.
static Bool_t LoadDDLStore(Bool_t warn=false)
Definition: AliMpCDB.cxx:149
AliMUONTriggerCrateStore * fCrates
void Mask(UShort_t mask)
set local boards enable
Regional trigger - real HW algorithm is implemented.
virtual void SetLocalResponse(UShort_t val[16])
Set Local trigger inputs.
Int_t LoHpt() const
Return High p.
TIterator * CreateCrateIterator() const
A container for AliMUONTriggerCrate objects.
Base class of a trigger information store.
virtual void Response()
virtual method for derivated classes
void PrintPattBin(Short_t s)
Trigger board base class.
Reconstructed Local Trigger object.
AliMUONVTriggerStore * TriggerStore(Int_t event, const char *treeLetter="R")
Implementation of local trigger board objects.
AliMUONTriggerCrateConfig * FindTriggerCrate(TString crateName, Bool_t warn=true) const
AliMUONGlobalCrateConfig * GlobalTriggerCrateConfig() const
Get the configuration for the global trigger board.
virtual UShort_t GetResponse() const
Return response.
TIterator * cratesIterator
virtual void Reset()
Reset regional board responses.
void MUONReCalcGlobalTrigger(const char *input)
virtual Int_t GetNumber() const
Return Board number.
AliMUONRegionalTriggerConfig * regionalConfig
virtual void Response()
virtual method for derivated classes
AliMUONCalibrationData * calibData
Single entry point to access MUON calibration data.
virtual void Reset()
virtual method for derivated classes
static Int_t runNumber
Definition: pdc06_config.C:126
virtual TObjArray * Boards()
Return pointer to board objects.
virtual void SetRegionalResponse(UShort_t resp[16])
Set regional board responses.
AliMUONTriggerCrate * Crate(const char *crateName) const
Int_t debug
Bool_t ReCalcGlobalTrigger(TIter *nextCrates)
Int_t LoCircuit() const
Return Circuit number.
The class defines the properties of regional trigger crate.
AliMUONGlobalTriggerBoard * fGlobalTriggerBoard
return kTRUE
Definition: AliFMDv1.cxx:97
AliMUONGlobalCrateConfig * globalConfig
UShort_t GetMask() const
Return mask.
void Mask(Int_t index, UInt_t mask)
Set mask for global input (from regional boards)