13#include "TGeoManager.h"
14#include "TGeoMatrix.h"
15#include "TGeoVolume.h"
20using std::stringstream;
28 fXmin(0.), fXmax(0.), fYmin(0.), fYmax(0.), fSensorD(0.), fSensorRot(0.),
42 TGeoPhysicalNode* node) :
45 fXmin(0.), fXmax(0.), fYmin(0.), fYmax(0.), fSensorD(0.), fSensorRot(0.),
71 fLadders.push_back(ladder);
78void BmnSsdStation::CheckSensorProperties() {
81 Double_t zMin = 999999.;
82 Double_t zMax = -999999.;
85 for (UInt_t iLad = 0; iLad < fLadders.size(); iLad++) {
102 if ( ! nSensors ) fFirstSensor = sensor;
105 TGeoPhysicalNode* sensorNode = sensor->
GetPnode();
107 Double_t local[3] = {0., 0., 0.};
109 sensorNode->GetMatrix()->LocalToMaster(local, global);
115 zMin = TMath::Min(zMin, global[2]);
116 zMax = TMath::Max(zMax, global[2]);
120 TGeoBBox* sBox =
dynamic_cast<TGeoBBox*
>(sensorNode->GetShape());
122 LOG(fatal) << GetName() <<
": sensor shape is not a box!";
123 Double_t sD = 2. * sBox->GetDZ();
124 if ( ! nSensors ) fSensorD = sD;
126 if ( TMath::Abs(sD - fSensorD) > 0.0001 )
127 fDiffSensorD = kTRUE;
136 fZ = 0.5 * (zMin + zMax);
137 fNofSensors = nSensors;
146 assert( side == 0 || side == 1);
148 if ( ! fFirstSensor ) {
149 LOG(WARNING) << GetName() <<
": No sensors connected to station!";
155 Double_t pitch = -1.;
156 if ( sensor ) pitch = sensor->
GetPitch(side);
158 LOG(WARNING) << GetName() <<
": Cannot get pitch for non-Dssd sensor.";
170 assert ( side == 0 || side == 1);
172 if ( ! fFirstSensor ) {
173 LOG(WARNING) << GetName() <<
": No sensors connected to station!";
180 Double_t stereo = 0.;
183 LOG(WARNING) << GetName()
184 <<
": Cannot get stereo angle for non-DssdStereo sensor.";
201 TGeoBBox* box =
dynamic_cast<TGeoBBox*
>(fNode->GetShape());
203 LOG(fatal) << GetName() <<
": shape is not box! ";
204 Double_t local[3] = { 0., 0., 0.};
206 fNode->GetMatrix()->LocalToMaster(local, global);
207 fXmin = global[0] - box->GetDX();
208 fXmax = global[0] + box->GetDX();
209 fYmin = global[1] - box->GetDY();
210 fYmax = global[1] + box->GetDY();
218 TGeoVolumeAssembly* statVol =
new TGeoVolumeAssembly(
"myStation");
219 for (UInt_t iLadder = 0; iLadder < fLadders.size(); iLadder++) {
220 TGeoVolume* ladVol = fLadders.at(iLadder)->GetPnode()->GetVolume();
221 TGeoHMatrix* ladMat = fLadders.at(iLadder)->GetPnode()->GetMatrix();
222 statVol->AddNode(ladVol, iLadder, ladMat);
224 statVol->GetShape()->ComputeBBox();
225 TGeoBBox* statShape =
dynamic_cast<TGeoBBox*
>(statVol->GetShape());
226 const Double_t* origin = statShape->GetOrigin();
227 fXmin = origin[0] - statShape->GetDX();
228 fXmax = origin[0] + statShape->GetDX();
229 fYmin = origin[1] - statShape->GetDY();
230 fYmax = origin[1] + statShape->GetDY();
236 CheckSensorProperties();
240 LOG(WARNING) << GetName() <<
": Different values for sensor thickness!";
243 assert(fFirstSensor);
244 TGeoPhysicalNode* sensorNode = fFirstSensor->
GetNode();
247 Double_t unitLocal[3] = {1., 0., 0.};
248 Double_t unitGlobal[3];
249 sensorNode->GetMatrix()->LocalToMaster(unitLocal, unitGlobal);
251 Double_t* translation = sensorNode->GetMatrix()->GetTranslation();
252 unitGlobal[0] -= translation[0];
253 unitGlobal[1] -= translation[1];
254 unitGlobal[2] -= translation[2];
256 fSensorRot =
atan2(unitGlobal[1], unitGlobal[0]);
267 ss << GetName() <<
": " << fNofSensors <<
" sensors, z = " << fZ
268 <<
" cm, x = " << fXmin <<
" to " << fXmax <<
" cm, y = " << fYmin
269 <<
" to " << fYmax <<
" cm " <<
"\n\t\t"
270 <<
" rotation " << fSensorRot * 180. / 3.1415927 <<
" degrees,"
271 <<
" sensor thickness " << fSensorD <<
" cm,"
friend F32vec4 atan2(const F32vec4 &y, const F32vec4 &x)
Class representing an element of the SSD setup.
Int_t GetNofDaughters() const
BmnSsdElement * GetDaughter(Int_t index) const
ESsdElementLevel GetLevel() const
TGeoPhysicalNode * GetPnode() const
Detector response for DSSD sensors with stereo angles and cross-connection by double metal layers.
Double_t GetStereoAngle(Int_t side) const
Stereo angle for front and back side.
Class describing double-sided silicon strip sensors.
virtual Double_t GetPitch(Int_t side) const =0
Strip pitch on front and back side.
Class representing an instance of a sensor in the BMN-SSD.
TGeoPhysicalNode * GetNode() const
Double_t GetSensorPitch(Int_t iSide) const
void Init()
Initialise the station parameters.
Double_t GetSensorStereoAngle(Int_t iSide) const
void AddLadder(BmnSsdElement *ladder)
virtual std::string ToString() const