led_pulse_analyzer.cc

Go to the documentation of this file.
00001 #ifndef LED_PULSE_ANALYZER_CC
00002 #define LED_PULSE_ANALYZER_CC
00003 
00004 #include "led_pulse_analyzer.hh"
00005 
00006 led_pulse_analyzer::led_pulse_analyzer() : _selector() { 
00007   _name="led_pulse_analyzer"; 
00008   _ch_tree = 0;
00009 }
00010 
00011 bool led_pulse_analyzer::initialize() {
00012 
00013   if(!_ch_tree){
00014 
00015     _ch_tree = new TTree("ch_tree","");
00016     _ch_tree->Branch("event_id",&_event_id,"event_id/I");
00017     _ch_tree->Branch("frame_id",&_ch_frame_id,"frame_id/I");
00018     _ch_tree->Branch("sample_id",&_ch_sample_id,"sample_id/I");
00019     _ch_tree->Branch("disc_id",&_disc_id,"disc_id/I");
00020     _ch_tree->Branch("ch",&_ch,"ch/I");
00021     _ch_tree->Branch("charge",&_wf_charge,"charge/D");
00022     _ch_tree->Branch("peak",&_wf_peak,"peak/D");
00023     _ch_tree->Branch("t_start",&_wf_ts,"t_start/D");
00024     _ch_tree->Branch("t_max",&_wf_tm,"t_max/D");
00025     _ch_tree->Branch("t_end",&_wf_te,"t_end/D");
00026     _ch_tree->Branch("ped_mean",&_ped_mean,"ped_mean/D");
00027     _ch_tree->Branch("ped_rms",&_ped_rms,"ped_rms/D");
00028     _ch_tree->Branch("nsample",&_nsample,"nsample/I");
00029 
00030   }
00031 
00032   return _selector.initialize();
00033 }
00034 
00035 bool led_pulse_analyzer::analyze(storage_manager* storage) {
00036   
00037   pulse_collection *pulses = (pulse_collection*)(storage->get_data(_selector.pulse_type()));
00038 
00039   if(pulses->size()==0) {
00040     Message::send(MSG::ERROR,__FUNCTION__,"No Pulse Found!");
00041     return false;
00042   }
00043 
00044   if(!_selector.analyze(storage)) return false;
00045 
00046   // Fill data for this event
00047   for(pulse_collection::const_iterator iter(pulses->begin());
00048       iter!=pulses->end();
00049       ++iter){
00050 
00051     if( !( _selector.select_pulse(&(*iter))) ) continue;
00052       
00053     _ch           = (*iter).channel_number();
00054     _ch_frame_id  = (*iter).frame_id();
00055     _ch_sample_id = (*iter).timeslice();
00056     _disc_id      = (int)((*iter).disc_id());
00057     _wf_charge    = (*iter).charge();
00058     _wf_peak      = (*iter).pulse_peak();
00059     _wf_ts        = (*iter).start_time();
00060     _wf_tm        = (*iter).max_time();
00061     _wf_te        = (*iter).end_time();
00062     _ped_mean     = (*iter).ped_mean();
00063     _ped_rms      = (*iter).ped_rms();
00064     _ch_tree->Fill();
00065     
00066   }
00067   
00068   return true;
00069 }
00070 
00071 bool led_pulse_analyzer::finalize() {
00072 
00073   // This function is called at the end of event loop.
00074   // Do all variable finalization you wish to do here.
00075   // If you need, you can store your ROOT class instance in the output
00076   // file. You have an access to the output file through "_fout" pointer.
00077   //amplitude->Write();
00078   _fout->cd();
00079   _ch_tree->Write();
00080   return true;
00081 }
00082 
00083 #endif

Generated on Mon Apr 7 15:35:12 2014 for MyProject by  doxygen 1.4.7