231 if (!digitVecHandle || !digitVecHandle->size())
return;
235 unsigned int dataSize = digitVec0->Samples();
237 std::cout <<
"!!!!! Bad dataSize: " << dataSize <<
std::endl;
241 std::vector<short> rawadc(dataSize);
244 std::map< raw::ChannelID_t, art::Ptr<raw::RawDigit> > rawdigitMap;
246 for (
size_t rdIter = 0; rdIter < digitVecHandle->size(); ++rdIter ) {
248 chnum = digitVec->Channel();
250 rawdigitMap[chnum]=digitVec;
255 if (!particleHandle){
257 <<
" No simb::MCParticle objects in this event - " 258 <<
" Line " << __LINE__ <<
" in file " << __FILE__ <<
std::endl;
264 if (!simChannelHandle->size())
return;
268 auto mcHandles =
evt.getMany<std::vector<simb::MCTruth>>();
269 std::vector< std::pair<int, std::string>> track_id_to_label;
271 for(
auto const& mcHandle : mcHandles ){
272 const std::string& sModuleLabel = mcHandle.provenance()->moduleLabel();
273 art::FindManyP<simb::MCParticle> findMCParts(mcHandle,
evt,
"largeant");
274 std::vector<art::Ptr<simb::MCParticle> > mcParts = findMCParts.at(0);
276 int track_id = ptr->TrackId();
277 gf->
add(track_id, sModuleLabel);
285 std::map<raw::ChannelID_t,std::map<int,WireSigInfo>>Ch2TrkWSInfoMap;
288 std::map<int,std::vector<raw::ChannelID_t>>Trk2ChVecMap;
292 for (
auto const&
channel : (*simChannelHandle) ){
299 bool selectThisChannel=
false;
302 std::map<int,WireSigInfo>Trk2WSInfoMap;
305 auto const& timeSlices =
channel.TDCIDEMap();
306 for (
auto const& timeSlice : timeSlices ){
308 auto const& energyDeposits = timeSlice.second;
309 auto const tpctime = timeSlice.first;
310 unsigned int tdctick =
static_cast<unsigned int>(clockData.TPCTDC2Tick(
double(tpctime)));
311 if(tdctick!=tpctime)std::cout <<
"tpctime: " << tpctime <<
", tdctick: " << tdctick <<
std::endl;
312 if(tdctick<0||tdctick>(dataSize-1))
continue;
315 for (
auto const& energyDeposit : energyDeposits ){
317 if (!energyDeposit.trackID)
continue;
318 int trkid = energyDeposit.trackID;
320 std::cout << energyDeposit.trackID <<
" " << trkid <<
" " << particle.
TrackId() <<
std::endl;
326 if (!eve_id)
continue;
329 if (Trk2WSInfoMap.find(trkid) == Trk2WSInfoMap.end()){
338 Trk2WSInfoMap.insert(std::pair<int,WireSigInfo>(trkid,wsinf));
340 if (tdctick<Trk2WSInfoMap.at(trkid).tdcmin)Trk2WSInfoMap.at(trkid).tdcmin=tdctick;
341 if (tdctick>Trk2WSInfoMap.at(trkid).tdcmax)Trk2WSInfoMap.at(trkid).tdcmax=tdctick;
342 Trk2WSInfoMap.at(trkid).edep +=energyDeposit.energy;
343 Trk2WSInfoMap.at(trkid).numel+=energyDeposit.numElectrons;
347 if(!Trk2WSInfoMap.empty()){
348 for(std::pair<int,WireSigInfo> itmap : Trk2WSInfoMap){
358 itmap.second.genlab.resize(6,
' ');
359 itmap.second.procid.resize(7,
' ');
364 int trkid = itmap.first;
365 if (Trk2ChVecMap.find(trkid) == Trk2ChVecMap.end()){
366 std::vector<raw::ChannelID_t>chvec;
367 Trk2ChVecMap.insert(std::pair<
int,std::vector<raw::ChannelID_t>>(trkid,chvec));
369 Trk2ChVecMap.at(trkid).push_back(ch1);
370 selectThisChannel=
true;
374 if(selectThisChannel){
375 Ch2TrkWSInfoMap.insert(std::pair<
raw::ChannelID_t,std::map<int,WireSigInfo>>(ch1,Trk2WSInfoMap));
382 if(!Trk2ChVecMap.empty()){
383 for(
auto const& ittrk : Trk2ChVecMap){
384 std::uniform_int_distribution<int> rndm_dist(0,ittrk.second.size()-1);
386 chnum=ittrk.second[i];
388 std::map<raw::ChannelID_t,std::map<int,WireSigInfo>>
::iterator itchn;
389 itchn = Ch2TrkWSInfoMap.find(chnum);
390 if( itchn != Ch2TrkWSInfoMap.end() ){
391 auto search = rawdigitMap.find(chnum);
392 if (
search == rawdigitMap.end() )
continue;
403 for (
auto const& it : itchn->second ){
417 for (
unsigned int i=icnt; i<5; ++i){
429 for (
unsigned int itck=0; itck<dataSize; ++itck ){
double E(const int i=0) const
float GetPedestal() const
int c2numpy_int32(c2numpy_writer *writer, int32_t data)
const ADCvector_t & ADCs() const
Reference to the compressed ADC count vector.
static std::string ViewName(geo::View_t view)
Returns the name of the specified view.
int c2numpy_int16(c2numpy_writer *writer, int16_t data)
void add(const int &track_id, const std::string &gname)
std::string Process() const
int c2numpy_uint16(c2numpy_writer *writer, uint16_t data)
int TrackIdToEveTrackId(int tid) const
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
int c2numpy_uint32(c2numpy_writer *writer, uint32_t data)
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
int c2numpy_string(c2numpy_writer *writer, const char *data)
raw::Compress_t Compression() const
Compression algorithm used to store the ADC counts.
simb::MCParticle TrackIdToMotherParticle(int const id) const
int c2numpy_float32(c2numpy_writer *writer, float data)
unsigned int ChannelID_t
Type representing the ID of a readout channel.
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
std::string get_gen(int tid)
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)