Update master to aliroot
[u/mrichter/AliRoot.git] / STEER / ESD / AliTriggerConfiguration.h
1 #ifndef ALITRIGGERCONFIGURATION_H
2 #define ALITRIGGERCONFIGURATION_H
3
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice                               */
6
7 ///////////////////////////////////////////////////////////////////////////////
8 //                                                                           //
9 // This class represents the CTP configuration                               //
10 //                                                                           //
11 //                                                                           //
12 // A Trigger Configuration define a trigger setup for particula run          //
13 // We have default one for different running modes                           //
14 // (Pb-Pb, p-p, p-A, Calibration, etc).                                      //
15 // It keep:                                                                  //
16 //   All the information contained in the real CTP configuration file        //
17 //   used online during the data taking.                                     //
18 //                                                                           //
19 //                                                                           //
20 ///////////////////////////////////////////////////////////////////////////////
21
22 #include <TNamed.h>
23 #include <TObjArray.h>
24 class TString;
25
26 class AliTriggerCluster;
27 class AliTriggerDescriptor;
28 class AliTriggerInput;
29 class AliTriggerInteraction;
30 class AliTriggerPFProtection;
31 class AliTriggerBCMask;
32 class AliTriggerClass;
33
34 class AliTriggerConfiguration : public TNamed {
35
36 public:
37                           AliTriggerConfiguration();
38                           AliTriggerConfiguration( TString & name, TString & description );
39                virtual   ~AliTriggerConfiguration();
40    //  Setters
41        AliTriggerInput*   AddInput(TString &name, TString &det, UChar_t level, UInt_t signature, UChar_t number);
42                 Bool_t    AddInput(AliTriggerInput *input);
43
44  AliTriggerInteraction*   AddInteraction(TString &name, TString &logic);
45                 Bool_t    AddInteraction(AliTriggerInteraction *interact);
46
47  AliTriggerInteraction*   AddFunction(TString &name, TString &logic);
48                 Bool_t    AddFunction(AliTriggerInteraction *func);
49
50                 Bool_t    AddPFProtection( AliTriggerPFProtection* pf );
51
52       AliTriggerBCMask*   AddMask( TString &name, TString &mask );
53                 Bool_t    AddMask( AliTriggerBCMask* mask );
54
55      AliTriggerCluster*   AddCluster( TString &name, UChar_t index, TString &detectors );
56                 Bool_t    AddCluster( AliTriggerCluster* cluster );
57
58   AliTriggerDescriptor*   AddDescriptor( TString & name, TString & cond);
59                 Bool_t    AddDescriptor( AliTriggerDescriptor* desc );
60
61        AliTriggerClass*   AddClass( TString &name, UChar_t index,
62                                     AliTriggerDescriptor *desc, AliTriggerCluster *clus,
63                                     AliTriggerPFProtection *pfp, AliTriggerBCMask *mask,
64                                     UInt_t prescaler, Bool_t allrare);
65        AliTriggerClass*   AddClass( TString &name, UChar_t index,
66                                     TString &desc, TString &clus,
67                                     TString &pfp, TString &mask,
68                                     UInt_t prescaler, Bool_t allrare);
69                  Bool_t   AddClass( AliTriggerClass *trclass);
70
71                    void   Reset();
72
73   //  Getters
74                TString    GetActiveDetectors() const;
75                TString    GetTriggeringDetectors() const;
76                TString    GetTriggeringModules() const;
77
78        const TObjArray&   GetInputs() const { return fInputs; }
79        const TObjArray&   GetInteractions() const { return fInteractions; }
80        const TObjArray&   GetFunctions() const { return fFunctions; }
81        const TObjArray&   GetPFProtections() const { return fPFProtections; }
82        const TObjArray&   GetMasks() const { return fMasks; }
83        const TObjArray&   GetClusters() const { return fClusters; }
84        const TObjArray&   GetDescriptors() const { return fDescriptors; }
85        const TObjArray&   GetClasses() const { return fClasses; }
86
87                   Int_t   GetVersion() const { return fVersion; }
88                   Int_t   GetClassIndexFromName(const char* className) const;
89              const char*  GetClassNameFromIndex(Int_t classIndex) const;
90         AliTriggerClass*  GetTriggerClass(Int_t classIndex) const;
91        //     AliTriggerCluster*   GetTriggerCluster(UInt_t index)
92        //       { return (index < kNMaxClusters) ? (AliTriggerCluster*)fClusters[index] : NULL; }
93
94        //AliTriggerPFProtection*   GetPFProtection(UInt_t index)
95        //              { return (index < kNMaxPFProtections) ? (AliTriggerPFProtection*)fPFProtections[index] : NULL; }
96                   void    Print( const Option_t* opt ="" ) const;
97
98   //  Configurations Database (root file)
99                   void    WriteConfiguration( const char* filename="" );
100       static TObjArray*   GetAvailableConfigurations( const char* filename="" );
101
102       static AliTriggerConfiguration* LoadConfiguration(TString & des);
103       static AliTriggerConfiguration* LoadConfigurationFromString(const char* configuration);
104       Bool_t    IsSelected( TString detName, TString & detectors ) const;
105
106       enum {kNMaxInputs = 60}; // CTP handles up to 60 trigger detector inputs
107       enum {kNMaxInteractions = 2}; // CTP handles up to two different interactions
108       enum {kNMaxFunctions = 4}; // CTP handles up to 4 different logical functions
109       enum {kNMaxClasses = 100}; // Maximum number of trigger classes = 50
110       enum {kNMaxClusters = 8}; // Maximum number of different detector clusters that can be handled by CTP
111       enum {kNMaxPFProtections = 4}; // Maximum number of different past-future protections that can be handled by CTP
112       enum {kNMaxMasks = 13};  // CTP handles up to 12 different BC masks + NONE
113
114 private:
115       Bool_t ProcessConfigurationLine(const char* line, Int_t& level);
116
117       TObjArray            fInputs;                           // Array with active CTP inputs
118       TObjArray            fInteractions;                     // Array with the trigger interactions
119       TObjArray            fFunctions;                        // Array with the logical functions of the first 4 inputs
120       TObjArray            fPFProtections;                    // Array of Past-Future Protections
121       TObjArray            fMasks;                            // Array with BC masks
122       TObjArray            fDescriptors;                      // Array with trigger descriptors
123       TObjArray            fClusters;                         // Array of Detector Trigger Clusters
124       TObjArray            fClasses;                          // Array of Trigger Classes
125
126       Int_t                fVersion;                          // Configuration format version
127
128    static const TString    fgkConfigurationFileName;        //! name of default configurations file
129
130    AliTriggerConfiguration&   operator=(const AliTriggerConfiguration& des);
131    AliTriggerConfiguration( const AliTriggerConfiguration& des );
132
133    ClassDef( AliTriggerConfiguration, 3 )  // Define a trigger configuration
134 };
135
136 #endif