Changes to compile with Root6 on macosx64
[u/mrichter/AliRoot.git] / TOF / AliTOFTrigger.cxx
CommitLineData
cd82ed2f 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/* $Id$ */
17
18/////////////////////////////////////////////////////////////////////
ee51d470 19//
cd82ed2f 20// Class performing TOF Trigger
21// Cosmic_Multi_muon: Cosmic Multi-Muonic Event Trigger (L0)
22// ppMB: p-p Minimum Bias Event Trigger (L0)
23// UltraPer_Coll: Ultra-Peripheral Collision Event Trigger (L0)
24// High_Mult: High Multiplicity Event Trigger (L0)
25// Jet: Events with Jet Topology Trigger (L1)
26//
ee51d470 27// A.Silenzi: added CTTM map,
28// method to fill LTM matrix from raw data,
29// method to retrieve the TOF pre-trigger for TRD detector
30//
31//
cd82ed2f 32/////////////////////////////////////////////////////////////////////
33
7ca4655f 34#include <TClonesArray.h>
c93255fe 35#include <TTree.h>
372be75e 36#include <TMath.h>
7ca4655f 37
cd82ed2f 38#include "AliLoader.h"
0e46b9ae 39#include "AliLog.h"
cd82ed2f 40#include "AliRunLoader.h"
0e46b9ae 41#include "AliRun.h"
cd82ed2f 42#include "AliTriggerInput.h"
ee51d470 43#include "AliRawReader.h"
0e46b9ae 44
ee51d470 45#include "AliTOFRawStream.h"
46#include "AliTOFrawData.h"
cd82ed2f 47#include "AliTOFdigit.h"
ee51d470 48#include "AliTOFGeometry.h"
0e46b9ae 49#include "AliTOFTrigger.h"
c06f660b 50#include "AliTOFTriggerMask.h"
cd82ed2f 51
c11d3763 52#include "AliCDBManager.h"
53#include "AliCDBEntry.h"
54
55
0e46b9ae 56extern AliRun* gAlice;
cd82ed2f 57
6786addd 58AliTOFTriggerMask* AliTOFTrigger:: fTOFTrigMap=NULL;
59AliTOFTriggerMask* AliTOFTrigger:: fTOFTrigMask=NULL;
cd82ed2f 60//-------------------------------------------------------------------------
61ClassImp(AliTOFTrigger)
62
63//----------------------------------------------------------------------
ee51d470 64 AliTOFTrigger::AliTOFTrigger() :
65 AliTriggerDetector(),
cd82ed2f 66 fHighMultTh(1000),
c06f660b 67 fppMBTh(4),//4:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
68 fMultiMuonTh(4),
cd82ed2f 69 fUPTh(2),
c06f660b 70 fdeltaminpsi(150), //150
71 fdeltamaxpsi(170), //170
cd82ed2f 72 fdeltaminro(70),
73 fdeltamaxro(110),
c06f660b 74 fstripWindow(2),
75 fSel1(0),
76 fSel2(0),
77 fSel3(0),
78 fSel4(0),
79 fNCrateOn(0),
80 fNMaxipadOn(0),
81 fNMaxipadOnAll(0),
372be75e 82 fStartTimeHit(0.0),
83 fTimeWidthTrigger(25.0)
84
cd82ed2f 85{
86 //main ctor
8104fec9 87 for (Int_t i=0;i<kNCTTM;i++) fLTMarray[i] = kFALSE;
88
cd82ed2f 89 for (Int_t i=0;i<kNLTM;i++){
8104fec9 90
cd82ed2f 91 for (Int_t j=0;j<kNLTMchannels;j++){
92 fLTMmatrix[i][j]=kFALSE;
93 }
94 if (i<kNCTTM){
95 for (Int_t j=0;j<kNCTTMchannels;j++){
96 fCTTMmatrixFront[i][j]=kFALSE;
97 fCTTMmatrixBack[i][j]=kFALSE;
98 }
99 }
100 }
c06f660b 101
102 fPowerMask[0] = 1;
103 for(Int_t i=1;i <= kNCTTMchannels;i++){
104 fPowerMask[i] = fPowerMask[i-1]*2;
105 }
106
cd82ed2f 107 SetName("TOF");
108 CreateInputs();
c06f660b 109
6786addd 110 if(!fTOFTrigMap) fTOFTrigMap = new AliTOFTriggerMask();
111
cd82ed2f 112}
ee51d470 113
cd82ed2f 114//----------------------------------------------------------------------
ee51d470 115
372be75e 116AliTOFTrigger::AliTOFTrigger(Int_t HighMultTh, Int_t ppMBTh, Int_t MultiMuonTh, Int_t UPTh, Float_t deltaminpsi, Float_t deltamaxpsi, Float_t deltaminro, Float_t deltamaxro, Int_t stripWindow,Float_t startTimeWindow,Float_t widthTimeWindow) :
ee51d470 117 AliTriggerDetector(),
655e379f 118 fHighMultTh(HighMultTh),
119 fppMBTh(ppMBTh),
120 fMultiMuonTh(MultiMuonTh),
121 fUPTh(UPTh),
122 fdeltaminpsi(deltaminpsi),
123 fdeltamaxpsi(deltamaxpsi),
124 fdeltaminro(deltaminro),
125 fdeltamaxro(deltamaxro),
c06f660b 126 fstripWindow(stripWindow),
127 fSel1(0),
128 fSel2(0),
129 fSel3(0),
130 fSel4(0),
131 fNCrateOn(0),
132 fNMaxipadOn(0),
133 fNMaxipadOnAll(0),
372be75e 134 fStartTimeHit(startTimeWindow),
135 fTimeWidthTrigger(widthTimeWindow)
cd82ed2f 136{
137 //ctor with thresholds for triggers
8104fec9 138 for (Int_t i=0;i<kNCTTM;i++) fLTMarray[i] = kFALSE;
cd82ed2f 139 for (Int_t i=0;i<kNLTM;i++){
140 for (Int_t j=0;j<kNLTMchannels;j++){
141 fLTMmatrix[i][j]=kFALSE;
142 }
143 if (i<kNCTTM){
144 for (Int_t j=0;j<kNCTTMchannels;j++){
145 fCTTMmatrixFront[i][j]=kFALSE;
146 fCTTMmatrixBack[i][j]=kFALSE;
147 }
148 }
149 }
c06f660b 150
151 fPowerMask[0] = 1;
152 for(Int_t i=1;i <= kNCTTMchannels;i++){
153 fPowerMask[i] = fPowerMask[i-1]*2;
154 }
155
cd82ed2f 156 SetName("TOF");
157 CreateInputs();
6786addd 158
159 if(!fTOFTrigMap) fTOFTrigMap = new AliTOFTriggerMask();
cd82ed2f 160}
161
9a838fb7 162
163#if 0 /*** COPY CONSTRUCTOR SUPPRESSED **/
ee51d470 164//____________________________________________________________________________
cd82ed2f 165
655e379f 166AliTOFTrigger::AliTOFTrigger(const AliTOFTrigger & tr):
8a190ba2 167 AliTriggerDetector(tr),
168 fHighMultTh(tr.fHighMultTh),
169 fppMBTh(tr.fppMBTh),
170 fMultiMuonTh(tr.fMultiMuonTh),
171 fUPTh(tr.fUPTh),
172 fdeltaminpsi(tr.fdeltaminpsi),
173 fdeltamaxpsi(tr.fdeltamaxpsi),
174 fdeltaminro(tr.fdeltaminro),
175 fdeltamaxro(tr.fdeltamaxro),
c06f660b 176 fstripWindow(tr.fstripWindow),
177 fSel1(tr.fSel1),
178 fSel2(tr.fSel2),
179 fSel3(tr.fSel3),
180 fSel4(tr.fSel4),
181 fNCrateOn(tr.fNCrateOn),
182 fNMaxipadOn(tr.fNMaxipadOn),
6786addd 183 fNMaxipadOnAll(tr.fNMaxipadOnAll)
cd82ed2f 184{
185 //copy ctor
8104fec9 186 for (Int_t i=0;i<kNCTTM;i++) fLTMarray[i] = kFALSE;
cd82ed2f 187 for (Int_t i=0;i<kNLTM;i++){
188 for (Int_t j=0;j<kNLTMchannels;j++){
189 fLTMmatrix[i][j]=tr.fLTMmatrix[i][j];
190 }
191 if (i<kNCTTM){
192 for (Int_t j=0;j<kNCTTMchannels;j++){
ee51d470 193 fCTTMmatrixFront[i][j]=tr.fCTTMmatrixFront[i][j];
194 fCTTMmatrixBack[i][j]=tr.fCTTMmatrixBack[i][j];
cd82ed2f 195 }
196 }
197 }
c06f660b 198
199 fPowerMask[0] = 1;
200 for(Int_t i=1;i <= kNCTTMchannels;i++){
201 fPowerMask[i] = fPowerMask[i-1]*2;
202 }
203
cd82ed2f 204 SetName(tr.GetName());
ee51d470 205 //fInputs=&(tr.GetInputs());
c06f660b 206 CreateInputs();
207
cd82ed2f 208}
9a838fb7 209#endif /*** COPY CONTRUCTOR SUPPRESSED ***/
cd82ed2f 210
211//----------------------------------------------------------------------
212
213void AliTOFTrigger::CreateInputs()
214{
ee51d470 215 // creating inputs
cd82ed2f 216 // Do not create inputs again!!
ee51d470 217 if( fInputs.GetEntriesFast() > 0 ) return;
218
0d79e946 219 //LoadActiveMask();
c06f660b 220
ee51d470 221 fInputs.AddLast(new AliTriggerInput("TOF_Cosmic_MultiMuon_L0","TOF",0));
222 fInputs.AddLast(new AliTriggerInput("0OIN","TOF",0)); // was "TOF_pp_MB_L0"
c06f660b 223 fInputs.AddLast(new AliTriggerInput("0OM2","TOF",0)); // was "TOF_PbPb_MB2_L0"
224 fInputs.AddLast(new AliTriggerInput("0OM3","TOF",0)); // was "TOF_PbPb_MB3_L0"
225 fInputs.AddLast(new AliTriggerInput("0OUP","TOF",0)); // was "TOF_UltraPer_Coll_L0"
ca3c63cb 226 fInputs.AddLast(new AliTriggerInput("0OMU","TOF",0)); // new trigger (150 < DeltaPhi < 180) and 2 <= N_pad <= 6
ee51d470 227
228 fInputs.AddLast(new AliTriggerInput("0OHM","TOF",0)); // was "TOF_High_Mult_L0"
229 fInputs.AddLast(new AliTriggerInput("TOF_Jet_L1","TOF",0));
230
cd82ed2f 231}
232
233//----------------------------------------------------------------------
ee51d470 234void AliTOFTrigger::Trigger() {
6786addd 235 fTOFTrigMap->ResetMask();
236 if(!fTOFTrigMask) LoadActiveMask();
237
cd82ed2f 238 //triggering method
c06f660b 239 fSel1=0;
240 fSel2=0;
241 fSel3=0;
242 fSel4=0;
c6eeb5c9 243
cd82ed2f 244 CreateLTMMatrix();
372be75e 245
cd82ed2f 246 Int_t nchonFront = 0;
247 Int_t nchonBack = 0;
248 Int_t nchonTot = 0;
c06f660b 249 Int_t nSectOn = 0; // °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
250 Int_t DeSlots = -1;// °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
251 Int_t AntiDeSlots = -1;// °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
cd82ed2f 252 Int_t nchonFrontBack = 0;
253 Int_t nchonFront1 = 0;
254 Int_t nchonBack1 = 0;
255 Int_t nchonFrontBack1 = 0;
256 Int_t mindeltapsi = (Int_t)fdeltaminpsi/10;
257 Int_t maxdeltapsi = (Int_t)fdeltamaxpsi/10;
258 Int_t mindeltaro = (Int_t)fdeltaminro/10;
259 Int_t maxdeltaro = (Int_t)fdeltamaxro/10;
ee51d470 260
cd82ed2f 261 for (Int_t i=0;i<kNCTTM;i++){
262 for (Int_t j=0;j<kNCTTMchannels;j++){
6786addd 263 if (fCTTMmatrixFront[i][j]){
264 nchonFront++;
265 fTOFTrigMap->SetON(i,j);
266 }
cd82ed2f 267 }
268 }
269
270 for (Int_t i=kNCTTM;i<(kNCTTM*2);i++){
271 for (Int_t j=0;j<kNCTTMchannels;j++){
6786addd 272 if (fCTTMmatrixBack[i-kNCTTM][j]){
273 nchonBack++;
274 fTOFTrigMap->SetON(i,j);
275 }
cd82ed2f 276 }
277 }
278
279 nchonTot = nchonFront + nchonBack;
c06f660b 280// fNMaxipadOn = nchonTot;
281 for(Int_t i=0;i<kNCTTM;i++) { if(fLTMarray[i]) nSectOn++; }
cd82ed2f 282
283 //pp Minimum Bias Trigger
284 if (nchonTot >= fppMBTh) {
c6eeb5c9 285 SetInput("0OIN");
c06f660b 286 fSel1=1;
287 //printf("0OIN - MB\n");
288 }
289
290 // PbPb MB
291 if (nchonTot >= 2) {
292 SetInput("0OM2");
293 fSel2=1;
294 }
295 if (nchonTot >= 3) {
296 SetInput("0OM3");
297 fSel3=1;
cd82ed2f 298 }
299
300 //High Multiplicity Trigger
301 if (nchonTot >= fHighMultTh) {
c6eeb5c9 302 SetInput("0OHM");
c06f660b 303 //printf("0OHM - High Mult\n");
cd82ed2f 304 }
305
ee51d470 306
cd82ed2f 307 //MultiMuon Trigger
308 nchonFront = 0;
309 nchonBack = 0;
310 nchonFrontBack = 0;
311
312 Bool_t boolCTTMor = kFALSE;
313
314 for (Int_t i=0;i<(kNCTTM/2);i++){
315 Int_t iopp = i+kNCTTM/2;
316 for (Int_t j=0;j<kNCTTMchannels;j++){
317 if (fCTTMmatrixFront[i][j]){
318 Int_t minj = j-fstripWindow;
319 Int_t maxj = j+fstripWindow;
320 if (minj<0) minj =0;
321 if (maxj>=kNCTTMchannels) maxj = kNCTTMchannels-1;
322 boolCTTMor = kFALSE;
323 for (Int_t k = minj;k<=maxj;k++){
324 boolCTTMor |= fCTTMmatrixFront[iopp][k];
ee51d470 325 }
cd82ed2f 326 if (boolCTTMor) {
327 nchonFront++;
328 }
329 }
ee51d470 330
cd82ed2f 331 if (fCTTMmatrixBack[i][j]){
332 Int_t minj = j-fstripWindow;
333 Int_t maxj = j+fstripWindow;
334 if (minj<0) minj =0;
335 if (maxj>=kNCTTMchannels) maxj =kNCTTMchannels-1;
336 boolCTTMor = kFALSE;
337 for (Int_t k = minj;k<=maxj;k++){
338 boolCTTMor |= fCTTMmatrixBack[iopp][k];
339 }
340 if (boolCTTMor) {
341 nchonBack++;
342 }
343 }
344 }
345 }
346
347 nchonFrontBack = nchonFront+nchonBack;
348
349 nchonFront1 = 0;
350 nchonBack1 = 0;
351 nchonFrontBack1 = 0;
352
353 boolCTTMor = kFALSE;
354 for (Int_t i=0;i<(kNCTTM/2);i++){
355 Int_t i2max = (kNCTTM-1)-i+1;
356 Int_t i2min = (kNCTTM-1)-i-1;
357 if (i2max >=kNCTTM) i2max = kNCTTM-1;
358 if (i2min==i) i2min = kNCTTM-1-i;
359 for (Int_t j=0;j<kNCTTMchannels;j++){
360 Int_t j2min = j-fstripWindow;
361 Int_t j2max = j+fstripWindow;
362 if (j2min<0) j2min =0;
363 if (j2max>=kNCTTMchannels) j2max =kNCTTMchannels-1;
364 if (fCTTMmatrixFront[i][j]){
365 boolCTTMor = kFALSE;
366 for (Int_t i2=i2min;i2<=i2max;i2++){
367 for (Int_t j2 = j2min;j2<=j2max;j2++){
368 boolCTTMor |= fCTTMmatrixFront[i2][j2];
ee51d470 369 }
cd82ed2f 370 if (boolCTTMor) {
371 nchonFront++;
372 }
373 }
374 }
375 if (fCTTMmatrixBack[i][j]){
c06f660b 376 boolCTTMor = kFALSE;
377 for (Int_t i2=i2min;i2<=i2max;i2++){
378 for (Int_t j2 = j2min;j2<=j2max;j2++){
379 boolCTTMor |= fCTTMmatrixBack[i2][j2];
380 }
381 }
382 if (boolCTTMor) {
383 nchonBack++;
cd82ed2f 384 }
cd82ed2f 385 }
386 }
387 }
c06f660b 388
cd82ed2f 389 nchonFrontBack1 = nchonFront1+nchonBack1;
c06f660b 390
cd82ed2f 391 if (nchonFrontBack >= fMultiMuonTh || nchonFrontBack1 >= fMultiMuonTh) {
c06f660b 392 SetInput("TOF_Cosmic_MultiMuon_L0");
cd82ed2f 393 }
c06f660b 394
cd82ed2f 395 //Ultra-Peripheral collision Trigger
c06f660b 396
397 // °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
398 // DeSlots = (k+1)_Array Element - k_Array Element
399 // AntiDeSlots = kNCTTM - DeSlots
400
401 if((!fSel1))// && nchonFront < 4 && nchonBack < 4)
402 {
403 // printf("nHitMaxipad CLASSE: %i \n",fNMaxipadOn);
404 // printf("Total Number per event of Switched-On sectors : %i \n", nSectOn);
405 // printf("mindeltapsi %i \n", mindeltapsi);
406 //printf("maxdeltapsi %i \n", maxdeltapsi);
407 for(Int_t i = 0; i < kNCTTM; i++){
408 if(fLTMarray[i]){
409 // printf(" i-sect On: %i\n",i);
410 for(Int_t j = i+1; j < kNCTTM; j++){
411 if(fLTMarray[j]) {
412 // printf(" j-sect On: %i\n",j);
413 DeSlots = j-i;
414 AntiDeSlots = kNCTTM - DeSlots;
415 //printf("DeSlots = %i \n",DeSlots);
416 //printf("AntiDeSlots = %i \n",AntiDeSlots);
417 if(DeSlots >= mindeltapsi && DeSlots <= maxdeltapsi){
418 fSel4=1;
419 SetInput("0OUP");
420 //printf("trigger On with DeSlot \n");
421 }
422 if(AntiDeSlots >= mindeltapsi && AntiDeSlots <= maxdeltapsi){
423 fSel4=1;
424 SetInput("0OUP");
425 //printf("trigger On with AntiDeSlot \n");
426 }
427
428
429 if(DeSlots >= mindeltaro && DeSlots <= maxdeltaro){
430 fSel4=1;
431 SetInput("0OUP");
432 //printf("trigger On with DeSlot \n");
433 }
434 if(AntiDeSlots >= mindeltaro && AntiDeSlots <= maxdeltaro){
435 fSel4=1;
436 SetInput("0OUP");
437 //printf("trigger On with AntiDeSlot \n");
438 }
439
ca3c63cb 440 if(nchonTot >= 2 && nchonTot <= 6){
9a66e1da 441 if(DeSlots >= 15 && DeSlots <= 18){
ca3c63cb 442 SetInput("0OMU");
443 }
9a66e1da 444 else if(AntiDeSlots >= 15 && AntiDeSlots <= 18){
ca3c63cb 445 SetInput("0OMU");
446 }
447 }
448 }
c06f660b 449 }
cd82ed2f 450 }
cd82ed2f 451 }
c06f660b 452 }
cd82ed2f 453}
ee51d470 454
cd82ed2f 455//-----------------------------------------------------------------------------
ee51d470 456void AliTOFTrigger::CreateLTMMatrix() {
cd82ed2f 457 //creating LTMMatrix
458 //initialization
ee51d470 459 CreateLTMMatrixFromDigits();
0d79e946 460 CreateCTTMMatrix();
ee51d470 461}
462
463//-------------------------------------------------------------------------
464
465void AliTOFTrigger::CreateLTMMatrixFromDigits() {
466 //
467 // Create LTM matrix by TOF digits
468 //
469
470 //initialization
8104fec9 471 for (Int_t i=0;i<kNCTTM;i++) fLTMarray[i]= kFALSE;
cd82ed2f 472 for (Int_t i=0;i<kNLTM;i++){
473 for (Int_t j=0;j<kNLTMchannels;j++){
474 fLTMmatrix[i][j]=kFALSE;
475 }
476 }
5cd96e39 477 for (Int_t i=0;i<kNCTTM;i++){
478 for (Int_t j=0;j<kNCTTMchannels;j++){
479 fCTTMmatrixFront[i][j]=kFALSE;
480 fCTTMmatrixBack[i][j]=kFALSE;
481 }
482 }
483
484
cd82ed2f 485 AliRunLoader *rl;
33c3c91a 486 rl = AliRunLoader::Instance();
ee51d470 487
cd82ed2f 488 Int_t ncurrevent = rl->GetEventNumber();
489 rl->GetEvent(ncurrevent);
ee51d470 490
cd82ed2f 491 AliLoader * tofLoader = rl->GetLoader("TOFLoader");
ee51d470 492
cd82ed2f 493 tofLoader->LoadDigits("read");
494 TTree *treeD = tofLoader->TreeD();
8104fec9 495 if (treeD == 0x0) {
496 AliFatal("AliTOFTrigger: Can not get TreeD");
497 return;
498 }
ee51d470 499
cd82ed2f 500 TBranch *branch = treeD->GetBranch("TOF");
ee51d470 501 if (!branch) {
cd82ed2f 502 AliError("can't get the branch with the TOF digits !");
503 return;
504 }
505 TClonesArray *tofDigits =new TClonesArray("AliTOFdigit", 1000);
506 branch->SetAddress(&tofDigits);
507 treeD->GetEvent(0);
508 Int_t ndigits = tofDigits->GetEntriesFast();
509 Int_t detind[5]; //detector indexes: 0 -> sector
c06f660b 510 // 1 -> plate(modulo)
cd82ed2f 511 // 2 -> strip
512 // 3 -> padz
513 // 4 -> padx
ee51d470 514
cd82ed2f 515 for (Int_t i=0;i<ndigits;i++){
516 AliTOFdigit * digit = (AliTOFdigit*)tofDigits->UncheckedAt(i);
517 detind[0] = digit->GetSector();
518 detind[1] = digit->GetPlate();
519 detind[2] = digit->GetStrip();
520 detind[3] = digit->GetPadz();
521 detind[4] = digit->GetPadx();
ee51d470 522
cd82ed2f 523 Int_t indexLTM[2] = {-1,-1};
524 GetLTMIndex(detind,indexLTM);
525
3b8ba5a3 526 //Float_t timedigit = digit->GetTdc()*AliTOFGeometry::TdcBinWidth()*1E-3; // decalibrated time digit in ns
527 Float_t timedigit = digit->GetTdcND()*AliTOFGeometry::TdcBinWidth()*1E-3; // time digit in ns
372be75e 528
529 Float_t pos[3];
6786addd 530 AliTOFGeometry::GetPosPar(detind, pos);
372be75e 531 Float_t length = 0.;
532 for (Int_t ic = 0; ic < 3; ic++) length += pos[ic] * pos[ic];
533 length = TMath::Sqrt(length);
534 timedigit -= length * 0.0333564095198152043; // subtract the minimal time in ns for the current channel
535
536 if(timedigit > fStartTimeHit - 0.5 && timedigit < fStartTimeHit + fTimeWidthTrigger - 0.5)
537 fLTMmatrix[indexLTM[0]][indexLTM[1]] = kTRUE;
538
c11d3763 539// fLTMarray[indexLTM[0]%36] = kTRUE; //dimensione MAX array 36 = kNCTTM
372be75e 540 }
c06f660b 541
cd82ed2f 542
28751b82 543 tofLoader->UnloadDigits();
ee51d470 544 // rl->UnloadgAlice();
ee51d470 545
cd82ed2f 546}
ee51d470 547
cd82ed2f 548//-----------------------------------------------------------------------------
ee51d470 549
550void AliTOFTrigger::CreateLTMMatrixFromRaw(AliRawReader *fRawReader) {
551 //
552 // Create LTM matrix by TOF raw data
553 //
6786addd 554 fTOFTrigMap->ResetMask();
ee51d470 555
556 //initialization
557 for (Int_t i=0;i<kNLTM;i++){
558 for (Int_t j=0;j<kNLTMchannels;j++){
559 fLTMmatrix[i][j]=kFALSE;
560 }
561 }
5cd96e39 562 for (Int_t i=0;i<kNCTTM;i++){
563 for (Int_t j=0;j<kNCTTMchannels;j++){
564 fCTTMmatrixFront[i][j]=kFALSE;
565 fCTTMmatrixBack[i][j]=kFALSE;
566 }
567 }
ee51d470 568
569 if(fRawReader){
570 AliTOFRawStream * tofRawStream = new AliTOFRawStream();
571
572 Int_t inholes = 0;
573
574 //if(!GetLoader()->TreeS()) {MakeTree("S"); MakeBranch("S");}
575
576 Clear();
577 tofRawStream->SetRawReader(fRawReader);
578
579 //ofstream ftxt;
580 //if (fVerbose==2) ftxt.open("TOFsdigitsRead.txt",ios::app);
581
582 TClonesArray staticRawData("AliTOFrawData",10000);
583 staticRawData.Clear();
584 TClonesArray * clonesRawData = &staticRawData;
585
586 Int_t dummy = -1;
587 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
588 Int_t digit[2];
589 //Int_t track = -1;
590 //Int_t last = -1;
591
592 Int_t indexDDL = 0;
593 Int_t iRawData = 0;
594 AliTOFrawData *tofRawDatum = 0;
595 for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
596
597 fRawReader->Reset();
5cd96e39 598 tofRawStream->LoadRawDataBuffersV2(indexDDL);
ee51d470 599
600 clonesRawData = tofRawStream->GetRawData();
601 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
602 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
603
604 tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
605
606 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
607 if (tofRawDatum->GetTOF()==-1) continue;
608
609 SetBit(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
610 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel());
611
612 dummy = detectorIndex[3];
613 detectorIndex[3] = detectorIndex[4];//padz
614 detectorIndex[4] = dummy;//padx
615
616 digit[0] = tofRawDatum->GetTOF();
617 digit[1] = tofRawDatum->GetTOT();
618
619 dummy = detectorIndex[3];
620 detectorIndex[3] = detectorIndex[4];//padx
621 detectorIndex[4] = dummy;//padz
622
623 // Do not reconstruct anything in the holes
624 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
625 if (detectorIndex[1]==2) { // plate with holes
626 inholes++;
627 continue;
628 }
629 }
630
631 tofRawDatum = 0;
632 } // while loop
633
634 clonesRawData->Clear();
635
636 } // DDL Loop
637
638 //if (fVerbose==2) ftxt.close();
639
640 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
6ec122c0 641 delete tofRawStream;
642 tofRawStream = NULL;
ee51d470 643
644 }
645
646}
6786addd 647//-----------------------------------------------------------------------------
648void AliTOFTrigger::PrepareTOFMapFromRaw(AliRawReader *fRawReader,Int_t deltaBC) {
649 //
650 // Create LTM matrix by TOF raw data
651 //
652 if(!fTOFTrigMap) fTOFTrigMap = new AliTOFTriggerMask();
653 fTOFTrigMap->ResetMask();
654 LoadActiveMask();
655
656 if(fRawReader){
657 AliTOFRawStream * tofRawStream = new AliTOFRawStream();
658
659 tofRawStream->SetRawReader(fRawReader);
660
661 TClonesArray staticRawData("AliTOFrawData",10000);
662 staticRawData.Clear();
663 TClonesArray * clonesRawData = &staticRawData;
664
665 Int_t indexDDL = 0;
666 Int_t iRawData = 0;
667 AliTOFrawData *tofRawDatum = 0;
668 for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
669
670 fRawReader->Reset();
671 tofRawStream->LoadRawDataBuffersV2(indexDDL);
672
673 clonesRawData = tofRawStream->GetRawData();
674 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
675
676 tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
677
678 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
679 if (tofRawDatum->GetTOF()==-1) continue;
680
681 Int_t nTRM = tofRawDatum->GetTRM();
682 Int_t iChain = tofRawDatum->GetTRMchain();
683 Int_t iTDC = tofRawDatum->GetTDC();
684 Int_t iCH=tofRawDatum->GetTDCchannel();
685
686 if(nTRM==3 && iTDC>=12 && iTDC<=14 && indexDDL%2==1){ // DDL number to LTM number mapping
687 Int_t iLTMindex=-1;
688 Int_t iChannelIndex=-1;
689 switch(indexDDL%AliTOFGeometry::NDDL()){
690 case 1:
691 iLTMindex=1;
692 break;
693 case 3:
694 iLTMindex=36;
695 break;
696 default:
697 break;
698 }
699 iLTMindex+=2*(Int_t)(indexDDL/AliTOFGeometry::NDDL());
700 if(iChain==0 && indexDDL<36)
701 iLTMindex--;
702 if(iChain==0 && indexDDL>=36)
703 iLTMindex++;
704 iChannelIndex=iCH+iTDC*AliTOFGeometry::NCh()-12*AliTOFGeometry::NCh();
705 Int_t index[2]={iLTMindex,iChannelIndex};
706
707
708 if(fTOFTrigMask->IsON(index[0],index[1]) && TMath::Abs(tofRawDatum->GetTOF()-deltaBC) < 400) fTOFTrigMap->SetON(index[0],index[1]);
709 }
710
711 tofRawDatum = 0;
712 } // while loop
713
714 clonesRawData->Clear();
715
716 } // DDL Loop
717
718
719 delete tofRawStream;
720 tofRawStream = NULL;
721
722 }
723
724}
725//-----------------------------------------------------------------------------
726void AliTOFTrigger::PrepareTOFMapFromDigit(TTree *treeD) {
727 if(!fTOFTrigMap) fTOFTrigMap = new AliTOFTriggerMask();
728 LoadActiveMask();
729
730 fTOFTrigMap->ResetMask();
731 if (treeD == 0x0) {
732 return;
733 }
ee51d470 734
6786addd 735 TBranch *branch = treeD->GetBranch("TOF");
736 if (!branch) {
737 return;
738 }
739 TClonesArray *tofDigits =new TClonesArray("AliTOFdigit", 1000);
740 branch->SetAddress(&tofDigits);
741 treeD->GetEvent(0);
742 Int_t ndigits = tofDigits->GetEntriesFast();
743 Int_t detind[5]; //detector indexes: 0 -> sector
744 // 1 -> plate(modulo)
745 // 2 -> strip
746 // 3 -> padz
747 // 4 -> padx
748
749 for (Int_t i=0;i<ndigits;i++){
750 AliTOFdigit * digit = (AliTOFdigit*)tofDigits->UncheckedAt(i);
751 detind[0] = digit->GetSector();
752 detind[1] = digit->GetPlate();
753 detind[2] = digit->GetStrip();
754 detind[3] = digit->GetPadz();
755 detind[4] = digit->GetPadx();
756
757 Int_t indexLTM[2] = {-1,-1};
758 GetLTMIndex(detind,indexLTM);
759
760 if(fTOFTrigMask->IsON(indexLTM[0],indexLTM[1])) fTOFTrigMap->SetON(indexLTM[0],indexLTM[1]);
761 }
762
763}
ee51d470 764//-----------------------------------------------------------------------------
42e171ac 765void AliTOFTrigger::GetLTMIndex(const Int_t * const detind, Int_t *indexLTM) {
ee51d470 766 //
767 // getting LTMmatrix indexes for current digit
768 //
769
cd82ed2f 770 if (detind[1]==0 || detind[1]==1 || (detind[1]==2 && detind[2]<=7)) {
771 if (detind[4]<24){
772 indexLTM[0] = detind[0]*2;
773 }
774 else {
775 indexLTM[0] = detind[0]*2+1;
776 }
777 }
778 else {
779 if (detind[4]<24){
780 indexLTM[0] = detind[0]*2+36;
781 }
782 else {
783 indexLTM[0] = (detind[0]*2+1)+36;
784 }
785 }
786
ee51d470 787 if (indexLTM[0]<36) {
cd82ed2f 788 if (detind[1] ==0){
789 indexLTM[1] = detind[2];
790 }
791 else if (detind[1] ==1){
792 indexLTM[1] = detind[2]+19;
793 }
794 else if (detind[1] ==2){
2901911a 795 indexLTM[1] = detind[2]+19*2;
cd82ed2f 796 }
797 else{
6786addd 798 // AliError("Smth Wrong!!!");
cd82ed2f 799 }
800 }
801 else {
802 if (detind[1] ==2){
803 indexLTM[1] = detind[2]-8;
804 }
805 else if (detind[1] ==3){
806 indexLTM[1] = detind[2]+7;
807 }
808 else if (detind[1] ==4){
809 indexLTM[1] = detind[2]+26;
810 }
811 else{
6786addd 812 // AliError("Smth Wrong!!!");
cd82ed2f 813 }
814 }
ee51d470 815
816}
817//-------------------------------------------------------------------------
818/*
819// to be checked because of warning problems
820void AliTOFTrigger::PrintMap()
821{
822 //
823 //
824 //
825
826 for(Int_t i = 0; i<kNLTM;i++) {
827 if(i<36) {
828 printf("| %d | %d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |\n",
829 (fCTTMmatrixFront[i][0])?1:0,(fCTTMmatrixFront[i][1])?1:0,(fCTTMmatrixFront[i][2])?1:0, \
830 (fCTTMmatrixFront[i][3])?1:0,(fCTTMmatrixFront[i][4])?1:0,(fCTTMmatrixFront[i][5])?1:0, \
831 (fCTTMmatrixFront[i][6])?1:0,(fCTTMmatrixFront[i][7])?1:0,(fCTTMmatrixFront[i][8])?1:0, \
832 (fCTTMmatrixFront[i][9])?1:0,(fCTTMmatrixFront[i][10])?1:0,(fCTTMmatrixFront[i][11])?1:0, \
833 (fCTTMmatrixFront[i][12])?1:0,(fCTTMmatrixFront[i][13])?1:0,(fCTTMmatrixFront[i][14])?1:0, \
834 (fCTTMmatrixFront[i][15])?1:0,(fCTTMmatrixFront[i][16])?1:0,(fCTTMmatrixFront[i][17])?1:0, \
835 (fCTTMmatrixFront[i][18])?1:0,(fCTTMmatrixFront[i][19])?1:0,(fCTTMmatrixFront[i][20])?1:0, \
836 (fCTTMmatrixFront[i][21])?1:0,(fCTTMmatrixFront[i][22])?1:0,(fCTTMmatrixFront[i][23])?1:0);
837 } else {
838 printf("| %d | %d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |%d |\n",
839 (fCTTMmatrixBack[i][0])?1:0,(fCTTMmatrixBack[i][1])?1:0,(fCTTMmatrixBack[i][2])?1:0, \
840 (fCTTMmatrixBack[i][3])?1:0,(fCTTMmatrixBack[i][4])?1:0,(fCTTMmatrixBack[i][5])?1:0, \
841 (fCTTMmatrixBack[i][6])?1:0,(fCTTMmatrixBack[i][7])?1:0,(fCTTMmatrixBack[i][8])?1:0, \
842 (fCTTMmatrixBack[i][9])?1:0,(fCTTMmatrixBack[i][10])?1:0,(fCTTMmatrixBack[i][11])?1:0, \
843 (fCTTMmatrixBack[i][12])?1:0,(fCTTMmatrixBack[i][13])?1:0,(fCTTMmatrixBack[i][14])?1:0, \
844 (fCTTMmatrixBack[i][15])?1:0,(fCTTMmatrixBack[i][16])?1:0,(fCTTMmatrixBack[i][17])?1:0, \
845 (fCTTMmatrixBack[i][18])?1:0,(fCTTMmatrixBack[i][19])?1:0,(fCTTMmatrixBack[i][20])?1:0, \
846 (fCTTMmatrixBack[i][21])?1:0,(fCTTMmatrixBack[i][22])?1:0,(fCTTMmatrixBack[i][23])?1:0);
847 }
848 }
849
850}
851*/
852//-------------------------------------------------------------------------
853
5cd96e39 854void AliTOFTrigger::GetMapMatrix(Bool_t map[][24]) const
855{
856 //
857 // Returns CTTM map
858 //
859
860 for(Int_t i = 0; i<kNLTM;i++)
861 for(Int_t j = 0; j<kNCTTMchannels;j++)
862 map[i][j]=(i<36)?fCTTMmatrixFront[i][j]:fCTTMmatrixBack[i-36][j];
863
864}
865//-------------------------------------------------------------------------
866
42e171ac 867void AliTOFTrigger::GetMap(Bool_t **map) const
ee51d470 868{
869 //
42e171ac 870 // Returns CTTM map
ee51d470 871 //
872
873 for(Int_t i = 0; i<kNLTM;i++)
874 for(Int_t j = 0; j<kNCTTMchannels;j++)
5cd96e39 875 map[i][j]=(i<36)?fCTTMmatrixFront[i][j]:fCTTMmatrixBack[i-36][j];
ee51d470 876
877}
878
5cd96e39 879
ee51d470 880//-------------------------------------------------------------------------
42e171ac 881void AliTOFTrigger::GetTRDmap(Bool_t **map) const
ee51d470 882{
883 //
884 // Retriev the bit map sent to the TRD detector
885 //
5cd96e39 886
887 for(int i = 0; i<kNLTM;i++)
888 for(int j = 0; j<kNLTMtoTRDchannels;j++){
889 map[i][j]=kFALSE;
890 }
ee51d470 891
5cd96e39 892 for(int i = 0; i<kNLTM/2;i++)
ee51d470 893 for(int j = 0; j<AliTOFTrigger::kNCTTMchannels;j++){
5cd96e39 894 UInt_t uTRDbit=j/3;
895 if(fCTTMmatrixFront[i][j]) map[i][uTRDbit]=kTRUE;
ee51d470 896 }
897 for(int i = kNLTM/2; i<kNLTM;i++)
5cd96e39 898 for(int j = 0; j<AliTOFTrigger::kNCTTMchannels;j++){
899 UInt_t uTRDbit=j/3;
900 if(fCTTMmatrixBack[i-kNLTM/2][j]) map[i][uTRDbit]=kTRUE;
901 }
902
903}
904//-------------------------------------------------------------------------
905void AliTOFTrigger::GetTRDmapMatrix(Bool_t map[][8]) const
906{
907 //
908 // Retriev the bit map sent to the TRD detector
909 //
910
911 for(int i = 0; i<kNLTM;i++)
912 for(int j = 0; j<kNLTMtoTRDchannels;j++){
913 map[i][j]=kFALSE;
914 }
915
916 for(int i = 0; i<kNLTM/2;i++)
ee51d470 917 for(int j = 0; j<AliTOFTrigger::kNCTTMchannels;j++){
5cd96e39 918 UInt_t uTRDbit=j/3;
919 if(fCTTMmatrixFront[i][j]) map[i][uTRDbit]=kTRUE;
920 }
921 for(int i = kNLTM/2; i<kNLTM;i++)
922 for(int j = 0; j<AliTOFTrigger::kNCTTMchannels;j++){
923 UInt_t uTRDbit=j/3;
924 if(fCTTMmatrixBack[i-kNLTM/2][j]) map[i][uTRDbit]=kTRUE;
ee51d470 925 }
5cd96e39 926
ee51d470 927}
928
929//-------------------------------------------------------------------------
930void AliTOFTrigger::SetBit(Int_t *detind)
931{
932 //
42e171ac 933 // Sets CTTM map element corresponding to detector element 'detind'
ee51d470 934 //
935
936 Int_t index[2];
937 GetCTTMIndex(detind,index);
938 if(index[0]<36)
939 fCTTMmatrixFront[index[0]][index[1]]=kTRUE;
940 else
5cd96e39 941 fCTTMmatrixBack[index[0]-36][index[1]]=kTRUE;
ee51d470 942
943}
944
945//-------------------------------------------------------------------------
946void AliTOFTrigger::SetBit(Int_t nDDL, Int_t nTRM, Int_t iChain,
947 Int_t iTDC, Int_t iCH)
948{
949 //
42e171ac 950 // Sets CTTM map element corresponding to equipment ID
951 // labelled by number nDDL, nTRM, iChain, iTDC, iCH
ee51d470 952 //
953
5cd96e39 954 if(nTRM==3 && iTDC>=12 && iTDC<=14 && nDDL%2==1){ // DDL number to LTM number mapping
955// getchar();
ee51d470 956 Int_t iLTMindex=-1;
957 Int_t iChannelIndex=-1;
958 switch(nDDL%AliTOFGeometry::NDDL()){
959 case 1:
960 iLTMindex=1;
961 break;
962 case 3:
963 iLTMindex=36;
964 break;
965 default:
966 AliError("Call this function only if(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) ");
967 break;
968 }
969 iLTMindex+=2*(Int_t)(nDDL/AliTOFGeometry::NDDL());
970 if(iChain==0 && nDDL<36)
971 iLTMindex--;
972 if(iChain==0 && nDDL>=36)
973 iLTMindex++;
974 iChannelIndex=iCH+iTDC*AliTOFGeometry::NCh()-12*AliTOFGeometry::NCh();
975 Int_t index[2]={iLTMindex,iChannelIndex};
5cd96e39 976 if (index[0]<36){
ee51d470 977 fCTTMmatrixFront[index[0]][index[1]]=kTRUE;
5cd96e39 978 fLTMmatrix[index[0]][index[1]*2]=kTRUE;
979 }
980 else{
981 fCTTMmatrixBack[index[0]-36][index[1]]=kTRUE;
982 fLTMmatrix[index[0]][index[1]*2]=kTRUE;
983 }
984 }
ee51d470 985
986}
987//-------------------------------------------------------------------------
988
989void AliTOFTrigger::ResetBit(Int_t *detind)
990{
991 //
42e171ac 992 // Sets CTTM map element corresponding to detector element 'detind'
ee51d470 993 //
994
995 Int_t index[2];
996 GetCTTMIndex(detind,index);
997 if(index[0]<36)
998 fCTTMmatrixFront[index[0]][index[1]]=kFALSE;
999 else
5cd96e39 1000 fCTTMmatrixBack[index[0]-36][index[1]]=kFALSE;
ee51d470 1001
1002}
1003
1004//-------------------------------------------------------------------------
1005void AliTOFTrigger::ResetBit(Int_t nDDL, Int_t nTRM, Int_t iChain,
1006 Int_t iTDC, Int_t iCH)
1007{
1008 //
42e171ac 1009 // Sets CTTM map element corresponding to equipment ID
1010 // labelled by number nDDL, nTRM, iChain, iTDC, iCH
ee51d470 1011 //
1012
1013 if(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1){ // DDL number to LTM number mapping
1014 Int_t iLTMindex=-1;
1015 Int_t iChannelIndex=-1;
1016 switch(nDDL%AliTOFGeometry::NDDL()){
1017 case 1:
1018 iLTMindex=1;
1019 break;
1020 case 3:
1021 iLTMindex=36;
1022 break;
1023 default:
1024 AliError("Call this function only if(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) ");
1025 break;
1026 }
1027 iLTMindex+=2*(Int_t)(nDDL/AliTOFGeometry::NDDL());
1028 if(iChain==0 && nDDL<36)
1029 iLTMindex--;
1030 if(iChain==0 && nDDL>=36)
1031 iLTMindex++;
1032 iChannelIndex=iCH+iTDC*AliTOFGeometry::NCh()-12*AliTOFGeometry::NCh();
1033 Int_t index[2]={iLTMindex,iChannelIndex};
5cd96e39 1034 if (index[0]<36){
ee51d470 1035 fCTTMmatrixFront[index[0]][index[1]]=kFALSE;
5cd96e39 1036 }
1037 else{
1038 fCTTMmatrixBack[index[0]-36][index[1]]=kFALSE;
1039 }
ee51d470 1040 }
1041 else
1042 AliError("Call this function only if(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) ");
1043
1044}
1045//-------------------------------------------------------------------------
1046
1047Bool_t AliTOFTrigger::GetBit(Int_t *detind)
1048{
1049 //
42e171ac 1050 // Returns CTTM map element corresponding to detector element 'detind'
ee51d470 1051 //
1052
1053 Int_t index[2];
1054 GetCTTMIndex(detind,index);
5cd96e39 1055 return (index[0]<36)?fCTTMmatrixFront[index[0]][index[1]]:fCTTMmatrixBack[index[0]-36][index[1]];
ee51d470 1056
1057}
1058
1059//-------------------------------------------------------------------------
1060Bool_t AliTOFTrigger::GetBit(Int_t nDDL, Int_t nTRM, Int_t iChain,
1061 Int_t iTDC, Int_t iCH)
1062{
1063 //
42e171ac 1064 // Returns CTTM map element corresponding to equipment ID
1065 // labelled by number nDDL, nTRM, iChain, iTDC, iCH
ee51d470 1066 //
1067
1068 if ( !(nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) ) {
1069 AliWarning("Call this function only if(nTRM==3 && iTDC>12 && iTDC<14) ");
1070 return kFALSE;
1071 }
1072 //if (nTRM==3 && iTDC>12 && iTDC<14 && nDDL%2==1) { // DDL number to LTM number mapping
1073
1074 UInt_t iLTMindex=0;
1075 UInt_t iChannelindex=0;
1076 switch(nDDL%AliTOFGeometry::NDDL()) {
1077 case 1:
1078 iLTMindex=1;
1079 break;
1080 case 3:
1081 iLTMindex=36;
1082 break;
1083 default:
1084 AliError("something wrong");
1085 break;
1086 }
1087 iLTMindex+=2*(Int_t)(nDDL/AliTOFGeometry::NDDL());
1088
1089 if (iChain==1) return kFALSE; // AdC
1090
1091 if (nDDL<36)
1092 iLTMindex--;
1093 if (nDDL>=36)
1094 iLTMindex++;
1095 iChannelindex=iCH+iTDC*AliTOFGeometry::NCh()-12*AliTOFGeometry::NCh();
2942f542 1096 Int_t index[2]={static_cast<Int_t>(iLTMindex),static_cast<Int_t>(iChannelindex)};
5cd96e39 1097 return (index[0]<36)?fCTTMmatrixFront[index[0]][index[1]]:fCTTMmatrixBack[index[0]-36][index[1]];
ee51d470 1098
1099}
1100
1101//-------------------------------------------------------------------------
1102
1103void AliTOFTrigger::CreateCTTMMatrix() {
1104 //
1105 // Create CTTM bit map
1106 //
0d79e946 1107
1108 LoadActiveMask();
1109
a6ec5bf6 1110 Int_t fromTriggertoDCS[72] = {0,1,4,5,8,9,12,13,16,17,20,21,24,25,28,29,32,33,36,37,40,41,44,45,48,49,52,53,56,57,60,61,64,65,68,69,3,
1111 2,7,6,11,10,15,14,19,18,23,22,27,26,31,30,35,34,39,38,43,42,47,46,51,50,55,54,59,58,63,62,67,66,71,70};
1112
1113
c06f660b 1114 fNMaxipadOnAll=0;
1115 fNMaxipadOn=0;
1116
1117 for(Int_t i = 0; i<kNLTM;i++){
1118 UInt_t currentMask = fPowerMask[kNCTTMchannels]-1;
a6ec5bf6 1119 if(fTOFTrigMask) currentMask=fTOFTrigMask->GetTriggerMask(fromTriggertoDCS[i]);
c06f660b 1120 if(i<kNCTTM){
1121 for(Int_t j = 0; j<kNCTTMchannels;j++){
1122 fCTTMmatrixFront[i][j]=fLTMmatrix[i][2*j]||fLTMmatrix[i][2*j+1];
1123 if(fCTTMmatrixFront[i][j]) fNMaxipadOnAll++;
1124 if(!(currentMask & fPowerMask[j])) fCTTMmatrixFront[i][j]=0;
c11d3763 1125 if(fCTTMmatrixFront[i][j]){
1126 fNMaxipadOn++;
1127 fLTMarray[i] = kTRUE;
1128 }
c06f660b 1129 }
1130 }
1131 else{
1132 for(Int_t j = 0; j<kNCTTMchannels;j++){
1133 fCTTMmatrixBack[i-kNCTTM][j]=fLTMmatrix[i][2*j]||fLTMmatrix[i][2*j+1];;
1134 if(fCTTMmatrixBack[i-kNCTTM][j]) fNMaxipadOnAll++;
1135 if(!(currentMask & fPowerMask[j])) fCTTMmatrixBack[i-kNCTTM][j]=0;
c11d3763 1136 if(fCTTMmatrixBack[i-kNCTTM][j]){
1137 fNMaxipadOn++;
1138 fLTMarray[i-kNCTTM] = kTRUE;
1139 }
c06f660b 1140 }
1141 }
ee51d470 1142 }
c11d3763 1143
1144 fNCrateOn = 0;
1145 for(Int_t j=0; j < kNCTTM; j++) {if(fLTMarray[j]) fNCrateOn++;}
1146
ee51d470 1147}
1148//-----------------------------------------------------------------------------
1149
1150void AliTOFTrigger::GetCTTMIndex(Int_t *detind, Int_t *indexCTTM) {
1151 //
42e171ac 1152 // Returns CTTM index corresponding to the detector element detind
ee51d470 1153 //
1154
1155 GetLTMIndex(detind,indexCTTM);
1156 indexCTTM[1]/=2;
1157
cd82ed2f 1158}
c06f660b 1159//-----------------------------------------------------------------------------
1160void AliTOFTrigger::LoadActiveMask(){
1161//
1162// Load OCDB current mask
1163//
c11d3763 1164
1165 AliCDBManager *cdb = AliCDBManager::Instance();
1166 if(cdb->GetRun() < 0 || !(cdb->GetDefaultStorage())){
1167 if(!(cdb->GetDefaultStorage())){
1168 cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
1169 printf("AliTOFTrigger (WARNING): probably CDB first instance - Default Sorage set to \"local://$ALICE_ROOT/OCDB\"\n");
1170 }
1171 if(cdb->GetRun() < 0){
1172 cdb->SetRun(0);
1173 printf("AliTOFTrigger (WARNING): probably CDB first instance - number of run set to 0\n");
1174 }
1175 }
de40f9c1 1176
c11d3763 1177 AliCDBEntry *cdbe = cdb->Get("TRIGGER/TOF/TriggerMask");
de40f9c1 1178 if(!cdbe) return;
c11d3763 1179 fTOFTrigMask= (AliTOFTriggerMask *)cdbe->GetObject();
c06f660b 1180
c11d3763 1181// UInt_t maskArray[kNLTM];
1182// if(fTOFTrigMask == NULL) fTOFTrigMask = new AliTOFTriggerMask();
1183// for (Int_t k = 0; k < kNLTM ; k++) maskArray[k] = fPowerMask[kNCTTMchannels]-1;
1184// //for (Int_t k = 0; k < kNLTM ; k+=2) maskArray[k] = 0;
1185
1186// fTOFTrigMask->SetTriggerMaskArray(maskArray);
c06f660b 1187}
1188
1189
1190//-----------------------------------------------------------------------------
1191AliTOFTrigger::~AliTOFTrigger()
1192{
1193 // dtor
1194
c06f660b 1195}
1196
1197//-----------------------------------------------------------------------------
1198AliTOFTrigger& AliTOFTrigger::operator=(const AliTOFTrigger &/*source*/)
1199{
1200 // ass. op.
1201 return *this;
1202
1203}
c11d3763 1204