EMCAL cells and PHOS cells separated.
[u/mrichter/AliRoot.git] / STEER / AliTriggerDetector.cxx
CommitLineData
a5a091ce 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///////////////////////////////////////////////////////////////////////////////
19// //
20// Base Class for Detector specific Trigger // //
21// //
22// //
23// //
24// //
25// //
26///////////////////////////////////////////////////////////////////////////////
27
bacbe0fd 28#include <Riostream.h>
a5a091ce 29#include <TNamed.h>
30#include <TString.h>
31#include <TObjArray.h>
32#include <TRandom.h>
33
34
35#include "AliLog.h"
36#include "AliRun.h"
37#include "AliRunLoader.h"
38
39#include "AliTriggerInput.h"
40#include "AliTriggerDetector.h"
41
42
43
44ClassImp( AliTriggerDetector )
45
46//_____________________________________________________________________________
75e3794b 47AliTriggerDetector::AliTriggerDetector() :
48 TNamed(),
49 fMask(0),
50 fInputs()
a5a091ce 51{
52 // Default constructor
a5a091ce 53}
54
55//_____________________________________________________________________________
56void AliTriggerDetector::CreateInputs()
57{
58 // Define the inputs to the Central Trigger Processor
59 // This is a dummy version
60
61 // Do not create inputs again!!
62 if( fInputs.GetEntriesFast() > 0 ) return;
63
64 TString name = GetName();
65 fInputs.AddLast( new AliTriggerInput( name+"_TEST1_L0", "Dummy input 1", 0x01 ) );
66 fInputs.AddLast( new AliTriggerInput( name+"_TEST2_L0", "Dummy input 2", 0x02 ) );
67 fInputs.AddLast( new AliTriggerInput( name+"_TEST3_L0", "Dummy input 3", 0x04 ) );
68}
69
70//_____________________________________________________________________________
71void AliTriggerDetector::Trigger()
72{
73 // This is a dummy version set all inputs in a random way
74
75 AliWarning( Form( "Triggering dummy detector %s", GetName() ) );
76
77 // ********** Get Digits for the current event **********
78 AliRunLoader* runLoader = gAlice->GetRunLoader();
79 AliInfo( Form( "Event %d", runLoader->GetEventNumber() ) );
80
81 TString loadername = GetName();
82 loadername.Append( "Loader" );
83 AliLoader * loader = runLoader->GetLoader( loadername.Data() );
84 if( loader ) {
85 loader->LoadDigits( "READ" );
86 TTree* digits = loader->TreeD();
87 // Do something with the digits !!!
88 if( digits ) {
89// digits->Print();
90 }
91 loader->UnloadDigits();
92 }
93 // ******************************************************
94
95 // set all inputs in a random way
96 Int_t nInputs = fInputs.GetEntriesFast();
97 for( Int_t j=0; j<nInputs; j++ ) {
98 AliTriggerInput* in = (AliTriggerInput*)fInputs.At( j );
99 if( gRandom->Rndm() > 0.5 ) {
100 in->Set();
101 fMask |= in->GetValue();
102 }
103 }
104}
105
106//_____________________________________________________________________________
107void AliTriggerDetector::SetInput( TString& name )
108{
109 // Set Input by name
92c1978f 110 SetInput( name.Data() );
a5a091ce 111}
112
113//_____________________________________________________________________________
114void AliTriggerDetector::SetInput( const char * name )
115{
116 // Set Input by name
117 AliTriggerInput* in = ((AliTriggerInput*)fInputs.FindObject( name ));
92c1978f 118 if( in ) {
119 in->Set();
120 fMask |= in->GetValue();
121 } else
122 AliError( Form( "There is not input named %s", name ) );
a5a091ce 123}
124
125//_____________________________________________________________________________
126void AliTriggerDetector::SetInput( Int_t mask )
127{
128 // Set Input by mask
129 Int_t nInputs = fInputs.GetEntriesFast();
130 for( Int_t j=0; j<nInputs; j++ ) {
131 AliTriggerInput* in = (AliTriggerInput*)fInputs.At( j );
132 if( in->GetMask() == mask ) {
133 in->Set();
134 fMask |= in->GetValue();
135 break;
136 }
137 }
138}
139
bacbe0fd 140//_____________________________________________________________________________
141void AliTriggerDetector::Print( const Option_t* opt ) const
142{
143 // Print
144 cout << "Trigger Detector : " << GetName() << endl;
145 cout << " Trigger Class Mask: 0x" << hex << GetMask() << dec << endl;
146 Int_t nInputs = fInputs.GetEntriesFast();
147 for( Int_t j=0; j<nInputs; j++ ) {
148 AliTriggerInput* in = (AliTriggerInput*)fInputs.At( j );
149 in->Print( opt );
150 }
151}