1 #include "gearimpl/TPCParametersImpl.h"
3 #include "gearimpl/TPCModuleImpl.h"
15 _maxDriftLength(maxDriftLength),
16 _coordinateType(coordinateType),
20 if ( (maxDriftLength == -1.) || (coordinateType == -1) )
27 _coordinateType = PadRowLayout2D::POLAR;
30 _planeExtent.push_back(0.0);
31 _planeExtent.push_back(0.0);
32 _planeExtent.push_back(0.0);
33 _planeExtent.push_back(0.0);
46 std::vector<TPCModule *>::const_iterator itr;
48 for(itr = right._TPCModules.begin();itr!=right._TPCModules.end();itr++)
50 _TPCModules.push_back( dynamic_cast<TPCModule *>((*itr)->clone()) );
54 if ((*itr)->getZPosition() <= 0 )
56 _modulesNegativeHalfTPC.push_back( _TPCModules.back() );
60 _modulesPositiveHalfTPC.push_back( _TPCModules.back() );
66 _modulesPositiveHalfTPC.push_back( _TPCModules.back() );
67 _modulesNegativeHalfTPC.push_back( _TPCModules.back() );
72 _maxDriftLength = right._maxDriftLength;
73 _coordinateType = right._coordinateType;
75 _planeExtent = right._planeExtent;
81 GearParametersImpl::operator = (right);
101 std::vector<TPCModule *>::iterator itr;
103 for(itr = _TPCModules.begin();itr!=_TPCModules.end();itr++){
110 _modulesPositiveHalfTPC.clear();
111 _modulesNegativeHalfTPC.clear();
117 std::map<int,int>::const_iterator moduleIter =
_moduleIDMap.find(moduleID);
120 std::stringstream message;
121 message <<
"TPCParameters::getModule: No module with ID " << moduleID
122 <<
" defined in the gear file! "<< std::endl;
126 int temp = moduleIter->second;
134 return _TPCModules.size();
140 std::vector<TPCModule *>
const & modulesVector)
const
143 if(modulesVector.size()){
144 toReturn = modulesVector.at(0);
146 std::vector<TPCModule *>::const_iterator itr;
148 for(itr = modulesVector.begin();itr!=modulesVector.end();itr++){
149 tempDistance =(*itr)->getDistanceToModule(c0,c1);
150 if(tempDistance < distance){
151 distance = tempDistance;
156 throw gear::Exception(
"TPCParameters::GetNearsestModule: No Modules are defined, Cannot find Nearest");
180 return _maxDriftLength;
202 std::vector<TPCModule *>
const & modulesVector )
const{
203 bool toReturn =
false;
204 std::vector<TPCModule *>::const_iterator itr;
206 for(itr = modulesVector.begin();itr!=modulesVector.end();itr++){
207 toReturn = toReturn||(*itr)->isInsideModule(c0,c1);
222 return isInsidePad(c0, c1, _modulesNegativeHalfTPC);
225 return isInsidePad(c0, c1, _modulesPositiveHalfTPC);
230 std::vector<TPCModule *>
const & modulesVector )
const{
231 bool toReturn =
false;
232 std::vector<TPCModule *>::const_iterator itr;
234 for(itr = modulesVector.begin();itr!=modulesVector.end();itr++){
235 toReturn = toReturn||(*itr)->isInsidePad(c0,c1);
258 std::vector<TPCModule *>
const & modulesVector )
const{
261 if(!modulesVector.size()) {
262 throw gear::Exception(
"TPCParametersImpl::getNearestPad: No Modules are defined, Cannot find Nearest");
265 std::vector<TPCModule *>::const_iterator itr, best_itr;
266 itr = modulesVector.begin();
269 GlobalPadIndex closest_pad( (*itr)->getNearestPad(c0, c1), (*itr)->getModuleID() );
271 if( modulesVector.size() == 1 ) {
277 double shortest_distance = (*itr)->getDistanceToPad( c0, c1, closest_pad.getPadIndex() );
280 for( itr+1; itr!=modulesVector.end(); itr++) {
282 GlobalPadIndex temp_pad( (*itr)->getNearestPad( c0, c1 ), (*itr)->getModuleID() );
284 const double distance = (*itr)->getDistanceToPad( c0, c1, temp_pad.getPadIndex() );
286 if( distance < shortest_distance ) {
288 closest_pad = temp_pad;
289 shortest_distance = distance;
300 if(!_TPCModules.size()) {
301 throw gear::Exception(
"TPCParametersImpl::getPlaneExtent: No Modules are defined, Bad User");
310 return _coordinateType;
314 if(TPCModule==NULL) {
315 throw gear::Exception(
"TPCParametersImpl::addModule: This Module is not defined, Bad User");
321 throw gear::Exception(
"TPCParametersImpl::addModule: Module has wrong coordinate type, Bad User");
324 int currentVectorSize = _TPCModules.size();
327 throw gear::Exception(
"TPCParametersImpl::addModule: This Module Number has already been used.");
330 _TPCModules.push_back(TPCModule);
337 _modulesNegativeHalfTPC.push_back(TPCModule);
341 _modulesPositiveHalfTPC.push_back(TPCModule);
345 setCathodePosition();
351 _modulesPositiveHalfTPC.push_back(TPCModule);
352 _modulesNegativeHalfTPC.push_back(TPCModule);
357 if (_TPCModules.size() == 1 )
397 if (_TPCModules.size() > 1)
398 throw gear::Exception(
"You cannot use TPCParametersImpl::getPadLayout() with more than one module. Use getModule(moduleID) instead!");
399 if (_TPCModules.size() < 1)
400 throw gear::Exception(
"You cannot use TPCParametersImpl::getPadLayout() without a module. Set the module / pad layout first!");
409 if ( (_TPCModules[0]->getAngle() != 0) || ((_TPCModules[0]->getOffset())[0] != 0)
410 || ((_TPCModules[0]->getOffset())[1] != 0) )
411 throw gear::Exception(
"Module coordinate system is not identical to coordinate system in pad plane. Use getModule(moduleID) instead!");
413 return *(_TPCModules[0]);
440 if (_TPCModules.size() > 1)
441 throw gear::Exception(
"You cannot use TPCParametersImpl::getRadoutFreuqency() with more than one module. Use getModule(moduleID) instead!");
442 if (_TPCModules.size() < 1)
443 throw gear::Exception(
"You cannot use TPCParametersImpl::getRadoutFreuqency() without a module. Set the module / pad plane first!");
446 return _TPCModules[0]->getReadoutFrequency();
456 _maxDriftLength = maxDriftLength ;
459 setCathodePosition();
479 if (_TPCModules.size() > 1)
480 throw gear::Exception(
"You cannot use TPCParametersImpl:::setReadoutFrequency() with more than one module. Use getModule(moduleID) instead!");
481 if (_TPCModules.size() < 1)
482 throw gear::Exception(
"You cannot use TPCParametersImpl:::setReadoutFrequency() without a module. Set the module / pad plane first!");
495 if (_TPCModules.size() != 0)
496 throw gear::Exception(
"There is already one module in TPCParametersImpl. Will not replace it!");
500 throw gear::Exception(
"Wrong type: PadLayout is a module, cannot set this using setPadLayout. Use addModule()!");
505 void TPCParametersImpl::setCathodePosition()
511 if ( ! _modulesNegativeHalfTPC.empty() )
513 if ( ! _modulesPositiveHalfTPC.empty() )
519 + _modulesPositiveHalfTPC[0]->getZPosition() ) /2. ;
523 _cathodePosition = _modulesNegativeHalfTPC[0]->getZPosition() + _maxDriftLength;
526 else if ( ! _modulesPositiveHalfTPC.empty() )
529 _cathodePosition = _modulesPositiveHalfTPC[0]->getZPosition() - _maxDriftLength;
533 catch ( TPCModule::NoZPositionException & )
virtual ~TPCParametersImpl()
Copy constructor for base parameters.
double _driftVelocity
Drift velocity is deprecated, should come from conditions data.
virtual void setDriftVelocity(double driftVelocity)
virtual double getZPosition() const =0
Returns the z position of the module.
Abstract description of a planar subdetector with pads (cells) that are positioned in rows (circular ...
virtual double getReadoutFrequency() const
Kept for backward compatibility.
Base exception class for GEAR - all other exceptions extend this.
virtual bool isInsideModule(double c0, double c1) const
True if coordinate (c0,c1) is within any module.
virtual const PadRowLayout2D & getPadLayout() const
Kept for backward compatibility.
virtual void setPadLayout(PadRowLayout2D *padLayout)
Global pad index implimentation .
virtual const std::vector< double > & getPlaneExtent() const
Extent of the sensitive plane - [xmin,xmax,ymin,ymax] CARTESIAN or [rmin,rmax,phimin,phimax] POLAR.
virtual int getNModules() const
Returns the number of modules in the TPC (endplate)
virtual double getMaxDriftLength() const
The maximum drift length in the TPC in mm.
virtual int getCoordinateType() const
Returns coordinate type as an int (see PadRowLayout2D::CARTESIAN, PadRowLayout2D::POLAR) ...
virtual const TPCModule & getModule(int moduleID) const
Returns module with the given module ID.
virtual int getPadLayoutImplType() const =0
The type of the row layout implementation: PadRowLayout2D.RECTANGULARPADROWLAYOUT, PadRowLayout2D.FIXEDPADSIZEDISKLAYOUT, PadRowLayout2D.FIXEDPADANGLEDISKLAYOUT or PadRowLayout2D.TPCMODULE.
virtual void setMaxDriftLength(double maxDriftLength)
std::map< int, int > _moduleIDMap
A map with the moduleID as key and the index in the _TPCModules vector as value.
virtual int getModuleID() const =0
Returns module ID.
virtual void setReadoutFrequency(double readoutFrequency)
virtual const std::vector< TPCModule * > & getModules() const
Returns vector of all modules in this TPC (endplate).
A Container for TPCModules which describe the geometry properties of a given TPC. ...
void cleanup()
function to delete all the objects pointed to and owned by the GearMgr.
TPCParametersImpl(double maxDriftLength=-1., int coordinateType=-1)
virtual GlobalPadIndex getNearestPad(double c0, double c1) const
Returns globalPadindex Object for nearest pad to given coordinates (2D).
virtual double getDriftVelocity() const
The electron drift velocity in the TPC in mm/s.
virtual void addModule(TPCModule *TPCModule)
Adds a Module to the vector of modules, or throws an exception.
TPCParametersImpl & operator=(const TPCParametersImpl &)
Assignment operator.
virtual const TPCModule & getNearestModule(double c0, double c1) const
Returns nearest module to given coordinates (2D).
double _cathodePosition
The cathode position is needed internally to distinguish the half TPCs.
virtual int getTPCCoordinateType() const =0
Returns the TPCs coordinate type.
An exception that is special for the TPCModule.
virtual const std::vector< double > & getModuleExtent() const =0
Maximal extent of the sensitive plane, defined relative to global origin - [xmin,xmax,ymin,ymax] CARTESIAN or [rmin,rmax,phimin,phimax] POLAR, may contain dead space due to conversion from local to global coordinate system.
void copy_and_assign(const TPCParametersImpl &)
function to copy all internal variables, incl.
A wrapper Class for PadRowLayout2D which converts between the actual pad layouts local coodinate syst...
A wrapper Class for PadRowLayout2D, allowing which converts between local and global coordinate syste...
virtual double getDistanceToModule(double c0, double c1) const =0
Returns distastance from a global coodinate (c0,c1), to the module's nearest boundery; (c0...
virtual bool isInsidePad(double c0, double c1) const
True if coordinate (c0,c1) is within any pad, on any module.