6 #ifndef BoDataFrameInput_h 7 #define BoDataFrameInput_h 1 106 produces<std::vector< raw::OpDetPulse> >();
110 std::string FullFilePath(
"");
111 cet::search_path sp(
"FW_SEARCH_PATH");
112 if( !sp.find_file(fInputFile, FullFilePath) )
113 throw cet::exception(
"BoDataFrameInput") <<
"Unable to find optical data file in " << sp.to_string() <<
"\n";
119 if(sub.substr(0,3)!=std::string(
"evt"))
121 mf::LogInfo(
"BoDataFrameInput")<<
"Warning: first command in text file is not an evt block as expected. Trying to persevere anyway : " << sub;
152 std::unique_ptr<std::vector< raw::OpDetPulse > > StoragePtr (
new std::vector<raw::OpDetPulse>);
155 std::vector<raw::OpDetPulse*> ThePulses;
164 mf::LogInfo(
"BoDataFrameInput")<<
"Reading optical pulses for event " <<evt.
id().
event() ;
165 std::vector<std::string> Commands;
166 std::vector<unsigned int> Values;
168 bool ContinueRead =
true;
170 std::string line(
"");
172 unsigned int CurrentChannel=0;
175 unsigned int ChannelsThisEvent=0;
176 unsigned int FEMModule=0;
177 unsigned int TriggerID=0;
178 unsigned int EventFrameNumber=0;
179 unsigned int TriggerTypeThisChannel=0;
180 unsigned int PMTFrameNumber=0;
182 unsigned int FirstSample=0;
184 std::map<int, std::vector<raw::OpDetPulse*> > PulsesThisEvent;
189 std::stringstream linestream(line);
190 while(linestream.good() && ContinueRead)
192 getline(linestream, sub,
',');
193 std::stringstream
ss(sub);
194 std::string Command(
"");
198 mf::LogInfo(
"BoDataFrameInput")<<
"Parsed a single line as C: " << Command<<
" V: "<<Value;
205 mf::LogInfo(
"BoDataFrameInput")<<
"Found start of next event, ID = " << Value<<
", finish frame readout";
208 else if(Command==
"nch")
211 if(ChannelsThisEvent==0)
212 ChannelsThisEvent=Value;
214 mf::LogInfo(
"BoDataFrameInput")<<
"Confused by data input: nch specified twice for the same event. Persevering anyway...";
216 else if(Command==
"mod")
222 else if(Command==
"tid")
228 else if(Command==
"efr")
231 EventFrameNumber=Value;
237 else if(Command==
"chn")
240 mf::LogInfo(
"BoDataFrameInput")<<
"Beginning channel " <<Value;
242 CurrentChannel = Value;
243 PulsesThisEvent[CurrentChannel].push_back(
new raw::OpDetPulse(CurrentChannel) );
248 else if(Command==
"cid")
252 TriggerTypeThisChannel=Value;
253 Value =TriggerTypeThisChannel;
255 else if(Command==
"smp")
259 PulsesThisEvent[CurrentChannel].at(PulsesThisEvent[CurrentChannel].size()-1)->SetFirstSample(FirstSample);
261 else if(Command==
"pfr")
280 int EvLowBits = EventFrameNumber & mask;
281 int EvHighBits = EventFrameNumber & ~mask;
283 if(Value < EvLowBits)
285 PMTFrameNumber = EvHighBits + 8 + Value;
287 else if(Value > EvLowBits)
289 PMTFrameNumber = EvHighBits + Value;
291 else if(Value == EvLowBits)
293 PMTFrameNumber = EvHighBits + EvLowBits;
297 mf::LogError(
"BoDataFrameInput") <<
"pfr routine confused - this should be impossible";
300 PulsesThisEvent[CurrentChannel].at(PulsesThisEvent[CurrentChannel].size()-1)->SetPMTFrame(PMTFrameNumber);
303 else if(Command==
"adc")
306 PulsesThisEvent[CurrentChannel].at(PulsesThisEvent[CurrentChannel].size()-1)->Waveform().push_back(Value);
313 for(std::map<
int, std::vector<raw::OpDetPulse*> >::
const_iterator it = PulsesThisEvent.begin();
314 it!=PulsesThisEvent.end(); ++it)
316 for(
size_t pulse=0; pulse!=it->second.size(); ++pulse)
318 StoragePtr->push_back( *(it->second.at(pulse)) );
322 evt.
put(std::move(StoragePtr));
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
ProductID put(std::unique_ptr< PROD > &&product)
contains objects relating to OpDet hits
#define DEFINE_ART_MODULE(klass)
T get(std::string const &key) const
EventNumber_t event() const
Tools and modules for checking out the basics of the Monte Carlo.
cet::coded_exception< error, detail::translate > exception