00001 #include "TAPGeneratorFactory.h" 00002 #include "%module%APGenerator.h" 00003 #include "TPulseIsland.h" 00004 #include "TAnalysedPulse.h" 00005 #include <iostream> 00006 using std::cout; 00007 using std::endl; 00008 00009 %module%APGenerator::%module%APGenerator(TAPGeneratorOptions* opts): 00010 TVAnalysedPulseGenerator("%module%",opts){ 00011 // Do things to set up the generator here. 00012 } 00013 00014 int %module%APGenerator::ProcessPulses( 00015 const PulseIslandList& pulseList, 00016 AnalysedPulseList& analysedList){ 00017 // Do something here that takes the TPIs in the PulseIslandList and 00018 // fills the list of TAPS 00019 00020 // Loop over all the TPIs given to us 00021 double amplitude; 00022 TAnalysedPulse* tap; 00023 for (PulseIslandList::const_iterator tpi=pulseList.begin(); 00024 tpi!=pulseList.end(); tpi++){ 00025 00026 // Analyse each TPI 00027 amplitude=(*tpi)->GetPulseHeight(); 00028 00029 // Now that we've found the information we were looking for make a TAP to 00030 // hold it. This method makes a TAP and sets the parent TPI info. It needs 00031 // the index of the parent TPI in the container as an argument 00032 tap = MakeNewTAP(tpi-pulseList.begin()); 00033 tap->SetAmplitude(amplitude); 00034 // Finally add the new TAP to the output list 00035 analysedList.push_back(tap); 00036 } 00037 00038 // Generators have a Debug method similar to modules 00039 if(Debug()){ 00040 // They also have a unique ID, retrievable by GetSource and 00041 // a GetChannel method to get the ID of just the channel 00042 cout<<"Now running source: "<<GetSource().str()<<" which looks for TAPs on " 00043 "channel: "<<GetChannel().str()<<'\n'; 00044 } 00045 00046 // returning 0 tells the caller that we were successful, return non-zero if not 00047 return 0; 00048 } 00049 00050 // Similar to the modules, this macro registers the generator with 00051 // MakeAnalysedPulses. The first argument is compulsory and gives the name of 00052 // this generator. All subsequent arguments will be used as names for arguments 00053 // given directly within the modules file. See the github wiki for more. 00054 // 00055 // NOTE: for TAP generators OMIT the APGenerator part of the class' name 00056 ALCAP_TAP_GENERATOR(%module%);