#include "DataFormat-TypeDef.hh"
#include <TF1.h>
#include <TMath.h>
Go to the source code of this file.
Functions | |
int | main () |
int main | ( | ) |
Definition at line 6 of file gen_sample_wf.cc.
References larlight::storage_manager::close(), larlight::storage_manager::get_data(), larlight::storage_manager::is_ready_io(), larlight::storage_manager::next_event(), larlight::storage_manager::open(), larlight::DATA::PMTFIFO, larlight::fifo::set_channel_number(), larlight::event_base::set_event_id(), larlight::storage_manager::set_io_mode(), larlight::storage_manager::set_out_filename(), larlight::event_base::set_run(), larlight::event_base::set_subrun(), and larlight::storage_manager::WRITE.
00006 { 00007 00008 // 00009 // A simple routine to generate a fake PMT waveform data file. 00010 // 00011 00012 // Prepare a fake waveform function 00013 TF1* f1 = new TF1("f1","100*(TMath::Poisson(x,[0]))",-1,21); 00014 f1->SetParameter(0,3); 00015 00016 // OK Let's create LArLight file and fill waveform 00017 larlight::storage_manager my_storage; 00018 00019 my_storage.set_io_mode(larlight::storage_manager::WRITE); 00020 00021 my_storage.set_out_filename("sample_pmt_waveform.root"); 00022 00023 my_storage.open(); 00024 00025 if(!my_storage.is_ready_io()) { 00026 std::cerr << "I/O preparation failed!" << std::endl; 00027 } 00028 00029 // Let's fill event_fifo for 100 events. 00030 larlight::event_pmtfifo* my_event_fifo = (larlight::event_pmtfifo*)(my_storage.get_data(larlight::DATA::PMTFIFO)); 00031 int run_id = 1; 00032 int subrun_id = 1; 00033 00034 for( int i=0; i<100; i++){ 00035 00036 int event_id = i; 00037 my_event_fifo->set_run(run_id); 00038 my_event_fifo->set_subrun(subrun_id); 00039 my_event_fifo->set_event_id(event_id); 00040 00041 // Let's fill 30 channels of PMT waveform all with cosmic discriminator threshold 00042 int n_channels=30; 00043 my_event_fifo->reserve(n_channels); 00044 for( int ch=0; ch<n_channels; ++ch) { 00045 00046 larlight::pmtfifo wf; 00047 00048 wf.set_channel_number(ch); 00049 //wf.set_disc_id(larlight::FEM::COSMIC_DISC); 00050 wf.reserve(20); 00051 for(size_t wf_index=0; wf_index<20; ++wf_index) 00052 00053 wf.push_back(f1->Eval((double)(wf_index - i%6))); 00054 00055 // Append 00056 my_event_fifo->push_back(wf); 00057 } 00058 00059 // Store & go next event 00060 my_storage.next_event(); 00061 00062 } 00063 00064 // End of event loop 00065 my_storage.close(); 00066 return 1; 00067 }