00001 #include "TVAnalysedPulseGenerator.h" 00002 #include <iostream> 00003 #include "debug_tools.h" 00004 00005 TVAnalysedPulseGenerator::TVAnalysedPulseGenerator(const char* name, TAPGeneratorOptions* opts): 00006 fAdcToEnergyGain(1), fAdcToEnergyOffset(0){ 00007 if(opts){ 00008 fDebug=( opts->HasOption("debug") || opts->Debug()); 00009 } 00010 fSource.Generator()=IDs::generator(name,opts->StringDescription()); 00011 SetChannel(opts->GetChannel()); 00012 try{ 00013 fAdcToEnergyGain = SetupNavigator::Instance()->GetAdcToEnergyGain( GetChannel()); 00014 fAdcToEnergyOffset= SetupNavigator::Instance()->GetAdcToEnergyConstant(GetChannel()); 00015 fCanCalibrate=true; 00016 } catch(Except::InvalidDetector& e){ 00017 std::cout<<"TVAnalysedPulseGenerator: WARNING: No calibration data an be found for the '"<<GetChannel()<<"' channel." 00018 " Will continue, but TAPs will not have an energy value filled."<<std::endl; 00019 fCanCalibrate=false; 00020 } 00021 } 00022 00023 void TVAnalysedPulseGenerator::CalibratePulses(AnalysedPulseList& theAnalysedPulses)const{ 00024 if(fCanCalibrate){ 00025 for(AnalysedPulseList::iterator i_tap=theAnalysedPulses.begin(); i_tap != theAnalysedPulses.end(); ++i_tap){ 00026 const double amplitude=(*i_tap)->GetAmplitude(); 00027 (*i_tap)->SetEnergy(fAdcToEnergyGain * amplitude + fAdcToEnergyOffset); 00028 } 00029 } 00030 } 00031