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