FembMappedAdcModifier_tool.cc
Go to the documentation of this file.
1 // FembMappedAdcModifier_tool.cc
2 
5 #include "TSystem.h"
6 #include <iostream>
7 #include <sstream>
8 
9 using std::string;
10 using std::cout;
11 using std::endl;
12 using std::ostringstream;
13 
14 using Name = std::string;
15 using ToolPtr = std::unique_ptr<TpcDataTool>;
16 
17 //**********************************************************************
18 
20 : m_LogLevel(ps.get<int>("LogLevel")),
21  m_ToolBase(ps.get<Name>("ToolBase")),
22  m_DirName(ps.get<Name>("DirName")) {
23  const string myname = "FembMappedAdcModifier::ctor: ";
24  if ( m_LogLevel >= 1 ) {
25  cout << myname << " Log level: " << m_LogLevel << endl;
26  cout << myname << " Tool base: " << m_ToolBase << endl;
27  cout << myname << " Fcl dir: " << m_DirName << endl;
28  }
29 }
30 
31 //**********************************************************************
32 
35  AdcChannelData acdtmp(acd);
36  acdtmp.samples = acd.samples;
37  return update(acdtmp);
38 }
39 
40 //**********************************************************************
41 
43  const string myname = "FembMappedAdcModifier::update: ";
44  DataMap res;
45  AdcChannel ifmb = acd.fembID();
46  ostringstream sstool;
47  sstool << m_ToolBase;
48  if ( ifmb == AdcChannelData::badIndex() ) sstool << "Default";
49  else sstool << ifmb;
50  Name toolName = sstool.str();
51  DuneToolManager* pdtm = nullptr;
52  std::unique_ptr<DuneToolManager> pdtmManaged;
53  if ( m_DirName.size() ) {
54  Name fclfile = m_DirName + "/" + toolName + ".fcl";
55  if ( gSystem->AccessPathName(fclfile.c_str()) ) {
56  cout << myname << "ERROR: No such file: " << fclfile << endl;
57  return res.setStatus(2000);
58  }
59  pdtmManaged.reset(new DuneToolManager(fclfile));
60  pdtm = pdtmManaged.get();
61  } else {
63  }
64  ToolPtr ptool = pdtm->getPrivate<TpcDataTool>(toolName);
65  if ( ptool == nullptr ) {
66  if ( m_LogLevel >= 2 ) {
67  cout << myname << "ERROR: Unable find tool " << toolName << endl;
68  }
69  return res.setStatus(1000);
70  }
71  return ptool->update(acd);
72 }
73 
74 //**********************************************************************
75 
#define DEFINE_ART_CLASS_TOOL(tool)
Definition: ToolMacros.h:42
static QCString result
DataMap view(const AdcChannelData &acd) const override
DataMap & setStatus(int stat)
Definition: DataMap.h:130
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
std::unique_ptr< TpcDataTool > ToolPtr
Index fembID() const
FembMappedAdcModifier(fhicl::ParameterSet const &ps)
static constexpr double ps
Definition: Units.h:99
std::unique_ptr< T > getPrivate(std::string name)
unsigned int AdcChannel
Definition: AdcTypes.h:50
DataMap update(AdcChannelData &acd) const override
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
static Index badIndex()
static DuneToolManager * instance(std::string fclname="", int dbg=1)
AdcSignalVector samples
QTextStream & endl(QTextStream &s)