59 std::cerr <<
"MagnifySource: called " <<
m_calls <<
" times\n";
61 std::cerr <<
"MagnifySource: past EOS\n";
65 std::cerr <<
"MagnifySource: EOS\n";
72 TFile* tfile = TFile::Open(url.c_str());
78 TTree *trun = (TTree*)tfile->Get(
"Trun");
80 std::cerr <<
"No tree: Trun in input file \n";
84 trun->SetBranchAddress(
"eventNo", &frame_ident);
85 trun->SetBranchAddress(
"total_time_bin", &nticks);
90 std::cerr <<
"MagnifySource: frame ident="<<frame_ident<<
", time=0, nticks="<<nticks<<
"\n";
94 for (
auto jcmmtree :
m_cfg[
"cmmtree"]) {
95 auto cmmkey = jcmmtree[0].asString();
96 auto treename = jcmmtree[1].asString();
97 TTree *tree =
dynamic_cast<TTree*
>(tfile->Get(treename.c_str()));
99 std::cerr <<
"MagnifySource: failed to find tree \"" << treename <<
"\" in " << tfile->GetName() <<
std::endl;
100 THROW(IOError() <<
errmsg{
"MagnifySource: failed to find tree."});
103 std::cerr <<
"MagnifySource: loading channel mask \"" << cmmkey <<
"\" from tree \"" << treename <<
"\"\n";
105 int chid=0, plane=0, start_time=0, end_time=0;
106 tree->SetBranchAddress(
"chid",&chid);
107 tree->SetBranchAddress(
"plane",&plane);
108 tree->SetBranchAddress(
"start_time",&start_time);
109 tree->SetBranchAddress(
"end_time",&end_time);
111 const int nentries = tree->GetEntries();
112 for (
int ientry = 0; ientry < nentries; ++ientry){
113 tree->GetEntry(ientry);
115 br.first = start_time;
116 br.second = end_time;
117 cmm[cmmkey][chid].push_back(br);
123 std::unordered_map<IFrame::tag_t, IFrame::trace_list_t>
tagged_traces;
126 for (
auto jtag : m_cfg[
"frames"]) {
127 auto frametag = jtag.asString();
128 int channel_number = 0;
129 for (
int iplane=0; iplane<3; ++iplane) {
130 std::string plane_name = Form(
"%cplane",
'u'+iplane);
131 std::string hist_name = Form(
"h%c_%s",
'u'+iplane, frametag.c_str());
132 std::cerr <<
"MagnifySource: loading " << hist_name <<
std::endl;
133 TH2*
hist = (TH2*)tfile->Get(hist_name.c_str());
137 int nchannels = hist->GetNbinsX();
138 int nticks = hist->GetNbinsY();
142 for (
int chip = 0; chip<nchannels; ++chip) {
143 const int ichbin = chip+1;
146 for (
int itickbin = 1; itickbin <=
nticks; ++itickbin) {
147 auto q = hist->GetBinContent(ichbin, itickbin);
148 charges.push_back(q);
151 const size_t index = all_traces.size();
152 tagged_traces[frametag].push_back(index);
153 all_traces.push_back(std::make_shared<SimpleTrace>(channel_number, 0, charges));
157 std::cerr <<
"MagnifySource: plane " << iplane
158 <<
": " << nchannels <<
" X " << nticks
166 auto sframe =
new SimpleFrame(frame_ident, frame_time,
168 for (
auto const& it : tagged_traces) {
169 sframe->tag_traces(it.first, it.second);
170 std::cerr <<
"MagnifySource: tag " << it.second.size() <<
" traces as: \"" << it.first <<
"\"\n";
std::shared_ptr< const IFrame > pointer
boost::error_info< struct tag_errmsg, std::string > errmsg
static const double microsecond
std::vector< pointer > vector
static ITrace::vector tagged_traces(IFrame::pointer frame, IFrame::tag_t tag)
std::vector< float > ChargeSequence
Sequential collection of charge.
QTextStream & endl(QTextStream &s)