00001 #ifndef TrigConf_TriggerItemNode
00002 #define TrigConf_TriggerItemNode
00003
00004 #include "TrigConfL1Data/L1DataDef.h"
00005
00006 #include <string>
00007 extern "C" {
00008 # include <stdint.h>
00009 }
00010
00011 namespace TrigConf {
00012
00013 class TriggerThreshold;
00014 class TriggerItemNode;
00015
00016 std::ostream & operator<<(std::ostream & o, const TrigConf::TriggerItemNode & node);
00017
00018 class TriggerItemNode {
00019 public:
00020 enum NodeType {OBJ, NOT, AND, OR, UNDEF};
00021 static NodeType typeFromString(const std::string&);
00022 static NodeType typeFromChar(const char& c);
00023 static std::string typeAsString(NodeType);
00024
00025 TriggerItemNode(NodeType);
00026 virtual ~TriggerItemNode();
00027
00028 typedef std::pair<L1DataDef::TriggerType,unsigned int> InternalType_t;
00029
00030 bool isThreshold() const;
00031 bool isInternalTrigger() const;
00032
00033
00034 void addChild(TriggerItemNode* node);
00035 const std::vector<TriggerItemNode*>& children() const { return m_Children; }
00036
00037
00038 void setThresholdName(const std::string thrname) { m_ThresholdName = thrname; }
00039 void setPosition(int pos) { m_Position = pos; }
00040 void setMultiplicity(int mult) { m_Multiplicity = mult; }
00041 void setTriggerThreshold(TriggerThreshold* thr);
00042 void setInternalTrigger(L1DataDef::TriggerType x, unsigned int thresholdNumber);
00043 void setInternalTrigger(const std::string& name);
00044
00045
00046 NodeType type() const { return m_NodeType; };
00047 const std::string& thresholdName() const { return m_ThresholdName; }
00048 int position() const { return m_Position; }
00049 int multiplicity() const { return m_Multiplicity; }
00050 TriggerThreshold* triggerThreshold() const { return m_Threshold; }
00051 L1DataDef::TriggerType internalTriggerType() const { return m_InternalTrigger.first; }
00052 unsigned int internalTriggerNumber() const { return m_InternalTrigger.second; }
00053
00054 void getAllFinalNodes(std::vector<const TriggerItemNode*>&) const;
00055 void getAllThresholds(std::vector<TriggerThreshold*>&) const;
00056 void getAllBunchGroups(std::vector<bool>&) const;
00057 void getBunchGroupsMask(uint16_t & bgmask) const;
00058 void getAllBunchGroups(std::vector<unsigned int>&) const;
00059 void getAllRandomTriggers(std::vector<unsigned int>&) const;
00060 void getAllPrescaledClockTriggers(std::vector<unsigned int>&) const;
00061
00062 void print(const std::string& indent="", unsigned int detail=1) const;
00063 void writeXML(std::ostream & xmlfile, int indentLevel=0, int indentWidth=2, bool omitDelimiter=false) const;
00064 void buildLogic(std::vector<std::string> & conditionList, std::string & logic) const;
00065
00066 virtual std::string __str__() const;
00067
00068 private:
00069 std::ostream & indent(std::ostream& o, int lvl, int size) const;
00070
00071 NodeType m_NodeType;
00072
00073
00074 std::vector<TriggerItemNode*> m_Children;
00075
00076
00077 std::string m_ThresholdName;
00078 int m_Position;
00079 int m_Multiplicity;
00080 TriggerThreshold* m_Threshold;
00081
00082
00083 InternalType_t m_InternalTrigger;
00084 };
00085
00086 }
00087
00088 #endif