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