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