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 <TClonesArray.h>
31 #include "AliLoader.h"
33 #include "AliRunLoader.h"
35 #include "AliTriggerInput.h"
37 #include "AliTOFdigit.h"
38 #include "AliTOFTrigger.h"
40 extern AliRun* gAlice;
42 //-------------------------------------------------------------------------
43 ClassImp(AliTOFTrigger)
45 //----------------------------------------------------------------------
46 AliTOFTrigger::AliTOFTrigger() :
59 for (Int_t i=0;i<kNLTM;i++){
60 for (Int_t j=0;j<kNLTMchannels;j++){
61 fLTMmatrix[i][j]=kFALSE;
64 for (Int_t j=0;j<kNCTTMchannels;j++){
65 fCTTMmatrixFront[i][j]=kFALSE;
66 fCTTMmatrixBack[i][j]=kFALSE;
73 //----------------------------------------------------------------------
74 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) :
76 fHighMultTh(HighMultTh),
78 fMultiMuonTh(MultiMuonTh),
80 fdeltaminpsi(deltaminpsi),
81 fdeltamaxpsi(deltamaxpsi),
82 fdeltaminro(deltaminro),
83 fdeltamaxro(deltamaxro),
84 fstripWindow(stripWindow)
87 //ctor with thresholds for triggers
88 for (Int_t i=0;i<kNLTM;i++){
89 for (Int_t j=0;j<kNLTMchannels;j++){
90 fLTMmatrix[i][j]=kFALSE;
93 for (Int_t j=0;j<kNCTTMchannels;j++){
94 fCTTMmatrixFront[i][j]=kFALSE;
95 fCTTMmatrixBack[i][j]=kFALSE;
103 //____________________________________________________________________________
105 AliTOFTrigger::AliTOFTrigger(const AliTOFTrigger & tr):
106 AliTriggerDetector(tr),
107 fHighMultTh(tr.fHighMultTh),
109 fMultiMuonTh(tr.fMultiMuonTh),
111 fdeltaminpsi(tr.fdeltaminpsi),
112 fdeltamaxpsi(tr.fdeltamaxpsi),
113 fdeltaminro(tr.fdeltaminro),
114 fdeltamaxro(tr.fdeltamaxro),
115 fstripWindow(tr.fstripWindow)
118 for (Int_t i=0;i<kNLTM;i++){
119 for (Int_t j=0;j<kNLTMchannels;j++){
120 fLTMmatrix[i][j]=tr.fLTMmatrix[i][j];
123 for (Int_t j=0;j<kNCTTMchannels;j++){
124 fCTTMmatrixFront[i][j]=tr.fCTTMmatrixFront[i][j];
125 fCTTMmatrixBack[i][j]=tr.fCTTMmatrixBack[i][j];
129 SetName(tr.GetName());
131 //fInputs=&(tr.GetInputs());
134 //----------------------------------------------------------------------
136 void AliTOFTrigger::CreateInputs()
139 // Do not create inputs again!!
140 if( fInputs.GetEntriesFast() > 0 ) return;
142 fInputs.AddLast(new AliTriggerInput("TOF_Cosmic_MultiMuon_L0","TOF",0));
143 fInputs.AddLast(new AliTriggerInput("0OIN","TOF",0)); // was "TOF_pp_MB_L0"
144 fInputs.AddLast(new AliTriggerInput("0OX1","TOF",0)); // was "TOF_UltraPer_Coll_L0"
146 fInputs.AddLast(new AliTriggerInput("0OHM","TOF",0)); // was "TOF_High_Mult_L0"
147 fInputs.AddLast(new AliTriggerInput("TOF_Jet_L1","TOF",0));
150 //----------------------------------------------------------------------
151 void AliTOFTrigger::Trigger(){
155 Int_t nchonFront = 0;
158 Int_t nchonFrontBack = 0;
159 Int_t nchonFront1 = 0;
160 Int_t nchonBack1 = 0;
161 Int_t nchonFrontBack1 = 0;
162 Int_t mindeltapsi = (Int_t)fdeltaminpsi/10;
163 Int_t maxdeltapsi = (Int_t)fdeltamaxpsi/10;
164 Int_t mindeltaro = (Int_t)fdeltaminro/10;
165 Int_t maxdeltaro = (Int_t)fdeltamaxro/10;
166 for (Int_t i=0;i<kNCTTM;i++){
167 for (Int_t j=0;j<kNCTTMchannels;j++){
168 fCTTMmatrixFront[i][j]=kFALSE;
169 fCTTMmatrixBack[i][j]=kFALSE;
172 for (Int_t i=0;i<kNCTTM;i++){
173 for (Int_t j=0;j<kNCTTMchannels;j++){
174 fCTTMmatrixFront[i][j] = (fLTMmatrix[i][j*2] || fLTMmatrix[i][j*2+1]);
175 if (fCTTMmatrixFront[i][j]) nchonFront++;
179 for (Int_t i=kNCTTM;i<(kNCTTM*2);i++){
180 for (Int_t j=0;j<kNCTTMchannels;j++){
181 fCTTMmatrixBack[i-kNCTTM][j] = (fLTMmatrix[i][j*2] || fLTMmatrix[i][j*2+1]);
182 if (fCTTMmatrixBack[i-kNCTTM][j]) nchonBack++;
186 nchonTot = nchonFront + nchonBack;
188 //pp Minimum Bias Trigger
189 if (nchonTot >= fppMBTh) {
193 //High Multiplicity Trigger
194 if (nchonTot >= fHighMultTh) {
204 Bool_t boolCTTMor = kFALSE;
206 for (Int_t i=0;i<(kNCTTM/2);i++){
207 Int_t iopp = i+kNCTTM/2;
208 for (Int_t j=0;j<kNCTTMchannels;j++){
209 if (fCTTMmatrixFront[i][j]){
210 Int_t minj = j-fstripWindow;
211 Int_t maxj = j+fstripWindow;
213 if (maxj>=kNCTTMchannels) maxj = kNCTTMchannels-1;
215 for (Int_t k = minj;k<=maxj;k++){
216 boolCTTMor |= fCTTMmatrixFront[iopp][k];
223 if (fCTTMmatrixBack[i][j]){
224 Int_t minj = j-fstripWindow;
225 Int_t maxj = j+fstripWindow;
227 if (maxj>=kNCTTMchannels) maxj =kNCTTMchannels-1;
229 for (Int_t k = minj;k<=maxj;k++){
230 boolCTTMor |= fCTTMmatrixBack[iopp][k];
239 nchonFrontBack = nchonFront+nchonBack;
246 for (Int_t i=0;i<(kNCTTM/2);i++){
247 Int_t i2max = (kNCTTM-1)-i+1;
248 Int_t i2min = (kNCTTM-1)-i-1;
249 if (i2max >=kNCTTM) i2max = kNCTTM-1;
250 if (i2min==i) i2min = kNCTTM-1-i;
251 for (Int_t j=0;j<kNCTTMchannels;j++){
252 Int_t j2min = j-fstripWindow;
253 Int_t j2max = j+fstripWindow;
254 if (j2min<0) j2min =0;
255 if (j2max>=kNCTTMchannels) j2max =kNCTTMchannels-1;
256 if (fCTTMmatrixFront[i][j]){
258 for (Int_t i2=i2min;i2<=i2max;i2++){
259 for (Int_t j2 = j2min;j2<=j2max;j2++){
260 boolCTTMor |= fCTTMmatrixFront[i2][j2];
267 if (fCTTMmatrixBack[i][j]){
269 for (Int_t i2=i2min;i2<=i2max;i2++){
270 for (Int_t j2 = j2min;j2<=j2max;j2++){
271 boolCTTMor |= fCTTMmatrixBack[i2][j2];
281 nchonFrontBack1 = nchonFront1+nchonBack1;
283 if (nchonFrontBack >= fMultiMuonTh || nchonFrontBack1 >= fMultiMuonTh) {
284 SetInput("TOF_Cosmic_MultiMuon_L0");
287 //Ultra-Peripheral collision Trigger
288 Bool_t boolpsi = kFALSE;
289 Bool_t boolro = kFALSE;
290 if (nchonTot == fUPTh){
291 for (Int_t i=0;i<kNCTTM;i++){
292 for (Int_t j=0;j<kNCTTMchannels;j++){
293 Int_t minipsi = i+mindeltapsi;
294 Int_t maxipsi = i+maxdeltapsi;
295 if (minipsi>=kNCTTM) minipsi = mindeltapsi-((kNCTTM-1)-i)-1;
296 if (maxipsi>=kNCTTM) maxipsi = maxdeltapsi-((kNCTTM-1)-i)-1;
297 Int_t miniro = i+mindeltaro;
298 Int_t maxiro = i+maxdeltaro;
299 if (miniro>=kNCTTM) miniro = mindeltaro-((kNCTTM-1)-i)-1;
300 if (maxiro>=kNCTTM) maxiro = maxdeltaro-((kNCTTM-1)-i)-1;
301 Int_t j2min = j-fstripWindow;
302 Int_t j2max = j+fstripWindow;
303 if (j2min<0) j2min =0;
304 if (j2max>=kNCTTMchannels) j2max =kNCTTMchannels-1;
305 if (fCTTMmatrixFront[i][j]){
306 for (Int_t i2=minipsi;i2<=maxipsi;i2++){
307 for (Int_t j2 = j2min;j2<=j2max;j2++){
308 if (fCTTMmatrixFront[i2][j2]) {
320 for (Int_t i2=miniro;i2<=maxiro;i2++){
321 for (Int_t j2 = j2min;j2<=j2max;j2++){
322 if (fCTTMmatrixFront[i2][j2]) {
336 else if (fCTTMmatrixBack[i][j]){
337 for (Int_t i2=minipsi;i2<=maxipsi;i2++){
338 for (Int_t j2 = j2min;j2<=j2max;j2++){
339 if (fCTTMmatrixBack[i2][j2]) {
351 for (Int_t i2=miniro;i2<=maxiro;i2++){
352 for (Int_t j2 = j2min;j2<=j2max;j2++){
353 if (fCTTMmatrixBack[i2][j2]) {
370 //-----------------------------------------------------------------------------
371 void AliTOFTrigger::CreateLTMMatrix(){
374 for (Int_t i=0;i<kNLTM;i++){
375 for (Int_t j=0;j<kNLTMchannels;j++){
376 fLTMmatrix[i][j]=kFALSE;
380 rl = AliRunLoader::Instance();
382 Int_t ncurrevent = rl->GetEventNumber();
383 rl->GetEvent(ncurrevent);
385 AliLoader * tofLoader = rl->GetLoader("TOFLoader");
387 tofLoader->LoadDigits("read");
388 TTree *treeD = tofLoader->TreeD();
391 AliFatal("AliTOFTrigger: Can not get TreeD");
394 TBranch *branch = treeD->GetBranch("TOF");
396 AliError("can't get the branch with the TOF digits !");
399 TClonesArray *tofDigits =new TClonesArray("AliTOFdigit", 1000);
400 branch->SetAddress(&tofDigits);
402 Int_t ndigits = tofDigits->GetEntriesFast();
403 Int_t detind[5]; //detector indexes: 0 -> sector
409 for (Int_t i=0;i<ndigits;i++){
410 AliTOFdigit * digit = (AliTOFdigit*)tofDigits->UncheckedAt(i);
411 detind[0] = digit->GetSector();
412 detind[1] = digit->GetPlate();
413 detind[2] = digit->GetStrip();
414 detind[3] = digit->GetPadz();
415 detind[4] = digit->GetPadx();
417 Int_t indexLTM[2] = {-1,-1};
418 GetLTMIndex(detind,indexLTM);
420 fLTMmatrix[indexLTM[0]][indexLTM[1]] = kTRUE;
423 tofLoader->UnloadDigits();
424 // rl->UnloadgAlice();
426 //-----------------------------------------------------------------------------
427 void AliTOFTrigger::GetLTMIndex(Int_t *detind, Int_t *indexLTM){
428 //getting LTMmatrix indexes for current digit
429 if (detind[1]==0 || detind[1]==1 || (detind[1]==2 && detind[2]<=7)) {
431 indexLTM[0] = detind[0]*2;
434 indexLTM[0] = detind[0]*2+1;
439 indexLTM[0] = detind[0]*2+36;
442 indexLTM[0] = (detind[0]*2+1)+36;
448 indexLTM[1] = detind[2];
450 else if (detind[1] ==1){
451 indexLTM[1] = detind[2]+19;
453 else if (detind[1] ==2){
454 indexLTM[1] = detind[2]+19*2;
457 AliError("Smth Wrong!!!");
462 indexLTM[1] = detind[2]-8;
464 else if (detind[1] ==3){
465 indexLTM[1] = detind[2]+7;
467 else if (detind[1] ==4){
468 indexLTM[1] = detind[2]+26;
471 AliError("Smth Wrong!!!");