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 **************************************************************************/
16 #include <Riostream.h>
18 #include <TClonesArray.h>
21 #include "AliRunLoader.h"
22 #include "AliACORDETrigger.h"
23 #include "AliACORDEConstants.h"
25 //______________________________________________________________________
28 ClassImp(AliACORDETrigger)
30 AliACORDETrigger::AliACORDETrigger()
31 :AliTriggerDetector(),
36 cout << " ================>>>>>>>>>>>>>>>>> AliACORDETrigger" << endl;
39 for (Int_t i=0; i<60; i++) fModuleFired[i]=kFALSE;
42 void AliACORDETrigger::CreateInputs()
44 // Do not create inputs again!!
45 if( fInputs.GetEntriesFast() > 0 ) return;
47 // two acorde triggers, single muon and multicoincidence
49 AliTriggerInput( "0ASL",
52 AliTriggerInput( "0AMU",
56 void AliACORDETrigger::Trigger()
59 // 1.- Get loaders and pointers
60 // 2.- Loop over all entries
61 // set temporal variables to default values
63 // 3.- Loop over all digits in an entrie
64 // Fill temporal arrays
65 // Find module with lowest time
66 // 4.- Loop over temporal arrays
67 // Find number of modules within the time window
68 // 5.- Set the relevant trigger
70 // 1.- Get loaders and pointers
71 AliRunLoader* runLoader = AliRunLoader::Instance();
72 AliACORDELoader* loader =
73 (AliACORDELoader* )runLoader->GetLoader( "ACORDELoader" );
74 loader->LoadDigits("READ");
75 TTree* acordeDigitsTree = loader->TreeD();
76 if (!acordeDigitsTree) return;
77 TClonesArray* acordeDigits = new TClonesArray("AliACORDEdigit",1000);
78 TBranch* digitBranch = acordeDigitsTree->GetBranch("ACORDEdigit");
79 digitBranch->SetAddress(&acordeDigits);
81 // 2.- Loop over all entries
82 // set temporal variables to default values
84 Int_t MultiMin = AliACORDEConstants::Instance()->MultiMuonThreshold();
85 Float_t time_window = AliACORDEConstants::Instance()->MultiMuonWindow();
86 Int_t MinTimeModule = -1;
87 Float_t MinTime = 1e10;
88 Float_t ModuleTimes[60];
89 for (Int_t i=0; i<60; i++) ModuleTimes[i] = -1.0;
92 Int_t nEntries = (Int_t)acordeDigitsTree->GetEntries();
93 cout << " ===AliACORDETrigger=== nEntries " <<nEntries << endl;
94 for (Int_t e=0; e<nEntries; e++) {
95 acordeDigitsTree->GetEvent(e);
96 // 3.- Loop over all digits in an entrie
97 // Fill temporal arrays
98 // Find module with lowest time
99 Int_t nDigits = acordeDigits->GetEntriesFast();
100 cout << " ===AliACORDETrigger=== nDigits " <<nDigits << endl;
101 for (Int_t d=0; d<nDigits; d++) {
102 AliACORDEdigit* digit = (AliACORDEdigit*)acordeDigits->At(d);
103 Int_t module = digit->GetModule();
104 Float_t mod_time = digit->GetTime();
105 ModuleTimes[module-1]=mod_time;
106 if (mod_time < MinTime) {
108 MinTimeModule = module;
110 } // end of loop over digits
111 } // end of loop over events in digits tree
113 // 4.- Loop over temporal arrays
114 // Find number of modules within the time window
115 if (MinTimeModule == -1) return;
116 for (Int_t i=0; i<60; i++) {
117 if (ModuleTimes[i]<0) continue;
118 Float_t diff = ModuleTimes[i]-MinTime;
119 if (diff<time_window) {
121 fModuleFired[i]=kTRUE;
124 cout << " fSingleMuon " << fSingleMuon
125 << " MinTime " << MinTime
126 << " fMultiMuon " << fMultiMuon << endl;
127 // 5.- Set the relevant trigger
128 fSingleMuon = MinTimeModule;
130 if (fMultiMuon>=MultiMin) SetInput( "0AMU" );