89 const string myname =
"AdcRoiToTree::viewMap: ";
91 TFile* pfil = TFile::Open(
m_OutFile.c_str(),
"UPDATE");
92 if ( pfil ==
nullptr || ! pfil->IsOpen() ) {
93 cout << myname <<
"ERROR: Unable to open output file " <<
m_OutFile <<
endl;
96 TTree* ptre =
dynamic_cast<TTree*
>(pfil->Get(
treeName().c_str()));
97 if ( ptre ==
nullptr ) {
98 cout << myname <<
"ERROR: Unable to open tree " <<
treeName() <<
endl;
104 tdat.nsam.resize(maxroi);
105 tdat.isam.resize(maxroi);
106 tdat.qroi.resize(maxroi);
107 tdat.hmin.resize(maxroi);
108 tdat.hmax.resize(maxroi);
109 ptre->SetBranchAddress(
"run", &tdat.run);
110 ptre->SetBranchAddress(
"event", &tdat.event);
111 ptre->SetBranchAddress(
"channel", &tdat.channel);
112 ptre->SetBranchAddress(
"status", &tdat.status);
114 float* pmd = &tdat.mdata[0];
116 ptre->SetBranchAddress(mnam.c_str(), pmd++);
118 ptre->SetBranchAddress(
"nroi", &tdat.nroi);
119 ptre->SetBranchAddress(
"nsam", &tdat.nsam[0]);
120 ptre->SetBranchAddress(
"isam", &tdat.isam[0]);
121 ptre->SetBranchAddress(
"qroi", &tdat.qroi[0]);
122 ptre->SetBranchAddress(
"hmin", &tdat.hmin[0]);
123 ptre->SetBranchAddress(
"hmax", &tdat.hmax[0]);
125 for (
const auto& iacd : acds ) {
128 tdat.event = acd.
event();
132 for (
Name mnam : m_MetadataFields ) {
134 cout << myname <<
"WARNING: Run/event/channel " 136 <<
" does not have metadata field " << mnam <<
endl;
140 tdat.nroi = acd.
rois.size();
142 for (
Index iroi=0; iroi<nroi; ++iroi ) {
149 bool haveSamples =
false;
150 if ( acd.
samples.size() > isam2 ) {
151 for (
Index isam=isam1; isam<=isam2; ++isam ) {
152 float qsam = acd.
samples[isam];
155 if ( qsam < hmin ) hmin = qsam;
156 if ( qsam > hmax ) hmax = qsam;
164 cout << myname <<
"WARNING: Ignoring missing samples for run " << acd.
run()
167 tdat.nsam[iroi] = 1 + isam2 - isam1;
168 tdat.isam[iroi] = isam1;
169 tdat.qroi[iroi] = qroi;
170 tdat.hmin[iroi] = hmin;
171 tdat.hmax[iroi] = hmax;
174 cout << myname <<
"Filling run " << tdat.run <<
", event " << tdat.event
175 <<
", channel " << tdat.channel <<
", nroi " << tdat.nroi <<
endl;
177 string spre = myname +
" nsam: [";
178 for (
Index iroi=0; iroi<nroi; ++iroi ) {
180 cout << tdat.nsam[iroi];
184 spre = myname +
" isam: [";
185 for (
Index iroi=0; iroi<nroi; ++iroi ) {
187 cout << tdat.isam[iroi];
191 spre = myname +
" qroi: [";
192 for (
Index iroi=0; iroi<nroi; ++iroi ) {
194 cout << tdat.qroi[iroi];
202 ptre->ResetBranchAddresses();
207 ret.
setInt(
"art_nfill", nfill);
DataMap & setStatus(int stat)
ChannelGroupService::Name Name
NameVector m_MetadataFields
bool hasMetadata(Name mname) const
float getMetadata(Name mname, float def=0.0) const
void setInt(Name name, int val)
Index channelStatus() const
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
QTextStream & endl(QTextStream &s)