/** * @file SEightChan_swTrig.cpp * @author Dan Saunders, on behalf of the SoLid collaboration. * @date 19 Feb 2016 */ #include "SEightChan_swTrig.h" //============================================================================== //! Constructor setting up default values. SEightChan_swTrig::SEightChan_swTrig(SDetector * dtr, SClipboard * cb) : ISAlgorithm(dtr, cb, "SEightChan_swTrig"), m_nBytesIn(0) { // This is ROOTs fault - have tried a few different ways, but ROOT does not seem // to like putting these into a vector to begin with. br_waveforms.push_back(&br_waveform0); br_waveforms.push_back(&br_waveform1); br_waveforms.push_back(&br_waveform2); br_waveforms.push_back(&br_waveform3); br_waveforms.push_back(&br_waveform4); br_waveforms.push_back(&br_waveform5); br_waveforms.push_back(&br_waveform6); br_waveforms.push_back(&br_waveform7); } //============================================================================== //! Setup branches to intput tree and load files on the clipboard. void SEightChan_swTrig::initialize() { m_chain = new TChain("waveforms"); for (uint iC = 0; iC; (*br_waveforms[iC]) = 0; std::string name = "wf_chan" + std::to_string(iC); m_chain->SetBranchAddress(name.c_str(), br_waveforms[iC]); } if (cb()->inputDataFileNames()->size()==0) { std::cout<<"[Error]: Exiting since no input files specified"<inputDataFileNames())) { std::cout<<"[Note]: Adding input data file: "<Add(f.c_str()); if (status < 1) { std::cout<<"[Error]: Exiting due to problem adding file: "<GetEntry(0); std::cout<<"[Note]: ...done"<GetEntry(cb()->cycle()); std::string currentFileName(m_chain->GetFile()->GetName()); if (currentFileName != cb()->currentFileName()) updateConditions(); // Loop over each channel. for (uint iC=0; iCchannel(iC)->masked()) { uint64_t time = 0; SWaveform * w = new SWaveform(time, 0, dtr()->channel(iC)); for (uint i=0; i<(*br_waveforms[iC])->size(); i++) w->samples()->emplace_back(uint16_t((*br_waveforms[iC])->at(i))); cb()->waveforms()->push_back(w); dtr()->channel(iC)->addWaveform(w); } } // See if the last cycle. if (cb()->cycle() == m_chain->GetEntries()-1) setRunStopped(true); // Status print out. if (cb()->cycle() % 500 == 0) { std::cout<<"[Status Note]: Cycle: "<cycle()<<"\t"<<"Fraction data processed: "<< cb()->cycle()/(1.*m_chain->GetEntries())<cdns(); // Get the current tfile. TFile * currentFile = m_chain->GetFile(); // Get the conditions tree and setup branchs. TTree * t = (TTree*)currentFile->Get("conditions"); t->Print(); std::vector branchNames = {"HVbias", "initialtemp", "finaltemp", "LVtrims"}; std::vector branchTypes = {"double", "vector_doubles", "vector_doubles", "vector_doubles"}; uint nConditions = branchNames.size(); // Loop over branchs specified. for (uint i=0; iclear(); } // Set the cycle of update time. cdn->updateCycle = cb()->cycle(); if (branchTypes[i] == "double") { double val = -999; int status = t->SetBranchAddress(branchNames[i].c_str(), &val); if (status == -5) std::cout<<"[Warning]: Branch not found in conditions tree: "<GetEntry(0); cdn->vals.push_back(val); t->ResetBranchAddresses(); } } else if (branchTypes[i] == "vector_doubles") { std::vector * vals = 0; int status = t->SetBranchAddress(branchNames[i].c_str(), &vals); if (status == -5) std::cout<<"[Warning]: Branch not found in conditions tree: "<GetEntry(0); cdn->vals = (*vals); t->ResetBranchAddresses(); } } } cb()->setCurrentFileName(std::string(currentFile->GetName())); cb()->printConditions(); std::cout<<"[Note]: ... updating conditions done."<cycle()/float(m_chain->GetEntries())<