AdcChannelDataTester.cxx
Go to the documentation of this file.
1 // AdcChannelDataTester.cxx
2 
3 #include "AdcChannelDataTester.h"
6 #include <ostream>
7 #include <iomanip>
8 
9 using std::string;
10 using std::cout;
11 using std::endl;
12 using std::setw;
13 using Index = unsigned int;
14 
15 //**********************************************************************
16 
18 fill(AdcChannelData& acd, Index icha, Index isam0) {
19  const string myname = "AdcChannelDataTester::fill: ";
21  acd.setChannelInfo(icha);
22  acd.pedestal = pedestal;
23  acd.sampleUnit = "ke";
24  if ( acd.raw.size() < nsam ) acd.raw.resize(nsam, 0);
25  if ( acd.samples.size() < nsam ) acd.samples.resize(nsam, 0.0);
26  for ( Index isam=0; isam<rawwf.size(); ++isam ) {
27  Index ksam = (isam+isam0)%nsam;
28  acd.raw[ksam] += rawwf[isam];
29  }
30  for ( Index isam=0; isam<samwf.size(); ++isam ) {
31  Index ksam = (isam+isam0)%nsam;
32  acd.samples[ksam] += samwf[isam];
33  }
34  return 0;
35 }
36 
37 //**********************************************************************
38 
41  const string myname = "strumChannels: ";
42  Index ncha = a_ncha;
43  if ( ncha == 0 ) {
45  if ( pgeo->DetectorName() == "" ) {
46  cout << myname << "Geometry not found." << endl;
47  return 1;
48  }
49  ncha = pgeo->Nchannels();
50  }
51  for ( Index icha=0; icha<ncha; ++icha ) {
52  channel = icha;
53  fill(acds[icha], icha, icha);
54  }
55  return 0;
56 }
57 
58 //**********************************************************************
59 
60 // Strum all wires in a TPC.
61 
64  const string myname = "strumTpcWires: ";
65 
67  if ( pgeo->DetectorName() == "" ) {
68  cout << myname << "Geometry not found." << endl;
69  return 1;
70  }
71 
72  geo::TPCID tid(icry, itpc);
73  if ( ! pgeo->HasTPC(tid) ) {
74  cout << myname << "TPC not found: " << tid << endl;
75  return 2;
76  }
77  const geo::TPCGeo& gtpc = pgeo->TPC(tid);
78  Index npla = gtpc.Nplanes();
79  Index nsam = 500;
80  Index isam = 0;
81  for ( Index ipla=0; ipla<npla; ++ipla ) {
82  geo::PlaneID pid(tid, ipla);
83  const geo::PlaneGeo& gpla = gtpc.Plane(ipla);
84  Index nwir = gpla.Nwires();
85  for ( Index iwir=0; iwir<nwir; ++iwir ) {
86  geo::WireID wid(pid, iwir);
87  Index icha = pgeo->PlaneWireToChannel(wid);
88  fill(acds[channel], icha, isam);
89  if ( ++isam >= nsam ) isam = 0;
90  }
91  }
92 
93  return 0;
94 }
95 
96 //**********************************************************************
97 
98 // Strum all wires in a cryostat.
99 
102  const string myname = "strumCryoWires: ";
103 
105  if ( pgeo->DetectorName() == "" ) {
106  cout << myname << "Geometry not found." << endl;
107  return 1;
108  }
109 
110  const geo::CryostatGeo& gcry = pgeo->Cryostat(icry);
111  for ( Index itpc=0; itpc<gcry.NTPC(); ++itpc ) {
112  strumTpcWires(acds, itpc, icry);
113  }
114 
115  return 0;
116 }
117 
118 //**********************************************************************
119 
120 // Strum all wires in the detector.
121 
124  const string myname = "strumDetectorWires: ";
125 
127  if ( pgeo->DetectorName() == "" ) {
128  cout << myname << "Geometry not found." << endl;
129  return 1;
130  }
131 
132  Index ncry = pgeo->Ncryostats();
133  for ( Index icry=0; icry<ncry; ++icry ) {
134  strumCryoWires(acds, icry);
135  }
136 
137  return 0;
138 }
139 
140 //**********************************************************************
std::string string
Definition: nybbler.cc:12
unsigned int Nplanes() const
Number of planes in this tpc.
Definition: TPCGeo.h:165
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
Geometry information for a single TPC.
Definition: TPCGeo.h:38
unsigned int Index
Geometry information for a single cryostat.
Definition: CryostatGeo.h:43
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
art framework interface to geometry description
std::vector< float > samwf
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
int strumCryoWires(AdcChannelDataMap &acds, Index icry=0)
void setChannelInfo(ChannelInfoPtr pchi)
int fill(AdcChannelData &acd, Index icha, Index isam0)
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
int strumChannels(AdcChannelDataMap &acds, Index ncha=0)
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:82
void setEventInfo(EventInfoPtr pevi)
unsigned int NTPC() const
Number of TPCs in this cryostat.
Definition: CryostatGeo.h:181
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
AdcCountVector raw
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
bool HasTPC(geo::TPCID const &tpcid) const
Returns whether we have the specified TPC.
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
AdcSignal pedestal
unsigned int Nwires() const
Number of wires in this plane.
Definition: PlaneGeo.h:269
int strumTpcWires(AdcChannelDataMap &acds, Index itpc, Index icry=0)
std::map< AdcChannel, AdcChannelData > AdcChannelDataMap
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
PlaneGeo const & Plane(geo::View_t view) const
Return the plane in the tpc with View_t view.
Definition: TPCGeo.cxx:263
AdcSignalVector samples
int strumDetectorWires(AdcChannelDataMap &acds)
QTextStream & endl(QTextStream &s)
Event finding and building.
std::vector< short > rawwf