2 /// \file MUONReCalcGlobalTrigger.C
3 /// \brief Re-calculate regional/global trigger response from local response.
7 /// MUONReCalcGlobalTrigger("path_to_reconstruction_galice");
9 /// Starting from local responses the macro will re-calculate regional and
10 /// global response and print-out the global trigger decision.
11 /// It is used for comissioning data with cosmics where the global trigger
12 /// was not written in the raw stream.
13 /// The purpose is (for the future) to compare the re-calculated answer with
14 /// the global trigger decision returned by the CTP.
16 /// \author Bogdan Vulpescu
18 #if !defined(__CINT__) || defined(__MAKECINT__)
20 #include "AliCDBManager.h"
22 #include "AliMUONCalibrationData.h"
23 #include "AliMUONTriggerCrateStore.h"
24 #include "AliMUONGlobalTriggerBoard.h"
25 #include "AliMUONDataInterface.h"
26 #include "AliMUONLocalTrigger.h"
27 #include "AliMUONVTriggerStore.h"
28 #include "AliMUONTriggerCrate.h"
29 #include "AliMUONRegionalTriggerBoard.h"
30 #include "AliMUONLocalTriggerBoard.h"
31 #include "AliMUONVCalibParam.h"
32 #include "AliMUONTriggerBoard.h"
35 #include <TIterator.h>
36 #include <TObjArray.h>
41 UShort_t locResp[235];
43 AliMUONCalibrationData *calibData;
44 AliMUONTriggerCrateStore *fCrates;
45 AliMUONGlobalTriggerBoard *fGlobalTriggerBoard;
49 //___________________________________________________________________________
50 void PrintPattBin(Short_t s) {
51 /// binary print-out of the strip patterns
55 for (Int_t i = 15; i >= 0; i--) {
56 mask = (Int_t)TMath::Power(2,i);
57 printf("%1d",(s & mask) >> i);
63 //___________________________________________________________________________
64 void PrintGloBin(UShort_t s) {
65 /// binary print-out of global trigger decision
68 for (Int_t i = 5; i >= 0; i--) {
69 mask = (Int_t)TMath::Power(2,i);
70 printf("%1d",(s & mask) >> i);
76 //___________________________________________________________________________
77 Bool_t ReCalcGlobalTrigger() {
78 /// re-calculate regional/global decision from array of local triggers
81 AliMUONTriggerCrate* cr;
85 fCrates->FirstCrate();
89 while ( ( cr = fCrates->NextCrate() ) ) {
91 if (debug) printf("Crate nr = %2d \n",++irb);
93 TObjArray *boards = cr->Boards();
95 AliMUONRegionalTriggerBoard *regb = (AliMUONRegionalTriggerBoard*)boards->At(0);
100 UShort_t regLocResp[16]; for (Int_t j=0; j<16; j++) regLocResp[j] = 0;
102 for (Int_t j = 1; j < boards->GetEntries(); j++) {
104 TObject *o = boards->At(j);
106 AliMUONLocalTriggerBoard *board = (AliMUONLocalTriggerBoard*)o;
108 if (board->GetNumber() == 0) continue;
111 printf("...Board nr = %2d : ",++nrBoard);
112 printf("%3d %s in slot %2d of crate %s \n",board->GetNumber(),board->GetName(),j,cr->GetName());
115 UShort_t response = locResp[board->GetNumber()];
117 if (debug) printf("......Response = %x \n",response);
120 loLpt = response & 3;
121 loHpt = (response & 12) >> 2;
122 //printf("Response loLpt = %02b loHpt = %02b \n",loLpt,loHpt);
125 regLocResp[j-1] = response;
127 } // local board loop
129 AliMUONVCalibParam* regionalBoardMasks = calibData->RegionalTriggerBoardMasks(irb);
130 UShort_t rmask = static_cast<UShort_t>(regionalBoardMasks->ValueAsInt(0) & 0xFFFF);
132 regb->SetLocalResponse(regLocResp);
134 //for (Int_t j=0; j<16; j++) printf("%3d ",regLocResp[j]);
135 //printf("Reg %2d Response %3d mask %4x\n",irb,regb->GetResponse(),rmask);
143 fGlobalTriggerBoard->Reset();
145 AliMUONVCalibParam* globalBoardMasks = calibData->GlobalTriggerBoardMasks();
146 for ( Int_t i = 0; i < globalBoardMasks->Size(); ++i ) {
147 UShort_t gmask = static_cast<UShort_t>(globalBoardMasks->ValueAsInt(i) & 0xFF);
148 fGlobalTriggerBoard->Mask(i,gmask);
151 fCrates->FirstCrate();
153 UShort_t regional[16];
156 if ( !fCrates->NumberOfCrates() >= 16 ) {
157 printf("Something is wrong : too many crates %d",fCrates->NumberOfCrates());
161 while ( ( cr = fCrates->NextCrate() ) ) {
162 AliMUONTriggerBoard* rb =
163 static_cast<AliMUONTriggerBoard*>(cr->Boards()->At(0));
164 regional[irb] = rb->GetResponse();
168 fGlobalTriggerBoard->SetRegionalResponse(regional);
169 fGlobalTriggerBoard->Response();
171 if (fGlobalTriggerBoard->GetResponse() != 0) {
172 fGlobalTriggerBoard->Scan("");
173 printf("Global trigger response = ");
174 PrintGloBin(fGlobalTriggerBoard->GetResponse());
182 //___________________________________________________________________________
183 void MUONReCalcGlobalTrigger(const char* input) {
184 /// create array of local triggers from the raw data, run the re-calculation
185 /// and print-out the results
191 AliCDBManager* man = AliCDBManager::Instance();
192 man->SetDefaultStorage("local://$ALICE_ROOT");
193 man->SetRun(runNumber);
194 AliMpCDB::LoadDDLStore();
196 calibData = new AliMUONCalibrationData(runNumber);
198 fCrates = new AliMUONTriggerCrateStore;
199 fCrates->ReadFromFile();
200 fGlobalTriggerBoard = new AliMUONGlobalTriggerBoard;
202 AliMUONDataInterface diRec(input);
204 printf("Number of events = %d \n",diRec.NumberOfEvents());
205 Int_t nEvents = diRec.NumberOfEvents();
207 AliMUONLocalTrigger* localTrig;
208 Int_t circ, loLpt, loHpt, lutLpt[2], lutHpt[2];
209 TArrayS xPattern[235];
210 TArrayS yPattern[235];
213 for (Int_t ievent = 0; ievent < nEvents; ++ievent) {
215 for (Int_t i = 0; i < 234; i++) {
219 AliMUONVTriggerStore* triggerStore = diRec.TriggerStore(ievent,"R");
220 TIter nextLocal(triggerStore->CreateLocalIterator());
221 while ( (localTrig = static_cast<AliMUONLocalTrigger*>( nextLocal() )) != NULL ) {
222 circ = localTrig->LoCircuit();
224 loLpt = localTrig->LoLpt();
225 loHpt = localTrig->LoHpt();
227 lutLpt[0] = loLpt & 1;
228 lutLpt[1] = (loLpt & 2) >> 1;
229 lutHpt[0] = loHpt & 1;
230 lutHpt[1] = (loHpt & 2) >> 1;
232 locResp[circ] = lutLpt[0] +
233 static_cast<int>(lutLpt[1]<<1) +
234 static_cast<int>(lutHpt[0]<<2) +
235 static_cast<int>(lutHpt[1]<<3);
237 localTrig->GetXPattern(xPattern[circ]);
238 localTrig->GetYPattern(yPattern[circ]);
241 printf("Event %4d circ %3d loLpt %1d loHpt %1d resp %3d\n",ievent,circ,loLpt,loHpt,locResp[circ]);
244 } // local trigger loop
246 if (ReCalcGlobalTrigger()) {
247 printf("............ for event %5d \n",ievent);
248 for (Int_t ic = 1; ic <= 234; ic++) {
249 if (locResp[ic] != 0) {
250 UShort_t response = locResp[ic];
251 loLpt = response & 3;
252 loHpt = (response & 12) >> 2;
253 printf("............ in circuit %3d loLpt %1d loHpt %1d resp %3d\n",ic,loLpt,loHpt,response);
255 printf(" Pattern X:\n");
256 PrintPattBin(xPattern[ic].At(0));
257 PrintPattBin(xPattern[ic].At(1));
258 PrintPattBin(xPattern[ic].At(2));
259 PrintPattBin(xPattern[ic].At(3));
260 printf(" Pattern Y:\n");
261 PrintPattBin(yPattern[ic].At(0));
262 PrintPattBin(yPattern[ic].At(1));
263 PrintPattBin(yPattern[ic].At(2));
264 PrintPattBin(yPattern[ic].At(3));