00001 #include "TAPGeneratorFactory.h" 00002 #include "CFTimeAPGenerator.h" 00003 #include "TPulseIsland.h" 00004 #include "TAnalysedPulse.h" 00005 #include "SetupNavigator.h" 00006 00007 #include <numeric> 00008 #include <algorithm> 00009 #include <cmath> 00010 #include <exception> 00011 00012 00013 class OptionsError : public std::exception { 00014 const char* what() const throw () { 00015 return "Bad MODULES option"; 00016 } 00017 }; 00018 00019 CFTimeAPGenerator::CFTimeAPGenerator(TAPGeneratorOptions* opts): 00020 TVAnalysedPulseGenerator("CFTimeAPGenerator",opts), 00021 // Set-up the algorithm in the generator list (it looks a bit messy) 00022 fConstantFractionTime(SetupNavigator::Instance()->GetPedestal(GetChannel()), 00023 TSetupData::Instance()->GetTriggerPolarity(TSetupData::Instance()->GetBankName(GetChannel().str())), 00024 TSetupData::Instance()->GetClockTick(TSetupData::Instance()->GetBankName(GetChannel().str())), 00025 opts->GetDouble("time_shift", TSetupData::Instance()->GetTimeShift(TSetupData::Instance()->GetBankName(GetChannel().str()))), 00026 opts->GetDouble("constant_fraction", -0.10) 00027 ) { 00028 00029 } 00030 00031 int CFTimeAPGenerator::ProcessPulses(const PulseIslandList& pulseList, 00032 AnalysedPulseList& analysedList) { 00033 00034 for (unsigned int iTPI = 0; iTPI < pulseList.size(); ++iTPI) { 00035 TPulseIsland* tpi = pulseList.at(iTPI); 00036 00037 double time = fConstantFractionTime(tpi); 00038 00039 TAnalysedPulse* tap = MakeNewTAP(iTPI); 00040 tap->SetTime(time); 00041 analysedList.push_back(tap); 00042 } 00043 00044 return 0; 00045 } 00046 00047 // Similar to the modules, this macro registers the generator with 00048 // MakeAnalysedPulses. The first argument is compulsory and gives the name of 00049 // this generator. All subsequent arguments will be used as names for arguments 00050 // given directly within the modules file. See the github wiki for more. 00051 // 00052 // NOTE: for TAP generators OMIT the APGenerator part of the class' name 00053 ALCAP_TAP_GENERATOR(CFTime);