6fa82e7ac19f772a4ba4824f26cc0e3a3c3cbb96
[u/mrichter/AliRoot.git] / STEER / 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 AliTriggerDescriptor;
33 class AliTriggerClass;
34
35 class AliTriggerConfiguration : public TNamed {
36
37 public:
38                           AliTriggerConfiguration();
39                           AliTriggerConfiguration( TString & name, TString & description );
40                virtual   ~AliTriggerConfiguration();
41    //  Setters
42        AliTriggerInput*   AddInput(TString &name, TString &det, UChar_t level, UInt_t signature, UChar_t number);
43                 Bool_t    AddInput(AliTriggerInput *input);
44
45  AliTriggerInteraction*   AddInteraction(TString &name, TString &logic);
46                 Bool_t    AddInteraction(AliTriggerInteraction *interact);
47
48  AliTriggerInteraction*   AddFunction(TString &name, TString &logic);
49                 Bool_t    AddFunction(AliTriggerInteraction *func);
50
51                 Bool_t    AddPFProtection( AliTriggerPFProtection* pf );
52
53       AliTriggerBCMask*   AddMask( TString &name, TString &mask );
54                 Bool_t    AddMask( AliTriggerBCMask* mask );
55
56      AliTriggerCluster*   AddCluster( TString &name, UChar_t index, TString &detectors );
57                 Bool_t    AddCluster( AliTriggerCluster* cluster );
58
59   AliTriggerDescriptor*   AddDescriptor( TString & name, TString & cond);
60                 Bool_t    AddDescriptor( AliTriggerDescriptor* desc );
61
62        AliTriggerClass*   AddClass( TString &name, UChar_t index,
63                                     AliTriggerDescriptor *desc, AliTriggerCluster *clus,
64                                     AliTriggerPFProtection *pfp, AliTriggerBCMask *mask,
65                                     UInt_t prescaler, Bool_t allrare);
66        AliTriggerClass*   AddClass( TString &name, UChar_t index,
67                                     TString &desc, TString &clus,
68                                     TString &pfp, TString &mask,
69                                     UInt_t prescaler, Bool_t allrare);
70                  Bool_t   AddClass( AliTriggerClass *trclass);
71
72                    void   Reset();
73
74   //  Getters
75                TString    GetActiveDetectors() const;
76                TString    GetTriggeringDetectors() const;
77                TString    GetTriggeringModules() const;
78
79        const TObjArray&   GetInputs() const { return fInputs; }
80        const TObjArray&   GetInteractions() const { return fInteractions; }
81        const TObjArray&   GetFunctions() const { return fFunctions; }
82        const TObjArray&   GetPFProtections() const { return fPFProtections; }
83        const TObjArray&   GetMasks() const { return fMasks; }
84        const TObjArray&   GetClusters() const { return fClusters; }
85        const TObjArray&   GetDescriptors() const { return fDescriptors; }
86        const TObjArray&   GetClasses() const { return fClasses; }
87
88                   Int_t   GetVersion() const { return fVersion; }
89                   Int_t   GetClassIndexFromName(const char* className) const;
90              const char*  GetClassNameFromIndex(Int_t classIndex) const;
91         AliTriggerClass*  GetTriggerClass(Int_t classIndex) const;
92        //     AliTriggerCluster*   GetTriggerCluster(UInt_t index)
93        //       { return (index < kNMaxClusters) ? (AliTriggerCluster*)fClusters[index] : NULL; }
94
95        //AliTriggerPFProtection*   GetPFProtection(UInt_t index)
96        //              { return (index < kNMaxPFProtections) ? (AliTriggerPFProtection*)fPFProtections[index] : NULL; }
97                 Bool_t    CheckConfiguration( TString & configfile );
98                   void    Print( const Option_t* opt ="" ) const;
99
100   //  Configurations Database (root file)
101                   void    WriteConfiguration( const char* filename="" );
102       static TObjArray*   GetAvailableConfigurations( const char* filename="" );
103
104       static AliTriggerConfiguration* LoadConfiguration(TString & des);
105       static AliTriggerConfiguration* LoadConfigurationFromString(const char* configuration);
106
107       enum {kNMaxInputs = 60}; // CTP handles up to 60 trigger detector inputs
108       enum {kNMaxInteractions = 2}; // CTP handles up to two different interactions
109       enum {kNMaxFunctions = 2}; // CTP handles up to two different logical functions
110       enum {kNMaxClasses = 50}; // Maximum number of trigger classes = 50
111       enum {kNMaxClusters = 6}; // Maximum number of different detector clusters that can be handled by CTP
112       enum {kNMaxPFProtections = 4}; // Maximum number of different past-future protections that can be handled by CTP
113       enum {kNMaxMasks = 4};  // CTP handles up to 4 different BC masks
114
115 private:
116       Bool_t ProcessConfigurationLine(const char* line, Int_t& level);
117
118       TObjArray            fInputs;                           // Array with active CTP inputs
119       TObjArray            fInteractions;                     // Array with the trigger interactions
120       TObjArray            fFunctions;                        // Array with the logical functions of the first 4 inputs
121       TObjArray            fPFProtections;                    // Array of Past-Future Protections
122       TObjArray            fMasks;                            // Array with BC masks
123       TObjArray            fDescriptors;                      // Array with trigger descriptors
124       TObjArray            fClusters;                         // Array of Detector Trigger Clusters
125       TObjArray            fClasses;                          // Array of Trigger Classes
126
127       Int_t                fVersion;                          // Configuration format version
128
129                  Bool_t    IsSelected( TString detName, TString & detectors ) const;
130    static const TString    fgkConfigurationFileName;        //! name of default configurations file
131
132    AliTriggerConfiguration&   operator=(const AliTriggerConfiguration& des);
133    AliTriggerConfiguration( const AliTriggerConfiguration& des );
134
135    ClassDef( AliTriggerConfiguration, 2 )  // Define a trigger configuration
136 };
137
138 #endif