diff --git a/Control/CalypsoExample/GeoModelTest/python/GeoModelTestConfig.py b/Control/CalypsoExample/GeoModelTest/python/GeoModelTestConfig.py index 15e048a52eb61c6c73982d72b595e41195166556..a4bd4c09aa91b622e20d77f92bdcf1bf0ea80147 100644 --- a/Control/CalypsoExample/GeoModelTest/python/GeoModelTestConfig.py +++ b/Control/CalypsoExample/GeoModelTest/python/GeoModelTestConfig.py @@ -32,6 +32,8 @@ if __name__ == "__main__": ConfigFlags.GeoModel.FaserVersion = "FASER-00" # Default FASER geometry ConfigFlags.GeoModel.GeoExportFile = "faserGeo.db" # Writes out a GeoModel file with the full geometry tree (optional, comment out to skip) ConfigFlags.Detector.SimulateVeto = True + ConfigFlags.Detector.SimulateTrigger = True + ConfigFlags.Detector.SimulatePreshower= True ConfigFlags.Detector.SimulateFaserSCT = True ConfigFlags.Detector.SimulateUpstreamDipole = True ConfigFlags.Detector.SimulateCentralDipole = True diff --git a/Control/CalypsoExample/GeoModelTest/src/GeoModelTestAlg.cxx b/Control/CalypsoExample/GeoModelTest/src/GeoModelTestAlg.cxx index 908a297185a7e81f586037592e0e68a00d35eb63..548d67c124e1046fb603e9590e336b0c17e2c52b 100644 --- a/Control/CalypsoExample/GeoModelTest/src/GeoModelTestAlg.cxx +++ b/Control/CalypsoExample/GeoModelTest/src/GeoModelTestAlg.cxx @@ -4,12 +4,16 @@ #include "GeoModelUtilities/GeoModelExperiment.h" #include "ScintReadoutGeometry/VetoDetectorManager.h" +#include "ScintReadoutGeometry/TriggerDetectorManager.h" +#include "ScintReadoutGeometry/PreshowerDetectorManager.h" #include "TrackerReadoutGeometry/SCT_DetectorManager.h" #include "ScintReadoutGeometry/ScintDetectorElement.h" #include "TrackerReadoutGeometry/SiDetectorElement.h" #include "ScintIdentifier/VetoID.h" +#include "ScintIdentifier/TriggerID.h" +#include "ScintIdentifier/PreshowerID.h" #include "TrackerIdentifier/FaserSCT_ID.h" #include "GaudiKernel/PhysicalConstants.h" @@ -59,6 +63,10 @@ StatusCode GeoModelTestAlg::execute() ATH_CHECK(testVeto()); + ATH_CHECK(testTrigger()); + + ATH_CHECK(testPreshower()); + ATH_CHECK(testSCT()); ATH_CHECK(testField()); @@ -583,6 +591,313 @@ StatusCode GeoModelTestAlg::testVeto() return StatusCode::SUCCESS; } +StatusCode GeoModelTestAlg::testTrigger() +{ + // Test retrieval of helper object directly from store + const TriggerID* helper = nullptr; + ATH_CHECK(detStore()->retrieve(helper, "TriggerID")); + if (helper != nullptr) + { + // Test neighbors with helper function + const IdContext& context = helper->plate_context(); + ATH_MSG_ALWAYS("Retrieved TriggerID helper from DetStore."); + for (int iStation = 0; iStation < m_numTriggerStations; iStation++) + { + for (int iPlate = 0; iPlate < m_numTriggerPlatesPerStation; iPlate++) + { + Identifier thisId = helper->plate_id(iStation, iPlate, true); + IdentifierHash thisHash = helper->plate_hash(thisId); + IdentifierHash prevHash; + IdentifierHash nextHash; + Identifier prevId; + Identifier nextId; + int prevStation {-1}; + int prevPlate {-1}; + int nextStation {-1}; + int nextPlate {-1}; + int prevStat = helper->get_prev_in_z(thisHash, prevHash); + if (prevStat == 0) + { + IdentifierHash testHash; + int nextStat = helper->get_next_in_z(prevHash, testHash); + if (nextStat != 0 || testHash != thisHash) + { + ATH_MSG_FATAL("Next Trigger plate (" << testHash << ") of previous (" << prevHash << ") is not the original (" << thisHash <<")" ); + return StatusCode::FAILURE; + } + prevStat = helper->get_id(prevHash, prevId, &context); + if (prevStat == 0) + { + prevStation = helper->station(prevId); + prevPlate = helper->plate(prevId); + } + } + int nextStat = helper->get_next_in_z(thisHash, nextHash); + if (nextStat == 0) + { + IdentifierHash testHash; + prevStat = helper->get_prev_in_z(nextHash, testHash); + if (prevStat != 0 || testHash != thisHash) + { + ATH_MSG_FATAL("Previous Trigger plate (" << testHash << ") of next (" << nextHash << ") is not the original (" << thisHash <<")" ); + return StatusCode::FAILURE; + } + nextStat = helper->get_id(nextHash, nextId, &context); + if (nextStat == 0) + { + nextStation = helper->station(nextId); + nextPlate = helper->plate(nextId); + } + } + ATH_MSG_ALWAYS("Station/Plate " << iStation << "/" << iPlate << + " (" << thisHash << ") " << + " : prev = " << prevStation << "/" << prevPlate << + " , next = " << nextStation << "/" << nextPlate ); + } + } + } + else + { + ATH_MSG_FATAL("Failed to retrieve TriggerID helper from DetStore."); + return StatusCode::FAILURE; + } + + // Test direct retrieval of typed managers from DetStore + const ScintDD::TriggerDetectorManager* triggerMgr = nullptr; + ATH_CHECK(detStore()->retrieve(triggerMgr, "Trigger")); + if (triggerMgr != nullptr) + { + ATH_MSG_ALWAYS("Retrieved (typed) Trigger detector manager with " << triggerMgr->getNumTreeTops() << " treetops directly from DetStore."); + // Compare numerology with the "right" answers from our properties + if (triggerMgr->numerology().numStations() != m_numTriggerStations || triggerMgr->getNumTreeTops() != m_numTriggerStations) + { + ATH_MSG_FATAL("Disagreement in number of Trigger stations."); + return StatusCode::FAILURE; + } + if (triggerMgr->numerology().numPlatesPerStation() != m_numTriggerPlatesPerStation) + { + ATH_MSG_FATAL("Disagreement in number of plates per Trigger station."); + return StatusCode::FAILURE; + } + if (triggerMgr->numerology().numPmtsPerPlate() != m_numTriggerPmtsPerPlate) + { + ATH_MSG_FATAL("Disagreement in number of pmts per Trigger plate."); + return StatusCode::FAILURE; + } + // Test detector elements + const ScintDD::ScintDetectorElementCollection* elements = triggerMgr->getDetectorElementCollection(); + for (int station = 0; station < m_numTriggerStations; station++) + { + for (int plate = 0; plate < m_numTriggerPlatesPerStation; plate++) + { + Identifier id = helper->plate_id(station, plate, true); + if (!triggerMgr->identifierBelongs(id)) + { + ATH_MSG_FATAL("Valid Trigger identifier does not pass identifierBelongs."); + return StatusCode::FAILURE; + } + IdentifierHash hash = helper->plate_hash(id); + ScintDD::ScintDetectorElement* elementByLevels = triggerMgr->getDetectorElement(station, plate); + ScintDD::ScintDetectorElement* elementById = triggerMgr->getDetectorElement(id); + ScintDD::ScintDetectorElement* elementByHash = triggerMgr->getDetectorElement(hash); + ScintDD::ScintDetectorElement* element = (*elements)[hash]; + if (elementByLevels != element || elementById != element || elementByHash != element) + { + ATH_MSG_FATAL("Inconsistent retrieval of Trigger detector elements"); + return StatusCode::FAILURE; + } + ATH_MSG_ALWAYS("Found Trigger plate (" << station << ", " << plate << ") with global center at (" << + element->center().x() << ", " << + element->center().y() << ", " << + element->center().z() << ")." + ); + const ScintDD::ScintDetectorElement* next = element->nextInZ(); + if (next != nullptr) + { + if (next->prevInZ() != element) + { + ATH_MSG_FATAL("Previous neighbor of next Trigger element is not this element."); + return StatusCode::FAILURE; + } + } + const ScintDD::ScintDetectorElement* prev = element->prevInZ(); + if (prev != nullptr) + { + if (prev->nextInZ() != element) + { + ATH_MSG_FATAL("Next neighbor of previous Trigger element is not this element."); + return StatusCode::FAILURE; + } + } + if (next == nullptr && prev == nullptr) + { + ATH_MSG_FATAL("Trigger element " << hash << " has no previous OR next neighbor."); + return StatusCode::FAILURE; + } + } + } + } + else + { + ATH_MSG_FATAL("Failed to retrieve (typed) Trigger detector manager directly from DetStore."); + return StatusCode::FAILURE; + } + return StatusCode::SUCCESS; +} + +StatusCode GeoModelTestAlg::testPreshower() +{ + // Test retrieval of helper object directly from store + const PreshowerID* helper = nullptr; + ATH_CHECK(detStore()->retrieve(helper, "PreshowerID")); + if (helper != nullptr) + { + // Test neighbors with helper function + const IdContext& context = helper->plate_context(); + ATH_MSG_ALWAYS("Retrieved PreshowerID helper from DetStore."); + for (int iStation = 0; iStation < m_numPreshowerStations; iStation++) + { + for (int iPlate = 0; iPlate < m_numPreshowerPlatesPerStation; iPlate++) + { + Identifier thisId = helper->plate_id(iStation, iPlate, true); + IdentifierHash thisHash = helper->plate_hash(thisId); + IdentifierHash prevHash; + IdentifierHash nextHash; + Identifier prevId; + Identifier nextId; + int prevStation {-1}; + int prevPlate {-1}; + int nextStation {-1}; + int nextPlate {-1}; + int prevStat = helper->get_prev_in_z(thisHash, prevHash); + if (prevStat == 0) + { + IdentifierHash testHash; + int nextStat = helper->get_next_in_z(prevHash, testHash); + if (nextStat != 0 || testHash != thisHash) + { + ATH_MSG_FATAL("Next Preshower plate (" << testHash << ") of previous (" << prevHash << ") is not the original (" << thisHash <<")" ); + return StatusCode::FAILURE; + } + prevStat = helper->get_id(prevHash, prevId, &context); + if (prevStat == 0) + { + prevStation = helper->station(prevId); + prevPlate = helper->plate(prevId); + } + } + int nextStat = helper->get_next_in_z(thisHash, nextHash); + if (nextStat == 0) + { + IdentifierHash testHash; + prevStat = helper->get_prev_in_z(nextHash, testHash); + if (prevStat != 0 || testHash != thisHash) + { + ATH_MSG_FATAL("Previous veto plate (" << testHash << ") of next (" << nextHash << ") is not the original (" << thisHash <<")" ); + return StatusCode::FAILURE; + } + nextStat = helper->get_id(nextHash, nextId, &context); + if (nextStat == 0) + { + nextStation = helper->station(nextId); + nextPlate = helper->plate(nextId); + } + } + ATH_MSG_ALWAYS("Station/Plate " << iStation << "/" << iPlate << + " (" << thisHash << ") " << + " : prev = " << prevStation << "/" << prevPlate << + " , next = " << nextStation << "/" << nextPlate ); + } + } + } + else + { + ATH_MSG_FATAL("Failed to retrieve PreshowerID helper from DetStore."); + return StatusCode::FAILURE; + } + + // Test direct retrieval of typed managers from DetStore + const ScintDD::PreshowerDetectorManager* preshowerMgr = nullptr; + ATH_CHECK(detStore()->retrieve(preshowerMgr, "Preshower")); + if (preshowerMgr != nullptr) + { + ATH_MSG_ALWAYS("Retrieved (typed) Preshower detector manager with " << preshowerMgr->getNumTreeTops() << " treetops directly from DetStore."); + // Compare numerology with the "right" answers from our properties + if (preshowerMgr->numerology().numStations() != m_numPreshowerStations || preshowerMgr->getNumTreeTops() != m_numPreshowerStations) + { + ATH_MSG_FATAL("Disagreement in number of preshower stations."); + return StatusCode::FAILURE; + } + if (preshowerMgr->numerology().numPlatesPerStation() != m_numPreshowerPlatesPerStation) + { + ATH_MSG_FATAL("Disagreement in number of plates per preshower station."); + return StatusCode::FAILURE; + } + if (preshowerMgr->numerology().numPmtsPerPlate() != m_numPreshowerPmtsPerPlate) + { + ATH_MSG_FATAL("Disagreement in number of pmts per preshower plate."); + return StatusCode::FAILURE; + } + // Test detector elements + const ScintDD::ScintDetectorElementCollection* elements = preshowerMgr->getDetectorElementCollection(); + for (int station = 0; station < m_numPreshowerStations; station++) + { + for (int plate = 0; plate < m_numPreshowerPlatesPerStation; plate++) + { + Identifier id = helper->plate_id(station, plate, true); + if (!preshowerMgr->identifierBelongs(id)) + { + ATH_MSG_FATAL("Valid Preshower identifier does not pass identifierBelongs."); + return StatusCode::FAILURE; + } + IdentifierHash hash = helper->plate_hash(id); + ScintDD::ScintDetectorElement* elementByLevels = preshowerMgr->getDetectorElement(station, plate); + ScintDD::ScintDetectorElement* elementById = preshowerMgr->getDetectorElement(id); + ScintDD::ScintDetectorElement* elementByHash = preshowerMgr->getDetectorElement(hash); + ScintDD::ScintDetectorElement* element = (*elements)[hash]; + if (elementByLevels != element || elementById != element || elementByHash != element) + { + ATH_MSG_FATAL("Inconsistent retrieval of Preshower detector elements"); + return StatusCode::FAILURE; + } + ATH_MSG_ALWAYS("Found Preshower plate (" << station << ", " << plate << ") with global center at (" << + element->center().x() << ", " << + element->center().y() << ", " << + element->center().z() << ")." + ); + const ScintDD::ScintDetectorElement* next = element->nextInZ(); + if (next != nullptr) + { + if (next->prevInZ() != element) + { + ATH_MSG_FATAL("Previous neighbor of next Preshower element is not this element."); + return StatusCode::FAILURE; + } + } + const ScintDD::ScintDetectorElement* prev = element->prevInZ(); + if (prev != nullptr) + { + if (prev->nextInZ() != element) + { + ATH_MSG_FATAL("Next neighbor of previous Preshower element is not this element."); + return StatusCode::FAILURE; + } + } + if (next == nullptr && prev == nullptr) + { + ATH_MSG_FATAL("Preshower element " << hash << " has no previous OR next neighbor."); + return StatusCode::FAILURE; + } + } + } + } + else + { + ATH_MSG_FATAL("Failed to retrieve (typed) Preshower detector manager directly from DetStore."); + return StatusCode::FAILURE; + } + return StatusCode::SUCCESS; +} StatusCode GeoModelTestAlg::finalize() { diff --git a/Control/CalypsoExample/GeoModelTest/src/GeoModelTestAlg.h b/Control/CalypsoExample/GeoModelTest/src/GeoModelTestAlg.h index a7ad58486c8e2e2e17ef2dc0018026cda2bcfc08..47aba8df6c48d519a42d596fdb711cddb0f2994c 100644 --- a/Control/CalypsoExample/GeoModelTest/src/GeoModelTestAlg.h +++ b/Control/CalypsoExample/GeoModelTest/src/GeoModelTestAlg.h @@ -18,6 +18,8 @@ class GeoModelTestAlg : public AthAlgorithm private: StatusCode testVeto(); + StatusCode testTrigger(); + StatusCode testPreshower(); StatusCode testSCT(); StatusCode testField(); @@ -26,6 +28,14 @@ class GeoModelTestAlg : public AthAlgorithm Gaudi::Property<int> m_numVetoPlatesPerStation {this, "NumVetoPlatesPerStation", 2, "Number of plates per station in the Veto detector"}; Gaudi::Property<int> m_numVetoPmtsPerPlate {this, "NumVetoPmtsPerPlate", 1, "Number of pmts per plate in the Veto detector"}; + Gaudi::Property<int> m_numTriggerStations {this, "NumTriggerStations", 1, "Number of stations in the Trigger detector"}; + Gaudi::Property<int> m_numTriggerPlatesPerStation {this, "NumTriggerPlatesPerStation", 2, "Number of plates per station in the Trigger detector"}; + Gaudi::Property<int> m_numTriggerPmtsPerPlate {this, "NumTriggerPmtsPerPlate", 2, "Number of pmts per plate in the Trigger detector"}; + + Gaudi::Property<int> m_numPreshowerStations {this, "NumPreshowerStations", 1, "Number of stations in the Preshower detector"}; + Gaudi::Property<int> m_numPreshowerPlatesPerStation {this, "NumPreshowerPlatesPerStation", 2, "Number of plates per station in the Preshower detector"}; + Gaudi::Property<int> m_numPreshowerPmtsPerPlate {this, "NumPreshowerPmtsPerPlate", 1, "Number of pmts per plate in the Preshower detector"}; + Gaudi::Property<int> m_numSctStations {this, "NumSCTStations", 3, "Number of stations in the SCT detector"}; Gaudi::Property<int> m_numSctPlanesPerStation {this, "NumSCTPlanesPerStation", 3, "Number of planes per station in the SCT detector"}; Gaudi::Property<int> m_numSctRowsPerPlane {this, "NumSCTRowsPerPlane", 4, "Number of rows of modules per plane in the SCT detector"}; diff --git a/DetectorDescription/DetDescrCnvSvc/src/DetDescrCnvSvc.cxx b/DetectorDescription/DetDescrCnvSvc/src/DetDescrCnvSvc.cxx index ad1870e3b08ad7f6a7856e6fc9201f24b9075eeb..8c71b542ee72320a5f6204291fb4ecf96b0ab2cc 100644 --- a/DetectorDescription/DetDescrCnvSvc/src/DetDescrCnvSvc.cxx +++ b/DetectorDescription/DetDescrCnvSvc/src/DetDescrCnvSvc.cxx @@ -118,6 +118,10 @@ DetDescrCnvSvc::initialize() { if (status != StatusCode::SUCCESS) return status; status = addToDetStore(131395045, "VetoID"); if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(58382802, "TriggerID"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(55179317, "PreshowerID"); + if (status != StatusCode::SUCCESS) return status; status = addToDetStore(205618430, "FaserSCT_ID"); if (status != StatusCode::SUCCESS) return status; diff --git a/DetectorDescription/GeoModel/FaserGeoModel/data/geomDB.sql b/DetectorDescription/GeoModel/FaserGeoModel/data/geomDB.sql index d90ea5f44671336f787dba7a577bf44200c4191f..148a323a632f86a380623ed3b249bc0f7ffa4440 100644 --- a/DetectorDescription/GeoModel/FaserGeoModel/data/geomDB.sql +++ b/DetectorDescription/GeoModel/FaserGeoModel/data/geomDB.sql @@ -104,7 +104,7 @@ CREATE TABLE IF NOT EXISTS "ELEMENTS_DATA2TAG" ( "ELEMENTS_DATA_ID" SLONGLONG ); -- --- Tables for describing scintillator plates (and passive radiators) +-- Tables for describing Veto scintillator plates (and passive radiators) -- DROP TABLE IF EXISTS "VETOTOPLEVEL_DATA"; CREATE TABLE IF NOT EXISTS "VETOTOPLEVEL_DATA" ( @@ -156,6 +156,113 @@ CREATE TABLE IF NOT EXISTS "VETOPLATEGENERAL_DATA2TAG" ( "VETOPLATEGENERAL_TAG_ID" SLONGLONG, "VETOPLATEGENERAL_DATA_ID" SLONGLONG ); +-- +-- Tables for describing Trigger scintillator plates (and passive radiators) +-- +DROP TABLE IF EXISTS "TRIGGERTOPLEVEL_DATA"; +CREATE TABLE IF NOT EXISTS "TRIGGERTOPLEVEL_DATA" ( + "TRIGGERTOPLEVEL_DATA_ID" SLONGLONG UNIQUE, + "POSX" DOUBLE, + "POSY" DOUBLE, + "POSZ" DOUBLE, + "ROTX" DOUBLE, + "ROTY" DOUBLE, + "ROTZ" DOUBLE, + "ROTORDER" INT, + "LABEL" TEXT +); +-- +-- The DATA2TAG tables associate specific rows of the corresponding +-- _DATA table with the referenced tag (from the HVS_TAG2NODE table). +-- This is a many-to-many relationship: each row may belong to +-- several tags, and each tag may apply to several rows. +DROP TABLE IF EXISTS "TRIGGERTOPLEVEL_DATA2TAG"; +CREATE TABLE IF NOT EXISTS "TRIGGERTOPLEVEL_DATA2TAG" ( + "TRIGGERTOPLEVEL_TAG_ID" SLONGLONG, + "TRIGGERTOPLEVEL_DATA_ID" SLONGLONG +); +-- +DROP TABLE IF EXISTS "TRIGGERSTATIONGENERAL_DATA"; +CREATE TABLE IF NOT EXISTS "TRIGGERSTATIONGENERAL_DATA" ( + "TRIGGERSTATIONGENERAL_DATA_ID" SLONGLONG UNIQUE, + "NUMPLATES" INT, + "PLATEPITCHY" DOUBLE, + "PLATEPITCHZ" DOUBLE +); +-- +DROP TABLE IF EXISTS "TRIGGERSTATIONGENERAL_DATA2TAG"; +CREATE TABLE IF NOT EXISTS "TRIGGERSTATIONGENERAL_DATA2TAG" ( + "TRIGGERSTATIONGENERAL_TAG_ID" SLONGLONG, + "TRIGGERSTATIONGENERAL_DATA_ID" SLONGLONG +); +DROP TABLE IF EXISTS "TRIGGERPLATEGENERAL_DATA"; +CREATE TABLE IF NOT EXISTS "TRIGGERPLATEGENERAL_DATA" ( + "TRIGGERPLATEGENERAL_DATA_ID" SLONGLONG UNIQUE, + "NUMPMTS" INT, + "WIDTH" DOUBLE, + "LENGTH" DOUBLE, + "THICKNESS" DOUBLE, + "MATERIAL" TEXT +); +-- +DROP TABLE IF EXISTS "TRIGGERPLATEGENERAL_DATA2TAG"; +CREATE TABLE IF NOT EXISTS "TRIGGERPLATEGENERAL_DATA2TAG" ( + "TRIGGERPLATEGENERAL_TAG_ID" SLONGLONG, + "TRIGGERPLATEGENERAL_DATA_ID" SLONGLONG +); +-- +-- Tables for describing Veto scintillator plates (and passive radiators) +-- +DROP TABLE IF EXISTS "PRESHOWERTOPLEVEL_DATA"; +CREATE TABLE IF NOT EXISTS "PRESHOWERTOPLEVEL_DATA" ( + "PRESHOWERTOPLEVEL_DATA_ID" SLONGLONG UNIQUE, + "POSX" DOUBLE, + "POSY" DOUBLE, + "POSZ" DOUBLE, + "ROTX" DOUBLE, + "ROTY" DOUBLE, + "ROTZ" DOUBLE, + "ROTORDER" INT, + "LABEL" TEXT +); +-- +-- The DATA2TAG tables associate specific rows of the corresponding +-- _DATA table with the referenced tag (from the HVS_TAG2NODE table). +-- This is a many-to-many relationship: each row may belong to +-- several tags, and each tag may apply to several rows. +DROP TABLE IF EXISTS "PRESHOWERTOPLEVEL_DATA2TAG"; +CREATE TABLE IF NOT EXISTS "PRESHOWERTOPLEVEL_DATA2TAG" ( + "PRESHOWERTOPLEVEL_TAG_ID" SLONGLONG, + "PRESHOWERTOPLEVEL_DATA_ID" SLONGLONG +); +-- +DROP TABLE IF EXISTS "PRESHOWERSTATIONGENERAL_DATA"; +CREATE TABLE IF NOT EXISTS "PRESHOWERSTATIONGENERAL_DATA" ( + "PRESHOWERSTATIONGENERAL_DATA_ID" SLONGLONG UNIQUE, + "NUMPLATES" INT, + "PLATEPITCH" DOUBLE +); +-- +DROP TABLE IF EXISTS "PRESHOWERSTATIONGENERAL_DATA2TAG"; +CREATE TABLE IF NOT EXISTS "PRESHOWERSTATIONGENERAL_DATA2TAG" ( + "PRESHOWERSTATIONGENERAL_TAG_ID" SLONGLONG, + "PRESHOWERSTATIONGENERAL_DATA_ID" SLONGLONG +); +DROP TABLE IF EXISTS "PRESHOWERPLATEGENERAL_DATA"; +CREATE TABLE IF NOT EXISTS "PRESHOWERPLATEGENERAL_DATA" ( + "PRESHOWERPLATEGENERAL_DATA_ID" SLONGLONG UNIQUE, + "NUMPMTS" INT, + "WIDTH" DOUBLE, + "LENGTH" DOUBLE, + "THICKNESS" DOUBLE, + "MATERIAL" TEXT +); +-- +DROP TABLE IF EXISTS "PRESHOWERPLATEGENERAL_DATA2TAG"; +CREATE TABLE IF NOT EXISTS "PRESHOWERPLATEGENERAL_DATA2TAG" ( + "PRESHOWERPLATEGENERAL_TAG_ID" SLONGLONG, + "PRESHOWERPLATEGENERAL_DATA_ID" SLONGLONG +); -- Tables for scintillator materials. -- Materials are recorded in two related nodes. -- One stores the name and density of the material. @@ -262,6 +369,38 @@ CREATE TABLE IF NOT EXISTS "VETOSWITCHES_DATA2TAG" ( "VETOSWITCHES_DATA_ID" SLONGLONG ); -- +DROP TABLE IF EXISTS "TRIGGERSWITCHES_DATA"; +CREATE TABLE IF NOT EXISTS "TRIGGERSWITCHES_DATA" ( + "TRIGGERSWITCHES_DATA_ID" SLONGLONG UNIQUE, + "DETECTORNAME" TEXT , + "USEMAGFIELDSVC" INT , + "COSMICLAYOUT" INT , + "VERSIONNAME" TEXT , + "LAYOUT" TEXT , + "DESCRIPTION" TEXT +); +DROP TABLE IF EXISTS "TRIGGERSWITCHES_DATA2TAG"; +CREATE TABLE IF NOT EXISTS "TRIGGERSWITCHES_DATA2TAG" ( + "TRIGGERSWITCHES_TAG_ID" SLONGLONG, + "TRIGGERSWITCHES_DATA_ID" SLONGLONG +); +-- +DROP TABLE IF EXISTS "PRESHOWERSWITCHES_DATA"; +CREATE TABLE IF NOT EXISTS "PRESHOWERSWITCHES_DATA" ( + "PRESHOWERSWITCHES_DATA_ID" SLONGLONG UNIQUE, + "DETECTORNAME" TEXT , + "USEMAGFIELDSVC" INT , + "COSMICLAYOUT" INT , + "VERSIONNAME" TEXT , + "LAYOUT" TEXT , + "DESCRIPTION" TEXT +); +DROP TABLE IF EXISTS "PRESHOWERSWITCHES_DATA2TAG"; +CREATE TABLE IF NOT EXISTS "PRESHOWERSWITCHES_DATA2TAG" ( + "PRESHOWERSWITCHES_TAG_ID" SLONGLONG, + "PRESHOWERSWITCHES_DATA_ID" SLONGLONG +); +-- DROP TABLE IF EXISTS "SCINTIDENTIFIER_DATA"; CREATE TABLE IF NOT EXISTS "SCINTIDENTIFIER_DATA" ( "SCINTIDENTIFIER_DATA_ID" SLONGLONG UNIQUE, @@ -331,6 +470,12 @@ INSERT INTO "HVS_NODE" VALUES (103, "Elements", 100, 0, NULL); INSERT INTO "HVS_NODE" VALUES (1001, "VetoTopLevel", 11, 0, NULL); INSERT INTO "HVS_NODE" VALUES (1002, "VetoStationGeneral", 11, 0, NULL); INSERT INTO "HVS_NODE" VALUES (1006, "VetoPlateGeneral", 11, 0, NULL); +INSERT INTO "HVS_NODE" VALUES (1101, "TriggerTopLevel", 12, 0, NULL); +INSERT INTO "HVS_NODE" VALUES (1102, "TriggerStationGeneral", 12, 0, NULL); +INSERT INTO "HVS_NODE" VALUES (1106, "TriggerPlateGeneral", 12, 0, NULL); +INSERT INTO "HVS_NODE" VALUES (1201, "PreshowerTopLevel", 13, 0, NULL); +INSERT INTO "HVS_NODE" VALUES (1202, "PreshowerStationGeneral", 13, 0, NULL); +INSERT INTO "HVS_NODE" VALUES (1206, "PreshowerPlateGeneral", 13, 0, NULL); INSERT INTO "HVS_NODE" VALUES (1003, "ScintMaterials", 1, 0, NULL); INSERT INTO "HVS_NODE" VALUES (1004, "ScintMatComponents", 1, 0, NULL); INSERT INTO "HVS_NODE" VALUES (2003, "TrackerMaterials", 2, 0, NULL); @@ -339,6 +484,8 @@ INSERT INTO "HVS_NODE" VALUES (3003, "CaloMaterials", 3, 0, NULL); INSERT INTO "HVS_NODE" VALUES (3004, "CaloMatComponents", 3, 0, NULL); INSERT INTO "HVS_NODE" VALUES (110, "FaserCommon", 0, 0, NULL); INSERT INTO "HVS_NODE" VALUES (1100, "VetoSwitches", 11, 0, NULL ); +INSERT INTO "HVS_NODE" VALUES (1200, "TriggerSwitches", 12, 0, NULL ); +INSERT INTO "HVS_NODE" VALUES (1300, "PreshowerSwitches", 13, 0, NULL ); INSERT INTO "HVS_NODE" VALUES (1005, "ScintIdentifier", 1, 0, NULL); INSERT INTO "HVS_NODE" VALUES (2005, "TrackerIdentifier", 2, 0, NULL); INSERT INTO "HVS_NODE" VALUES (3005, "CaloIdentifier", 3, 0, NULL); @@ -369,6 +516,12 @@ INSERT INTO "HVS_TAG2NODE" VALUES (103, "Elements-00", 100008, NULL, 0, 0, 15492 INSERT INTO "HVS_TAG2NODE" VALUES (1001, "VetoTopLevel-00", 100009, NULL, 0, 0, 1567123200000000000, NULL, 22); INSERT INTO "HVS_TAG2NODE" VALUES (1002, "VetoStationGeneral-00", 100010, NULL, 0, 0, 1567123200000000000, NULL, 22); INSERT INTO "HVS_TAG2NODE" VALUES (1006, "VetoPlateGeneral-00", 100025, NULL, 0, 0, 1567209600000000000, NULL, 22); +INSERT INTO "HVS_TAG2NODE" VALUES (1101, "TriggerTopLevel-00", 110009, NULL, 0, 0, 1581292800000000000, NULL, 22); +INSERT INTO "HVS_TAG2NODE" VALUES (1102, "TriggerStationGeneral-00", 110010, NULL, 0, 0, 1581292800000000000, NULL, 22); +INSERT INTO "HVS_TAG2NODE" VALUES (1106, "TriggerPlateGeneral-00", 110025, NULL, 0, 0, 1581292800000000000, NULL, 22); +INSERT INTO "HVS_TAG2NODE" VALUES (1201, "PreshowerTopLevel-00", 120009, NULL, 0, 0, 1581292800000000000, NULL, 22); +INSERT INTO "HVS_TAG2NODE" VALUES (1202, "PreshowerStationGeneral-00", 120010, NULL, 0, 0, 1581292800000000000, NULL, 22); +INSERT INTO "HVS_TAG2NODE" VALUES (1206, "PreshowerPlateGeneral-00", 120025, NULL, 0, 0, 1581292800000000000, NULL, 22); INSERT INTO "HVS_TAG2NODE" VALUES (1003, "ScintMaterials-00", 100011, NULL, 0, 0, 1549238400000000000, NULL, 22); INSERT INTO "HVS_TAG2NODE" VALUES (1004, "ScintMatComponents-00", 100012, NULL, 0, 0, 1549238400000000000, NULL, 22); INSERT INTO "HVS_TAG2NODE" VALUES (2003, "TrackerMaterials-00", 100021, NULL, 0, 0, 1550448000000000000, NULL, 22); @@ -377,6 +530,8 @@ INSERT INTO "HVS_TAG2NODE" VALUES (3003, "CaloMaterials-00", 100023, NULL, 0, 0, INSERT INTO "HVS_TAG2NODE" VALUES (3004, "CaloMatComponents-00", 100024, NULL, 0, 0, 1550448000000000000, NULL, 22); INSERT INTO "HVS_TAG2NODE" VALUES (110, "FaserCommon-00", 100013, NULL, 0, 0, 1549324800000000000, NULL, 22); INSERT INTO "HVS_TAG2NODE" VALUES (1100, "VetoSwitches-00", 100014, NULL, 0, 0, 1550361600000000000 ,NULL, 22); +INSERT INTO "HVS_TAG2NODE" VALUES (1200, "TriggerSwitches-00", 110014, NULL, 0, 0, 1581292800000000000 ,NULL, 22); +INSERT INTO "HVS_TAG2NODE" VALUES (1300, "PreshowerSwitches-00", 120014, NULL, 0, 0, 1550361600000000000 ,NULL, 22); INSERT INTO "HVS_TAG2NODE" VALUES (11, "Veto-00", 100015, NULL, 0, 0, 1550448000000000000, NULL, 22); INSERT INTO "HVS_TAG2NODE" VALUES (12, "Trigger-00", 100019, NULL, 0, 0, 1550448000000000000, NULL, 22); INSERT INTO "HVS_TAG2NODE" VALUES (13, "Preshower-00", 100020, NULL, 0, 0, 1550448000000000000, NULL, 22); @@ -394,6 +549,12 @@ INSERT INTO "HVS_LTAG2LTAG" VALUES (100, 100005, 103, 100008); INSERT INTO "HVS_LTAG2LTAG" VALUES (11, 100015, 1001, 100009); INSERT INTO "HVS_LTAG2LTAG" VALUES (11, 100015, 1002, 100010); INSERT INTO "HVS_LTAG2LTAG" VALUES (11, 100015, 1006, 100025); +INSERT INTO "HVS_LTAG2LTAG" VALUES (12, 110015, 1101, 110009); +INSERT INTO "HVS_LTAG2LTAG" VALUES (12, 110015, 1102, 110010); +INSERT INTO "HVS_LTAG2LTAG" VALUES (12, 110015, 1106, 110025); +INSERT INTO "HVS_LTAG2LTAG" VALUES (13, 120015, 1201, 120009); +INSERT INTO "HVS_LTAG2LTAG" VALUES (13, 120015, 1202, 120010); +INSERT INTO "HVS_LTAG2LTAG" VALUES (13, 120015, 1206, 120025); INSERT INTO "HVS_LTAG2LTAG" VALUES (1, 100001, 1003, 100011); INSERT INTO "HVS_LTAG2LTAG" VALUES (1, 100001, 1004, 100012); INSERT INTO "HVS_LTAG2LTAG" VALUES (2, 100002, 2003, 100021); @@ -418,6 +579,8 @@ INSERT INTO "HVS_LTAG2LTAG" VALUES (1, 100001, 11, 100015); INSERT INTO "HVS_LTAG2LTAG" VALUES (1, 100001, 12, 100019); INSERT INTO "HVS_LTAG2LTAG" VALUES (1, 100001, 13, 100020); INSERT INTO "HVS_LTAG2LTAG" VALUES (11, 100015, 1100, 100014); +INSERT INTO "HVS_LTAG2LTAG" VALUES (12, 110015, 1200, 110014); +INSERT INTO "HVS_LTAG2LTAG" VALUES (13, 120015, 1300, 120014); INSERT INTO "HVS_LTAG2LTAG" VALUES (1, 100001, 1005, 100016); INSERT INTO "HVS_LTAG2LTAG" VALUES (2, 100002, 2005, 100017); INSERT INTO "HVS_LTAG2LTAG" VALUES (3, 100003, 3005, 100018); @@ -446,6 +609,12 @@ INSERT INTO "HVS_TAGCACHE" VALUES ("FASER-00", "Elements", "Elements-0 INSERT INTO "HVS_TAGCACHE" VALUES ("FASER-00", "VetoTopLevel", "VetoTopLevel-00", 100009); INSERT INTO "HVS_TAGCACHE" VALUES ("FASER-00", "VetoStationGeneral", "VetoStationGeneral-00", 100010); INSERT INTO "HVS_TAGCACHE" VALUES ("FASER-00", "VetoPlateGeneral", "VetoPlateGeneral-00", 100025); +INSERT INTO "HVS_TAGCACHE" VALUES ("FASER-00", "TriggerTopLevel", "TriggerTopLevel-00", 110009); +INSERT INTO "HVS_TAGCACHE" VALUES ("FASER-00", "TriggerStationGeneral", "TriggerStationGeneral-00", 110010); +INSERT INTO "HVS_TAGCACHE" VALUES ("FASER-00", "TriggerPlateGeneral", "TriggerPlateGeneral-00", 110025); +INSERT INTO "HVS_TAGCACHE" VALUES ("FASER-00", "PreshowerTopLevel", "PreshowerTopLevel-00", 120009); +INSERT INTO "HVS_TAGCACHE" VALUES ("FASER-00", "PreshowerStationGeneral", "PreshowerStationGeneral-00", 120010); +INSERT INTO "HVS_TAGCACHE" VALUES ("FASER-00", "PreshowerPlateGeneral", "PreshowerPlateGeneral-00", 120025); INSERT INTO "HVS_TAGCACHE" VALUES ("FASER-00", "ScintMaterials", "ScintMaterials-00", 100011); INSERT INTO "HVS_TAGCACHE" VALUES ("FASER-00", "ScintMatComponents", "ScintMatComponents-00", 100012); INSERT INTO "HVS_TAGCACHE" VALUES ("FASER-00", "TrackerMaterials", "TrackerMaterials-00", 100021); @@ -454,6 +623,8 @@ INSERT INTO "HVS_TAGCACHE" VALUES ("FASER-00", "CaloMaterials", "CaloMateria INSERT INTO "HVS_TAGCACHE" VALUES ("FASER-00", "CaloMatComponents", "CaloMatComponents-00", 100024); INSERT INTO "HVS_TAGCACHE" VALUES ("FASER-00", "FaserCommon", "FaserCommon-00", 100013); INSERT INTO "HVS_TAGCACHE" VALUES ("FASER-00", "VetoSwitches", "VetoSwitches-00", 100014); +INSERT INTO "HVS_TAGCACHE" VALUES ("FASER-00", "TriggerSwitches", "TriggerSwitches-00", 110014); +INSERT INTO "HVS_TAGCACHE" VALUES ("FASER-00", "PreshowerSwitches", "PreshowerSwitches-00", 120014); INSERT INTO "HVS_TAGCACHE" VALUES ("FASER-00", "Veto", "Veto-00", 100015); INSERT INTO "HVS_TAGCACHE" VALUES ("FASER-00", "Trigger", "Trigger-00", 100019); INSERT INTO "HVS_TAGCACHE" VALUES ("FASER-00", "Preshower", "Preshower-00", 100020); @@ -1016,6 +1187,37 @@ INSERT INTO "VETOSTATIONGENERAL_DATA2TAG" VALUES (100010, 0); INSERT INTO "VETOPLATEGENERAL_DATA" VALUES (0, 1, 300.0, 300.0, 20.0, "scint::Scintillator"); INSERT INTO "VETOPLATEGENERAL_DATA2TAG" VALUES (100025, 0); -- +-- +INSERT INTO "TRIGGERTOPLEVEL_DATA" VALUES (0, 0.0, 0.0, 187.0, 0.0, 0.0, 0.0, 321, "Trigger"); +INSERT INTO "TRIGGERTOPLEVEL_DATA" VALUES (1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 321, "StationA"); +--INSERT INTO "TRIGGERTOPLEVEL_DATA" VALUES (2, 0.0, 0.0, 160.0, 0.0, 0.0, 0.0, 321, "StationB"); +INSERT INTO "TRIGGERTOPLEVEL_DATA2TAG" VALUES (110009, 0); +INSERT INTO "TRIGGERTOPLEVEL_DATA2TAG" VALUES (110009, 1); +--INSERT INTO "TRIGGERTOPLEVEL_DATA2TAG" VALUES (110009, 2); +-- +-- +INSERT INTO "TRIGGERSTATIONGENERAL_DATA" VALUES (0, 2, 195.0, 11.0); +INSERT INTO "TRIGGERSTATIONGENERAL_DATA2TAG" VALUES (110010, 0); +-- +INSERT INTO "TRIGGERPLATEGENERAL_DATA" VALUES (0, 2, 400.0, 200.0, 10.0, "scint::Scintillator"); +INSERT INTO "TRIGGERPLATEGENERAL_DATA2TAG" VALUES (110025, 0); +-- +-- +INSERT INTO "PRESHOWERTOPLEVEL_DATA" VALUES (0, 0.0, 0.0, 2626.0, 0.0, 0.0, 0.0, 321, "Preshower"); +INSERT INTO "PRESHOWERTOPLEVEL_DATA" VALUES (1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 321, "StationA"); +--INSERT INTO "PRESHOWERTOPLEVEL_DATA" VALUES (2, 0.0, 0.0, 160.0, 0.0, 0.0, 0.0, 321, "StationB"); +INSERT INTO "PRESHOWERTOPLEVEL_DATA2TAG" VALUES (120009, 0); +INSERT INTO "PRESHOWERTOPLEVEL_DATA2TAG" VALUES (120009, 1); +--INSERT INTO "PRESHOWERTOPLEVEL_DATA2TAG" VALUES (120009, 2); +-- +-- +INSERT INTO "PRESHOWERSTATIONGENERAL_DATA" VALUES (0, 2, 80.0); +INSERT INTO "PRESHOWERSTATIONGENERAL_DATA2TAG" VALUES (120010, 0); +-- +INSERT INTO "PRESHOWERPLATEGENERAL_DATA" VALUES (0, 1, 300.0, 300.0, 20.0, "scint::Scintillator"); +INSERT INTO "PRESHOWERPLATEGENERAL_DATA2TAG" VALUES (120025, 0); +-- +-- INSERT INTO "SCINTMATERIALS_DATA" VALUES (0, "Scintillator", 1.032); INSERT INTO "SCINTMATERIALS_DATA2TAG" VALUES (100011, 0); -- @@ -1034,6 +1236,14 @@ INSERT INTO "VETOSWITCHES_DATA" VALUES (0, "Veto", 1, 0, "GEO", "Development", INSERT INTO "VETOSWITCHES_DATA2TAG" VALUES (100014, 0); -- -- +INSERT INTO "TRIGGERSWITCHES_DATA" VALUES (0, "Trigger", 1, 0, "GEO", "Development", "Baseline geometry"); +INSERT INTO "TRIGGERSWITCHES_DATA2TAG" VALUES (110014, 0); +-- +-- +INSERT INTO "PRESHOWERSWITCHES_DATA" VALUES (0, "Preshower", 1, 0, "GEO", "Development", "Baseline geometry"); +INSERT INTO "PRESHOWERSWITCHES_DATA2TAG" VALUES (120014, 0); +-- +-- INSERT INTO "SCINTIDENTIFIER_DATA" VALUES (0, "Scintillator", "ScintIdDictFiles/IdDictScintillator.xml", "Baseline layout"); INSERT INTO "SCINTIDENTIFIER_DATA2TAG" VALUES (100016, 0); -- diff --git a/DetectorDescription/GeoModel/FaserGeoModel/python/FaserGeoModelConfig.py b/DetectorDescription/GeoModel/FaserGeoModel/python/FaserGeoModelConfig.py index bc6e08edc9b2c9f0b4550d8c82e364dc804004e3..37baa0e45cc652d9b5ea16e2bafca4a4dd938a4b 100644 --- a/DetectorDescription/GeoModel/FaserGeoModel/python/FaserGeoModelConfig.py +++ b/DetectorDescription/GeoModel/FaserGeoModel/python/FaserGeoModelConfig.py @@ -25,7 +25,4 @@ def FaserGeometryCfg (flags): from FaserGeoModel.DipoleGMConfig import DipoleGeometryCfg acc.merge(DipoleGeometryCfg(flags)) - # Protect against random failures to find sqlite files - # acc.getService("PoolSvc").SortReplicas = False - return acc diff --git a/DetectorDescription/GeoModel/FaserGeoModel/python/GeoModelInit.py b/DetectorDescription/GeoModel/FaserGeoModel/python/GeoModelInit.py index a3cc6be03369d6ed62ae02bd3a78463ca83acbdc..37c7692f8f50d8afb04f734b58d0b9895d806430 100644 --- a/DetectorDescription/GeoModel/FaserGeoModel/python/GeoModelInit.py +++ b/DetectorDescription/GeoModel/FaserGeoModel/python/GeoModelInit.py @@ -40,6 +40,24 @@ def _setupGeoModel(): geoModelSvc.DetectorTools += [ vetoDetectorTool ] + from TriggerGeoModel.TriggerGeoModelConf import TriggerDetectorTool + triggerDetectorTool = TriggerDetectorTool( DetectorName = "Trigger", + Alignable = True, + RDBAccessSvc = "RDBAccessSvc", + GeometryDBSvc = "ScintGeometryDBSvc", + GeoDbTagSvc = "GeoDbTagSvc") + + geoModelSvc.DetectorTools += [ triggerDetectorTool ] + + from PreshowerGeoModel.PreshowerGeoModelConf import PreshowerDetectorTool + preshowerDetectorTool = PreshowerDetectorTool( DetectorName = "Preshower", + Alignable = True, + RDBAccessSvc = "RDBAccessSvc", + GeometryDBSvc = "ScintGeometryDBSvc", + GeoDbTagSvc = "GeoDbTagSvc") + + geoModelSvc.DetectorTools += [ preshowerDetectorTool ] + from FaserSCT_GeoModel.FaserSCT_GeoModelConf import FaserSCT_DetectorTool faserSCTDetectorTool = FaserSCT_DetectorTool( DetectorName = "SCT", Alignable = True, diff --git a/DetectorDescription/GeoModel/FaserGeoModel/python/ScintGMConfig.py b/DetectorDescription/GeoModel/FaserGeoModel/python/ScintGMConfig.py index d1534eaf0cec8bf8a2815410e8d6bf7224f4d9f1..cecd5e6bcf2b36d5ece6fa4ea2e4e6a00ca92913 100644 --- a/DetectorDescription/GeoModel/FaserGeoModel/python/ScintGMConfig.py +++ b/DetectorDescription/GeoModel/FaserGeoModel/python/ScintGMConfig.py @@ -8,6 +8,14 @@ def ScintGeometryCfg (flags): acc = ComponentAccumulator() from VetoGeoModel.VetoGeoModelConfig import VetoGeometryCfg acc.merge(VetoGeometryCfg( flags )) + + from TriggerGeoModel.TriggerGeoModelConfig import TriggerGeometryCfg + acc.merge(TriggerGeometryCfg( flags )) + + from PreshowerGeoModel.PreshowerGeoModelConfig import PreshowerGeometryCfg + acc.merge(PreshowerGeometryCfg( flags )) + + return acc @@ -30,6 +38,8 @@ if __name__ == "__main__": # ConfigFlags.Input.Files = defaultTestFiles.HITS ConfigFlags.IOVDb.GlobalTag = "OFLCOND-XXXX-XXX-XX" ConfigFlags.Detector.SimulateVeto = True + ConfigFlags.Detector.SimulateTrigger= True + ConfigFlags.Detector.SimulatePreshower= True ConfigFlags.GeoModel.Align.Dynamic = False # Provide data input ##from AthenaConfiguration.TestDefaults import defaultTestFiles diff --git a/DetectorDescription/GeoModel/GeoAdaptors/GeoAdaptors/GeoScintHit.icc b/DetectorDescription/GeoModel/GeoAdaptors/GeoAdaptors/GeoScintHit.icc index b1cdaef101b0cc1af551dc2c02cac75da9521aac..9626a59a8f6d866585e4f5d607f9c9a18242eab8 100644 --- a/DetectorDescription/GeoModel/GeoAdaptors/GeoAdaptors/GeoScintHit.icc +++ b/DetectorDescription/GeoModel/GeoAdaptors/GeoAdaptors/GeoScintHit.icc @@ -5,13 +5,13 @@ #include "ScintSimEvent/ScintHit.h" #include "ScintReadoutGeometry/ScintDetectorElement.h" #include "ScintReadoutGeometry/VetoDetectorManager.h" -// #include "ScintReadoutGeometry/TriggerDetectorManager.h" -// #include "ScintReadoutGeometry/PreshowerDetectorManager.h" +#include "ScintReadoutGeometry/TriggerDetectorManager.h" +#include "ScintReadoutGeometry/PreshowerDetectorManager.h" #include "StoreGate/StoreGateSvc.h" #include "StoreGate/StoreGate.h" #include "ScintIdentifier/VetoID.h" -// #include "ScintIdentifier/TriggerID.h" -// #include "ScintIdentifier/PreshowerID.h" +#include "ScintIdentifier/TriggerID.h" +#include "ScintIdentifier/PreshowerID.h" #include "GeoPrimitives/CLHEPtoEigenConverter.h" inline void GeoScintHit::init() { @@ -19,21 +19,21 @@ inline void GeoScintHit::init() { StoreGateSvc *detStore = StoreGate::pointer("DetectorStore"); if(detStore->retrieve(s_veto,"Veto").isFailure()) s_veto = 0; -// if(detStore->retrieve(s_trigger,"Trigger").isFailure()) - s_trigger = 0; -// if(detStore->retrieve(s_trigger,"Preshower").isFailure()) - s_preshower = 0; + if(detStore->retrieve(s_trigger,"Trigger").isFailure()) + s_trigger = 0; + if(detStore->retrieve(s_preshower,"Preshower").isFailure()) + s_preshower = 0; if(detStore->retrieve(s_vID,"VetoID").isFailure()) - s_vID = 0; -// if(detStore->retrieve(s_tID,"TriggerID").isFailure()) - s_tID = 0; -// if(detStore->retrieve(s_pID,"PreshowerID").isFailure()) - s_pID = 0; + s_vID = 0; + if(detStore->retrieve(s_tID,"TriggerID").isFailure()) + s_tID = 0; + if(detStore->retrieve(s_pID,"PreshowerID").isFailure()) + s_pID = 0; } inline GeoScintHit::GeoScintHit (const ScintHit & h) { m_hit = &h; - if (!s_veto /*|| ! s_trigger || ! s_preshower */) init(); + if (!s_veto || ! s_trigger || ! s_preshower ) init(); } inline HepGeom::Point3D<double> GeoScintHit::getGlobalPosition() const { @@ -46,15 +46,15 @@ inline HepGeom::Point3D<double> GeoScintHit::getGlobalPosition() const { m_hit->getPlate()); geoelement = s_veto->getDetectorElement(id); } -// else if (m_hit->isTrigger()) { -// id = s_tID->wafer_id(Barrel, -// m_hit->getPlate()); -// geoelement = s_trigger->getDetectorElement(id); -// } else { -// id = s_pID->wafer_id(Barrel, -// m_hit->getPlate()); -// geoelement = s_preshower->getDetectorElement(id); -// } + else if (m_hit->isTrigger()) { + id = s_tID->plate_id(Station, + m_hit->getPlate()); + geoelement = s_trigger->getDetectorElement(id); + } else { + id = s_pID->plate_id(Station, + m_hit->getPlate()); + geoelement = s_preshower->getDetectorElement(id); + } if (geoelement) { diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/CMakeLists.txt b/Scintillator/ScintDetDescr/PreshowerGeoModel/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..d53c8ec926d945debb2be6aaa2553161650ba92a --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/CMakeLists.txt @@ -0,0 +1,49 @@ +################################################################################ +# Package: PreshowerGeoModel +################################################################################ + +# Declare the package name: +atlas_subdir( PreshowerGeoModel ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + Control/AthenaKernel + Database/RDBAccessSvc + DetectorDescription/GeoModel/GeoModelUtilities + DetectorDescription/GeoModel/GeoModelFaserUtilities + DetectorDescription/GeoPrimitives + GaudiKernel + Scintillator/ScintDetDescr/ScintGeoModelUtils + Scintillator/ScintDetDescr/ScintReadoutGeometry + PRIVATE + Control/SGTools + Control/StoreGate + Database/AthenaPOOL/AthenaPoolUtilities + DetectorDescription/DetDescrCond/DetDescrConditions + DetectorDescription/GeoModel/GeoModelInterfaces + DetectorDescription/GeometryDBSvc + DetectorDescription/Identifier + Scintillator/ScintDetDescr/ScintIdentifier + DetectorDescription/FaserDetDescr + Scintillator/ScintDetDescr/ScintIdentifier ) + +# External dependencies: +find_package( Boost COMPONENTS filesystem thread system ) +find_package( CORAL COMPONENTS CoralBase CoralKernel RelationalAccess ) +find_package( Eigen ) +find_package( GeoModelCore ) + +# Component(s) in the package: +atlas_add_component( PreshowerGeoModel + src/*.cxx + src/components/*.cxx + INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} + LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} ${GEOMODEL_LIBRARIES} AthenaKernel GeoModelUtilities GeoModelFaserUtilities GaudiKernel SGTools StoreGateLib SGtests AthenaPoolUtilities DetDescrConditions FaserDetDescr ScintGeoModelUtils ScintReadoutGeometry ScintIdentifier Identifier ) + +#atlas_add_test( SCT_GMConfig_test +# SCRIPT test/SCT_GMConfig_test.py +# PROPERTIES TIMEOUT 300 ) + +# Install files from the package: +atlas_install_python_modules( python/*.py ) +atlas_install_scripts( test/*.py ) diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/PreshowerGeoModel/PreshowerDetectorTool.h b/Scintillator/ScintDetDescr/PreshowerGeoModel/PreshowerGeoModel/PreshowerDetectorTool.h new file mode 100644 index 0000000000000000000000000000000000000000..634f702e9fec22a4585ee4ea708fefb6ae9be924 --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/PreshowerGeoModel/PreshowerDetectorTool.h @@ -0,0 +1,61 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PRESHOWERGEOMODEL_PRESHOWERDETECTORTOOL_H +#define PRESHOWERGEOMODEL_PRESHOWERDETECTORTOOL_H + +#include "GeoModelUtilities/GeoModelTool.h" +#include "PreshowerGeoModel/PreshowerGeoModelAthenaComps.h" + +#include "GeometryDBSvc/IGeometryDBSvc.h" +#include "GeoModelInterfaces/IGeoDbTagSvc.h" +#include "RDBAccessSvc/IRDBAccessSvc.h" + +#include "GaudiKernel/ServiceHandle.h" + +#include <string> + +namespace ScintDD { + class PreshowerDetectorManager; +} + +class PreshowerID; +// class FaserDetectorID; + +class PreshowerDetectorTool : public GeoModelTool { + +public: + // Standard Constructor + PreshowerDetectorTool(const std::string& type, const std::string& name, const IInterface* parent); + + virtual StatusCode create() override final; + virtual StatusCode clear() override final; + + // Register callback function on ConDB object + virtual StatusCode registerCallback() override final; + + // Callback function itself + virtual StatusCode align(IOVSVC_CALLBACK_ARGS) override; + +private: + StringProperty m_detectorName{this, "DetectorName", "Preshower"}; + BooleanProperty m_alignable{this, "Alignable", true}; + BooleanProperty m_useDynamicAlignFolders{this, "useDynamicAlignFolders", false}; + bool m_cosmic; + + const ScintDD::PreshowerDetectorManager* m_manager; + + PreshowerGeoModelAthenaComps m_athenaComps; + + ServiceHandle< IGeoDbTagSvc > m_geoDbTagSvc; + ServiceHandle< IRDBAccessSvc > m_rdbAccessSvc; + ServiceHandle< IGeometryDBSvc > m_geometryDBSvc; + + StringProperty m_run1Folder{this, "Run1Folder", "/Scint/Align"}; + StringProperty m_run2L1Folder{this, "Run2L1Folder", "/Scint/AlignL1/ID"}; + StringProperty m_run2L2Folder{this, "Run2L2Folder", "/Scint/AlignL2/SCT"}; + StringProperty m_run2L3Folder{this, "Run2L3Folder", "/Scint/AlignL3"}; +}; + +#endif // PRESHOWERGEOMODEL_PRESHOWERDETECTORTOOL_H diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/PreshowerGeoModel/PreshowerGeoModelAthenaComps.h b/Scintillator/ScintDetDescr/PreshowerGeoModel/PreshowerGeoModel/PreshowerGeoModelAthenaComps.h new file mode 100644 index 0000000000000000000000000000000000000000..f12912b1bac207f23c6c697ae6179d971b0ce5ee --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/PreshowerGeoModel/PreshowerGeoModelAthenaComps.h @@ -0,0 +1,29 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PreshowerGeoModel_PreshowerGeoModelAthenaComps_H +#define PreshowerGeoModel_PreshowerGeoModelAthenaComps_H 1 + +#include "ScintGeoModelUtils/ScintDDAthenaComps.h" + +class PreshowerID; + +/// Class to hold various Athena components +// template <class ID_HELPER> +class PreshowerGeoModelAthenaComps : public ScintDD::AthenaComps { + +public: + + PreshowerGeoModelAthenaComps(); + + void setIdHelper(const PreshowerID* idHelper); + + const PreshowerID* getIdHelper() const; + +private: + const PreshowerID* m_idHelper; + +}; + +#endif // PreshowerGeoModel_PreshowerGeoModelAthenaComps_H diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/python/PreshowerGeoModelConfig.py b/Scintillator/ScintDetDescr/PreshowerGeoModel/python/PreshowerGeoModelConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..78f1ed88dbdba501b82f13bed284d37b71e9fb8f --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/python/PreshowerGeoModelConfig.py @@ -0,0 +1,55 @@ +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + +from AthenaCommon import CfgMgr + +def getPreshowerDetectorTool(name="PreshowerDetectorTool", **kwargs): + kwargs.setdefault("DetectorName", "Preshower"); + kwargs.setdefault("Alignable", True); + kwargs.setdefault("RDBAccessSvc", "RDBAccessSvc"); + kwargs.setdefault("GeometryDBSvc", "ScintGeometryDBSvc"); + kwargs.setdefault("GeoDbTagSvc", "GeoDbTagSvc"); + return CfgMgr.PreshowerDetectorTool(name, **kwargs) + +from IOVDbSvc.IOVDbSvcConfig import addFoldersSplitOnline + +def PreshowerGeometryCfg( flags ): + from FaserGeoModel.GeoModelConfig import GeoModelCfg + acc = GeoModelCfg( flags ) + geoModelSvc = acc.getPrimary() + + from GeometryDBSvc.GeometryDBSvcConf import GeometryDBSvc + acc.addService(GeometryDBSvc("ScintGeometryDBSvc")) + + from RDBAccessSvc.RDBAccessSvcConf import RDBAccessSvc + acc.addService(RDBAccessSvc("RDBAccessSvc")) + + from DBReplicaSvc.DBReplicaSvcConf import DBReplicaSvc + acc.addService(DBReplicaSvc("DBReplicaSvc")) + + from PreshowerGeoModel.PreshowerGeoModelConf import PreshowerDetectorTool + preshowerDetectorTool = PreshowerDetectorTool() + + preshowerDetectorTool.useDynamicAlignFolders = flags.GeoModel.Align.Dynamic + geoModelSvc.DetectorTools += [ preshowerDetectorTool ] + + # if flags.GeoModel.Align.Dynamic: + # acc.merge(addFoldersSplitOnline(flags,"INDET","/Indet/Onl/AlignL1/ID","/Indet/AlignL1/ID",className="CondAttrListCollection")) + # acc.merge(addFoldersSplitOnline(flags,"INDET","/Indet/Onl/AlignL2/SCT","/Indet/AlignL2/SCT",className="CondAttrListCollection")) + # acc.merge(addFoldersSplitOnline(flags,"INDET","/Indet/Onl/AlignL3","/Indet/AlignL3",className="AlignableTransformContainer")) + # else: + # if (not flags.Detector.SimulatePreshower) or flags.Detector.OverlayPreshower: + # acc.merge(addFoldersSplitOnline(flags,"INDET","/Indet/Onl/Align","/Indet/Align",className="AlignableTransformContainer")) + # else: + # acc.merge(addFoldersSplitOnline(flags,"INDET","/Indet/Onl/Align","/Indet/Align")) + + # if flags.Common.Project is not "AthSimulation": # Protection for AthSimulation builds + # if (not flags.Detector.SimulatePreshower) or flags.Detector.OverlayPreshower: + # from PreshowerConditionsAlgorithms.PreshowerConditionsAlgorithmsConf import PreshowerAlignCondAlg + # preshowerAlignCondAlg = PreshowerAlignCondAlg(name = "PreshowerAlignCondAlg", + # UseDynamicAlignFolders = flags.GeoModel.Align.Dynamic) + # acc.addCondAlgo(preshowerAlignCondAlg) + # from PreshowerConditionsAlgorithms.PreshowerConditionsAlgorithmsConf import PreshowerDetectorElementCondAlg + # preshowerDetectorElementCondAlg = PreshowerDetectorElementCondAlg(name = "PreshowerDetectorElementCondAlg") + # acc.addCondAlgo(preshowerDetectorElementCondAlg) + + return acc diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerComponentFactory.cxx b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerComponentFactory.cxx new file mode 100644 index 0000000000000000000000000000000000000000..29f9ab72bf651eaba5266d24d74efac8769f6ed6 --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerComponentFactory.cxx @@ -0,0 +1,40 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "PreshowerComponentFactory.h" +#include "GaudiKernel/SystemOfUnits.h" + +#include <sstream> +#include <string> + +using ScintDD::PreshowerDetectorManager; + +const double PreshowerComponentFactory::s_epsilon = 1.0e-6 * Gaudi::Units::mm; + +PreshowerComponentFactory::PreshowerComponentFactory(const std::string & name, + ScintDD::PreshowerDetectorManager* detectorManager, + const PreshowerGeometryManager* geometryManager, + PreshowerMaterialManager* materials) + : m_detectorManager(detectorManager), + m_geometryManager(geometryManager), + m_materials(materials), + m_name(name) +{} + +PreshowerComponentFactory::~PreshowerComponentFactory() +{} + +std::string +PreshowerComponentFactory::intToString(int i) const +{ + std::ostringstream str; + str << i; + return str.str(); +} + +double +PreshowerComponentFactory::epsilon() const +{ + return s_epsilon; +} diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerComponentFactory.h b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerComponentFactory.h new file mode 100644 index 0000000000000000000000000000000000000000..49e5e71768314322f089a71f00c69849f2fcd668 --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerComponentFactory.h @@ -0,0 +1,89 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PRESHOWERGEOMODEL_PRESHOWERCOMPONENTFACTORY_H +#define PRESHOWERGEOMODEL_PRESHOWERCOMPONENTFACTORY_H + +#include "PreshowerIdentifier.h" +#include <string> + +namespace ScintDD{class PreshowerDetectorManager;} +class PreshowerGeometryManager; +class PreshowerMaterialManager; + +class GeoLogVol; +class GeoVPhysVol; + + +class PreshowerComponentFactory +{ + +public: + PreshowerComponentFactory(const std::string & name, + ScintDD::PreshowerDetectorManager* detectorManager, + const PreshowerGeometryManager* geometryManager, + PreshowerMaterialManager* materials); + + const std::string & getName() const {return m_name;} + + // utility function to covert int to string + std::string intToString(int i) const; + +protected: + ScintDD::PreshowerDetectorManager* m_detectorManager; + const PreshowerGeometryManager* m_geometryManager; + PreshowerMaterialManager* m_materials; + + double epsilon() const; + virtual ~PreshowerComponentFactory(); + +private: + std::string m_name; + static const double s_epsilon; + +}; + + +class PreshowerSharedComponentFactory : public PreshowerComponentFactory +{ + +public: + PreshowerSharedComponentFactory(const std::string & name, + ScintDD::PreshowerDetectorManager* detectorManager, + const PreshowerGeometryManager* geometryManager, + PreshowerMaterialManager* materials=nullptr) : + PreshowerComponentFactory(name, detectorManager, geometryManager, materials), + m_physVolume(nullptr) + {}; + + GeoVPhysVol * getVolume() {return m_physVolume;} + +protected: + GeoVPhysVol * m_physVolume; + virtual GeoVPhysVol * build() = 0; + +}; + +class PreshowerUniqueComponentFactory : public PreshowerComponentFactory +{ + +public: + PreshowerUniqueComponentFactory(const std::string & name, + ScintDD::PreshowerDetectorManager* detectorManager, + const PreshowerGeometryManager* geometryManager, + PreshowerMaterialManager* materials=nullptr) : + PreshowerComponentFactory(name, detectorManager, geometryManager, materials), + m_logVolume{nullptr} + {}; + + virtual GeoVPhysVol * build(PreshowerIdentifier id) = 0; + +protected: + const GeoLogVol * m_logVolume; + + virtual const GeoLogVol * preBuild() = 0; + +}; + +#endif // PRESHOWERGEOMODEL_PRESHOWERCOMPONENTFACTORY_H diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerDataBase.cxx b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerDataBase.cxx new file mode 100644 index 0000000000000000000000000000000000000000..e45e3051cf883674f2216a86579ebdf2856aaa41 --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerDataBase.cxx @@ -0,0 +1,104 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "PreshowerDataBase.h" + +#include "RDBAccessSvc/IRDBAccessSvc.h" +#include "RDBAccessSvc/IRDBRecordset.h" +#include "RDBAccessSvc/IRDBRecord.h" + +#include "GeoModelInterfaces/IGeoDbTagSvc.h" +#include "GeoModelFaserUtilities/DecodeFaserVersionKey.h" + +#include "PreshowerGeoModel/PreshowerGeoModelAthenaComps.h" + +#include <iostream> + +PreshowerDataBase::PreshowerDataBase(const PreshowerGeoModelAthenaComps * athenaComps) +{ + m_athenaComps = athenaComps; + + IGeoDbTagSvc * geoDbTag = m_athenaComps->geoDbTagSvc(); + + // Get version tag and node for Preshower + DecodeFaserVersionKey versionKey(geoDbTag,"Preshower"); + std::string versionTag = versionKey.tag(); + std::string versionNode = versionKey.node(); + + // Get version tag and node for Scintillator. + DecodeFaserVersionKey scintVersionKey(geoDbTag,"Scintillator"); + + // Access the RDB + IRDBAccessSvc* rdbSvc = m_athenaComps->rdbAccessSvc(); + + // Preshower version tag + m_preshowerVersionTag = rdbSvc->getChildTag("Preshower", versionKey.tag(), versionKey.node(), "FASERDD"); + + +///////////////////////////////////////////////////////// +// +// Gets the structures +// +///////////////////////////////////////////////////////// + + msg(MSG::INFO) << "Retrieving Record Sets from database ..." << endmsg; + msg(MSG::DEBUG) << " Using version tag: " << versionTag << endmsg; + msg(MSG::DEBUG) << " at node: " << versionNode << endmsg; + msg(MSG::DEBUG) << " Preshower Version: " << m_preshowerVersionTag << endmsg; + + // ATLS - not sure I use it. + // General atlas parameters + + // + // Preshower General + // + + // Preshower TopLevel + m_topLevel = rdbSvc->getRecordsetPtr("PreshowerTopLevel", versionTag, versionNode, "FASERDD"); + msg(MSG::DEBUG) << "Table PreshowerTopLevel Fetched" << endmsg; + + // Weight Table + m_weightTable = rdbSvc->getRecordsetPtr("PreshowerWeights", versionTag, versionNode, "FASERDD"); + msg(MSG::DEBUG) << "Table PreshowerWeights Fetched" << endmsg; + + // Extra Scaling Table. This is used for extra material studies. For nominal material the table should be empty. + // NB this is at InnerDetector level node. + m_scalingTable = rdbSvc->getRecordsetPtr("PreshowerMatScaling", scintVersionKey.tag(), scintVersionKey.node(), "FASERDD"); + msg(MSG::DEBUG) << "Table PreshowerMatScaling Fetched" << endmsg; + +// // Default conditions +// m_conditions = rdbSvc->getRecordsetPtr("PreshowerConditions", versionTag, versionNode, "FASERDD"); +// msg(MSG::DEBUG) << "Table PreshowerConditions Fetched" << endmsg; + + m_stationGeneral = rdbSvc->getRecordsetPtr("PreshowerStationGeneral", versionTag, versionNode, "FASERDD"); + msg(MSG::DEBUG) << "Table PreshowerStationGeneral Fetched" << endmsg; + + m_plateGeneral = rdbSvc->getRecordsetPtr("PreshowerPlateGeneral", versionTag, versionNode, "FASERDD"); + msg(MSG::DEBUG) << "Table PreshowerPlateGeneral Fetched" << endmsg; + +} + +const PreshowerGeoModelAthenaComps* PreshowerDataBase::athenaComps() const { return m_athenaComps; } + +IRDBRecordset_ptr PreshowerDataBase::weightTable() const {return m_weightTable;} + +IRDBRecordset_ptr PreshowerDataBase::scalingTable() const {return m_scalingTable;} + +// //const IRDBRecord* PreshowerDataBase::atls() const {return *m_atls)[0];} +IRDBRecordset_ptr PreshowerDataBase::topLevelTable() const {return m_topLevel;} + +// IRDBRecordset_ptr PreshowerDataBase::conditionsTable() const {return m_conditions;} +// const IRDBRecord* PreshowerDataBase::conditions() const {return (*m_conditions)[0];} + +const IRDBRecord* PreshowerDataBase::stationGeneral() const {return (*m_stationGeneral)[0];} +const IRDBRecord* PreshowerDataBase::plateGeneral() const {return (*m_plateGeneral)[0];} + +const std::string & PreshowerDataBase::versionTag() const { + return m_preshowerVersionTag; +} + +MsgStream& PreshowerDataBase::msg (MSG::Level lvl) const +{ + return m_athenaComps->msg(lvl); +} diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerDataBase.h b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerDataBase.h new file mode 100644 index 0000000000000000000000000000000000000000..7021191a20b434a95dfe66606c742ba9258e5f52 --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerDataBase.h @@ -0,0 +1,59 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PreshowerGeoModel_PreshowerDataBase_H +#define PreshowerGeoModel_PreshowerDataBase_H + +#include "PreshowerGeoModel/PreshowerGeoModelAthenaComps.h" +#include <string> + +#include "RDBAccessSvc/IRDBAccessSvc.h" +class IRDBRecord; + + +class PreshowerDataBase +{ + + +public: + + PreshowerDataBase(const PreshowerGeoModelAthenaComps* athenaComps); + + const PreshowerGeoModelAthenaComps* athenaComps() const; + + IRDBRecordset_ptr weightTable() const; + IRDBRecordset_ptr scalingTable() const; + IRDBRecordset_ptr topLevelTable() const; + + const IRDBRecord* stationGeneral() const; + const IRDBRecord* plateGeneral() const; + + // Return the Preshower version tag. + const std::string & versionTag() const; + + MsgStream& msg (MSG::Level lvl) const; + +private: + + PreshowerDataBase(const PreshowerDataBase &); + PreshowerDataBase& operator= (const PreshowerDataBase &); + +private: + + const PreshowerGeoModelAthenaComps* m_athenaComps; + + std::string m_preshowerVersionTag; + + IRDBRecordset_ptr m_weightTable; + IRDBRecordset_ptr m_scalingTable; + IRDBRecordset_ptr m_topLevel; + IRDBRecordset_ptr m_conditions; + + IRDBRecordset_ptr m_stationGeneral; + IRDBRecordset_ptr m_plateGeneral; + + +}; + +#endif //PreshowerGeoModel_PreshowerDataBase_H diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerDetectorFactory.cxx b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerDetectorFactory.cxx new file mode 100644 index 0000000000000000000000000000000000000000..13c00ff33d5bb16805acb97196fdbe8cd12a82da --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerDetectorFactory.cxx @@ -0,0 +1,263 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +// +// PreshowerDetectorFactory: This is the top level node +// + + +#include "PreshowerDetectorFactory.h" + +#include "PreshowerDataBase.h" +#include "PreshowerIdentifier.h" +#include "PreshowerGeometryManager.h" +#include "PreshowerMaterialManager.h" +#include "PreshowerGeneralParameters.h" +#include "ScintReadoutGeometry/Version.h" +#include "ScintReadoutGeometry/ScintCommonItems.h" +#include "ScintReadoutGeometry/ScintDD_Defs.h" +#include "ScintReadoutGeometry/ScintDetectorDesign.h" + +#include "PreshowerStation.h" +#include "PreshowerPlate.h" +#include "PreshowerDataBase.h" +#include "PreshowerGeoModel/PreshowerGeoModelAthenaComps.h" + +// +// GeoModel include files: +// +#include "GeoModelKernel/GeoMaterial.h" +#include "GeoModelKernel/GeoTube.h" +#include "GeoModelKernel/GeoLogVol.h" +#include "GeoModelKernel/GeoNameTag.h" +#include "GeoModelKernel/GeoIdentifierTag.h" +#include "GeoModelKernel/GeoPhysVol.h" +#include "GeoModelKernel/GeoVPhysVol.h" +#include "GeoModelKernel/GeoTransform.h" +#include "GeoModelKernel/GeoAlignableTransform.h" +#include "GeoModelKernel/GeoShape.h" +#include "GeoModelKernel/GeoShapeUnion.h" +#include "GeoModelKernel/GeoShapeShift.h" +#include "GeoModelInterfaces/StoredMaterialManager.h" +#include "GeoModelInterfaces/IGeoDbTagSvc.h" +#include "GeoModelFaserUtilities/DecodeFaserVersionKey.h" +#include "RDBAccessSvc/IRDBAccessSvc.h" +#include "RDBAccessSvc/IRDBRecordset.h" +#include "RDBAccessSvc/IRDBRecord.h" +#include "AthenaPoolUtilities/CondAttrListCollection.h" +#include "DetDescrConditions/AlignableTransformContainer.h" +# +#include "StoreGate/StoreGateSvc.h" +#include "GaudiKernel/ISvcLocator.h" + +#include "GeoModelKernel/GeoDefinitions.h" +#include "GaudiKernel/SystemOfUnits.h" + + + +#include <iostream> +#include <iomanip> +#include <string> + +using ScintDD::PreshowerDetectorManager; +using ScintDD::ScintCommonItems; + +PreshowerDetectorFactory::PreshowerDetectorFactory(const PreshowerGeoModelAthenaComps * athenaComps, + const PreshowerOptions & options) + : ScintDD::DetectorFactoryBase(athenaComps), + m_useDynamicAlignFolders(false) +{ + + // Create the detector manager + m_detectorManager = new PreshowerDetectorManager(detStore()); + msg(MSG::DEBUG) << "Created PreshowerDetectorManager" << endmsg; + + // Create the database + m_db = new PreshowerDataBase{athenaComps}; + msg(MSG::DEBUG) << "Created PreshowerDataBase" << endmsg; + + // Create the material manager + m_materials = new PreshowerMaterialManager{m_db}; + msg(MSG::DEBUG) << "Created PreshowerMaterialManager" << endmsg; + + // Create the geometry manager. + m_geometryManager = new PreshowerGeometryManager{m_db}; + msg(MSG::DEBUG) << "Created PreshowerGeometryManager" << endmsg; + m_geometryManager->setOptions(options); + msg(MSG::DEBUG) << "Set options on PreshowerGeometryManager" << endmsg; + + m_useDynamicAlignFolders = options.dynamicAlignFolders(); + + // Set Version information + // Get the geometry tag + DecodeFaserVersionKey versionKey(geoDbTagSvc(),"Preshower"); + IRDBRecordset_ptr switchSet + = rdbAccessSvc()->getRecordsetPtr("PreshowerSwitches", versionKey.tag(), versionKey.node(),"FASERDD"); + const IRDBRecord *switches = (*switchSet)[0]; + msg(MSG::DEBUG) << "Retrieved PreshowerSwitches" << endmsg; + + std::string layout = "Final"; + std::string description; + if (!switches->isFieldNull("LAYOUT")) { + layout = switches->getString("LAYOUT"); + } + if (!switches->isFieldNull("DESCRIPTION")) { + description = switches->getString("DESCRIPTION"); + } + + std::string versionTag = rdbAccessSvc()->getChildTag("Preshower", versionKey.tag(), versionKey.node(),"FASERDD"); + std::string versionName = switches->getString("VERSIONNAME"); + int versionMajorNumber = 1; + int versionMinorNumber = 0; + int versionPatchNumber = 0; + ScintDD::Version version(versionTag, + versionName, + layout, + description, + versionMajorNumber, + versionMinorNumber, + versionPatchNumber); + m_detectorManager->setVersion(version); +} + + +PreshowerDetectorFactory::~PreshowerDetectorFactory() +{ + // NB the detector manager (m_detectorManager)is stored in the detector store by the + // Tool and so we don't delete it. + delete m_db; + delete m_materials; + delete m_geometryManager; +} + +void PreshowerDetectorFactory::create(GeoPhysVol *world) +{ + + msg(MSG::INFO) << "Building Preshower Detector." << endmsg; + msg(MSG::INFO) << " " << m_detectorManager->getVersion().fullDescription() << endmsg; + + // Change precision. + int oldPrecision = std::cout.precision(6); + + // The tree tops get added to world. We name it "indet" though. + GeoPhysVol *scint = world; + + const PreshowerGeneralParameters * preshowerGeneral = m_geometryManager->generalParameters(); + + GeoTrf::Transform3D preshowerTransform = preshowerGeneral->partTransform("Preshower"); + + std::string stationA_Label = "StationA"; + // std::string stationB_Label = "StationB"; + // std::string absorberA_Label = "AbsorberA"; + // std::string absorberB_Label = "AbsorberB"; + + bool stationA_Present = preshowerGeneral->partPresent(stationA_Label); + // bool stationB_Present = preshowerGeneral->partPresent(stationB_Label); + // bool absorberA_Present = preshowerGeneral->partPresent(absorberA_Label); + // bool absorberB_Present = preshowerGeneral->partPresent(absorberB_Label); + + // + // Plate is the same for all stations + // + PreshowerPlate plate("Plate", m_detectorManager, m_geometryManager, m_materials); + msg(MSG::DEBUG) << "Created Preshower plate with dimensions (" << plate.thickness() << "," << plate.width() << "," << plate.length() << ")" << endmsg; + // + // Station A + // + if (stationA_Present) + { + msg(MSG::DEBUG) << "Building the Preshower Station A." << endmsg; + m_detectorManager->numerology().addStation(0); + + // Create the station + PreshowerStation stationA("PreshowerStationA", &plate, m_detectorManager, m_geometryManager, m_materials); + PreshowerIdentifier id{m_geometryManager->athenaComps()->getIdHelper()}; + id.setStation(0); + GeoVPhysVol* stationA_PV = stationA.build(id); + GeoAlignableTransform* stationA_Transform = new GeoAlignableTransform(preshowerTransform * preshowerGeneral->partTransform(stationA_Label)); + + msg(MSG::INFO) << stationA_Transform->getTransform().translation() << endmsg; + GeoNameTag* topLevelNameTag = new GeoNameTag("Preshower"); + scint->add(topLevelNameTag); + scint->add(new GeoIdentifierTag(0)); + scint->add(stationA_Transform); + scint->add(stationA_PV); + m_detectorManager->addTreeTop(stationA_PV); + + // Store alignable transform for station (level = 1) + m_detectorManager->addAlignableTransform(1, id.getPlateId(), stationA_Transform, stationA_PV); + } + + // + // Station B + // + // if (stationB_Present) + // { + // msg(MSG::DEBUG) << "Building the Preshower Station B." << endmsg; + // m_detectorManager->numerology().addStation(1); + + // // Create the station + // PreshowerStation stationB("PreshowerStationB", &plate, m_detectorManager, m_geometryManager, m_materials); + // PreshowerIdentifier id{m_geometryManager->athenaComps()->getIdHelper()}; + // id.setStation(1); + // GeoVPhysVol* stationB_PV = stationB.build(id); + // GeoAlignableTransform* stationB_Transform = new GeoAlignableTransform(preshowerTransform * preshowerGeneral->partTransform(stationB_Label)); + + // GeoNameTag* topLevelNameTag = new GeoNameTag("Preshower"); + // scint->add(topLevelNameTag); + // scint->add(new GeoIdentifierTag(0)); + // scint->add(stationB_Transform); + // scint->add(stationB_PV); + // m_detectorManager->addTreeTop(stationB_PV); + + // // Store alignable transform for station (level = 1) + // m_detectorManager->addAlignableTransform(1, id.getPlateId(), stationB_Transform, stationB_PV); + // } + + // Set the neighbours + m_detectorManager->initNeighbours(); + + // Set number of pmts in numerology. + const ScintDD::ScintDetectorDesign* design = m_detectorManager->getPreshowerDesign(); + if (design != nullptr) + { + m_detectorManager->numerology().setNumPmtsPerPlate(m_detectorManager->getPreshowerDesign()->cells()); + } + else + { + m_detectorManager->numerology().setNumPmtsPerPlate(0); + } + + + // Register the keys and the level corresponding to the key + // and whether it expects a global or local shift. + // level 0: sensor, level 1: module, level 2, layer/disc, level 3: whole barrel/enccap + + + if (!m_useDynamicAlignFolders){ + + m_detectorManager->addAlignFolderType(ScintDD::static_run1); + // m_detectorManager->addFolder("/Scint/Align"); + } + else { + m_detectorManager->addAlignFolderType(ScintDD::timedependent_run2); + // m_detectorManager->addGlobalFolder("/Scint/AlignL1/Scint"); + // m_detectorManager->addGlobalFolder("/Scint/AlignL2/Preshower"); + // m_detectorManager->addChannel("/Scint/AlignL1/Scint",3,ScintDD::global); + // m_detectorManager->addChannel("/Scint/AlignL2/Preshower",2,ScintDD::global); + // m_detectorManager->addFolder("/Scint/AlignL3"); + } + + // Return precision to its original value + std::cout.precision(oldPrecision); + +} + + +const PreshowerDetectorManager * PreshowerDetectorFactory::getDetectorManager() const +{ + return m_detectorManager; +} + + diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerDetectorFactory.h b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerDetectorFactory.h new file mode 100644 index 0000000000000000000000000000000000000000..1b10b58e2fed7e9070e4b66d1b86dc81223c9b96 --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerDetectorFactory.h @@ -0,0 +1,50 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PRESHOWERGEOMODEL_PRESHOWERDETECTORFACTORY_H +#define PRESHOWERGEOMODEL_PRESHOWERDETECTORFACTORY_H + +#include "ScintGeoModelUtils/DetectorFactoryBase.h" +#include "ScintReadoutGeometry/PreshowerDetectorManager.h" +#include "ScintReadoutGeometry/ScintDD_Defs.h" + +class GeoPhysVol; +class PreshowerDataBase; +class PreshowerGeometryManager; +class PreshowerGeoModelAthenaComps; +class PreshowerMaterialManager; +class PreshowerOptions; + +class PreshowerDetectorFactory : public ScintDD::DetectorFactoryBase +{ + + public: + // Constructor + PreshowerDetectorFactory(const PreshowerGeoModelAthenaComps * athenaComps, + const PreshowerOptions & options); + + // Destructor + virtual ~PreshowerDetectorFactory(); + + // Creation of geometry: + virtual void create(GeoPhysVol *world); + + // Access to the results: + virtual const ScintDD::PreshowerDetectorManager * getDetectorManager() const; + + private: + // Copy and assignments operations illegal and so are made private + PreshowerDetectorFactory(const PreshowerDetectorFactory &right); + const PreshowerDetectorFactory & operator=(const PreshowerDetectorFactory &right); + + ScintDD::PreshowerDetectorManager *m_detectorManager; + PreshowerGeometryManager *m_geometryManager; + PreshowerDataBase* m_db; + PreshowerMaterialManager* m_materials; + bool m_useDynamicAlignFolders; + +}; + +#endif + diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerDetectorTool.cxx b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerDetectorTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..83b38a9d8830473fad9cb51b83a9141d7eb51c37 --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerDetectorTool.cxx @@ -0,0 +1,249 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "PreshowerGeoModel/PreshowerDetectorTool.h" + +#include "PreshowerDetectorFactory.h" +#include "PreshowerDataBase.h" +// #include "PreshowerMaterialManager.h" +#include "PreshowerOptions.h" + +// temporary +#include "ScintReadoutGeometry/PreshowerDetectorManager.h" +#include "ScintIdentifier/PreshowerID.h" +#include "DetDescrConditions/AlignableTransformContainer.h" + +#include "GeoModelUtilities/GeoModelExperiment.h" +#include "GeoModelFaserUtilities/DecodeFaserVersionKey.h" +#include "StoreGate/DataHandle.h" +#include "RDBAccessSvc/IRDBRecord.h" +#include "RDBAccessSvc/IRDBRecordset.h" + +#include "AthenaKernel/ClassID_traits.h" +#include "SGTools/DataProxy.h" + +using ScintDD::PreshowerDetectorManager; +using ScintDD::ScintDetectorManager; + +// +// Constructor +// +PreshowerDetectorTool::PreshowerDetectorTool(const std::string& type, + const std::string& name, + const IInterface* parent) + : GeoModelTool(type, name, parent), + m_cosmic{false}, + m_manager{nullptr}, + m_athenaComps{ }, + m_geoDbTagSvc{"GeoDbTagSvc", name}, + m_rdbAccessSvc{"RDBAccessSvc", name}, + m_geometryDBSvc{"ScintGeometryDBSvc", name} +{ + // Get parameter values from jobOptions file + declareProperty("GeoDbTagSvc", m_geoDbTagSvc); + declareProperty("RDBAccessSvc", m_rdbAccessSvc); + declareProperty("GeometryDBSvc", m_geometryDBSvc); +} + +// +// Create the Geometry via the factory corresponding to this tool +// + +StatusCode +PreshowerDetectorTool::create() +{ + // Get the detector configuration. + ATH_CHECK(m_geoDbTagSvc.retrieve()); + + DecodeFaserVersionKey versionKey{&*m_geoDbTagSvc, "Preshower"}; + // Issue error if AUTO. + if (versionKey.tag() == "AUTO") { + ATH_MSG_ERROR("AUTO Faser version. Please select a version."); + } + ATH_MSG_INFO("Building Preshower with Version Tag: " << versionKey.tag() << " at Node: " << versionKey.node()); + + ATH_CHECK(m_rdbAccessSvc.retrieve()); + // Print the Preshower version tag: + std::string preshowerVersionTag{m_rdbAccessSvc->getChildTag("Preshower", versionKey.tag(), versionKey.node(), "FASERDD")}; + ATH_MSG_INFO("Preshower Version: " << preshowerVersionTag << " Package Version: " << PACKAGE_VERSION); + // Check if version is empty. If so, then the Preshower cannot be built. This may or may not be intentional. We + // just issue an INFO message. + if (preshowerVersionTag.empty()) { + ATH_MSG_INFO("No Preshower Version. Preshower will not be built."); + } else { + std::string versionName; + if (versionKey.custom()) { + ATH_MSG_WARNING("PreshowerDetectorTool: Detector Information coming from a custom configuration!!"); + } else { + ATH_MSG_DEBUG("PreshowerDetectorTool: Detector Information coming from the database and job options IGNORED."); + ATH_MSG_DEBUG("Keys for Preshower Switches are " << versionKey.tag() << " " << versionKey.node()); + + IRDBRecordset_ptr switchSet{m_rdbAccessSvc->getRecordsetPtr("PreshowerSwitches", versionKey.tag(), versionKey.node(), "FASERDD")}; + const IRDBRecord* switches{(*switchSet)[0]}; + m_detectorName.setValue(switches->getString("DETECTORNAME")); + + if (not switches->isFieldNull("COSMICLAYOUT")) + { + m_cosmic = switches->getInt("COSMICLAYOUT"); + } + if (not switches->isFieldNull("VERSIONNAME")) + { + versionName = switches->getString("VERSIONNAME"); + } + } + + ATH_MSG_DEBUG("Creating the Preshower"); + ATH_MSG_DEBUG("Preshower Geometry Options: "); + ATH_MSG_DEBUG(" Alignable: " << (m_alignable.value() ? "true" : "false")); + ATH_MSG_DEBUG(" CosmicLayout: " << (m_cosmic ? "true" : "false")); + ATH_MSG_DEBUG(" VersionName: " << versionName); + + PreshowerOptions options; + options.setAlignable(m_alignable.value()); + options.setDynamicAlignFolders(m_useDynamicAlignFolders.value()); + m_manager = nullptr; + + // + // Locate the top level experiment node + // + GeoModelExperiment* theExpt{nullptr}; + ATH_CHECK(detStore()->retrieve(theExpt, "FASER")); + + // Retrieve the Geometry DB Interface + ATH_CHECK(m_geometryDBSvc.retrieve()); + + // Pass athena services to factory, etc + m_athenaComps.setDetStore(detStore().operator->()); + m_athenaComps.setGeoDbTagSvc(&*m_geoDbTagSvc); + m_athenaComps.setGeometryDBSvc(&*m_geometryDBSvc); + m_athenaComps.setRDBAccessSvc(&*m_rdbAccessSvc); + const PreshowerID* idHelper{nullptr}; + ATH_CHECK(detStore()->retrieve(idHelper, "PreshowerID")); + m_athenaComps.setIdHelper(idHelper); + idHelper->test_plate_packing(); + // + // This strange way of casting is to avoid an + // utterly brain damaged compiler warning. + // + GeoPhysVol* world{&*theExpt->getPhysVol()}; + if (world != nullptr) ATH_MSG_INFO("Retrieved World PhysVol"); + + PreshowerDetectorFactory thePreshower{&m_athenaComps, options}; + ATH_MSG_INFO("Created instance of detector factory"); + thePreshower.create(world); + ATH_MSG_INFO("Called create methon on factory"); + m_manager = thePreshower.getDetectorManager(); + ATH_MSG_INFO("Attempted to retrieve detector manager"); + + if (m_manager==nullptr) { + ATH_MSG_FATAL("PreshowerDetectorManager not created"); + return StatusCode::FAILURE; + } + + // Get the manager from the factory and store it in the detector store. + // m_detector is non constant so I can not set it to a const pointer. + // m_detector = theSCT.getDetectorManager(); + + ATH_MSG_DEBUG("Registering PreshowerDetectorManager. "); + ATH_CHECK(detStore()->record(m_manager, m_manager->getName())); + theExpt->addManager(m_manager); + + // Create a symLink to the ScintDetectorManager base class + const ScintDetectorManager* scintDetManager{m_manager}; + ATH_CHECK(detStore()->symLink(m_manager, scintDetManager)); + } + + return StatusCode::SUCCESS; +} + +StatusCode +PreshowerDetectorTool::clear() +{ + ATH_MSG_WARNING("Called untested PreshowerDetectorTool::clear()"); + SG::DataProxy* proxy{detStore()->proxy(ClassID_traits<PreshowerDetectorManager>::ID(), m_manager->getName())}; + if (proxy) { + proxy->reset(); + m_manager = nullptr; + } + return StatusCode::SUCCESS; +} + +StatusCode +PreshowerDetectorTool::registerCallback() +{ + StatusCode sc{StatusCode::FAILURE, true}; + if (m_alignable.value()) { + ATH_MSG_WARNING("Called untested PreshowerDetectorTool::registerCallback()"); + if (m_useDynamicAlignFolders.value()) { + + if (detStore()->contains<CondAttrListCollection>(m_run2L1Folder.value())) { + ATH_MSG_DEBUG("Registering callback on global Container with folder " << m_run2L1Folder.value()); + const DataHandle<CondAttrListCollection> calc; + ATH_CHECK(detStore()->regFcn(&IGeoModelTool::align, dynamic_cast<IGeoModelTool*>(this), calc, m_run2L1Folder.value())); + sc = StatusCode::SUCCESS; + } else { + ATH_MSG_WARNING("Unable to register callback on global Container with folder " << m_run2L1Folder.value()); + return StatusCode::FAILURE; + } + + if (detStore()->contains<CondAttrListCollection>(m_run2L2Folder.value())) { + ATH_MSG_DEBUG("Registering callback on global Container with folder " << m_run2L2Folder.value()); + const DataHandle<CondAttrListCollection> calc; + ATH_CHECK(detStore()->regFcn(&IGeoModelTool::align, dynamic_cast<IGeoModelTool*>(this), calc, m_run2L2Folder.value())); + sc = StatusCode::SUCCESS; + } else { + ATH_MSG_WARNING("Unable to register callback on global Container with folder " << m_run2L2Folder.value()); + return StatusCode::FAILURE; + } + + if (detStore()->contains<AlignableTransformContainer>(m_run2L3Folder.value())) { + ATH_MSG_DEBUG("Registering callback on AlignableTransformContainer with folder " << m_run2L3Folder.value()); + const DataHandle<AlignableTransformContainer> atc; + ATH_CHECK(detStore()->regFcn(&IGeoModelTool::align, dynamic_cast<IGeoModelTool*>(this), atc, m_run2L3Folder.value())); + sc = StatusCode::SUCCESS; + } else { + ATH_MSG_WARNING("Unable to register callback on AlignableTransformContainer with folder " << m_run2L3Folder.value()); + return StatusCode::FAILURE; + } + + } else { + + if (detStore()->contains<AlignableTransformContainer>(m_run1Folder.value())) { + ATH_MSG_DEBUG("Registering callback on AlignableTransformContainer with folder " << m_run1Folder.value()); + const DataHandle<AlignableTransformContainer> atc; + ATH_CHECK(detStore()->regFcn(&IGeoModelTool::align, dynamic_cast<IGeoModelTool*>(this), atc, m_run1Folder.value())); + sc = StatusCode::SUCCESS; + } else { + ATH_MSG_WARNING("Unable to register callback on AlignableTransformContainer with folder " + << m_run1Folder.value() << ", Alignment disabled (only if no Run2 scheme is loaded)!"); + return StatusCode::FAILURE; + } + } + } else { + ATH_MSG_INFO("Alignment disabled. No callback registered"); + // We return failure otherwise it will try and register + // a GeoModelSvc callback associated with this callback. + return StatusCode::FAILURE; + } + return sc; +} + +StatusCode +PreshowerDetectorTool::align(IOVSVC_CALLBACK_ARGS_P(I, keys)) +{ + ATH_MSG_WARNING("Called untested PreshowerDetectorTool::align()"); + void* i = &I; + void* k = &keys; + if (i == nullptr && k == nullptr) return StatusCode::SUCCESS; // suppress stupid warning + if (m_manager==nullptr) { + ATH_MSG_FATAL("Manager does not exist"); + return StatusCode::FAILURE; + } + if (m_alignable.value()) { + return m_manager->align(I, keys); + } else { + ATH_MSG_DEBUG("Alignment disabled. No alignments applied"); + return StatusCode::SUCCESS; + } +} diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerGeneralParameters.cxx b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerGeneralParameters.cxx new file mode 100644 index 0000000000000000000000000000000000000000..0dab603eb363d1c35e5092f1e5da95a4141e75e4 --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerGeneralParameters.cxx @@ -0,0 +1,88 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "PreshowerGeneralParameters.h" +#include "PreshowerDataBase.h" +#include "RDBAccessSvc/IRDBRecord.h" +#include "RDBAccessSvc/IRDBRecordset.h" +#include "GaudiKernel/SystemOfUnits.h" +#include "GeoModelKernel/GeoDefinitions.h" +#include "ScintGeoModelUtils/TopLevelPlacements.h" + +const double PreshowerSAFETY = 0.01 * Gaudi::Units::mm; // Used in some places to make envelopes slightly larger to ensure + // no overlaps due to rounding errors. + + +PreshowerGeneralParameters::PreshowerGeneralParameters(PreshowerDataBase* rdb) +{ + m_rdb = rdb; + m_placements = new TopLevelPlacements(m_rdb->topLevelTable()); +} + + +PreshowerGeneralParameters::~PreshowerGeneralParameters() +{ + delete m_placements; +} + + +const GeoTrf::Transform3D & +PreshowerGeneralParameters::partTransform(const std::string & partName) const +{ + return m_placements->transform(partName); +} + + +bool +PreshowerGeneralParameters::partPresent(const std::string & partName) const +{ + return m_placements->present(partName); +} + + + +// +// General +// +double +PreshowerGeneralParameters::safety() const +{ + return PreshowerSAFETY; +} + +// Default Conditions. Values should be come form conditions data base. These values provide +// default vlaues if nothing from the conditions database is provided. + + +// double +// PreshowerGeneralParameters::temperature() const +// { +// if (m_rdb->conditionsTable()->size() == 0) { +// return 266.15 * Gaudi::Units::kelvin; // -7 C +// } +// return (m_rdb->conditions()->getDouble("TEMPERATURE") + 273.15) * Gaudi::Units::kelvin; +// } + + +// double +// SCT_GeneralParameters::biasVoltage() const +// { +// if (m_rdb->conditionsTable()->size() == 0) { +// return 100 * Gaudi::Units::volt; +// } +// return m_rdb->conditions()->getDouble("BIASVOLT") * Gaudi::Units::volt; +// } + +// double +// SCT_GeneralParameters::depletionVoltage() const +// { +// if (m_rdb->conditionsTable()->size() == 0) { +// return 20 * Gaudi::Units::volt; +// } +// return m_rdb->conditions()->getDouble("DEPLETIONVOLT") * Gaudi::Units::volt; +// } + + + + diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerGeneralParameters.h b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerGeneralParameters.h new file mode 100644 index 0000000000000000000000000000000000000000..66c42262d7b6854678f96c8e0a3041351305deaf --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerGeneralParameters.h @@ -0,0 +1,45 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PreshowerGeoModel_PreshowerGeneralParameters_H +#define PreshowerGeoModel_PreshowerGeneralParameters_H + +#include "GeoModelKernel/GeoDefinitions.h" + +#include <map> +#include <string> + +class PreshowerDataBase; +class TopLevelPlacements; + +class PreshowerGeneralParameters { + +public: + + PreshowerGeneralParameters(PreshowerDataBase* rdb); + ~PreshowerGeneralParameters(); + //Explicitly disallow copy, assignment to appease coverity + PreshowerGeneralParameters(const PreshowerGeneralParameters &) = delete; + PreshowerGeneralParameters & operator=(const PreshowerGeneralParameters &) = delete; + + // General + double safety() const; + + //Default conditions. +// double temperature() const; +// double biasVoltage() const; +// double depletionVoltage() const; + + const GeoTrf::Transform3D & partTransform(const std::string & partName) const; + bool partPresent(const std::string & partName) const; + +private: + + PreshowerDataBase * m_rdb; + TopLevelPlacements * m_placements; + +}; + + +#endif // SCT_GeoModel_SCT_GeneralParameters_H diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerGeoModelAthenaComps.cxx b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerGeoModelAthenaComps.cxx new file mode 100644 index 0000000000000000000000000000000000000000..6230dac07a8a2248c461aa1d602434e031ecafd9 --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerGeoModelAthenaComps.cxx @@ -0,0 +1,23 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#include "PreshowerGeoModel/PreshowerGeoModelAthenaComps.h" + +PreshowerGeoModelAthenaComps::PreshowerGeoModelAthenaComps() + : ScintDD::AthenaComps("PreshowerGeoModel"), + m_idHelper(0) +{} + +void +PreshowerGeoModelAthenaComps::setIdHelper(const PreshowerID* idHelper) +{ + m_idHelper = idHelper; +} + +const PreshowerID* +PreshowerGeoModelAthenaComps::getIdHelper() const +{ + return m_idHelper; +} + diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerGeometryManager.cxx b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerGeometryManager.cxx new file mode 100644 index 0000000000000000000000000000000000000000..6be4e0d11075d22a7f89c8bbb2421c47247ca47f --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerGeometryManager.cxx @@ -0,0 +1,112 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "PreshowerGeometryManager.h" + +#include "ScintGeoModelUtils/DistortedMaterialManager.h" +#include "ScintIdentifier/PreshowerID.h" +#include "ScintReadoutGeometry/ScintCommonItems.h" +#include "PreshowerStationParameters.h" +#include "PreshowerPlateParameters.h" +#include "PreshowerDataBase.h" +#include "PreshowerGeneralParameters.h" +#include "PreshowerGeoModel/PreshowerGeoModelAthenaComps.h" + +PreshowerGeometryManager::PreshowerGeometryManager(PreshowerDataBase* rdb) + : m_athenaComps{rdb->athenaComps()}, + m_rdb{rdb} +{ + // This class uses reference counting. Should not be delete'd in destructor. + m_commonItems = new ScintDD::ScintCommonItems(m_athenaComps->getIdHelper()); + + m_stationParameters = std::make_unique<PreshowerStationParameters>(m_rdb); + m_plateParameters = std::make_unique<PreshowerPlateParameters>(m_rdb); + m_generalParameters = std::make_unique<PreshowerGeneralParameters>(m_rdb); + m_distortedMatManager = std::make_unique<ScintDD::DistortedMaterialManager>(); +} + +PreshowerGeometryManager::~PreshowerGeometryManager() +{ +} + +// +// Access to run time options. +// +const PreshowerOptions & +PreshowerGeometryManager::options() const +{ + return m_options; +} + +void +PreshowerGeometryManager::setOptions(const PreshowerOptions & options) +{ + m_options = options; +} + +const PreshowerGeoModelAthenaComps * +PreshowerGeometryManager::athenaComps() const +{ + return m_athenaComps; +} + +// +// ScintCommonItems which are passed to ScintDetectorElements. +// + +const ScintDD::ScintCommonItems * +PreshowerGeometryManager::commonItems() const +{ + return m_commonItems; +} + +const PreshowerStationParameters * +PreshowerGeometryManager::stationParameters() const +{ + return m_stationParameters.get(); +} + +const PreshowerPlateParameters * +PreshowerGeometryManager::plateParameters() const +{ + return m_plateParameters.get(); +} + +const PreshowerGeneralParameters * +PreshowerGeometryManager::generalParameters() const +{ + return m_generalParameters.get(); +} + +const ScintDD::DistortedMaterialManager * +PreshowerGeometryManager::distortedMatManager() const +{ + return m_distortedMatManager.get(); +} + +PreshowerGeometryManager& +PreshowerGeometryManager::operator=(const PreshowerGeometryManager& right) { + if (this != &right) { + m_options = right.m_options; + m_athenaComps = right.m_athenaComps; + m_commonItems = right.m_commonItems; + m_rdb = right.m_rdb; + m_stationParameters.reset(new PreshowerStationParameters(m_rdb)); + m_plateParameters.reset(new PreshowerPlateParameters(m_rdb)); + m_generalParameters.reset(new PreshowerGeneralParameters(m_rdb)); + m_distortedMatManager.reset(new ScintDD::DistortedMaterialManager()); + } + return *this; +} + +PreshowerGeometryManager::PreshowerGeometryManager(const PreshowerGeometryManager& right) { + m_options = right.m_options; + m_athenaComps = right.m_athenaComps; + m_commonItems = right.m_commonItems; + m_rdb = right.m_rdb; + m_stationParameters.reset(new PreshowerStationParameters(m_rdb)); + m_plateParameters.reset(new PreshowerPlateParameters(m_rdb)); + m_generalParameters.reset(new PreshowerGeneralParameters(m_rdb)); + m_distortedMatManager.reset(new ScintDD::DistortedMaterialManager()); +} diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerGeometryManager.h b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerGeometryManager.h new file mode 100644 index 0000000000000000000000000000000000000000..4f8336cdda68af6ac37c8d09f2c39f718d751b7f --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerGeometryManager.h @@ -0,0 +1,66 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PreshowerGeoModel_PreshowerGeometryManager_H +#define PreshowerGeoModel_PreshowerGeometryManager_H + +#include "PreshowerOptions.h" + +#include <memory> + +namespace ScintDD { + class ScintCommonItems; + class DistortedMaterialManager; +} + +class PreshowerStationParameters; +class PreshowerPlateParameters; +class PreshowerDataBase; +class PreshowerGeneralParameters; +class PreshowerGeoModelAthenaComps; + +class PreshowerGeometryManager { + +public: + + // Constructor + PreshowerGeometryManager(PreshowerDataBase* rdb); + + // Destructor + ~PreshowerGeometryManager(); + + // Access to run time options + const PreshowerOptions & options() const; + void setOptions(const PreshowerOptions & options); + + // Access to athena components + const PreshowerGeoModelAthenaComps * athenaComps() const; + + // To be passed to detector element. + const ScintDD::ScintCommonItems * commonItems() const; + + const PreshowerStationParameters* stationParameters() const; + const PreshowerPlateParameters* plateParameters() const; + const PreshowerGeneralParameters* generalParameters() const; + const ScintDD::DistortedMaterialManager* distortedMatManager() const; + + PreshowerGeometryManager& operator=(const PreshowerGeometryManager& right); + PreshowerGeometryManager(const PreshowerGeometryManager& right); + +private: + + PreshowerOptions m_options; + const PreshowerGeoModelAthenaComps * m_athenaComps; + ScintDD::ScintCommonItems * m_commonItems; + PreshowerDataBase* m_rdb; + + std::unique_ptr<PreshowerStationParameters> m_stationParameters; + std::unique_ptr<PreshowerPlateParameters> m_plateParameters; + std::unique_ptr<PreshowerGeneralParameters> m_generalParameters; + std::unique_ptr<ScintDD::DistortedMaterialManager> m_distortedMatManager; + +}; + + +#endif // PreshowerGeoModel_PreshowerGeometryManager_H diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerIdentifier.cxx b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerIdentifier.cxx new file mode 100644 index 0000000000000000000000000000000000000000..a715ffb1a791ba74193c4ad90172ac1e8504ce34 --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerIdentifier.cxx @@ -0,0 +1,23 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "PreshowerIdentifier.h" +#include "ScintIdentifier/PreshowerID.h" +#include "Identifier/Identifier.h" + +#include <cassert> +#include <iostream> + +Identifier +PreshowerIdentifier::getPlateId() +{ + assert (m_idHelper); + return m_idHelper->plate_id(m_station, m_plate); +} + +void PreshowerIdentifier::print() +{ + std::cout << "2/3/" << m_station << "/" + << m_plate << std::endl; +} diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerIdentifier.h b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerIdentifier.h new file mode 100644 index 0000000000000000000000000000000000000000..854e63deddaace8342137ff4eeaff527653c9654 --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerIdentifier.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PRESHOWERGEOMODEL_PRESHOWERIDENTIFIER_H +#define PRESHOWERGEOMODEL_PRESHOWERIDENTIFIER_H + +class Identifier; +class PreshowerID; + +class PreshowerIdentifier +{ +public: + + PreshowerIdentifier( const PreshowerID* idHelper, + int station = 0, + int plate = 0 ) + : m_idHelper{idHelper}, + m_station{station}, + m_plate{plate} + {}; + + + void setStation(int i) {m_station = i;} + int getStation() const {return m_station;} + + void setPlate(int i) {m_plate = i;} + int getPlate() const {return m_plate;} + + Identifier getPlateId(); + + // For debugging purposes. + void print(); + +private: + const PreshowerID* m_idHelper; + int m_station; + int m_plate; +}; + +#endif // PRESHOWERGEOMODEL_PRESHOWERIDENTIFIER_H diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerMaterialManager.cxx b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerMaterialManager.cxx new file mode 100644 index 0000000000000000000000000000000000000000..c657a3ed7f8d5f0ede602b34deeb8738c22905c2 --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerMaterialManager.cxx @@ -0,0 +1,83 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "PreshowerMaterialManager.h" +#include "GeoModelKernel/GeoMaterial.h" +#include "GeoModelKernel/GeoElement.h" +#include "PreshowerDataBase.h" +#include "RDBAccessSvc/IRDBRecordset.h" +#include "StoreGate/StoreGateSvc.h" +#include "GaudiKernel/Bootstrap.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/SystemOfUnits.h" + +#include <iostream> + +// Constructor +PreshowerMaterialManager::PreshowerMaterialManager(PreshowerDataBase* db) +{ + // Get my material manager. + ISvcLocator* svcLocator = Gaudi::svcLocator(); // from Bootstrap + StoreGateSvc* detStore; + StatusCode sc = svcLocator->service("DetectorStore", detStore ); + if (sc.isFailure()) { + std::cout << "Could not locate DetectorStore" << std::endl; + return; + } + + m_materialManager = std::make_unique<ScintMaterialManager>("PreshowerMaterialManager", db->athenaComps()); + m_materialManager->addWeightTable(db->weightTable(), "preshower"); + m_materialManager->addScalingTable(db->scalingTable()); + + loadMaterials(); + + m_gasMaterial = m_materialManager->getMaterial("std::Air"); +} + +// Add materials not yet in the database +void +PreshowerMaterialManager::loadMaterials() +{ +} + +const GeoElement* +PreshowerMaterialManager::getElement(const std::string & elementName) const +{ + return m_materialManager->getElement(elementName); +} + +const GeoMaterial* +PreshowerMaterialManager::getMaterial(const std::string & materialName) const +{ + return m_materialManager->getMaterial(materialName); +} + +void +PreshowerMaterialManager::addMaterial(GeoMaterial* material) +{ + return m_materialManager->addMaterial(material); +} + +const GeoMaterial* +PreshowerMaterialManager::getMaterial(const std::string & originalMaterial, + double density, + const std::string & newName) +{ + + return m_materialManager->getMaterial(originalMaterial, density, newName); +} + +const GeoMaterial * +PreshowerMaterialManager::getMaterialForVolume(const std::string & materialName, double volume) +{ + return m_materialManager->getMaterialForVolume(materialName, volume); +} + + + +const GeoMaterial* +PreshowerMaterialManager::gasMaterial() const +{ + return m_gasMaterial; +} diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerMaterialManager.h b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerMaterialManager.h new file mode 100644 index 0000000000000000000000000000000000000000..95bfba95e878850044cae1093aff7ee28a8e2200 --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerMaterialManager.h @@ -0,0 +1,48 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PRESHOWERMATERIALMANAGER_H +#define PRESHOWERMATERIALMANAGER_H + +// PreshowerMaterialManager. This provides an interface to the ScintMaterialManager which in turn +// is an interface to GeoModel Material Manager with some additional functionality. +#include "ScintGeoModelUtils/ScintMaterialManager.h" + +#include <memory> +#include <string> + +class GeoMaterial; +class GeoElement; +class ScintMaterialManager; +class PreshowerDataBase; + +class PreshowerMaterialManager +{ + +public: + + PreshowerMaterialManager(PreshowerDataBase* db); + + const GeoMaterial* getMaterial(const std::string & materialName) const; + const GeoElement* getElement(const std::string & elementName) const; + + const GeoMaterial* getMaterial(const std::string & originalMaterial, + double density, + const std::string & newName = ""); + const GeoMaterial *getMaterialForVolume(const std::string & materialName, double volume); + + // Default gas material + const GeoMaterial* gasMaterial() const; + +private: + void loadMaterials(); + void addMaterial(GeoMaterial* material); + + std::unique_ptr<ScintMaterialManager> m_materialManager; + const GeoMaterial* m_gasMaterial; + +}; + + +#endif // PRESHOWERMATERIALMANAGER_H diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerOptions.cxx b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerOptions.cxx new file mode 100644 index 0000000000000000000000000000000000000000..39ed5a21c571263c2ab075ca990722aa626980bf --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerOptions.cxx @@ -0,0 +1,47 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "PreshowerOptions.h" + +PreshowerOptions::PreshowerOptions() + : m_alignable(true) +// , m_alignModule(true) + , m_dynAlignFolders(false) +{} + +void +PreshowerOptions::setAlignable(bool flag) +{ + m_alignable = flag; +} + +bool +PreshowerOptions::alignable() const +{ + return m_alignable; +} + +// following may eventually become useful +// +// void +// SCT_Options::setAlignAtModuleLevel(bool flag) +// { +// m_alignModule = flag; +// } + +// bool +// SCT_Options::alignAtModuleLevel() const +// { +// return m_alignModule; +// } + +void PreshowerOptions::setDynamicAlignFolders(const bool flag) +{ + m_dynAlignFolders = flag; +} + +bool PreshowerOptions::dynamicAlignFolders() const +{ + return m_dynAlignFolders; +} diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerOptions.h b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerOptions.h new file mode 100644 index 0000000000000000000000000000000000000000..c80af7e29253ec53f7e9185d9d0b072914da7482 --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerOptions.h @@ -0,0 +1,35 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PreshowerGeoModel_PreshowerOptions_H +#define PreshowerGeoModel_PreshowerOptions_H + +// Class for any run time options. + + +class PreshowerOptions +{ + +public: + PreshowerOptions(); + bool alignable() const; +// bool alignAtModuleLevel() const; + + void setAlignable(bool flag = true); +// void setAlignAtModuleLevel(bool flag = true); + + //dynamic alignment folders + void setDynamicAlignFolders(const bool flag = true); + bool dynamicAlignFolders() const; + +private: + + bool m_alignable; +// bool m_alignModule; + bool m_dynAlignFolders; //controls which set of alignment folders is used + +}; + + +#endif // PreshowerGeoModel_PreshowerOptions_H diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerPlate.cxx b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerPlate.cxx new file mode 100644 index 0000000000000000000000000000000000000000..fad434d52da19d73695a592c951d75d0cc562941 --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerPlate.cxx @@ -0,0 +1,117 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "PreshowerPlate.h" + +#include "PreshowerGeometryManager.h" +#include "PreshowerMaterialManager.h" + +#include "PreshowerPlateParameters.h" + +#include "GeoModelKernel/GeoBox.h" +#include "GeoModelKernel/GeoLogVol.h" +#include "GeoModelKernel/GeoFullPhysVol.h" +#include "GeoModelKernel/GeoMaterial.h" + +#include "ScintReadoutGeometry/PreshowerDetectorManager.h" +#include "ScintReadoutGeometry/ScintDetectorDesign.h" +#include "ScintReadoutGeometry/ScintDetectorElement.h" +#include "ScintReadoutGeometry/ScintDD_Defs.h" +#include "ScintReadoutGeometry/ScintCommonItems.h" + +#include "GaudiKernel/SystemOfUnits.h" + +using namespace ScintDD; + +PreshowerPlate::PreshowerPlate(const std::string & name, + ScintDD::PreshowerDetectorManager* detectorManager, + const PreshowerGeometryManager* geometryManager, + PreshowerMaterialManager* materials) + : PreshowerUniqueComponentFactory(name, detectorManager, geometryManager, materials), + m_noElementWarning{true} +{ + getParameters(); + m_logVolume = preBuild(); +} + + +void +PreshowerPlate::getParameters() +{ + + const PreshowerPlateParameters * parameters = m_geometryManager->plateParameters(); + m_material = m_materials->getMaterial(parameters->plateMaterial()); + m_thickness = parameters->plateThickness(); + m_length = parameters->plateLength(); + m_width = parameters->plateWidth(); + m_detectorManager->numerology().setNumPmtsPerPlate(parameters->platePmts()); +} + +const GeoLogVol * +PreshowerPlate::preBuild() +{ + + // Build the plate. Just a simple box. + // const GeoBox * plateShape = new GeoBox(0.5*m_thickness, 0.5*m_width, 0.5*m_length); + const GeoBox * plateShape = new GeoBox(0.5*m_width, 0.5*m_length, 0.5*m_thickness); + GeoLogVol * plateLog = new GeoLogVol(getName(), plateShape, m_material); + + // Make the scint design for this plate + makeDesign(); + + m_detectorManager->setDesign(m_design); + + return plateLog; +} + + +void +PreshowerPlate::makeDesign() +{ + //SiDetectorDesign::Axis etaAxis = SiDetectorDesign::zAxis; + //SiDetectorDesign::Axis phiAxis = SiDetectorDesign::yAxis; + //SiDetectorDesign::Axis depthAxis = SiDetectorDesign::xAxis; + + const PreshowerPlateParameters * parameters = m_geometryManager->plateParameters(); + + m_design = new ScintDetectorDesign(m_thickness, + m_length, + m_width, + parameters->platePmts()); +} + + + +GeoVPhysVol * +PreshowerPlate::build(PreshowerIdentifier id) +{ + GeoFullPhysVol * plate = new GeoFullPhysVol(m_logVolume); + + // Make detector element and add to collection + // Only do so if we have a valid id helper. + + //id.print(); // for debugging only + + const ScintCommonItems* commonItems = m_geometryManager->commonItems(); + + if (commonItems->getIdHelper()) { + + ScintDetectorElement * detElement; + + detElement = new ScintDetectorElement(id.getPlateId(), + m_design, + plate, + commonItems); + + // Add the detector element. + m_detectorManager->addDetectorElement(detElement); + + } else { + if (m_noElementWarning) { + std::cout << "WARNING!!!!: No Preshower id helper and so no elements being produced." << std::endl; + m_noElementWarning = false; + } + } + return plate; +} diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerPlate.h b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerPlate.h new file mode 100644 index 0000000000000000000000000000000000000000..9307dc1cbd72e0e5205c2b8924b1eaf598f62085 --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerPlate.h @@ -0,0 +1,48 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PRESHOWERGEOMODEL_PRESHOWERPLATE_H +#define PRESHOWERGEOMODEL_PRESHOWERPLATE_H + +#include "PreshowerComponentFactory.h" + +#include <atomic> +#include <string> + +class GeoMaterial; +class GeoVPhysVol; +namespace ScintDD{class ScintDetectorDesign;} + +class PreshowerPlate: public PreshowerUniqueComponentFactory +{ +public: + PreshowerPlate(const std::string & name, + ScintDD::PreshowerDetectorManager* detectorManager, + const PreshowerGeometryManager* geometryManager, + PreshowerMaterialManager* materials); + +public: + const GeoMaterial * material() const {return m_material;} + double thickness() const {return m_thickness;} + double width() const {return m_width;} + double length() const {return m_length;} + + virtual GeoVPhysVol * build(PreshowerIdentifier id); + +private: + void getParameters(); + virtual const GeoLogVol * preBuild(); + void makeDesign(); + + const GeoMaterial * m_material; + double m_thickness; + double m_width; + double m_length; + + ScintDD::ScintDetectorDesign * m_design; + + mutable std::atomic_bool m_noElementWarning; +}; + +#endif // PRESHOWERGEOMODEL_PRESHOWERPLATE_H diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerPlateParameters.cxx b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerPlateParameters.cxx new file mode 100644 index 0000000000000000000000000000000000000000..0e8030a6ef27c4fcbff17b2cd987bac28f38a8ed --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerPlateParameters.cxx @@ -0,0 +1,52 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "PreshowerPlateParameters.h" +#include "PreshowerGeometryManager.h" + +#include "PreshowerDataBase.h" + +#include "RDBAccessSvc/IRDBRecord.h" +#include "GaudiKernel/SystemOfUnits.h" + +#include <cmath> + + +PreshowerPlateParameters::PreshowerPlateParameters(PreshowerDataBase* rdb) +{ + m_rdb = rdb; +} + +// +// Plate General +// +int +PreshowerPlateParameters::platePmts() const +{ + return m_rdb->plateGeneral()->getInt("NUMPMTS"); +} + +double +PreshowerPlateParameters::plateWidth() const +{ + return m_rdb->plateGeneral()->getDouble("WIDTH") * Gaudi::Units::mm; +} + +double +PreshowerPlateParameters::plateLength() const +{ + return m_rdb->plateGeneral()->getDouble("LENGTH") * Gaudi::Units::mm; +} + +double +PreshowerPlateParameters::plateThickness() const +{ + return m_rdb->plateGeneral()->getDouble("THICKNESS") * Gaudi::Units::mm; +} + +std::string PreshowerPlateParameters::plateMaterial() const +{ + return m_rdb->plateGeneral()->getString("MATERIAL"); +} + diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerPlateParameters.h b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerPlateParameters.h new file mode 100644 index 0000000000000000000000000000000000000000..3dac0667e785e05901a7cf0568d8e9bbd6cb2205 --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerPlateParameters.h @@ -0,0 +1,32 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PreshowerGeoModel_PreshowerPlateParameters_H +#define PreshowerGeoModel_PreshowerPlateParameters_H + +#include <string> + +class PreshowerDataBase; + +class PreshowerPlateParameters { + +public: + + // Constructor + PreshowerPlateParameters(PreshowerDataBase* rdb); + + // Barrel General + int platePmts() const; + double plateThickness() const; + double plateWidth() const; + double plateLength() const; + std::string plateMaterial() const; + + private: + PreshowerDataBase * m_rdb; + +}; + + +#endif // PreshowerGeoModel_PreshowerPlateParameters_H diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerStation.cxx b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerStation.cxx new file mode 100644 index 0000000000000000000000000000000000000000..b6cd78cbc839ebe2ac29e22f7a9dcbd83512aae7 --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerStation.cxx @@ -0,0 +1,100 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "PreshowerStation.h" + +#include "PreshowerMaterialManager.h" + +#include "PreshowerGeometryManager.h" +#include "PreshowerStationParameters.h" +#include "PreshowerGeneralParameters.h" +#include "PreshowerIdentifier.h" +#include "PreshowerPlate.h" + +#include "ScintReadoutGeometry/PreshowerDetectorManager.h" + +#include "ScintGeoModelUtils/ExtraMaterial.h" + +#include "GeoModelKernel/GeoBox.h" +#include "GeoModelKernel/GeoLogVol.h" +#include "GeoModelKernel/GeoFullPhysVol.h" +#include "GeoModelKernel/GeoPhysVol.h" +#include "GeoModelKernel/GeoNameTag.h" +#include "GeoModelKernel/GeoIdentifierTag.h" +#include "GeoModelKernel/GeoTransform.h" +#include "GeoModelKernel/GeoAlignableTransform.h" +#include "GeoModelKernel/GeoMaterial.h" +#include "GeoModelKernel/GeoShape.h" +#include "GeoModelKernel/GeoShapeShift.h" +#include "GaudiKernel/SystemOfUnits.h" + +#include <iostream> + +PreshowerStation::PreshowerStation(const std::string & name, + PreshowerPlate* plate, + ScintDD::PreshowerDetectorManager* detectorManager, + const PreshowerGeometryManager* geometryManager, + PreshowerMaterialManager* materials) + : PreshowerUniqueComponentFactory(name, detectorManager, geometryManager, materials), + m_plate { plate } +{ + getParameters(); + m_logVolume = preBuild(); +} + + +void +PreshowerStation::getParameters() +{ + const PreshowerStationParameters * parameters = m_geometryManager->stationParameters(); + + m_numPlates = parameters->numPlates(); + m_platePitch = parameters->platePitch(); + + const PreshowerGeneralParameters* generalParameters = m_geometryManager->generalParameters(); + m_safety = generalParameters->safety(); + + m_width = m_plate->width() + m_safety; + m_length = m_plate->length() + m_safety; + // pitch includes thickness of one plate + m_thickness = (m_numPlates - 1) * m_platePitch + m_plate->thickness() + m_safety; + + // Set numerology + m_detectorManager->numerology().setNumPlatesPerStation(m_numPlates); +} + +const GeoLogVol * +PreshowerStation::preBuild() +{ + // Create the station volume + // Box envelope containing the station. + const GeoBox* stationEnvelopeShape = new GeoBox(0.5 * m_width, 0.5 * m_length, 0.5 * m_thickness); + GeoLogVol* stationLog = new GeoLogVol(getName(), stationEnvelopeShape, m_materials->gasMaterial()); + return stationLog; +} + +GeoVPhysVol * +PreshowerStation::build(PreshowerIdentifier id) +{ + + GeoFullPhysVol * station = new GeoFullPhysVol(m_logVolume); + + double activeDepth = m_thickness - m_safety/2; + double plateThickness = m_plate->thickness(); + for (int iPlate = 0; iPlate < m_numPlates; iPlate++) + { + station->add(new GeoNameTag("Plate#"+intToString(iPlate))); + station->add(new GeoIdentifierTag(iPlate)); + id.setPlate(iPlate); + GeoAlignableTransform* transform = new GeoAlignableTransform(GeoTrf::Translate3D(0.0, + 0.0, + (plateThickness - activeDepth)/2 + iPlate * m_platePitch)); + station->add(transform); + GeoVPhysVol* platePV = m_plate->build(id); + station->add(platePV); + m_detectorManager->addAlignableTransform(0, id.getPlateId(), transform, platePV); + } + return station; +} + diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerStation.h b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerStation.h new file mode 100644 index 0000000000000000000000000000000000000000..fb4d6f588699db07cb0212bb850d59b1062bee21 --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerStation.h @@ -0,0 +1,50 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PRESHOWERGEOMODEL_PRESHOWERSTATION_H +#define PRESHOWERGEOMODEL_PRESHOWERSTATION_H + +#include "PreshowerComponentFactory.h" + +class GeoVPhysVol; +class GeoFullPhysVol; +class GeoLogVol; +class PreshowerIdentifier; +class PreshowerPlate; + +class PreshowerStation : public PreshowerUniqueComponentFactory +{ + +public: + PreshowerStation(const std::string & name, + PreshowerPlate* plate, + ScintDD::PreshowerDetectorManager* detectorManager, + const PreshowerGeometryManager* geometryManager, + PreshowerMaterialManager* materials); + virtual GeoVPhysVol * build(PreshowerIdentifier id); + +public: + int numPlates() const {return m_numPlates;} + double platePitch() const {return m_platePitch;} + double thickness() const {return m_thickness;} + double width() const {return m_width;} + double length() const {return m_length;} + +private: + void getParameters(); + virtual const GeoLogVol * preBuild(); + + PreshowerPlate* m_plate; + + int m_numPlates; + double m_platePitch; + + double m_thickness; + double m_width; + double m_length; + + double m_safety; +}; + +#endif // PRESHOWERGEOMODEL_PRESHOWERSTATION_H diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerStationParameters.cxx b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerStationParameters.cxx new file mode 100644 index 0000000000000000000000000000000000000000..80934e298fc9f189b8e634d5cc115e231c52099a --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerStationParameters.cxx @@ -0,0 +1,35 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "PreshowerStationParameters.h" +#include "PreshowerGeometryManager.h" + +#include "PreshowerDataBase.h" + +#include "RDBAccessSvc/IRDBRecord.h" +#include "GaudiKernel/SystemOfUnits.h" + +#include <cmath> + + +PreshowerStationParameters::PreshowerStationParameters(PreshowerDataBase* rdb) +{ + m_rdb = rdb; +} + +// +// General +// +int +PreshowerStationParameters::numPlates() const +{ + return m_rdb->stationGeneral()->getInt("NUMPLATES"); +} + +double +PreshowerStationParameters::platePitch() const +{ + return m_rdb->stationGeneral()->getDouble("PLATEPITCH"); +} + diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerStationParameters.h b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerStationParameters.h new file mode 100644 index 0000000000000000000000000000000000000000..d47e36b2606384a31cb61d1dfcd46fb5d72b9bb6 --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/PreshowerStationParameters.h @@ -0,0 +1,30 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PreshowerGeoModel_PreshowerStationParameters_H +#define PreshowerGeoModel_PreshowerStationParameters_H + +#include <string> + +class PreshowerDataBase; + +class PreshowerStationParameters { + +public: + + // Constructor + PreshowerStationParameters(PreshowerDataBase* rdb); + + + // General + int numPlates() const; + double platePitch() const; + + private: + PreshowerDataBase * m_rdb; + +}; + + +#endif // PreshowerGeoModel_PreshowerStationParameters_H diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/src/components/PreshowerGeoModel_entries.cxx b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/components/PreshowerGeoModel_entries.cxx new file mode 100644 index 0000000000000000000000000000000000000000..07e0ae1805c0644ca7c2b0326105e0c032afc325 --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/src/components/PreshowerGeoModel_entries.cxx @@ -0,0 +1,3 @@ +#include "PreshowerGeoModel/PreshowerDetectorTool.h" + +DECLARE_COMPONENT( PreshowerDetectorTool ) \ No newline at end of file diff --git a/Scintillator/ScintDetDescr/PreshowerGeoModel/test/PreshowerGMConfig_test.py b/Scintillator/ScintDetDescr/PreshowerGeoModel/test/PreshowerGMConfig_test.py new file mode 100644 index 0000000000000000000000000000000000000000..f25dc8fa2873cc7b4d6ea6f5c490c6e4248386e7 --- /dev/null +++ b/Scintillator/ScintDetDescr/PreshowerGeoModel/test/PreshowerGMConfig_test.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python +"""Run tests on VetoGeoModel configuration + +Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +""" +if __name__ == "__main__": + from AthenaCommon.Configurable import Configurable + Configurable.configurableRun3Behavior=1 + from CalypsoConfiguration.AllConfigFlags import ConfigFlags + from AthenaConfiguration.TestDefaults import defaultTestFiles + + ConfigFlags.Input.Files = defaultTestFiles.HITS + ConfigFlags.IOVDb.GlobalTag = "OFLCOND-XXXX-XXX-XX" + # ConfigFlags.Detector.SimulatePixel = False + ConfigFlags.Detector.SimulatePreshower = False + # ConfigFlags.Detector.SimulateTRT = False + ConfigFlags.GeoModel.Align.Dynamic = False + ConfigFlags.lock() + + from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator + from PreshowerGeoModel.PreshowerGeoModelConfig import PreshowerGeometryCfg + acc = PreshowerGeometryCfg(ConfigFlags) + f=open('PreshowerGeometryCfg.pkl','w') + acc.store(f) + f.close() diff --git a/Scintillator/ScintDetDescr/ScintIdDictFiles/data/IdDictScintillator.xml b/Scintillator/ScintDetDescr/ScintIdDictFiles/data/IdDictScintillator.xml index c2142072bac66070cbba81fb65f848b8e9cbc9d5..13d77e21372822bd19cbdb4c5b7ae3046d27693f 100644 --- a/Scintillator/ScintDetDescr/ScintIdDictFiles/data/IdDictScintillator.xml +++ b/Scintillator/ScintDetDescr/ScintIdDictFiles/data/IdDictScintillator.xml @@ -22,8 +22,8 @@ <region> <range field="part" value="Preshower" /> - <range field="station" minvalue="0" maxvalue="1" /> - <range field="plate" minvalue="0" maxvalue="0" /> + <range field="station" minvalue="0" maxvalue="0" /> + <range field="plate" minvalue="0" maxvalue="1" /> <range field="pmt" minvalue="0" maxvalue="0" /> </region> </IdDictionary> \ No newline at end of file diff --git a/Scintillator/ScintDetDescr/ScintIdentifier/CMakeLists.txt b/Scintillator/ScintDetDescr/ScintIdentifier/CMakeLists.txt index 660ea8422bc728b3b0bb12c687f6291a4516b1e5..58008a3bf3834644eef4274e338ac61eb4f6152a 100644 --- a/Scintillator/ScintDetDescr/ScintIdentifier/CMakeLists.txt +++ b/Scintillator/ScintDetDescr/ScintIdentifier/CMakeLists.txt @@ -21,8 +21,8 @@ find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread ) # Component(s) in the package: atlas_add_library( ScintIdentifier src/VetoID.cxx -# src/TriggerID.cxx -# src/PreshowerID.cxx + src/TriggerID.cxx + src/PreshowerID.cxx # src/ScintillatorID.cxx PUBLIC_HEADERS ScintIdentifier PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} diff --git a/Scintillator/ScintDetDescr/ScintIdentifier/ScintIdentifier/PreshowerID.h b/Scintillator/ScintDetDescr/ScintIdentifier/ScintIdentifier/PreshowerID.h new file mode 100644 index 0000000000000000000000000000000000000000..3277fde825a086a4053d4769a38d566d620257a7 --- /dev/null +++ b/Scintillator/ScintDetDescr/ScintIdentifier/ScintIdentifier/PreshowerID.h @@ -0,0 +1,541 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef SCINTIDENTIFIER_PRESHOWERID_H +#define SCINTIDENTIFIER_PRESHOWERID_H +/** + * @file PreshowerID.h + * + * @brief This is an Identifier helper class for the Preshower + * subdetector. This class is a factory for creating compact + * Identifier objects and IdentifierHash or hash ids. And it also + * allows decoding of these ids. + * + */ + +//<<<<<< INCLUDES >>>>>> + +#include "FaserDetDescr/FaserDetectorID.h" +#include "Identifier/Identifier.h" +#include "Identifier/IdentifierHash.h" +#include "Identifier/Range.h" +#include "Identifier/IdHelper.h" +#include "IdDict/IdDictFieldImplementation.h" +#include "AthenaKernel/CLASS_DEF.h" + +#include <string> +#include <assert.h> +#include <algorithm> + +//<<<<<< PUBLIC DEFINES >>>>>> +//<<<<<< PUBLIC CONSTANTS >>>>>> +//<<<<<< PUBLIC TYPES >>>>>> + +class IdDictDictionary; + +//<<<<<< PUBLIC VARIABLES >>>>>> +//<<<<<< PUBLIC FUNCTIONS >>>>>> +//<<<<<< CLASS DECLARATIONS >>>>>> + +/** + ** @class PreshowerID + ** + ** @brief This is an Identifier helper class for the Preshower + ** subdetector. This class is a factory for creating compact + ** Identifier objects and IdentifierHash or hash ids. And it also + ** allows decoding of these ids. + ** + ** Definition and the range of values for the levels of the + ** identifier are: + ** + ** @verbatim + ** element range meaning + ** ------- ----- ------- + ** + ** station 0 single longitudinal location + ** plate 0 to 1 two plates per station + ** pmt 0 single pmt per plate + ** + ** @endverbatim + ** + */ +class PreshowerID : public FaserDetectorID +{ +public: + + /// @name public typedefs + //@{ + typedef Identifier::size_type size_type; + typedef std::vector<Identifier>::const_iterator const_id_iterator; + typedef MultiRange::const_identifier_factory const_expanded_id_iterator; + //@} + + /// @name strutors + //@{ + PreshowerID(void); + virtual ~PreshowerID(void) = default; + //@} + + /// @name Creators for plate ids and pmt ids + //@{ + /// For a single station + Identifier station_id ( int station ) const; + Identifier station_id ( int station, + bool checks) const; + + /// For a station from a plate id + Identifier station_id ( const Identifier& plate_id ) const; + + /// For a single plate + Identifier plate_id ( int station, + int plate ) const; + Identifier plate_id ( int station, + int plate, + bool checks) const; + + /// For a single plate from a pmt id + Identifier plate_id ( const Identifier& pmt_id ) const; + + /// From hash - optimized + Identifier plate_id ( IdentifierHash plate_hash ) const; + + /// For an individual pmt + Identifier pmt_id ( int station, + int plate, + int pmt ) const; + + Identifier pmt_id ( int station, + int plate, + int pmt, + bool check ) const; + + Identifier pmt_id ( const Identifier& plate_id, + int pmt ) const; + + //@} + + + /// @name Hash table maximum sizes + //@{ + size_type plate_hash_max (void) const; + size_type pmt_hash_max (void) const; + //@} + + /// @name Access to all ids + //@{ + /// Iterators over full set of ids. Plate iterator is sorted + const_id_iterator plate_begin (void) const; + const_id_iterator plate_end (void) const; + /// For pmt ids, only expanded id iterators are available. Use + /// following "pmt_id" method to obtain a compact identifier + const_expanded_id_iterator pmt_begin (void) const; + const_expanded_id_iterator pmt_end (void) const; + //@} + + + /// @name Optimized accessors - ASSUMES id IS a preshower id, i.e. NOT other + //@{ + /// wafer hash from id - optimized + IdentifierHash plate_hash (Identifier plate_id) const; + + /// Values of different levels (failure returns 0) + int station (const Identifier& id) const; + int plate (const Identifier& id) const; + int pmt (const Identifier& id) const; + + /// Max/Min values for each field (-999 == failure) + int station_max (const Identifier& id) const; + int plate_max (const Identifier& id) const; + int pmt_max (const Identifier& id) const; + //@} + + /// @name module navigation + //@{ + /// Previous plate in z + int get_prev_in_z(const IdentifierHash& id, IdentifierHash& prev) const; + /// Next plate in z + int get_next_in_z(const IdentifierHash& id, IdentifierHash& next) const; + // /// Previous wafer hash in phi (return == 0 for neighbor found) + // int get_prev_in_phi (const IdentifierHash& id, IdentifierHash& prev) const; + // /// Next wafer hash in phi (return == 0 for neighbor found) + // int get_next_in_phi (const IdentifierHash& id, IdentifierHash& next) const; + // /// Previous wafer hash in eta (return == 0 for neighbor found) + // int get_prev_in_eta (const IdentifierHash& id, IdentifierHash& prev) const; + // /// Next wafer hash in eta (return == 0 for neighbor found) + // int get_next_in_eta (const IdentifierHash& id, IdentifierHash& next) const; + // /// Wafer hash on other side + // int get_other_side (const IdentifierHash& id, IdentifierHash& other) const; + + // // To check for when phi wrap around may be needed, use + // bool is_phi_module_max(const Identifier& id) const; + // /// For the barrel + // bool is_eta_module_min(const Identifier& id) const; + // /// For the barrel + // bool is_eta_module_max(const Identifier& id) const; + //@} + + /// @name contexts to distinguish plate id from pixel id + //@{ + IdContext plate_context (void) const; + IdContext pmt_context (void) const; + //@} + + /// @name methods from abstract interface - slower than opt version + //@{ + /// Create compact id from hash id (return == 0 for OK) + virtual int get_id (const IdentifierHash& hash_id, + Identifier& id, + const IdContext* context = 0) const; + + /// Create hash id from compact id (return == 0 for OK) + virtual int get_hash (const Identifier& id, + IdentifierHash& hash_id, + const IdContext* context = 0) const; + //@} + + /// Return the lowest bit position used in the channel id + int base_bit (void) const; + + /// Calculate a channel offset between the two identifiers. + Identifier::diff_type calc_offset(const Identifier& base, + const Identifier& target) const; + + /// Create an identifier with a given base and channel offset + Identifier pmt_id_offset(const Identifier& base, + Identifier::diff_type offset) const; + + /// @name interaction with id dictionary + //@{ + /// Create strip Identifier from expanded id, which is returned by the + /// id_iterators + Identifier pmt_id (const ExpandedIdentifier& pmt_id) const; + + /// Create expanded id from compact id (return == 0 for OK) + void get_expanded_id (const Identifier& id, + ExpandedIdentifier& exp_id, + const IdContext* context = 0) const; + + /// Initialization from the identifier dictionary + virtual int initialize_from_dictionary(const IdDictMgr& dict_mgr); + + /// Tests of packing + void test_plate_packing (void) const; + //@} + +private: + + enum {NOT_VALID_HASH = 64000}; + + typedef std::vector<Identifier> id_vec; + typedef id_vec::const_iterator id_vec_it; + typedef std::vector<unsigned short> hash_vec; + typedef hash_vec::const_iterator hash_vec_it; + + void plate_id_checks ( int station, + int plate ) const; + + void pmt_id_checks ( int station, + int plate, + int pmt ) const; + + + int initLevelsFromDict(void); + + int init_hashes(void); + + int init_neighbors(void); + + // Temporary method for adapting an identifier for the MultiRange + // check - MR is missing the InnerDetector level + // Identifier idForCheck (const Identifier& id) const; + + size_type m_preshower_region_index; + size_type m_SCINT_INDEX; + size_type m_PRESHOWER_INDEX; + size_type m_STATION_INDEX; + size_type m_PLATE_INDEX; + size_type m_PMT_INDEX; + + const IdDictDictionary* m_dict; + MultiRange m_full_plate_range; + MultiRange m_full_pmt_range; + size_type m_plate_hash_max; + size_type m_pmt_hash_max; + // Range::field m_barrel_field; + id_vec m_plate_vec; + hash_vec m_prev_z_plate_vec; + hash_vec m_next_z_plate_vec; + // hash_vec m_prev_phi_wafer_vec; + // hash_vec m_next_phi_wafer_vec; + // hash_vec m_prev_eta_wafer_vec; + // hash_vec m_next_eta_wafer_vec; + // bool m_hasRows ; + + IdDictFieldImplementation m_scint_impl ; + IdDictFieldImplementation m_preshower_impl ; + IdDictFieldImplementation m_station_impl ; + IdDictFieldImplementation m_plate_impl ; + IdDictFieldImplementation m_pmt_impl ; +}; + + +//<<<<<< INLINE PUBLIC FUNCTIONS >>>>>> + +///////////////////////////////////////////////////////////////////////////// +//<<<<<< INLINE MEMBER FUNCTIONS >>>>>> +///////////////////////////////////////////////////////////////////////////// + +//using the macros below we can assign an identifier (and a version) +//This is required and checked at compile time when you try to record/retrieve +CLASS_DEF(PreshowerID, 55179317, 1) + +//---------------------------------------------------------------------------- +inline Identifier +PreshowerID::station_id ( int station, + bool checks) const +{ + + // Build identifier + Identifier result((Identifier::value_type)0); + + // Pack fields independently + m_scint_impl.pack (scint_field_value(), result); + m_preshower_impl.pack (preshower_field_value(), result); + m_station_impl.pack (station, result); + // Do checks + if(checks) + { + plate_id_checks ( station, 0 ); + } + + return result; +} + +inline Identifier +PreshowerID::station_id ( int station ) const +{ + return station_id (station, do_checks()); +} + +//---------------------------------------------------------------------------- +inline Identifier +PreshowerID::station_id ( const Identifier& plate_id ) const +{ + Identifier result(plate_id); + // Reset the plate and pmt fields + m_plate_impl.reset(result); + m_pmt_impl.reset(result); + return (result); +} + +//---------------------------------------------------------------------------- +inline Identifier +PreshowerID::plate_id ( int station, + int plate, + bool checks) const +{ + // Build identifier + Identifier result((Identifier::value_type)0); + + // Pack fields independently + m_scint_impl.pack (scint_field_value(), result); + m_preshower_impl.pack (preshower_field_value(), result); + m_station_impl.pack (station, result); + m_plate_impl.pack (plate, result); + + // Do checks + if(checks) + { + plate_id_checks ( station, plate ); + } + return result; +} + +inline Identifier +PreshowerID::plate_id ( int station, + int plate ) const +{ + return plate_id (station, plate, do_checks()); +} + +//---------------------------------------------------------------------------- +inline Identifier +PreshowerID::plate_id ( const Identifier& pmt_id ) const +{ + Identifier result(pmt_id); + // reset the pmt field + m_pmt_impl.reset(result); + return (result); +} + +//---------------------------------------------------------------------------- +inline Identifier PreshowerID::plate_id ( IdentifierHash plate_hash ) const +{ + return (m_plate_vec[plate_hash]); +} + +//---------------------------------------------------------------------------- +inline IdentifierHash PreshowerID::plate_hash (Identifier plate_id) const +{ + // MsgStream log(m_msgSvc, "PreshowerID"); + // log << MSG::VERBOSE << "m_plate_vec size: " << m_plate_vec.size() << endmsg; + // log << MSG::VERBOSE << "input id = " << plate_id << endmsg; + // for (size_t i = 0; i < m_plate_vec.size(); i++) + // { + // log << MSG::VERBOSE << "Hash = " << i << " : ID = " << m_plate_vec[i] << endmsg; + // } + id_vec_it it = std::lower_bound(m_plate_vec.begin(), + m_plate_vec.end(), + plate_id); + // Require that plate_id matches the one in vector + if (it != m_plate_vec.end() && plate_id == (*it)) { + return (it - m_plate_vec.begin()); + } + IdentifierHash result; + return (result); // return hash in invalid state +} + +//---------------------------------------------------------------------------- +inline Identifier +PreshowerID::pmt_id ( int station, + int plate, + int pmt, + bool checks) const +{ + // Build identifier + Identifier result((Identifier::value_type)0); + + // Pack fields independently + m_scint_impl.pack (scint_field_value(), result); + m_preshower_impl.pack (preshower_field_value(), result); + m_station_impl.pack (station, result); + m_plate_impl.pack (plate, result); + m_pmt_impl.pack (pmt, result); + + // Do checks + if(checks) { + pmt_id_checks ( station, plate, pmt ); + } + return result; +} + +inline Identifier +PreshowerID::pmt_id ( int station, + int plate, + int pmt ) const +{ + return pmt_id (station, plate, pmt, do_checks()); +} + +//---------------------------------------------------------------------------- +inline Identifier +PreshowerID::pmt_id (const ExpandedIdentifier& id) const +{ + // Build identifier + Identifier result((Identifier::value_type)0); + + // Pack fields independently + m_scint_impl.pack (scint_field_value(), result); + m_preshower_impl.pack (preshower_field_value(), result); + m_station_impl.pack (id[m_STATION_INDEX], result); + m_plate_impl.pack (id[m_PLATE_INDEX], result); + m_pmt_impl.pack (id[m_PMT_INDEX], result); + + // Do checks + if(m_do_checks) + { + pmt_id_checks ( id[m_STATION_INDEX], + id[m_PLATE_INDEX], + id[m_PMT_INDEX]); + } + return result; +} + +//---------------------------------------------------------------------------- +inline Identifier +PreshowerID::pmt_id ( const Identifier& plate_id, int pmt ) const +{ + // Build identifier + Identifier result(plate_id); + + // Reset strip and then add in value + m_pmt_impl.reset (result); + m_pmt_impl.pack (pmt, result); + + if(m_do_checks) + { + pmt_id_checks ( station(result), + plate(result), + pmt ); + } + return result; +} + +//---------------------------------------------------------------------------- +inline Identifier::diff_type +PreshowerID::calc_offset(const Identifier& base, const Identifier& target) const +{ + Identifier::diff_type tval = static_cast<Identifier::diff_type>(target.get_compact() >> base_bit()); + Identifier::diff_type bval = static_cast<Identifier::diff_type>(base.get_compact() >> base_bit()); + return (tval - bval); +} + +//---------------------------------------------------------------------------- +inline Identifier +PreshowerID::pmt_id_offset(const Identifier& base, + Identifier::diff_type offset) const +{ + Identifier::value_type bval = base.get_compact() >> base_bit(); + return Identifier((bval + offset) << base_bit()); +} + +//---------------------------------------------------------------------------- +inline int +PreshowerID::base_bit ( void ) const +{ + int base = static_cast<int>(m_pmt_impl.shift()); // lowest field base + return (base > 32) ? 32 : base; + // max base is 32 so we can still read old strip id's and differences + // from non-SLHC releases. +} + +//---------------------------------------------------------------------------- +inline IdContext +PreshowerID::plate_context (void) const +{ + ExpandedIdentifier id; + return (IdContext(id, 0, m_PLATE_INDEX)); +} + +//---------------------------------------------------------------------------- +inline IdContext +PreshowerID::pmt_context (void) const +{ + ExpandedIdentifier id; + return (IdContext(id, 0, m_PMT_INDEX)); +} + +//---------------------------------------------------------------------------- +inline int +PreshowerID::station (const Identifier& id) const +{ + return (m_station_impl.unpack(id)); +} + +//---------------------------------------------------------------------------- +inline int +PreshowerID::plate (const Identifier& id) const +{ + return (m_plate_impl.unpack(id)); +} + +//---------------------------------------------------------------------------- +inline int +PreshowerID::pmt (const Identifier& id) const +{ + return (m_pmt_impl.unpack(id)); +} + + +#endif // SCINTIDENTIFIER_PRESHOWERID_H diff --git a/Scintillator/ScintDetDescr/ScintIdentifier/ScintIdentifier/ScintIdentifierDict.h b/Scintillator/ScintDetDescr/ScintIdentifier/ScintIdentifier/ScintIdentifierDict.h index e5563f4ed1a153a2f512e1edad4c20c55024d690..f8b6827f70ef31390a1ef377622d1d42b31d9730 100644 --- a/Scintillator/ScintDetDescr/ScintIdentifier/ScintIdentifier/ScintIdentifierDict.h +++ b/Scintillator/ScintDetDescr/ScintIdentifier/ScintIdentifier/ScintIdentifierDict.h @@ -14,7 +14,7 @@ // #include "ScintIdentifier/PreshowerID.h" // #include "ScintIdentifier/ScintillatorID.h" -// #include "ScintIdentifier/TriggerID.h" +#include "ScintIdentifier/TriggerID.h" #include "ScintIdentifier/VetoID.h" #endif // SCINTIDENTIFIER_SCINTIDENTIFIERDICT_H diff --git a/Scintillator/ScintDetDescr/ScintIdentifier/ScintIdentifier/TriggerID.h b/Scintillator/ScintDetDescr/ScintIdentifier/ScintIdentifier/TriggerID.h new file mode 100644 index 0000000000000000000000000000000000000000..8c3e5a34387d4d10819f85b1d34ade9ac17c6ffe --- /dev/null +++ b/Scintillator/ScintDetDescr/ScintIdentifier/ScintIdentifier/TriggerID.h @@ -0,0 +1,534 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef SCINTIDENTIFIER_TRIGGERID_H +#define SCINTIDENTIFIER_TRIGGERID_H +/** + * @file TriggerID.h + * + * @brief This is an Identifier helper class for the Trigger + * subdetector. This class is a factory for creating compact + * Identifier objects and IdentifierHash or hash ids. And it also + * allows decoding of these ids. + * + */ + +//<<<<<< INCLUDES >>>>>> + +#include "FaserDetDescr/FaserDetectorID.h" +#include "Identifier/Identifier.h" +#include "Identifier/IdentifierHash.h" +#include "Identifier/Range.h" +#include "Identifier/IdHelper.h" +#include "IdDict/IdDictFieldImplementation.h" +#include "AthenaKernel/CLASS_DEF.h" + +#include <string> +#include <assert.h> +#include <algorithm> + +//<<<<<< PUBLIC DEFINES >>>>>> +//<<<<<< PUBLIC CONSTANTS >>>>>> +//<<<<<< PUBLIC TYPES >>>>>> + +class IdDictDictionary; + +//<<<<<< PUBLIC VARIABLES >>>>>> +//<<<<<< PUBLIC FUNCTIONS >>>>>> +//<<<<<< CLASS DECLARATIONS >>>>>> + +/** + ** @class TriggerID + ** + ** @brief This is an Identifier helper class for the Trigger + ** subdetector. This class is a factory for creating compact + ** Identifier objects and IdentifierHash or hash ids. And it also + ** allows decoding of these ids. + ** + ** Definition and the range of values for the levels of the + ** identifier are: + ** + ** @verbatim + ** element range meaning + ** ------- ----- ------- + ** + ** station 0 single longitudinal location + ** plate 0 - 1 two plates per station + ** pmt 0 - 1 two pmts per plate + ** + ** @endverbatim + ** + */ +class TriggerID : public FaserDetectorID +{ +public: + + /// @name public typedefs + //@{ + typedef Identifier::size_type size_type; + typedef std::vector<Identifier>::const_iterator const_id_iterator; + typedef MultiRange::const_identifier_factory const_expanded_id_iterator; + //@} + + /// @name strutors + //@{ + TriggerID(void); + virtual ~TriggerID(void) = default; + //@} + + /// @name Creators for plate ids and pmt ids + //@{ + /// For a single station + Identifier station_id ( int station ) const; + Identifier station_id ( int station, + bool checks) const; + + /// For a station from a plate id + Identifier station_id ( const Identifier& plate_id ) const; + + /// For a single plate + Identifier plate_id ( int station, + int plate ) const; + Identifier plate_id ( int station, + int plate, + bool checks) const; + + /// For a single plate from a pmt id + Identifier plate_id ( const Identifier& pmt_id ) const; + + /// From hash - optimized + Identifier plate_id ( IdentifierHash plate_hash ) const; + + /// For an individual pmt + Identifier pmt_id ( int station, + int plate, + int pmt ) const; + + Identifier pmt_id ( int station, + int plate, + int pmt, + bool check ) const; + + Identifier pmt_id ( const Identifier& plate_id, + int pmt ) const; + + //@} + + + /// @name Hash table maximum sizes + //@{ + size_type plate_hash_max (void) const; + size_type pmt_hash_max (void) const; + //@} + + /// @name Access to all ids + //@{ + /// Iterators over full set of ids. Plate iterator is sorted + const_id_iterator plate_begin (void) const; + const_id_iterator plate_end (void) const; + /// For pmt ids, only expanded id iterators are available. Use + /// following "pmt_id" method to obtain a compact identifier + const_expanded_id_iterator pmt_begin (void) const; + const_expanded_id_iterator pmt_end (void) const; + //@} + + + /// @name Optimized accessors - ASSUMES id IS a trigger id, i.e. NOT other + //@{ + /// wafer hash from id - optimized + IdentifierHash plate_hash (Identifier plate_id) const; + + /// Values of different levels (failure returns 0) + int station (const Identifier& id) const; + int plate (const Identifier& id) const; + int pmt (const Identifier& id) const; + + /// Max/Min values for each field (-999 == failure) + int station_max (const Identifier& id) const; + int plate_max (const Identifier& id) const; + int pmt_max (const Identifier& id) const; + //@} + + /// @name module navigation + //@{ + /// Previous plate in z + int get_prev_in_z(const IdentifierHash& id, IdentifierHash& prev) const; + /// Next plate in z + int get_next_in_z(const IdentifierHash& id, IdentifierHash& next) const; + // /// Previous wafer hash in phi (return == 0 for neighbor found) + // int get_prev_in_phi (const IdentifierHash& id, IdentifierHash& prev) const; + // /// Next wafer hash in phi (return == 0 for neighbor found) + // int get_next_in_phi (const IdentifierHash& id, IdentifierHash& next) const; + // /// Previous wafer hash in eta (return == 0 for neighbor found) + // int get_prev_in_eta (const IdentifierHash& id, IdentifierHash& prev) const; + // /// Next wafer hash in eta (return == 0 for neighbor found) + // int get_next_in_eta (const IdentifierHash& id, IdentifierHash& next) const; + // /// Wafer hash on other side + // int get_other_side (const IdentifierHash& id, IdentifierHash& other) const; + + // // To check for when phi wrap around may be needed, use + // bool is_phi_module_max(const Identifier& id) const; + // /// For the barrel + // bool is_eta_module_min(const Identifier& id) const; + // /// For the barrel + // bool is_eta_module_max(const Identifier& id) const; + //@} + + /// @name contexts to distinguish plate id from pixel id + //@{ + IdContext plate_context (void) const; + IdContext pmt_context (void) const; + //@} + + /// @name methods from abstract interface - slower than opt version + //@{ + /// Create compact id from hash id (return == 0 for OK) + virtual int get_id (const IdentifierHash& hash_id, + Identifier& id, + const IdContext* context = 0) const; + + /// Create hash id from compact id (return == 0 for OK) + virtual int get_hash (const Identifier& id, + IdentifierHash& hash_id, + const IdContext* context = 0) const; + //@} + + /// Return the lowest bit position used in the channel id + int base_bit (void) const; + + /// Calculate a channel offset between the two identifiers. + Identifier::diff_type calc_offset(const Identifier& base, + const Identifier& target) const; + + /// Create an identifier with a given base and channel offset + Identifier pmt_id_offset(const Identifier& base, + Identifier::diff_type offset) const; + + /// @name interaction with id dictionary + //@{ + /// Create strip Identifier from expanded id, which is returned by the + /// id_iterators + Identifier pmt_id (const ExpandedIdentifier& pmt_id) const; + + /// Create expanded id from compact id (return == 0 for OK) + void get_expanded_id (const Identifier& id, + ExpandedIdentifier& exp_id, + const IdContext* context = 0) const; + + /// Initialization from the identifier dictionary + virtual int initialize_from_dictionary(const IdDictMgr& dict_mgr); + + /// Tests of packing + void test_plate_packing (void) const; + //@} + +private: + + enum {NOT_VALID_HASH = 64000}; + + typedef std::vector<Identifier> id_vec; + typedef id_vec::const_iterator id_vec_it; + typedef std::vector<unsigned short> hash_vec; + typedef hash_vec::const_iterator hash_vec_it; + + void plate_id_checks ( int station, + int plate ) const; + + void pmt_id_checks ( int station, + int plate, + int pmt ) const; + + + int initLevelsFromDict(void); + + int init_hashes(void); + + int init_neighbors(void); + + // Temporary method for adapting an identifier for the MultiRange + // check - MR is missing the InnerDetector level + // Identifier idForCheck (const Identifier& id) const; + + size_type m_trigger_region_index; + size_type m_SCINT_INDEX; + size_type m_TRIGGER_INDEX; + size_type m_STATION_INDEX; + size_type m_PLATE_INDEX; + size_type m_PMT_INDEX; + + const IdDictDictionary* m_dict; + MultiRange m_full_plate_range; + MultiRange m_full_pmt_range; + size_type m_plate_hash_max; + size_type m_pmt_hash_max; + // Range::field m_barrel_field; + id_vec m_plate_vec; + hash_vec m_prev_z_plate_vec; + hash_vec m_next_z_plate_vec; + // hash_vec m_prev_phi_wafer_vec; + // hash_vec m_next_phi_wafer_vec; + // hash_vec m_prev_eta_wafer_vec; + // hash_vec m_next_eta_wafer_vec; + // bool m_hasRows ; + + IdDictFieldImplementation m_scint_impl ; + IdDictFieldImplementation m_trigger_impl ; + IdDictFieldImplementation m_station_impl ; + IdDictFieldImplementation m_plate_impl ; + IdDictFieldImplementation m_pmt_impl ; +}; + + +//<<<<<< INLINE PUBLIC FUNCTIONS >>>>>> + +///////////////////////////////////////////////////////////////////////////// +//<<<<<< INLINE MEMBER FUNCTIONS >>>>>> +///////////////////////////////////////////////////////////////////////////// + +//using the macros below we can assign an identifier (and a version) +//This is required and checked at compile time when you try to record/retrieve +CLASS_DEF(TriggerID, 58382802, 1) + +//---------------------------------------------------------------------------- +inline Identifier +TriggerID::station_id ( int station, + bool checks) const +{ + + // Build identifier + Identifier result((Identifier::value_type)0); + + // Pack fields independently + m_scint_impl.pack (scint_field_value(), result); + m_trigger_impl.pack (trigger_field_value(), result); + m_station_impl.pack (station, result); + // Do checks + if(checks) + { + plate_id_checks ( station, 0 ); + } + + return result; +} + +inline Identifier +TriggerID::station_id ( int station ) const +{ + return station_id (station, do_checks()); +} + +//---------------------------------------------------------------------------- +inline Identifier +TriggerID::station_id ( const Identifier& plate_id ) const +{ + Identifier result(plate_id); + // Reset the plate and pmt fields + m_plate_impl.reset(result); + m_pmt_impl.reset(result); + return (result); +} + +//---------------------------------------------------------------------------- +inline Identifier +TriggerID::plate_id ( int station, + int plate, + bool checks) const +{ + // Build identifier + Identifier result((Identifier::value_type)0); + + // Pack fields independently + m_scint_impl.pack (scint_field_value(), result); + m_trigger_impl.pack (trigger_field_value(), result); + m_station_impl.pack (station, result); + m_plate_impl.pack (plate, result); + + // Do checks + if(checks) + { + plate_id_checks ( station, plate ); + } + return result; +} + +inline Identifier +TriggerID::plate_id ( int station, + int plate ) const +{ + return plate_id (station, plate, do_checks()); +} + +//---------------------------------------------------------------------------- +inline Identifier +TriggerID::plate_id ( const Identifier& pmt_id ) const +{ + Identifier result(pmt_id); + // reset the pmt field + m_pmt_impl.reset(result); + return (result); +} + +//---------------------------------------------------------------------------- +inline Identifier TriggerID::plate_id ( IdentifierHash plate_hash ) const +{ + return (m_plate_vec[plate_hash]); +} + +//---------------------------------------------------------------------------- +inline IdentifierHash TriggerID::plate_hash (Identifier plate_id) const +{ + id_vec_it it = std::lower_bound(m_plate_vec.begin(), + m_plate_vec.end(), + plate_id); + // Require that plate_id matches the one in vector + if (it != m_plate_vec.end() && plate_id == (*it)) { + return (it - m_plate_vec.begin()); + } + IdentifierHash result; + return (result); // return hash in invalid state +} + +//---------------------------------------------------------------------------- +inline Identifier +TriggerID::pmt_id ( int station, + int plate, + int pmt, + bool checks) const +{ + // Build identifier + Identifier result((Identifier::value_type)0); + + // Pack fields independently + m_scint_impl.pack (scint_field_value(), result); + m_trigger_impl.pack (trigger_field_value(), result); + m_station_impl.pack (station, result); + m_plate_impl.pack (plate, result); + m_pmt_impl.pack (pmt, result); + + // Do checks + if(checks) { + pmt_id_checks ( station, plate, pmt ); + } + return result; +} + +inline Identifier +TriggerID::pmt_id ( int station, + int plate, + int pmt ) const +{ + return pmt_id (station, plate, pmt, do_checks()); +} + +//---------------------------------------------------------------------------- +inline Identifier +TriggerID::pmt_id (const ExpandedIdentifier& id) const +{ + // Build identifier + Identifier result((Identifier::value_type)0); + + // Pack fields independently + m_scint_impl.pack (scint_field_value(), result); + m_trigger_impl.pack (trigger_field_value(), result); + m_station_impl.pack (id[m_STATION_INDEX], result); + m_plate_impl.pack (id[m_PLATE_INDEX], result); + m_pmt_impl.pack (id[m_PMT_INDEX], result); + + // Do checks + if(m_do_checks) + { + pmt_id_checks ( id[m_STATION_INDEX], + id[m_PLATE_INDEX], + id[m_PMT_INDEX]); + } + return result; +} + +//---------------------------------------------------------------------------- +inline Identifier +TriggerID::pmt_id ( const Identifier& plate_id, int pmt ) const +{ + // Build identifier + Identifier result(plate_id); + + // Reset strip and then add in value + m_pmt_impl.reset (result); + m_pmt_impl.pack (pmt, result); + + if(m_do_checks) + { + pmt_id_checks ( station(result), + plate(result), + pmt ); + } + return result; +} + +//---------------------------------------------------------------------------- +inline Identifier::diff_type +TriggerID::calc_offset(const Identifier& base, const Identifier& target) const +{ + Identifier::diff_type tval = static_cast<Identifier::diff_type>(target.get_compact() >> base_bit()); + Identifier::diff_type bval = static_cast<Identifier::diff_type>(base.get_compact() >> base_bit()); + return (tval - bval); +} + +//---------------------------------------------------------------------------- +inline Identifier +TriggerID::pmt_id_offset(const Identifier& base, + Identifier::diff_type offset) const +{ + Identifier::value_type bval = base.get_compact() >> base_bit(); + return Identifier((bval + offset) << base_bit()); +} + +//---------------------------------------------------------------------------- +inline int +TriggerID::base_bit ( void ) const +{ + int base = static_cast<int>(m_pmt_impl.shift()); // lowest field base + return (base > 32) ? 32 : base; + // max base is 32 so we can still read old strip id's and differences + // from non-SLHC releases. +} + +//---------------------------------------------------------------------------- +inline IdContext +TriggerID::plate_context (void) const +{ + ExpandedIdentifier id; + return (IdContext(id, 0, m_PLATE_INDEX)); +} + +//---------------------------------------------------------------------------- +inline IdContext +TriggerID::pmt_context (void) const +{ + ExpandedIdentifier id; + return (IdContext(id, 0, m_PMT_INDEX)); +} + +//---------------------------------------------------------------------------- +inline int +TriggerID::station (const Identifier& id) const +{ + return (m_station_impl.unpack(id)); +} + +//---------------------------------------------------------------------------- +inline int +TriggerID::plate (const Identifier& id) const +{ + return (m_plate_impl.unpack(id)); +} + +//---------------------------------------------------------------------------- +inline int +TriggerID::pmt (const Identifier& id) const +{ + return (m_pmt_impl.unpack(id)); +} + + +#endif // SCINTIDENTIFIER_TRIGGERID_H diff --git a/Scintillator/ScintDetDescr/ScintIdentifier/ScintIdentifier/VetoID.h b/Scintillator/ScintDetDescr/ScintIdentifier/ScintIdentifier/VetoID.h index 1f758dcea8f8c6814b2a81406da326f2f9804b06..6895570e4cc8d2963566023a3836eac635d1c921 100644 --- a/Scintillator/ScintDetDescr/ScintIdentifier/ScintIdentifier/VetoID.h +++ b/Scintillator/ScintDetDescr/ScintIdentifier/ScintIdentifier/VetoID.h @@ -54,7 +54,7 @@ class IdDictDictionary; ** ------- ----- ------- ** ** station 0 to 1 longitudinal location - ** plate 0 single plate per station + ** plate 0 to 1 two plates per station ** pmt 0 single pmt per plate ** ** @endverbatim diff --git a/Scintillator/ScintDetDescr/ScintIdentifier/ScintIdentifier/selection.xml b/Scintillator/ScintDetDescr/ScintIdentifier/ScintIdentifier/selection.xml index 7725964df2b75d5d261b65354eb1e5c403939e80..543856daa22bebedab8c75cff790f07b7f7468f5 100644 --- a/Scintillator/ScintDetDescr/ScintIdentifier/ScintIdentifier/selection.xml +++ b/Scintillator/ScintDetDescr/ScintIdentifier/ScintIdentifier/selection.xml @@ -1,8 +1,8 @@ <lcgdict> <!-- - <class name="PreshowerID" /> <class name="ScintillatorID" /> - <class name="TriggerID" /> --> <class name="VetoID" /> + <class name="TriggerID" /> + <class name="PreshowerID" /> </lcgdict> diff --git a/Scintillator/ScintDetDescr/ScintIdentifier/src/PreshowerID.cxx b/Scintillator/ScintDetDescr/ScintIdentifier/src/PreshowerID.cxx new file mode 100644 index 0000000000000000000000000000000000000000..a65d45f5536faede91de2434227a197947298344 --- /dev/null +++ b/Scintillator/ScintDetDescr/ScintIdentifier/src/PreshowerID.cxx @@ -0,0 +1,1030 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/*************************************************************************** + Scintillator identifier package + ------------------------------------------- +***************************************************************************/ + +//<<<<<< INCLUDES >>>>>> +#include "GaudiKernel/MsgStream.h" + +#include "ScintIdentifier/PreshowerID.h" +#include "Identifier/IdentifierHash.h" +#include "IdDict/IdDictDefs.h" +#include <set> +#include <algorithm> +#include <iostream> + +//<<<<<< PRIVATE DEFINES >>>>>> +//<<<<<< PRIVATE CONSTANTS >>>>>> +//<<<<<< PRIVATE TYPES >>>>>> +//<<<<<< PRIVATE VARIABLE DEFINITIONS >>>>>> +//<<<<<< PUBLIC VARIABLE DEFINITIONS >>>>>> +//<<<<<< CLASS STRUCTURE INITIALIZATION >>>>>> +//<<<<<< PRIVATE FUNCTION DEFINITIONS >>>>>> +//<<<<<< PUBLIC FUNCTION DEFINITIONS >>>>>> +//<<<<<< MEMBER FUNCTION DEFINITIONS >>>>>> + + +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// + + +PreshowerID::PreshowerID(void) + : + m_preshower_region_index(0), + m_SCINT_INDEX(0), + m_PRESHOWER_INDEX(1), + m_STATION_INDEX(2), + m_PLATE_INDEX(3), + m_PMT_INDEX(4), + m_dict(0), + m_plate_hash_max(0), + m_pmt_hash_max(0) +{ +} + +void +PreshowerID::plate_id_checks ( int station, + int plate ) const +{ + + // Check that id is within allowed range + + // Fill expanded id + ExpandedIdentifier id; + id << scint_field_value() << preshower_field_value() + << station << plate; + + if (!m_full_plate_range.match(id)) { // module range check is sufficient + MsgStream log(m_msgSvc, "PreshowerID"); + log << MSG::ERROR << " PreshowerID::plate_id result is NOT ok. ID, range " + << (std::string)id << " " << (std::string)m_full_plate_range << endmsg; + } +} + +void +PreshowerID::pmt_id_checks ( int station, + int plate, + int pmt) const +{ + + // Check that id is within allowed range + + // Fill expanded id + ExpandedIdentifier id; + id << scint_field_value() << preshower_field_value() + << station << plate << pmt; + + if (!m_full_pmt_range.match(id)) { + MsgStream log(m_msgSvc, "PreshowerID"); + log << MSG::ERROR << " PreshowerID::pmt_id result is NOT ok. ID, range " + << (std::string)id << " " << (std::string)m_full_pmt_range << std::endl; + } +} + +int +PreshowerID::station_max(const Identifier& id) const +{ + // get max from dictionary + ExpandedIdentifier expId; + IdContext plate_context1 = plate_context(); + get_expanded_id(id, expId, &plate_context1); + for (unsigned int i = 0; i < m_full_plate_range.size(); ++i) { + const Range& range = m_full_plate_range[i]; + if (range.match(expId)) { + const Range::field& station_field = range[m_STATION_INDEX]; + if (station_field.has_maximum()) { + return (station_field.get_maximum()); + } + } + } + return (-999); // default +} + +int +PreshowerID::pmt_max (const Identifier& id) const +{ + ExpandedIdentifier expId; + IdContext station_context(expId, 0, m_STATION_INDEX); + get_expanded_id(id, expId, &station_context); + int result = -999; + for (unsigned int i = 0; i < m_full_pmt_range.size(); ++i) { + const Range& range = m_full_pmt_range[i]; + if (range.match(expId)) { + const Range::field& pmt_field = range[m_PMT_INDEX]; + if (pmt_field.has_maximum()) { + int pmt = pmt_field.get_maximum(); + if (result < pmt) result = pmt; + } + } + } + return (result); +} + +int +PreshowerID::plate_max(const Identifier& id) const +{ + // get max from dictionary + ExpandedIdentifier expId; + IdContext plate_context1 = plate_context(); + get_expanded_id(id, expId, &plate_context1); + for (unsigned int i = 0; i < m_full_plate_range.size(); ++i) { + const Range& range = m_full_plate_range[i]; + if (range.match(expId)) { + const Range::field& plate_field = range[m_PLATE_INDEX]; + if (plate_field.has_maximum()) { + return (plate_field.get_maximum()); + } + } + } + return -1; +} + +int +PreshowerID::initialize_from_dictionary(const IdDictMgr& dict_mgr) +{ + MsgStream log(m_msgSvc, "PreshowerID"); + log << MSG::INFO << "Initialize from dictionary" << endmsg; + + // Check whether this helper should be reinitialized + if (!reinitialize(dict_mgr)) { + log << MSG::INFO << "Request to reinitialize not satisfied - tags have not changed" << endmsg; + return (0); + } + else { + if (m_msgSvc) { + log << MSG::DEBUG << "(Re)initialize" << endmsg; + } + else { + std::cout << " DEBUG (Re)initialize" << std::endl; + } + } + + // init base object + if(FaserDetectorID::initialize_from_dictionary(dict_mgr)) return (1); + + // Register version of InnerDetector dictionary + if (register_dict_tag(dict_mgr, "Scintillator")) return(1); + + m_dict = dict_mgr.find_dictionary ("Scintillator"); + if(!m_dict) { + log << MSG::ERROR << " PreshowerID::initialize_from_dict - cannot access Scintillator dictionary " << endmsg; + return 1; + } + + // Initialize the field indices + if(initLevelsFromDict()) return (1); + + // + // Build multirange for the valid set of identifiers + // + + + // Find value for the field Scintillator + const IdDictDictionary* faserDict = dict_mgr.find_dictionary ("FASER"); + int scintField = -1; + if (faserDict->get_label_value("subdet", "Scintillator", scintField)) { + log << MSG::ERROR << "Could not get value for label 'Scintillator' of field 'subdet' in dictionary " + << faserDict->m_name + << endmsg; + return (1); + } + + // Find value for the field Preshower + int preshowerField = -1; + if (m_dict->get_label_value("part", "Preshower", preshowerField)) { + log << MSG::ERROR << "Could not get value for label 'Preshower' of field 'part' in dictionary " + << m_dict->m_name + << endmsg; + return (1); + } + if (m_msgSvc) { + log << MSG::DEBUG << " PreshowerID::initialize_from_dict " + << "Found field values: Preshower " + << preshowerField + << std::endl; + } + else { + std::cout << " DEBUG PreshowerID::initialize_from_dict " + << "Found field values: Preshower " + << preshowerField + << std::endl; + } + + // Set up id for region and range prefix + ExpandedIdentifier region_id; + region_id.add(scintField); + region_id.add(preshowerField); + Range prefix; + m_full_plate_range = m_dict->build_multirange(region_id, prefix, "plate"); + m_full_pmt_range = m_dict->build_multirange(region_id, prefix); + + // Setup the hash tables + if(init_hashes()) return (1); + + // Setup hash tables for finding neighbors + if(init_neighbors()) return (1); + + if (m_msgSvc) { + log << MSG::INFO << " PreshowerID::initialize_from_dict " << endmsg; + log << MSG::DEBUG + << "Plate range -> " << (std::string)m_full_plate_range + << endmsg; + log << MSG::DEBUG + << "Pmt range -> " << (std::string)m_full_pmt_range + << endmsg; + } + else { + std::cout << " INFO PreshowerID::initialize_from_dict " << std::endl; + std::cout << " DEBUG Plate range -> " << (std::string)m_full_plate_range + << std::endl; + std::cout << " DEBUG Pmt range -> " << (std::string)m_full_pmt_range + << std::endl; + } + + return 0; +} + +int +PreshowerID::init_hashes(void) +{ + + // + // create a vector(s) to retrieve the hashes for compact ids. For + // the moment, we implement a hash for plates but NOT for pmts + // + MsgStream log(m_msgSvc, "PreshowerID"); + // plate hash + m_plate_hash_max = m_full_plate_range.cardinality(); + m_plate_vec.resize(m_plate_hash_max); + unsigned int nids = 0; + std::set<Identifier> ids; + for (unsigned int i = 0; i < m_full_plate_range.size(); ++i) { + const Range& range = m_full_plate_range[i]; + Range::const_identifier_factory first = range.factory_begin(); + Range::const_identifier_factory last = range.factory_end(); + for (; first != last; ++first) { + const ExpandedIdentifier& exp_id = (*first); + Identifier id = plate_id(exp_id[m_STATION_INDEX], + exp_id[m_PLATE_INDEX]); + if(!(ids.insert(id)).second) { + log << MSG::ERROR << " PreshowerID::init_hashes " + << " Error: duplicated id for plate id. nid " << nids + << " compact id " << id.getString() + << " id " << (std::string)exp_id << endmsg; + return (1); + } + nids++; + } + } + if(ids.size() != m_plate_hash_max) { + log << MSG::ERROR << " PreshowerID::init_hashes " + << " Error: set size NOT EQUAL to hash max. size " << ids.size() + << " hash max " << m_plate_hash_max + << endmsg; + return (1); + } + + nids = 0; + std::set<Identifier>::const_iterator first = ids.begin(); + std::set<Identifier>::const_iterator last = ids.end(); + for (; first != last && nids < m_plate_vec.size(); ++first) { + m_plate_vec[nids] = (*first); + nids++; + } + + // pmt hash - we do not keep a vec for the pmts + m_pmt_hash_max = m_full_pmt_range.cardinality(); + + return (0); +} + + int + PreshowerID::get_prev_in_z(const IdentifierHash& id, IdentifierHash& prev) const + { + unsigned short index = id; + if (index < m_prev_z_plate_vec.size()) + { + if (m_prev_z_plate_vec[index] == NOT_VALID_HASH) return (1); + prev = m_prev_z_plate_vec[index]; + return (0); + } + return (1); + } + + int + PreshowerID::get_next_in_z(const IdentifierHash& id, IdentifierHash& next) const + { + unsigned short index = id; + if (index < m_next_z_plate_vec.size()) + { + if (m_next_z_plate_vec[index] == NOT_VALID_HASH) return (1); + next = m_next_z_plate_vec[index]; + return (0); + } + return (1); + } + +// int +// PreshowerID::get_prev_in_phi(const IdentifierHash& id, IdentifierHash& prev) const +// { +// unsigned short index = id; +// if (index < m_prev_phi_wafer_vec.size()) { +// if (m_prev_phi_wafer_vec[index] == NOT_VALID_HASH) return (1); +// prev = m_prev_phi_wafer_vec[index]; +// return (0); +// } +// return (1); +// } + +// int +// PreshowerID::get_next_in_phi(const IdentifierHash& id, IdentifierHash& next) const +// { +// unsigned short index = id; +// if (index < m_next_phi_wafer_vec.size()) { +// if (m_next_phi_wafer_vec[index] == NOT_VALID_HASH) return (1); +// next = m_next_phi_wafer_vec[index]; +// return (0); +// } +// return (1); +// } + +// int +// PreshowerID::get_prev_in_eta(const IdentifierHash& id, IdentifierHash& prev) const +// { +// unsigned short index = id; +// if (index < m_prev_eta_wafer_vec.size()) { +// if (m_prev_eta_wafer_vec[index] == NOT_VALID_HASH) return (1); +// prev = m_prev_eta_wafer_vec[index]; +// return (0); +// } +// return (1); +// } + +// int +// PreshowerID::get_next_in_eta(const IdentifierHash& id, IdentifierHash& next) const +// { +// unsigned short index = id; +// if (index < m_next_eta_wafer_vec.size()) { +// if (m_next_eta_wafer_vec[index] == NOT_VALID_HASH) return (1); +// next = m_next_eta_wafer_vec[index]; +// return (0); +// } +// return (1); +// } + +// int +// PreshowerID::get_other_side (const IdentifierHash& hashId, IdentifierHash& other) const +// { +// if (m_dict) { +// // get max from dictionary +// Identifier id; +// IdContext wafer_context1 = wafer_context(); +// if(!get_id(hashId, id, &wafer_context1)) { +// other = side(id) ? hashId - 1 : hashId + 1; +// return (0); +// } +// } +// return (1); +// } + +int +PreshowerID::init_neighbors(void) +{ + // + // create a vector(s) to retrieve the hashes for compact ids for + // plate neighbors. + // + MsgStream log(m_msgSvc, "PreshowerID"); + + m_prev_z_plate_vec.resize(m_plate_hash_max, NOT_VALID_HASH); + m_next_z_plate_vec.resize(m_plate_hash_max, NOT_VALID_HASH); + for (unsigned int i = 0; i < m_full_plate_range.size(); i++) + { + const Range& range = m_full_plate_range[i]; + const Range::field& station_field = range[m_STATION_INDEX]; + const Range::field& plate_field = range[m_PLATE_INDEX]; + Range::const_identifier_factory first = range.factory_begin(); + Range::const_identifier_factory last = range.factory_end(); + for (; first != last; ++first) + { + const ExpandedIdentifier& exp_id = (*first); + ExpandedIdentifier::element_type previous_plate; + ExpandedIdentifier::element_type next_plate; + ExpandedIdentifier::element_type previous_station; + ExpandedIdentifier::element_type next_station; + bool pplate = plate_field.get_previous(exp_id[m_PLATE_INDEX], previous_plate); + bool nplate = plate_field.get_next (exp_id[m_PLATE_INDEX], next_plate); + bool pstation = station_field.get_previous(exp_id[m_STATION_INDEX], previous_station); + bool nstation = station_field.get_next (exp_id[m_STATION_INDEX], next_station); + + IdContext pcontext = plate_context(); + + IdentifierHash hash_id; + Identifier originalId = plate_id(exp_id[m_STATION_INDEX], + exp_id[m_PLATE_INDEX]); + + if (get_hash(originalId, hash_id, &pcontext)) + { + log << MSG::ERROR << " PreshowerID::init_neighbors - unable to get hash, exp/compact " + << show_to_string(originalId, &pcontext) + << " " << (std::string)m_full_plate_range << endmsg; + return (1); + } + + // index for the subsequent arrays + unsigned short index = hash_id; + assert (hash_id < m_prev_z_plate_vec.size()); + assert (hash_id < m_next_z_plate_vec.size()); + + if (pplate) { + // Get previous plate hash id + ExpandedIdentifier expId = exp_id; + expId[m_PLATE_INDEX] = previous_plate; + Identifier id = plate_id(expId[m_STATION_INDEX], + expId[m_PLATE_INDEX]); + + if (get_hash(id, hash_id, &pcontext)) { + log << MSG::ERROR << " PreshowerID::init_neighbors - unable to get previous plate hash, exp/compact " << id.getString() << " " + << endmsg; + return (1); + } + m_prev_z_plate_vec[index] = hash_id; + } + else if (pstation) + { + ExpandedIdentifier expId = exp_id; + expId[m_STATION_INDEX] = previous_station; + ExpandedIdentifier stationId; + stationId.add(expId[m_SCINT_INDEX]); + stationId.add(expId[m_PRESHOWER_INDEX]); + stationId.add(previous_station); + Range prefix; + MultiRange stationPlateRange = m_dict->build_multirange(stationId, prefix, "plate"); + const Range::field& upstream_plate_field = range[m_PLATE_INDEX]; + if (upstream_plate_field.has_maximum()) + { + expId[m_PLATE_INDEX] = upstream_plate_field.get_maximum(); + Identifier id = plate_id(expId[m_STATION_INDEX], + expId[m_PLATE_INDEX]); + if (get_hash(id, hash_id, &pcontext)) { + log << MSG::ERROR << " PreshowerID::init_neighbors - unable to get last plate hash from previous station, exp/compact " << id.getString() << " " + << endmsg; + return (1); + } + m_prev_z_plate_vec[index] = hash_id; + } + else + { + log << MSG::ERROR << "PreshowerID::init_neighbors - unable to get plate_max for previous station, exp/compact " << originalId.getString() << " " + << endmsg; + return (1); + } + } + + if (nplate) { + // Get next plate hash id + ExpandedIdentifier expId = exp_id; + expId[m_PLATE_INDEX] = next_plate; + Identifier id = plate_id(expId[m_STATION_INDEX], + expId[m_PLATE_INDEX]); + + if (get_hash(id, hash_id, &pcontext)) { + log << MSG::ERROR << " PreshowerID::init_neighbors - unable to get next plate hash, exp/compact " << id.getString() << " " + << endmsg; + return (1); + } + m_next_z_plate_vec[index] = hash_id; + } + else if (nstation) + { + ExpandedIdentifier expId = exp_id; + expId[m_STATION_INDEX] = next_station; + ExpandedIdentifier stationId; + stationId.add(expId[m_SCINT_INDEX]); + stationId.add(expId[m_PRESHOWER_INDEX]); + stationId.add(next_station); + Range prefix; + MultiRange stationPlateRange = m_dict->build_multirange(stationId, prefix, "plate"); + const Range::field& downstream_plate_field = range[m_PLATE_INDEX]; + if (downstream_plate_field.has_minimum()) + { + expId[m_PLATE_INDEX] = downstream_plate_field.get_minimum(); + Identifier id = plate_id(expId[m_STATION_INDEX], + expId[m_PLATE_INDEX]); + if (get_hash(id, hash_id, &pcontext)) { + log << MSG::ERROR << " PreshowerID::init_neighbors - unable to get previous plate hash from next station, exp/compact " << id.getString() << " " + << endmsg; + return (1); + } + m_next_z_plate_vec[index] = hash_id; + } + else + { + log << MSG::ERROR << "PreshowerID::init_neighbors - unable to get plate_min for next station, exp/compact " << originalId.getString() << " " + << endmsg; + return (1); + } + } + + } + } + + // m_prev_phi_wafer_vec.resize(m_wafer_hash_max, NOT_VALID_HASH); + // m_next_phi_wafer_vec.resize(m_wafer_hash_max, NOT_VALID_HASH); + // m_prev_eta_wafer_vec.resize(m_wafer_hash_max, NOT_VALID_HASH); + // m_next_eta_wafer_vec.resize(m_wafer_hash_max, NOT_VALID_HASH); + + // for (unsigned int i = 0; i < m_full_wafer_range.size(); ++i) { + // const Range& range = m_full_wafer_range[i]; + // const Range::field& phi_field = range[m_PHI_MODULE_INDEX]; + // const Range::field& eta_field = range[m_ETA_MODULE_INDEX]; + // Range::const_identifier_factory first = range.factory_begin(); + // Range::const_identifier_factory last = range.factory_end(); + // for (; first != last; ++first) { + // const ExpandedIdentifier& exp_id = (*first); + // ExpandedIdentifier::element_type previous_phi; + // ExpandedIdentifier::element_type next_phi; + // ExpandedIdentifier::element_type previous_eta; + // ExpandedIdentifier::element_type next_eta; + // bool pphi = phi_field.get_previous(exp_id[m_PHI_MODULE_INDEX], previous_phi); + // bool nphi = phi_field.get_next (exp_id[m_PHI_MODULE_INDEX], next_phi); + // bool peta = eta_field.get_previous(exp_id[m_ETA_MODULE_INDEX], previous_eta); + // bool neta = eta_field.get_next (exp_id[m_ETA_MODULE_INDEX], next_eta); + + // IdContext wcontext = wafer_context(); + + // // First get primary hash id + // IdentifierHash hash_id; + // Identifier id = wafer_id(exp_id[m_BARREL_EC_INDEX], + // exp_id[m_LAYER_DISK_INDEX], + // exp_id[m_PHI_MODULE_INDEX], + // exp_id[m_ETA_MODULE_INDEX], + // exp_id[m_SIDE_INDEX]); + // if (get_hash(id, hash_id, &wcontext)) { + // log << MSG::ERROR << " PreshowerID::init_neighbors - unable to get hash, exp/compact " + // << show_to_string(id, &wcontext) + // << " " << (std::string)m_full_wafer_range << endmsg; + // return (1); + // } + + // // index for the subsequent arrays + // unsigned short index = hash_id; + // assert (hash_id < m_prev_phi_wafer_vec.size()); + // assert (hash_id < m_next_phi_wafer_vec.size()); + // assert (hash_id < m_prev_eta_wafer_vec.size()); + // assert (hash_id < m_next_eta_wafer_vec.size()); + + // if (pphi) { + // // Get previous phi hash id + // ExpandedIdentifier expId = exp_id; + // expId[m_PHI_MODULE_INDEX] = previous_phi; + // Identifier id = wafer_id(expId[m_BARREL_EC_INDEX], + // expId[m_LAYER_DISK_INDEX], + // expId[m_PHI_MODULE_INDEX], + // expId[m_ETA_MODULE_INDEX], + // expId[m_SIDE_INDEX]); + // if (get_hash(id, hash_id, &wcontext)) { + // log << MSG::ERROR << " PreshowerID::init_neighbors - unable to get previous phi hash, exp/compact " << id.getString() << " " + // << endmsg; + // return (1); + // } + // m_prev_phi_wafer_vec[index] = hash_id; + // } + + // if (nphi) { + // // Get next phi hash id + // ExpandedIdentifier expId = exp_id; + // expId[m_PHI_MODULE_INDEX] = next_phi; + // Identifier id = wafer_id(expId[m_BARREL_EC_INDEX], + // expId[m_LAYER_DISK_INDEX], + // expId[m_PHI_MODULE_INDEX], + // expId[m_ETA_MODULE_INDEX], + // expId[m_SIDE_INDEX]); + // if (get_hash(id, hash_id, &wcontext)) { + // log << MSG::ERROR << " PreshowerID::init_neighbors - unable to get next phi hash, exp/compact " << id.getString() << + // " " << MSG::hex << id.getString() << MSG::dec << endmsg; + // return (1); + // } + // m_next_phi_wafer_vec[index] = hash_id; + // } + + // if (peta) { + // // Get previous eta hash id + // ExpandedIdentifier expId = exp_id; + // expId[m_ETA_MODULE_INDEX] = previous_eta; + // Identifier id = wafer_id(expId[m_BARREL_EC_INDEX], + // expId[m_LAYER_DISK_INDEX], + // expId[m_PHI_MODULE_INDEX], + // expId[m_ETA_MODULE_INDEX], + // expId[m_SIDE_INDEX]); + // if (get_hash(id, hash_id, &wcontext)) { + // log << MSG::ERROR << " PreshowerID::init_neighbors - unable to get previous eta hash, exp/compact " << id.getString() + // << " " << std::endl; + // return (1); + // } + // m_prev_eta_wafer_vec[index] = hash_id; + // } + + // if (neta) { + // // Get next eta hash id + // ExpandedIdentifier expId = exp_id; + // expId[m_ETA_MODULE_INDEX] = next_eta; + // Identifier id = wafer_id(expId[m_BARREL_EC_INDEX], + // expId[m_LAYER_DISK_INDEX], + // expId[m_PHI_MODULE_INDEX], + // expId[m_ETA_MODULE_INDEX], + // expId[m_SIDE_INDEX]); + // if (get_hash(id, hash_id, &wcontext)) { + // log << MSG::ERROR << " PreshowerID::init_neighbors - unable to get next eta hash, exp/compact " << id.getString() + // << " " << endmsg; + // return (1); + // } + // m_next_eta_wafer_vec[index] = hash_id; + // } + + +// std::cout << " PreshowerID::init_neighbors " +// << " phi, previous, next " << id[m_PHI_MODULE_INDEX] +// << " " << pphi +// << " " << previous_phi +// << " " << nphi +// << " " << next_phi +// << " eta, previous, next " << id[m_ETA_MODULE_INDEX] +// << " " << peta +// << " " << previous_eta +// << " " << neta +// << " " << next_eta +// << " id " << (std::string)(*first) +// << std::endl; + // } + // } + return (0); +} + + + +int +PreshowerID::initLevelsFromDict() +{ + + + MsgStream log(m_msgSvc, "PreshowerID"); + if(!m_dict) { + log << MSG::ERROR << " PreshowerID::initLevelsFromDict - dictionary NOT initialized " << endmsg; + return (1); + } + + // Find out which identifier field corresponds to each level. Use + // names to find each field/leve. + + m_SCINT_INDEX = 999; + m_PRESHOWER_INDEX = 999; + m_STATION_INDEX = 999; + m_PLATE_INDEX = 999; + m_PMT_INDEX = 999; + + // Save index to a Preshower region for unpacking + ExpandedIdentifier id; + id << scint_field_value() << preshower_field_value(); + if (m_dict->find_region(id, m_preshower_region_index)) { + log << MSG::ERROR << "PreshowerID::initLevelsFromDict - unable to find preshower region index: id, reg " + << (std::string)id << " " << m_preshower_region_index + << endmsg; + return (1); + } + + // Find a Preshower region + IdDictField* field = m_dict->find_field("subdet"); + if (field) { + m_SCINT_INDEX = field->m_index; + } + else { + log << MSG::ERROR << "PreshowerID::initLevelsFromDict - unable to find 'subdet' field " << endmsg; + return (1); + } + field = m_dict->find_field("part"); + if (field) { + m_PRESHOWER_INDEX = field->m_index; + } + else { + log << MSG::ERROR << "PreshowerID::initLevelsFromDict - unable to find 'part' field " << endmsg; + return (1); + } + field = m_dict->find_field("station"); + if (field) { + m_STATION_INDEX = field->m_index; + } + else { + log << MSG::ERROR << "PreshowerID::initLevelsFromDict - unable to find 'station' field " << endmsg; + return (1); + } + field = m_dict->find_field("plate"); + if (field) { + m_PLATE_INDEX = field->m_index; + } + else { + log << MSG::ERROR<< "PreshowerID::initLevelsFromDict - unable to find 'plate' field " << endmsg; + return (1); + } + field = m_dict->find_field("pmt"); + if (field) { + m_PMT_INDEX = field->m_index; + } + else { + log << MSG::ERROR << "PreshowerID::initLevelsFromDict - unable to find 'pmt' field " << endmsg; + return (1); + } + + // Set the field implementations + + const IdDictRegion& region = *m_dict->m_regions[m_preshower_region_index]; + + m_scint_impl = region.m_implementation[m_SCINT_INDEX]; + m_preshower_impl = region.m_implementation[m_PRESHOWER_INDEX]; + m_station_impl = region.m_implementation[m_STATION_INDEX]; + m_plate_impl = region.m_implementation[m_PLATE_INDEX]; + m_pmt_impl = region.m_implementation[m_PMT_INDEX]; + + if (m_msgSvc) { + log << MSG::DEBUG << "decode index and bit fields for each level: " << endmsg; + log << MSG::DEBUG << "scint " << m_scint_impl.show_to_string() << endmsg; + log << MSG::DEBUG << "preshower " << m_preshower_impl.show_to_string() << endmsg; + log << MSG::DEBUG << "station " << m_station_impl.show_to_string() << endmsg; + log << MSG::DEBUG << "plate " << m_plate_impl.show_to_string() << endmsg; + log << MSG::DEBUG << "pmt " << m_pmt_impl.show_to_string() << endmsg; + } + else { + std::cout << " DEBUG decode index and bit fields for each level: " << std::endl; + std::cout << " DEBUG scint " << m_scint_impl.show_to_string() << std::endl; + std::cout << " DEBUG preshower " << m_preshower_impl.show_to_string() << std::endl; + std::cout << " DEBUG station " << m_station_impl.show_to_string() << std::endl; + std::cout << " DEBUG plate " << m_plate_impl.show_to_string() << std::endl; + std::cout << " DEBUG pmt " << m_pmt_impl.show_to_string() << std::endl; + } + + std::cout << "scint " << m_scint_impl.decode_index() << " " + << (std::string)m_scint_impl.ored_field() << " " + << std::hex << m_scint_impl.mask() << " " + << m_scint_impl.zeroing_mask() << " " + << std::dec << m_scint_impl.shift() << " " + << m_scint_impl.bits() << " " + << m_scint_impl.bits_offset() + << std::endl; + std::cout << "preshower" << m_preshower_impl.decode_index() << " " + << (std::string)m_preshower_impl.ored_field() << " " + << std::hex << m_preshower_impl.mask() << " " + << m_preshower_impl.zeroing_mask() << " " + << std::dec << m_preshower_impl.shift() << " " + << m_preshower_impl.bits() << " " + << m_preshower_impl.bits_offset() + << std::endl; + std::cout << "station"<< m_station_impl.decode_index() << " " + << (std::string)m_station_impl.ored_field() << " " + << std::hex << m_station_impl.mask() << " " + << m_station_impl.zeroing_mask() << " " + << std::dec << m_station_impl.shift() << " " + << m_station_impl.bits() << " " + << m_station_impl.bits_offset() + << std::endl; + std::cout << "plate" << m_plate_impl.decode_index() << " " + << (std::string)m_plate_impl.ored_field() << " " + << std::hex << m_plate_impl.mask() << " " + << m_plate_impl.zeroing_mask() << " " + << std::dec << m_plate_impl.shift() << " " + << m_plate_impl.bits() << " " + << m_plate_impl.bits_offset() + << std::endl; + std::cout << "pmt" << m_pmt_impl.decode_index() << " " + << (std::string)m_pmt_impl.ored_field() << " " + << std::hex << m_pmt_impl.mask() << " " + << m_pmt_impl.zeroing_mask() << " " + << std::dec << m_pmt_impl.shift() << " " + << m_pmt_impl.bits() << " " + << m_pmt_impl.bits_offset() + << std::endl; + + return (0); +} + +PreshowerID::size_type +PreshowerID::plate_hash_max (void) const +{ + return m_plate_hash_max; +} + +PreshowerID::size_type +PreshowerID::pmt_hash_max (void) const +{ + return m_pmt_hash_max; +} + +PreshowerID::const_id_iterator PreshowerID::plate_begin (void) const +{ + return (m_plate_vec.begin()); +} + +PreshowerID::const_id_iterator PreshowerID::plate_end (void) const +{ + return (m_plate_vec.end()); +} + +PreshowerID::const_expanded_id_iterator PreshowerID::pmt_begin (void) const +{ + return (m_full_pmt_range.factory_begin()); +} + +PreshowerID::const_expanded_id_iterator PreshowerID::pmt_end (void) const +{ + return (m_full_pmt_range.factory_end()); +} + +// From hash get Identifier +int +PreshowerID::get_id (const IdentifierHash& hash_id, + Identifier& id, + const IdContext* context) const +{ + + int result = 1; + id.clear(); + + size_t begin = (context) ? context->begin_index(): 0; + // cannot get hash if end is 0: + size_t end = (context) ? context->end_index() : 0; + if (0 == begin) { + // No hashes yet for ids with prefixes + if (m_PLATE_INDEX == end) { + if (hash_id < (unsigned int)(m_plate_vec.end() - m_plate_vec.begin())) { + id = m_plate_vec[hash_id]; + result = 0; + } + } + else if (m_PMT_INDEX == end) { + // Do not know how to calculate strip id from hash yet!! + std::cout << "Do not know how to calculate pmt id from hash yet!!" << std::endl; + } + } + return (result); +} + +void +PreshowerID::get_expanded_id (const Identifier& id, + ExpandedIdentifier& exp_id, + const IdContext* context) const +{ + exp_id.clear(); + exp_id << scint_field_value() + << preshower_field_value() + << station(id) + << plate(id); + if(!context || context->end_index() == m_PMT_INDEX) + { + exp_id << pmt(id); + } +} + +int +PreshowerID::get_hash (const Identifier& id, + IdentifierHash& hash_id, + const IdContext* context) const +{ + + // Get the hash code from either a vec (for plate) or calculate + // it (pmts). For the former, we convert to compact and call + // get_hash again. For the latter, we calculate the hash from the + // Identifier. + + int result = 1; + hash_id = 0; + size_t begin = (context) ? context->begin_index(): 0; + size_t end = (context) ? context->end_index() : 0; + if (0 == begin) { + // No hashes yet for ids with prefixes + if (m_PLATE_INDEX == end) { + hash_id = plate_hash(id); + if (hash_id.is_valid()) result = 0; + } + else if (context && context->end_index() == m_PMT_INDEX) { + // Must calculate for strip hash + ExpandedIdentifier new_id; + get_expanded_id(id, new_id); + hash_id = m_full_pmt_range.cardinalityUpTo(new_id); + result = 0; + } + } + return (result); +} + + +void +PreshowerID::test_plate_packing (void) const +{ + MsgStream log(m_msgSvc, "PreshowerID"); + + if (m_dict) { + + int nids = 0; + int nerr = 0; + IdContext context = plate_context(); + const_id_iterator first = m_plate_vec.begin(); + const_id_iterator last = m_plate_vec.end(); + for (; first != last; ++first, ++nids) { + Identifier id = (*first); + ExpandedIdentifier exp_id; + get_expanded_id(id, exp_id, &context); + Identifier new_id = plate_id(exp_id[m_STATION_INDEX], + exp_id[m_PLATE_INDEX]); + if (id != new_id) { + log << MSG::ERROR << "PreshowerID::test_plate_packing: new and old compacts not equal. New/old/expanded ids " + << MSG::hex << show_to_string(id) << " " << show_to_string(new_id) << " " << MSG::dec + << (std::string)exp_id << endmsg; + nerr++; + continue; + } + // check station id + if (!exp_id[m_PLATE_INDEX]) { + + Identifier new_id1 = station_id(exp_id[m_STATION_INDEX]); + if (id != new_id1) { + log << MSG::ERROR << "PreshowerID::test_plate_packing: new and old station ids not equal. New/old/expanded ids " + << MSG::hex << show_to_string(id) << " " << show_to_string(new_id1) << " " << MSG::dec + << (std::string)exp_id << endmsg; + nerr++; + continue; + } + } + } + + if (m_msgSvc) { + log << MSG::DEBUG << "PreshowerID::test_plate_packing: tested plate and station ids. nids, errors " + << nids << " " << nerr << endmsg; + } + else { + std::cout << " DEBUG PreshowerID::test_plate_packing: tested plate and station ids. nids, errors " + << nids << " " << nerr << std::endl; + } + + nids = 0; + context = pmt_context(); + const_expanded_id_iterator first_preshower = pmt_begin(); + const_expanded_id_iterator last_preshower = pmt_end(); + for (; first_preshower != last_preshower; ++first_preshower, ++nids) { + // if (nids%10000 != 1) continue; + const ExpandedIdentifier& exp_id = *first_preshower; + ExpandedIdentifier new_exp_id; + + Identifier id = plate_id(exp_id[m_STATION_INDEX], + exp_id[m_PLATE_INDEX]); + get_expanded_id(id, new_exp_id, &context); + if (exp_id[0] != new_exp_id[0] || + exp_id[1] != new_exp_id[1] || + exp_id[2] != new_exp_id[2] || + exp_id[3] != new_exp_id[3]) + { + log << MSG::ERROR << "PreshowerID::test_plate_packing: new and old ids not equal. New/old/compact ids " + << (std::string)new_exp_id << " " << (std::string)exp_id + << " " << show_to_string(id) << endmsg; + continue; + } + + Identifier pmtid ; + Identifier pmtid1 ; + pmtid = pmt_id ( + exp_id[m_STATION_INDEX], + exp_id[m_PLATE_INDEX], + exp_id[m_PMT_INDEX]); + + pmtid1 = pmt_id ( + station(pmtid), + plate(pmtid), + pmt(pmtid)); + + if (pmtid != pmtid1) { + log << MSG::ERROR << "PreshowerID::test_plate_packing: new and old pixel ids not equal. New/old ids " + << " " << show_to_string(pmtid1) << " " + << show_to_string(pmtid) << endmsg; + } + } + + if (m_msgSvc) { + log << MSG::DEBUG << "PreshowerID::test_plate_packing: Successful tested " + << nids << " ids. " + << endmsg; + } + else { + std::cout << " DEBUG PreshowerID::test_plate_packing: Successful tested " + << nids << " ids. " + << std::endl; + } + } + else { + log << MSG::ERROR << "PreshowerID::test_plate_packing: Unable to test plate packing - no dictionary has been defined. " + << endmsg; + } +} + diff --git a/Scintillator/ScintDetDescr/ScintIdentifier/src/TriggerID.cxx b/Scintillator/ScintDetDescr/ScintIdentifier/src/TriggerID.cxx new file mode 100644 index 0000000000000000000000000000000000000000..408e7bf08dbc80e7087ed351535abf9e9ed38124 --- /dev/null +++ b/Scintillator/ScintDetDescr/ScintIdentifier/src/TriggerID.cxx @@ -0,0 +1,1030 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/*************************************************************************** + Scintillator identifier package + ------------------------------------------- +***************************************************************************/ + +//<<<<<< INCLUDES >>>>>> +#include "GaudiKernel/MsgStream.h" + +#include "ScintIdentifier/TriggerID.h" +#include "Identifier/IdentifierHash.h" +#include "IdDict/IdDictDefs.h" +#include <set> +#include <algorithm> +#include <iostream> + +//<<<<<< PRIVATE DEFINES >>>>>> +//<<<<<< PRIVATE CONSTANTS >>>>>> +//<<<<<< PRIVATE TYPES >>>>>> +//<<<<<< PRIVATE VARIABLE DEFINITIONS >>>>>> +//<<<<<< PUBLIC VARIABLE DEFINITIONS >>>>>> +//<<<<<< CLASS STRUCTURE INITIALIZATION >>>>>> +//<<<<<< PRIVATE FUNCTION DEFINITIONS >>>>>> +//<<<<<< PUBLIC FUNCTION DEFINITIONS >>>>>> +//<<<<<< MEMBER FUNCTION DEFINITIONS >>>>>> + + +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// + + +TriggerID::TriggerID(void) + : + m_trigger_region_index(0), + m_SCINT_INDEX(0), + m_TRIGGER_INDEX(1), + m_STATION_INDEX(2), + m_PLATE_INDEX(3), + m_PMT_INDEX(4), + m_dict(0), + m_plate_hash_max(0), + m_pmt_hash_max(0) +{ +} + +void +TriggerID::plate_id_checks ( int station, + int plate ) const +{ + + // Check that id is within allowed range + + // Fill expanded id + ExpandedIdentifier id; + id << scint_field_value() << trigger_field_value() + << station << plate; + + if (!m_full_plate_range.match(id)) { // module range check is sufficient + MsgStream log(m_msgSvc, "TriggerID"); + log << MSG::ERROR << " TriggerID::plate_id result is NOT ok. ID, range " + << (std::string)id << " " << (std::string)m_full_plate_range << endmsg; + } +} + +void +TriggerID::pmt_id_checks ( int station, + int plate, + int pmt) const +{ + + // Check that id is within allowed range + + // Fill expanded id + ExpandedIdentifier id; + id << scint_field_value() << trigger_field_value() + << station << plate << pmt; + + if (!m_full_pmt_range.match(id)) { + MsgStream log(m_msgSvc, "TriggerID"); + log << MSG::ERROR << " TriggerID::pmt_id result is NOT ok. ID, range " + << (std::string)id << " " << (std::string)m_full_pmt_range << std::endl; + } +} + +int +TriggerID::station_max(const Identifier& id) const +{ + // get max from dictionary + ExpandedIdentifier expId; + IdContext plate_context1 = plate_context(); + get_expanded_id(id, expId, &plate_context1); + for (unsigned int i = 0; i < m_full_plate_range.size(); ++i) { + const Range& range = m_full_plate_range[i]; + if (range.match(expId)) { + const Range::field& station_field = range[m_STATION_INDEX]; + if (station_field.has_maximum()) { + return (station_field.get_maximum()); + } + } + } + return (-999); // default +} + +int +TriggerID::pmt_max (const Identifier& id) const +{ + ExpandedIdentifier expId; + IdContext station_context(expId, 0, m_STATION_INDEX); + get_expanded_id(id, expId, &station_context); + int result = -999; + for (unsigned int i = 0; i < m_full_pmt_range.size(); ++i) { + const Range& range = m_full_pmt_range[i]; + if (range.match(expId)) { + const Range::field& pmt_field = range[m_PMT_INDEX]; + if (pmt_field.has_maximum()) { + int pmt = pmt_field.get_maximum(); + if (result < pmt) result = pmt; + } + } + } + return (result); +} + +int +TriggerID::plate_max(const Identifier& id) const +{ + // get max from dictionary + ExpandedIdentifier expId; + IdContext plate_context1 = plate_context(); + get_expanded_id(id, expId, &plate_context1); + for (unsigned int i = 0; i < m_full_plate_range.size(); ++i) { + const Range& range = m_full_plate_range[i]; + if (range.match(expId)) { + const Range::field& plate_field = range[m_PLATE_INDEX]; + if (plate_field.has_maximum()) { + return (plate_field.get_maximum()); + } + } + } + return -1; +} + +int +TriggerID::initialize_from_dictionary(const IdDictMgr& dict_mgr) +{ + MsgStream log(m_msgSvc, "TriggerID"); + log << MSG::INFO << "Initialize from dictionary" << endmsg; + + // Check whether this helper should be reinitialized + if (!reinitialize(dict_mgr)) { + log << MSG::INFO << "Request to reinitialize not satisfied - tags have not changed" << endmsg; + return (0); + } + else { + if (m_msgSvc) { + log << MSG::DEBUG << "(Re)initialize" << endmsg; + } + else { + std::cout << " DEBUG (Re)initialize" << std::endl; + } + } + + // init base object + if(FaserDetectorID::initialize_from_dictionary(dict_mgr)) return (1); + + // Register version of InnerDetector dictionary + if (register_dict_tag(dict_mgr, "Scintillator")) return(1); + + m_dict = dict_mgr.find_dictionary ("Scintillator"); + if(!m_dict) { + log << MSG::ERROR << " TriggerID::initialize_from_dict - cannot access Scintillator dictionary " << endmsg; + return 1; + } + + // Initialize the field indices + if(initLevelsFromDict()) return (1); + + // + // Build multirange for the valid set of identifiers + // + + + // Find value for the field Scintillator + const IdDictDictionary* faserDict = dict_mgr.find_dictionary ("FASER"); + int scintField = -1; + if (faserDict->get_label_value("subdet", "Scintillator", scintField)) { + log << MSG::ERROR << "Could not get value for label 'Scintillator' of field 'subdet' in dictionary " + << faserDict->m_name + << endmsg; + return (1); + } + + // Find value for the field Trigger + int triggerField = -1; + if (m_dict->get_label_value("part", "Trigger", triggerField)) { + log << MSG::ERROR << "Could not get value for label 'Trigger' of field 'part' in dictionary " + << m_dict->m_name + << endmsg; + return (1); + } + if (m_msgSvc) { + log << MSG::DEBUG << " TriggerID::initialize_from_dict " + << "Found field values: Trigger " + << triggerField + << std::endl; + } + else { + std::cout << " DEBUG TriggerID::initialize_from_dict " + << "Found field values: Trigger " + << triggerField + << std::endl; + } + + // Set up id for region and range prefix + ExpandedIdentifier region_id; + region_id.add(scintField); + region_id.add(triggerField); + Range prefix; + m_full_plate_range = m_dict->build_multirange(region_id, prefix, "plate"); + m_full_pmt_range = m_dict->build_multirange(region_id, prefix); + + // Setup the hash tables + if(init_hashes()) return (1); + + // Setup hash tables for finding neighbors + if(init_neighbors()) return (1); + + if (m_msgSvc) { + log << MSG::INFO << " TriggerID::initialize_from_dict " << endmsg; + log << MSG::DEBUG + << "Plate range -> " << (std::string)m_full_plate_range + << endmsg; + log << MSG::DEBUG + << "Pmt range -> " << (std::string)m_full_pmt_range + << endmsg; + } + else { + std::cout << " INFO TriggerID::initialize_from_dict " << std::endl; + std::cout << " DEBUG Plate range -> " << (std::string)m_full_plate_range + << std::endl; + std::cout << " DEBUG Pmt range -> " << (std::string)m_full_pmt_range + << std::endl; + } + + return 0; +} + +int +TriggerID::init_hashes(void) +{ + + // + // create a vector(s) to retrieve the hashes for compact ids. For + // the moment, we implement a hash for plates but NOT for pmts + // + MsgStream log(m_msgSvc, "TriggerID"); + // plate hash + m_plate_hash_max = m_full_plate_range.cardinality(); + m_plate_vec.resize(m_plate_hash_max); + unsigned int nids = 0; + std::set<Identifier> ids; + for (unsigned int i = 0; i < m_full_plate_range.size(); ++i) { + const Range& range = m_full_plate_range[i]; + Range::const_identifier_factory first = range.factory_begin(); + Range::const_identifier_factory last = range.factory_end(); + for (; first != last; ++first) { + const ExpandedIdentifier& exp_id = (*first); + Identifier id = plate_id(exp_id[m_STATION_INDEX], + exp_id[m_PLATE_INDEX]); + if(!(ids.insert(id)).second) { + log << MSG::ERROR << " TriggerID::init_hashes " + << " Error: duplicated id for plate id. nid " << nids + << " compact id " << id.getString() + << " id " << (std::string)exp_id << endmsg; + return (1); + } + nids++; + } + } + if(ids.size() != m_plate_hash_max) { + log << MSG::ERROR << " TriggerID::init_hashes " + << " Error: set size NOT EQUAL to hash max. size " << ids.size() + << " hash max " << m_plate_hash_max + << endmsg; + return (1); + } + + nids = 0; + std::set<Identifier>::const_iterator first = ids.begin(); + std::set<Identifier>::const_iterator last = ids.end(); + for (; first != last && nids < m_plate_vec.size(); ++first) { + m_plate_vec[nids] = (*first); + nids++; + } + + // pmt hash - we do not keep a vec for the pmts + m_pmt_hash_max = m_full_pmt_range.cardinality(); + + return (0); +} + + int + TriggerID::get_prev_in_z(const IdentifierHash& id, IdentifierHash& prev) const + { + unsigned short index = id; + if (index < m_prev_z_plate_vec.size()) + { + if (m_prev_z_plate_vec[index] == NOT_VALID_HASH) return (1); + prev = m_prev_z_plate_vec[index]; + return (0); + } + return (1); + } + + int + TriggerID::get_next_in_z(const IdentifierHash& id, IdentifierHash& next) const + { + unsigned short index = id; + if (index < m_next_z_plate_vec.size()) + { + if (m_next_z_plate_vec[index] == NOT_VALID_HASH) return (1); + next = m_next_z_plate_vec[index]; + return (0); + } + return (1); + } + +// int +// TriggerID::get_prev_in_phi(const IdentifierHash& id, IdentifierHash& prev) const +// { +// unsigned short index = id; +// if (index < m_prev_phi_wafer_vec.size()) { +// if (m_prev_phi_wafer_vec[index] == NOT_VALID_HASH) return (1); +// prev = m_prev_phi_wafer_vec[index]; +// return (0); +// } +// return (1); +// } + +// int +// TriggerID::get_next_in_phi(const IdentifierHash& id, IdentifierHash& next) const +// { +// unsigned short index = id; +// if (index < m_next_phi_wafer_vec.size()) { +// if (m_next_phi_wafer_vec[index] == NOT_VALID_HASH) return (1); +// next = m_next_phi_wafer_vec[index]; +// return (0); +// } +// return (1); +// } + +// int +// TriggerID::get_prev_in_eta(const IdentifierHash& id, IdentifierHash& prev) const +// { +// unsigned short index = id; +// if (index < m_prev_eta_wafer_vec.size()) { +// if (m_prev_eta_wafer_vec[index] == NOT_VALID_HASH) return (1); +// prev = m_prev_eta_wafer_vec[index]; +// return (0); +// } +// return (1); +// } + +// int +// TriggerID::get_next_in_eta(const IdentifierHash& id, IdentifierHash& next) const +// { +// unsigned short index = id; +// if (index < m_next_eta_wafer_vec.size()) { +// if (m_next_eta_wafer_vec[index] == NOT_VALID_HASH) return (1); +// next = m_next_eta_wafer_vec[index]; +// return (0); +// } +// return (1); +// } + +// int +// TriggerID::get_other_side (const IdentifierHash& hashId, IdentifierHash& other) const +// { +// if (m_dict) { +// // get max from dictionary +// Identifier id; +// IdContext wafer_context1 = wafer_context(); +// if(!get_id(hashId, id, &wafer_context1)) { +// other = side(id) ? hashId - 1 : hashId + 1; +// return (0); +// } +// } +// return (1); +// } + +int +TriggerID::init_neighbors(void) +{ + // + // create a vector(s) to retrieve the hashes for compact ids for + // plate neighbors. + // + MsgStream log(m_msgSvc, "TriggerID"); + + m_prev_z_plate_vec.resize(m_plate_hash_max, NOT_VALID_HASH); + m_next_z_plate_vec.resize(m_plate_hash_max, NOT_VALID_HASH); + for (unsigned int i = 0; i < m_full_plate_range.size(); i++) + { + const Range& range = m_full_plate_range[i]; + const Range::field& station_field = range[m_STATION_INDEX]; + const Range::field& plate_field = range[m_PLATE_INDEX]; + Range::const_identifier_factory first = range.factory_begin(); + Range::const_identifier_factory last = range.factory_end(); + for (; first != last; ++first) + { + const ExpandedIdentifier& exp_id = (*first); + ExpandedIdentifier::element_type previous_plate; + ExpandedIdentifier::element_type next_plate; + ExpandedIdentifier::element_type previous_station; + ExpandedIdentifier::element_type next_station; + bool pplate = plate_field.get_previous(exp_id[m_PLATE_INDEX], previous_plate); + bool nplate = plate_field.get_next (exp_id[m_PLATE_INDEX], next_plate); + bool pstation = station_field.get_previous(exp_id[m_STATION_INDEX], previous_station); + bool nstation = station_field.get_next (exp_id[m_STATION_INDEX], next_station); + + IdContext pcontext = plate_context(); + + IdentifierHash hash_id; + Identifier originalId = plate_id(exp_id[m_STATION_INDEX], + exp_id[m_PLATE_INDEX]); + + if (get_hash(originalId, hash_id, &pcontext)) + { + log << MSG::ERROR << " TriggerID::init_neighbors - unable to get hash, exp/compact " + << show_to_string(originalId, &pcontext) + << " " << (std::string)m_full_plate_range << endmsg; + return (1); + } + + // index for the subsequent arrays + unsigned short index = hash_id; + assert (hash_id < m_prev_z_plate_vec.size()); + assert (hash_id < m_next_z_plate_vec.size()); + + if (pplate) { + // Get previous plate hash id + ExpandedIdentifier expId = exp_id; + expId[m_PLATE_INDEX] = previous_plate; + Identifier id = plate_id(expId[m_STATION_INDEX], + expId[m_PLATE_INDEX]); + + if (get_hash(id, hash_id, &pcontext)) { + log << MSG::ERROR << " TriggerID::init_neighbors - unable to get previous plate hash, exp/compact " << id.getString() << " " + << endmsg; + return (1); + } + m_prev_z_plate_vec[index] = hash_id; + } + else if (pstation) + { + ExpandedIdentifier expId = exp_id; + expId[m_STATION_INDEX] = previous_station; + ExpandedIdentifier stationId; + stationId.add(expId[m_SCINT_INDEX]); + stationId.add(expId[m_TRIGGER_INDEX]); + stationId.add(previous_station); + Range prefix; + MultiRange stationPlateRange = m_dict->build_multirange(stationId, prefix, "plate"); + const Range::field& upstream_plate_field = range[m_PLATE_INDEX]; + if (upstream_plate_field.has_maximum()) + { + expId[m_PLATE_INDEX] = upstream_plate_field.get_maximum(); + Identifier id = plate_id(expId[m_STATION_INDEX], + expId[m_PLATE_INDEX]); + if (get_hash(id, hash_id, &pcontext)) { + log << MSG::ERROR << " TriggerID::init_neighbors - unable to get last plate hash from previous station, exp/compact " << id.getString() << " " + << endmsg; + return (1); + } + m_prev_z_plate_vec[index] = hash_id; + } + else + { + log << MSG::ERROR << "TriggerID::init_neighbors - unable to get plate_max for previous station, exp/compact " << originalId.getString() << " " + << endmsg; + return (1); + } + } + + if (nplate) { + // Get next plate hash id + ExpandedIdentifier expId = exp_id; + expId[m_PLATE_INDEX] = next_plate; + Identifier id = plate_id(expId[m_STATION_INDEX], + expId[m_PLATE_INDEX]); + + if (get_hash(id, hash_id, &pcontext)) { + log << MSG::ERROR << " TriggerID::init_neighbors - unable to get next plate hash, exp/compact " << id.getString() << " " + << endmsg; + return (1); + } + m_next_z_plate_vec[index] = hash_id; + } + else if (nstation) + { + ExpandedIdentifier expId = exp_id; + expId[m_STATION_INDEX] = next_station; + ExpandedIdentifier stationId; + stationId.add(expId[m_SCINT_INDEX]); + stationId.add(expId[m_TRIGGER_INDEX]); + stationId.add(next_station); + Range prefix; + MultiRange stationPlateRange = m_dict->build_multirange(stationId, prefix, "plate"); + const Range::field& downstream_plate_field = range[m_PLATE_INDEX]; + if (downstream_plate_field.has_minimum()) + { + expId[m_PLATE_INDEX] = downstream_plate_field.get_minimum(); + Identifier id = plate_id(expId[m_STATION_INDEX], + expId[m_PLATE_INDEX]); + if (get_hash(id, hash_id, &pcontext)) { + log << MSG::ERROR << " TriggerID::init_neighbors - unable to get previous plate hash from next station, exp/compact " << id.getString() << " " + << endmsg; + return (1); + } + m_next_z_plate_vec[index] = hash_id; + } + else + { + log << MSG::ERROR << "TriggerID::init_neighbors - unable to get plate_min for next station, exp/compact " << originalId.getString() << " " + << endmsg; + return (1); + } + } + + } + } + + // m_prev_phi_wafer_vec.resize(m_wafer_hash_max, NOT_VALID_HASH); + // m_next_phi_wafer_vec.resize(m_wafer_hash_max, NOT_VALID_HASH); + // m_prev_eta_wafer_vec.resize(m_wafer_hash_max, NOT_VALID_HASH); + // m_next_eta_wafer_vec.resize(m_wafer_hash_max, NOT_VALID_HASH); + + // for (unsigned int i = 0; i < m_full_wafer_range.size(); ++i) { + // const Range& range = m_full_wafer_range[i]; + // const Range::field& phi_field = range[m_PHI_MODULE_INDEX]; + // const Range::field& eta_field = range[m_ETA_MODULE_INDEX]; + // Range::const_identifier_factory first = range.factory_begin(); + // Range::const_identifier_factory last = range.factory_end(); + // for (; first != last; ++first) { + // const ExpandedIdentifier& exp_id = (*first); + // ExpandedIdentifier::element_type previous_phi; + // ExpandedIdentifier::element_type next_phi; + // ExpandedIdentifier::element_type previous_eta; + // ExpandedIdentifier::element_type next_eta; + // bool pphi = phi_field.get_previous(exp_id[m_PHI_MODULE_INDEX], previous_phi); + // bool nphi = phi_field.get_next (exp_id[m_PHI_MODULE_INDEX], next_phi); + // bool peta = eta_field.get_previous(exp_id[m_ETA_MODULE_INDEX], previous_eta); + // bool neta = eta_field.get_next (exp_id[m_ETA_MODULE_INDEX], next_eta); + + // IdContext wcontext = wafer_context(); + + // // First get primary hash id + // IdentifierHash hash_id; + // Identifier id = wafer_id(exp_id[m_BARREL_EC_INDEX], + // exp_id[m_LAYER_DISK_INDEX], + // exp_id[m_PHI_MODULE_INDEX], + // exp_id[m_ETA_MODULE_INDEX], + // exp_id[m_SIDE_INDEX]); + // if (get_hash(id, hash_id, &wcontext)) { + // log << MSG::ERROR << " TriggerID::init_neighbors - unable to get hash, exp/compact " + // << show_to_string(id, &wcontext) + // << " " << (std::string)m_full_wafer_range << endmsg; + // return (1); + // } + + // // index for the subsequent arrays + // unsigned short index = hash_id; + // assert (hash_id < m_prev_phi_wafer_vec.size()); + // assert (hash_id < m_next_phi_wafer_vec.size()); + // assert (hash_id < m_prev_eta_wafer_vec.size()); + // assert (hash_id < m_next_eta_wafer_vec.size()); + + // if (pphi) { + // // Get previous phi hash id + // ExpandedIdentifier expId = exp_id; + // expId[m_PHI_MODULE_INDEX] = previous_phi; + // Identifier id = wafer_id(expId[m_BARREL_EC_INDEX], + // expId[m_LAYER_DISK_INDEX], + // expId[m_PHI_MODULE_INDEX], + // expId[m_ETA_MODULE_INDEX], + // expId[m_SIDE_INDEX]); + // if (get_hash(id, hash_id, &wcontext)) { + // log << MSG::ERROR << " TriggerID::init_neighbors - unable to get previous phi hash, exp/compact " << id.getString() << " " + // << endmsg; + // return (1); + // } + // m_prev_phi_wafer_vec[index] = hash_id; + // } + + // if (nphi) { + // // Get next phi hash id + // ExpandedIdentifier expId = exp_id; + // expId[m_PHI_MODULE_INDEX] = next_phi; + // Identifier id = wafer_id(expId[m_BARREL_EC_INDEX], + // expId[m_LAYER_DISK_INDEX], + // expId[m_PHI_MODULE_INDEX], + // expId[m_ETA_MODULE_INDEX], + // expId[m_SIDE_INDEX]); + // if (get_hash(id, hash_id, &wcontext)) { + // log << MSG::ERROR << " TriggerID::init_neighbors - unable to get next phi hash, exp/compact " << id.getString() << + // " " << MSG::hex << id.getString() << MSG::dec << endmsg; + // return (1); + // } + // m_next_phi_wafer_vec[index] = hash_id; + // } + + // if (peta) { + // // Get previous eta hash id + // ExpandedIdentifier expId = exp_id; + // expId[m_ETA_MODULE_INDEX] = previous_eta; + // Identifier id = wafer_id(expId[m_BARREL_EC_INDEX], + // expId[m_LAYER_DISK_INDEX], + // expId[m_PHI_MODULE_INDEX], + // expId[m_ETA_MODULE_INDEX], + // expId[m_SIDE_INDEX]); + // if (get_hash(id, hash_id, &wcontext)) { + // log << MSG::ERROR << " TriggerID::init_neighbors - unable to get previous eta hash, exp/compact " << id.getString() + // << " " << std::endl; + // return (1); + // } + // m_prev_eta_wafer_vec[index] = hash_id; + // } + + // if (neta) { + // // Get next eta hash id + // ExpandedIdentifier expId = exp_id; + // expId[m_ETA_MODULE_INDEX] = next_eta; + // Identifier id = wafer_id(expId[m_BARREL_EC_INDEX], + // expId[m_LAYER_DISK_INDEX], + // expId[m_PHI_MODULE_INDEX], + // expId[m_ETA_MODULE_INDEX], + // expId[m_SIDE_INDEX]); + // if (get_hash(id, hash_id, &wcontext)) { + // log << MSG::ERROR << " TriggerID::init_neighbors - unable to get next eta hash, exp/compact " << id.getString() + // << " " << endmsg; + // return (1); + // } + // m_next_eta_wafer_vec[index] = hash_id; + // } + + +// std::cout << " TriggerID::init_neighbors " +// << " phi, previous, next " << id[m_PHI_MODULE_INDEX] +// << " " << pphi +// << " " << previous_phi +// << " " << nphi +// << " " << next_phi +// << " eta, previous, next " << id[m_ETA_MODULE_INDEX] +// << " " << peta +// << " " << previous_eta +// << " " << neta +// << " " << next_eta +// << " id " << (std::string)(*first) +// << std::endl; + // } + // } + return (0); +} + + + +int +TriggerID::initLevelsFromDict() +{ + + + MsgStream log(m_msgSvc, "TriggerID"); + if(!m_dict) { + log << MSG::ERROR << " TriggerID::initLevelsFromDict - dictionary NOT initialized " << endmsg; + return (1); + } + + // Find out which identifier field corresponds to each level. Use + // names to find each field/leve. + + m_SCINT_INDEX = 999; + m_TRIGGER_INDEX = 999; + m_STATION_INDEX = 999; + m_PLATE_INDEX = 999; + m_PMT_INDEX = 999; + + // Save index to a Trigger region for unpacking + ExpandedIdentifier id; + id << scint_field_value() << trigger_field_value(); + if (m_dict->find_region(id, m_trigger_region_index)) { + log << MSG::ERROR << "TriggerID::initLevelsFromDict - unable to find trigger region index: id, reg " + << (std::string)id << " " << m_trigger_region_index + << endmsg; + return (1); + } + + // Find a Trigger region + IdDictField* field = m_dict->find_field("subdet"); + if (field) { + m_SCINT_INDEX = field->m_index; + } + else { + log << MSG::ERROR << "TriggerID::initLevelsFromDict - unable to find 'subdet' field " << endmsg; + return (1); + } + field = m_dict->find_field("part"); + if (field) { + m_TRIGGER_INDEX = field->m_index; + } + else { + log << MSG::ERROR << "TriggerID::initLevelsFromDict - unable to find 'part' field " << endmsg; + return (1); + } + field = m_dict->find_field("station"); + if (field) { + m_STATION_INDEX = field->m_index; + } + else { + log << MSG::ERROR << "TriggerID::initLevelsFromDict - unable to find 'station' field " << endmsg; + return (1); + } + field = m_dict->find_field("plate"); + if (field) { + m_PLATE_INDEX = field->m_index; + } + else { + log << MSG::ERROR<< "TriggerID::initLevelsFromDict - unable to find 'plate' field " << endmsg; + return (1); + } + field = m_dict->find_field("pmt"); + if (field) { + m_PMT_INDEX = field->m_index; + } + else { + log << MSG::ERROR << "TriggerID::initLevelsFromDict - unable to find 'pmt' field " << endmsg; + return (1); + } + + // Set the field implementations + + const IdDictRegion& region = *m_dict->m_regions[m_trigger_region_index]; + + m_scint_impl = region.m_implementation[m_SCINT_INDEX]; + m_trigger_impl = region.m_implementation[m_TRIGGER_INDEX]; + m_station_impl = region.m_implementation[m_STATION_INDEX]; + m_plate_impl = region.m_implementation[m_PLATE_INDEX]; + m_pmt_impl = region.m_implementation[m_PMT_INDEX]; + + if (m_msgSvc) { + log << MSG::DEBUG << "decode index and bit fields for each level: " << endmsg; + log << MSG::DEBUG << "scint " << m_scint_impl.show_to_string() << endmsg; + log << MSG::DEBUG << "trigger " << m_trigger_impl.show_to_string() << endmsg; + log << MSG::DEBUG << "station " << m_station_impl.show_to_string() << endmsg; + log << MSG::DEBUG << "plate " << m_plate_impl.show_to_string() << endmsg; + log << MSG::DEBUG << "pmt " << m_pmt_impl.show_to_string() << endmsg; + } + else { + std::cout << " DEBUG decode index and bit fields for each level: " << std::endl; + std::cout << " DEBUG scint " << m_scint_impl.show_to_string() << std::endl; + std::cout << " DEBUG trigger " << m_trigger_impl.show_to_string() << std::endl; + std::cout << " DEBUG station " << m_station_impl.show_to_string() << std::endl; + std::cout << " DEBUG plate " << m_plate_impl.show_to_string() << std::endl; + std::cout << " DEBUG pmt " << m_pmt_impl.show_to_string() << std::endl; + } + + std::cout << "scint " << m_scint_impl.decode_index() << " " + << (std::string)m_scint_impl.ored_field() << " " + << std::hex << m_scint_impl.mask() << " " + << m_scint_impl.zeroing_mask() << " " + << std::dec << m_scint_impl.shift() << " " + << m_scint_impl.bits() << " " + << m_scint_impl.bits_offset() + << std::endl; + std::cout << "trigger" << m_trigger_impl.decode_index() << " " + << (std::string)m_trigger_impl.ored_field() << " " + << std::hex << m_trigger_impl.mask() << " " + << m_trigger_impl.zeroing_mask() << " " + << std::dec << m_trigger_impl.shift() << " " + << m_trigger_impl.bits() << " " + << m_trigger_impl.bits_offset() + << std::endl; + std::cout << "station"<< m_station_impl.decode_index() << " " + << (std::string)m_station_impl.ored_field() << " " + << std::hex << m_station_impl.mask() << " " + << m_station_impl.zeroing_mask() << " " + << std::dec << m_station_impl.shift() << " " + << m_station_impl.bits() << " " + << m_station_impl.bits_offset() + << std::endl; + std::cout << "plate" << m_plate_impl.decode_index() << " " + << (std::string)m_plate_impl.ored_field() << " " + << std::hex << m_plate_impl.mask() << " " + << m_plate_impl.zeroing_mask() << " " + << std::dec << m_plate_impl.shift() << " " + << m_plate_impl.bits() << " " + << m_plate_impl.bits_offset() + << std::endl; + std::cout << "pmt" << m_pmt_impl.decode_index() << " " + << (std::string)m_pmt_impl.ored_field() << " " + << std::hex << m_pmt_impl.mask() << " " + << m_pmt_impl.zeroing_mask() << " " + << std::dec << m_pmt_impl.shift() << " " + << m_pmt_impl.bits() << " " + << m_pmt_impl.bits_offset() + << std::endl; + + return (0); +} + +TriggerID::size_type +TriggerID::plate_hash_max (void) const +{ + return m_plate_hash_max; +} + +TriggerID::size_type +TriggerID::pmt_hash_max (void) const +{ + return m_pmt_hash_max; +} + +TriggerID::const_id_iterator TriggerID::plate_begin (void) const +{ + return (m_plate_vec.begin()); +} + +TriggerID::const_id_iterator TriggerID::plate_end (void) const +{ + return (m_plate_vec.end()); +} + +TriggerID::const_expanded_id_iterator TriggerID::pmt_begin (void) const +{ + return (m_full_pmt_range.factory_begin()); +} + +TriggerID::const_expanded_id_iterator TriggerID::pmt_end (void) const +{ + return (m_full_pmt_range.factory_end()); +} + +// From hash get Identifier +int +TriggerID::get_id (const IdentifierHash& hash_id, + Identifier& id, + const IdContext* context) const +{ + + int result = 1; + id.clear(); + + size_t begin = (context) ? context->begin_index(): 0; + // cannot get hash if end is 0: + size_t end = (context) ? context->end_index() : 0; + if (0 == begin) { + // No hashes yet for ids with prefixes + if (m_PLATE_INDEX == end) { + if (hash_id < (unsigned int)(m_plate_vec.end() - m_plate_vec.begin())) { + id = m_plate_vec[hash_id]; + result = 0; + } + } + else if (m_PMT_INDEX == end) { + // Do not know how to calculate strip id from hash yet!! + std::cout << "Do not know how to calculate pmt id from hash yet!!" << std::endl; + } + } + return (result); +} + +void +TriggerID::get_expanded_id (const Identifier& id, + ExpandedIdentifier& exp_id, + const IdContext* context) const +{ + exp_id.clear(); + exp_id << scint_field_value() + << trigger_field_value() + << station(id) + << plate(id); + if(!context || context->end_index() == m_PMT_INDEX) + { + exp_id << pmt(id); + } +} + +int +TriggerID::get_hash (const Identifier& id, + IdentifierHash& hash_id, + const IdContext* context) const +{ + + // Get the hash code from either a vec (for plate) or calculate + // it (pmts). For the former, we convert to compact and call + // get_hash again. For the latter, we calculate the hash from the + // Identifier. + + int result = 1; + hash_id = 0; + size_t begin = (context) ? context->begin_index(): 0; + size_t end = (context) ? context->end_index() : 0; + if (0 == begin) { + // No hashes yet for ids with prefixes + if (m_PLATE_INDEX == end) { + hash_id = plate_hash(id); + if (hash_id.is_valid()) result = 0; + } + else if (context && context->end_index() == m_PMT_INDEX) { + // Must calculate for strip hash + ExpandedIdentifier new_id; + get_expanded_id(id, new_id); + hash_id = m_full_pmt_range.cardinalityUpTo(new_id); + result = 0; + } + } + return (result); +} + + +void +TriggerID::test_plate_packing (void) const +{ + MsgStream log(m_msgSvc, "TriggerID"); + + if (m_dict) { + + int nids = 0; + int nerr = 0; + IdContext context = plate_context(); + const_id_iterator first = m_plate_vec.begin(); + const_id_iterator last = m_plate_vec.end(); + for (; first != last; ++first, ++nids) { + Identifier id = (*first); + ExpandedIdentifier exp_id; + get_expanded_id(id, exp_id, &context); + Identifier new_id = plate_id(exp_id[m_STATION_INDEX], + exp_id[m_PLATE_INDEX]); + if (id != new_id) { + log << MSG::ERROR << "TriggerID::test_plate_packing: new and old compacts not equal. New/old/expanded ids " + << MSG::hex << show_to_string(id) << " " << show_to_string(new_id) << " " << MSG::dec + << (std::string)exp_id << endmsg; + nerr++; + continue; + } + // check station id + if (!exp_id[m_PLATE_INDEX]) { + + Identifier new_id1 = station_id(exp_id[m_STATION_INDEX]); + if (id != new_id1) { + log << MSG::ERROR << "TriggerID::test_plate_packing: new and old station ids not equal. New/old/expanded ids " + << MSG::hex << show_to_string(id) << " " << show_to_string(new_id1) << " " << MSG::dec + << (std::string)exp_id << endmsg; + nerr++; + continue; + } + } + } + + if (m_msgSvc) { + log << MSG::DEBUG << "TriggerID::test_plate_packing: tested plate and station ids. nids, errors " + << nids << " " << nerr << endmsg; + } + else { + std::cout << " DEBUG TriggerID::test_plate_packing: tested plate and station ids. nids, errors " + << nids << " " << nerr << std::endl; + } + + nids = 0; + context = pmt_context(); + const_expanded_id_iterator first_trigger = pmt_begin(); + const_expanded_id_iterator last_trigger = pmt_end(); + for (; first_trigger != last_trigger; ++first_trigger, ++nids) { + // if (nids%10000 != 1) continue; + const ExpandedIdentifier& exp_id = *first_trigger; + ExpandedIdentifier new_exp_id; + + Identifier id = plate_id(exp_id[m_STATION_INDEX], + exp_id[m_PLATE_INDEX]); + get_expanded_id(id, new_exp_id, &context); + if (exp_id[0] != new_exp_id[0] || + exp_id[1] != new_exp_id[1] || + exp_id[2] != new_exp_id[2] || + exp_id[3] != new_exp_id[3] ) + { + log << MSG::ERROR << "TriggerID::test_plate_packing: new and old ids not equal. New/old/compact ids " + << (std::string)new_exp_id << " " << (std::string)exp_id + << " " << show_to_string(id) << endmsg; + continue; + } + + Identifier pmtid ; + Identifier pmtid1 ; + pmtid = pmt_id ( + exp_id[m_STATION_INDEX], + exp_id[m_PLATE_INDEX], + exp_id[m_PMT_INDEX]); + + pmtid1 = pmt_id ( + station(pmtid), + plate(pmtid), + pmt(pmtid)); + + if (pmtid != pmtid1) { + log << MSG::ERROR << "TriggerID::test_plate_packing: new and old pixel ids not equal. New/old ids " + << " " << show_to_string(pmtid1) << " " + << show_to_string(pmtid) << endmsg; + } + } + + if (m_msgSvc) { + log << MSG::DEBUG << "TriggerID::test_plate_packing: Successful tested " + << nids << " ids. " + << endmsg; + } + else { + std::cout << " DEBUG TriggerID::test_plate_packing: Successful tested " + << nids << " ids. " + << std::endl; + } + } + else { + log << MSG::ERROR << "TriggerID::test_plate_packing: Unable to test plate packing - no dictionary has been defined. " + << endmsg; + } +} + diff --git a/Scintillator/ScintDetDescr/ScintIdentifier/src/VetoID.cxx b/Scintillator/ScintDetDescr/ScintIdentifier/src/VetoID.cxx index 1d55a61947dec1ffd7017994a82528549c1a9ecd..3bd7a627d006f7d53dd361b23189ed6774440355 100644 --- a/Scintillator/ScintDetDescr/ScintIdentifier/src/VetoID.cxx +++ b/Scintillator/ScintDetDescr/ScintIdentifier/src/VetoID.cxx @@ -974,7 +974,7 @@ VetoID::test_plate_packing (void) const const_expanded_id_iterator first_veto = pmt_begin(); const_expanded_id_iterator last_veto = pmt_end(); for (; first_veto != last_veto; ++first_veto, ++nids) { - if (nids%10000 != 1) continue; + // if (nids%10000 != 1) continue; const ExpandedIdentifier& exp_id = *first_veto; ExpandedIdentifier new_exp_id; @@ -984,8 +984,8 @@ VetoID::test_plate_packing (void) const if (exp_id[0] != new_exp_id[0] || exp_id[1] != new_exp_id[1] || exp_id[2] != new_exp_id[2] || - exp_id[3] != new_exp_id[3] || - exp_id[4] != new_exp_id[4]) { + exp_id[3] != new_exp_id[3]) + { log << MSG::ERROR << "VetoID::test_plate_packing: new and old ids not equal. New/old/compact ids " << (std::string)new_exp_id << " " << (std::string)exp_id << " " << show_to_string(id) << endmsg; diff --git a/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/PreshowerDetectorManager.h b/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/PreshowerDetectorManager.h new file mode 100644 index 0000000000000000000000000000000000000000..0a7672b89d75d41ed524ee0b6d816511a57c887e --- /dev/null +++ b/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/PreshowerDetectorManager.h @@ -0,0 +1,163 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// PreshowerDetectorManager.h +/////////////////////////////////////////////////////////////////// +// (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#ifndef SCINTREADOUTGEOMETRY_PRESHOWERDETECTORMANAGER_H +#define SCINTREADOUTGEOMETRY_PRESHOWERDETECTORMANAGER_H + +#include "GeoPrimitives/GeoPrimitives.h" + +#include "GeoModelKernel/GeoVPhysVol.h" + +#include "ScintReadoutGeometry/ScintDetectorManager.h" +#include "ScintReadoutGeometry/ScintDetectorElementCollection.h" +#include "ScintReadoutGeometry/ScintDD_Defs.h" + +#include "ScintIdentifier/PreshowerID.h" + +class StoreGateSvc; +class Identifier; +class IdentifierHash; +class GeoAlignableTransform; +class GeoVFullPhysVol; +class GeoVPhysVol; +class GeoVAlignmentStore; +class CondAttrListCollection; + +namespace ScintDD { + + class ScintDetectorElement; + class ExtendedAlignableTransform; + class PreshowerDetectorDesign; + + /** @class PreshowerDetectorManager + + Dedicated detector manager extending the functionality of the ScintDetectorManager + with dedicated Preshower information, access. + + @author: Grant Gorfine + - modified and maintained by Nick Styles & Andreas Salzburger + - modified for FASER by D. Casper + */ + + class PreshowerDetectorManager : public ScintDetectorManager { + + public: + + // Constructor + PreshowerDetectorManager( StoreGateSvc* detStore ); + + // Destructor + virtual ~PreshowerDetectorManager(); + + /** Access Raw Geometry */ + virtual unsigned int getNumTreeTops() const override; + virtual PVConstLink getTreeTop(unsigned int i) const override; + /** Add tree top */ + void addTreeTop(PVLink); + + + // + // Access Readout Elements + // + + /** access to individual elements via Identifier */ + virtual ScintDetectorElement * getDetectorElement(const Identifier &id) const override; + + /** access to individual elements via IdentifierHash */ + virtual ScintDetectorElement * getDetectorElement(const IdentifierHash &idHash) const override; + + /** access to individual elements via module numbering schema */ + ScintDetectorElement * getDetectorElement(int station, int plate) const; + + /** access to whole collectiom via iterators */ + virtual const ScintDetectorElementCollection * getDetectorElementCollection() const override; + virtual ScintDetectorElementCollection::const_iterator getDetectorElementBegin() const override; + virtual ScintDetectorElementCollection::const_iterator getDetectorElementEnd() const override; + + /** Add elememts during construction */ + virtual void addDetectorElement(ScintDetectorElement * element) override; + + /** Add alignable transforms. No access to these, they will be changed by manager: */ + virtual void addAlignableTransform (int level, + const Identifier &id, + GeoAlignableTransform *xf, + const GeoVFullPhysVol * child); + + /** As above but does a dynamic_cast to GeoVFullPhysVol */ + virtual void addAlignableTransform (int level, + const Identifier &id, + GeoAlignableTransform *xf, + const GeoVPhysVol * child); + + /** Initialize the neighbours. This can only be done when all elements are built. */ + virtual void initNeighbours() override; + + /** Check identifier is for this detector */ + virtual bool identifierBelongs(const Identifier & id) const override; + + /** Access to module design, casts to PreshowerDetectorDesign */ + const ScintDetectorDesign * getPreshowerDesign() const; + + /** Process new global DB folders for L1 and L2 **/ + virtual + bool processGlobalAlignment(const std::string &, int level, FrameType frame, + const CondAttrListCollection* obj, + GeoVAlignmentStore* alignStore) const override; + + // comply with ScintDetectorManager interface + bool processSpecialAlignment(const std::string & key, + ScintDD::AlignFolderType alignfolder) const override; + + bool processSpecialAlignment(const std::string& key, + const CondAttrListCollection* obj=nullptr, + GeoVAlignmentStore* alignStore=nullptr) const override; + + + private: + /** implements the main alignment update for delta transforms in different frames, + it translates into the LocalDelta or GlobalDelta function of ScintDetectorManager + */ + virtual bool setAlignableTransformDelta(int level, + const Identifier & id, + const Amg::Transform3D & delta, + FrameType frame, + GeoVAlignmentStore* alignStore) const override; + + /** Prevent copy and assignment */ + const PreshowerDetectorManager & operator=(const PreshowerDetectorManager &right); + PreshowerDetectorManager(const PreshowerDetectorManager &right); + + virtual const PreshowerID* getIdHelper() const override; + + // Private member data + std::vector<PVLink> m_volume; + ScintDetectorElementCollection m_elementCollection; + typedef std::map<Identifier, ExtendedAlignableTransform *> AlignableTransformMap; + std::vector< AlignableTransformMap > m_higherAlignableTransforms; + std::vector< ExtendedAlignableTransform *> m_alignableTransforms; + const PreshowerID* m_idHelper; + + /** This variable switches the how the local alignment corrections are applied + If true they will be calcualted on top of all of other corrections but in the default reference frame + If false they will be calcualted on top of all of other corrections but in the globally aligned reference frame + */ + bool m_isLogical; + + + }; + +} // namespace ScintDD + +#ifndef GAUDI_NEUTRAL +#include "AthenaKernel/CLASS_DEF.h" +CLASS_DEF(ScintDD::PreshowerDetectorManager, 33913008, 1) +#endif + +#endif // SCINTREADOUTGEOMETRY_PRESHOWERDETECTORMANAGER_H diff --git a/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/TriggerDetectorManager.h b/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/TriggerDetectorManager.h new file mode 100644 index 0000000000000000000000000000000000000000..f6f34077dfd7375a1df3be022eff109570090b1d --- /dev/null +++ b/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/TriggerDetectorManager.h @@ -0,0 +1,163 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// TriggerDetectorManager.h +/////////////////////////////////////////////////////////////////// +// (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#ifndef SCINTREADOUTGEOMETRY_TRIGGERDETECTORMANAGER_H +#define SCINTREADOUTGEOMETRY_TRIGGERDETECTORMANAGER_H + +#include "GeoPrimitives/GeoPrimitives.h" + +#include "GeoModelKernel/GeoVPhysVol.h" + +#include "ScintReadoutGeometry/ScintDetectorManager.h" +#include "ScintReadoutGeometry/ScintDetectorElementCollection.h" +#include "ScintReadoutGeometry/ScintDD_Defs.h" + +#include "ScintIdentifier/TriggerID.h" + +class StoreGateSvc; +class Identifier; +class IdentifierHash; +class GeoAlignableTransform; +class GeoVFullPhysVol; +class GeoVPhysVol; +class GeoVAlignmentStore; +class CondAttrListCollection; + +namespace ScintDD { + + class ScintDetectorElement; + class ExtendedAlignableTransform; + class TriggerDetectorDesign; + + /** @class TriggerDetectorManager + + Dedicated detector manager extending the functionality of the ScintDetectorManager + with dedicated Trigger information, access. + + @author: Grant Gorfine + - modified and maintained by Nick Styles & Andreas Salzburger + - modified for FASER by D. Casper + */ + + class TriggerDetectorManager : public ScintDetectorManager { + + public: + + // Constructor + TriggerDetectorManager( StoreGateSvc* detStore ); + + // Destructor + virtual ~TriggerDetectorManager(); + + /** Access Raw Geometry */ + virtual unsigned int getNumTreeTops() const override; + virtual PVConstLink getTreeTop(unsigned int i) const override; + /** Add tree top */ + void addTreeTop(PVLink); + + + // + // Access Readout Elements + // + + /** access to individual elements via Identifier */ + virtual ScintDetectorElement * getDetectorElement(const Identifier &id) const override; + + /** access to individual elements via IdentifierHash */ + virtual ScintDetectorElement * getDetectorElement(const IdentifierHash &idHash) const override; + + /** access to individual elements via module numbering schema */ + ScintDetectorElement * getDetectorElement(int station, int plate) const; + + /** access to whole collectiom via iterators */ + virtual const ScintDetectorElementCollection * getDetectorElementCollection() const override; + virtual ScintDetectorElementCollection::const_iterator getDetectorElementBegin() const override; + virtual ScintDetectorElementCollection::const_iterator getDetectorElementEnd() const override; + + /** Add elememts during construction */ + virtual void addDetectorElement(ScintDetectorElement * element) override; + + /** Add alignable transforms. No access to these, they will be changed by manager: */ + virtual void addAlignableTransform (int level, + const Identifier &id, + GeoAlignableTransform *xf, + const GeoVFullPhysVol * child); + + /** As above but does a dynamic_cast to GeoVFullPhysVol */ + virtual void addAlignableTransform (int level, + const Identifier &id, + GeoAlignableTransform *xf, + const GeoVPhysVol * child); + + /** Initialize the neighbours. This can only be done when all elements are built. */ + virtual void initNeighbours() override; + + /** Check identifier is for this detector */ + virtual bool identifierBelongs(const Identifier & id) const override; + + /** Access to module design, casts to TriggerDetectorDesign */ + const ScintDetectorDesign * getTriggerDesign() const; + + /** Process new global DB folders for L1 and L2 **/ + virtual + bool processGlobalAlignment(const std::string &, int level, FrameType frame, + const CondAttrListCollection* obj, + GeoVAlignmentStore* alignStore) const override; + + // comply with ScintDetectorManager interface + bool processSpecialAlignment(const std::string & key, + ScintDD::AlignFolderType alignfolder) const override; + + bool processSpecialAlignment(const std::string& key, + const CondAttrListCollection* obj=nullptr, + GeoVAlignmentStore* alignStore=nullptr) const override; + + + private: + /** implements the main alignment update for delta transforms in different frames, + it translates into the LocalDelta or GlobalDelta function of ScintDetectorManager + */ + virtual bool setAlignableTransformDelta(int level, + const Identifier & id, + const Amg::Transform3D & delta, + FrameType frame, + GeoVAlignmentStore* alignStore) const override; + + /** Prevent copy and assignment */ + const TriggerDetectorManager & operator=(const TriggerDetectorManager &right); + TriggerDetectorManager(const TriggerDetectorManager &right); + + virtual const TriggerID* getIdHelper() const override; + + // Private member data + std::vector<PVLink> m_volume; + ScintDetectorElementCollection m_elementCollection; + typedef std::map<Identifier, ExtendedAlignableTransform *> AlignableTransformMap; + std::vector< AlignableTransformMap > m_higherAlignableTransforms; + std::vector< ExtendedAlignableTransform *> m_alignableTransforms; + const TriggerID* m_idHelper; + + /** This variable switches the how the local alignment corrections are applied + If true they will be calcualted on top of all of other corrections but in the default reference frame + If false they will be calcualted on top of all of other corrections but in the globally aligned reference frame + */ + bool m_isLogical; + + + }; + +} // namespace ScintDD + +#ifndef GAUDI_NEUTRAL +#include "AthenaKernel/CLASS_DEF.h" +CLASS_DEF(ScintDD::TriggerDetectorManager, 199337809, 1) +#endif + +#endif // SCINTREADOUTGEOMETRY_TRIGGERDETECTORMANAGER_H diff --git a/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/PreshowerDetectorManager.cxx b/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/PreshowerDetectorManager.cxx new file mode 100644 index 0000000000000000000000000000000000000000..a49b9faba812482b2b3100dd28d059f6464204b7 --- /dev/null +++ b/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/PreshowerDetectorManager.cxx @@ -0,0 +1,348 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "ScintReadoutGeometry/PreshowerDetectorManager.h" + +#include "AthenaBaseComps/AthMsgStreamMacros.h" +#include "AthenaPoolUtilities/CondAttrListCollection.h" +#include "GeoPrimitives/CLHEPtoEigenConverter.h" +#include "Identifier/Identifier.h" +#include "Identifier/IdentifierHash.h" +#include "ScintIdentifier/PreshowerID.h" +#include "ScintReadoutGeometry/ScintDetectorElementCollection.h" +#include "ScintReadoutGeometry/ScintDetectorElement.h" +#include "ScintReadoutGeometry/ExtendedAlignableTransform.h" +#include "ScintReadoutGeometry/ScintDetectorDesign.h" +#include "StoreGate/StoreGateSvc.h" + +#include <iostream> + +namespace ScintDD { + + const int FIRST_HIGHER_LEVEL = 1; + + PreshowerDetectorManager::PreshowerDetectorManager( StoreGateSvc* detStore ) + : ScintDetectorManager(detStore, "Preshower"), + m_idHelper(0), + m_isLogical(false) // Change to true to change the definition of local module corrections + { + // + // Initialized the Identifier helper. + // + StatusCode sc = detStore->retrieve(m_idHelper, "PreshowerID"); + if (sc.isFailure()) { + ATH_MSG_ERROR("Could not retrieve Preshower id helper"); + } + // Initialize the collections. + if (m_idHelper) { + m_elementCollection.resize(m_idHelper->plate_hash_max()); + m_alignableTransforms.resize(m_idHelper->plate_hash_max()); + // m_moduleAlignableTransforms.resize(m_idHelper->plate_hash_max()); + } + } + + + + PreshowerDetectorManager::~PreshowerDetectorManager() + { + // Clean up + for (size_t i=0; i < m_volume.size(); i++) { + m_volume[i]->unref(); + } + + for (size_t j=0; j < m_higherAlignableTransforms.size(); j++){ + AlignableTransformMap::iterator iterMap; + for (iterMap = m_higherAlignableTransforms[j].begin(); + iterMap != m_higherAlignableTransforms[j].end(); + ++iterMap) { + delete iterMap->second; + } + } + + for (size_t k=0; k < m_alignableTransforms.size(); k++){ + delete m_alignableTransforms[k]; + } + + // for (size_t l=0; l < m_moduleAlignableTransforms.size(); l++){ + // delete m_moduleAlignableTransforms[l]; + // } + } + + unsigned int PreshowerDetectorManager::getNumTreeTops() const + { + return m_volume.size(); + } + + PVConstLink PreshowerDetectorManager::getTreeTop(unsigned int i) const + { + return m_volume[i]; + } + + void PreshowerDetectorManager::addTreeTop(PVLink vol){ + vol->ref(); + m_volume.push_back(vol); + } + + + ScintDetectorElement* PreshowerDetectorManager::getDetectorElement(const Identifier & id) const + { + // NB the id helpers implementation for getting a hash is not optimal. + // Essentially does a binary search. + // Make sure it is a wafer Id + Identifier waferId = m_idHelper->plate_id(id); + IdentifierHash idHash = m_idHelper->plate_hash(waferId); + if (idHash.is_valid()) { + return m_elementCollection[idHash]; + } else { + return 0; + } + } + + ScintDetectorElement* PreshowerDetectorManager::getDetectorElement(const IdentifierHash & idHash) const + { + return m_elementCollection[idHash]; + } + + ScintDetectorElement* PreshowerDetectorManager::getDetectorElement(int station, int plate) const + { + return getDetectorElement(m_idHelper->plate_id(station, plate)); + } + + const ScintDetectorElementCollection* PreshowerDetectorManager::getDetectorElementCollection() const + { + return &m_elementCollection; + } + + ScintDetectorElementCollection::const_iterator PreshowerDetectorManager::getDetectorElementBegin() const + { + return m_elementCollection.begin(); + } + + ScintDetectorElementCollection::const_iterator PreshowerDetectorManager::getDetectorElementEnd() const + { + return m_elementCollection.end(); + } + + + void PreshowerDetectorManager::addDetectorElement(ScintDetectorElement * element) + { + IdentifierHash idHash = element->identifyHash(); + if (idHash >= m_elementCollection.size()) + throw std::runtime_error("PreshowerDetectorManager: Error adding detector element."); + m_elementCollection[idHash] = element; + } + + void PreshowerDetectorManager::initNeighbours() + { + ScintDetectorElementCollection::iterator iter; + + // Loop over all elements and set the neighbours + for (iter = m_elementCollection.begin(); iter != m_elementCollection.end(); ++iter){ + + ScintDetectorElement * element = *iter; + if (element) { + + IdentifierHash idHash = element->identifyHash(); + IdentifierHash idHashOther; + + int result; + // If no neighbour, result != 0 in which case we leave neighbour as null + result = m_idHelper->get_next_in_z(idHash, idHashOther); + if (result==0) element->setNextInZ(m_elementCollection[idHashOther]); + + result = m_idHelper->get_prev_in_z(idHash, idHashOther); + if (result==0) element->setPrevInZ(m_elementCollection[idHashOther]); + } + } + } + + const PreshowerID* PreshowerDetectorManager::getIdHelper() const + { + return m_idHelper; + } + + + bool PreshowerDetectorManager::setAlignableTransformDelta(int level, + const Identifier & id, + const Amg::Transform3D & delta, + FrameType frame, + GeoVAlignmentStore* alignStore) const + { + + if (level == 0) { // 0 - At the element level + + // We retrieve it via a hashId. + IdentifierHash idHash = m_idHelper->plate_hash(id); + if (!idHash.is_valid()) return false; + + if (frame == ScintDD::global) { // global shift + // Its a global transform + return setAlignableTransformGlobalDelta(m_alignableTransforms[idHash], delta, alignStore); + + } else if (frame == ScintDD::local) { // local shift + + ScintDetectorElement * element = m_elementCollection[idHash]; + if (!element) return false; + + + // Its a local transform + //See header file for definition of m_isLogical + if( m_isLogical ){ + //Ensure cache is up to date and use the alignment corrected local to global transform + element->setCache(); + return setAlignableTransformLocalDelta(m_alignableTransforms[idHash], element->transform(), delta, alignStore); + } else + //Use default local to global transform + return setAlignableTransformLocalDelta(m_alignableTransforms[idHash], element->defTransform(), delta, alignStore); + + } else { + // other not supported + ATH_MSG_WARNING("Frames other than global or local are not supported."); + return false; + } + } else { // higher level + if (frame != ScintDD::global) { + ATH_MSG_WARNING("Non global shift at higher levels is not supported."); + return false; + } + + int index = level - FIRST_HIGHER_LEVEL; // level 0 is treated separately. + if (index >= static_cast<int>(m_higherAlignableTransforms.size())) return false; + + // We retrieve it from a map. + AlignableTransformMap::const_iterator iter; + iter = m_higherAlignableTransforms[index].find(id); + if (iter == m_higherAlignableTransforms[index].end()) return false; + + // Its a global transform + return setAlignableTransformGlobalDelta(iter->second, delta, alignStore); + } + } + + void PreshowerDetectorManager::addAlignableTransform (int level, + const Identifier & id, + GeoAlignableTransform *transform, + const GeoVPhysVol * child) + { + if (m_idHelper) { + + const GeoVFullPhysVol * childFPV = dynamic_cast<const GeoVFullPhysVol *>(child); + if (!childFPV) { + ATH_MSG_ERROR("Child of alignable transform is not a full physical volume"); + } else { + addAlignableTransform (level, id, transform, childFPV); + } + } + } + + void PreshowerDetectorManager::addAlignableTransform (int level, + const Identifier & id, + GeoAlignableTransform *transform, + const GeoVFullPhysVol * child) + { + if (m_idHelper) { + if (level == 0) { + // Element + IdentifierHash idHash = m_idHelper->plate_hash(id); + if (idHash.is_valid()) { + m_alignableTransforms[idHash]= new ExtendedAlignableTransform(transform, child); + } + } else { + // Higher levels are saved in a map. NB level=0 is treated above. + int index = level - FIRST_HIGHER_LEVEL; // level 0 is treated separately. + if (index >= static_cast<int>(m_higherAlignableTransforms.size())) m_higherAlignableTransforms.resize(index+1); + m_higherAlignableTransforms[index][id] = new ExtendedAlignableTransform(transform, child); + } + } + } + + bool + PreshowerDetectorManager::identifierBelongs(const Identifier & id) const + { + return getIdHelper()->is_preshower(id); + } + + + const ScintDetectorDesign* PreshowerDetectorManager::getPreshowerDesign() const + { + return dynamic_cast<const ScintDetectorDesign *>(getDesign()); + } + + // New global alignment folders + bool PreshowerDetectorManager::processGlobalAlignment(const std::string & key, int level, FrameType frame, + const CondAttrListCollection* obj, GeoVAlignmentStore* alignStore) const + { + ATH_MSG_INFO("Processing new global alignment containers with key " << key << " in the " << frame << " frame at level "); + + const CondAttrListCollection* atrlistcol=obj; + if(atrlistcol==nullptr and m_detStore->retrieve(atrlistcol,key)!=StatusCode::SUCCESS) { + ATH_MSG_INFO("Cannot find new global align Container for key " + << key << " - no new global alignment "); + return false; + } + + bool alignmentChange = false; + Identifier ident=Identifier(); + + // loop over objects in collection + for (CondAttrListCollection::const_iterator citr=atrlistcol->begin(); citr!=atrlistcol->end();++citr) { + const coral::AttributeList& atrlist=citr->second; + // SCT manager, therefore ignore all that is not a SCT Identifier + // if (atrlist["det"].data<int>()!=2) continue; + ATH_MSG_FATAL("Using invalid alignment data for Preshower detector (correct treatment not yet implemented"); + ident = getIdHelper()->plate_id(atrlist["station"].data<int>(), + atrlist["plate"].data<int>()); // The last is the module side which is at this ident-level always the 0-side + + // construct new transform + // Order of rotations is defined as around z, then y, then x. + Amg::Translation3D newtranslation(atrlist["Tx"].data<float>(),atrlist["Ty"].data<float>(),atrlist["Tz"].data<float>()); + Amg::Transform3D newtrans = newtranslation * Amg::RotationMatrix3D::Identity(); + newtrans *= Amg::AngleAxis3D(atrlist["Rz"].data<float>()*CLHEP::mrad, Amg::Vector3D(0.,0.,1.)); + newtrans *= Amg::AngleAxis3D(atrlist["Ry"].data<float>()*CLHEP::mrad, Amg::Vector3D(0.,1.,0.)); + newtrans *= Amg::AngleAxis3D(atrlist["Rx"].data<float>()*CLHEP::mrad, Amg::Vector3D(1.,0.,0.)); + + ATH_MSG_DEBUG("New global DB -- channel: " << citr->first + << " ,det: " << atrlist["det"].data<int>() + << " ,bec: " << atrlist["bec"].data<int>() + << " ,layer: " << atrlist["layer"].data<int>() + << " ,ring: " << atrlist["ring"].data<int>() + << " ,sector: " << atrlist["sector"].data<int>() + << " ,Tx: " << atrlist["Tx"].data<float>() + << " ,Ty: " << atrlist["Ty"].data<float>() + << " ,Tz: " << atrlist["Tz"].data<float>() + << " ,Rx: " << atrlist["Rx"].data<float>() + << " ,Ry: " << atrlist["Ry"].data<float>() + << " ,Rz: " << atrlist["Rz"].data<float>()); + + // Set the new transform; Will replace existing one with updated transform + bool status = setAlignableTransformDelta(level, + ident, + newtrans, + frame, + alignStore); + + if (!status) { + ATH_MSG_DEBUG("Cannot set AlignableTransform for identifier." + << getIdHelper()->show_to_string(ident) + << " at level " << level << " for new global DB "); + } + + alignmentChange = (alignmentChange || status); + } + return alignmentChange; + } + +bool PreshowerDetectorManager::processSpecialAlignment( + const std::string &, ScintDD::AlignFolderType) const { + return false; +} + +bool PreshowerDetectorManager::processSpecialAlignment(const std::string& /*key*/, + const CondAttrListCollection* /*obj*/, + GeoVAlignmentStore* /*alignStore*/) const { + return false; + +} + +} // namespace ScintDD diff --git a/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/ScintDetectorElement.cxx b/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/ScintDetectorElement.cxx index 7c5c8f2df502fbbda7372b4776e905423dac8fb2..7656d64d4456cffe8d34821087ad6b9d7ad8784d 100644 --- a/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/ScintDetectorElement.cxx +++ b/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/ScintDetectorElement.cxx @@ -12,8 +12,8 @@ #include "ScintReadoutGeometry/ScintDetectorElement.h" #include "ScintIdentifier/VetoID.h" -// #include "ScintIdentifier/TriggerID.h" -// #include "ScintIdentifier/PreshowerID.h" +#include "ScintIdentifier/TriggerID.h" +#include "ScintIdentifier/PreshowerID.h" #include "GeoModelKernel/GeoVFullPhysVol.h" #include "GeoModelUtilities/GeoAlignmentStore.h" @@ -110,11 +110,13 @@ ScintDetectorElement::commonConstructor() } else if (isTrigger()) { - m_idHash = 64000; //FIXME - will blow up on invalid hash if ever reached + const TriggerID* triggerId = dynamic_cast<const TriggerID* >(getIdHelper()); + m_idHash = triggerId->plate_hash(m_id); } else if (isPreshower()) { - m_idHash = 64000; //FIXME + const PreshowerID* preshowerId = dynamic_cast<const PreshowerID* >(getIdHelper()); + m_idHash = preshowerId->plate_hash(m_id); } if (!m_idHash.is_valid()) throw std::runtime_error("ScintDetectorElement: Unable to set IdentifierHash"); diff --git a/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/TriggerDetectorManager.cxx b/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/TriggerDetectorManager.cxx new file mode 100644 index 0000000000000000000000000000000000000000..e1a1dd00b836c8da3dfd4fe640faa9be262f9a3c --- /dev/null +++ b/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/TriggerDetectorManager.cxx @@ -0,0 +1,349 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "ScintReadoutGeometry/TriggerDetectorManager.h" + +#include "AthenaBaseComps/AthMsgStreamMacros.h" +#include "AthenaPoolUtilities/CondAttrListCollection.h" +#include "GeoPrimitives/CLHEPtoEigenConverter.h" +#include "Identifier/Identifier.h" +#include "Identifier/IdentifierHash.h" +#include "ScintIdentifier/TriggerID.h" +#include "ScintReadoutGeometry/ScintDetectorElementCollection.h" +#include "ScintReadoutGeometry/ScintDetectorElement.h" +#include "ScintReadoutGeometry/ExtendedAlignableTransform.h" +#include "ScintReadoutGeometry/ScintDetectorDesign.h" +#include "StoreGate/StoreGateSvc.h" + +#include <iostream> + +namespace ScintDD { + + const int FIRST_HIGHER_LEVEL = 1; + + TriggerDetectorManager::TriggerDetectorManager( StoreGateSvc* detStore ) + : ScintDetectorManager(detStore, "Trigger"), + m_idHelper(0), + m_isLogical(false) // Change to true to change the definition of local module corrections + { + // + // Initialized the Identifier helper. + // + StatusCode sc = detStore->retrieve(m_idHelper, "TriggerID"); + if (sc.isFailure()) { + ATH_MSG_ERROR("Could not retrieve Trigger id helper"); + } + // Initialize the collections. + if (m_idHelper) { + ATH_MSG_INFO("Creating detector element collection for " << m_idHelper->plate_hash_max() << " elements"); + m_elementCollection.resize(m_idHelper->plate_hash_max()); + m_alignableTransforms.resize(m_idHelper->plate_hash_max()); + // m_moduleAlignableTransforms.resize(m_idHelper->plate_hash_max()); + } + } + + + + TriggerDetectorManager::~TriggerDetectorManager() + { + // Clean up + for (size_t i=0; i < m_volume.size(); i++) { + m_volume[i]->unref(); + } + + for (size_t j=0; j < m_higherAlignableTransforms.size(); j++){ + AlignableTransformMap::iterator iterMap; + for (iterMap = m_higherAlignableTransforms[j].begin(); + iterMap != m_higherAlignableTransforms[j].end(); + ++iterMap) { + delete iterMap->second; + } + } + + for (size_t k=0; k < m_alignableTransforms.size(); k++){ + delete m_alignableTransforms[k]; + } + + // for (size_t l=0; l < m_moduleAlignableTransforms.size(); l++){ + // delete m_moduleAlignableTransforms[l]; + // } + } + + unsigned int TriggerDetectorManager::getNumTreeTops() const + { + return m_volume.size(); + } + + PVConstLink TriggerDetectorManager::getTreeTop(unsigned int i) const + { + return m_volume[i]; + } + + void TriggerDetectorManager::addTreeTop(PVLink vol){ + vol->ref(); + m_volume.push_back(vol); + } + + + ScintDetectorElement* TriggerDetectorManager::getDetectorElement(const Identifier & id) const + { + // NB the id helpers implementation for getting a hash is not optimal. + // Essentially does a binary search. + // Make sure it is a wafer Id + Identifier waferId = m_idHelper->plate_id(id); + IdentifierHash idHash = m_idHelper->plate_hash(waferId); + if (idHash.is_valid()) { + return m_elementCollection[idHash]; + } else { + return 0; + } + } + + ScintDetectorElement* TriggerDetectorManager::getDetectorElement(const IdentifierHash & idHash) const + { + return m_elementCollection[idHash]; + } + + ScintDetectorElement* TriggerDetectorManager::getDetectorElement(int station, int plate) const + { + return getDetectorElement(m_idHelper->plate_id(station, plate)); + } + + const ScintDetectorElementCollection* TriggerDetectorManager::getDetectorElementCollection() const + { + return &m_elementCollection; + } + + ScintDetectorElementCollection::const_iterator TriggerDetectorManager::getDetectorElementBegin() const + { + return m_elementCollection.begin(); + } + + ScintDetectorElementCollection::const_iterator TriggerDetectorManager::getDetectorElementEnd() const + { + return m_elementCollection.end(); + } + + + void TriggerDetectorManager::addDetectorElement(ScintDetectorElement * element) + { + IdentifierHash idHash = element->identifyHash(); + if (idHash >= m_elementCollection.size()) + throw std::runtime_error("TriggerDetectorManager: Error adding detector element."); + m_elementCollection[idHash] = element; + } + + void TriggerDetectorManager::initNeighbours() + { + ScintDetectorElementCollection::iterator iter; + + // Loop over all elements and set the neighbours + for (iter = m_elementCollection.begin(); iter != m_elementCollection.end(); ++iter){ + + ScintDetectorElement * element = *iter; + if (element) { + + IdentifierHash idHash = element->identifyHash(); + IdentifierHash idHashOther; + + int result; + // If no neighbour, result != 0 in which case we leave neighbour as null + result = m_idHelper->get_next_in_z(idHash, idHashOther); + if (result==0) element->setNextInZ(m_elementCollection[idHashOther]); + + result = m_idHelper->get_prev_in_z(idHash, idHashOther); + if (result==0) element->setPrevInZ(m_elementCollection[idHashOther]); + } + } + } + + const TriggerID* TriggerDetectorManager::getIdHelper() const + { + return m_idHelper; + } + + + bool TriggerDetectorManager::setAlignableTransformDelta(int level, + const Identifier & id, + const Amg::Transform3D & delta, + FrameType frame, + GeoVAlignmentStore* alignStore) const + { + + if (level == 0) { // 0 - At the element level + + // We retrieve it via a hashId. + IdentifierHash idHash = m_idHelper->plate_hash(id); + if (!idHash.is_valid()) return false; + + if (frame == ScintDD::global) { // global shift + // Its a global transform + return setAlignableTransformGlobalDelta(m_alignableTransforms[idHash], delta, alignStore); + + } else if (frame == ScintDD::local) { // local shift + + ScintDetectorElement * element = m_elementCollection[idHash]; + if (!element) return false; + + + // Its a local transform + //See header file for definition of m_isLogical + if( m_isLogical ){ + //Ensure cache is up to date and use the alignment corrected local to global transform + element->setCache(); + return setAlignableTransformLocalDelta(m_alignableTransforms[idHash], element->transform(), delta, alignStore); + } else + //Use default local to global transform + return setAlignableTransformLocalDelta(m_alignableTransforms[idHash], element->defTransform(), delta, alignStore); + + } else { + // other not supported + ATH_MSG_WARNING("Frames other than global or local are not supported."); + return false; + } + } else { // higher level + if (frame != ScintDD::global) { + ATH_MSG_WARNING("Non global shift at higher levels is not supported."); + return false; + } + + int index = level - FIRST_HIGHER_LEVEL; // level 0 is treated separately. + if (index >= static_cast<int>(m_higherAlignableTransforms.size())) return false; + + // We retrieve it from a map. + AlignableTransformMap::const_iterator iter; + iter = m_higherAlignableTransforms[index].find(id); + if (iter == m_higherAlignableTransforms[index].end()) return false; + + // Its a global transform + return setAlignableTransformGlobalDelta(iter->second, delta, alignStore); + } + } + + void TriggerDetectorManager::addAlignableTransform (int level, + const Identifier & id, + GeoAlignableTransform *transform, + const GeoVPhysVol * child) + { + if (m_idHelper) { + + const GeoVFullPhysVol * childFPV = dynamic_cast<const GeoVFullPhysVol *>(child); + if (!childFPV) { + ATH_MSG_ERROR("Child of alignable transform is not a full physical volume"); + } else { + addAlignableTransform (level, id, transform, childFPV); + } + } + } + + void TriggerDetectorManager::addAlignableTransform (int level, + const Identifier & id, + GeoAlignableTransform *transform, + const GeoVFullPhysVol * child) + { + if (m_idHelper) { + if (level == 0) { + // Element + IdentifierHash idHash = m_idHelper->plate_hash(id); + if (idHash.is_valid()) { + m_alignableTransforms[idHash]= new ExtendedAlignableTransform(transform, child); + } + } else { + // Higher levels are saved in a map. NB level=0 is treated above. + int index = level - FIRST_HIGHER_LEVEL; // level 0 is treated separately. + if (index >= static_cast<int>(m_higherAlignableTransforms.size())) m_higherAlignableTransforms.resize(index+1); + m_higherAlignableTransforms[index][id] = new ExtendedAlignableTransform(transform, child); + } + } + } + + bool + TriggerDetectorManager::identifierBelongs(const Identifier & id) const + { + return getIdHelper()->is_trigger(id); + } + + + const ScintDetectorDesign* TriggerDetectorManager::getTriggerDesign() const + { + return dynamic_cast<const ScintDetectorDesign *>(getDesign()); + } + + // New global alignment folders + bool TriggerDetectorManager::processGlobalAlignment(const std::string & key, int level, FrameType frame, + const CondAttrListCollection* obj, GeoVAlignmentStore* alignStore) const + { + ATH_MSG_INFO("Processing new global alignment containers with key " << key << " in the " << frame << " frame at level "); + + const CondAttrListCollection* atrlistcol=obj; + if(atrlistcol==nullptr and m_detStore->retrieve(atrlistcol,key)!=StatusCode::SUCCESS) { + ATH_MSG_INFO("Cannot find new global align Container for key " + << key << " - no new global alignment "); + return false; + } + + bool alignmentChange = false; + Identifier ident=Identifier(); + + // loop over objects in collection + for (CondAttrListCollection::const_iterator citr=atrlistcol->begin(); citr!=atrlistcol->end();++citr) { + const coral::AttributeList& atrlist=citr->second; + // SCT manager, therefore ignore all that is not a SCT Identifier + // if (atrlist["det"].data<int>()!=2) continue; + ATH_MSG_FATAL("Using invalid alignment data for Trigger detector (correct treatment not yet implemented"); + ident = getIdHelper()->plate_id(atrlist["station"].data<int>(), + atrlist["plate"].data<int>()); // The last is the module side which is at this ident-level always the 0-side + + // construct new transform + // Order of rotations is defined as around z, then y, then x. + Amg::Translation3D newtranslation(atrlist["Tx"].data<float>(),atrlist["Ty"].data<float>(),atrlist["Tz"].data<float>()); + Amg::Transform3D newtrans = newtranslation * Amg::RotationMatrix3D::Identity(); + newtrans *= Amg::AngleAxis3D(atrlist["Rz"].data<float>()*CLHEP::mrad, Amg::Vector3D(0.,0.,1.)); + newtrans *= Amg::AngleAxis3D(atrlist["Ry"].data<float>()*CLHEP::mrad, Amg::Vector3D(0.,1.,0.)); + newtrans *= Amg::AngleAxis3D(atrlist["Rx"].data<float>()*CLHEP::mrad, Amg::Vector3D(1.,0.,0.)); + + ATH_MSG_DEBUG("New global DB -- channel: " << citr->first + << " ,det: " << atrlist["det"].data<int>() + << " ,bec: " << atrlist["bec"].data<int>() + << " ,layer: " << atrlist["layer"].data<int>() + << " ,ring: " << atrlist["ring"].data<int>() + << " ,sector: " << atrlist["sector"].data<int>() + << " ,Tx: " << atrlist["Tx"].data<float>() + << " ,Ty: " << atrlist["Ty"].data<float>() + << " ,Tz: " << atrlist["Tz"].data<float>() + << " ,Rx: " << atrlist["Rx"].data<float>() + << " ,Ry: " << atrlist["Ry"].data<float>() + << " ,Rz: " << atrlist["Rz"].data<float>()); + + // Set the new transform; Will replace existing one with updated transform + bool status = setAlignableTransformDelta(level, + ident, + newtrans, + frame, + alignStore); + + if (!status) { + ATH_MSG_DEBUG("Cannot set AlignableTransform for identifier." + << getIdHelper()->show_to_string(ident) + << " at level " << level << " for new global DB "); + } + + alignmentChange = (alignmentChange || status); + } + return alignmentChange; + } + +bool TriggerDetectorManager::processSpecialAlignment( + const std::string &, ScintDD::AlignFolderType) const { + return false; +} + +bool TriggerDetectorManager::processSpecialAlignment(const std::string& /*key*/, + const CondAttrListCollection* /*obj*/, + GeoVAlignmentStore* /*alignStore*/) const { + return false; + +} + +} // namespace ScintDD diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/CMakeLists.txt b/Scintillator/ScintDetDescr/TriggerGeoModel/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..b8789d285ac0289b0bfcdc95f1ba7c7f146f9553 --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/CMakeLists.txt @@ -0,0 +1,49 @@ +################################################################################ +# Package: TriggerGeoModel +################################################################################ + +# Declare the package name: +atlas_subdir( TriggerGeoModel ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + Control/AthenaKernel + Database/RDBAccessSvc + DetectorDescription/GeoModel/GeoModelUtilities + DetectorDescription/GeoModel/GeoModelFaserUtilities + DetectorDescription/GeoPrimitives + GaudiKernel + Scintillator/ScintDetDescr/ScintGeoModelUtils + Scintillator/ScintDetDescr/ScintReadoutGeometry + PRIVATE + Control/SGTools + Control/StoreGate + Database/AthenaPOOL/AthenaPoolUtilities + DetectorDescription/DetDescrCond/DetDescrConditions + DetectorDescription/GeoModel/GeoModelInterfaces + DetectorDescription/GeometryDBSvc + DetectorDescription/Identifier + Scintillator/ScintDetDescr/ScintIdentifier + DetectorDescription/FaserDetDescr + Scintillator/ScintDetDescr/ScintIdentifier ) + +# External dependencies: +find_package( Boost COMPONENTS filesystem thread system ) +find_package( CORAL COMPONENTS CoralBase CoralKernel RelationalAccess ) +find_package( Eigen ) +find_package( GeoModelCore ) + +# Component(s) in the package: +atlas_add_component( TriggerGeoModel + src/*.cxx + src/components/*.cxx + INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} + LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} ${GEOMODEL_LIBRARIES} AthenaKernel GeoModelUtilities GeoModelFaserUtilities GaudiKernel SGTools StoreGateLib SGtests AthenaPoolUtilities DetDescrConditions FaserDetDescr ScintGeoModelUtils ScintReadoutGeometry ScintIdentifier Identifier ) + +#atlas_add_test( SCT_GMConfig_test +# SCRIPT test/SCT_GMConfig_test.py +# PROPERTIES TIMEOUT 300 ) + +# Install files from the package: +atlas_install_python_modules( python/*.py ) +atlas_install_scripts( test/*.py ) diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/TriggerGeoModel/TriggerDetectorTool.h b/Scintillator/ScintDetDescr/TriggerGeoModel/TriggerGeoModel/TriggerDetectorTool.h new file mode 100644 index 0000000000000000000000000000000000000000..f947787e92e34459b0f2e0ae9d600331d54277ee --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/TriggerGeoModel/TriggerDetectorTool.h @@ -0,0 +1,61 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGGERGEOMODEL_TRIGGERDETECTORTOOL_H +#define TRIGGERGEOMODEL_TRIGGERDETECTORTOOL_H + +#include "GeoModelUtilities/GeoModelTool.h" +#include "TriggerGeoModel/TriggerGeoModelAthenaComps.h" + +#include "GeometryDBSvc/IGeometryDBSvc.h" +#include "GeoModelInterfaces/IGeoDbTagSvc.h" +#include "RDBAccessSvc/IRDBAccessSvc.h" + +#include "GaudiKernel/ServiceHandle.h" + +#include <string> + +namespace ScintDD { + class TriggerDetectorManager; +} + +class TriggerID; +// class FaserDetectorID; + +class TriggerDetectorTool : public GeoModelTool { + +public: + // Standard Constructor + TriggerDetectorTool(const std::string& type, const std::string& name, const IInterface* parent); + + virtual StatusCode create() override final; + virtual StatusCode clear() override final; + + // Register callback function on ConDB object + virtual StatusCode registerCallback() override final; + + // Callback function itself + virtual StatusCode align(IOVSVC_CALLBACK_ARGS) override; + +private: + StringProperty m_detectorName{this, "DetectorName", "Trigger"}; + BooleanProperty m_alignable{this, "Alignable", true}; + BooleanProperty m_useDynamicAlignFolders{this, "useDynamicAlignFolders", false}; + bool m_cosmic; + + const ScintDD::TriggerDetectorManager* m_manager; + + TriggerGeoModelAthenaComps m_athenaComps; + + ServiceHandle< IGeoDbTagSvc > m_geoDbTagSvc; + ServiceHandle< IRDBAccessSvc > m_rdbAccessSvc; + ServiceHandle< IGeometryDBSvc > m_geometryDBSvc; + + StringProperty m_run1Folder{this, "Run1Folder", "/Scint/Align"}; + StringProperty m_run2L1Folder{this, "Run2L1Folder", "/Scint/AlignL1/ID"}; + StringProperty m_run2L2Folder{this, "Run2L2Folder", "/Scint/AlignL2/SCT"}; + StringProperty m_run2L3Folder{this, "Run2L3Folder", "/Scint/AlignL3"}; +}; + +#endif // TRIGGERGEOMODEL_TRIGGERDETECTORTOOL_H diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/TriggerGeoModel/TriggerGeoModelAthenaComps.h b/Scintillator/ScintDetDescr/TriggerGeoModel/TriggerGeoModel/TriggerGeoModelAthenaComps.h new file mode 100644 index 0000000000000000000000000000000000000000..8b4d83016182adf651e9a3bdcddec0d4f3492e3e --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/TriggerGeoModel/TriggerGeoModelAthenaComps.h @@ -0,0 +1,29 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TriggerGeoModel_TriggerGeoModelAthenaComps_H +#define TriggerGeoModel_TriggerGeoModelAthenaComps_H 1 + +#include "ScintGeoModelUtils/ScintDDAthenaComps.h" + +class TriggerID; + +/// Class to hold various Athena components +// template <class ID_HELPER> +class TriggerGeoModelAthenaComps : public ScintDD::AthenaComps { + +public: + + TriggerGeoModelAthenaComps(); + + void setIdHelper(const TriggerID* idHelper); + + const TriggerID* getIdHelper() const; + +private: + const TriggerID* m_idHelper; + +}; + +#endif // TriggerGeoModel_TriggerGeoModelAthenaComps_H diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/python/TriggerGeoModelConfig.py b/Scintillator/ScintDetDescr/TriggerGeoModel/python/TriggerGeoModelConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..34dda703f0c7bbd48602723586ed2b45ca1dc904 --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/python/TriggerGeoModelConfig.py @@ -0,0 +1,55 @@ +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + +from AthenaCommon import CfgMgr + +def getTriggerDetectorTool(name="TriggerDetectorTool", **kwargs): + kwargs.setdefault("DetectorName", "Trigger"); + kwargs.setdefault("Alignable", True); + kwargs.setdefault("RDBAccessSvc", "RDBAccessSvc"); + kwargs.setdefault("GeometryDBSvc", "ScintGeometryDBSvc"); + kwargs.setdefault("GeoDbTagSvc", "GeoDbTagSvc"); + return CfgMgr.TriggerDetectorTool(name, **kwargs) + +from IOVDbSvc.IOVDbSvcConfig import addFoldersSplitOnline + +def TriggerGeometryCfg( flags ): + from FaserGeoModel.GeoModelConfig import GeoModelCfg + acc = GeoModelCfg( flags ) + geoModelSvc = acc.getPrimary() + + from GeometryDBSvc.GeometryDBSvcConf import GeometryDBSvc + acc.addService(GeometryDBSvc("ScintGeometryDBSvc")) + + from RDBAccessSvc.RDBAccessSvcConf import RDBAccessSvc + acc.addService(RDBAccessSvc("RDBAccessSvc")) + + from DBReplicaSvc.DBReplicaSvcConf import DBReplicaSvc + acc.addService(DBReplicaSvc("DBReplicaSvc")) + + from TriggerGeoModel.TriggerGeoModelConf import TriggerDetectorTool + triggerDetectorTool = TriggerDetectorTool() + + triggerDetectorTool.useDynamicAlignFolders = flags.GeoModel.Align.Dynamic + geoModelSvc.DetectorTools += [ triggerDetectorTool ] + + # if flags.GeoModel.Align.Dynamic: + # acc.merge(addFoldersSplitOnline(flags,"INDET","/Indet/Onl/AlignL1/ID","/Indet/AlignL1/ID",className="CondAttrListCollection")) + # acc.merge(addFoldersSplitOnline(flags,"INDET","/Indet/Onl/AlignL2/SCT","/Indet/AlignL2/SCT",className="CondAttrListCollection")) + # acc.merge(addFoldersSplitOnline(flags,"INDET","/Indet/Onl/AlignL3","/Indet/AlignL3",className="AlignableTransformContainer")) + # else: + # if (not flags.Detector.SimulateTrigger) or flags.Detector.OverlayTrigger: + # acc.merge(addFoldersSplitOnline(flags,"INDET","/Indet/Onl/Align","/Indet/Align",className="AlignableTransformContainer")) + # else: + # acc.merge(addFoldersSplitOnline(flags,"INDET","/Indet/Onl/Align","/Indet/Align")) + + # if flags.Common.Project is not "AthSimulation": # Protection for AthSimulation builds + # if (not flags.Detector.SimulateTrigger) or flags.Detector.OverlayTrigger: + # from TriggerConditionsAlgorithms.TriggerConditionsAlgorithmsConf import TriggerAlignCondAlg + # triggerAlignCondAlg = TriggerAlignCondAlg(name = "TriggerAlignCondAlg", + # UseDynamicAlignFolders = flags.GeoModel.Align.Dynamic) + # acc.addCondAlgo(triggerAlignCondAlg) + # from TriggerConditionsAlgorithms.TriggerConditionsAlgorithmsConf import TriggerDetectorElementCondAlg + # triggerDetectorElementCondAlg = TriggerDetectorElementCondAlg(name = "TriggerDetectorElementCondAlg") + # acc.addCondAlgo(triggerDetectorElementCondAlg) + + return acc diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerComponentFactory.cxx b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerComponentFactory.cxx new file mode 100644 index 0000000000000000000000000000000000000000..6336015a12702ac3d299998d49622db466e3881e --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerComponentFactory.cxx @@ -0,0 +1,40 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TriggerComponentFactory.h" +#include "GaudiKernel/SystemOfUnits.h" + +#include <sstream> +#include <string> + +using ScintDD::TriggerDetectorManager; + +const double TriggerComponentFactory::s_epsilon = 1.0e-6 * Gaudi::Units::mm; + +TriggerComponentFactory::TriggerComponentFactory(const std::string & name, + ScintDD::TriggerDetectorManager* detectorManager, + const TriggerGeometryManager* geometryManager, + TriggerMaterialManager* materials) + : m_detectorManager(detectorManager), + m_geometryManager(geometryManager), + m_materials(materials), + m_name(name) +{} + +TriggerComponentFactory::~TriggerComponentFactory() +{} + +std::string +TriggerComponentFactory::intToString(int i) const +{ + std::ostringstream str; + str << i; + return str.str(); +} + +double +TriggerComponentFactory::epsilon() const +{ + return s_epsilon; +} diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerComponentFactory.h b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerComponentFactory.h new file mode 100644 index 0000000000000000000000000000000000000000..61f7b3d16a773661ae88c426d70a1283f516cfec --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerComponentFactory.h @@ -0,0 +1,89 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGGERGEOMODEL_TRIGGERCOMPONENTFACTORY_H +#define TRIGGERGEOMODEL_TRIGGERCOMPONENTFACTORY_H + +#include "TriggerIdentifier.h" +#include <string> + +namespace ScintDD{class TriggerDetectorManager;} +class TriggerGeometryManager; +class TriggerMaterialManager; + +class GeoLogVol; +class GeoVPhysVol; + + +class TriggerComponentFactory +{ + +public: + TriggerComponentFactory(const std::string & name, + ScintDD::TriggerDetectorManager* detectorManager, + const TriggerGeometryManager* geometryManager, + TriggerMaterialManager* materials); + + const std::string & getName() const {return m_name;} + + // utility function to covert int to string + std::string intToString(int i) const; + +protected: + ScintDD::TriggerDetectorManager* m_detectorManager; + const TriggerGeometryManager* m_geometryManager; + TriggerMaterialManager* m_materials; + + double epsilon() const; + virtual ~TriggerComponentFactory(); + +private: + std::string m_name; + static const double s_epsilon; + +}; + + +class TriggerSharedComponentFactory : public TriggerComponentFactory +{ + +public: + TriggerSharedComponentFactory(const std::string & name, + ScintDD::TriggerDetectorManager* detectorManager, + const TriggerGeometryManager* geometryManager, + TriggerMaterialManager* materials=nullptr) : + TriggerComponentFactory(name, detectorManager, geometryManager, materials), + m_physVolume(nullptr) + {}; + + GeoVPhysVol * getVolume() {return m_physVolume;} + +protected: + GeoVPhysVol * m_physVolume; + virtual GeoVPhysVol * build() = 0; + +}; + +class TriggerUniqueComponentFactory : public TriggerComponentFactory +{ + +public: + TriggerUniqueComponentFactory(const std::string & name, + ScintDD::TriggerDetectorManager* detectorManager, + const TriggerGeometryManager* geometryManager, + TriggerMaterialManager* materials=nullptr) : + TriggerComponentFactory(name, detectorManager, geometryManager, materials), + m_logVolume{nullptr} + {}; + + virtual GeoVPhysVol * build(TriggerIdentifier id) = 0; + +protected: + const GeoLogVol * m_logVolume; + + virtual const GeoLogVol * preBuild() = 0; + +}; + +#endif // TRIGGERGEOMODEL_TRIGGERCOMPONENTFACTORY_H diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerDataBase.cxx b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerDataBase.cxx new file mode 100644 index 0000000000000000000000000000000000000000..fdc662e74df6fc709aba6e41fd61988fc4b1fdea --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerDataBase.cxx @@ -0,0 +1,104 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TriggerDataBase.h" + +#include "RDBAccessSvc/IRDBAccessSvc.h" +#include "RDBAccessSvc/IRDBRecordset.h" +#include "RDBAccessSvc/IRDBRecord.h" + +#include "GeoModelInterfaces/IGeoDbTagSvc.h" +#include "GeoModelFaserUtilities/DecodeFaserVersionKey.h" + +#include "TriggerGeoModel/TriggerGeoModelAthenaComps.h" + +#include <iostream> + +TriggerDataBase::TriggerDataBase(const TriggerGeoModelAthenaComps * athenaComps) +{ + m_athenaComps = athenaComps; + + IGeoDbTagSvc * geoDbTag = m_athenaComps->geoDbTagSvc(); + + // Get version tag and node for Trigger + DecodeFaserVersionKey versionKey(geoDbTag,"Trigger"); + std::string versionTag = versionKey.tag(); + std::string versionNode = versionKey.node(); + + // Get version tag and node for Scintillator. + DecodeFaserVersionKey scintVersionKey(geoDbTag,"Scintillator"); + + // Access the RDB + IRDBAccessSvc* rdbSvc = m_athenaComps->rdbAccessSvc(); + + // Trigger version tag + m_triggerVersionTag = rdbSvc->getChildTag("Trigger", versionKey.tag(), versionKey.node(), "FASERDD"); + + +///////////////////////////////////////////////////////// +// +// Gets the structures +// +///////////////////////////////////////////////////////// + + msg(MSG::INFO) << "Retrieving Record Sets from database ..." << endmsg; + msg(MSG::DEBUG) << " Using version tag: " << versionTag << endmsg; + msg(MSG::DEBUG) << " at node: " << versionNode << endmsg; + msg(MSG::DEBUG) << " Trigger Version: " << m_triggerVersionTag << endmsg; + + // ATLS - not sure I use it. + // General atlas parameters + + // + // Trigger General + // + + // Trigger TopLevel + m_topLevel = rdbSvc->getRecordsetPtr("TriggerTopLevel", versionTag, versionNode, "FASERDD"); + msg(MSG::DEBUG) << "Table TriggerTopLevel Fetched" << endmsg; + + // Weight Table + m_weightTable = rdbSvc->getRecordsetPtr("TriggerWeights", versionTag, versionNode, "FASERDD"); + msg(MSG::DEBUG) << "Table TriggerWeights Fetched" << endmsg; + + // Extra Scaling Table. This is used for extra material studies. For nominal material the table should be empty. + // NB this is at InnerDetector level node. + m_scalingTable = rdbSvc->getRecordsetPtr("TriggerMatScaling", scintVersionKey.tag(), scintVersionKey.node(), "FASERDD"); + msg(MSG::DEBUG) << "Table TriggerMatScaling Fetched" << endmsg; + +// // Default conditions +// m_conditions = rdbSvc->getRecordsetPtr("TriggerConditions", versionTag, versionNode, "FASERDD"); +// msg(MSG::DEBUG) << "Table TriggerConditions Fetched" << endmsg; + + m_stationGeneral = rdbSvc->getRecordsetPtr("TriggerStationGeneral", versionTag, versionNode, "FASERDD"); + msg(MSG::DEBUG) << "Table TriggerStationGeneral Fetched" << endmsg; + + m_plateGeneral = rdbSvc->getRecordsetPtr("TriggerPlateGeneral", versionTag, versionNode, "FASERDD"); + msg(MSG::DEBUG) << "Table TriggerPlateGeneral Fetched" << endmsg; + +} + +const TriggerGeoModelAthenaComps* TriggerDataBase::athenaComps() const { return m_athenaComps; } + +IRDBRecordset_ptr TriggerDataBase::weightTable() const {return m_weightTable;} + +IRDBRecordset_ptr TriggerDataBase::scalingTable() const {return m_scalingTable;} + +// //const IRDBRecord* TriggerDataBase::atls() const {return *m_atls)[0];} +IRDBRecordset_ptr TriggerDataBase::topLevelTable() const {return m_topLevel;} + +// IRDBRecordset_ptr TriggerDataBase::conditionsTable() const {return m_conditions;} +// const IRDBRecord* TriggerDataBase::conditions() const {return (*m_conditions)[0];} + +const IRDBRecord* TriggerDataBase::stationGeneral() const {return (*m_stationGeneral)[0];} +const IRDBRecord* TriggerDataBase::plateGeneral() const {return (*m_plateGeneral)[0];} + +const std::string & TriggerDataBase::versionTag() const { + return m_triggerVersionTag; +} + +MsgStream& TriggerDataBase::msg (MSG::Level lvl) const +{ + return m_athenaComps->msg(lvl); +} diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerDataBase.h b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerDataBase.h new file mode 100644 index 0000000000000000000000000000000000000000..99dcf0b53b0e543de00bb899ab60ddb5bfb8d99c --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerDataBase.h @@ -0,0 +1,153 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TriggerGeoModel_TriggerDataBase_H +#define TriggerGeoModel_TriggerDataBase_H + +#include "TriggerGeoModel/TriggerGeoModelAthenaComps.h" +#include <string> + +#include "RDBAccessSvc/IRDBAccessSvc.h" +class IRDBRecord; + + +class TriggerDataBase +{ + + +public: + + TriggerDataBase(const TriggerGeoModelAthenaComps* athenaComps); + + const TriggerGeoModelAthenaComps* athenaComps() const; + + IRDBRecordset_ptr weightTable() const; + IRDBRecordset_ptr scalingTable() const; + IRDBRecordset_ptr topLevelTable() const; + +// IRDBRecordset_ptr conditionsTable() const; +// const IRDBRecord* conditions() const; + +// const IRDBRecord* brlSensor() const; +// const IRDBRecord* brlModule() const; + +// const IRDBRecord* brlSki() const; +// const IRDBRecord* brlSkiZ(int i) const; +// int brlSkiZSize() const; +// const IRDBRecord* brlLayer(int i) const; +// const IRDBRecord* brlServices() const; +// const IRDBRecord* brlServPerLayer(int i) const; +// const IRDBRecord* brlThermalShield() const; + const IRDBRecord* stationGeneral() const; + const IRDBRecord* plateGeneral() const; +// const IRDBRecord* brlFSI() const; +// int brlFSISize() const; +// const IRDBRecord* brlFSILocation(int i) const; + +// const IRDBRecord* fwdSensor(int i) const; +// const IRDBRecord* fwdHybrid() const; +// const IRDBRecord* fwdSpine(int i) const; +// const IRDBRecord* fwdModule(int i) const; +// int fwdModuleSize() const; +// IRDBRecordset_ptr fwdModuleConnectorTable() const; +// const IRDBRecord* fwdModuleConnector() const; + +// const IRDBRecord* fwdRing(int i) const; +// int fwdRingSize() const; +// const IRDBRecord* fwdWheel(int i) const; +// const IRDBRecord* fwdWheelRingMap(int i) const; +// int fwdWheelRingMapSize() const; +// const IRDBRecord* fwdDiscSupport() const; +// const IRDBRecord* fwdPatchPanelLoc(int i) const; +// int fwdPatchPanelLocSize() const; +// const IRDBRecord* fwdPatchPanel(int i) const; +// int fwdPatchPanelSize() const; +// const IRDBRecord* fwdPPConnector() const; +// int fwdPPConnectorSize() const; +// const IRDBRecord* fwdPPCooling() const; +// int fwdPPCoolingSize() const; +// const IRDBRecord* fwdCoolingBlock(int i) const; +// const IRDBRecord* fwdRingServices(int i) const; +// const IRDBRecord* fwdServices() const; +// const IRDBRecord* fwdFSILocation(int i) const; +// int fwdFSILocationSize() const; +// const IRDBRecord* fwdFSIType(int i) const; +// int fwdFSITypeSize() const; +// const IRDBRecord* fwdFSI(int i) const; +// int fwdFSISize() const; +// const IRDBRecord* fwdThermalShield(int i) const; +// int fwdThermalShieldSize() const; +// const IRDBRecord* fwdGeneral() const; +// IRDBRecordset_ptr fwdOptoHarnessTable() const; +// const IRDBRecord* fwdOptoHarness(int i) const; +// IRDBRecordset_ptr fwdDiscFixationTable() const; +// const IRDBRecord* fwdDiscFixation() const; +// const IRDBRecord* fwdCylServ(int i) const; +// int fwdCylServSize() const; +// const IRDBRecord* fwdCylServLoc(int i) const; +// int fwdCylServLocSize() const; + + // Return the Trigger version tag. + const std::string & versionTag() const; + + MsgStream& msg (MSG::Level lvl) const; + +private: + + TriggerDataBase(const TriggerDataBase &); + TriggerDataBase& operator= (const TriggerDataBase &); + +private: + + const TriggerGeoModelAthenaComps* m_athenaComps; + + std::string m_triggerVersionTag; + + IRDBRecordset_ptr m_weightTable; + IRDBRecordset_ptr m_scalingTable; + IRDBRecordset_ptr m_topLevel; + IRDBRecordset_ptr m_conditions; + +// IRDBRecordset_ptr m_brlSensor; +// IRDBRecordset_ptr m_brlModule; +// IRDBRecordset_ptr m_brlSki; +// IRDBRecordset_ptr m_brlSkiZ; +// IRDBRecordset_ptr m_brlLayer; +// IRDBRecordset_ptr m_brlServices; +// IRDBRecordset_ptr m_brlServPerLayer; +// IRDBRecordset_ptr m_brlThermalShield; + IRDBRecordset_ptr m_stationGeneral; + IRDBRecordset_ptr m_plateGeneral; +// IRDBRecordset_ptr m_brlFSI; +// IRDBRecordset_ptr m_brlFSILocation; +// IRDBRecordset_ptr m_fwdSensor; +// IRDBRecordset_ptr m_fwdHybrid; +// IRDBRecordset_ptr m_fwdSpine; +// IRDBRecordset_ptr m_fwdModule; +// IRDBRecordset_ptr m_fwdModuleConnector; +// IRDBRecordset_ptr m_fwdRing; +// IRDBRecordset_ptr m_fwdWheel; +// IRDBRecordset_ptr m_fwdWheelRingMap; +// IRDBRecordset_ptr m_fwdDiscSupport; +// IRDBRecordset_ptr m_fwdPatchPanelLoc; +// IRDBRecordset_ptr m_fwdPatchPanel; +// IRDBRecordset_ptr m_fwdPPConnector; +// IRDBRecordset_ptr m_fwdPPCooling; +// IRDBRecordset_ptr m_fwdCoolingBlock; +// IRDBRecordset_ptr m_fwdRingServices; +// IRDBRecordset_ptr m_fwdServices; +// IRDBRecordset_ptr m_fwdFSILocation; +// IRDBRecordset_ptr m_fwdFSIType; +// IRDBRecordset_ptr m_fwdFSI; +// IRDBRecordset_ptr m_fwdThermalShield; +// IRDBRecordset_ptr m_fwdGeneral; +// IRDBRecordset_ptr m_fwdOptoHarness; +// IRDBRecordset_ptr m_fwdDiscFixation; +// IRDBRecordset_ptr m_fwdCylServ; +// IRDBRecordset_ptr m_fwdCylServLoc; + + +}; + +#endif //TriggerGeoModel_TriggerDataBase_H diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerDetectorFactory.cxx b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerDetectorFactory.cxx new file mode 100644 index 0000000000000000000000000000000000000000..0df14cc6d216888f268ba7d71072583b78d14309 --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerDetectorFactory.cxx @@ -0,0 +1,264 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +// +// TriggerDetectorFactory: This is the top level node +// + + +#include "TriggerDetectorFactory.h" + +#include "TriggerDataBase.h" +#include "TriggerIdentifier.h" +#include "TriggerGeometryManager.h" +#include "TriggerMaterialManager.h" +#include "TriggerGeneralParameters.h" +#include "ScintReadoutGeometry/Version.h" +#include "ScintReadoutGeometry/ScintCommonItems.h" +#include "ScintReadoutGeometry/ScintDD_Defs.h" +#include "ScintReadoutGeometry/ScintDetectorDesign.h" + +#include "TriggerStation.h" +#include "TriggerPlate.h" +#include "TriggerDataBase.h" +#include "TriggerGeoModel/TriggerGeoModelAthenaComps.h" + +// +// GeoModel include files: +// +#include "GeoModelKernel/GeoMaterial.h" +#include "GeoModelKernel/GeoTube.h" +#include "GeoModelKernel/GeoLogVol.h" +#include "GeoModelKernel/GeoNameTag.h" +#include "GeoModelKernel/GeoIdentifierTag.h" +#include "GeoModelKernel/GeoPhysVol.h" +#include "GeoModelKernel/GeoVPhysVol.h" +#include "GeoModelKernel/GeoTransform.h" +#include "GeoModelKernel/GeoAlignableTransform.h" +#include "GeoModelKernel/GeoShape.h" +#include "GeoModelKernel/GeoShapeUnion.h" +#include "GeoModelKernel/GeoShapeShift.h" +#include "GeoModelInterfaces/StoredMaterialManager.h" +#include "GeoModelInterfaces/IGeoDbTagSvc.h" +#include "GeoModelFaserUtilities/DecodeFaserVersionKey.h" +#include "RDBAccessSvc/IRDBAccessSvc.h" +#include "RDBAccessSvc/IRDBRecordset.h" +#include "RDBAccessSvc/IRDBRecord.h" +#include "AthenaPoolUtilities/CondAttrListCollection.h" +#include "DetDescrConditions/AlignableTransformContainer.h" +# +#include "StoreGate/StoreGateSvc.h" +#include "GaudiKernel/ISvcLocator.h" + +#include "GeoModelKernel/GeoDefinitions.h" +#include "GaudiKernel/SystemOfUnits.h" + + + +#include <iostream> +#include <iomanip> +#include <string> + +using ScintDD::TriggerDetectorManager; +using ScintDD::ScintCommonItems; + +TriggerDetectorFactory::TriggerDetectorFactory(const TriggerGeoModelAthenaComps * athenaComps, + const TriggerOptions & options) + : ScintDD::DetectorFactoryBase(athenaComps), + m_useDynamicAlignFolders(false) +{ + + // Create the detector manager + m_detectorManager = new TriggerDetectorManager(detStore()); + msg(MSG::DEBUG) << "Created TriggerDetectorManager" << endmsg; + + // Create the database + m_db = new TriggerDataBase{athenaComps}; + msg(MSG::DEBUG) << "Created TriggerDataBase" << endmsg; + + // Create the material manager + m_materials = new TriggerMaterialManager{m_db}; + msg(MSG::DEBUG) << "Created TriggerMaterialManager" << endmsg; + + // Create the geometry manager. + m_geometryManager = new TriggerGeometryManager{m_db}; + msg(MSG::DEBUG) << "Created TriggerGeometryManager" << endmsg; + m_geometryManager->setOptions(options); + msg(MSG::DEBUG) << "Set options on TriggerGeometryManager" << endmsg; + + m_useDynamicAlignFolders = options.dynamicAlignFolders(); + + // Set Version information + // Get the geometry tag + DecodeFaserVersionKey versionKey(geoDbTagSvc(),"Trigger"); + IRDBRecordset_ptr switchSet + = rdbAccessSvc()->getRecordsetPtr("TriggerSwitches", versionKey.tag(), versionKey.node(),"FASERDD"); + const IRDBRecord *switches = (*switchSet)[0]; + msg(MSG::DEBUG) << "Retrieved TriggerSwitches" << endmsg; + + std::string layout = "Final"; + std::string description; + if (!switches->isFieldNull("LAYOUT")) { + layout = switches->getString("LAYOUT"); + } + if (!switches->isFieldNull("DESCRIPTION")) { + description = switches->getString("DESCRIPTION"); + } + + std::string versionTag = rdbAccessSvc()->getChildTag("Trigger", versionKey.tag(), versionKey.node(),"FASERDD"); + std::string versionName = switches->getString("VERSIONNAME"); + int versionMajorNumber = 1; + int versionMinorNumber = 0; + int versionPatchNumber = 0; + ScintDD::Version version(versionTag, + versionName, + layout, + description, + versionMajorNumber, + versionMinorNumber, + versionPatchNumber); + m_detectorManager->setVersion(version); +} + + +TriggerDetectorFactory::~TriggerDetectorFactory() +{ + // NB the detector manager (m_detectorManager)is stored in the detector store by the + // Tool and so we don't delete it. + delete m_db; + delete m_materials; + delete m_geometryManager; +} + +void TriggerDetectorFactory::create(GeoPhysVol *world) +{ + + msg(MSG::INFO) << "Building Trigger Detector." << endmsg; + msg(MSG::INFO) << " " << m_detectorManager->getVersion().fullDescription() << endmsg; + + // Change precision. + int oldPrecision = std::cout.precision(6); + + // The tree tops get added to world. We name it "indet" though. + GeoPhysVol *scint = world; + + const TriggerGeneralParameters * triggerGeneral = m_geometryManager->generalParameters(); + + GeoTrf::Transform3D triggerTransform = triggerGeneral->partTransform("Trigger"); + + std::string stationA_Label = "StationA"; + // std::string stationB_Label = "StationB"; + // std::string absorberA_Label = "AbsorberA"; + // std::string absorberB_Label = "AbsorberB"; + + bool stationA_Present = triggerGeneral->partPresent(stationA_Label); + // bool stationB_Present = triggerGeneral->partPresent(stationB_Label); + // bool absorberA_Present = triggerGeneral->partPresent(absorberA_Label); + // bool absorberB_Present = triggerGeneral->partPresent(absorberB_Label); + + // + // Plate is the same for all stations + // + TriggerPlate plate("Plate", m_detectorManager, m_geometryManager, m_materials); + msg(MSG::DEBUG) << "Created Trigger plate with dimensions (" << plate.thickness() << "," << plate.width() << "," << plate.length() << ")" << endmsg; + // + // Station A + // + if (stationA_Present) + { + msg(MSG::DEBUG) << "Building the Trigger Station A." << endmsg; + m_detectorManager->numerology().addStation(0); + + // Create the station + TriggerStation stationA("TriggerStationA", &plate, m_detectorManager, m_geometryManager, m_materials); + TriggerIdentifier id{m_geometryManager->athenaComps()->getIdHelper()}; + id.setStation(0); + msg(MSG::VERBOSE) << "Building Station A physical volume" << endmsg; + GeoVPhysVol* stationA_PV = stationA.build(id); + msg(MSG::VERBOSE) << "Build Station A physical volume" << endmsg; + GeoAlignableTransform* stationA_Transform = new GeoAlignableTransform(triggerTransform * triggerGeneral->partTransform(stationA_Label)); + + GeoNameTag* topLevelNameTag = new GeoNameTag("Trigger"); + scint->add(topLevelNameTag); + scint->add(new GeoIdentifierTag(0)); + scint->add(stationA_Transform); + scint->add(stationA_PV); + m_detectorManager->addTreeTop(stationA_PV); + + // Store alignable transform for station (level = 1) + m_detectorManager->addAlignableTransform(1, id.getPlateId(), stationA_Transform, stationA_PV); + } + + // + // Station B + // + // if (stationB_Present) + // { + // msg(MSG::DEBUG) << "Building the Trigger Station B." << endmsg; + // m_detectorManager->numerology().addStation(1); + + // // Create the station + // TriggerStation stationB("TriggerStationB", &plate, m_detectorManager, m_geometryManager, m_materials); + // TriggerIdentifier id{m_geometryManager->athenaComps()->getIdHelper()}; + // id.setStation(1); + // GeoVPhysVol* stationB_PV = stationB.build(id); + // GeoAlignableTransform* stationB_Transform = new GeoAlignableTransform(triggerTransform * triggerGeneral->partTransform(stationB_Label)); + + // GeoNameTag* topLevelNameTag = new GeoNameTag("Trigger"); + // scint->add(topLevelNameTag); + // scint->add(new GeoIdentifierTag(0)); + // scint->add(stationB_Transform); + // scint->add(stationB_PV); + // m_detectorManager->addTreeTop(stationB_PV); + + // // Store alignable transform for station (level = 1) + // m_detectorManager->addAlignableTransform(1, id.getPlateId(), stationB_Transform, stationB_PV); + // } + + // Set the neighbours + m_detectorManager->initNeighbours(); + + // Set number of pmts in numerology. + const ScintDD::ScintDetectorDesign* design = m_detectorManager->getTriggerDesign(); + if (design != nullptr) + { + m_detectorManager->numerology().setNumPmtsPerPlate(m_detectorManager->getTriggerDesign()->cells()); + } + else + { + m_detectorManager->numerology().setNumPmtsPerPlate(0); + } + + + // Register the keys and the level corresponding to the key + // and whether it expects a global or local shift. + // level 0: sensor, level 1: module, level 2, layer/disc, level 3: whole barrel/enccap + + + if (!m_useDynamicAlignFolders){ + + m_detectorManager->addAlignFolderType(ScintDD::static_run1); + // m_detectorManager->addFolder("/Scint/Align"); + } + else { + m_detectorManager->addAlignFolderType(ScintDD::timedependent_run2); + // m_detectorManager->addGlobalFolder("/Scint/AlignL1/Scint"); + // m_detectorManager->addGlobalFolder("/Scint/AlignL2/Trigger"); + // m_detectorManager->addChannel("/Scint/AlignL1/Scint",3,ScintDD::global); + // m_detectorManager->addChannel("/Scint/AlignL2/Trigger",2,ScintDD::global); + // m_detectorManager->addFolder("/Scint/AlignL3"); + } + + // Return precision to its original value + std::cout.precision(oldPrecision); + +} + + +const TriggerDetectorManager * TriggerDetectorFactory::getDetectorManager() const +{ + return m_detectorManager; +} + + diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerDetectorFactory.h b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerDetectorFactory.h new file mode 100644 index 0000000000000000000000000000000000000000..9c15e5892bb8f96bf7071bdb5eb090981b0f3c1a --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerDetectorFactory.h @@ -0,0 +1,50 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGGERGEOMODEL_TRIGGERDETECTORFACTORY_H +#define TRIGGERGEOMODEL_TRIGGERDETECTORFACTORY_H + +#include "ScintGeoModelUtils/DetectorFactoryBase.h" +#include "ScintReadoutGeometry/TriggerDetectorManager.h" +#include "ScintReadoutGeometry/ScintDD_Defs.h" + +class GeoPhysVol; +class TriggerDataBase; +class TriggerGeometryManager; +class TriggerGeoModelAthenaComps; +class TriggerMaterialManager; +class TriggerOptions; + +class TriggerDetectorFactory : public ScintDD::DetectorFactoryBase +{ + + public: + // Constructor + TriggerDetectorFactory(const TriggerGeoModelAthenaComps * athenaComps, + const TriggerOptions & options); + + // Destructor + virtual ~TriggerDetectorFactory(); + + // Creation of geometry: + virtual void create(GeoPhysVol *world); + + // Access to the results: + virtual const ScintDD::TriggerDetectorManager * getDetectorManager() const; + + private: + // Copy and assignments operations illegal and so are made private + TriggerDetectorFactory(const TriggerDetectorFactory &right); + const TriggerDetectorFactory & operator=(const TriggerDetectorFactory &right); + + ScintDD::TriggerDetectorManager *m_detectorManager; + TriggerGeometryManager *m_geometryManager; + TriggerDataBase* m_db; + TriggerMaterialManager* m_materials; + bool m_useDynamicAlignFolders; + +}; + +#endif + diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerDetectorTool.cxx b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerDetectorTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..569cdadd198f9e42c6347471f74ac753b3b426ff --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerDetectorTool.cxx @@ -0,0 +1,249 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TriggerGeoModel/TriggerDetectorTool.h" + +#include "TriggerDetectorFactory.h" +#include "TriggerDataBase.h" +// #include "TriggerMaterialManager.h" +#include "TriggerOptions.h" + +// temporary +#include "ScintReadoutGeometry/TriggerDetectorManager.h" +#include "ScintIdentifier/TriggerID.h" +#include "DetDescrConditions/AlignableTransformContainer.h" + +#include "GeoModelUtilities/GeoModelExperiment.h" +#include "GeoModelFaserUtilities/DecodeFaserVersionKey.h" +#include "StoreGate/DataHandle.h" +#include "RDBAccessSvc/IRDBRecord.h" +#include "RDBAccessSvc/IRDBRecordset.h" + +#include "AthenaKernel/ClassID_traits.h" +#include "SGTools/DataProxy.h" + +using ScintDD::TriggerDetectorManager; +using ScintDD::ScintDetectorManager; + +// +// Constructor +// +TriggerDetectorTool::TriggerDetectorTool(const std::string& type, + const std::string& name, + const IInterface* parent) + : GeoModelTool(type, name, parent), + m_cosmic{false}, + m_manager{nullptr}, + m_athenaComps{ }, + m_geoDbTagSvc{"GeoDbTagSvc", name}, + m_rdbAccessSvc{"RDBAccessSvc", name}, + m_geometryDBSvc{"ScintGeometryDBSvc", name} +{ + // Get parameter values from jobOptions file + declareProperty("GeoDbTagSvc", m_geoDbTagSvc); + declareProperty("RDBAccessSvc", m_rdbAccessSvc); + declareProperty("GeometryDBSvc", m_geometryDBSvc); +} + +// +// Create the Geometry via the factory corresponding to this tool +// + +StatusCode +TriggerDetectorTool::create() +{ + // Get the detector configuration. + ATH_CHECK(m_geoDbTagSvc.retrieve()); + + DecodeFaserVersionKey versionKey{&*m_geoDbTagSvc, "Trigger"}; + // Issue error if AUTO. + if (versionKey.tag() == "AUTO") { + ATH_MSG_ERROR("AUTO Faser version. Please select a version."); + } + ATH_MSG_INFO("Building Trigger with Version Tag: " << versionKey.tag() << " at Node: " << versionKey.node()); + + ATH_CHECK(m_rdbAccessSvc.retrieve()); + // Print the Trigger version tag: + std::string triggerVersionTag{m_rdbAccessSvc->getChildTag("Trigger", versionKey.tag(), versionKey.node(), "FASERDD")}; + ATH_MSG_INFO("Trigger Version: " << triggerVersionTag << " Package Version: " << PACKAGE_VERSION); + // Check if version is empty. If so, then the Trigger cannot be built. This may or may not be intentional. We + // just issue an INFO message. + if (triggerVersionTag.empty()) { + ATH_MSG_INFO("No Trigger Version. Trigger will not be built."); + } else { + std::string versionName; + if (versionKey.custom()) { + ATH_MSG_WARNING("TriggerDetectorTool: Detector Information coming from a custom configuration!!"); + } else { + ATH_MSG_DEBUG("TriggerDetectorTool: Detector Information coming from the database and job options IGNORED."); + ATH_MSG_DEBUG("Keys for Trigger Switches are " << versionKey.tag() << " " << versionKey.node()); + + IRDBRecordset_ptr switchSet{m_rdbAccessSvc->getRecordsetPtr("TriggerSwitches", versionKey.tag(), versionKey.node(), "FASERDD")}; + const IRDBRecord* switches{(*switchSet)[0]}; + m_detectorName.setValue(switches->getString("DETECTORNAME")); + + if (not switches->isFieldNull("COSMICLAYOUT")) + { + m_cosmic = switches->getInt("COSMICLAYOUT"); + } + if (not switches->isFieldNull("VERSIONNAME")) + { + versionName = switches->getString("VERSIONNAME"); + } + } + + ATH_MSG_DEBUG("Creating the Trigger"); + ATH_MSG_DEBUG("Trigger Geometry Options: "); + ATH_MSG_DEBUG(" Alignable: " << (m_alignable.value() ? "true" : "false")); + ATH_MSG_DEBUG(" CosmicLayout: " << (m_cosmic ? "true" : "false")); + ATH_MSG_DEBUG(" VersionName: " << versionName); + + TriggerOptions options; + options.setAlignable(m_alignable.value()); + options.setDynamicAlignFolders(m_useDynamicAlignFolders.value()); + m_manager = nullptr; + + // + // Locate the top level experiment node + // + GeoModelExperiment* theExpt{nullptr}; + ATH_CHECK(detStore()->retrieve(theExpt, "FASER")); + + // Retrieve the Geometry DB Interface + ATH_CHECK(m_geometryDBSvc.retrieve()); + + // Pass athena services to factory, etc + m_athenaComps.setDetStore(detStore().operator->()); + m_athenaComps.setGeoDbTagSvc(&*m_geoDbTagSvc); + m_athenaComps.setGeometryDBSvc(&*m_geometryDBSvc); + m_athenaComps.setRDBAccessSvc(&*m_rdbAccessSvc); + const TriggerID* idHelper{nullptr}; + ATH_CHECK(detStore()->retrieve(idHelper, "TriggerID")); + m_athenaComps.setIdHelper(idHelper); + idHelper->test_plate_packing(); + // + // This strange way of casting is to avoid an + // utterly brain damaged compiler warning. + // + GeoPhysVol* world{&*theExpt->getPhysVol()}; + if (world != nullptr) ATH_MSG_INFO("Retrieved World PhysVol"); + + TriggerDetectorFactory theTrigger{&m_athenaComps, options}; + ATH_MSG_INFO("Created instance of detector factory"); + theTrigger.create(world); + ATH_MSG_INFO("Called create method on factory"); + m_manager = theTrigger.getDetectorManager(); + ATH_MSG_INFO("Attempted to retrieve detector manager"); + + if (m_manager==nullptr) { + ATH_MSG_FATAL("TriggerDetectorManager not created"); + return StatusCode::FAILURE; + } + + // Get the manager from the factory and store it in the detector store. + // m_detector is non constant so I can not set it to a const pointer. + // m_detector = theSCT.getDetectorManager(); + + ATH_MSG_DEBUG("Registering TriggerDetectorManager. "); + ATH_CHECK(detStore()->record(m_manager, m_manager->getName())); + theExpt->addManager(m_manager); + + // Create a symLink to the ScintDetectorManager base class + const ScintDetectorManager* scintDetManager{m_manager}; + ATH_CHECK(detStore()->symLink(m_manager, scintDetManager)); + } + + return StatusCode::SUCCESS; +} + +StatusCode +TriggerDetectorTool::clear() +{ + ATH_MSG_WARNING("Called untested TriggerDetectorTool::clear()"); + SG::DataProxy* proxy{detStore()->proxy(ClassID_traits<TriggerDetectorManager>::ID(), m_manager->getName())}; + if (proxy) { + proxy->reset(); + m_manager = nullptr; + } + return StatusCode::SUCCESS; +} + +StatusCode +TriggerDetectorTool::registerCallback() +{ + StatusCode sc{StatusCode::FAILURE, true}; + if (m_alignable.value()) { + ATH_MSG_WARNING("Called untested TriggerDetectorTool::registerCallback()"); + if (m_useDynamicAlignFolders.value()) { + + if (detStore()->contains<CondAttrListCollection>(m_run2L1Folder.value())) { + ATH_MSG_DEBUG("Registering callback on global Container with folder " << m_run2L1Folder.value()); + const DataHandle<CondAttrListCollection> calc; + ATH_CHECK(detStore()->regFcn(&IGeoModelTool::align, dynamic_cast<IGeoModelTool*>(this), calc, m_run2L1Folder.value())); + sc = StatusCode::SUCCESS; + } else { + ATH_MSG_WARNING("Unable to register callback on global Container with folder " << m_run2L1Folder.value()); + return StatusCode::FAILURE; + } + + if (detStore()->contains<CondAttrListCollection>(m_run2L2Folder.value())) { + ATH_MSG_DEBUG("Registering callback on global Container with folder " << m_run2L2Folder.value()); + const DataHandle<CondAttrListCollection> calc; + ATH_CHECK(detStore()->regFcn(&IGeoModelTool::align, dynamic_cast<IGeoModelTool*>(this), calc, m_run2L2Folder.value())); + sc = StatusCode::SUCCESS; + } else { + ATH_MSG_WARNING("Unable to register callback on global Container with folder " << m_run2L2Folder.value()); + return StatusCode::FAILURE; + } + + if (detStore()->contains<AlignableTransformContainer>(m_run2L3Folder.value())) { + ATH_MSG_DEBUG("Registering callback on AlignableTransformContainer with folder " << m_run2L3Folder.value()); + const DataHandle<AlignableTransformContainer> atc; + ATH_CHECK(detStore()->regFcn(&IGeoModelTool::align, dynamic_cast<IGeoModelTool*>(this), atc, m_run2L3Folder.value())); + sc = StatusCode::SUCCESS; + } else { + ATH_MSG_WARNING("Unable to register callback on AlignableTransformContainer with folder " << m_run2L3Folder.value()); + return StatusCode::FAILURE; + } + + } else { + + if (detStore()->contains<AlignableTransformContainer>(m_run1Folder.value())) { + ATH_MSG_DEBUG("Registering callback on AlignableTransformContainer with folder " << m_run1Folder.value()); + const DataHandle<AlignableTransformContainer> atc; + ATH_CHECK(detStore()->regFcn(&IGeoModelTool::align, dynamic_cast<IGeoModelTool*>(this), atc, m_run1Folder.value())); + sc = StatusCode::SUCCESS; + } else { + ATH_MSG_WARNING("Unable to register callback on AlignableTransformContainer with folder " + << m_run1Folder.value() << ", Alignment disabled (only if no Run2 scheme is loaded)!"); + return StatusCode::FAILURE; + } + } + } else { + ATH_MSG_INFO("Alignment disabled. No callback registered"); + // We return failure otherwise it will try and register + // a GeoModelSvc callback associated with this callback. + return StatusCode::FAILURE; + } + return sc; +} + +StatusCode +TriggerDetectorTool::align(IOVSVC_CALLBACK_ARGS_P(I, keys)) +{ + ATH_MSG_WARNING("Called untested TriggerDetectorTool::align()"); + void* i = &I; + void* k = &keys; + if (i == nullptr && k == nullptr) return StatusCode::SUCCESS; // suppress stupid warning + if (m_manager==nullptr) { + ATH_MSG_FATAL("Manager does not exist"); + return StatusCode::FAILURE; + } + if (m_alignable.value()) { + return m_manager->align(I, keys); + } else { + ATH_MSG_DEBUG("Alignment disabled. No alignments applied"); + return StatusCode::SUCCESS; + } +} diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerGeneralParameters.cxx b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerGeneralParameters.cxx new file mode 100644 index 0000000000000000000000000000000000000000..18675452d65a10159f34b130edaffb0bf4a26491 --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerGeneralParameters.cxx @@ -0,0 +1,88 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TriggerGeneralParameters.h" +#include "TriggerDataBase.h" +#include "RDBAccessSvc/IRDBRecord.h" +#include "RDBAccessSvc/IRDBRecordset.h" +#include "GaudiKernel/SystemOfUnits.h" +#include "GeoModelKernel/GeoDefinitions.h" +#include "ScintGeoModelUtils/TopLevelPlacements.h" + +const double TriggerSAFETY = 0.01 * Gaudi::Units::mm; // Used in some places to make envelopes slightly larger to ensure + // no overlaps due to rounding errors. + + +TriggerGeneralParameters::TriggerGeneralParameters(TriggerDataBase* rdb) +{ + m_rdb = rdb; + m_placements = new TopLevelPlacements(m_rdb->topLevelTable()); +} + + +TriggerGeneralParameters::~TriggerGeneralParameters() +{ + delete m_placements; +} + + +const GeoTrf::Transform3D & +TriggerGeneralParameters::partTransform(const std::string & partName) const +{ + return m_placements->transform(partName); +} + + +bool +TriggerGeneralParameters::partPresent(const std::string & partName) const +{ + return m_placements->present(partName); +} + + + +// +// General +// +double +TriggerGeneralParameters::safety() const +{ + return TriggerSAFETY; +} + +// Default Conditions. Values should be come form conditions data base. These values provide +// default vlaues if nothing from the conditions database is provided. + + +// double +// TriggerGeneralParameters::temperature() const +// { +// if (m_rdb->conditionsTable()->size() == 0) { +// return 266.15 * Gaudi::Units::kelvin; // -7 C +// } +// return (m_rdb->conditions()->getDouble("TEMPERATURE") + 273.15) * Gaudi::Units::kelvin; +// } + + +// double +// SCT_GeneralParameters::biasVoltage() const +// { +// if (m_rdb->conditionsTable()->size() == 0) { +// return 100 * Gaudi::Units::volt; +// } +// return m_rdb->conditions()->getDouble("BIASVOLT") * Gaudi::Units::volt; +// } + +// double +// SCT_GeneralParameters::depletionVoltage() const +// { +// if (m_rdb->conditionsTable()->size() == 0) { +// return 20 * Gaudi::Units::volt; +// } +// return m_rdb->conditions()->getDouble("DEPLETIONVOLT") * Gaudi::Units::volt; +// } + + + + diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerGeneralParameters.h b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerGeneralParameters.h new file mode 100644 index 0000000000000000000000000000000000000000..296627e8287fff96a5ed98791fe6d76f7087e217 --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerGeneralParameters.h @@ -0,0 +1,45 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TriggerGeoModel_TriggerGeneralParameters_H +#define TriggerGeoModel_TriggerGeneralParameters_H + +#include "GeoModelKernel/GeoDefinitions.h" + +#include <map> +#include <string> + +class TriggerDataBase; +class TopLevelPlacements; + +class TriggerGeneralParameters { + +public: + + TriggerGeneralParameters(TriggerDataBase* rdb); + ~TriggerGeneralParameters(); + //Explicitly disallow copy, assignment to appease coverity + TriggerGeneralParameters(const TriggerGeneralParameters &) = delete; + TriggerGeneralParameters & operator=(const TriggerGeneralParameters &) = delete; + + // General + double safety() const; + + //Default conditions. +// double temperature() const; +// double biasVoltage() const; +// double depletionVoltage() const; + + const GeoTrf::Transform3D & partTransform(const std::string & partName) const; + bool partPresent(const std::string & partName) const; + +private: + + TriggerDataBase * m_rdb; + TopLevelPlacements * m_placements; + +}; + + +#endif // TriggerGeoModel_TriggerGeneralParameters_H diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerGeoModelAthenaComps.cxx b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerGeoModelAthenaComps.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d8cda2c491eaa60ceac16fe89ed13e19eb83a8e4 --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerGeoModelAthenaComps.cxx @@ -0,0 +1,23 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TriggerGeoModel/TriggerGeoModelAthenaComps.h" + +TriggerGeoModelAthenaComps::TriggerGeoModelAthenaComps() + : ScintDD::AthenaComps("TriggerGeoModel"), + m_idHelper(0) +{} + +void +TriggerGeoModelAthenaComps::setIdHelper(const TriggerID* idHelper) +{ + m_idHelper = idHelper; +} + +const TriggerID* +TriggerGeoModelAthenaComps::getIdHelper() const +{ + return m_idHelper; +} + diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerGeometryManager.cxx b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerGeometryManager.cxx new file mode 100644 index 0000000000000000000000000000000000000000..39fef7a42a2c445d340834b2d7da55a9ef95b188 --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerGeometryManager.cxx @@ -0,0 +1,112 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TriggerGeometryManager.h" + +#include "ScintGeoModelUtils/DistortedMaterialManager.h" +#include "ScintIdentifier/TriggerID.h" +#include "ScintReadoutGeometry/ScintCommonItems.h" +#include "TriggerStationParameters.h" +#include "TriggerPlateParameters.h" +#include "TriggerDataBase.h" +#include "TriggerGeneralParameters.h" +#include "TriggerGeoModel/TriggerGeoModelAthenaComps.h" + +TriggerGeometryManager::TriggerGeometryManager(TriggerDataBase* rdb) + : m_athenaComps{rdb->athenaComps()}, + m_rdb{rdb} +{ + // This class uses reference counting. Should not be delete'd in destructor. + m_commonItems = new ScintDD::ScintCommonItems(m_athenaComps->getIdHelper()); + + m_stationParameters = std::make_unique<TriggerStationParameters>(m_rdb); + m_plateParameters = std::make_unique<TriggerPlateParameters>(m_rdb); + m_generalParameters = std::make_unique<TriggerGeneralParameters>(m_rdb); + m_distortedMatManager = std::make_unique<ScintDD::DistortedMaterialManager>(); +} + +TriggerGeometryManager::~TriggerGeometryManager() +{ +} + +// +// Access to run time options. +// +const TriggerOptions & +TriggerGeometryManager::options() const +{ + return m_options; +} + +void +TriggerGeometryManager::setOptions(const TriggerOptions & options) +{ + m_options = options; +} + +const TriggerGeoModelAthenaComps * +TriggerGeometryManager::athenaComps() const +{ + return m_athenaComps; +} + +// +// ScintCommonItems which are passed to ScintDetectorElements. +// + +const ScintDD::ScintCommonItems * +TriggerGeometryManager::commonItems() const +{ + return m_commonItems; +} + +const TriggerStationParameters * +TriggerGeometryManager::stationParameters() const +{ + return m_stationParameters.get(); +} + +const TriggerPlateParameters * +TriggerGeometryManager::plateParameters() const +{ + return m_plateParameters.get(); +} + +const TriggerGeneralParameters * +TriggerGeometryManager::generalParameters() const +{ + return m_generalParameters.get(); +} + +const ScintDD::DistortedMaterialManager * +TriggerGeometryManager::distortedMatManager() const +{ + return m_distortedMatManager.get(); +} + +TriggerGeometryManager& +TriggerGeometryManager::operator=(const TriggerGeometryManager& right) { + if (this != &right) { + m_options = right.m_options; + m_athenaComps = right.m_athenaComps; + m_commonItems = right.m_commonItems; + m_rdb = right.m_rdb; + m_stationParameters.reset(new TriggerStationParameters(m_rdb)); + m_plateParameters.reset(new TriggerPlateParameters(m_rdb)); + m_generalParameters.reset(new TriggerGeneralParameters(m_rdb)); + m_distortedMatManager.reset(new ScintDD::DistortedMaterialManager()); + } + return *this; +} + +TriggerGeometryManager::TriggerGeometryManager(const TriggerGeometryManager& right) { + m_options = right.m_options; + m_athenaComps = right.m_athenaComps; + m_commonItems = right.m_commonItems; + m_rdb = right.m_rdb; + m_stationParameters.reset(new TriggerStationParameters(m_rdb)); + m_plateParameters.reset(new TriggerPlateParameters(m_rdb)); + m_generalParameters.reset(new TriggerGeneralParameters(m_rdb)); + m_distortedMatManager.reset(new ScintDD::DistortedMaterialManager()); +} diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerGeometryManager.h b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerGeometryManager.h new file mode 100644 index 0000000000000000000000000000000000000000..862e5e49b9834a4ba00e1d5e766e18ab21ab6d98 --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerGeometryManager.h @@ -0,0 +1,66 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TriggerGeoModel_TriggerGeometryManager_H +#define TriggerGeoModel_TriggerGeometryManager_H + +#include "TriggerOptions.h" + +#include <memory> + +namespace ScintDD { + class ScintCommonItems; + class DistortedMaterialManager; +} + +class TriggerStationParameters; +class TriggerPlateParameters; +class TriggerDataBase; +class TriggerGeneralParameters; +class TriggerGeoModelAthenaComps; + +class TriggerGeometryManager { + +public: + + // Constructor + TriggerGeometryManager(TriggerDataBase* rdb); + + // Destructor + ~TriggerGeometryManager(); + + // Access to run time options + const TriggerOptions & options() const; + void setOptions(const TriggerOptions & options); + + // Access to athena components + const TriggerGeoModelAthenaComps * athenaComps() const; + + // To be passed to detector element. + const ScintDD::ScintCommonItems * commonItems() const; + + const TriggerStationParameters* stationParameters() const; + const TriggerPlateParameters* plateParameters() const; + const TriggerGeneralParameters* generalParameters() const; + const ScintDD::DistortedMaterialManager* distortedMatManager() const; + + TriggerGeometryManager& operator=(const TriggerGeometryManager& right); + TriggerGeometryManager(const TriggerGeometryManager& right); + +private: + + TriggerOptions m_options; + const TriggerGeoModelAthenaComps * m_athenaComps; + ScintDD::ScintCommonItems * m_commonItems; + TriggerDataBase* m_rdb; + + std::unique_ptr<TriggerStationParameters> m_stationParameters; + std::unique_ptr<TriggerPlateParameters> m_plateParameters; + std::unique_ptr<TriggerGeneralParameters> m_generalParameters; + std::unique_ptr<ScintDD::DistortedMaterialManager> m_distortedMatManager; + +}; + + +#endif // TriggerGeoModel_TriggerGeometryManager_H diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerIdentifier.cxx b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerIdentifier.cxx new file mode 100644 index 0000000000000000000000000000000000000000..932153600066a7aa1738c1b662e9bce2fe9b2df6 --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerIdentifier.cxx @@ -0,0 +1,23 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TriggerIdentifier.h" +#include "ScintIdentifier/TriggerID.h" +#include "Identifier/Identifier.h" + +#include <cassert> +#include <iostream> + +Identifier +TriggerIdentifier::getPlateId() +{ + assert (m_idHelper); + return m_idHelper->plate_id(m_station, m_plate); +} + +void TriggerIdentifier::print() +{ + std::cout << "2/2/" << m_station << "/" + << m_plate << std::endl; +} diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerIdentifier.h b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerIdentifier.h new file mode 100644 index 0000000000000000000000000000000000000000..cc898a7d52f05022e084cdbeabd6a71b2a6106bc --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerIdentifier.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGGERGEOMODEL_TRIGGERIDENTIFIER_H +#define TRIGGERGEOMODEL_TRIGGERIDENTIFIER_H + +class Identifier; +class TriggerID; + +class TriggerIdentifier +{ +public: + + TriggerIdentifier( const TriggerID* idHelper, + int station = 0, + int plate = 0 ) + : m_idHelper{idHelper}, + m_station{station}, + m_plate{plate} + {}; + + + void setStation(int i) {m_station = i;} + int getStation() const {return m_station;} + + void setPlate(int i) {m_plate = i;} + int getPlate() const {return m_plate;} + + Identifier getPlateId(); + + // For debugging purposes. + void print(); + +private: + const TriggerID* m_idHelper; + int m_station; + int m_plate; +}; + +#endif // TRIGGERGEOMODEL_TRIGGERIDENTIFIER_H diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerMaterialManager.cxx b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerMaterialManager.cxx new file mode 100644 index 0000000000000000000000000000000000000000..b4c5f77c7901b42c602f4de6d532a61534794772 --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerMaterialManager.cxx @@ -0,0 +1,83 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TriggerMaterialManager.h" +#include "GeoModelKernel/GeoMaterial.h" +#include "GeoModelKernel/GeoElement.h" +#include "TriggerDataBase.h" +#include "RDBAccessSvc/IRDBRecordset.h" +#include "StoreGate/StoreGateSvc.h" +#include "GaudiKernel/Bootstrap.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/SystemOfUnits.h" + +#include <iostream> + +// Constructor +TriggerMaterialManager::TriggerMaterialManager(TriggerDataBase* db) +{ + // Get my material manager. + ISvcLocator* svcLocator = Gaudi::svcLocator(); // from Bootstrap + StoreGateSvc* detStore; + StatusCode sc = svcLocator->service("DetectorStore", detStore ); + if (sc.isFailure()) { + std::cout << "Could not locate DetectorStore" << std::endl; + return; + } + + m_materialManager = std::make_unique<ScintMaterialManager>("TriggerMaterialManager", db->athenaComps()); + m_materialManager->addWeightTable(db->weightTable(), "trigger"); + m_materialManager->addScalingTable(db->scalingTable()); + + loadMaterials(); + + m_gasMaterial = m_materialManager->getMaterial("std::Air"); +} + +// Add materials not yet in the database +void +TriggerMaterialManager::loadMaterials() +{ +} + +const GeoElement* +TriggerMaterialManager::getElement(const std::string & elementName) const +{ + return m_materialManager->getElement(elementName); +} + +const GeoMaterial* +TriggerMaterialManager::getMaterial(const std::string & materialName) const +{ + return m_materialManager->getMaterial(materialName); +} + +void +TriggerMaterialManager::addMaterial(GeoMaterial* material) +{ + return m_materialManager->addMaterial(material); +} + +const GeoMaterial* +TriggerMaterialManager::getMaterial(const std::string & originalMaterial, + double density, + const std::string & newName) +{ + + return m_materialManager->getMaterial(originalMaterial, density, newName); +} + +const GeoMaterial * +TriggerMaterialManager::getMaterialForVolume(const std::string & materialName, double volume) +{ + return m_materialManager->getMaterialForVolume(materialName, volume); +} + + + +const GeoMaterial* +TriggerMaterialManager::gasMaterial() const +{ + return m_gasMaterial; +} diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerMaterialManager.h b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerMaterialManager.h new file mode 100644 index 0000000000000000000000000000000000000000..522b13bbcfa12657350ef6eccde2025060b96c04 --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerMaterialManager.h @@ -0,0 +1,48 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGGERMATERIALMANAGER_H +#define TRIGGERMATERIALMANAGER_H + +// TriggerMaterialManager. This provides an interface to the ScintMaterialManager which in turn +// is an interface to GeoModel Material Manager with some additional functionality. +#include "ScintGeoModelUtils/ScintMaterialManager.h" + +#include <memory> +#include <string> + +class GeoMaterial; +class GeoElement; +class ScintMaterialManager; +class TriggerDataBase; + +class TriggerMaterialManager +{ + +public: + + TriggerMaterialManager(TriggerDataBase* db); + + const GeoMaterial* getMaterial(const std::string & materialName) const; + const GeoElement* getElement(const std::string & elementName) const; + + const GeoMaterial* getMaterial(const std::string & originalMaterial, + double density, + const std::string & newName = ""); + const GeoMaterial *getMaterialForVolume(const std::string & materialName, double volume); + + // Default gas material + const GeoMaterial* gasMaterial() const; + +private: + void loadMaterials(); + void addMaterial(GeoMaterial* material); + + std::unique_ptr<ScintMaterialManager> m_materialManager; + const GeoMaterial* m_gasMaterial; + +}; + + +#endif // TRIGGERMATERIALMANAGER_H diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerOptions.cxx b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerOptions.cxx new file mode 100644 index 0000000000000000000000000000000000000000..6106c95ec5f9a32ad5e30e8b0b965e3db4b3d5f9 --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerOptions.cxx @@ -0,0 +1,47 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TriggerOptions.h" + +TriggerOptions::TriggerOptions() + : m_alignable(true) +// , m_alignModule(true) + , m_dynAlignFolders(false) +{} + +void +TriggerOptions::setAlignable(bool flag) +{ + m_alignable = flag; +} + +bool +TriggerOptions::alignable() const +{ + return m_alignable; +} + +// following may eventually become useful +// +// void +// SCT_Options::setAlignAtModuleLevel(bool flag) +// { +// m_alignModule = flag; +// } + +// bool +// SCT_Options::alignAtModuleLevel() const +// { +// return m_alignModule; +// } + +void TriggerOptions::setDynamicAlignFolders(const bool flag) +{ + m_dynAlignFolders = flag; +} + +bool TriggerOptions::dynamicAlignFolders() const +{ + return m_dynAlignFolders; +} diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerOptions.h b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerOptions.h new file mode 100644 index 0000000000000000000000000000000000000000..085e6f532738606585c66ff13eccb7cb909bade6 --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerOptions.h @@ -0,0 +1,35 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TriggerGeoModel_TriggerOptions_H +#define TriggerGeoModel_TriggerOptions_H + +// Class for any run time options. + + +class TriggerOptions +{ + +public: + TriggerOptions(); + bool alignable() const; +// bool alignAtModuleLevel() const; + + void setAlignable(bool flag = true); +// void setAlignAtModuleLevel(bool flag = true); + + //dynamic alignment folders + void setDynamicAlignFolders(const bool flag = true); + bool dynamicAlignFolders() const; + +private: + + bool m_alignable; +// bool m_alignModule; + bool m_dynAlignFolders; //controls which set of alignment folders is used + +}; + + +#endif // TriggerGeoModel_TriggerOptions_H diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerPlate.cxx b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerPlate.cxx new file mode 100644 index 0000000000000000000000000000000000000000..56a0f7eba9ecc4c828d2904330f132b8b29fff98 --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerPlate.cxx @@ -0,0 +1,117 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TriggerPlate.h" + +#include "TriggerGeometryManager.h" +#include "TriggerMaterialManager.h" + +#include "TriggerPlateParameters.h" + +#include "GeoModelKernel/GeoBox.h" +#include "GeoModelKernel/GeoLogVol.h" +#include "GeoModelKernel/GeoFullPhysVol.h" +#include "GeoModelKernel/GeoMaterial.h" + +#include "ScintReadoutGeometry/TriggerDetectorManager.h" +#include "ScintReadoutGeometry/ScintDetectorDesign.h" +#include "ScintReadoutGeometry/ScintDetectorElement.h" +#include "ScintReadoutGeometry/ScintDD_Defs.h" +#include "ScintReadoutGeometry/ScintCommonItems.h" + +#include "GaudiKernel/SystemOfUnits.h" + +using namespace ScintDD; + +TriggerPlate::TriggerPlate(const std::string & name, + ScintDD::TriggerDetectorManager* detectorManager, + const TriggerGeometryManager* geometryManager, + TriggerMaterialManager* materials) + : TriggerUniqueComponentFactory(name, detectorManager, geometryManager, materials), + m_noElementWarning{true} +{ + getParameters(); + m_logVolume = preBuild(); +} + + +void +TriggerPlate::getParameters() +{ + + const TriggerPlateParameters * parameters = m_geometryManager->plateParameters(); + m_material = m_materials->getMaterial(parameters->plateMaterial()); + m_thickness = parameters->plateThickness(); + m_length = parameters->plateLength(); + m_width = parameters->plateWidth(); + m_detectorManager->numerology().setNumPmtsPerPlate(parameters->platePmts()); +} + +const GeoLogVol * +TriggerPlate::preBuild() +{ + + // Build the plate. Just a simple box. + // const GeoBox * plateShape = new GeoBox(0.5*m_thickness, 0.5*m_width, 0.5*m_length); + const GeoBox * plateShape = new GeoBox(0.5*m_width, 0.5*m_length, 0.5*m_thickness); + GeoLogVol * plateLog = new GeoLogVol(getName(), plateShape, m_material); + + // Make the scint design for this plate + makeDesign(); + + m_detectorManager->setDesign(m_design); + + return plateLog; +} + + +void +TriggerPlate::makeDesign() +{ + //SiDetectorDesign::Axis etaAxis = SiDetectorDesign::zAxis; + //SiDetectorDesign::Axis phiAxis = SiDetectorDesign::yAxis; + //SiDetectorDesign::Axis depthAxis = SiDetectorDesign::xAxis; + + const TriggerPlateParameters * parameters = m_geometryManager->plateParameters(); + + m_design = new ScintDetectorDesign(m_thickness, + m_length, + m_width, + parameters->platePmts()); +} + + + +GeoVPhysVol * +TriggerPlate::build(TriggerIdentifier id) +{ + GeoFullPhysVol * plate = new GeoFullPhysVol(m_logVolume); + + // Make detector element and add to collection + // Only do so if we have a valid id helper. + + //id.print(); // for debugging only + + const ScintCommonItems* commonItems = m_geometryManager->commonItems(); + + if (commonItems->getIdHelper()) { + + ScintDetectorElement * detElement; + + detElement = new ScintDetectorElement(id.getPlateId(), + m_design, + plate, + commonItems); + + // Add the detector element. + m_detectorManager->addDetectorElement(detElement); + + } else { + if (m_noElementWarning) { + std::cout << "WARNING!!!!: No Trigger id helper and so no elements being produced." << std::endl; + m_noElementWarning = false; + } + } + return plate; +} diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerPlate.h b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerPlate.h new file mode 100644 index 0000000000000000000000000000000000000000..a77259e0160d509de7dbe6abc057a2ef187a6236 --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerPlate.h @@ -0,0 +1,48 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGGERGEOMODEL_TRIGGERPLATE_H +#define TRIGGERGEOMODEL_TRIGGERPLATE_H + +#include "TriggerComponentFactory.h" + +#include <atomic> +#include <string> + +class GeoMaterial; +class GeoVPhysVol; +namespace ScintDD{class ScintDetectorDesign;} + +class TriggerPlate: public TriggerUniqueComponentFactory +{ +public: + TriggerPlate(const std::string & name, + ScintDD::TriggerDetectorManager* detectorManager, + const TriggerGeometryManager* geometryManager, + TriggerMaterialManager* materials); + +public: + const GeoMaterial * material() const {return m_material;} + double thickness() const {return m_thickness;} + double width() const {return m_width;} + double length() const {return m_length;} + + virtual GeoVPhysVol * build(TriggerIdentifier id); + +private: + void getParameters(); + virtual const GeoLogVol * preBuild(); + void makeDesign(); + + const GeoMaterial * m_material; + double m_thickness; + double m_width; + double m_length; + + ScintDD::ScintDetectorDesign * m_design; + + mutable std::atomic_bool m_noElementWarning; +}; + +#endif // TRIGGERGEOMODEL_TRIGGERPLATE_H diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerPlateParameters.cxx b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerPlateParameters.cxx new file mode 100644 index 0000000000000000000000000000000000000000..a8df401102a9ed66fc9d412cc7ada1c2593c771d --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerPlateParameters.cxx @@ -0,0 +1,52 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TriggerPlateParameters.h" +#include "TriggerGeometryManager.h" + +#include "TriggerDataBase.h" + +#include "RDBAccessSvc/IRDBRecord.h" +#include "GaudiKernel/SystemOfUnits.h" + +#include <cmath> + + +TriggerPlateParameters::TriggerPlateParameters(TriggerDataBase* rdb) +{ + m_rdb = rdb; +} + +// +// Plate General +// +int +TriggerPlateParameters::platePmts() const +{ + return m_rdb->plateGeneral()->getInt("NUMPMTS"); +} + +double +TriggerPlateParameters::plateWidth() const +{ + return m_rdb->plateGeneral()->getDouble("WIDTH") * Gaudi::Units::mm; +} + +double +TriggerPlateParameters::plateLength() const +{ + return m_rdb->plateGeneral()->getDouble("LENGTH") * Gaudi::Units::mm; +} + +double +TriggerPlateParameters::plateThickness() const +{ + return m_rdb->plateGeneral()->getDouble("THICKNESS") * Gaudi::Units::mm; +} + +std::string TriggerPlateParameters::plateMaterial() const +{ + return m_rdb->plateGeneral()->getString("MATERIAL"); +} + diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerPlateParameters.h b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerPlateParameters.h new file mode 100644 index 0000000000000000000000000000000000000000..6488722d7f121389749f37d4219b0e8fa2185c70 --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerPlateParameters.h @@ -0,0 +1,32 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TriggerGeoModel_TriggerPlateParameters_H +#define TriggerGeoModel_TriggerPlateParameters_H + +#include <string> + +class TriggerDataBase; + +class TriggerPlateParameters { + +public: + + // Constructor + TriggerPlateParameters(TriggerDataBase* rdb); + + // Barrel General + int platePmts() const; + double plateThickness() const; + double plateWidth() const; + double plateLength() const; + std::string plateMaterial() const; + + private: + TriggerDataBase * m_rdb; + +}; + + +#endif // TriggerGeoModel_TriggerPlateParameters_H diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerStation.cxx b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerStation.cxx new file mode 100644 index 0000000000000000000000000000000000000000..7da905ddd441fc285c63c8bb5276b25f6c8e9ec5 --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerStation.cxx @@ -0,0 +1,102 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TriggerStation.h" + +#include "TriggerMaterialManager.h" + +#include "TriggerGeometryManager.h" +#include "TriggerStationParameters.h" +#include "TriggerGeneralParameters.h" +#include "TriggerIdentifier.h" +#include "TriggerPlate.h" + +#include "ScintReadoutGeometry/TriggerDetectorManager.h" + +#include "ScintGeoModelUtils/ExtraMaterial.h" + +#include "GeoModelKernel/GeoBox.h" +#include "GeoModelKernel/GeoLogVol.h" +#include "GeoModelKernel/GeoFullPhysVol.h" +#include "GeoModelKernel/GeoPhysVol.h" +#include "GeoModelKernel/GeoNameTag.h" +#include "GeoModelKernel/GeoIdentifierTag.h" +#include "GeoModelKernel/GeoTransform.h" +#include "GeoModelKernel/GeoAlignableTransform.h" +#include "GeoModelKernel/GeoMaterial.h" +#include "GeoModelKernel/GeoShape.h" +#include "GeoModelKernel/GeoShapeShift.h" +#include "GaudiKernel/SystemOfUnits.h" + +#include <iostream> + +TriggerStation::TriggerStation(const std::string & name, + TriggerPlate* plate, + ScintDD::TriggerDetectorManager* detectorManager, + const TriggerGeometryManager* geometryManager, + TriggerMaterialManager* materials) + : TriggerUniqueComponentFactory(name, detectorManager, geometryManager, materials), + m_plate { plate } +{ + getParameters(); + m_logVolume = preBuild(); +} + + +void +TriggerStation::getParameters() +{ + const TriggerStationParameters * parameters = m_geometryManager->stationParameters(); + + m_numPlates = parameters->numPlates(); + m_platePitchY = parameters->platePitchY(); + m_platePitchZ = parameters->platePitchZ(); + + const TriggerGeneralParameters* generalParameters = m_geometryManager->generalParameters(); + m_safety = generalParameters->safety(); + + m_width = m_plate->width() + m_safety; + // m_length = m_plate->length() + m_safety; // veto + // pitch includes thickness of one plate + m_length = m_platePitchY + m_plate->length() + m_safety; + m_thickness = (m_numPlates - 1) * m_platePitchZ + m_plate->thickness() + m_safety; + + // Set numerology + m_detectorManager->numerology().setNumPlatesPerStation(m_numPlates); +} + +const GeoLogVol * +TriggerStation::preBuild() +{ + // Create the station volume + // Box envelope containing the station. + const GeoBox* stationEnvelopeShape = new GeoBox(0.5 * m_width, 0.5 * m_length, 0.5 * m_thickness); + GeoLogVol* stationLog = new GeoLogVol(getName(), stationEnvelopeShape, m_materials->gasMaterial()); + return stationLog; +} + +GeoVPhysVol * +TriggerStation::build(TriggerIdentifier id) +{ + + GeoFullPhysVol * station = new GeoFullPhysVol(m_logVolume); + + double activeDepth = m_thickness - m_safety/2; + double plateThickness = m_plate->thickness(); + for (int iPlate = 0; iPlate < m_numPlates; iPlate++) + { + station->add(new GeoNameTag("Plate#"+intToString(iPlate))); + station->add(new GeoIdentifierTag(iPlate)); + id.setPlate(iPlate); + GeoAlignableTransform* transform = new GeoAlignableTransform(GeoTrf::Translate3D(0.0, + -0.5*m_platePitchY + (iPlate%2) * m_platePitchY, + (plateThickness - activeDepth)/2 + iPlate * m_platePitchZ)); + station->add(transform); + GeoVPhysVol* platePV = m_plate->build(id); + station->add(platePV); + m_detectorManager->addAlignableTransform(0, id.getPlateId(), transform, platePV); + } + return station; +} + diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerStation.h b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerStation.h new file mode 100644 index 0000000000000000000000000000000000000000..e76dab65e32adfb6cf0254a141dca92b36a5aef5 --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerStation.h @@ -0,0 +1,52 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGGERGEOMODEL_TRIGGERSTATION_H +#define TRIGGERGEOMODEL_TRIGGERSTATION_H + +#include "TriggerComponentFactory.h" + +class GeoVPhysVol; +class GeoFullPhysVol; +class GeoLogVol; +class TriggerIdentifier; +class TriggerPlate; + +class TriggerStation : public TriggerUniqueComponentFactory +{ + +public: + TriggerStation(const std::string & name, + TriggerPlate* plate, + ScintDD::TriggerDetectorManager* detectorManager, + const TriggerGeometryManager* geometryManager, + TriggerMaterialManager* materials); + virtual GeoVPhysVol * build(TriggerIdentifier id); + +public: + int numPlates() const {return m_numPlates;} + double platePitchY() const {return m_platePitchY;} + double platePitchZ() const {return m_platePitchZ;} + double thickness() const {return m_thickness;} + double width() const {return m_width;} + double length() const {return m_length;} + +private: + void getParameters(); + virtual const GeoLogVol * preBuild(); + + TriggerPlate* m_plate; + + int m_numPlates; + double m_platePitchY; + double m_platePitchZ; + + double m_thickness; + double m_width; + double m_length; + + double m_safety; +}; + +#endif // TRIGGERGEOMODEL_TRIGGERSTATION_H diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerStationParameters.cxx b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerStationParameters.cxx new file mode 100644 index 0000000000000000000000000000000000000000..b888804ad29df21c0191ff2c7d12885e6742ee28 --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerStationParameters.cxx @@ -0,0 +1,43 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TriggerStationParameters.h" +#include "TriggerGeometryManager.h" + +#include "TriggerDataBase.h" + +#include "RDBAccessSvc/IRDBRecord.h" +#include "GaudiKernel/SystemOfUnits.h" + +#include <cmath> + + +TriggerStationParameters::TriggerStationParameters(TriggerDataBase* rdb) +{ + m_rdb = rdb; +} + + +// +// General +// +int +TriggerStationParameters::numPlates() const +{ + return m_rdb->stationGeneral()->getInt("NUMPLATES"); +} + +double +TriggerStationParameters::platePitchY() const +{ + return m_rdb->stationGeneral()->getDouble("PLATEPITCHY") * Gaudi::Units::mm; +} + +double +TriggerStationParameters::platePitchZ() const +{ + return m_rdb->stationGeneral()->getDouble("PLATEPITCHZ") * Gaudi::Units::mm; +} + + diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoStationParameters.h b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerStationParameters.h similarity index 94% rename from Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoStationParameters.h rename to Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerStationParameters.h index 173b4e99dc3f3ff85ac1c53a4db8246600ca4a90..8f75f0eb279db9bd4b5d2cd53b414c6e2834b4ea 100644 --- a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoStationParameters.h +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/TriggerStationParameters.h @@ -2,19 +2,19 @@ Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ -#ifndef VetoGeoModel_VetoStationParameters_H -#define VetoGeoModel_VetoStationParameters_H +#ifndef TriggerGeoModel_TriggerStationParameters_H +#define TriggerGeoModel_TriggerStationParameters_H #include <string> -class VetoDataBase; +class TriggerDataBase; -class VetoStationParameters { +class TriggerStationParameters { public: // Constructor - VetoStationParameters(VetoDataBase* rdb); + TriggerStationParameters(TriggerDataBase* rdb); // // Ski // int skiFirstStagger() const; @@ -174,7 +174,8 @@ public: // Barrel General int numPlates() const; - double platePitch() const; + double platePitchY() const; + double platePitchZ() const; // double stationThickness() const; // double stationWidth() const; // double stationLength() const; @@ -183,9 +184,9 @@ public: // bool isOldGeometry() const; private: - VetoDataBase * m_rdb; + TriggerDataBase * m_rdb; }; -#endif // VetoGeoModel_VetoStationParameters_H +#endif // TriggerGeoModel_TriggerStationParameters_H diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/src/components/TriggerGeoModel_entries.cxx b/Scintillator/ScintDetDescr/TriggerGeoModel/src/components/TriggerGeoModel_entries.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d213d74b92293952b10ad64edf4fbccd350a254c --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/src/components/TriggerGeoModel_entries.cxx @@ -0,0 +1,3 @@ +#include "TriggerGeoModel/TriggerDetectorTool.h" + +DECLARE_COMPONENT( TriggerDetectorTool ) \ No newline at end of file diff --git a/Scintillator/ScintDetDescr/TriggerGeoModel/test/TriggerGMConfig_test.py b/Scintillator/ScintDetDescr/TriggerGeoModel/test/TriggerGMConfig_test.py new file mode 100644 index 0000000000000000000000000000000000000000..c07c7af4ec0c8841ff3341c0d041772e3feb5493 --- /dev/null +++ b/Scintillator/ScintDetDescr/TriggerGeoModel/test/TriggerGMConfig_test.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python +"""Run tests on TriggerGeoModel configuration + +Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +""" +if __name__ == "__main__": + from AthenaCommon.Configurable import Configurable + Configurable.configurableRun3Behavior=1 + from CalypsoConfiguration.AllConfigFlags import ConfigFlags + from AthenaConfiguration.TestDefaults import defaultTestFiles + + ConfigFlags.Input.Files = defaultTestFiles.HITS + ConfigFlags.IOVDb.GlobalTag = "OFLCOND-XXXX-XXX-XX" + # ConfigFlags.Detector.SimulatePixel = False + ConfigFlags.Detector.SimulateTrigger = False + # ConfigFlags.Detector.SimulateTRT = False + ConfigFlags.GeoModel.Align.Dynamic = False + ConfigFlags.lock() + + from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator + from TriggerGeoModel.TriggerGeoModelConfig import TriggerGeometryCfg + acc = TriggerGeometryCfg(ConfigFlags) + f=open('TriggerGeometryCfg.pkl','w') + acc.store(f) + f.close() diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoComponentFactory.cxx b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoComponentFactory.cxx index 55bb3efe0c3471f949481f5cc963eee3280cd90a..8e7f14e32d78890fcc22cdbf2381352ff2293bb5 100644 --- a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoComponentFactory.cxx +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoComponentFactory.cxx @@ -2,7 +2,7 @@ Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ -#include "VetoGeoModel/VetoComponentFactory.h" +#include "VetoComponentFactory.h" #include "GaudiKernel/SystemOfUnits.h" #include <sstream> diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoComponentFactory.h b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoComponentFactory.h similarity index 98% rename from Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoComponentFactory.h rename to Scintillator/ScintDetDescr/VetoGeoModel/src/VetoComponentFactory.h index 4f2ea7453464c244ed5b5cb1858fed463709fb80..e73f2e281c2c77c061738b4da852a64b017d5461 100644 --- a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoComponentFactory.h +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoComponentFactory.h @@ -5,7 +5,7 @@ #ifndef VETOGEOMODEL_VETOCOMPONENTFACTORY_H #define VETOGEOMODEL_VETOCOMPONENTFACTORY_H -#include "VetoGeoModel/VetoIdentifier.h" +#include "VetoIdentifier.h" #include <string> namespace ScintDD{class VetoDetectorManager;} diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoDataBase.cxx b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoDataBase.cxx index 3f059b7a43c983d6a05bb99995d186dac07a8488..44bb1e086f16685bd9b7ce768d9942a08e9cf334 100644 --- a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoDataBase.cxx +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoDataBase.cxx @@ -2,7 +2,7 @@ Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ -#include "VetoGeoModel/VetoDataBase.h" +#include "VetoDataBase.h" #include "RDBAccessSvc/IRDBAccessSvc.h" #include "RDBAccessSvc/IRDBRecordset.h" diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoDataBase.h b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoDataBase.h similarity index 100% rename from Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoDataBase.h rename to Scintillator/ScintDetDescr/VetoGeoModel/src/VetoDataBase.h diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoDetectorFactory.cxx b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoDetectorFactory.cxx index f2d43e8796e689800f6a05145a9e5696ec75d6f7..c85ae49d8c24d8c72debd67b90232054f7098749 100644 --- a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoDetectorFactory.cxx +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoDetectorFactory.cxx @@ -7,21 +7,21 @@ // -#include "VetoGeoModel/VetoDetectorFactory.h" +#include "VetoDetectorFactory.h" -#include "VetoGeoModel/VetoDataBase.h" -#include "VetoGeoModel/VetoIdentifier.h" -#include "VetoGeoModel/VetoGeometryManager.h" -#include "VetoGeoModel/VetoMaterialManager.h" -#include "VetoGeoModel/VetoGeneralParameters.h" +#include "VetoDataBase.h" +#include "VetoIdentifier.h" +#include "VetoGeometryManager.h" +#include "VetoMaterialManager.h" +#include "VetoGeneralParameters.h" #include "ScintReadoutGeometry/Version.h" #include "ScintReadoutGeometry/ScintCommonItems.h" #include "ScintReadoutGeometry/ScintDD_Defs.h" #include "ScintReadoutGeometry/ScintDetectorDesign.h" -#include "VetoGeoModel/VetoStation.h" -#include "VetoGeoModel/VetoPlate.h" -#include "VetoGeoModel/VetoDataBase.h" +#include "VetoStation.h" +#include "VetoPlate.h" +#include "VetoDataBase.h" #include "VetoGeoModel/VetoGeoModelAthenaComps.h" // diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoDetectorFactory.h b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoDetectorFactory.h similarity index 100% rename from Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoDetectorFactory.h rename to Scintillator/ScintDetDescr/VetoGeoModel/src/VetoDetectorFactory.h diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoDetectorTool.cxx b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoDetectorTool.cxx index fc2b478095da4e49db83fae478048af157a62fb9..a397a0591ea34a456b68bb882aebcf8217a0bda3 100644 --- a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoDetectorTool.cxx +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoDetectorTool.cxx @@ -4,10 +4,10 @@ #include "VetoGeoModel/VetoDetectorTool.h" -#include "VetoGeoModel/VetoDetectorFactory.h" -#include "VetoGeoModel/VetoDataBase.h" -// #include "VetoGeoModel/VetoMaterialManager.h" -#include "VetoGeoModel/VetoOptions.h" +#include "VetoDetectorFactory.h" +#include "VetoDataBase.h" +// #include "VetoMaterialManager.h" +#include "VetoOptions.h" // temporary #include "ScintReadoutGeometry/VetoDetectorManager.h" diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoGeneralParameters.cxx b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoGeneralParameters.cxx index 15f2411d605af588f14b783b0486edbe1fa8fd30..a1bc08897cdd1013e5b48ca5297ff687870d798f 100644 --- a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoGeneralParameters.cxx +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoGeneralParameters.cxx @@ -2,8 +2,8 @@ Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ -#include "VetoGeoModel/VetoGeneralParameters.h" -#include "VetoGeoModel/VetoDataBase.h" +#include "VetoGeneralParameters.h" +#include "VetoDataBase.h" #include "RDBAccessSvc/IRDBRecord.h" #include "RDBAccessSvc/IRDBRecordset.h" #include "GaudiKernel/SystemOfUnits.h" diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoGeneralParameters.h b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoGeneralParameters.h similarity index 100% rename from Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoGeneralParameters.h rename to Scintillator/ScintDetDescr/VetoGeoModel/src/VetoGeneralParameters.h diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoGeometryManager.cxx b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoGeometryManager.cxx index 2b018e65920a0509db331c08efb22967766ddf70..1e5757aff9a4f931b45c0e3cc6e0e3330328a8ff 100644 --- a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoGeometryManager.cxx +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoGeometryManager.cxx @@ -2,15 +2,15 @@ Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ -#include "VetoGeoModel/VetoGeometryManager.h" +#include "VetoGeometryManager.h" #include "ScintGeoModelUtils/DistortedMaterialManager.h" #include "ScintIdentifier/VetoID.h" #include "ScintReadoutGeometry/ScintCommonItems.h" -#include "VetoGeoModel/VetoStationParameters.h" -#include "VetoGeoModel/VetoPlateParameters.h" -#include "VetoGeoModel/VetoDataBase.h" -#include "VetoGeoModel/VetoGeneralParameters.h" +#include "VetoStationParameters.h" +#include "VetoPlateParameters.h" +#include "VetoDataBase.h" +#include "VetoGeneralParameters.h" #include "VetoGeoModel/VetoGeoModelAthenaComps.h" VetoGeometryManager::VetoGeometryManager(VetoDataBase* rdb) diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoGeometryManager.h b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoGeometryManager.h similarity index 97% rename from Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoGeometryManager.h rename to Scintillator/ScintDetDescr/VetoGeoModel/src/VetoGeometryManager.h index 8f759df8367b2044c9462ce397fcd1dc46fd8f37..8531453e2791b7767e585d0f0bee5e1fe9b89f10 100644 --- a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoGeometryManager.h +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoGeometryManager.h @@ -5,7 +5,7 @@ #ifndef VetoGeoModel_VetoGeometryManager_H #define VetoGeoModel_VetoGeometryManager_H -#include "VetoGeoModel/VetoOptions.h" +#include "VetoOptions.h" #include <memory> diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoIdentifier.cxx b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoIdentifier.cxx index 0d6d17eacbfc70a354846047597eb5bbba747008..745870ce91e390795722a2bf6a34f586020eb677 100644 --- a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoIdentifier.cxx +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoIdentifier.cxx @@ -2,7 +2,7 @@ Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ -#include "VetoGeoModel/VetoIdentifier.h" +#include "VetoIdentifier.h" #include "ScintIdentifier/VetoID.h" #include "Identifier/Identifier.h" diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoIdentifier.h b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoIdentifier.h similarity index 100% rename from Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoIdentifier.h rename to Scintillator/ScintDetDescr/VetoGeoModel/src/VetoIdentifier.h diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoMaterialManager.cxx b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoMaterialManager.cxx index b0a3b4de631b1cbeede980a0d99b7b24dcbe5fea..3ee20eb612b6f3e8f6cc8f6def5180a8f5d95747 100644 --- a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoMaterialManager.cxx +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoMaterialManager.cxx @@ -2,10 +2,10 @@ Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ -#include "VetoGeoModel/VetoMaterialManager.h" +#include "VetoMaterialManager.h" #include "GeoModelKernel/GeoMaterial.h" #include "GeoModelKernel/GeoElement.h" -#include "VetoGeoModel/VetoDataBase.h" +#include "VetoDataBase.h" #include "RDBAccessSvc/IRDBRecordset.h" #include "StoreGate/StoreGateSvc.h" #include "GaudiKernel/Bootstrap.h" diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoMaterialManager.h b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoMaterialManager.h similarity index 100% rename from Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoMaterialManager.h rename to Scintillator/ScintDetDescr/VetoGeoModel/src/VetoMaterialManager.h diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoOptions.cxx b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoOptions.cxx index 1a4691d5f4a03668b216804fe29510e9f54cddc3..333776e3aa736fa97a98635b6c1e3b6fadc68183 100644 --- a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoOptions.cxx +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoOptions.cxx @@ -2,7 +2,7 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -#include "VetoGeoModel/VetoOptions.h" +#include "VetoOptions.h" VetoOptions::VetoOptions() : m_alignable(true) diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoOptions.h b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoOptions.h similarity index 100% rename from Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoOptions.h rename to Scintillator/ScintDetDescr/VetoGeoModel/src/VetoOptions.h diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoPlate.cxx b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoPlate.cxx index 9b32c4a1e38c4efe2c4003a09d3d49c22a054a34..a7c6c9b475921bc72459d54954b71df2a38fe5a8 100644 --- a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoPlate.cxx +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoPlate.cxx @@ -2,12 +2,12 @@ Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ -#include "VetoGeoModel/VetoPlate.h" +#include "VetoPlate.h" -#include "VetoGeoModel/VetoGeometryManager.h" -#include "VetoGeoModel/VetoMaterialManager.h" +#include "VetoGeometryManager.h" +#include "VetoMaterialManager.h" -#include "VetoGeoModel/VetoPlateParameters.h" +#include "VetoPlateParameters.h" #include "GeoModelKernel/GeoBox.h" #include "GeoModelKernel/GeoLogVol.h" diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoPlate.h b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoPlate.h similarity index 95% rename from Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoPlate.h rename to Scintillator/ScintDetDescr/VetoGeoModel/src/VetoPlate.h index 44e38a155f38741e44d902f6e230a119fc735172..5b7858b63e83a290668410d529f0fcf00df4647f 100644 --- a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoPlate.h +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoPlate.h @@ -5,7 +5,7 @@ #ifndef VETOGEOMODEL_VETOPLATE_H #define VETOGEOMODEL_VETOPLATE_H -#include "VetoGeoModel/VetoComponentFactory.h" +#include "VetoComponentFactory.h" #include <atomic> #include <string> diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoPlateParameters.cxx b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoPlateParameters.cxx index d953dd75be6eb492c3ffc1791886830c1621dd6c..a171f1f3281b67f21eb277796a1b8764321cf70d 100644 --- a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoPlateParameters.cxx +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoPlateParameters.cxx @@ -2,10 +2,10 @@ Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ -#include "VetoGeoModel/VetoPlateParameters.h" -#include "VetoGeoModel/VetoGeometryManager.h" +#include "VetoPlateParameters.h" +#include "VetoGeometryManager.h" -#include "VetoGeoModel/VetoDataBase.h" +#include "VetoDataBase.h" #include "RDBAccessSvc/IRDBRecord.h" #include "GaudiKernel/SystemOfUnits.h" diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoPlateParameters.h b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoPlateParameters.h similarity index 100% rename from Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoPlateParameters.h rename to Scintillator/ScintDetDescr/VetoGeoModel/src/VetoPlateParameters.h diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoStation.cxx b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoStation.cxx index c15e5aa41e4903c144a04d4a4949efd37a44c189..0a969c4a94c8f4d9fba27bf541648f58b92b9350 100644 --- a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoStation.cxx +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoStation.cxx @@ -2,15 +2,15 @@ Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ -#include "VetoGeoModel/VetoStation.h" +#include "VetoStation.h" -#include "VetoGeoModel/VetoMaterialManager.h" +#include "VetoMaterialManager.h" -#include "VetoGeoModel/VetoGeometryManager.h" -#include "VetoGeoModel/VetoStationParameters.h" -#include "VetoGeoModel/VetoGeneralParameters.h" -#include "VetoGeoModel/VetoIdentifier.h" -#include "VetoGeoModel/VetoPlate.h" +#include "VetoGeometryManager.h" +#include "VetoStationParameters.h" +#include "VetoGeneralParameters.h" +#include "VetoIdentifier.h" +#include "VetoPlate.h" #include "ScintReadoutGeometry/VetoDetectorManager.h" diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoStation.h b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoStation.h similarity index 96% rename from Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoStation.h rename to Scintillator/ScintDetDescr/VetoGeoModel/src/VetoStation.h index b0650c7940f2e137baef981b1dab9a0cc2354a11..bb91ace47c4942eeeb4d9b9cb6a44ae48f93fb58 100644 --- a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoStation.h +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoStation.h @@ -5,7 +5,7 @@ #ifndef VETOGEOMODEL_VETOSTATION_H #define VETOGEOMODEL_VETOSTATION_H -#include "VetoGeoModel/VetoComponentFactory.h" +#include "VetoComponentFactory.h" class GeoVPhysVol; class GeoFullPhysVol; diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoStationParameters.cxx b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoStationParameters.cxx index da767000c088a4de99ca808f8eaac7a369a0ec2e..ffdee27f3bc71309565eea8d26c07effebdde0af 100644 --- a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoStationParameters.cxx +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoStationParameters.cxx @@ -2,10 +2,10 @@ Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ -#include "VetoGeoModel/VetoStationParameters.h" -#include "VetoGeoModel/VetoGeometryManager.h" +#include "VetoStationParameters.h" +#include "VetoGeometryManager.h" -#include "VetoGeoModel/VetoDataBase.h" +#include "VetoDataBase.h" #include "RDBAccessSvc/IRDBRecord.h" #include "GaudiKernel/SystemOfUnits.h" diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoStationParameters.h b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoStationParameters.h new file mode 100644 index 0000000000000000000000000000000000000000..4dbace5be1ffdc8a9df000656b1229facb02591d --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoStationParameters.h @@ -0,0 +1,30 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VetoGeoModel_VetoStationParameters_H +#define VetoGeoModel_VetoStationParameters_H + +#include <string> + +class VetoDataBase; + +class VetoStationParameters { + +public: + + // Constructor + VetoStationParameters(VetoDataBase* rdb); + + + // General + int numPlates() const; + double platePitch() const; + + private: + VetoDataBase * m_rdb; + +}; + + +#endif // VetoGeoModel_VetoStationParameters_H diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/src/components/ScintGeoModel_entries.cxx b/Scintillator/ScintDetDescr/VetoGeoModel/src/components/VetoGeoModel_entries.cxx similarity index 100% rename from Scintillator/ScintDetDescr/VetoGeoModel/src/components/ScintGeoModel_entries.cxx rename to Scintillator/ScintDetDescr/VetoGeoModel/src/components/VetoGeoModel_entries.cxx diff --git a/Scintillator/ScintDetDescrCnv/ScintIdCnv/src/PreshowerIDDetDescrCnv.cxx b/Scintillator/ScintDetDescrCnv/ScintIdCnv/src/PreshowerIDDetDescrCnv.cxx new file mode 100644 index 0000000000000000000000000000000000000000..1be3c20e66b547f46f0a7e0aa1950d33ae11ee2d --- /dev/null +++ b/Scintillator/ScintDetDescrCnv/ScintIdCnv/src/PreshowerIDDetDescrCnv.cxx @@ -0,0 +1,239 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/*************************************************************************** + Scint DetDescrCnv package + ----------------------------------------- + ***************************************************************************/ + +//<<<<<< INCLUDES >>>>>> + +#include "PreshowerIDDetDescrCnv.h" + +#include "DetDescrCnvSvc/DetDescrConverter.h" +#include "DetDescrCnvSvc/DetDescrAddress.h" +#include "GaudiKernel/MsgStream.h" +#include "StoreGate/StoreGate.h" + +#include "IdDictDetDescr/IdDictManager.h" +#include "ScintIdentifier/PreshowerID.h" + + +//<<<<<< PRIVATE DEFINES >>>>>> +//<<<<<< PRIVATE CONSTANTS >>>>>> +//<<<<<< PRIVATE TYPES >>>>>> +//<<<<<< PRIVATE VARIABLE DEFINITIONS >>>>>> +//<<<<<< PUBLIC VARIABLE DEFINITIONS >>>>>> +//<<<<<< CLASS STRUCTURE INITIALIZATION >>>>>> +//<<<<<< PRIVATE FUNCTION DEFINITIONS >>>>>> +//<<<<<< PUBLIC FUNCTION DEFINITIONS >>>>>> +//<<<<<< MEMBER FUNCTION DEFINITIONS >>>>>> + +//-------------------------------------------------------------------- + +long int +PreshowerIDDetDescrCnv::repSvcType() const +{ + return (storageType()); +} + +//-------------------------------------------------------------------- + +StatusCode +PreshowerIDDetDescrCnv::initialize() +{ + // First call parent init + StatusCode sc = DetDescrConverter::initialize(); + MsgStream log(msgSvc(), "PreshowerIDDetDescrCnv"); + log << MSG::DEBUG << "in initialize" << endmsg; + + if (sc.isFailure()) { + log << MSG::ERROR << "DetDescrConverter::initialize failed" << endmsg; + return sc; + } + + // The following is an attempt to "bootstrap" the loading of a + // proxy for PreshowerID into the detector store. However, + // PreshowerIDDetDescrCnv::initialize is NOT called by the conversion + // service. So for the moment, this cannot be use. Instead the + // DetDescrCnvSvc must do the bootstrap from a parameter list. + + +// // Add Scint_DetDescrManager proxy as entry point to the detector store +// // - this is ONLY needed for the manager of each system +// sc = addToDetStore(classID(), "PreshowerID"); +// if (sc.isFailure()) { +// log << MSG::FATAL << "Unable to add proxy for PreshowerID to the Detector Store!" << endmsg; +// return StatusCode::FAILURE; +// } else {} + + return StatusCode::SUCCESS; +} + +//-------------------------------------------------------------------- + +StatusCode +PreshowerIDDetDescrCnv::finalize() +{ + MsgStream log(msgSvc(), "PreshowerIDDetDescrCnv"); + log << MSG::DEBUG << "in finalize" << endmsg; + + return StatusCode::SUCCESS; +} + +//-------------------------------------------------------------------- + +StatusCode +PreshowerIDDetDescrCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj) +{ + //StatusCode sc = StatusCode::SUCCESS; + MsgStream log(msgSvc(), "PreshowerIDDetDescrCnv"); + log << MSG::INFO << "in createObj: creating a PreshowerID helper object in the detector store" << endmsg; + + // Create a new PreshowerID + + DetDescrAddress* ddAddr; + ddAddr = dynamic_cast<DetDescrAddress*> (pAddr); + if(!ddAddr) { + log << MSG::FATAL << "Could not cast to DetDescrAddress." << endmsg; + return StatusCode::FAILURE; + } + + // Get the StoreGate key of this container. + std::string helperKey = *( ddAddr->par() ); + if ("" == helperKey) { + log << MSG::DEBUG << "No Helper key " << endmsg; + } + else { + log << MSG::DEBUG << "Helper key is " << helperKey << endmsg; + } + + + // get DetectorStore service + StoreGateSvc * detStore; + StatusCode status = serviceLocator()->service("DetectorStore", detStore); + if (status.isFailure()) { + log << MSG::FATAL << "DetectorStore service not found !" << endmsg; + return StatusCode::FAILURE; + } else {} + + // Get the dictionary manager from the detector store + const DataHandle<IdDictManager> idDictMgr; + status = detStore->retrieve(idDictMgr, "IdDict"); + if (status.isFailure()) { + log << MSG::FATAL << "Could not get IdDictManager !" << endmsg; + return StatusCode::FAILURE; + } + else { + log << MSG::DEBUG << " Found the IdDictManager. " << endmsg; + } + + // Only create new helper if it is the first pass or if there is a + // change in the the file or tag + bool initHelper = false; + + const IdDictMgr* mgr = idDictMgr->manager(); + + // Internal Scint id tag + std::string scintIDTag = mgr->tag(); + + // DoChecks flag + bool doChecks = mgr->do_checks(); + + IdDictDictionary* dict = mgr->find_dictionary("Scintillator"); + if (!dict) { + log << MSG::ERROR + << "unable to find idDict for Scintillator" + << endmsg; + return StatusCode::FAILURE; + } + + // File to be read for Scint ids + std::string scintIDFileName = dict->file_name(); + + // Tag of RDB record for Scint ids + std::string scintIdDictTag = dict->dict_tag(); + + + if (m_preshowerId) { + + // Preshower id helper already exists - second pass. Check for a + // change + if (scintIDTag != m_scintIDTag) { + // Internal Scint id tag + initHelper = true; + log << MSG::DEBUG << " Changed internal Scint id tag: " + << scintIDTag << endmsg; + } + if (scintIDFileName != m_scintIDFileName) { + // File to be read for Scint ids + initHelper = true; + log << MSG::DEBUG << " Changed ScintFileName:" + << scintIDFileName << endmsg; + } + if (scintIdDictTag != m_scintIdDictTag) { + // Tag of RDB record for Scint ids + initHelper = true; + log << MSG::DEBUG << " Changed ScintIdDictTag: " + << scintIdDictTag + << endmsg; + } + if (doChecks != m_doChecks) { + // DoChecks flag + initHelper = true; + log << MSG::DEBUG << " Changed doChecks flag: " + << doChecks + << endmsg; + } + } + else { + // create the helper + m_preshowerId = new PreshowerID; + initHelper = true; + // add in message service for printout + m_preshowerId->setMessageSvc(msgSvc()); + } + + if (initHelper) { + if (idDictMgr->initializeHelper(*m_preshowerId)) { + log << MSG::ERROR << "Unable to initialize PreshowerID" << endmsg; + return StatusCode::FAILURE; + } + // Save state: + m_scintIDTag = scintIDTag; + m_scintIDFileName = scintIDFileName; + m_scintIdDictTag = scintIdDictTag; + m_doChecks = doChecks; + } + + // Pass a pointer to the container to the Persistency service by reference. + pObj = StoreGateSvc::asStorable(m_preshowerId); + + return StatusCode::SUCCESS; + +} + +//-------------------------------------------------------------------- + +long +PreshowerIDDetDescrCnv::storageType() +{ + return DetDescr_StorageType; +} + +//-------------------------------------------------------------------- +const CLID& +PreshowerIDDetDescrCnv::classID() { + return ClassID_traits<PreshowerID>::ID(); +} + +//-------------------------------------------------------------------- +PreshowerIDDetDescrCnv::PreshowerIDDetDescrCnv(ISvcLocator* svcloc) + : + DetDescrConverter(ClassID_traits<PreshowerID>::ID(), svcloc), + m_preshowerId(0), + m_doChecks(false) + +{} + diff --git a/Scintillator/ScintDetDescrCnv/ScintIdCnv/src/PreshowerIDDetDescrCnv.h b/Scintillator/ScintDetDescrCnv/ScintIdCnv/src/PreshowerIDDetDescrCnv.h new file mode 100644 index 0000000000000000000000000000000000000000..07ef590eae66ba36e373ca85be5f717a1cb4b96e --- /dev/null +++ b/Scintillator/ScintDetDescrCnv/ScintIdCnv/src/PreshowerIDDetDescrCnv.h @@ -0,0 +1,71 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/*************************************************************************** + Scint DetDescrCnv package + ----------------------------------------- + ***************************************************************************/ + +#ifndef SCINTIDCNV_PRESHOWERIDDETDESCRCNV_H +#define SCINTIDCNV_PRESHOWERIDDETDESCRCNV_H + +//<<<<<< INCLUDES >>>>>> + +#include "DetDescrCnvSvc/DetDescrConverter.h" + +//<<<<<< PUBLIC DEFINES >>>>>> +//<<<<<< PUBLIC CONSTANTS >>>>>> +//<<<<<< PUBLIC TYPES >>>>>> + +class PreshowerID; + +//<<<<<< PUBLIC VARIABLES >>>>>> +//<<<<<< PUBLIC FUNCTIONS >>>>>> +//<<<<<< CLASS DECLARATIONS >>>>>> + + +/** + ** This class is a converter for the PreshowerID an IdHelper which is + ** stored in the detector store. This class derives from + ** DetDescrConverter which is a converter of the DetDescrCnvSvc. + ** + **/ + +class PreshowerIDDetDescrCnv: public DetDescrConverter { + +public: + virtual long int repSvcType() const; + virtual StatusCode initialize(); + virtual StatusCode finalize(); + virtual StatusCode createObj(IOpaqueAddress* pAddr, DataObject*& pObj); + + // Storage type and class ID (used by CnvFactory) + static long storageType(); + static const CLID& classID(); + + PreshowerIDDetDescrCnv(ISvcLocator* svcloc); + +private: + /// The helper - only will create it once + PreshowerID* m_preshowerId; + + /// File to be read for Scint ids + std::string m_scintIDFileName; + + /// Tag of RDB record for Scint ids + std::string m_scintIdDictTag; + + /// Internal Scint id tag + std::string m_scintIDTag; + + /// Whether or not + bool m_doChecks; + +}; + + +//<<<<<< INLINE PUBLIC FUNCTIONS >>>>>> +//<<<<<< INLINE MEMBER FUNCTIONS >>>>>> + +#endif // SCINTIDCNV_PRESHOWERIDDETDESCRCNV_H diff --git a/Scintillator/ScintDetDescrCnv/ScintIdCnv/src/ScintIdCnv_entries.cxx b/Scintillator/ScintDetDescrCnv/ScintIdCnv/src/ScintIdCnv_entries.cxx index 6c2fee3310e2db91d2dd59fd532990b60ec4057c..18719ef20c15237f1febd9b268e819ce2b88f5e5 100644 --- a/Scintillator/ScintDetDescrCnv/ScintIdCnv/src/ScintIdCnv_entries.cxx +++ b/Scintillator/ScintDetDescrCnv/ScintIdCnv/src/ScintIdCnv_entries.cxx @@ -3,9 +3,13 @@ // #include "SiliconIDDetDescrCnv.h" // #include "TRT_IDDetDescrCnv.h" #include "VetoIDDetDescrCnv.h" +#include "TriggerIDDetDescrCnv.h" +#include "PreshowerIDDetDescrCnv.h" // DECLARE_CONVERTER(SCT_IDDetDescrCnv) // DECLARE_CONVERTER(PixelIDDetDescrCnv) // DECLARE_CONVERTER(SiliconIDDetDescrCnv) // DECLARE_CONVERTER(TRT_IDDetDescrCnv) DECLARE_CONVERTER(VetoIDDetDescrCnv) +DECLARE_CONVERTER(TriggerIDDetDescrCnv) +DECLARE_CONVERTER(PreshowerIDDetDescrCnv) diff --git a/Scintillator/ScintDetDescrCnv/ScintIdCnv/src/TriggerIDDetDescrCnv.cxx b/Scintillator/ScintDetDescrCnv/ScintIdCnv/src/TriggerIDDetDescrCnv.cxx new file mode 100644 index 0000000000000000000000000000000000000000..73c89f76f9534c9e91366354af6e4ee262e305b6 --- /dev/null +++ b/Scintillator/ScintDetDescrCnv/ScintIdCnv/src/TriggerIDDetDescrCnv.cxx @@ -0,0 +1,239 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/*************************************************************************** + Scint DetDescrCnv package + ----------------------------------------- + ***************************************************************************/ + +//<<<<<< INCLUDES >>>>>> + +#include "TriggerIDDetDescrCnv.h" + +#include "DetDescrCnvSvc/DetDescrConverter.h" +#include "DetDescrCnvSvc/DetDescrAddress.h" +#include "GaudiKernel/MsgStream.h" +#include "StoreGate/StoreGate.h" + +#include "IdDictDetDescr/IdDictManager.h" +#include "ScintIdentifier/TriggerID.h" + + +//<<<<<< PRIVATE DEFINES >>>>>> +//<<<<<< PRIVATE CONSTANTS >>>>>> +//<<<<<< PRIVATE TYPES >>>>>> +//<<<<<< PRIVATE VARIABLE DEFINITIONS >>>>>> +//<<<<<< PUBLIC VARIABLE DEFINITIONS >>>>>> +//<<<<<< CLASS STRUCTURE INITIALIZATION >>>>>> +//<<<<<< PRIVATE FUNCTION DEFINITIONS >>>>>> +//<<<<<< PUBLIC FUNCTION DEFINITIONS >>>>>> +//<<<<<< MEMBER FUNCTION DEFINITIONS >>>>>> + +//-------------------------------------------------------------------- + +long int +TriggerIDDetDescrCnv::repSvcType() const +{ + return (storageType()); +} + +//-------------------------------------------------------------------- + +StatusCode +TriggerIDDetDescrCnv::initialize() +{ + // First call parent init + StatusCode sc = DetDescrConverter::initialize(); + MsgStream log(msgSvc(), "TriggerIDDetDescrCnv"); + log << MSG::DEBUG << "in initialize" << endmsg; + + if (sc.isFailure()) { + log << MSG::ERROR << "DetDescrConverter::initialize failed" << endmsg; + return sc; + } + + // The following is an attempt to "bootstrap" the loading of a + // proxy for TriggerID into the detector store. However, + // TriggerIDDetDescrCnv::initialize is NOT called by the conversion + // service. So for the moment, this cannot be use. Instead the + // DetDescrCnvSvc must do the bootstrap from a parameter list. + + +// // Add Scint_DetDescrManager proxy as entry point to the detector store +// // - this is ONLY needed for the manager of each system +// sc = addToDetStore(classID(), "TriggerID"); +// if (sc.isFailure()) { +// log << MSG::FATAL << "Unable to add proxy for TriggerID to the Detector Store!" << endmsg; +// return StatusCode::FAILURE; +// } else {} + + return StatusCode::SUCCESS; +} + +//-------------------------------------------------------------------- + +StatusCode +TriggerIDDetDescrCnv::finalize() +{ + MsgStream log(msgSvc(), "TriggerIDDetDescrCnv"); + log << MSG::DEBUG << "in finalize" << endmsg; + + return StatusCode::SUCCESS; +} + +//-------------------------------------------------------------------- + +StatusCode +TriggerIDDetDescrCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj) +{ + //StatusCode sc = StatusCode::SUCCESS; + MsgStream log(msgSvc(), "TriggerIDDetDescrCnv"); + log << MSG::INFO << "in createObj: creating a TriggerID helper object in the detector store" << endmsg; + + // Create a new TriggerID + + DetDescrAddress* ddAddr; + ddAddr = dynamic_cast<DetDescrAddress*> (pAddr); + if(!ddAddr) { + log << MSG::FATAL << "Could not cast to DetDescrAddress." << endmsg; + return StatusCode::FAILURE; + } + + // Get the StoreGate key of this container. + std::string helperKey = *( ddAddr->par() ); + if ("" == helperKey) { + log << MSG::DEBUG << "No Helper key " << endmsg; + } + else { + log << MSG::DEBUG << "Helper key is " << helperKey << endmsg; + } + + + // get DetectorStore service + StoreGateSvc * detStore; + StatusCode status = serviceLocator()->service("DetectorStore", detStore); + if (status.isFailure()) { + log << MSG::FATAL << "DetectorStore service not found !" << endmsg; + return StatusCode::FAILURE; + } else {} + + // Get the dictionary manager from the detector store + const DataHandle<IdDictManager> idDictMgr; + status = detStore->retrieve(idDictMgr, "IdDict"); + if (status.isFailure()) { + log << MSG::FATAL << "Could not get IdDictManager !" << endmsg; + return StatusCode::FAILURE; + } + else { + log << MSG::DEBUG << " Found the IdDictManager. " << endmsg; + } + + // Only create new helper if it is the first pass or if there is a + // change in the the file or tag + bool initHelper = false; + + const IdDictMgr* mgr = idDictMgr->manager(); + + // Internal Scint id tag + std::string scintIDTag = mgr->tag(); + + // DoChecks flag + bool doChecks = mgr->do_checks(); + + IdDictDictionary* dict = mgr->find_dictionary("Scintillator"); + if (!dict) { + log << MSG::ERROR + << "unable to find idDict for Scintillator" + << endmsg; + return StatusCode::FAILURE; + } + + // File to be read for Scint ids + std::string scintIDFileName = dict->file_name(); + + // Tag of RDB record for Scint ids + std::string scintIdDictTag = dict->dict_tag(); + + + if (m_triggerId) { + + // Trigger id helper already exists - second pass. Check for a + // change + if (scintIDTag != m_scintIDTag) { + // Internal Scint id tag + initHelper = true; + log << MSG::DEBUG << " Changed internal Scint id tag: " + << scintIDTag << endmsg; + } + if (scintIDFileName != m_scintIDFileName) { + // File to be read for Scint ids + initHelper = true; + log << MSG::DEBUG << " Changed ScintFileName:" + << scintIDFileName << endmsg; + } + if (scintIdDictTag != m_scintIdDictTag) { + // Tag of RDB record for Scint ids + initHelper = true; + log << MSG::DEBUG << " Changed ScintIdDictTag: " + << scintIdDictTag + << endmsg; + } + if (doChecks != m_doChecks) { + // DoChecks flag + initHelper = true; + log << MSG::DEBUG << " Changed doChecks flag: " + << doChecks + << endmsg; + } + } + else { + // create the helper + m_triggerId = new TriggerID; + initHelper = true; + // add in message service for printout + m_triggerId->setMessageSvc(msgSvc()); + } + + if (initHelper) { + if (idDictMgr->initializeHelper(*m_triggerId)) { + log << MSG::ERROR << "Unable to initialize TriggerID" << endmsg; + return StatusCode::FAILURE; + } + // Save state: + m_scintIDTag = scintIDTag; + m_scintIDFileName = scintIDFileName; + m_scintIdDictTag = scintIdDictTag; + m_doChecks = doChecks; + } + + // Pass a pointer to the container to the Persistency service by reference. + pObj = StoreGateSvc::asStorable(m_triggerId); + + return StatusCode::SUCCESS; + +} + +//-------------------------------------------------------------------- + +long +TriggerIDDetDescrCnv::storageType() +{ + return DetDescr_StorageType; +} + +//-------------------------------------------------------------------- +const CLID& +TriggerIDDetDescrCnv::classID() { + return ClassID_traits<TriggerID>::ID(); +} + +//-------------------------------------------------------------------- +TriggerIDDetDescrCnv::TriggerIDDetDescrCnv(ISvcLocator* svcloc) + : + DetDescrConverter(ClassID_traits<TriggerID>::ID(), svcloc), + m_triggerId(0), + m_doChecks(false) + +{} + diff --git a/Scintillator/ScintDetDescrCnv/ScintIdCnv/src/TriggerIDDetDescrCnv.h b/Scintillator/ScintDetDescrCnv/ScintIdCnv/src/TriggerIDDetDescrCnv.h new file mode 100644 index 0000000000000000000000000000000000000000..d1c59b73f86144ab423227ace314b2335826832f --- /dev/null +++ b/Scintillator/ScintDetDescrCnv/ScintIdCnv/src/TriggerIDDetDescrCnv.h @@ -0,0 +1,71 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/*************************************************************************** + Scint DetDescrCnv package + ----------------------------------------- + ***************************************************************************/ + +#ifndef SCINTIDCNV_TRIGGERIDDETDESCRCNV_H +#define SCINTIDCNV_TRIGGERIDDETDESCRCNV_H + +//<<<<<< INCLUDES >>>>>> + +#include "DetDescrCnvSvc/DetDescrConverter.h" + +//<<<<<< PUBLIC DEFINES >>>>>> +//<<<<<< PUBLIC CONSTANTS >>>>>> +//<<<<<< PUBLIC TYPES >>>>>> + +class TriggerID; + +//<<<<<< PUBLIC VARIABLES >>>>>> +//<<<<<< PUBLIC FUNCTIONS >>>>>> +//<<<<<< CLASS DECLARATIONS >>>>>> + + +/** + ** This class is a converter for the TriggerID an IdHelper which is + ** stored in the detector store. This class derives from + ** DetDescrConverter which is a converter of the DetDescrCnvSvc. + ** + **/ + +class TriggerIDDetDescrCnv: public DetDescrConverter { + +public: + virtual long int repSvcType() const; + virtual StatusCode initialize(); + virtual StatusCode finalize(); + virtual StatusCode createObj(IOpaqueAddress* pAddr, DataObject*& pObj); + + // Storage type and class ID (used by CnvFactory) + static long storageType(); + static const CLID& classID(); + + TriggerIDDetDescrCnv(ISvcLocator* svcloc); + +private: + /// The helper - only will create it once + TriggerID* m_triggerId; + + /// File to be read for Scint ids + std::string m_scintIDFileName; + + /// Tag of RDB record for Scint ids + std::string m_scintIdDictTag; + + /// Internal Scint id tag + std::string m_scintIDTag; + + /// Whether or not + bool m_doChecks; + +}; + + +//<<<<<< INLINE PUBLIC FUNCTIONS >>>>>> +//<<<<<< INLINE MEMBER FUNCTIONS >>>>>> + +#endif // SCINTIDCNV_TRIGGERIDDETDESCRCNV_H diff --git a/Scintillator/ScintG4/PreshowerG4_SD/CMakeLists.txt b/Scintillator/ScintG4/PreshowerG4_SD/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..7b777c99982d9059d03c62b8ffad60814b638cbb --- /dev/null +++ b/Scintillator/ScintG4/PreshowerG4_SD/CMakeLists.txt @@ -0,0 +1,36 @@ +################################################################################ +# Package: PreshowerG4_SD +################################################################################ + +# Declare the package name: +atlas_subdir( PreshowerG4_SD ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PRIVATE + Control/StoreGate + GaudiKernel + Scintillator/ScintSimEvent + Simulation/G4Atlas/G4AtlasTools + Simulation/G4Sim/MCTruth + ) + +# External dependencies: +find_package( CLHEP ) +find_package( Geant4 ) +find_package( XercesC ) + +# Component(s) in the package: +atlas_add_component( PreshowerG4_SD + src/*.cxx + src/components/*.cxx + INCLUDE_DIRS ${GEANT4_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} + LINK_LIBRARIES ${GEANT4_LIBRARIES} ${XERCESC_LIBRARIES} ${CLHEP_LIBRARIES} StoreGateLib SGtests GaudiKernel ScintSimEvent G4AtlasToolsLib MCTruth ) + +atlas_add_test( PreshowerG4_SDToolConfig_test + SCRIPT test/PreshowerG4_SDToolConfig_test.py + PROPERTIES TIMEOUT 300 ) + +# Install files from the package: +atlas_install_python_modules( python/*.py ) +atlas_install_scripts( test/*.py ) + diff --git a/Scintillator/ScintG4/PreshowerG4_SD/python/PreshowerG4_SDConfig.py b/Scintillator/ScintG4/PreshowerG4_SD/python/PreshowerG4_SDConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..1b801ae1d5168187febe1c149ae30574ff337574 --- /dev/null +++ b/Scintillator/ScintG4/PreshowerG4_SD/python/PreshowerG4_SDConfig.py @@ -0,0 +1,19 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +from AthenaCommon import CfgMgr +from G4AtlasApps.SimFlags import simFlags + +from ISF_Algorithms.collection_merger_helpers import generate_mergeable_collection_name + + +def getPreshowerSensorSD(name="PreshowerSensorSD", **kwargs): + bare_collection_name = "PreshowerHits" + mergeable_collection_suffix = "_G4" + merger_input_property = "PreshowerHits" + hits_collection_name = generate_mergeable_collection_name(bare_collection_name, + mergeable_collection_suffix, + merger_input_property) + kwargs.setdefault("LogicalVolumeNames", ["Preshower::Plate"]) + kwargs.setdefault("OutputCollectionNames", [hits_collection_name]) + return CfgMgr.PreshowerSensorSDTool(name, **kwargs) + diff --git a/Scintillator/ScintG4/PreshowerG4_SD/python/PreshowerG4_SDConfigDb.py b/Scintillator/ScintG4/PreshowerG4_SD/python/PreshowerG4_SDConfigDb.py new file mode 100644 index 0000000000000000000000000000000000000000..dab39a5150490d7ffa351f5508a37ddaea72b3b2 --- /dev/null +++ b/Scintillator/ScintG4/PreshowerG4_SD/python/PreshowerG4_SDConfigDb.py @@ -0,0 +1,5 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +from AthenaCommon.CfgGetter import addTool + +addTool("PreshowerG4_SD.PreshowerG4_SDConfig.getPreshowerSensorSD" , "PreshowerSensorSD" ) diff --git a/Scintillator/ScintG4/PreshowerG4_SD/python/PreshowerG4_SDToolConfig.py b/Scintillator/ScintG4/PreshowerG4_SD/python/PreshowerG4_SDToolConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..9f7200d5f4ca28b4d75a4f5b1c5e93e04e63c660 --- /dev/null +++ b/Scintillator/ScintG4/PreshowerG4_SD/python/PreshowerG4_SDToolConfig.py @@ -0,0 +1,21 @@ +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from ISF_Algorithms.collection_merger_helpersNew import CollectionMergerCfg + +# from PreshowerG4_SD.PreshowerG4_SDConf import PreshowerSensorSDTool +from PreshowerG4_SD.PreshowerG4_SDConfig import getPreshowerSensorSD + +def PreshowerSensorSDCfg(ConfigFlags, name="PreshowerSensorSD", **kwargs): + + result = ComponentAccumulator() + bare_collection_name = "PreshowerHits" + mergeable_collection_suffix = "_G4" + merger_input_property = "PreshowerHits" + + acc, hits_collection_name = CollectionMergerCfg(ConfigFlags, bare_collection_name, mergeable_collection_suffix, merger_input_property) + kwargs.setdefault("LogicalVolumeNames", ["Preshower::Plate"]) + kwargs.setdefault("OutputCollectionNames", [hits_collection_name]) + + result.merge(acc) + return result, getPreshowerSensorSD(name, **kwargs) diff --git a/Scintillator/ScintG4/PreshowerG4_SD/src/PreshowerSensorSD.cxx b/Scintillator/ScintG4/PreshowerG4_SD/src/PreshowerSensorSD.cxx new file mode 100644 index 0000000000000000000000000000000000000000..fbfa521a7eada20834e734b6908c57edab311b16 --- /dev/null +++ b/Scintillator/ScintG4/PreshowerG4_SD/src/PreshowerSensorSD.cxx @@ -0,0 +1,116 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +// +// Preshower Sensitive Detector. +// The Hits are processed here. For every hit I get the position and +// an information on the sensor in which the interaction happened +// + +// class headers +#include "PreshowerSensorSD.h" + +// athena includes +#include "MCTruth/TrackHelper.h" + +// Geant4 includes +#include "G4Step.hh" +#include "G4ThreeVector.hh" +#include "G4SDManager.hh" +#include "G4Geantino.hh" +#include "G4ChargedGeantino.hh" + +// CLHEP transform +#include "CLHEP/Geometry/Transform3D.h" + +#include <memory> // For make unique + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +PreshowerSensorSD::PreshowerSensorSD( const std::string& name, const std::string& hitCollectionName ) + : G4VSensitiveDetector( name ) + , m_HitColl( hitCollectionName ) +{ +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void PreshowerSensorSD::Initialize(G4HCofThisEvent *) +{ + if (!m_HitColl.isValid()) m_HitColl = std::make_unique<ScintHitCollection>(); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +G4bool PreshowerSensorSD::ProcessHits(G4Step* aStep, G4TouchableHistory* /*ROhist*/) +{ + double edep = aStep->GetTotalEnergyDeposit(); + if(edep==0.) { + if(aStep->GetTrack()->GetDefinition()!=G4Geantino::GeantinoDefinition() && + aStep->GetTrack()->GetDefinition()!=G4ChargedGeantino::ChargedGeantinoDefinition()) + return false; + } + edep *= CLHEP::MeV; + // + // Get the Touchable History: + // + const G4TouchableHistory *myTouch = dynamic_cast<const G4TouchableHistory*>(aStep->GetPreStepPoint()->GetTouchable()); + // + // Get the hit coordinates. Start and End Point + // + G4ThreeVector coord1 = aStep->GetPreStepPoint()->GetPosition(); + G4ThreeVector coord2 = aStep->GetPostStepPoint()->GetPosition(); + // + // Calculate the local step begin and end position. + // From a G4 FAQ: + // http://geant4-hn.slac.stanford.edu:5090/HyperNews/public/get/geometry/17/1.html + // + const G4AffineTransform transformation = myTouch->GetHistory()->GetTopTransform(); + G4ThreeVector localPosition1 = transformation.TransformPoint(coord1); + G4ThreeVector localPosition2 = transformation.TransformPoint(coord2); + // + // Get it into a vector in local coords and with the right units: + // + HepGeom::Point3D<double> lP1,lP2; + + // No funny business with coordinates like ATLAS... + lP1[2] = localPosition1[2]*CLHEP::mm; + lP1[1] = localPosition1[1]*CLHEP::mm; + lP1[0] = localPosition1[0]*CLHEP::mm; + + lP2[2] = localPosition2[2]*CLHEP::mm; + lP2[1] = localPosition2[1]*CLHEP::mm; + lP2[0] = localPosition2[0]*CLHEP::mm; + + // Now Navigate the history to know in what detector the step is: + // and finally set the ID of det element in which the hit is. + // + //G4int History; + // + // Get station and plate + // + int station = 0; + int plate = 0; + this->indexMethod(myTouch, station, plate); + // get the HepMcParticleLink from the TrackHelper + TrackHelper trHelp(aStep->GetTrack()); + m_HitColl->Emplace(lP1, + lP2, + edep, + aStep->GetPreStepPoint()->GetGlobalTime(),//use the global time. i.e. the time from the beginning of the event + trHelp.GetParticleLink(), + 2,station,plate); + return true; +} + +void PreshowerSensorSD::indexMethod(const G4TouchableHistory *myTouch, + int &station, int &plate) { + + + plate = myTouch->GetVolume()->GetCopyNo(); + const std::string stationName = myTouch->GetVolume(1)->GetLogicalVolume()->GetName(); + station = (stationName == "Preshower::PreshowerStationA" ? 0 : 1 ); + + return; +} diff --git a/Scintillator/ScintG4/PreshowerG4_SD/src/PreshowerSensorSD.h b/Scintillator/ScintG4/PreshowerG4_SD/src/PreshowerSensorSD.h new file mode 100644 index 0000000000000000000000000000000000000000..367ed5ff8829354e70050da4449d5ad71c708afb --- /dev/null +++ b/Scintillator/ScintG4/PreshowerG4_SD/src/PreshowerSensorSD.h @@ -0,0 +1,50 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/**************************************************************** + Preshower Sensitive Detector class +****************************************************************/ + +#ifndef PRESHOWERG4_SD_PRESHOWERSENSORSD_H +#define PRESHOWERG4_SD_PRESHOWERSENSORSD_H + +// Base class +#include "G4VSensitiveDetector.hh" + +// For the hits +#include "ScintSimEvent/ScintHitCollection.h" +#include "StoreGate/WriteHandle.h" + +// G4 needed classes +class G4Step; +class G4TouchableHistory; + +class PreshowerSensorSD : public G4VSensitiveDetector +{ +public: + // Constructor + PreshowerSensorSD(const std::string& name, const std::string& hitCollectionName); + + // Destructor + ~PreshowerSensorSD() { /* If all goes well we do not own myHitColl here */ } + + // Deal with each G4 hit + G4bool ProcessHits(G4Step*, G4TouchableHistory*) override; + + // For setting up the hit collection + void Initialize(G4HCofThisEvent*) override final; + + /** Templated method to stuff a single hit into the sensitive detector class. This + could get rather tricky, but the idea is to allow fast simulations to use the very + same SD classes as the standard simulation. */ + template <class... Args> void AddHit(Args&&... args){ m_HitColl->Emplace( args... ); } + +private: + void indexMethod(const G4TouchableHistory *myTouch, int &station, int &plate); +protected: + // The hits collection + SG::WriteHandle<ScintHitCollection> m_HitColl; +}; + +#endif //PRESHOWERG4_SD_PRESHOWERSENSORSD_H diff --git a/Scintillator/ScintG4/PreshowerG4_SD/src/PreshowerSensorSDTool.cxx b/Scintillator/ScintG4/PreshowerG4_SD/src/PreshowerSensorSDTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..dbf2c768e275b051f9e9dac95cc54dc16f0ba669 --- /dev/null +++ b/Scintillator/ScintG4/PreshowerG4_SD/src/PreshowerSensorSDTool.cxx @@ -0,0 +1,32 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// Preshower Sensitive Detector Tool. +// + +// class header +#include "PreshowerSensorSDTool.h" + +// package includes +#include "PreshowerSensorSD.h" + +// STL includes +#include <exception> + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +PreshowerSensorSDTool::PreshowerSensorSDTool(const std::string& type, const std::string& name, const IInterface* parent) + : SensitiveDetectorBase( type , name , parent ) +{ + +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +G4VSensitiveDetector* PreshowerSensorSDTool::makeSD() const +{ + ATH_MSG_DEBUG( "Creating Preshower SD: " << name() ); + return new PreshowerSensorSD(name(), m_outputCollectionNames[0]); +} + diff --git a/Scintillator/ScintG4/PreshowerG4_SD/src/PreshowerSensorSDTool.h b/Scintillator/ScintG4/PreshowerG4_SD/src/PreshowerSensorSDTool.h new file mode 100644 index 0000000000000000000000000000000000000000..34972847c443199661a5960ea8b1d8a58646cb22 --- /dev/null +++ b/Scintillator/ScintG4/PreshowerG4_SD/src/PreshowerSensorSDTool.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/**************************************************************** + Preshower Sensitive Detector Tool + ****************************************************************/ + +#ifndef PRESHOWERG4_SD_PRESHOWERSENSORSDTOOL_H +#define PRESHOWERG4_SD_PRESHOWERSENSORSDTOOL_H + +// Base class +#include "G4AtlasTools/SensitiveDetectorBase.h" + +// STL headers +#include <string> + +class G4VSensitiveDetector; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... + +class PreshowerSensorSDTool : public SensitiveDetectorBase +{ + public: + // Constructor + PreshowerSensorSDTool(const std::string& type, const std::string& name, const IInterface *parent); + + // Destructor + ~PreshowerSensorSDTool() { /* If all goes well we do not own myHitColl here */ } + +protected: + // Make me an SD! + G4VSensitiveDetector* makeSD() const override final; +}; + +#endif //PRESHOWERG4_SD_PRESHOWERSENSORSDTOOL_H diff --git a/Scintillator/ScintG4/PreshowerG4_SD/src/components/PreshowerG4_SD_entries.cxx b/Scintillator/ScintG4/PreshowerG4_SD/src/components/PreshowerG4_SD_entries.cxx new file mode 100644 index 0000000000000000000000000000000000000000..c7ca31ec0cd52a037126a275327eca1ed844c20e --- /dev/null +++ b/Scintillator/ScintG4/PreshowerG4_SD/src/components/PreshowerG4_SD_entries.cxx @@ -0,0 +1,3 @@ +#include "../PreshowerSensorSDTool.h" + +DECLARE_COMPONENT( PreshowerSensorSDTool ) diff --git a/Scintillator/ScintG4/PreshowerG4_SD/test/PreshowerG4_SDToolConfig_test.py b/Scintillator/ScintG4/PreshowerG4_SD/test/PreshowerG4_SDToolConfig_test.py new file mode 100644 index 0000000000000000000000000000000000000000..9f586ed169b7c13b81ad48490833d3df29f51123 --- /dev/null +++ b/Scintillator/ScintG4/PreshowerG4_SD/test/PreshowerG4_SDToolConfig_test.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python +"""Run tests on PreshowerG4_SD configuration + +Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +""" +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator + + +if __name__ == '__main__': + + + #import config flags + from CalypsoConfiguration.AllConfigFlags import ConfigFlags + # Set up logging and config behaviour + from AthenaCommon.Logging import log + from AthenaCommon.Constants import DEBUG + from AthenaCommon.Configurable import Configurable + log.setLevel(DEBUG) + Configurable.configurableRun3Behavior = 1 + + + # ConfigFlags.Sim.ISF.Run = True + ConfigFlags.Detector.SimulatePreshower = True + + #Provide input + from AthenaConfiguration.TestDefaults import defaultTestFiles + inputDir = defaultTestFiles.d + ConfigFlags.Input.Files = defaultTestFiles.EVNT + + # Finalize + ConfigFlags.lock() + + + ## Initialize a new component accumulator + cfg = ComponentAccumulator() + + from PreshowerG4_SD.PreshowerG4_SDToolConfig import PreshowerSensorSDCfg + + acc, tool = PreshowerSensorSDCfg(ConfigFlags) + acc.addPublicTool(tool) + cfg.merge(acc) + + + cfg.printConfig(withDetails=True, summariseProps = True) + ConfigFlags.dump() + + f=open("test.pkl","w") + cfg.store(f) + f.close() + + + + print cfg._publicTools + print "-----------------finished----------------------" diff --git a/Scintillator/ScintG4/TriggerG4_SD/CMakeLists.txt b/Scintillator/ScintG4/TriggerG4_SD/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..41e528f82c92a2b19684e1832c50838987dcc0e9 --- /dev/null +++ b/Scintillator/ScintG4/TriggerG4_SD/CMakeLists.txt @@ -0,0 +1,36 @@ +################################################################################ +# Package: TriggerG4_SD +################################################################################ + +# Declare the package name: +atlas_subdir( TriggerG4_SD ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PRIVATE + Control/StoreGate + GaudiKernel + Scintillator/ScintSimEvent + Simulation/G4Atlas/G4AtlasTools + Simulation/G4Sim/MCTruth + ) + +# External dependencies: +find_package( CLHEP ) +find_package( Geant4 ) +find_package( XercesC ) + +# Component(s) in the package: +atlas_add_component( TriggerG4_SD + src/*.cxx + src/components/*.cxx + INCLUDE_DIRS ${GEANT4_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} + LINK_LIBRARIES ${GEANT4_LIBRARIES} ${XERCESC_LIBRARIES} ${CLHEP_LIBRARIES} StoreGateLib SGtests GaudiKernel ScintSimEvent G4AtlasToolsLib MCTruth ) + +atlas_add_test( TriggerG4_SDToolConfig_test + SCRIPT test/TriggerG4_SDToolConfig_test.py + PROPERTIES TIMEOUT 300 ) + +# Install files from the package: +atlas_install_python_modules( python/*.py ) +atlas_install_scripts( test/*.py ) + diff --git a/Scintillator/ScintG4/TriggerG4_SD/python/TriggerG4_SDConfig.py b/Scintillator/ScintG4/TriggerG4_SD/python/TriggerG4_SDConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..b8da576f86c8d27e2f3cd7bd91f143340f658fe5 --- /dev/null +++ b/Scintillator/ScintG4/TriggerG4_SD/python/TriggerG4_SDConfig.py @@ -0,0 +1,19 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +from AthenaCommon import CfgMgr +from G4AtlasApps.SimFlags import simFlags + +from ISF_Algorithms.collection_merger_helpers import generate_mergeable_collection_name + + +def getTriggerSensorSD(name="TriggerSensorSD", **kwargs): + bare_collection_name = "TriggerHits" + mergeable_collection_suffix = "_G4" + merger_input_property = "TriggerHits" + hits_collection_name = generate_mergeable_collection_name(bare_collection_name, + mergeable_collection_suffix, + merger_input_property) + kwargs.setdefault("LogicalVolumeNames", ["Trigger::Plate"]) + kwargs.setdefault("OutputCollectionNames", [hits_collection_name]) + return CfgMgr.TriggerSensorSDTool(name, **kwargs) + diff --git a/Scintillator/ScintG4/TriggerG4_SD/python/TriggerG4_SDConfigDb.py b/Scintillator/ScintG4/TriggerG4_SD/python/TriggerG4_SDConfigDb.py new file mode 100644 index 0000000000000000000000000000000000000000..48358192c01a5d0cbeaf2542f29d31298e422ad3 --- /dev/null +++ b/Scintillator/ScintG4/TriggerG4_SD/python/TriggerG4_SDConfigDb.py @@ -0,0 +1,5 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +from AthenaCommon.CfgGetter import addTool + +addTool("TriggerG4_SD.TriggerG4_SDConfig.getTriggerSensorSD" , "TriggerSensorSD" ) diff --git a/Scintillator/ScintG4/TriggerG4_SD/python/TriggerG4_SDToolConfig.py b/Scintillator/ScintG4/TriggerG4_SD/python/TriggerG4_SDToolConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..757de83619b99df40f6e0b2e63024f6cd4c6cd7e --- /dev/null +++ b/Scintillator/ScintG4/TriggerG4_SD/python/TriggerG4_SDToolConfig.py @@ -0,0 +1,21 @@ +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from ISF_Algorithms.collection_merger_helpersNew import CollectionMergerCfg + +# from TriggerG4_SD.TriggerG4_SDConf import TriggerSensorSDTool +from TriggerG4_SD.TriggerG4_SDConfig import getTriggerSensorSD + +def TriggerSensorSDCfg(ConfigFlags, name="TriggerSensorSD", **kwargs): + + result = ComponentAccumulator() + bare_collection_name = "TriggerHits" + mergeable_collection_suffix = "_G4" + merger_input_property = "TriggerHits" + + acc, hits_collection_name = CollectionMergerCfg(ConfigFlags, bare_collection_name, mergeable_collection_suffix, merger_input_property) + kwargs.setdefault("LogicalVolumeNames", ["Trigger::Plate"]) + kwargs.setdefault("OutputCollectionNames", [hits_collection_name]) + + result.merge(acc) + return result, getTriggerSensorSD(name, **kwargs) diff --git a/Scintillator/ScintG4/TriggerG4_SD/src/TriggerSensorSD.cxx b/Scintillator/ScintG4/TriggerG4_SD/src/TriggerSensorSD.cxx new file mode 100644 index 0000000000000000000000000000000000000000..516cd37efb4564401e7da1e4d40e64f39fc010b2 --- /dev/null +++ b/Scintillator/ScintG4/TriggerG4_SD/src/TriggerSensorSD.cxx @@ -0,0 +1,116 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +// +// Trigger Sensitive Detector. +// The Hits are processed here. For every hit I get the position and +// an information on the sensor in which the interaction happened +// + +// class headers +#include "TriggerSensorSD.h" + +// athena includes +#include "MCTruth/TrackHelper.h" + +// Geant4 includes +#include "G4Step.hh" +#include "G4ThreeVector.hh" +#include "G4SDManager.hh" +#include "G4Geantino.hh" +#include "G4ChargedGeantino.hh" + +// CLHEP transform +#include "CLHEP/Geometry/Transform3D.h" + +#include <memory> // For make unique + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +TriggerSensorSD::TriggerSensorSD( const std::string& name, const std::string& hitCollectionName ) + : G4VSensitiveDetector( name ) + , m_HitColl( hitCollectionName ) +{ +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void TriggerSensorSD::Initialize(G4HCofThisEvent *) +{ + if (!m_HitColl.isValid()) m_HitColl = std::make_unique<ScintHitCollection>(); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +G4bool TriggerSensorSD::ProcessHits(G4Step* aStep, G4TouchableHistory* /*ROhist*/) +{ + double edep = aStep->GetTotalEnergyDeposit(); + if(edep==0.) { + if(aStep->GetTrack()->GetDefinition()!=G4Geantino::GeantinoDefinition() && + aStep->GetTrack()->GetDefinition()!=G4ChargedGeantino::ChargedGeantinoDefinition()) + return false; + } + edep *= CLHEP::MeV; + // + // Get the Touchable History: + // + const G4TouchableHistory *myTouch = dynamic_cast<const G4TouchableHistory*>(aStep->GetPreStepPoint()->GetTouchable()); + // + // Get the hit coordinates. Start and End Point + // + G4ThreeVector coord1 = aStep->GetPreStepPoint()->GetPosition(); + G4ThreeVector coord2 = aStep->GetPostStepPoint()->GetPosition(); + // + // Calculate the local step begin and end position. + // From a G4 FAQ: + // http://geant4-hn.slac.stanford.edu:5090/HyperNews/public/get/geometry/17/1.html + // + const G4AffineTransform transformation = myTouch->GetHistory()->GetTopTransform(); + G4ThreeVector localPosition1 = transformation.TransformPoint(coord1); + G4ThreeVector localPosition2 = transformation.TransformPoint(coord2); + // + // Get it into a vector in local coords and with the right units: + // + HepGeom::Point3D<double> lP1,lP2; + + // No funny business with coordinates like ATLAS... + lP1[2] = localPosition1[2]*CLHEP::mm; + lP1[1] = localPosition1[1]*CLHEP::mm; + lP1[0] = localPosition1[0]*CLHEP::mm; + + lP2[2] = localPosition2[2]*CLHEP::mm; + lP2[1] = localPosition2[1]*CLHEP::mm; + lP2[0] = localPosition2[0]*CLHEP::mm; + + // Now Navigate the history to know in what detector the step is: + // and finally set the ID of det element in which the hit is. + // + //G4int History; + // + // Get station and plate + // + int station = 0; + int plate = 0; + this->indexMethod(myTouch, station, plate); + // get the HepMcParticleLink from the TrackHelper + TrackHelper trHelp(aStep->GetTrack()); + m_HitColl->Emplace(lP1, + lP2, + edep, + aStep->GetPreStepPoint()->GetGlobalTime(),//use the global time. i.e. the time from the beginning of the event + trHelp.GetParticleLink(), + 1,station,plate); + return true; +} + +void TriggerSensorSD::indexMethod(const G4TouchableHistory *myTouch, + int &station, int &plate) { + + + plate = myTouch->GetVolume()->GetCopyNo(); + const std::string stationName = myTouch->GetVolume(1)->GetLogicalVolume()->GetName(); + station = (stationName == "Trigger::TriggerStationA" ? 0 : 1 ); + + return; +} diff --git a/Scintillator/ScintG4/TriggerG4_SD/src/TriggerSensorSD.h b/Scintillator/ScintG4/TriggerG4_SD/src/TriggerSensorSD.h new file mode 100644 index 0000000000000000000000000000000000000000..da37d6d55da1a4bd6861aa4fac490fa57b632364 --- /dev/null +++ b/Scintillator/ScintG4/TriggerG4_SD/src/TriggerSensorSD.h @@ -0,0 +1,50 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/**************************************************************** + Trigger Sensitive Detector class +****************************************************************/ + +#ifndef TRIGGERG4_SD_TRIGGERSENSORSD_H +#define TRIGGERG4_SD_TRIGGERSENSORSD_H + +// Base class +#include "G4VSensitiveDetector.hh" + +// For the hits +#include "ScintSimEvent/ScintHitCollection.h" +#include "StoreGate/WriteHandle.h" + +// G4 needed classes +class G4Step; +class G4TouchableHistory; + +class TriggerSensorSD : public G4VSensitiveDetector +{ +public: + // Constructor + TriggerSensorSD(const std::string& name, const std::string& hitCollectionName); + + // Destructor + ~TriggerSensorSD() { /* If all goes well we do not own myHitColl here */ } + + // Deal with each G4 hit + G4bool ProcessHits(G4Step*, G4TouchableHistory*) override; + + // For setting up the hit collection + void Initialize(G4HCofThisEvent*) override final; + + /** Templated method to stuff a single hit into the sensitive detector class. This + could get rather tricky, but the idea is to allow fast simulations to use the very + same SD classes as the standard simulation. */ + template <class... Args> void AddHit(Args&&... args){ m_HitColl->Emplace( args... ); } + +private: + void indexMethod(const G4TouchableHistory *myTouch, int &station, int &plate); +protected: + // The hits collection + SG::WriteHandle<ScintHitCollection> m_HitColl; +}; + +#endif //TRIGGERG4_SD_TRIGGERSENSORSD_H diff --git a/Scintillator/ScintG4/TriggerG4_SD/src/TriggerSensorSDTool.cxx b/Scintillator/ScintG4/TriggerG4_SD/src/TriggerSensorSDTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..14a7f6afeaa1d217937b6f73fece80d74f6d358e --- /dev/null +++ b/Scintillator/ScintG4/TriggerG4_SD/src/TriggerSensorSDTool.cxx @@ -0,0 +1,32 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// Trigger Sensitive Detector Tool. +// + +// class header +#include "TriggerSensorSDTool.h" + +// package includes +#include "TriggerSensorSD.h" + +// STL includes +#include <exception> + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +TriggerSensorSDTool::TriggerSensorSDTool(const std::string& type, const std::string& name, const IInterface* parent) + : SensitiveDetectorBase( type , name , parent ) +{ + +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +G4VSensitiveDetector* TriggerSensorSDTool::makeSD() const +{ + ATH_MSG_DEBUG( "Creating Trigger SD: " << name() ); + return new TriggerSensorSD(name(), m_outputCollectionNames[0]); +} + diff --git a/Scintillator/ScintG4/TriggerG4_SD/src/TriggerSensorSDTool.h b/Scintillator/ScintG4/TriggerG4_SD/src/TriggerSensorSDTool.h new file mode 100644 index 0000000000000000000000000000000000000000..533ba214fb54abeb9f55ad08cb7b95213a45ee0b --- /dev/null +++ b/Scintillator/ScintG4/TriggerG4_SD/src/TriggerSensorSDTool.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/**************************************************************** + Trigger Sensitive Detector Tool + ****************************************************************/ + +#ifndef TRIGGERG4_SD_TRIGGERSENSORSDTOOL_H +#define TRIGGERG4_SD_TRIGGERSENSORSDTOOL_H + +// Base class +#include "G4AtlasTools/SensitiveDetectorBase.h" + +// STL headers +#include <string> + +class G4VSensitiveDetector; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... + +class TriggerSensorSDTool : public SensitiveDetectorBase +{ + public: + // Constructor + TriggerSensorSDTool(const std::string& type, const std::string& name, const IInterface *parent); + + // Destructor + ~TriggerSensorSDTool() { /* If all goes well we do not own myHitColl here */ } + +protected: + // Make me an SD! + G4VSensitiveDetector* makeSD() const override final; +}; + +#endif //TRIGGERG4_SD_TRIGGERSENSORSDTOOL_H diff --git a/Scintillator/ScintG4/TriggerG4_SD/src/components/TriggerG4_SD_entries.cxx b/Scintillator/ScintG4/TriggerG4_SD/src/components/TriggerG4_SD_entries.cxx new file mode 100644 index 0000000000000000000000000000000000000000..82d3e54983eb40bebb40e4a516dbda3c47c5da3f --- /dev/null +++ b/Scintillator/ScintG4/TriggerG4_SD/src/components/TriggerG4_SD_entries.cxx @@ -0,0 +1,3 @@ +#include "../TriggerSensorSDTool.h" + +DECLARE_COMPONENT( TriggerSensorSDTool ) diff --git a/Scintillator/ScintG4/TriggerG4_SD/test/TriggerG4_SDToolConfig_test.py b/Scintillator/ScintG4/TriggerG4_SD/test/TriggerG4_SDToolConfig_test.py new file mode 100644 index 0000000000000000000000000000000000000000..5c482eee3f6d12f12785089888f3761f4b1d62ee --- /dev/null +++ b/Scintillator/ScintG4/TriggerG4_SD/test/TriggerG4_SDToolConfig_test.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python +"""Run tests on TriggerG4_SD configuration + +Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +""" +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator + + +if __name__ == '__main__': + + + #import config flags + from CalypsoConfiguration.AllConfigFlags import ConfigFlags + # Set up logging and config behaviour + from AthenaCommon.Logging import log + from AthenaCommon.Constants import DEBUG + from AthenaCommon.Configurable import Configurable + log.setLevel(DEBUG) + Configurable.configurableRun3Behavior = 1 + + + # ConfigFlags.Sim.ISF.Run = True + ConfigFlags.Detector.SimulateTrigger = True + + #Provide input + from AthenaConfiguration.TestDefaults import defaultTestFiles + inputDir = defaultTestFiles.d + ConfigFlags.Input.Files = defaultTestFiles.EVNT + + # Finalize + ConfigFlags.lock() + + + ## Initialize a new component accumulator + cfg = ComponentAccumulator() + + from TriggerG4_SD.TriggerG4_SDToolConfig import TriggerSensorSDCfg + + acc, tool = TriggerSensorSDCfg(ConfigFlags) + acc.addPublicTool(tool) + cfg.merge(acc) + + + cfg.printConfig(withDetails=True, summariseProps = True) + ConfigFlags.dump() + + f=open("test.pkl","w") + cfg.store(f) + f.close() + + + + print cfg._publicTools + print "-----------------finished----------------------" diff --git a/Simulation/G4Faser/G4FaserApp/test/runG4.py b/Simulation/G4Faser/G4FaserApp/test/runG4.py index 1b4a8c173e0a55a9e7fce1d4d797a98091fa98ef..06157d9f7603ebdfec2df597448ed254d1163e7b 100644 --- a/Simulation/G4Faser/G4FaserApp/test/runG4.py +++ b/Simulation/G4Faser/G4FaserApp/test/runG4.py @@ -22,6 +22,8 @@ if __name__ == "__main__": from G4AtlasTools.G4AtlasToolsConf import SensitiveDetectorMasterTool from G4FaserTools.G4FaserToolsConfig import generateSensitiveDetectorList from VetoG4_SD.VetoG4_SDToolConfig import VetoSensorSDCfg + from TriggerG4_SD.TriggerG4_SDToolConfig import TriggerSensorSDCfg + from PreshowerG4_SD.PreshowerG4_SDToolConfig import PreshowerSensorSDCfg from FaserSCT_G4_SD.FaserSCT_G4_SDToolConfig import SctSensorSDCfg # # Set up logging and new style config @@ -66,6 +68,10 @@ if __name__ == "__main__": # ConfigFlags.Detector.SimulateVeto = True ConfigFlags.Detector.GeometryVeto = True + ConfigFlags.Detector.SimulateTrigger= True + ConfigFlags.Detector.GeometryTrigger= True + ConfigFlags.Detector.SimulatePreshower = True + ConfigFlags.Detector.GeometryPreshower = True ConfigFlags.Detector.SimulateFaserSCT = True ConfigFlags.Detector.GeometryFaserSCT = True ConfigFlags.Detector.SimulateUpstreamDipole = True @@ -122,11 +128,15 @@ if __name__ == "__main__": acc.merge(G4FaserAlgCfg(ConfigFlags)) algo = acc.getEventAlgo("G4FaserAlg") veto, vetosd = VetoSensorSDCfg(ConfigFlags) + trigger, triggersd = TriggerSensorSDCfg(ConfigFlags) + preshower, preshowersd = PreshowerSensorSDCfg(ConfigFlags) sct, sctsd = SctSensorSDCfg(ConfigFlags) - sendet = SensitiveDetectorMasterTool(SensitiveDetectors = [vetosd,sctsd]) + sendet = SensitiveDetectorMasterTool(SensitiveDetectors = [vetosd,triggersd,preshowersd,sctsd]) acc.addPublicTool(sendet) algo.SenDetMasterTool = sendet acc.merge(veto) + acc.merge(trigger) + acc.merge(preshower) acc.merge(sct) acc.addService(G4GeometryNotifierSvcCfg(ConfigFlags, ActivateLVNotifier=True)) diff --git a/Simulation/G4Faser/G4FaserServices/python/G4FaserServicesConfigNew.py b/Simulation/G4Faser/G4FaserServices/python/G4FaserServicesConfigNew.py index b26b6b33dbb94a949ab7274c71d52d2b317faa5c..6b12511cd32e6eb475e393f5e6e16e0e9366272d 100644 --- a/Simulation/G4Faser/G4FaserServices/python/G4FaserServicesConfigNew.py +++ b/Simulation/G4Faser/G4FaserServices/python/G4FaserServicesConfigNew.py @@ -17,7 +17,7 @@ from G4FaserTools.G4GeometryToolConfig import MaterialDescriptionToolCfg, G4Atla # # Magnetic field tools - start simple # -from G4FaserTools.G4FieldConfigNew import FASERFieldManagerToolCfg, VetoFieldManagerToolCfg +from G4FaserTools.G4FieldConfigNew import FASERFieldManagerToolCfg, VetoFieldManagerToolCfg, TriggerFieldManagerToolCfg, PreshowerFieldManagerToolCfg # # Future field managers (?) # @@ -75,14 +75,14 @@ def FASER_FieldMgrListCfg(ConfigFlags): acc = VetoFieldManagerToolCfg(ConfigFlags) tool = result.popToolsAndMerge(acc) fieldMgrList += [tool] - # if ConfigFlags.Detector.SimulateTrigger: - # acc = TriggerFieldManagerToolCfg(ConfigFlags) - # tool = result.popToolsAndMerge(acc) - # fieldMgrList += [tool] - # if ConfigFlags.Detector.SimulatePreshower: - # acc = PreshowerFieldManagerToolCfg(ConfigFlags) - # tool = result.popToolsAndMerge(acc) - # fieldMgrList += [tool] + if ConfigFlags.Detector.SimulateTrigger: + acc = TriggerFieldManagerToolCfg(ConfigFlags) + tool = result.popToolsAndMerge(acc) + fieldMgrList += [tool] + if ConfigFlags.Detector.SimulatePreshower: + acc = PreshowerFieldManagerToolCfg(ConfigFlags) + tool = result.popToolsAndMerge(acc) + fieldMgrList += [tool] if ConfigFlags.Detector.SimulateTracker: acc = TrackerFieldManagerToolCfg(ConfigFlags) tool = result.popToolsAndMerge(acc) diff --git a/Simulation/G4Faser/G4FaserTools/python/G4FaserToolsConfig.py b/Simulation/G4Faser/G4FaserTools/python/G4FaserToolsConfig.py index 39bb811698c8fecbd7852a948f3d170f9c89a607..0c47f6b7038425e65978e3ada70555638925fdd1 100644 --- a/Simulation/G4Faser/G4FaserTools/python/G4FaserToolsConfig.py +++ b/Simulation/G4Faser/G4FaserTools/python/G4FaserToolsConfig.py @@ -73,10 +73,10 @@ def generateScintillatorSensitiveDetectorList(): if (ConfigFlags.Detector.SimulateScintillator): if (ConfigFlags.Detector.SimulateVeto): SensitiveDetectorList += [ 'VetoSensorSD' ] - # if (ConfigFlags.Detector.SimulateTrigger): - # SensitiveDetectorList += [ 'TriggerSensorSD'] - # if (ConfigFlags.Detector.SimulatePreshowe): - # SensitiveDetectorList += [ 'PreshowerSD'] + if (ConfigFlags.Detector.SimulateTrigger): + SensitiveDetectorList += [ 'TriggerSensorSD'] + if (ConfigFlags.Detector.SimulatePreshowe): + SensitiveDetectorList += [ 'PreshowerSD'] return SensitiveDetectorList def generateTrackerSensitiveDetectorList(): diff --git a/Simulation/G4Faser/G4FaserTools/python/G4FieldConfigNew.py b/Simulation/G4Faser/G4FaserTools/python/G4FieldConfigNew.py index 91a2bc9b1a99fb1313e68143de5c13c791f23be8..60b13be2124d66e4ad582b7056dc884933af5f1d 100644 --- a/Simulation/G4Faser/G4FaserTools/python/G4FieldConfigNew.py +++ b/Simulation/G4Faser/G4FaserTools/python/G4FieldConfigNew.py @@ -98,6 +98,28 @@ def VetoFieldManagerToolCfg(ConfigFlags, name='VetoFieldManager', **kwargs): return BasicDetectorFieldManagerToolCfg(ConfigFlags, name, **kwargs) +def TriggerFieldManagerToolCfg(ConfigFlags, name='TriggerFieldManager', **kwargs): + kwargs.setdefault("LogicalVolumes", ['Trigger::Trigger']) + #kwargs.setdefault('DeltaChord', 0.00001) + kwargs.setdefault('DeltaIntersection', 0.00001) + kwargs.setdefault('DeltaOneStep', 0.0001) + kwargs.setdefault('MaximumEpsilonStep', 0.001) + kwargs.setdefault('MinimumEpsilonStep', 0.00001) + # return BasicDetectorConstantFieldManagerToolCfg(ConfigFlags, name, **kwargs) + return BasicDetectorFieldManagerToolCfg(ConfigFlags, name, **kwargs) + + +def PreshowerFieldManagerToolCfg(ConfigFlags, name='PreshowerFieldManager', **kwargs): + kwargs.setdefault("LogicalVolumes", ['Preshower::Preshower']) + #kwargs.setdefault('DeltaChord', 0.00001) + kwargs.setdefault('DeltaIntersection', 0.00001) + kwargs.setdefault('DeltaOneStep', 0.0001) + kwargs.setdefault('MaximumEpsilonStep', 0.001) + kwargs.setdefault('MinimumEpsilonStep', 0.00001) + # return BasicDetectorConstantFieldManagerToolCfg(ConfigFlags, name, **kwargs) + return BasicDetectorFieldManagerToolCfg(ConfigFlags, name, **kwargs) + + def TrackerFieldManagerToolCfg(ConfigFlags, name='TrackerFieldManager', **kwargs): kwargs.setdefault("LogicalVolumes", ['SCT::Station']) #kwargs.setdefault('DeltaChord', 0.00001) diff --git a/Simulation/G4Faser/G4FaserTools/python/G4GeometryToolConfig.py b/Simulation/G4Faser/G4FaserTools/python/G4GeometryToolConfig.py index f1722d2cd319ad76c8b8421eaaa90b34c137cc12..97dd909e6f500eeeec44340be2198fa024af5392 100644 --- a/Simulation/G4Faser/G4FaserTools/python/G4GeometryToolConfig.py +++ b/Simulation/G4Faser/G4FaserTools/python/G4GeometryToolConfig.py @@ -7,6 +7,8 @@ from G4AtlasTools.G4AtlasToolsConf import CylindricalEnvelope, PolyconicalEnvelo from AthenaCommon.SystemOfUnits import mm, cm, m from VetoGeoModel.VetoGeoModelConfig import VetoGeometryCfg +from TriggerGeoModel.TriggerGeoModelConfig import TriggerGeometryCfg +from PreshowerGeoModel.PreshowerGeoModelConfig import PreshowerGeometryCfg from FaserSCT_GeoModel.FaserSCT_GeoModelConfig import FaserSCT_GeometryCfg from DipoleGeoModel.DipoleGeoModelConfig import DipoleGeometryCfg @@ -21,6 +23,18 @@ def VetoGeoDetectorToolCfg(ConfigFlags, name='Veto', **kwargs): kwargs.setdefault("DetectorName", "Veto") return result, GeoDetectorTool(name, **kwargs) +def TriggerGeoDetectorToolCfg(ConfigFlags, name='Trigger', **kwargs): + #set up geometry + result=TriggerGeometryCfg(ConfigFlags) + kwargs.setdefault("DetectorName", "Trigger") + return result, GeoDetectorTool(name, **kwargs) + +def PreshowerGeoDetectorToolCfg(ConfigFlags, name='Preshower', **kwargs): + #set up geometry + result=PreshowerGeometryCfg(ConfigFlags) + kwargs.setdefault("DetectorName", "Preshower") + return result, GeoDetectorTool(name, **kwargs) + def SCTGeoDetectorToolCfg(ConfigFlags, name='SCT', **kwargs): #set up geometry result=FaserSCT_GeometryCfg(ConfigFlags) @@ -42,6 +56,16 @@ def generateSubDetectorList(ConfigFlags): SubDetectorList += [ toolVeto ] result.merge(accVeto) + if ConfigFlags.Detector.SimulateTrigger: + accTrigger, toolTrigger = TriggerGeoDetectorToolCfg(ConfigFlags) + SubDetectorList += [ toolTrigger ] + result.merge(accTrigger) + + if ConfigFlags.Detector.SimulatePreshower: + accPreshower, toolPreshower = PreshowerGeoDetectorToolCfg(ConfigFlags) + SubDetectorList += [ toolPreshower ] + result.merge(accPreshower) + if ConfigFlags.Detector.SimulateFaserSCT: accSCT, toolSCT = SCTGeoDetectorToolCfg(ConfigFlags) SubDetectorList += [ toolSCT ] @@ -73,7 +97,7 @@ def FASEREnvelopeCfg(ConfigFlags, name="Faser", **kwargs): # kwargs.setdefault("dZ", 33.0 * mm) kwargs.setdefault("dX", 600.0 * mm) kwargs.setdefault("dY", 600.0 * mm) - kwargs.setdefault("dZ", 2500.0 * mm) + kwargs.setdefault("dZ", 3000.0 * mm) kwargs.setdefault("SubDetectors", SubDetectorList) diff --git a/graphics/VTI12/VTI12Utils/src/VP1DetInfo.cxx b/graphics/VTI12/VTI12Utils/src/VP1DetInfo.cxx index b1f26b327cabf70abf00404ee979e7a6d6b41b01..0415dbaedf907ab8293164586bdb2f77de80b5a3 100644 --- a/graphics/VTI12/VTI12Utils/src/VP1DetInfo.cxx +++ b/graphics/VTI12/VTI12Utils/src/VP1DetInfo.cxx @@ -23,12 +23,16 @@ #include "GeoModelKernel/GeoPVConstLink.h" #include "ScintReadoutGeometry/VetoDetectorManager.h" +#include "ScintReadoutGeometry/TriggerDetectorManager.h" +#include "ScintReadoutGeometry/PreshowerDetectorManager.h" #include "TrackerReadoutGeometry/SCT_DetectorManager.h" #include "FaserDetDescr/FaserDetectorID.h" #include "ScintIdentifier/VetoID.h" +#include "ScintIdentifier/TriggerID.h" +#include "ScintIdentifier/PreshowerID.h" #include "TrackerIdentifier/FaserSCT_ID.h" @@ -116,20 +120,16 @@ const T * VP1DetInfo::Imp::cachedRetrieve(const T*& cachedPtr, const char* prefe } const ScintDD::VetoDetectorManager * VP1DetInfo::vetoDetMgr() { return Imp::cachedRetrieve(Imp::m_vetoDetMgr,"Veto",VP1JobConfigInfo::hasVetoGeometry()); } -const ScintDD::TriggerDetectorManager * VP1DetInfo::triggerDetMgr() { return nullptr; } -const ScintDD::PreshowerDetectorManager * VP1DetInfo::preshowerDetMgr() {return nullptr; } -// const ScintDD::TriggerDetectorManager * VP1DetInfo::triggerDetMgr() { return Imp::cachedRetrieve(Imp::m_triggerDetMgr,"Trigger",VP1JobConfigInfo::hasTriggerGeometry()); } -// const ScintDD::PreshowerDetectorManager * VP1DetInfo::preshowerDetMgr() { return Imp::cachedRetrieve(Imp::m_preshowerDetMgr,"Preshower",VP1JobConfigInfo::hasPreshowerGeometry()); } +const ScintDD::TriggerDetectorManager * VP1DetInfo::triggerDetMgr() { return Imp::cachedRetrieve(Imp::m_triggerDetMgr,"Trigger",VP1JobConfigInfo::hasTriggerGeometry()); } +const ScintDD::PreshowerDetectorManager * VP1DetInfo::preshowerDetMgr() { return Imp::cachedRetrieve(Imp::m_preshowerDetMgr,"Preshower",VP1JobConfigInfo::hasPreshowerGeometry()); } const TrackerDD::SCT_DetectorManager * VP1DetInfo::sctDetMgr() { return Imp::cachedRetrieve(Imp::m_sctDetMgr,"SCT",VP1JobConfigInfo::hasSCTGeometry()); } const FaserDetectorID * VP1DetInfo::faserIDHelper() { return Imp::cachedRetrieve(Imp::m_faserIDHelper,"FaserID",true); } const VetoID * VP1DetInfo::vetoIDHelper() { return Imp::cachedRetrieve(Imp::m_vetoIDHelper,"VetoID",VP1JobConfigInfo::hasVetoGeometry()); } -const TriggerID * VP1DetInfo::triggerIDHelper() { return nullptr; } -const PreshowerID * VP1DetInfo::preshowerIDHelper() { return nullptr; } -// const TriggerID * VP1DetInfo::triggerIDHelper() { return Imp::cachedRetrieve(Imp::m_triggerIDHelper,"TriggerID",VP1JobConfigInfo::hasTriggerGeometry()); } -// const PreshowerID * VP1DetInfo::preshowerIDHelper() { return Imp::cachedRetrieve(Imp::m_preshowerIDHelper,"PreshowerID",VP1JobConfigInfo::hasPreshowerGeometry()); } +const TriggerID * VP1DetInfo::triggerIDHelper() { return Imp::cachedRetrieve(Imp::m_triggerIDHelper,"TriggerID",VP1JobConfigInfo::hasTriggerGeometry()); } +const PreshowerID * VP1DetInfo::preshowerIDHelper() { return Imp::cachedRetrieve(Imp::m_preshowerIDHelper,"PreshowerID",VP1JobConfigInfo::hasPreshowerGeometry()); } const FaserSCT_ID * VP1DetInfo::sctIDHelper() { return Imp::cachedRetrieve(Imp::m_sctIDHelper,"FaserSCT_ID",VP1JobConfigInfo::hasSCTGeometry()); } diff --git a/graphics/VTI12/VTI12Utils/src/VP1JobConfigInfo.cxx b/graphics/VTI12/VTI12Utils/src/VP1JobConfigInfo.cxx index 443516f2344bc1622621a1456d8a182aa328746b..3cb7089466bb7bf5cfa6e94eb6739eac574bafcb 100644 --- a/graphics/VTI12/VTI12Utils/src/VP1JobConfigInfo.cxx +++ b/graphics/VTI12/VTI12Utils/src/VP1JobConfigInfo.cxx @@ -84,9 +84,9 @@ void VP1JobConfigInfo::Imp::ensureInit() if (VP1Msg::verbose()) { VP1Msg::messageVerbose("VTI12JobConfigInfo => Found job configuration:"); VP1Msg::messageVerbose("VTI12JobConfigInfo => hasGeoModelExperiment = "+QString(hasGeoModelExperiment?"On":"Off")); - VP1Msg::messageVerbose("VP1JobConfigInfo => hasVetoGeometry = "+QString(hasVetoGeometry?"On":"Off")); - VP1Msg::messageVerbose("VP1JobConfigInfo => hasTriggerGeometry = "+QString(hasTriggerGeometry?"On":"Off")); - VP1Msg::messageVerbose("VP1JobConfigInfo => hasPreshowerGeometry = "+QString(hasPreshowerGeometry?"On":"Off")); + VP1Msg::messageVerbose("VTI12JobConfigInfo => hasVetoGeometry = "+QString(hasVetoGeometry?"On":"Off")); + VP1Msg::messageVerbose("VTI12JobConfigInfo => hasTriggerGeometry = "+QString(hasTriggerGeometry?"On":"Off")); + VP1Msg::messageVerbose("VTI12JobConfigInfo => hasPreshowerGeometry = "+QString(hasPreshowerGeometry?"On":"Off")); // VP1Msg::messageVerbose("VP1JobConfigInfo => hasPixelGeometry = "+QString(hasPixelGeometry?"On":"Off")); VP1Msg::messageVerbose("VP1JobConfigInfo => hasSCTGeometry = "+QString(hasSCTGeometry?"On":"Off")); @@ -151,6 +151,7 @@ bool VP1JobConfigInfo::Imp::actualInit( StoreGateSvc* detStore ) while (!av.atEnd()) { std::string name = av.getName(); + // VP1Msg::message( QString { name.c_str() } ); if ( !hasVetoGeometry && name=="Veto") hasVetoGeometry = true; if ( !hasTriggerGeometry && name=="Trigger") hasTriggerGeometry = true; if ( !hasPreshowerGeometry && name=="Preshower") hasPreshowerGeometry = true;