00001 #ifndef PULSE_ANALYZER_CC
00002 #define PULSE_ANALYZER_CC
00003
00004 #include "pulse_analyzer.hh"
00005
00006 pulse_analyzer::pulse_analyzer() {
00007 _name="pulse_analyzer";
00008 _pulse_type=DATA_STRUCT::THRES_WIN_PULSE_COLLECTION;
00009 }
00010
00011 bool pulse_analyzer::initialize() {
00012
00013 TString tree_name(Form("%s_tree",DATA_STRUCT::DATA_TREE_NAME[_pulse_type].c_str()));
00014 tree_name.ReplaceAll("pulse_","");
00015 tree_name.ReplaceAll("_window","");
00016
00017 _fout->cd();
00018
00019 _ch_tree = new TTree(tree_name.Data(),"");
00020 _ch_tree->Branch("event_id",&_event_id,"event_id/I");
00021 _ch_tree->Branch("frame_id",&_ch_frame_id,"frame_id/I");
00022 _ch_tree->Branch("sample_id",&_ch_sample_id,"sample_id/I");
00023 _ch_tree->Branch("disc_id",&_disc_id,"disc_id/I");
00024 _ch_tree->Branch("ch",&_ch,"ch/I");
00025 _ch_tree->Branch("charge",&_wf_charge,"charge/D");
00026 _ch_tree->Branch("peak",&_wf_peak,"peak/D");
00027 _ch_tree->Branch("t_start",&_wf_ts,"t_start/D");
00028 _ch_tree->Branch("t_max",&_wf_tm,"t_max/D");
00029 _ch_tree->Branch("t_end",&_wf_te,"t_end/D");
00030 _ch_tree->Branch("ped_mean",&_ped_mean,"ped_mean/D");
00031 _ch_tree->Branch("ped_rms",&_ped_rms,"ped_rms/D");
00032 _ch_tree->Branch("nsample",&_nsample,"nsample/I");
00033
00034 return true;
00035 }
00036
00037 bool pulse_analyzer::analyze(storage_manager* storage) {
00038
00039 pulse_collection *pulses = (pulse_collection*)(storage->get_data(_pulse_type));
00040 pmt_wf_collection *wfs = (pmt_wf_collection*)(storage->get_data(DATA_STRUCT::PMT_WF_COLLECTION));
00041
00042 if(pulses->size()==0) {
00043 Message::send(MSG::ERROR,__FUNCTION__,"No Pulse Found!");
00044 return false;
00045 }
00046 if(wfs->size()==0) {
00047 Message::send(MSG::ERROR,__FUNCTION__,"No Waveforms Found!");
00048 return false;
00049 }
00050
00051
00052 for(pulse_collection::const_iterator iter(pulses->begin());
00053 iter!=pulses->end();
00054 ++iter){
00055 _ch = (*iter).channel_number();
00056 _ch_frame_id = (*iter).frame_id();
00057 _ch_sample_id = (*iter).timeslice();
00058 _disc_id = (int)((*iter).disc_id());
00059 _wf_charge = (*iter).charge();
00060 _wf_peak = (*iter).pulse_peak();
00061 _wf_ts = (*iter).start_time();
00062 _wf_tm = (*iter).max_time();
00063 _wf_te = (*iter).end_time();
00064 _ped_mean = (*iter).ped_mean();
00065 _ped_rms = (*iter).ped_rms();
00066 _ch_tree->Fill();
00067
00068 }
00069
00070 return true;
00071 }
00072
00073 bool pulse_analyzer::finalize() {
00074
00075
00076
00077
00078
00079
00080 _fout->cd();
00081 _ch_tree->Write();
00082 return true;
00083 }
00084
00085 #endif