Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 31 additions & 8 deletions src/MModuleDepthCalibration.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -440,23 +440,45 @@ bool MModuleDepthCalibration::LoadDetectorDimensions(MDGeometryQuest* Geometry)
// ie DetID=0 should be the 0th detector in m_Detectors, DetID=1 should the 1st, etc.
vector<MDDetector*> DetList = Geometry->GetDetectorList();

// Look through the Geometry and get the names and thicknesses of all the detectors.
// Look through the Geometry and get the names and thicknesses of all Strip3D detectors.
vector<string> DetectorNames;
unsigned int DetID = 0;

for (unsigned int i = 0; i < DetList.size(); ++i) {
// For now, DetID is in order of detectors, which puts contraints on how the geometry file should be written.
// If using the card cage at UCSD, default to DetID=11.
unsigned int DetID = i;
if (m_UCSDOverride == true) {
DetID = 11;
}

MDDetector* det = DetList[i];
vector<string> DetectorNames;
if (det->GetTypeName() == "Strip3D") {
if (det->GetNSensitiveVolumes() == 1) {
MDVolume* vol = det->GetSensitiveVolume(0);
string det_name = vol->GetName().GetString();
if (find(DetectorNames.begin(), DetectorNames.end(), det_name) == DetectorNames.end()) {
DetectorNames.push_back(det_name);
MString DetectorName = det->GetName();
string DetName = DetectorName.GetString();

// Check that the DetID agrees with the naming scheme GeD_X
if (DetectorName.BeginsWith("GeD_") == true) {
DetectorName.RemoveAllInPlace("GeD_"); // The number after GeD is the COSI detector ID
if (DetID != DetectorName.ToUnsignedInt()) {
if (g_Verbosity >= c_Error) {
cout << "ERROR in MModuleDepthCalibration::Initialize: Non-matching DetID="<<DetID<<" for detector "<<DetName<<endl;
}
// Return false if this is running with the COSI SMEX payload mass model
if (Geometry->GetName() == "COSI-SMEX-Payload"){
return false;
}
}
} else if (Geometry->GetName() == "COSI-SMEX-Payload") {
if (g_Verbosity >= c_Error) {
cout << "ERROR in MModuleDepthCalibration::Initialize: COSI-SMEX-Payload expects all Strip3D detectors to follow the name scheme GeD_X"<<endl;
}
return false;
}

if (find(DetectorNames.begin(), DetectorNames.end(), DetName) == DetectorNames.end()) {
DetectorNames.push_back(DetName);
m_Thicknesses[DetID] = 2 * (det->GetStructuralSize().GetZ());
MDStrip3D* strip = dynamic_cast<MDStrip3D*>(det);
m_XPitches[DetID] = strip->GetPitchX();
Expand All @@ -465,7 +487,7 @@ bool MModuleDepthCalibration::LoadDetectorDimensions(MDGeometryQuest* Geometry)
m_NYStrips[DetID] = strip->GetNStripsY();

if (g_Verbosity >= c_Info) {
cout << "Found detector " << det_name << " corresponding to DetID=" << DetID << "." << endl;
cout << "Found detector " << DetName << " corresponding to DetID=" << DetID << "." << endl;
cout << "Detector thickness: " << m_Thicknesses[DetID] << endl;
cout << "Number of X strips: " << m_NXStrips[DetID] << endl;
cout << "Number of Y strips: " << m_NYStrips[DetID] << endl;
Expand All @@ -474,9 +496,10 @@ bool MModuleDepthCalibration::LoadDetectorDimensions(MDGeometryQuest* Geometry)
}
m_DetectorIDs.push_back(DetID);
m_Detectors[DetID] = det;
DetID += 1;
} else {
if (g_Verbosity >= c_Error) {
cout<<"ERROR in MModuleDepthCalibration::Initialize: Found a duplicate detector: "<<det_name<<endl;
cout<<"ERROR in MModuleDepthCalibration::Initialize: Found a duplicate detector: "<<DetName<<endl;
}
}
} else {
Expand Down
41 changes: 31 additions & 10 deletions src/MSubModuleChargeTransport.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,39 @@ bool MSubModuleChargeTransport::Initialize()
// ie DetID=0 should be the 0th detector in m_Detectors, DetID=1 should the 1st, etc.
vector<MDDetector*> DetList = m_Geometry->GetDetectorList();

// Look through the Geometry and get the names and thicknesses of all the detectors.
// Look through the Geometry and get the names and thicknesses of all Strip3D detectors.
vector<string> DetectorNames;
unsigned int DetID = 0;

for(unsigned int i = 0; i < DetList.size(); ++i){

unsigned int DetID = i;

MDDetector* det = DetList[i];
vector<string> DetectorNames;
if (det->GetTypeName() == "Strip3D") {
if (det->GetNSensitiveVolumes() == 1) {
MDVolume* vol = det->GetSensitiveVolume(0);
string det_name = vol->GetName().GetString();
if (find(DetectorNames.begin(), DetectorNames.end(), det_name) == DetectorNames.end()) {
DetectorNames.push_back(det_name);
MString DetectorName = det->GetName();
string DetName = DetectorName.GetString();

// Check that the DetID agrees with the naming scheme GeD_X
if (DetectorName.BeginsWith("GeD_") == true) {
DetectorName.RemoveAllInPlace("GeD_"); // The number after GeD is the COSI detector ID
if (DetID != DetectorName.ToUnsignedInt()) {
if (g_Verbosity >= c_Error) {
cout << "ERROR in MModuleDepthCalibration::Initialize: Non-matching DetID="<<DetID<<" for detector "<<DetName<<endl;
}
// Return false if this is running with the COSI SMEX payload mass model
if (m_Geometry->GetName() == "COSI-SMEX-Payload"){
return false;
}
}
} else if (m_Geometry->GetName() == "COSI-SMEX-Payload") {
if (g_Verbosity >= c_Error) {
cout << "ERROR in MModuleDepthCalibration::Initialize: COSI-SMEX-Payload expects all Strip3D detectors to follow the name scheme GeD_X"<<endl;
}
return false;
}

if (find(DetectorNames.begin(), DetectorNames.end(), DetName) == DetectorNames.end()) {
DetectorNames.push_back(DetName);
m_Thicknesses[DetID] = 2*(det->GetStructuralSize().GetZ());
MDStrip3D* strip = dynamic_cast<MDStrip3D*>(det);
m_XPitches[DetID] = strip->GetPitchX();
Expand All @@ -113,7 +133,7 @@ bool MSubModuleChargeTransport::Initialize()
}

if (g_Verbosity >= c_Info) {
cout << "Found detector " << det_name << " corresponding to DetID=" << DetID << "." << endl;
cout << "Found detector " << DetName << " corresponding to DetID=" << DetID << "." << endl;
cout << "Detector width (X): " << m_XWidths[DetID] << endl;
cout << "Detector width (Y): " << m_YWidths[DetID] << endl;
cout << "Detector radius (R): " << m_Radii[DetID] << endl;
Expand All @@ -125,8 +145,9 @@ bool MSubModuleChargeTransport::Initialize()
}
m_DetectorIDs.push_back(DetID);
m_Detectors[DetID] = det;
DetID += 1;
} else {
cout << "ERROR in MSubModuleChargeTransport::Initialize: Found a duplicate detector: " << det_name << endl;
cout << "ERROR in MSubModuleChargeTransport::Initialize: Found a duplicate detector: " << DetName << endl;
}
} else {
cout << "ERROR in MSubModuleChargeTransport::Initialize: Found a Strip3D detector with " << det->GetNSensitiveVolumes() << " Sensitive Volumes." << endl;
Expand Down
Loading