Neutral Particle Spectrometer analysis code
Loading...
Searching...
No Matches
THcNPSConfigEvtHandler.cxx
Go to the documentation of this file.
2#include "THaGlobals.h"
3#include "THcGlobals.h"
4#include "THaRunBase.h"
5#include "THaEvData.h"
6#include "DAQconfig.h"
7#include "THcParmList.h"
8#include <sstream>
9
10using namespace std;
11
13//
14// Parse NPS FADC250 and VTP config data (ev 137) -- regular text
15//
17
18//_______________________________________________________________
20 const char* description ) :
21 THaEvtTypeHandler(name, description)
22{
23}
24
25//_______________________________________________________________
27{
28
29 for( auto& cfg : fNPSConfigList ) {
30 gHcParms->RemoveString(cfg.par);
31 }
32}
33
34//_______________________________________________________________
36{
37 // default event type for nps config
38 if( fEvtTypes.empty() ) {
39 fEvtTypes.push_back(137);
40 }
41
42 // default parameter list
43 fNPSConfigList.push_back( {Form("g%s_fadc250_sparsification", GetName()),"FADC250_SPARSIFICATION"} );
44 fNPSConfigList.push_back( {Form("g%s_vtp_clus_trig_thr", GetName()),"VTP_NPS_ECALCLUSTER_CLUSTER_TRIGGER_THR"} );
45 fNPSConfigList.push_back( {Form("g%s_vtp_clus_ro_thr", GetName()),"VTP_NPS_ECALCLUSTER_CLUSTER_READOUT_THR"} );
46 fNPSConfigList.push_back( {Form("g%s_vtp_pair_trig_thr", GetName()),"VTP_NPS_ECALCLUSTER_CLUSTER_PAIR_TRIGGER_THR"} );
47
48 return THaEvtTypeHandler::Init(date);
49}
50
51//_______________________________________________________________
53{
54 // We don't want to add this event type to the evt type list of THaEvtTypeHandler
55 // eventtypes from THaEvtTypeHandler is looked up by all inherited EvtTypeHandler classes
56 // Instead, we set the event types only relevant for this class
57
58 if( std::find(fEvtTypes.begin(), fEvtTypes.end(), evtype ) == fEvtTypes.end() )
59 fEvtTypes.push_back(evtype);
60}
61
62//_______________________________________________________________
63void THcNPSConfigEvtHandler::AddParameter(std::string parname, std::string keyname)
64{
65 fNPSConfigList.push_back( {Form("g%s_%s", GetName(), parname.data()), keyname} );
66}
67
68//_______________________________________________________________
70{
71 // all data parsed as a single string varaible
72
73 for( auto& cfg : fNPSConfigList ) {
74 if( !GetInfo(cfg.key.data()).empty() ) {
75 gHcParms->RemoveString(cfg.par);
76 gHcParms->AddString(cfg.par, GetInfo(cfg.key.data()) );
77 }
78 }
79
80}
81
82//_______________________________________________________________
83const string& THcNPSConfigEvtHandler::GetInfo(const char* parname )
84{
85 static const string nullstr;
86 auto it = fNPSConfigData.find(parname);
87 if( it != fNPSConfigData.end() )
88 return it->second;
89 else
90 return nullstr;
91}
92
93//_______________________________________________________________
95{
96
97 //std::cout << "********* THcNPSConfigEvtHandler::Analyze *********" << std::endl;
98
99 UInt_t evtype = evdata->GetEvType();
100
101 // Check event type
102 if( std::find(fEvtTypes.begin(), fEvtTypes.end(), evtype) == fEvtTypes.end() )
103 return -1;
104
105 auto* ifo = DAQInfoExtra::GetFrom(evdata->GetExtra());
106 if( !ifo ) return -1;
107
108 // Parse string and store (key, value) pairs into a new container
109 // VTP_* keys are missing when using THaRunBase::GetDAQInfo
110 // So we parse them separately here
111
112 for( auto& this_info : ifo->strings ) {
113 istringstream ifstr(this_info);
114 string line;
115 while( getline(ifstr, line) ) {
116 // skip blank lines
117 if( line.find_first_not_of(" \t") == string::npos )
118 continue;
119
120 auto items = Podd::vsplit(line);
121 if( !items.empty() ) {
122 string& key = items[0];
123 string val;
124 val.reserve(line.size());
125 for( size_t j = 1, e = items.size(); j < e; ++j ) {
126 val.append(items[j]);
127 if( j + 1 != e )
128 val.append(" ");
129 }
130 if( val != "end" )
131 fNPSConfigData.emplace(std::move(key), std::move(val));
132 }
133 }// getline
134 }
135
136 // Add to the gHcParm list
137 MakeParms();
138
139 /*
140 for( auto& keyval : ifo->keyval )
141 std::cout << keyval.first << "\t" << keyval.second << std::endl;
142 std::cout << "Print FADC Mode: " << gHaRun->GetDAQInfo("FADC250_SPARSIFICATION") << std::endl;
143 std::cout << "Print VTP Parameters: " << gHaRun->GetDAQInfo("VTP_FIRMWARETYPE") << std::endl;
144 std::cout << "Print VTP Parameters: " << gHaRun->GetDAQInfo("VTP_NPS_ECALCLUSTER_CLUSTER_TRIGGER_THR") << std::endl;
145 */
146
147 return 0;
148}
149
int Int_t
unsigned int UInt_t
#define e(i)
ClassImp(VDC::AnalyticTTDConv) using namespace std
R__EXTERN class THcParmList * gHcParms
char * Form(const char *fmt,...)
static DAQconfig * GetFrom(TObject *p)
UInt_t GetEvType() const
TObject * GetExtra() const
virtual void AddParameter(std::string parname, std::string keyname)
std::vector< UInt_t > fEvtTypes
const std::string & GetInfo(const char *parname)
std::map< std::string, std::string > fNPSConfigData
std::vector< NPSConfig > fNPSConfigList
THcNPSConfigEvtHandler(const char *name, const char *description="")
virtual Int_t Analyze(THaEvData *evdata)
virtual void AddEvtType(UInt_t evtype)
Int_t AddString(const std::string &name, const std::string &value)
void RemoveString(const std::string &name)
const char * GetName() const override
TLine * line
STL namespace.