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 **************************************************************************/
18 /////////////////////////////////////////////////////////////////////
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)
27 /////////////////////////////////////////////////////////////////////
29 #include "AliLoader.h"
31 #include "AliRunLoader.h"
33 #include "AliTriggerInput.h"
35 #include "AliTOFdigit.h"
36 #include "AliTOFTrigger.h"
38 extern AliRun* gAlice;
40 //-------------------------------------------------------------------------
41 ClassImp(AliTOFTrigger)
43 //----------------------------------------------------------------------
44 AliTOFTrigger::AliTOFTrigger() :
57 for (Int_t i=0;i<kNLTM;i++){
58 for (Int_t j=0;j<kNLTMchannels;j++){
59 fLTMmatrix[i][j]=kFALSE;
62 for (Int_t j=0;j<kNCTTMchannels;j++){
63 fCTTMmatrixFront[i][j]=kFALSE;
64 fCTTMmatrixBack[i][j]=kFALSE;
71 //----------------------------------------------------------------------
72 AliTOFTrigger::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) :
74 fHighMultTh(HighMultTh),
76 fMultiMuonTh(MultiMuonTh),
78 fdeltaminpsi(deltaminpsi),
79 fdeltamaxpsi(deltamaxpsi),
80 fdeltaminro(deltaminro),
81 fdeltamaxro(deltamaxro),
82 fstripWindow(stripWindow)
85 //ctor with thresholds for triggers
86 for (Int_t i=0;i<kNLTM;i++){
87 for (Int_t j=0;j<kNLTMchannels;j++){
88 fLTMmatrix[i][j]=kFALSE;
91 for (Int_t j=0;j<kNCTTMchannels;j++){
92 fCTTMmatrixFront[i][j]=kFALSE;
93 fCTTMmatrixBack[i][j]=kFALSE;
101 //____________________________________________________________________________
103 AliTOFTrigger::AliTOFTrigger(const AliTOFTrigger & tr):
104 AliTriggerDetector(),
116 fHighMultTh=tr.fHighMultTh;
118 fMultiMuonTh=tr.fMultiMuonTh;
120 fdeltaminpsi = tr.fdeltaminpsi;
121 fdeltamaxpsi = tr.fdeltamaxpsi;
122 fdeltaminro = tr.fdeltaminro;
123 fdeltamaxro = tr.fdeltamaxro;
124 fstripWindow = tr.fstripWindow;
125 for (Int_t i=0;i<kNLTM;i++){
126 for (Int_t j=0;j<kNLTMchannels;j++){
127 fLTMmatrix[i][j]=tr.fLTMmatrix[i][j];
130 for (Int_t j=0;j<kNCTTMchannels;j++){
131 fCTTMmatrixFront[i][j]=tr.fCTTMmatrixFront[i][j];
132 fCTTMmatrixBack[i][j]=tr.fCTTMmatrixBack[i][j];
136 SetName(tr.GetName());
138 //fInputs=&(tr.GetInputs());
141 //----------------------------------------------------------------------
143 void AliTOFTrigger::CreateInputs()
146 // Do not create inputs again!!
147 if( fInputs.GetEntriesFast() > 0 ) return;
149 fInputs.AddLast(new AliTriggerInput("TOF_Cosmic_MultiMuon_L0","Cosmic Multimuon Topology",0x01));
150 fInputs.AddLast(new AliTriggerInput("TOF_pp_MB_L0","pp Minimum Bias",0x02));
151 fInputs.AddLast(new AliTriggerInput("TOF_UltraPer_Coll_L0","Ultra Peripheral Collisions",0x04));
153 fInputs.AddLast(new AliTriggerInput("TOF_High_Mult_L0","High Multiplicity",0x08));
154 fInputs.AddLast(new AliTriggerInput("TOF_Jet_L1","Jet Search",0x10));
157 //----------------------------------------------------------------------
158 void AliTOFTrigger::Trigger(){
161 Int_t nchonFront = 0;
164 Int_t nchonFrontBack = 0;
165 Int_t nchonFront1 = 0;
166 Int_t nchonBack1 = 0;
167 Int_t nchonFrontBack1 = 0;
168 Int_t mindeltapsi = (Int_t)fdeltaminpsi/10;
169 Int_t maxdeltapsi = (Int_t)fdeltamaxpsi/10;
170 Int_t mindeltaro = (Int_t)fdeltaminro/10;
171 Int_t maxdeltaro = (Int_t)fdeltamaxro/10;
172 for (Int_t i=0;i<kNCTTM;i++){
173 for (Int_t j=0;j<kNCTTMchannels;j++){
174 fCTTMmatrixFront[i][j]=kFALSE;
175 fCTTMmatrixBack[i][j]=kFALSE;
178 for (Int_t i=0;i<kNCTTM;i++){
179 for (Int_t j=0;j<kNCTTMchannels;j++){
180 fCTTMmatrixFront[i][j] = (fLTMmatrix[i][j*2] || fLTMmatrix[i][j*2+1]);
181 if (fCTTMmatrixFront[i][j]) nchonFront++;
185 for (Int_t i=kNCTTM;i<(kNCTTM*2);i++){
186 for (Int_t j=0;j<kNCTTMchannels;j++){
187 fCTTMmatrixBack[i-kNCTTM][j] = (fLTMmatrix[i][j*2] || fLTMmatrix[i][j*2+1]);
188 if (fCTTMmatrixBack[i-kNCTTM][j]) nchonBack++;
192 nchonTot = nchonFront + nchonBack;
194 //pp Minimum Bias Trigger
195 if (nchonTot >= fppMBTh) {
196 SetInput("TOF_pp_MB_L0");
199 //High Multiplicity Trigger
200 if (nchonTot >= fHighMultTh) {
201 SetInput("TOF_High_Mult_L0");
210 Bool_t boolCTTMor = kFALSE;
212 for (Int_t i=0;i<(kNCTTM/2);i++){
213 Int_t iopp = i+kNCTTM/2;
214 for (Int_t j=0;j<kNCTTMchannels;j++){
215 if (fCTTMmatrixFront[i][j]){
216 Int_t minj = j-fstripWindow;
217 Int_t maxj = j+fstripWindow;
219 if (maxj>=kNCTTMchannels) maxj = kNCTTMchannels-1;
221 for (Int_t k = minj;k<=maxj;k++){
222 boolCTTMor |= fCTTMmatrixFront[iopp][k];
229 if (fCTTMmatrixBack[i][j]){
230 Int_t minj = j-fstripWindow;
231 Int_t maxj = j+fstripWindow;
233 if (maxj>=kNCTTMchannels) maxj =kNCTTMchannels-1;
235 for (Int_t k = minj;k<=maxj;k++){
236 boolCTTMor |= fCTTMmatrixBack[iopp][k];
245 nchonFrontBack = nchonFront+nchonBack;
252 for (Int_t i=0;i<(kNCTTM/2);i++){
253 Int_t i2max = (kNCTTM-1)-i+1;
254 Int_t i2min = (kNCTTM-1)-i-1;
255 if (i2max >=kNCTTM) i2max = kNCTTM-1;
256 if (i2min==i) i2min = kNCTTM-1-i;
257 for (Int_t j=0;j<kNCTTMchannels;j++){
258 Int_t j2min = j-fstripWindow;
259 Int_t j2max = j+fstripWindow;
260 if (j2min<0) j2min =0;
261 if (j2max>=kNCTTMchannels) j2max =kNCTTMchannels-1;
262 if (fCTTMmatrixFront[i][j]){
264 for (Int_t i2=i2min;i2<=i2max;i2++){
265 for (Int_t j2 = j2min;j2<=j2max;j2++){
266 boolCTTMor |= fCTTMmatrixFront[i2][j2];
273 if (fCTTMmatrixBack[i][j]){
275 for (Int_t i2=i2min;i2<=i2max;i2++){
276 for (Int_t j2 = j2min;j2<=j2max;j2++){
277 boolCTTMor |= fCTTMmatrixBack[i2][j2];
287 nchonFrontBack1 = nchonFront1+nchonBack1;
289 if (nchonFrontBack >= fMultiMuonTh || nchonFrontBack1 >= fMultiMuonTh) {
290 SetInput("TOF_Cosmic_MultiMuon_L0");
293 //Ultra-Peripheral collision Trigger
294 Bool_t boolpsi = kFALSE;
295 Bool_t boolro = kFALSE;
296 if (nchonTot == fUPTh){
297 for (Int_t i=0;i<kNCTTM;i++){
298 for (Int_t j=0;j<kNCTTMchannels;j++){
299 Int_t minipsi = i+mindeltapsi;
300 Int_t maxipsi = i+maxdeltapsi;
301 if (minipsi>=kNCTTM) minipsi = mindeltapsi-((kNCTTM-1)-i)-1;
302 if (maxipsi>=kNCTTM) maxipsi = maxdeltapsi-((kNCTTM-1)-i)-1;
303 Int_t miniro = i+mindeltaro;
304 Int_t maxiro = i+maxdeltaro;
305 if (miniro>=kNCTTM) miniro = mindeltaro-((kNCTTM-1)-i)-1;
306 if (maxiro>=kNCTTM) maxiro = maxdeltaro-((kNCTTM-1)-i)-1;
307 Int_t j2min = j-fstripWindow;
308 Int_t j2max = j+fstripWindow;
309 if (j2min<0) j2min =0;
310 if (j2max>=kNCTTMchannels) j2max =kNCTTMchannels-1;
311 if (fCTTMmatrixFront[i][j]){
312 for (Int_t i2=minipsi;i2<=maxipsi;i2++){
313 for (Int_t j2 = j2min;j2<=j2max;j2++){
314 if (fCTTMmatrixFront[i2][j2]) {
315 SetInput("TOF_UltraPer_Coll_L0");
326 for (Int_t i2=miniro;i2<=maxiro;i2++){
327 for (Int_t j2 = j2min;j2<=j2max;j2++){
328 if (fCTTMmatrixFront[i2][j2]) {
329 SetInput("TOF_UltraPer_Coll_L0");
342 else if (fCTTMmatrixBack[i][j]){
343 for (Int_t i2=minipsi;i2<=maxipsi;i2++){
344 for (Int_t j2 = j2min;j2<=j2max;j2++){
345 if (fCTTMmatrixBack[i2][j2]) {
346 SetInput("TOF_UltraPer_Coll_L0");
357 for (Int_t i2=miniro;i2<=maxiro;i2++){
358 for (Int_t j2 = j2min;j2<=j2max;j2++){
359 if (fCTTMmatrixBack[i2][j2]) {
360 SetInput("TOF_UltraPer_Coll_L0");
376 //-----------------------------------------------------------------------------
377 void AliTOFTrigger::CreateLTMMatrix(){
380 for (Int_t i=0;i<kNLTM;i++){
381 for (Int_t j=0;j<kNLTMchannels;j++){
382 fLTMmatrix[i][j]=kFALSE;
386 rl = gAlice->GetRunLoader();
388 Int_t ncurrevent = rl->GetEventNumber();
389 rl->GetEvent(ncurrevent);
391 AliLoader * tofLoader = rl->GetLoader("TOFLoader");
393 tofLoader->LoadDigits("read");
394 TTree *treeD = tofLoader->TreeD();
397 AliFatal("AliTOFTrigger: Can not get TreeD");
400 TBranch *branch = treeD->GetBranch("TOF");
402 AliError("can't get the branch with the TOF digits !");
405 TClonesArray *tofDigits =new TClonesArray("AliTOFdigit", 1000);
406 branch->SetAddress(&tofDigits);
408 Int_t ndigits = tofDigits->GetEntriesFast();
409 Int_t detind[5]; //detector indexes: 0 -> sector
415 for (Int_t i=0;i<ndigits;i++){
416 AliTOFdigit * digit = (AliTOFdigit*)tofDigits->UncheckedAt(i);
417 detind[0] = digit->GetSector();
418 detind[1] = digit->GetPlate();
419 detind[2] = digit->GetStrip();
420 detind[3] = digit->GetPadz();
421 detind[4] = digit->GetPadx();
423 Int_t indexLTM[2] = {-1,-1};
424 GetLTMIndex(detind,indexLTM);
426 fLTMmatrix[indexLTM[0]][indexLTM[1]] = kTRUE;
429 tofLoader->UnloadDigits();
430 // rl->UnloadgAlice();
432 //-----------------------------------------------------------------------------
433 void AliTOFTrigger::GetLTMIndex(Int_t *detind, Int_t *indexLTM){
434 //getting LTMmatrix indexes for current digit
435 if (detind[1]==0 || detind[1]==1 || (detind[1]==2 && detind[2]<=7)) {
437 indexLTM[0] = detind[0]*2;
440 indexLTM[0] = detind[0]*2+1;
445 indexLTM[0] = detind[0]*2+36;
448 indexLTM[0] = (detind[0]*2+1)+36;
454 indexLTM[1] = detind[2];
456 else if (detind[1] ==1){
457 indexLTM[1] = detind[2]+19;
459 else if (detind[1] ==2){
460 indexLTM[1] = detind[2]+19*2;
463 AliError("Smth Wrong!!!");
468 indexLTM[1] = detind[2]-8;
470 else if (detind[1] ==3){
471 indexLTM[1] = detind[2]+7;
473 else if (detind[1] ==4){
474 indexLTM[1] = detind[2]+26;
477 AliError("Smth Wrong!!!");