34 const string myname =
"util::CrpGainService::ctor: ";
41 if( !m_LemEffTool.empty() )
48 cout << myname <<
"Unable to retrieve tool manaager." <<
endl;
55 cout << myname <<
"Unable to retrieve lem efficiency tool " << m_LemEffTool <<
endl;
72 cout<<myname<<
"Configurations\n";
74 cout<<myname<<
" CrpNominalGain : "<<m_CrpDefGain<<
endl;
75 cout<<myname<<
" CrpNumLem : "<<m_CrpNLem<<
endl;
76 cout<<myname<<
" LemViewChans : "<<m_LemViewChans<<
endl;
77 cout<<myname<<
" LemEffTool : "<<m_LemEffTool<<
" (@"<<
m_plemeff<<
")"<<
endl;
84 <<
"Bad geometry configuration detected. ";
89 cout<<myname<<
"WARNING the LEM transmission map does not match the expected size."<<
endl;
94 int nlemeff = ps.
get<
int>(
"DumpLemEff", 0);
103 const string myname =
"util::CrpGainService::checkGeoConfig: ";
107 cout<<myname<<
"ERROR the number of LEMs per CRP is non-square\n";
116 cout<<myname<<
"ERROR wrong number of readout planes\n";
120 for(
unsigned p = 0;
p < tpcgeo.
Nplanes(); ++
p)
126 cout<<myname<<
"ERROR problem with number of channels per view\n";
140 const string myname =
"util::CrpGainService::viewCharge: ";
142 double q = psc->
Charge(itck);
143 if(q <= 1.0
E-3)
return 0;
166 unsigned widother = 0;
167 if(wid.
Plane == 0 ) widother = 1;
175 if( drift == 0 ) tcoord = 1;
176 else if( drift == 1 ) tcoord = 0;
185 cout<<myname<<
"chan "<<psc->
Channel()
186 <<
" plane "<<wid.
Plane 188 <<
" view "<<pthis.
View()
189 <<
" viewother "<<pother.
View()
190 <<
" tcoord "<<tcoord<<
endl;
193 if( tcoord < 0 || (tcoord == 2 && pother.
View() !=
geo::kZ) )
195 cout<<myname<<
"WARNING cannot figure out the coordinate system\n";
205 cout<<myname<<
"WARNING could not get IDEs for tick "<<itck<<
endl;
209 unsigned tpcid = wid.
TPC;
218 if( wother < 0 || wother >= (
int)pother.
Nwires() )
220 cout<<myname<<
"WARNING the wire number appeares to be incorrect "<<wother<<
"\n";
235 qsum += (0.5 *
G) * ide.numElectrons;
248 const string myname =
"util::CrpGainService::crpGain: ";
258 cout << myname <<
"WARNING cannot find the point in a TPC" <<
endl;
267 int ch[2] = {-1, -1};
274 if( ch[0] < 0 || ch[0] >= (
int)pfirst.
Nwires() )
276 cout<<myname<<
"WARNING the wire number appeares to be incorrect " <<
endl;
280 if( ch[1] < 0 || ch[1] >= (
int)plast.
Nwires() )
282 cout<<myname<<
"WARNING the wire number appeares to be incorrect " <<
endl;
291 if( ch[0] < 0 || ch[0] >= (
int)plast.
Nwires() )
293 cout<<myname<<
"WARNING the wire number appeares to be incorrect " <<
endl;
297 if( ch[1] < 0 || ch[1] >= (
int)pfirst.
Nwires() )
299 cout<<myname<<
"WARNING the wire number appeares to be incorrect " <<
endl;
305 cout<<myname<<
"WARNING cannot figure out the coordinate system\n";
318 const string myname =
"util::CrpGainService::getLemId: ";
325 cout<<myname<<
"WARNING LEM ID exceeds the number of declared LEMs: " 326 <<chx<<
" "<<chy<<
" "<<iX<<
" "<<iY<<
" "<<
id<<
endl;
332 id += (
int)crp * m_CrpNLem;
355 const string myname =
"util::CrpGainService::getLemTransparency: ";
361 if( chx < 0 || chy < 0 )
return 0;
368 cout<< myname <<
"WARNING the index of LEM transmission map is too large"<<
endl;
391 const string myname =
"util::CrpGainService::dumpLemEffMap: ";
392 cout<<myname<<
"Dump LEM efficiecy map for a block "<<nlems<<
" x "<<nlems<<
"\n";
396 TFile *
fout = TFile::Open(
"dumplemeffmap.root",
"RECREATE");
397 TH2F *
hist =
new TH2F(
"lemeffmap",
"lemeffmap",
399 nlems*m_LemViewChans, 0, nlems*m_LemViewChans );
401 for(
int iy = 0; iy<hist->GetNbinsY(); ++iy){
402 for(
int ix = 0; ix<hist->GetNbinsX(); ++ix){
geo::TPCID const & ID() const
Returns the identifier of this TPC.
double getCrpGain(unsigned crp, int chx, int chy) const
CrpGainService(fhicl::ParameterSet const &ps, art::ActivityRegistry &areg)
Namespace for general, non-LArSoft-specific utilities.
Energy deposited on a readout channel by simulated tracks.
unsigned int Nplanes() const
Number of planes in this tpc.
Planes which measure X direction.
Geometry information for a single TPC.
geo::PlaneGeo const & FirstPlane() const
Returns the first wire plane (the closest to TPC center).
geo::TPCGeo const * PositionToTPCptr(geo::Point_t const &point) const
Returns the TPC at specified location.
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
Planes which measure Z direction.
unsigned int m_CrpNLemPerSide
WireID_t Wire
Index of the wire within its plane.
double crpGain(geo::Point_t const &pos) const
bool checkGeoConfig() const
IteratorBox< TPC_id_iterator,&GeometryCore::begin_TPC_id,&GeometryCore::end_TPC_id > IterateTPCIDs() const
Enables ranged-for loops on all TPC IDs of the detector.
Planes which measure Y direction.
unsigned int m_LemTotChans
View_t View() const
Which coordinate does this plane measure.
double crpDefaultGain() const
double Charge(TDC_t tdc) const
Returns the total number of ionization electrons on this channel in the specified TDC...
T get(std::string const &key) const
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
void dumpLemEffMap(int nlems) const
static constexpr double ps
The data type to uniquely identify a TPC.
PlaneID_t Plane
Index of the plane within its TPC.
unsigned int m_LemViewChans
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
double viewCharge(const sim::SimChannel *psc, unsigned itck) const
raw::ChannelID_t Channel() const
Returns the readout channel this object describes.
#define DEFINE_ART_SERVICE(svc)
const geo::Geometry * m_geo
short int DetectDriftDirection() const
Returns the expected drift direction based on geometry.
std::vector< sim::IDE > TrackIDsAndEnergies(TDC_t startTDC, TDC_t endTDC) const
Return all the recorded energy deposition within a time interval.
geo::PlaneGeo const & LastPlane() const
Returns the last wire plane (the farther from TPC center).
double getLemGain(int lemid) const
unsigned int Nwires() const
Number of wires in this plane.
double getLemTransparency(int chx, int chy) const
int getLemId(unsigned crp, int chx, int chy) const
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.
double WireCoordinate(Point const &point) const
Returns the coordinate of the point on the plane, in wire units.
TPCID_t TPC
Index of the TPC within its cryostat.
std::vector< float > m_lemgainmap
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)