1919#include " DetectorsDCS/DeliveryType.h"
2020#include " CCDB/CcdbObjectInfo.h"
2121#include " CommonUtils/MemFileHelper.h"
22+ #include " DataFormatsTRD/DcsCcdbObjects.h"
23+ #include " DataFormatsTRD/Constants.h"
24+
2225#include " CCDB/CcdbApi.h"
2326#include < Rtypes.h>
2427#include < unordered_map>
2528#include < string>
29+ #include < bitset>
2630#include < gsl/gsl>
2731
2832// / @brief Class to process TRD DCS data points
@@ -36,18 +40,6 @@ using DPID = o2::dcs::DataPointIdentifier;
3640using DPVAL = o2::dcs::DataPointValue;
3741using DPCOM = o2::dcs::DataPointCompositeObject;
3842
39- struct TRDDCSMinMaxMeanInfo {
40- float minValue{0 .f }; // min value seen by the TRD DCS processor
41- float maxValue{0 .f }; // max value seen by the TRD DCS processor
42- float meanValue{0 .f }; // mean value seen by the TRD DCS processor
43- int nPoints{0 }; // number of values seen by the TRD DCS processor
44-
45- void print () const ;
46- void addPoint (float value);
47-
48- ClassDefNV (TRDDCSMinMaxMeanInfo, 1 );
49- };
50-
5143class DCSProcessor
5244{
5345
@@ -58,44 +50,91 @@ class DCSProcessor
5850 DCSProcessor () = default ;
5951 ~DCSProcessor () = default ;
6052
53+ // initialization based on configured DP IDs
6154 void init (const std::vector<DPID >& pids);
6255
56+ // processing methods
6357 int process (const gsl::span<const DPCOM > dps);
6458 int processDP (const DPCOM & dpcom);
6559 int processFlags (uint64_t flag, const char * pid);
6660
67- void updateDPsCCDB ();
68-
69- const CcdbObjectInfo& getccdbDPsInfo () const { return mCcdbDPsInfo ; }
70- CcdbObjectInfo& getccdbDPsInfo () { return mCcdbDPsInfo ; }
71- const std::unordered_map<DPID , TRDDCSMinMaxMeanInfo>& getTRDDPsInfo () const { return mTRDDCS ; }
72-
73- template <typename T>
74- void prepareCCDBobjectInfo (T& obj, CcdbObjectInfo& info, const std::string& path, TFType tf,
75- const std::map<std::string, std::string>& md);
76-
77- void setStartValidity (TFType tf) { mStartValidity = tf; }
78- void useVerboseMode () { mVerbose = true ; }
79-
80- void clearDPsinfo ()
81- {
82- mDpsDoublesmap .clear ();
83- mTRDDCS .clear ();
84- }
61+ // these functions prepare the CCDB objects
62+ bool updateGasDPsCCDB ();
63+ bool updateVoltagesDPsCCDB ();
64+ bool updateCurrentsDPsCCDB ();
65+ bool updateEnvDPsCCDB ();
66+ bool updateRunDPsCCDB ();
67+
68+ // signal that the CCDB object for the voltages should be updated due to change exceeding threshold
69+ bool shouldUpdateVoltages () const { return mShouldUpdateVoltages ; }
70+ bool shouldUpdateRun () const { return mShouldUpdateRun ; }
71+
72+ // allow access to the CCDB objects from DPL processor
73+ CcdbObjectInfo& getccdbGasDPsInfo () { return mCcdbGasDPsInfo ; }
74+ CcdbObjectInfo& getccdbVoltagesDPsInfo () { return mCcdbVoltagesDPsInfo ; }
75+ CcdbObjectInfo& getccdbCurrentsDPsInfo () { return mCcdbCurrentsDPsInfo ; }
76+ CcdbObjectInfo& getccdbEnvDPsInfo () { return mCcdbEnvDPsInfo ; }
77+ CcdbObjectInfo& getccdbRunDPsInfo () { return mCcdbRunDPsInfo ; }
78+ const std::unordered_map<DPID , TRDDCSMinMaxMeanInfo>& getTRDGasDPsInfo () const { return mTRDDCSGas ; }
79+ const std::unordered_map<DPID , float >& getTRDVoltagesDPsInfo () const { return mTRDDCSVoltages ; }
80+ const std::unordered_map<DPID , TRDDCSMinMaxMeanInfo>& getTRDCurrentsDPsInfo () const { return mTRDDCSCurrents ; }
81+ const std::unordered_map<DPID , TRDDCSMinMaxMeanInfo>& getTRDEnvDPsInfo () const { return mTRDDCSEnv ; }
82+ const std::unordered_map<DPID , int >& getTRDRunDPsInfo () const { return mTRDDCSRun ; }
83+
84+ // settings
85+ void setCurrentTS (TFType tf) { mCurrentTS = tf; }
86+ void setVerbosity (int v) { mVerbosity = v; }
87+
88+ // reset methods
89+ void clearGasDPsInfo ();
90+ void clearVoltagesDPsInfo ();
91+ void clearCurrentsDPsInfo ();
92+ void clearEnvDPsInfo ();
93+ void clearRunDPsInfo ();
94+
95+ // helper functions
96+ int getChamberIdFromAlias (const char * alias) const ;
8597
8698 private:
87- std::unordered_map<DPID , TRDDCSMinMaxMeanInfo> mTRDDCS ; // this is the object that will go to the CCDB
88- std::unordered_map<DPID , bool > mPids ; // contains all PIDs for the processor, the bool
89- // will be true if the DP was processed at least once
90- std::unordered_map<DPID , std::vector<DPCOM >> mDpsDoublesmap ; // this is the map that will hold the DPs for the
91- // double type
92-
93- CcdbObjectInfo mCcdbDPsInfo ;
94- TFType mStartTF ; // TF index for processing of first processed TF, used to store CCDB object
95- TFType mStartValidity = 0 ; // TF index for processing, used to store CCDB object
96- bool mStartTFset = false ;
97-
98- bool mVerbose = false ;
99+ // the CCDB objects
100+ std::unordered_map<DPID , TRDDCSMinMaxMeanInfo> mTRDDCSGas ; // /< gas DPs (CO2, O2, H20 and from the chromatograph CO2, N2, Xe)
101+ std::unordered_map<DPID , TRDDCSMinMaxMeanInfo> mTRDDCSCurrents ; // /< anode and drift currents
102+ std::unordered_map<DPID , float > mTRDDCSVoltages ; // /< anode and drift voltages
103+ std::unordered_map<DPID , TRDDCSMinMaxMeanInfo> mTRDDCSEnv ; // /< environment parameters (temperatures, pressures)
104+ std::unordered_map<DPID , int > mTRDDCSRun ; // /< run number and run type
105+ // TODO
106+ // Possibly add CFG tag and chamber status here?
107+ // Or send errors to the InfoLogger in case CFG tag mismatches are detected for chamber which have the same FSM state?
108+ // For this I need more information on the chamber status - which status indicates all good and included in data taking?
109+ // not TODO
110+ // I don't think the FED ENV temperature is needed at analysis level at any point in time so I am leaving it out for now
111+
112+ // helper variables
113+ std::unordered_map<DPID , bool > mPids ; // /< flag for each DP whether it has been processed at least once
114+ std::unordered_map<DPID , uint64_t > mLastDPTimeStamps ; // /< for each DP keep here the time stamp of the DP processed last
115+ CcdbObjectInfo mCcdbGasDPsInfo ;
116+ CcdbObjectInfo mCcdbVoltagesDPsInfo ;
117+ CcdbObjectInfo mCcdbCurrentsDPsInfo ;
118+ CcdbObjectInfo mCcdbEnvDPsInfo ;
119+ CcdbObjectInfo mCcdbRunDPsInfo ;
120+ TFType mGasStartTS ; // /< the time stamp of the first TF which was processesd for the current GAS CCDB object
121+ TFType mVoltagesStartTS ; // /< the time stamp of the first TF which was processesd for the current voltages CCDB object
122+ TFType mCurrentsStartTS ; // /< the time stamp of the first TF which was processesd for the current voltages CCDB object
123+ TFType mEnvStartTS ;
124+ TFType mRunStartTS ;
125+ TFType mRunEndTS ;
126+ TFType mCurrentTS {0 }; // /< the time stamp of the TF currently being processed
127+ bool mGasStartTSset {false };
128+ bool mVoltagesStartTSSet {false };
129+ bool mCurrentsStartTSSet {false };
130+ bool mEnvStartTSSet {false };
131+ bool mRunStartTSSet {false };
132+ std::bitset<constants::MAXCHAMBER > mVoltageSet {};
133+ bool mShouldUpdateVoltages {false };
134+ bool mShouldUpdateRun {false };
135+
136+ // settings
137+ int mVerbosity {0 };
99138
100139 ClassDefNV (DCSProcessor, 0 );
101140};
0 commit comments