diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3cba605b33ce3adcd9ad6a604170521570005156..0aef82debb458e44c3b9bfa1dceb4d2f79548bee 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -25,7 +25,7 @@ build_image: - mkdir build - cd build - set +e && source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh; set -e - - set +e && asetup --input=../../calypso/asetup.faser Athena,22.0.40; set -e + - set +e && asetup --input=../../calypso/asetup.faser Athena,22.0.49; set -e - cmake ../../calypso - make -j 3 artifacts: @@ -41,7 +41,7 @@ test_unittest: - yum -y install man - cd build - set +e && source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh; set -e - - set +e && asetup --input=../../calypso/asetup.faser Athena,22.0.40; set -e + - set +e && asetup --input=../../calypso/asetup.faser Athena,22.0.49; set -e - set +e && source `find . -name 'setup.sh'`; set -e - ctest -j3 dependencies: diff --git a/Calorimeter/CaloEventCnv/FaserCaloSimEventAthenaPool/src/CaloHitCollectionCnv.cxx b/Calorimeter/CaloEventCnv/FaserCaloSimEventAthenaPool/src/CaloHitCollectionCnv.cxx index 2ac860d86c8f3c42b3c5f1382f36e905bc17371c..6abec9240110bcc60b27a2afec12a9a7029fa242 100644 --- a/Calorimeter/CaloEventCnv/FaserCaloSimEventAthenaPool/src/CaloHitCollectionCnv.cxx +++ b/Calorimeter/CaloEventCnv/FaserCaloSimEventAthenaPool/src/CaloHitCollectionCnv.cxx @@ -18,12 +18,16 @@ CaloHitCollection_PERS* CaloHitCollectionCnv::createPersistent(CaloHitCollection CaloHitCollection* CaloHitCollectionCnv::createTransient() { MsgStream mlog(msgSvc(), "CaloHitCollectionConverter" ); CaloHitCollectionCnv_p1 converter_p1; + CaloHitCollectionCnv_p1a converter_p1a; static const pool::Guid p1_guid("134E8045-AB99-43EF-9AD1-324C48830B64"); - // static const pool::Guid p1_guid("B2573A16-4B46-4E1E-98E3-F93421680779"); + static const pool::Guid p1a_guid("02C108EE-0AD9-4444-83BD-D5273FCDEF6F"); CaloHitCollection *trans_cont(0); - if( this->compareClassGuid(p1_guid)) { + if( this->compareClassGuid(p1a_guid)) { + std::unique_ptr< CaloHitCollection_p1a > col_vect( this->poolReadObject< CaloHitCollection_p1a >() ); + trans_cont = converter_p1a.createTransient( col_vect.get(), mlog ); + } else if( this->compareClassGuid(p1_guid)) { std::unique_ptr< CaloHitCollection_p1 > col_vect( this->poolReadObject< CaloHitCollection_p1 >() ); trans_cont = converter_p1.createTransient( col_vect.get(), mlog ); } else { diff --git a/Calorimeter/CaloEventCnv/FaserCaloSimEventAthenaPool/src/CaloHitCollectionCnv.h b/Calorimeter/CaloEventCnv/FaserCaloSimEventAthenaPool/src/CaloHitCollectionCnv.h index b46894c5ffe1f96fe91451b9206269b2f8e44b53..1de7cc3e08b9d75f340646ee1c4007e78211a6bb 100644 --- a/Calorimeter/CaloEventCnv/FaserCaloSimEventAthenaPool/src/CaloHitCollectionCnv.h +++ b/Calorimeter/CaloEventCnv/FaserCaloSimEventAthenaPool/src/CaloHitCollectionCnv.h @@ -8,12 +8,14 @@ #include "FaserCaloSimEvent/CaloHitCollection.h" #include "FaserCaloSimEventTPCnv/CaloHits/CaloHitCollection_p1.h" #include "FaserCaloSimEventTPCnv/CaloHits/CaloHitCollectionCnv_p1.h" +#include "FaserCaloSimEventTPCnv/CaloHits/CaloHitCollection_p1a.h" +#include "FaserCaloSimEventTPCnv/CaloHits/CaloHitCollectionCnv_p1a.h" #include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" // Gaudi #include "GaudiKernel/MsgStream.h" // typedef to the latest persistent version -typedef CaloHitCollection_p1 CaloHitCollection_PERS; -typedef CaloHitCollectionCnv_p1 CaloHitCollectionCnv_PERS; +typedef CaloHitCollection_p1a CaloHitCollection_PERS; +typedef CaloHitCollectionCnv_p1a CaloHitCollectionCnv_PERS; class CaloHitCollectionCnv : public T_AthenaPoolCustomCnv<CaloHitCollection, CaloHitCollection_PERS > { friend class CnvFactory<CaloHitCollectionCnv>; diff --git a/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/CMakeLists.txt b/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/CMakeLists.txt index dbbd1a372aa26fde66a58aee80ce3bf30f758812..ef770c2b59d440fe41bc1c63893f49ecd0d49439 100644 --- a/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/CMakeLists.txt +++ b/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/CMakeLists.txt @@ -22,5 +22,5 @@ atlas_add_dictionary( FaserCaloSimEventTPCnvDict FaserCaloSimEventTPCnv/CaloSimEventTPCnvDict.h FaserCaloSimEventTPCnv/selection.xml INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaPoolCnvSvcLib GaudiKernel GeneratorObjectsTPCnv FaserCaloSimEvent TestTools StoreGateLib SGtests Identifier FaserCaloSimEventTPCnv ) + LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaPoolCnvSvcLib GaudiKernel GeneratorObjectsTPCnv FaserCaloSimEvent TestTools StoreGateLib SGtests Identifier FaserCaloSimEventTPCnv AthenaKernel) diff --git a/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/FaserCaloSimEventTPCnv/CaloHits/CaloHitCollectionCnv_p1a.h b/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/FaserCaloSimEventTPCnv/CaloHits/CaloHitCollectionCnv_p1a.h new file mode 100644 index 0000000000000000000000000000000000000000..80534aae7aaff3b32ca4bb1aff9105296859e05a --- /dev/null +++ b/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/FaserCaloSimEventTPCnv/CaloHits/CaloHitCollectionCnv_p1a.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef CALOHITCOLLECTIONCNV_P1A_H +#define CALOHITCOLLECTIONCNV_P1A_H + +// CaloHitCollectionCnv_p1, T/P separation of Calo Hits +// author D.Costanzo <davide.costanzo@cern.ch> +// author O.Arnaez <olivier.arnaez@cern.ch> + +#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h" +#include "FaserCaloSimEvent/CaloHitCollection.h" +#include "CaloHitCollection_p1a.h" + + +class CaloHitCollectionCnv_p1a : public T_AthenaPoolTPCnvBase<CaloHitCollection, CaloHitCollection_p1a> +{ + public: + + CaloHitCollectionCnv_p1a() {}; + + virtual CaloHitCollection* createTransient(const CaloHitCollection_p1a* persObj, MsgStream &log); + + virtual void persToTrans(const CaloHitCollection_p1a* persCont, + CaloHitCollection* transCont, + MsgStream &log) ; + virtual void transToPers(const CaloHitCollection* transCont, + CaloHitCollection_p1a* persCont, + MsgStream &log) ; + + private: + + static const double m_persEneUnit; + static const double m_persLenUnit; + static const double m_persAngUnit; + static const double m_2bHalfMaximum; + static const int m_2bMaximum; +}; + +#endif diff --git a/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/FaserCaloSimEventTPCnv/CaloHits/CaloHitCollection_p1a.h b/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/FaserCaloSimEventTPCnv/CaloHits/CaloHitCollection_p1a.h new file mode 100644 index 0000000000000000000000000000000000000000..7dc511d9d281c6223c6a6209f0b6778ddb399703 --- /dev/null +++ b/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/FaserCaloSimEventTPCnv/CaloHits/CaloHitCollection_p1a.h @@ -0,0 +1,59 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef CALOHITCOLLECTION_P1A_H +#define CALOHITCOLLECTION_P1A_H + +/* + +Authors: Davide Costanzo Rob Duxfield +Modified for FASER by D. Casper - change internal unsigned short counters to unsigned long +p2, p3, etc reserved for possible future ATLAS changes + +*/ + +#include <vector> +#include <string> + +class CaloHitCollection_p1a +{ + public: +/// Default constructor + CaloHitCollection_p1a (); + //private: + + std::vector<float> m_hit1_meanTime; // 1 element per string + std::vector<float> m_hit1_x0; // + std::vector<float> m_hit1_y0; // + std::vector<float> m_hit1_z0; // + std::vector<float> m_hit1_theta; // + std::vector<float> m_hit1_phi; // + std::vector<unsigned long> m_nHits; // + + std::vector<unsigned short> m_hitEne_2b; // 1 element per hit + std::vector<unsigned short> m_hitLength_2b; // + + std::vector<unsigned short> m_dTheta; // 1 element per hit except for first hit in string + std::vector<unsigned short> m_dPhi; // + + std::vector<float> m_hitEne_4b; // 1 element per hit with m_hitEne_2b[i] == 2**16 + + std::vector<float> m_hitLength_4b; // 1 element per hit with m_hitLength_2b[i] == 2**16 + + std::vector<unsigned long> m_barcode; + std::vector<unsigned long> m_mcEvtIndex; + std::vector<char> m_evtColl; + std::vector<unsigned long> m_nBC; + + std::vector<unsigned long> m_id; + std::vector<unsigned long> m_nId; +}; + + +// inlines + +inline +CaloHitCollection_p1a::CaloHitCollection_p1a () {} + +#endif diff --git a/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/FaserCaloSimEventTPCnv/CaloSimEventTPCnvDict.h b/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/FaserCaloSimEventTPCnv/CaloSimEventTPCnvDict.h index 80937ffc825a51c8dc4611a559507fcd0e7e30b5..de24c20ac134a200e6de30114da8ea2d2ed56210 100644 --- a/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/FaserCaloSimEventTPCnv/CaloSimEventTPCnvDict.h +++ b/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/FaserCaloSimEventTPCnv/CaloSimEventTPCnvDict.h @@ -15,6 +15,8 @@ #include "FaserCaloSimEventTPCnv/CaloHits/CaloHitCnv_p1.h" #include "FaserCaloSimEventTPCnv/CaloHits/CaloHitCollectionCnv_p1.h" #include "FaserCaloSimEventTPCnv/CaloHits/CaloHitCollection_p1.h" +#include "FaserCaloSimEventTPCnv/CaloHits/CaloHitCollectionCnv_p1a.h" +#include "FaserCaloSimEventTPCnv/CaloHits/CaloHitCollection_p1a.h" #include "FaserCaloSimEventTPCnv/CaloHits/CaloHit_p1.h" #endif // CALOEVENTTPCNV_CALOSIMEVENTTPCNVDICT_H diff --git a/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/FaserCaloSimEventTPCnv/selection.xml b/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/FaserCaloSimEventTPCnv/selection.xml index d73b5ce1a258bce7766b3278358530e5a99b4fbc..e90551988f46845a79383bb3ec830265715ea73e 100644 --- a/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/FaserCaloSimEventTPCnv/selection.xml +++ b/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/FaserCaloSimEventTPCnv/selection.xml @@ -4,4 +4,6 @@ <class name="CaloHit_p1" /> <class name="std::vector<CaloHit_p1>" /> <class name="CaloHitCollection_p1" id="134E8045-AB99-43EF-9AD1-324C48830B64" /> + <class name="CaloHitCollection_p1a" id="02C108EE-0AD9-4444-83BD-D5273FCDEF6F" /> + </lcgdict> diff --git a/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/src/CaloHits/CaloHitCollectionCnv_p1.cxx b/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/src/CaloHits/CaloHitCollectionCnv_p1.cxx index c54f8765abfcbeda9b8c72b67717608c9c8b21ef..0568ff080b1e634023284128efdd7909dbc85af2 100644 --- a/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/src/CaloHits/CaloHitCollectionCnv_p1.cxx +++ b/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/src/CaloHits/CaloHitCollectionCnv_p1.cxx @@ -14,7 +14,10 @@ #include "CLHEP/Geometry/Point3D.h" // Gaudi #include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/ThreadLocalContext.h" + // Athena +#include "AthenaKernel/ExtendedEventContext.h" #include "StoreGate/StoreGateSvc.h" // * * * stolen from eflowRec * * * // @@ -60,7 +63,7 @@ const double CaloHitCollectionCnv_p1::m_2bHalfMaximum = pow(2.0, 15.0); const int CaloHitCollectionCnv_p1::m_2bMaximum = (unsigned short)(-1); -void CaloHitCollectionCnv_p1::transToPers(const CaloHitCollection* transCont, CaloHitCollection_p1* persCont, MsgStream &/*log*/) +void CaloHitCollectionCnv_p1::transToPers(const CaloHitCollection* transCont, CaloHitCollection_p1* persCont, MsgStream &log) { // Finds hits belonging to a "string" (in which the end point of one hit is the same as the start point of the next) and // persistifies the end point of each hit plus the start point of the first hit in each string. @@ -77,6 +80,8 @@ void CaloHitCollectionCnv_p1::transToPers(const CaloHitCollection* transCont, Ca static const double dRcut = 1.0e-7; static const double dTcut = 1.0; + const EventContext& ctx = Gaudi::Hive::currentContext(); + const IProxyDict* proxy = Atlas::getExtendedEventContext(ctx).proxy(); const HepMcParticleLink * lastLink=nullptr; int lastId = -1; double stringFirstTheta = 0.0; @@ -98,11 +103,23 @@ void CaloHitCollectionCnv_p1::transToPers(const CaloHitCollection* transCont, Ca if ( !lastLink || (siHit->particleLink() != *lastLink) ) { - // store barcode once for set of consecutive hits with same barcode + // store barcode, eventIndex and McEventCollection once for set of consecutive hits with same barcode lastLink = &(siHit->particleLink()); persCont->m_barcode.push_back(lastLink->barcode()); - persCont->m_mcEvtIndex.push_back(lastLink->eventIndex()); + log << MSG::ALWAYS << "TP: Event collection from link: " << lastLink->getEventCollection() << " ; char value: " << lastLink->getEventCollectionAsChar() << " barcode: " << lastLink->barcode() << endmsg; + unsigned short index{0}; + const HepMcParticleLink::index_type position = + HepMcParticleLink::getEventPositionInCollection(lastLink->eventIndex(), + lastLink->getEventCollection(), + proxy).at(0); + if (position!=0) { + index = lastLink->eventIndex(); + if(lastLink->eventIndex()!=static_cast<HepMcParticleLink::index_type>(index)) { + log << MSG::WARNING << "Attempting to persistify an eventIndex larger than max unsigned short!" << endmsg; + } + } + persCont->m_mcEvtIndex.push_back(index); persCont->m_evtColl.push_back(lastLink->getEventCollectionAsChar()); if (idx > 0) { @@ -238,18 +255,29 @@ void CaloHitCollectionCnv_p1::transToPers(const CaloHitCollection* transCont, Ca persCont->m_nBC.push_back(idx - endBC); persCont->m_nId.push_back(idx - endId); persCont->m_nHits.push_back(idx - endHit); + + log << MSG::ALWAYS << "nBC: " << persCont->m_nBC << endmsg; + log << MSG::ALWAYS << "nId: " << persCont->m_nId << endmsg; + log << MSG::ALWAYS << "nHits:" << persCont->m_nHits << endmsg; } CaloHitCollection* CaloHitCollectionCnv_p1::createTransient(const CaloHitCollection_p1* persObj, MsgStream &log) { + for (size_t i = 0; i < persObj->m_evtColl.size(); i++) + { + if (persObj->m_evtColl[i] != 'a') + log << MSG::ALWAYS << "Corrupted in createTransient: " << persObj->m_evtColl[i] << endmsg; + } std::unique_ptr<CaloHitCollection> trans(std::make_unique<CaloHitCollection>("DefaultCollectionName",persObj->m_nHits.size())); persToTrans(persObj, trans.get(), log); return(trans.release()); } -void CaloHitCollectionCnv_p1::persToTrans(const CaloHitCollection_p1* persCont, CaloHitCollection* transCont, MsgStream &/*log*/) +void CaloHitCollectionCnv_p1::persToTrans(const CaloHitCollection_p1* persCont, CaloHitCollection* transCont, MsgStream &log) { + const EventContext& ctx = Gaudi::Hive::currentContext(); + unsigned int hitCount = 0; unsigned int angleCount = 0; unsigned int idxBC = 0; @@ -260,12 +288,15 @@ void CaloHitCollectionCnv_p1::persToTrans(const CaloHitCollection_p1* persCont, unsigned int endBC = 0; unsigned int endId = 0; + log << MSG::ALWAYS << "nHits.size(): " << persCont->m_nHits.size() << " nBC.size(): " << persCont->m_nBC.size() << endmsg; + log << MSG::ALWAYS << " nBC: " << persCont->m_nBC << endmsg; + for (unsigned int i = 0; i < persCont->m_nHits.size(); i++) { if (persCont->m_nHits[i]) { - const unsigned int start = endHit; endHit += persCont->m_nHits[i]; + log << MSG::ALWAYS << "i: " << i << " persCont->m_nHits[i]: " << persCont->m_nHits[i] << " start: " << start << " endHit: " << endHit << endmsg; const double t0 = persCont->m_hit1_meanTime[i]; const double theta0 = persCont->m_hit1_theta[i]; @@ -273,7 +304,6 @@ void CaloHitCollectionCnv_p1::persToTrans(const CaloHitCollection_p1* persCont, HepGeom::Point3D<double> endLast(persCont->m_hit1_x0[i], persCont->m_hit1_y0[i], persCont->m_hit1_z0[i]); for (unsigned int j = start; j < endHit; j++) { - if (j >= endBC + persCont->m_nBC[idxBC]) endBC += persCont->m_nBC[idxBC++]; @@ -299,7 +329,13 @@ void CaloHitCollectionCnv_p1::persToTrans(const CaloHitCollection_p1* persCont, HepGeom::Point3D<double> endThis( endLast + r ); - HepMcParticleLink partLink( persCont->m_barcode[idxBC], persCont->m_mcEvtIndex[idxBC], HepMcParticleLink::ExtendedBarCode::eventCollectionFromChar(persCont->m_evtColl[idxBC]), HepMcParticleLink::IS_INDEX ); + HepMcParticleLink::PositionFlag flag = HepMcParticleLink::IS_INDEX; + if (persCont->m_mcEvtIndex[idxBC] == 0) { + flag = HepMcParticleLink::IS_POSITION; + } + log << MSG::ALWAYS << "PT: Event collection from persCont: " << persCont->m_evtColl[idxBC] << " ; idxBC: " << idxBC << " evtColl.size(): " << persCont->m_evtColl.size() << " evtIndex.size(): " << persCont->m_mcEvtIndex.size() << endmsg; + + HepMcParticleLink partLink( persCont->m_barcode[idxBC], persCont->m_mcEvtIndex[idxBC], HepMcParticleLink::ExtendedBarCode::eventCollectionFromChar(persCont->m_evtColl[idxBC]), flag, ctx ); transCont->Emplace( endLast, endThis, eneLoss, meanTime, partLink, persCont->m_id[idxId]); endLast = endThis; @@ -309,4 +345,5 @@ void CaloHitCollectionCnv_p1::persToTrans(const CaloHitCollection_p1* persCont, } } } + log << MSG::ALWAYS << "hitCount: " << hitCount << endmsg; } diff --git a/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/src/CaloHits/CaloHitCollectionCnv_p1a.cxx b/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/src/CaloHits/CaloHitCollectionCnv_p1a.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d1d6ec53b9250c1b184c5b78f5af4b85711409bd --- /dev/null +++ b/Calorimeter/CaloEventCnv/FaserCaloSimEventTPCnv/src/CaloHits/CaloHitCollectionCnv_p1a.cxx @@ -0,0 +1,339 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "FaserCaloSimEvent/CaloHit.h" +#include "FaserCaloSimEvent/CaloHitCollection.h" +#include "FaserCaloSimEventTPCnv/CaloHits/CaloHitCollection_p1a.h" +#include "FaserCaloSimEventTPCnv/CaloHits/CaloHitCollectionCnv_p1a.h" +#include "GeneratorObjects/HepMcParticleLink.h" + +#include <cmath> + +//CLHEP +#include "CLHEP/Geometry/Point3D.h" +// Gaudi +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/ThreadLocalContext.h" + +// Athena +#include "AthenaKernel/ExtendedEventContext.h" +#include "StoreGate/StoreGateSvc.h" + +// * * * stolen from eflowRec * * * // +inline double phicorr(double a) +{ + if (a <= -M_PI) + { + return a+(2*M_PI*floor(-(a-M_PI)/(2*M_PI))); + } + else if (a > M_PI) + { + return a-(2*M_PI*floor((a+M_PI)/(2*M_PI))); + } + else + { + return a; + } +} + +// * * * stolen from eflowRec * * * // +inline double cycle(double a, double b) +{ + double del = b-a; + if (del > M_PI) + { + return a+2.0*M_PI; + } + else if (del < -M_PI) + { + return a-2.0*M_PI; + } + else + { + return a; + } +} + + +const double CaloHitCollectionCnv_p1a::m_persEneUnit = 1.0e-5; +const double CaloHitCollectionCnv_p1a::m_persLenUnit = 1.0e-5; +const double CaloHitCollectionCnv_p1a::m_persAngUnit = 1.0e-5; +const double CaloHitCollectionCnv_p1a::m_2bHalfMaximum = pow(2.0, 15.0); +const int CaloHitCollectionCnv_p1a::m_2bMaximum = (unsigned short)(-1); + + +void CaloHitCollectionCnv_p1a::transToPers(const CaloHitCollection* transCont, CaloHitCollection_p1a* persCont, MsgStream &log) +{ + // Finds hits belonging to a "string" (in which the end point of one hit is the same as the start point of the next) and + // persistifies the end point of each hit plus the start point of the first hit in each string. + // + // Further compression is achieved by optimising the storage of the position vectors:- start (x,y,z) and (theta,phi) of + // first hit are stored as floats, (delta_theta,delta_phi) relative to the fisrst hit are stored as 2 byte numbers and + // used to specify the hit direction. All hit lengths are stored as 2 byte numbers. + // + // Additional savings are achieved by storing the energy loss for each hit as a 2 byte number and only storing the mean + // time of the first hit per string. + // + // See http://indico.cern.ch/getFile.py/access?contribId=11&resId=2&materialId=slides&confId=30893 for more info. + + static const double dRcut = 1.0e-7; + static const double dTcut = 1.0; + + const EventContext& ctx = Gaudi::Hive::currentContext(); + const IProxyDict* proxy = Atlas::getExtendedEventContext(ctx).proxy(); + const HepMcParticleLink * lastLink=nullptr; + int lastId = -1; + double stringFirstTheta = 0.0; + double stringFirstPhi = 0.0; + double lastT = 0.0; + double persSumE = 0.0; + double transSumE = 0.0; + unsigned int idx = 0; + unsigned int endBC = 0; + unsigned int endId = 0; + unsigned int endHit = 0; + HepGeom::Point3D<double> lastTransEnd(0.0, 0.0, 0.0); + HepGeom::Point3D<double> lastPersEnd(0.0, 0.0, 0.0); + + for (CaloHitCollection::const_iterator it = transCont->begin(); it != transCont->end(); ++it) { + + CaloHitCollection::const_iterator siHit = it; + + + if ( !lastLink || (siHit->particleLink() != *lastLink) ) { + + // store barcode, eventIndex and McEventCollection once for set of consecutive hits with same barcode + + lastLink = &(siHit->particleLink()); + persCont->m_barcode.push_back(lastLink->barcode()); + unsigned short index{0}; + const HepMcParticleLink::index_type position = + HepMcParticleLink::getEventPositionInCollection(lastLink->eventIndex(), + lastLink->getEventCollection(), + proxy).at(0); + if (position!=0) { + index = lastLink->eventIndex(); + if(lastLink->eventIndex()!=static_cast<HepMcParticleLink::index_type>(index)) { + log << MSG::WARNING << "Attempting to persistify an eventIndex larger than max unsigned short!" << endmsg; + } + } + persCont->m_mcEvtIndex.push_back(index); + persCont->m_evtColl.push_back(lastLink->getEventCollectionAsChar()); + + if (idx > 0) { + persCont->m_nBC.push_back(idx - endBC); + endBC = idx; + } + } + + if ( (int)siHit->identify() != lastId ) { + + // store id once for set of consecutive hits with same barcode + + lastId = siHit->identify(); + persCont->m_id.push_back(lastId); + + if (idx > 0) { + persCont->m_nId.push_back(idx - endId); + endId = idx; + } + } + + HepGeom::Point3D<double> st = siHit->localStartPosition(); + HepGeom::Point3D<double> en = siHit->localEndPosition(); + + const double dx = st.x() - lastTransEnd.x(); + const double dy = st.y() - lastTransEnd.y(); + const double dz = st.z() - lastTransEnd.z(); + const double t = siHit->meanTime(); + + const double dRLast = sqrt(dx * dx + dy * dy + dz * dz); // dR between end of previous hit and start of current one + const double dTLast = fabs(t - lastT); + + CLHEP::Hep3Vector direction(0.0, 0.0, 0.0); + double theta = 0.0; + double phi = 0.0; + bool startNewString = false; + + if (dRLast < dRcut && dTLast < dTcut) { + + // hit is part of existing string + + direction = CLHEP::Hep3Vector( en.x() - lastPersEnd.x(), en.y() - lastPersEnd.y(), en.z() - lastPersEnd.z() ); + + theta = direction.theta(); + phi = phicorr( direction.phi() ); + + const int dTheta_2b = (int)( (theta - stringFirstTheta) / m_persAngUnit + m_2bHalfMaximum + 0.5 ); + const int dPhi_2b = (int)( (cycle(phi, stringFirstPhi) - stringFirstPhi) / m_persAngUnit + m_2bHalfMaximum + 0.5 ); + + if ( dTheta_2b < m_2bMaximum && dTheta_2b >= 0 && dPhi_2b < m_2bMaximum && dPhi_2b >= 0) { + persCont->m_dTheta.push_back(dTheta_2b); + persCont->m_dPhi.push_back(dPhi_2b); + theta = stringFirstTheta + ( (double)dTheta_2b - m_2bHalfMaximum ) * m_persAngUnit; + phi = stringFirstPhi + ( (double)dPhi_2b - m_2bHalfMaximum ) * m_persAngUnit; + phi = phicorr(phi); + } + else { + startNewString = true; + } + } + + if (startNewString || dRLast >= dRcut || dTLast >= dTcut) { + + // begin new hit string + + direction = CLHEP::Hep3Vector( en.x() - st.x(), en.y() - st.y(), en.z() - st.z() ); + + theta = direction.theta(); + phi = phicorr( direction.phi() ); + + persCont->m_hit1_meanTime.push_back(t); + persCont->m_hit1_x0.push_back(st.x()); + persCont->m_hit1_y0.push_back(st.y()); + persCont->m_hit1_z0.push_back(st.z()); + persCont->m_hit1_theta.push_back(theta); + persCont->m_hit1_phi.push_back(phi); + + lastPersEnd = HepGeom::Point3D<double>(st.x(), st.y(), st.z()); + + stringFirstTheta = theta; + stringFirstPhi = phi; + + if (idx > 0) { + persCont->m_nHits.push_back(idx - endHit); + endHit = idx; + } + } + + lastTransEnd = HepGeom::Point3D<double>(en.x(), en.y(), en.z()); + transSumE += siHit->energyLoss(); + + const int eneLoss_2b = (int)((transSumE - persSumE) / m_persEneUnit + 0.5); // calculated to allow recovery sum over + // whole hit string to chosen precision + + const int hitLength_2b = (int)(direction.mag() / m_persLenUnit + 0.5); // calculated to give the correct position to + // the chosen precision, NOT the length of the + // hit (small difference in practice). + double eneLoss = 0.0; + + if (eneLoss_2b >= m_2bMaximum) { + eneLoss = siHit->energyLoss(); + persCont->m_hitEne_2b.push_back(m_2bMaximum); + persCont->m_hitEne_4b.push_back(eneLoss); + } + else { + eneLoss = eneLoss_2b * m_persEneUnit; + persCont->m_hitEne_2b.push_back(eneLoss_2b); + } + + double length = 0.0; + + if (hitLength_2b >= m_2bMaximum) { + length = direction.mag(); + persCont->m_hitLength_2b.push_back(m_2bMaximum); + persCont->m_hitLength_4b.push_back(direction.mag()); + } + else { + length = hitLength_2b * m_persLenUnit; + persCont->m_hitLength_2b.push_back(hitLength_2b); + } + + CLHEP::Hep3Vector persDir(length, 0.0, 0.0); + persDir.setTheta(theta); + persDir.setPhi(phi); + + lastPersEnd = (CLHEP::Hep3Vector)lastPersEnd + persDir; + persSumE += eneLoss; + lastT = t; + + ++idx; + } + + persCont->m_nBC.push_back(idx - endBC); + persCont->m_nId.push_back(idx - endId); + persCont->m_nHits.push_back(idx - endHit); +} + + +CaloHitCollection* CaloHitCollectionCnv_p1a::createTransient(const CaloHitCollection_p1a* persObj, MsgStream &log) { + for (size_t i = 0; i < persObj->m_evtColl.size(); i++) + { + if (persObj->m_evtColl[i] != 'a') + log << MSG::ALWAYS << "Corrupted in createTransient: " << persObj->m_evtColl[i] << endmsg; + } + std::unique_ptr<CaloHitCollection> trans(std::make_unique<CaloHitCollection>("DefaultCollectionName",persObj->m_nHits.size())); + persToTrans(persObj, trans.get(), log); + return(trans.release()); +} + + +void CaloHitCollectionCnv_p1a::persToTrans(const CaloHitCollection_p1a* persCont, CaloHitCollection* transCont, MsgStream &/*log*/) +{ + const EventContext& ctx = Gaudi::Hive::currentContext(); + + unsigned int hitCount = 0; + unsigned int angleCount = 0; + unsigned int idxBC = 0; + unsigned int idxId = 0; + unsigned int idxEne4b = 0; + unsigned int idxLen4b = 0; + unsigned int endHit = 0; + unsigned int endBC = 0; + unsigned int endId = 0; + + + for (unsigned int i = 0; i < persCont->m_nHits.size(); i++) { + + if (persCont->m_nHits[i]) { + const unsigned int start = endHit; + endHit += persCont->m_nHits[i]; + + const double t0 = persCont->m_hit1_meanTime[i]; + const double theta0 = persCont->m_hit1_theta[i]; + const double phi0 = persCont->m_hit1_phi[i]; + HepGeom::Point3D<double> endLast(persCont->m_hit1_x0[i], persCont->m_hit1_y0[i], persCont->m_hit1_z0[i]); + + for (unsigned int j = start; j < endHit; j++) { + if (j >= endBC + persCont->m_nBC[idxBC]) + endBC += persCont->m_nBC[idxBC++]; + + if (j >= endId + persCont->m_nId[idxId]) + endId += persCont->m_nId[idxId++]; + + const double eneLoss_2b = persCont->m_hitEne_2b[hitCount]; + const double hitLength_2b = persCont->m_hitLength_2b[hitCount]; + + const double eneLoss = (eneLoss_2b < m_2bMaximum) ? eneLoss_2b * m_persEneUnit : persCont->m_hitEne_4b[idxEne4b++]; + const double length = (hitLength_2b < m_2bMaximum) ? hitLength_2b * m_persLenUnit : persCont->m_hitLength_4b[idxLen4b++]; + + const double dTheta = (j > start) ? ((double)persCont->m_dTheta[angleCount] - m_2bHalfMaximum) * m_persAngUnit : 0.0; + const double dPhi = (j > start) ? ((double)persCont->m_dPhi[angleCount] - m_2bHalfMaximum) * m_persAngUnit : 0.0; + + const double meanTime = t0; + const double theta = theta0 + dTheta; + const double phi = phicorr(phi0 + dPhi); + + CLHEP::Hep3Vector r(length, 0.0, 0.0); + r.setTheta(theta); + r.setPhi(phi); + + HepGeom::Point3D<double> endThis( endLast + r ); + + HepMcParticleLink::PositionFlag flag = HepMcParticleLink::IS_INDEX; + if (persCont->m_mcEvtIndex[idxBC] == 0) { + flag = HepMcParticleLink::IS_POSITION; + } + + HepMcParticleLink partLink( persCont->m_barcode[idxBC], persCont->m_mcEvtIndex[idxBC], HepMcParticleLink::ExtendedBarCode::eventCollectionFromChar(persCont->m_evtColl[idxBC]), flag, ctx ); + transCont->Emplace( endLast, endThis, eneLoss, meanTime, partLink, persCont->m_id[idxId]); + + endLast = endThis; + + ++hitCount; + if (j > start) ++angleCount; + } + } + } +} diff --git a/Calorimeter/CaloG4/EcalG4_SD/python/EcalG4_SDToolConfig.py b/Calorimeter/CaloG4/EcalG4_SD/python/EcalG4_SDToolConfig.py index e679d7fca9c93e9341a87c61685f6bd2d9d00b6c..293f2057dd710cc2edb3f5cd29d049f619a127df 100644 --- a/Calorimeter/CaloG4/EcalG4_SD/python/EcalG4_SDToolConfig.py +++ b/Calorimeter/CaloG4/EcalG4_SD/python/EcalG4_SDToolConfig.py @@ -17,5 +17,7 @@ def EcalSensorSDCfg(ConfigFlags, name="EcalSensorSD", **kwargs): kwargs.setdefault("LogicalVolumeNames", ["Ecal::_dd_Geometry_DownstreamRegion_Ecal_Modules_OutCell"]) kwargs.setdefault("OutputCollectionNames", [bare_collection_name]) - # result.merge(acc) - return result, EcalSensorSDTool(name, **kwargs) + result = ComponentAccumulator() + result.setPrivateTools(CompFactory.EcalSensorSDTool(name, **kwargs)) + return result + diff --git a/Calorimeter/CaloRecAlgs/CMakeLists.txt b/Calorimeter/CaloRecAlgs/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..219db92a3a8927ae9cc025bea46985387e072ce0 --- /dev/null +++ b/Calorimeter/CaloRecAlgs/CMakeLists.txt @@ -0,0 +1,15 @@ +################################################################################ +# Package: CaloRecAlgs +################################################################################ + +# Declare the package name: +atlas_subdir( CaloRecAlgs ) + +# Component(s) in the package: +atlas_add_component( CaloRecAlgs + src/*.cxx src/*.h + src/components/*.cxx + LINK_LIBRARIES AthenaBaseComps StoreGateLib xAODFaserCalorimeter xAODFaserWaveform) + +atlas_install_python_modules( python/*.py ) + diff --git a/Calorimeter/CaloRecAlgs/python/CaloRecAlgsConfig.py b/Calorimeter/CaloRecAlgs/python/CaloRecAlgsConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..034bf08b5b36a4620567f6716eca5d31338a1c04 --- /dev/null +++ b/Calorimeter/CaloRecAlgs/python/CaloRecAlgsConfig.py @@ -0,0 +1,41 @@ +""" Define methods used to instantiate configured Waveform reconstruction tools and algorithms + +Copyright (C) 2020 CERN for the benefit of the FASER collaboration +""" +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from AthenaConfiguration.ComponentFactory import CompFactory + +from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg + +#CalorimeterReconstructionTool = CompFactory.CalorimeterReconstructionTool + +# One stop shopping for normal FASER data +def CalorimeterReconstructionCfg(flags, **kwargs): + """ Return all algorithms and tools for Waveform reconstruction """ + acc = ComponentAccumulator() + + #tool = CalorimeterReconstructionTool(name="CaloRecTool", **kwargs) + + kwargs.setdefault("CaloWaveHitContainerKey", "CaloWaveformHits") + kwargs.setdefault("PreshowerWaveHitContainerKey", "PreshowerWaveformHits") + kwargs.setdefault("CaloHitContainerKey", "CaloHits") + #kwargs.setdefault("CalorimeterReconstructionTool", tool) + + recoAlg = CompFactory.CaloRecAlg("CaloRecAlg", **kwargs) + #recoAlg.CalorimeterReconstructionTool = tool + acc.addEventAlgo(recoAlg) + + return acc + +def CalorimeterReconstructionOutputCfg(flags, **kwargs): + """ Return ComponentAccumulator with output for Calorimeter Reco""" + acc = ComponentAccumulator() + ItemList = [ + "xAOD::CalorimeterHitContainer#*" + , "xAOD::CalorimeterHitAuxContainer#*" + ] + acc.merge(OutputStreamCfg(flags, "xAOD", ItemList)) + # ostream = acc.getEventAlgo("OutputStreamRDO") + # ostream.TakeItemsFromInput = True # Don't know what this does + return acc + diff --git a/Calorimeter/CaloRecAlgs/src/CaloRecAlg.cxx b/Calorimeter/CaloRecAlgs/src/CaloRecAlg.cxx new file mode 100644 index 0000000000000000000000000000000000000000..4b4d6f158f29478a60443381c5292d254d1c665f --- /dev/null +++ b/Calorimeter/CaloRecAlgs/src/CaloRecAlg.cxx @@ -0,0 +1,123 @@ +#include "CaloRecAlg.h" + +CaloRecAlg::CaloRecAlg(const std::string& name, + ISvcLocator* pSvcLocator) + : AthReentrantAlgorithm(name, pSvcLocator) { + +} + +StatusCode +CaloRecAlg::initialize() { + ATH_MSG_INFO(name() << "::initalize()" ); + + // Initalize tools + //ATH_CHECK( m_recoTool.retrieve() ); + + // Set key to read calo hits from + ATH_CHECK( m_caloWaveHitContainerKey.initialize() ); + + // Set key to read preshower hits from + ATH_CHECK( m_preshowerWaveHitContainerKey.initialize() ); + + // Set key to write container + ATH_CHECK( m_caloHitContainerKey.initialize() ); + + return StatusCode::SUCCESS; +} + +StatusCode +CaloRecAlg::finalize() { + ATH_MSG_INFO(name() << "::finalize()"); + + return StatusCode::SUCCESS; +} + +StatusCode +CaloRecAlg::execute(const EventContext& ctx) const { + ATH_MSG_DEBUG("Executing"); + + ATH_MSG_DEBUG("Run: " << ctx.eventID().run_number() + << " Event: " << ctx.eventID().event_number()); + + // Find the input waveform hit containers + SG::ReadHandle<xAOD::WaveformHitContainer> caloWaveHitHandle(m_caloWaveHitContainerKey, ctx); + + ATH_CHECK( caloWaveHitHandle.isValid() ); + ATH_MSG_DEBUG("Found ReadHandle for WaveformHitContainer " << m_caloWaveHitContainerKey); + + if (caloWaveHitHandle->size() == 0) { + ATH_MSG_DEBUG("Calorimeter Waveform Hit container found with zero length!"); + } + + SG::ReadHandle<xAOD::WaveformHitContainer> preshowerWaveHitHandle(m_preshowerWaveHitContainerKey, ctx); + + ATH_CHECK( preshowerWaveHitHandle.isValid() ); + ATH_MSG_DEBUG("Found ReadHandle for WaveformHitContainer " << m_preshowerWaveHitContainerKey); + + if (preshowerWaveHitHandle->size() == 0) { + ATH_MSG_DEBUG("Preshower Waveform Hit container found with zero length!"); + } + + // Find the output waveform container + SG::WriteHandle<xAOD::CalorimeterHitContainer> caloHitContainerHandle(m_caloHitContainerKey, ctx); + ATH_CHECK( caloHitContainerHandle.record( std::make_unique<xAOD::CalorimeterHitContainer>(), + std::make_unique<xAOD::CalorimeterHitAuxContainer>() ) ); + + ATH_MSG_DEBUG("WaveformsHitContainer '" << caloHitContainerHandle.name() << "' initialized"); + + // Reconstruct all waveforms + //CHECK( m_recoTool->reconstructAll(*waveformHandle, clockptr, hitContainerHandle.ptr()) ); + + // Find peak time (most significant hit) + const xAOD::WaveformHit* peakHit = findPeakHit(*caloWaveHitHandle); + if (peakHit == NULL) return StatusCode::SUCCESS; + + // Create a new calo hit + xAOD::CalorimeterHit* calo_hit = new xAOD::CalorimeterHit(); + caloHitContainerHandle->push_back(calo_hit); + + calo_hit->set_raw_energy(-1.); // Dummy value + + // Find closest hits in time per channel + std::map<int, const xAOD::WaveformHit*> hitMap; + for ( const auto& hit : *caloWaveHitHandle ) { + int channel = hit->channel(); + if (hitMap.count(channel) == 0) + hitMap[channel] = hit; + else { + if (abs(hitMap[channel]->localtime() - peakHit->localtime()) > + abs(hit->localtime() - peakHit->localtime())) + hitMap[channel] = hit; + } + } + + // For each hit found, insert these into the caloHit + // Clear before association + calo_hit->clearCaloWaveformLinks(); + for ( const auto& [chan, hit] : hitMap ) { + ATH_MSG_VERBOSE("Found hit " << *hit); + calo_hit->addCaloHit(caloWaveHitHandle.get(), hit); + } + + ATH_MSG_DEBUG("CaloHitContainer '" << caloHitContainerHandle.name() << "' filled with "<< caloHitContainerHandle->size() <<" items"); + + return StatusCode::SUCCESS; +} + +const xAOD::WaveformHit* +CaloRecAlg::findPeakHit(const xAOD::WaveformHitContainer& hitContainer) const { + + const xAOD::WaveformHit* peakHit = NULL; + for( const auto& hit : hitContainer ) { + if (peakHit == NULL) { + peakHit = hit; + } else { + if ( hit->peak() > peakHit->peak() ) peakHit = hit; + } + } + + // Didn't find anything? + if (peakHit == NULL) return NULL; + if (peakHit->status_bit(xAOD::WaveformStatus::THRESHOLD_FAILED)) return NULL; + return peakHit; +} diff --git a/Calorimeter/CaloRecAlgs/src/CaloRecAlg.h b/Calorimeter/CaloRecAlgs/src/CaloRecAlg.h new file mode 100644 index 0000000000000000000000000000000000000000..bd98e9afd6b693b8cc4518ebd87ddd72207fddef --- /dev/null +++ b/Calorimeter/CaloRecAlgs/src/CaloRecAlg.h @@ -0,0 +1,83 @@ +#ifndef CALORECALGS_CALORECALG_H +#define CALORECALGS_CALORECALG_H + +// Base class +#include "AthenaBaseComps/AthReentrantAlgorithm.h" + +// Data classes +#include "xAODFaserWaveform/WaveformHitContainer.h" + +#include "xAODFaserCalorimeter/CalorimeterHit.h" +#include "xAODFaserCalorimeter/CalorimeterHitContainer.h" +#include "xAODFaserCalorimeter/CalorimeterHitAuxContainer.h" + +// Tool classes +//#include "CaloRecTools/ICalorimeterReconstructionTool.h" + +// Handles +#include "StoreGate/ReadHandleKey.h" +#include "StoreGate/WriteHandleKey.h" + +// Gaudi +#include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/ToolHandle.h" + +// STL +#include <string> + +class CaloRecAlg : public AthReentrantAlgorithm { + + public: + // Constructor + CaloRecAlg(const std::string& name, ISvcLocator* pSvcLocator); + virtual ~CaloRecAlg() = default; + + /** @name Usual algorithm methods */ + //@{ + virtual StatusCode initialize() override; + virtual StatusCode execute(const EventContext& ctx) const override; + virtual StatusCode finalize() override; + //@} + + private: + + /** @name Disallow default instantiation, copy, assignment */ + //@{ + CaloRecAlg() = delete; + CaloRecAlg(const CaloRecAlg&) = delete; + CaloRecAlg &operator=(const CaloRecAlg&) = delete; + //@} + + /** + * @name Reconstruction tool + */ + //ToolHandle<ICalorimeterReconstructionTool> m_recoTool + //{this, "CalorimeterReconstructionTool", "CalorimeterReconstructionTool"}; + + /** + * @name Input raw waveform data using SG::ReadHandleKey + */ + //@{ + SG::ReadHandleKey<xAOD::WaveformHitContainer> m_caloWaveHitContainerKey + {this, "CaloWaveHitContainerKey", ""}; + //@} + + //@{ + SG::ReadHandleKey<xAOD::WaveformHitContainer> m_preshowerWaveHitContainerKey + {this, "PreshowerWaveHitContainerKey", ""}; + //@} + + /** + * @name Output data using SG::WriteHandleKey + */ + //@{ + SG::WriteHandleKey<xAOD::CalorimeterHitContainer> m_caloHitContainerKey + {this, "CaloHitContainerKey", ""}; + //@} + + const xAOD::WaveformHit* + findPeakHit(const xAOD::WaveformHitContainer& hitContainer) const; + +}; + +#endif // CALORECALGS_CALORECALG_H diff --git a/Calorimeter/CaloRecAlgs/src/components/CaloRecAlgs_entries.cxx b/Calorimeter/CaloRecAlgs/src/components/CaloRecAlgs_entries.cxx new file mode 100644 index 0000000000000000000000000000000000000000..bf444d88011c857e2273ba392269cc2fb943c31a --- /dev/null +++ b/Calorimeter/CaloRecAlgs/src/components/CaloRecAlgs_entries.cxx @@ -0,0 +1,3 @@ +#include "../CaloRecAlg.h" + +DECLARE_COMPONENT( CaloRecAlg ) diff --git a/Control/CalypsoConfiguration/python/GeoModelConfigFlags.py b/Control/CalypsoConfiguration/python/GeoModelConfigFlags.py index 448d65d80fad40f7a16501b4720853ed4bddae11..69d280a85975a9785e4ceaaef704d190bdca9434 100644 --- a/Control/CalypsoConfiguration/python/GeoModelConfigFlags.py +++ b/Control/CalypsoConfiguration/python/GeoModelConfigFlags.py @@ -10,6 +10,8 @@ def createGeoModelConfigFlags(): GetFileMD(prevFlags.Input.Files).get("GeoFaser",None)) or "FASER-01")) gcf.addFlag("GeoModel.GeoExportFile","") + gcf.addFlag("GeoModel.Align.Disable", False) # Hack to avoid loading alignment when we want to create it from scratch + return gcf diff --git a/Control/CalypsoExample/GeoModelTest/CMakeLists.txt b/Control/CalypsoExample/GeoModelTest/CMakeLists.txt index 5c4205019552d4db08974473329ba6fdca37cb44..9db978f852f7d3ae840297d164670b9c6ba9aa00 100644 --- a/Control/CalypsoExample/GeoModelTest/CMakeLists.txt +++ b/Control/CalypsoExample/GeoModelTest/CMakeLists.txt @@ -15,11 +15,17 @@ atlas_add_component( GeoModelTest INCLUDE_DIRS ${GEOMODEL_INCLUDE_DIRS} LINK_LIBRARIES ${GEOMODEL_LIBRARIES} AthenaBaseComps GeoModelFaserUtilities ScintReadoutGeometry TrackerReadoutGeometry MagFieldInterfaces MagFieldElements MagFieldConditions ) -atlas_add_test( GeoModelCheck - SCRIPT python ${CMAKE_CURRENT_SOURCE_DIR}/python/GeoModelTestConfig.py +atlas_add_test( Faser01GeoCheck + SCRIPT python ${CMAKE_CURRENT_SOURCE_DIR}/python/Faser01TestConfig.py PROPERTIES WORKING_DIRECTORY ${CMAKE_BINARY_DIR} PROPERTIES TIMEOUT 300 ) +atlas_add_test( Faser02GeoCheck + SCRIPT python ${CMAKE_CURRENT_SOURCE_DIR}/python/Faser02TestConfig.py + PROPERTIES WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + PROPERTIES TIMEOUT 300 ) + + atlas_add_test( TestBeamGeoCheck SCRIPT python ${CMAKE_CURRENT_SOURCE_DIR}/python/TestBeamTestConfig.py PROPERTIES WORKING_DIRECTORY ${CMAKE_BINARY_DIR} diff --git a/Control/CalypsoExample/GeoModelTest/python/GeoModelTestConfig.py b/Control/CalypsoExample/GeoModelTest/python/Faser01TestConfig.py similarity index 87% rename from Control/CalypsoExample/GeoModelTest/python/GeoModelTestConfig.py rename to Control/CalypsoExample/GeoModelTest/python/Faser01TestConfig.py index ad33f2cf97c66ba18a5d1902fdc1f9d8b58cb85f..69a57833523e460b1ab5465312f410ae9e2509d6 100644 --- a/Control/CalypsoExample/GeoModelTest/python/GeoModelTestConfig.py +++ b/Control/CalypsoExample/GeoModelTest/python/Faser01TestConfig.py @@ -17,7 +17,9 @@ def GeoModelTestCfg(flags, name="GeoModelTestAlg", **kwargs): # Configure the algorithm itself GeoModelTestAlg = CompFactory.GeoModelTestAlg - a.addEventAlgo(GeoModelTestAlg(name, **kwargs)) + a.addEventAlgo(GeoModelTestAlg(name, FirstSCTStation=1, + LastSCTStation=3, + **kwargs)) return a @@ -32,7 +34,7 @@ if __name__ == "__main__": ConfigFlags.Input.isMC = True # Needed to bypass autoconfig ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01" # Always needed; must match FaserVersion ConfigFlags.GeoModel.FaserVersion = "FASER-01" # Default FASER geometry - ConfigFlags.GeoModel.GeoExportFile = "faserGeo.db" # Writes out a GeoModel file with the full geometry tree (optional, comment out to skip) + # ConfigFlags.GeoModel.GeoExportFile = "faserGeo01.db" # Writes out a GeoModel file with the full geometry tree (optional, comment out to skip) # ConfigFlags.Detector.EnableVeto = True # ConfigFlags.Detector.EnableTrigger = True # ConfigFlags.Detector.EnablePreshower= True diff --git a/Control/CalypsoExample/GeoModelTest/python/Faser02TestConfig.py b/Control/CalypsoExample/GeoModelTest/python/Faser02TestConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..03913db74587b020b24c290fc6a2928eb965e22d --- /dev/null +++ b/Control/CalypsoExample/GeoModelTest/python/Faser02TestConfig.py @@ -0,0 +1,66 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +#!/usr/bin/env python +import sys +from AthenaCommon.Constants import VERBOSE, INFO +from AthenaConfiguration.ComponentFactory import CompFactory + +def GeoModelTestCfg(flags, name="GeoModelTestAlg", **kwargs): + + # Initialize GeoModel + from FaserGeoModel.FaserGeoModelConfig import FaserGeometryCfg + a = FaserGeometryCfg(flags) + + # Initialize field service + from MagFieldServices.MagFieldServicesConfig import MagneticFieldSvcCfg + a.merge(MagneticFieldSvcCfg(flags)) + + # Configure the algorithm itself + GeoModelTestAlg = CompFactory.GeoModelTestAlg + a.addEventAlgo(GeoModelTestAlg(name, FirstSCTStation=0, + LastSCTStation=3, + PrintSctIDs=True, + **kwargs)) + + return a + +if __name__ == "__main__": + from AthenaCommon.Logging import log#, logging + from AthenaCommon.Configurable import Configurable + from CalypsoConfiguration.AllConfigFlags import ConfigFlags + + Configurable.configurableRun3Behavior = True + +# Flags for this job + ConfigFlags.Input.isMC = True # Needed to bypass autoconfig + ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-02" # Always needed; must match FaserVersion + ConfigFlags.GeoModel.FaserVersion = "FASERNU-02" # Default FASER geometry + # ConfigFlags.GeoModel.GeoExportFile = "faserGeoNu02.db" # Writes out a GeoModel file with the full geometry tree (optional, comment out to skip) + # ConfigFlags.Detector.EnableVeto = True + # ConfigFlags.Detector.EnableTrigger = True + # ConfigFlags.Detector.EnablePreshower= True + # ConfigFlags.Detector.EnableFaserSCT = True + # ConfigFlags.Detector.EnableUpstreamDipole = True + # ConfigFlags.Detector.EnableCentralDipole = True + # ConfigFlags.Detector.EnableDownstreamDipole = True + # ConfigFlags.Detector.EnableEcal = True + ConfigFlags.lock() + +# Configure components + from CalypsoConfiguration.MainServicesConfig import MainServicesCfg + acc = MainServicesCfg(ConfigFlags) + +# Set up algorithm + acc.merge(GeoModelTestCfg(ConfigFlags)) + +# Configure verbosity + msgSvc = acc.getService("MessageSvc") + msgSvc.Format = "% F%30W%S%7W%R%T %0W%M" + # ConfigFlags.dump() + # logging.getLogger('forcomps').setLevel(VERBOSE) + acc.foreach_component("*").OutputLevel = VERBOSE + acc.foreach_component("*ClassID*").OutputLevel = INFO + log.setLevel(VERBOSE) + +# Execute and finish + sys.exit(int(acc.run(maxEvents=1).isFailure())) diff --git a/Control/CalypsoExample/GeoModelTest/python/TestBeamTestConfig.py b/Control/CalypsoExample/GeoModelTest/python/TestBeamTestConfig.py index 641c9a7558a39389d33e2c6f220b951af096f7dc..d590b125b0570e1628481ecbcaad312c357aa021 100644 --- a/Control/CalypsoExample/GeoModelTest/python/TestBeamTestConfig.py +++ b/Control/CalypsoExample/GeoModelTest/python/TestBeamTestConfig.py @@ -26,6 +26,7 @@ def GeoModelTestCfg(flags, name="GeoModelTestAlg", **kwargs): NumVetoStations=1, NumVetoPlatesPerStation=2, NumTriggerStations=0, + PrintSctIDs=True, **kwargs)) return a @@ -39,9 +40,9 @@ if __name__ == "__main__": # Flags for this job ConfigFlags.Input.isMC = True # Needed to bypass autoconfig - ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-02" # Always needed; must match FaserVersion + ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-TB00" # Always needed; must match FaserVersion ConfigFlags.GeoModel.FaserVersion = "FASER-TB00" # Default FASER geometry - ConfigFlags.GeoModel.GeoExportFile = "faserTestBeamGeo.db" # Writes out a GeoModel file with the full geometry tree (optional, comment out to skip) + # ConfigFlags.GeoModel.GeoExportFile = "faserTestBeamGeo.db" # Writes out a GeoModel file with the full geometry tree (optional, comment out to skip) # ConfigFlags.Detector.EnableVeto = True # ConfigFlags.Detector.EnableTrigger = True # ConfigFlags.Detector.EnablePreshower= True diff --git a/Control/CalypsoExample/GeoModelTest/src/GeoModelTestAlg.cxx b/Control/CalypsoExample/GeoModelTest/src/GeoModelTestAlg.cxx index 2deb292d34deba66b91761a7a9d95f10fdcbf0c1..0865640503cfd4d2862f643acb6cbe38a7828dc4 100644 --- a/Control/CalypsoExample/GeoModelTest/src/GeoModelTestAlg.cxx +++ b/Control/CalypsoExample/GeoModelTest/src/GeoModelTestAlg.cxx @@ -126,11 +126,13 @@ StatusCode GeoModelTestAlg::testSCT() const ATH_MSG_ALWAYS("Retrieved FaserSCT_ID helper from DetStore."); // Print list of identifiers - // for (FaserSCT_ID::const_id_iterator it = helper->wafer_begin(); it != helper->wafer_end(); ++it) - // { - // ATH_MSG_ALWAYS("Wafer ID: " << (it->get_compact() >>32)); - // } - + if (m_printSctIdentifiers) + { + for (FaserSCT_ID::const_id_iterator it = helper->wafer_begin(); it != helper->wafer_end(); ++it) + { + ATH_MSG_ALWAYS("Wafer ID: " << (it->get_compact() >>32)); + } + } for (int iStation = m_firstSctStation; iStation <= m_lastSctStation; iStation++) { // if (m_numSctStations%2 == 0 && iStation == 0) continue; diff --git a/Control/CalypsoExample/GeoModelTest/src/GeoModelTestAlg.h b/Control/CalypsoExample/GeoModelTest/src/GeoModelTestAlg.h index ff5244b175bfaeb49462fc5c1191dd42cbc8d9bd..010be38c93980f6bb9db5f3f4779b5bc6144b559 100644 --- a/Control/CalypsoExample/GeoModelTest/src/GeoModelTestAlg.h +++ b/Control/CalypsoExample/GeoModelTest/src/GeoModelTestAlg.h @@ -51,6 +51,7 @@ class GeoModelTestAlg : public AthReentrantAlgorithm Gaudi::Property<int> m_numSctRowsPerPlane {this, "NumSCTRowsPerPlane", 4, "Number of rows of modules per plane in the SCT detector"}; Gaudi::Property<int> m_numSctModulesPerRow {this, "NumSCTModulesPerRow", 2, "Number of modules per row in the SCT detector"}; Gaudi::Property<int> m_numSctStripsPerSensor {this, "NumSCTStripsPerSensor", 768,"Number of readout strips per sensor in the SCT detector"}; + Gaudi::Property<bool> m_printSctIdentifiers {this, "PrintSctIDs", false, "Flag to print raw wafer identifiers"}; int m_numSctStations; // ServiceHandle<MagField::IMagFieldSvc> m_field { this, "FieldService", "FaserFieldSvc" }; diff --git a/Control/CalypsoExample/Reconstruction/CMakeLists.txt b/Control/CalypsoExample/Reconstruction/CMakeLists.txt index b5644c450e793fb6fdcb32f502b37c4d7a54231d..dddd2f621013501750a82d0569e2714bbb20c9db 100644 --- a/Control/CalypsoExample/Reconstruction/CMakeLists.txt +++ b/Control/CalypsoExample/Reconstruction/CMakeLists.txt @@ -12,12 +12,15 @@ atlas_subdir( Reconstruction ) # INCLUDE_DIRS ${GEOMODEL_INCLUDE_DIRS} # LINK_LIBRARIES ${GEOMODEL_LIBRARIES} AthenaBaseComps GeoModelFaserUtilities ScintReadoutGeometry TrackerReadoutGeometry MagFieldInterfaces MagFieldElements MagFieldConditions ) -#atlas_add_test( ReconstructionTest -# SCRIPT python ${CMAKE_CURRENT_SOURCE_DIR}/python/GeoModelTestConfig.py -# PROPERTIES WORKING_DIRECTORY ${CMAKE_BINARY_DIR} -# PROPERTIES TIMEOUT 300 ) - # Install files from the package: #atlas_install_joboptions( share/*.py ) #atlas_install_python_modules( python/*.py ) atlas_install_scripts( scripts/*.sh scripts/*.py ) + +atlas_add_test( ProdRecoTI12 + SCRIPT scripts/faser_reco.py ${CMAKE_CURRENT_SOURCE_DIR}/../rawdata/Faser-Physics-001920-filtered.raw TI12Data + PROPERTIES TIMEOUT 300 ) +atlas_add_test( ProdRecoTestBeam + SCRIPT scripts/faser_reco.py ${CMAKE_CURRENT_SOURCE_DIR}/../RAWDATA/Faser-Physics-003613-filtered.raw TestBeamData + PROPERTIES TIMEOUT 300 ) + diff --git a/Control/CalypsoExample/Reconstruction/scripts/faser_reco.py b/Control/CalypsoExample/Reconstruction/scripts/faser_reco.py index a5c03abb9b11173dcde1b373d5e66d6963dd7255..aa6e8143f3f3ec00b56131004af2123f1e42a5b9 100755 --- a/Control/CalypsoExample/Reconstruction/scripts/faser_reco.py +++ b/Control/CalypsoExample/Reconstruction/scripts/faser_reco.py @@ -24,6 +24,8 @@ parser.add_argument("-r", "--reco", default="", help="Specify reco tag (to append to output filename)") parser.add_argument("-n", "--nevents", type=int, default=-1, help="Specify number of events to process (default: all)") +parser.add_argument("-v", "--verbose", action='store_true', + help="Turn on DEBUG output") args = parser.parse_args() @@ -61,8 +63,8 @@ from CalypsoConfiguration.AllConfigFlags import ConfigFlags Configurable.configurableRun3Behavior = True # Flags for this job -ConfigFlags.Input.isMC = False # Needed to bypass autoconfig -ConfigFlags.IOVDb.DatabaseInstance = "OFLP200" # Use MC conditions for now +ConfigFlags.Input.isMC = False # Needed to bypass autoconfig +ConfigFlags.IOVDb.DatabaseInstance = "OFLP200" # Use MC conditions for now ConfigFlags.Input.ProjectName = "data20" ConfigFlags.GeoModel.Align.Dynamic = False @@ -73,8 +75,13 @@ if runtype == "TI12Data": ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01" # Testbeam setup -elif runtype == "TestBeamData": +elif runtype == "TestBeamData" or runtype == "TestBeam2021": ConfigFlags.GeoModel.FaserVersion = "FASER-TB00" + ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-TB00" + +# New TI12 geometry (ugh) +elif runtype == "TI12Data02": + ConfigFlags.GeoModel.FaserVersion = "FASER-02" ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-02" else: @@ -121,13 +128,17 @@ acc.merge(FaserGeometryCfg(ConfigFlags)) from WaveRecAlgs.WaveRecAlgsConfig import WaveformReconstructionCfg acc.merge(WaveformReconstructionCfg(ConfigFlags)) +# Not ready for primetime +# from CaloRecAlgs.CaloRecAlgsConfig import CalorimeterReconstructionCfg +# acc.merge(CalorimeterReconstructionCfg(ConfigFlags)) + # Tracker clusters from TrackerPrepRawDataFormation.TrackerPrepRawDataFormationConfig import FaserSCT_ClusterizationCfg acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags)) -# ... try SpacePoints -#from TrackerSpacePointFormation.TrackerSpacePointFormationConfig import TrackerSpacePointFinderCfg -#acc.merge(TrackerSpacePointFinderCfg(ConfigFlags)) +# SpacePoints +from TrackerSpacePointFormation.TrackerSpacePointFormationConfig import TrackerSpacePointFinderCfg +acc.merge(TrackerSpacePointFinderCfg(ConfigFlags)) # Try Dave's fitter from TrackerClusterFit.TrackerClusterFitConfig import ClusterFitAlgCfg @@ -142,33 +153,47 @@ itemList = [ "xAOD::EventInfo#*" , "xAOD::FaserTriggerDataAux#*" , "FaserSCT_RDO_Container#*" , "Tracker::FaserSCT_ClusterContainer#*" - #, "Tracker::SCT_SpacePointContainer#*" - #, "Tracker::SCT_SpacePointOverlapCollection#*" + , "FaserSCT_SpacePointContainer#*" + #, "FaserSCT_SpacePointOverlapCollection#*" , "TrackCollection#*" ] acc.merge(OutputStreamCfg(ConfigFlags, "xAOD", itemList)) -# Waveform reconstruction +# Waveform reconstruction output from WaveRecAlgs.WaveRecAlgsConfig import WaveformReconstructionOutputCfg acc.merge(WaveformReconstructionOutputCfg(ConfigFlags)) +# Calorimeter reconstruction output +# from CaloRecAlgs.CaloRecAlgsConfig import CalorimeterReconstructionOutputCfg +# acc.merge(CalorimeterReconstructionOutputCfg(ConfigFlags)) + # Check what we have print( "Writing out xAOD objects:" ) print( acc.getEventAlgo("OutputStreamxAOD").ItemList ) +# Hack to avoid problem with our use of MC databases when isMC = False +replicaSvc = acc.getService("DBReplicaSvc") +replicaSvc.COOLSQLiteVetoPattern = "" +replicaSvc.UseCOOLSQLite = True +replicaSvc.UseCOOLFrontier = False +replicaSvc.UseGeomSQLite = True + # Configure verbosity # ConfigFlags.dump() -# logging.getLogger('forcomps').setLevel(VERBOSE) -# acc.foreach_component("*").OutputLevel = VERBOSE -acc.foreach_component("*").OutputLevel = INFO +if args.verbose: + acc.foreach_component("*").OutputLevel = VERBOSE + + #acc.getService("FaserByteStreamInputSvc").DumpFlag = True + #acc.getService("FaserEventSelector").OutputLevel = VERBOSE + #acc.getService("FaserByteStreamInputSvc").OutputLevel = VERBOSE + #acc.getService("FaserByteStreamCnvSvc").OutputLevel = VERBOSE + #acc.getService("FaserByteStreamAddressProviderSvc").OutputLevel = VERBOSE + +else: + acc.foreach_component("*").OutputLevel = INFO + acc.foreach_component("*ClassID*").OutputLevel = INFO -# log.setLevel(VERBOSE) -#acc.getService("FaserByteStreamInputSvc").DumpFlag = True -#acc.getService("FaserEventSelector").OutputLevel = VERBOSE -#acc.getService("FaserByteStreamInputSvc").OutputLevel = VERBOSE -#acc.getService("FaserByteStreamCnvSvc").OutputLevel = VERBOSE -#acc.getService("FaserByteStreamAddressProviderSvc").OutputLevel = VERBOSE acc.getService("MessageSvc").Format = "% F%40W%S%7W%R%T %0W%M" # Execute and finish diff --git a/Control/CalypsoExample/Reconstruction/scripts/submit_faser_reco.sh b/Control/CalypsoExample/Reconstruction/scripts/submit_faser_reco.sh index 6bb4b895732639182709dc0d237458704ddeb4fe..64cca5567690c0680a4966b7e64f1d8ea869b1ca 100755 --- a/Control/CalypsoExample/Reconstruction/scripts/submit_faser_reco.sh +++ b/Control/CalypsoExample/Reconstruction/scripts/submit_faser_reco.sh @@ -89,7 +89,7 @@ asetup source build/x8*/setup.sh # # Do this by hand -# asetup --input="$release_directory/calypso/asetup.faser" Athena,22.0.40 +# asetup --input="$release_directory/calypso/asetup.faser" Athena,22.0.49 # source "$release_directory/build/x8*/setup.sh" # # diff --git a/Control/CalypsoExample/TrackerDataAccessExample/python/TrackerDataAccessExampleConfig.py b/Control/CalypsoExample/TrackerDataAccessExample/python/TrackerDataAccessExampleConfig.py index 066f8560b4df98fae490fc79a876c21ae1332313..7a0df38c43f4348ef13c84b5f5af7348c468a0ae 100755 --- a/Control/CalypsoExample/TrackerDataAccessExample/python/TrackerDataAccessExampleConfig.py +++ b/Control/CalypsoExample/TrackerDataAccessExample/python/TrackerDataAccessExampleConfig.py @@ -53,7 +53,6 @@ if __name__ == "__main__": acc.merge(PoolWriteCfg(ConfigFlags)) # Configure output - from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg itemList = [ "xAOD::EventInfo#*", "xAOD::EventAuxInfo#*", @@ -65,6 +64,13 @@ if __name__ == "__main__": # Set up algorithm acc.merge(TrackerDataAccessExampleCfg(ConfigFlags)) +# Hack to avoid problem with our use of MC databases when isMC = False + replicaSvc = acc.getService("DBReplicaSvc") + replicaSvc.COOLSQLiteVetoPattern = "" + replicaSvc.UseCOOLSQLite = True + replicaSvc.UseCOOLFrontier = False + replicaSvc.UseGeomSQLite = True + # Configure verbosity # ConfigFlags.dump() logging.getLogger('forcomps').setLevel(WARNING) diff --git a/Control/CalypsoExample/TriggerDataAccessExample/python/TriggerDataAccessExampleConfig.py b/Control/CalypsoExample/TriggerDataAccessExample/python/TriggerDataAccessExampleConfig.py index 737d03721f09409e6d88e83dadd2e618cbedd600..add815c7f67c8d705be76b635104ffe21ce24c31 100755 --- a/Control/CalypsoExample/TriggerDataAccessExample/python/TriggerDataAccessExampleConfig.py +++ b/Control/CalypsoExample/TriggerDataAccessExample/python/TriggerDataAccessExampleConfig.py @@ -52,7 +52,6 @@ if __name__ == "__main__": acc.merge(PoolWriteCfg(ConfigFlags)) # Configure output - from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg itemList = [ "xAOD::EventInfo#*", "xAOD::EventAuxInfo#*", @@ -64,6 +63,13 @@ if __name__ == "__main__": # Set up algorithm acc.merge(TriggerDataAccessExampleCfg(ConfigFlags)) +# Hack to avoid problem with our use of MC databases when isMC = False + replicaSvc = acc.getService("DBReplicaSvc") + replicaSvc.COOLSQLiteVetoPattern = "" + replicaSvc.UseCOOLSQLite = True + replicaSvc.UseCOOLFrontier = False + replicaSvc.UseGeomSQLite = True + # Configure verbosity # ConfigFlags.dump() # logging.getLogger('forcomps').setLevel(VERBOSE) diff --git a/Control/CalypsoExample/WaveformDataAccessExample/python/WaveformDataAccessExampleConfig.py b/Control/CalypsoExample/WaveformDataAccessExample/python/WaveformDataAccessExampleConfig.py index 1151c74dffc7ddaa0182df025e82dd243c36684a..e360be84e063b25d99ce129819562b33f6223e37 100755 --- a/Control/CalypsoExample/WaveformDataAccessExample/python/WaveformDataAccessExampleConfig.py +++ b/Control/CalypsoExample/WaveformDataAccessExample/python/WaveformDataAccessExampleConfig.py @@ -52,7 +52,6 @@ if __name__ == "__main__": acc.merge(PoolWriteCfg(ConfigFlags)) # Configure output - from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg itemList = [ "xAOD::EventInfo#*", "xAOD::EventAuxInfo#*", @@ -64,6 +63,13 @@ if __name__ == "__main__": # Set up algorithm acc.merge(WaveformDataAccessExampleCfg(ConfigFlags)) +# Hack to avoid problem with our use of MC databases when isMC = False + replicaSvc = acc.getService("DBReplicaSvc") + replicaSvc.COOLSQLiteVetoPattern = "" + replicaSvc.UseCOOLSQLite = True + replicaSvc.UseCOOLFrontier = False + replicaSvc.UseGeomSQLite = True + # Configure verbosity # ConfigFlags.dump() # logging.getLogger('forcomps').setLevel(VERBOSE) diff --git a/Control/CalypsoExample/WriteAlignment/python/WriteAlignmentConfig.py b/Control/CalypsoExample/WriteAlignment/python/WriteAlignmentConfig_Faser01.py similarity index 73% rename from Control/CalypsoExample/WriteAlignment/python/WriteAlignmentConfig.py rename to Control/CalypsoExample/WriteAlignment/python/WriteAlignmentConfig_Faser01.py index de5a92acd49f221666e3d4ff053b1af43183526f..675f61f5b77cea6bc6fac3c42eb01f17bfc492b8 100644 --- a/Control/CalypsoExample/WriteAlignment/python/WriteAlignmentConfig.py +++ b/Control/CalypsoExample/WriteAlignment/python/WriteAlignmentConfig_Faser01.py @@ -12,11 +12,11 @@ def WriteAlignmentCfg(flags, name="WriteAlignmentAlg", **kwargs): a = FaserGeometryCfg(flags) # This section is to allow alignment to be written to a conditions DB file - # from IOVDbSvc.IOVDbSvcConfig import IOVDbSvcCfg - # result = IOVDbSvcCfg(flags) - # iovDbSvc = result.getPrimary() - # iovDbSvc.dbConnection="sqlite://;schema=ALLP200.db;dbname=OFLP200" - # a.merge(result) + from IOVDbSvc.IOVDbSvcConfig import IOVDbSvcCfg + result = IOVDbSvcCfg(flags) + iovDbSvc = result.getPrimary() + iovDbSvc.dbConnection=flags.IOVDb.DBConnection + a.merge(result) AthenaPoolCnvSvc=CompFactory.AthenaPoolCnvSvc apcs=AthenaPoolCnvSvc() @@ -28,7 +28,7 @@ def WriteAlignmentCfg(flags, name="WriteAlignmentAlg", **kwargs): # Configure the algorithm itself WriteAlignmentAlg = CompFactory.WriteAlignmentAlg - outputTool = CompFactory.AthenaOutputStreamTool("DbStreamTool", OutputFile = "FaserSCT_AlignDb.pool.root", + outputTool = CompFactory.AthenaOutputStreamTool("DbStreamTool", OutputFile = flags.WriteAlignment.PoolFileName, PoolContainerPrefix="ConditionsContainer", TopLevelContainerName = "<type>", SubLevelBranchName= "<key>" ) @@ -48,10 +48,11 @@ if __name__ == "__main__": # Flags for this job ConfigFlags.Input.isMC = True # Needed to bypass autoconfig - ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01" # Always needed; must match FaserVersion ConfigFlags.GeoModel.FaserVersion = "FASER-01" # Default FASER geometry - ConfigFlags.GeoModel.GeoExportFile = "faserGeo.db" # Writes out a GeoModel file with the full geometry tree (optional, comment out to skip) - ConfigFlags.IOVDb.DBConnection = "sqlite://;schema=ALLP200.db;dbname=OFLP200" + ConfigFlags.IOVDb.GlobalTag = "OFLCOND-"+ ConfigFlags.GeoModel.FaserVersion # Always needed; must match FaserVersion + ConfigFlags.IOVDb.DBConnection = "sqlite://;schema=" + ConfigFlags.GeoModel.FaserVersion + "_ALLP200.db;dbname=OFLP200" + ConfigFlags.GeoModel.Align.Disable = True # Hack to avoid loading alignment when we want to create it from scratch + ConfigFlags.addFlag("WriteAlignment.PoolFileName", ConfigFlags.GeoModel.FaserVersion + "_Align.pool.root") ConfigFlags.lock() # Configure components @@ -59,7 +60,7 @@ if __name__ == "__main__": acc = MainServicesCfg(ConfigFlags) # Set things up to create a conditions DB with neutral Tracker alignment transforms - acc.merge(WriteAlignmentCfg(ConfigFlags)) + acc.merge(WriteAlignmentCfg(ConfigFlags, ValidRunStart=1, ValidEvtStart=0, ValidRunEnd=9999999, ValidEvtEnd=9999999, CondTag=ConfigFlags.GeoModel.FaserVersion.replace("FASER", "TRACKER-ALIGN"))) # Configure verbosity # ConfigFlags.dump() diff --git a/Control/CalypsoExample/WriteAlignment/python/WriteAlignmentConfig_Faser02.py b/Control/CalypsoExample/WriteAlignment/python/WriteAlignmentConfig_Faser02.py new file mode 100644 index 0000000000000000000000000000000000000000..b05c15632415e873e301a08d9f63332175ebfe20 --- /dev/null +++ b/Control/CalypsoExample/WriteAlignment/python/WriteAlignmentConfig_Faser02.py @@ -0,0 +1,73 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +#!/usr/bin/env python +import sys +from AthenaCommon.Constants import VERBOSE, INFO +from AthenaConfiguration.ComponentFactory import CompFactory + +def WriteAlignmentCfg(flags, name="WriteAlignmentAlg", **kwargs): + + # Initialize GeoModel + from FaserGeoModel.FaserGeoModelConfig import FaserGeometryCfg + a = FaserGeometryCfg(flags) + + # This section is to allow alignment to be written to a conditions DB file + from IOVDbSvc.IOVDbSvcConfig import IOVDbSvcCfg + result = IOVDbSvcCfg(flags) + iovDbSvc = result.getPrimary() + iovDbSvc.dbConnection=flags.IOVDb.DBConnection + a.merge(result) + + AthenaPoolCnvSvc=CompFactory.AthenaPoolCnvSvc + apcs=AthenaPoolCnvSvc() + a.addService(apcs) + EvtPersistencySvc=CompFactory.EvtPersistencySvc + a.addService(EvtPersistencySvc("EventPersistencySvc",CnvServices=[apcs.getFullJobOptName(),])) + + a.addService(CompFactory.IOVRegistrationSvc(PayloadTable=False,OutputLevel=VERBOSE)) + + # Configure the algorithm itself + WriteAlignmentAlg = CompFactory.WriteAlignmentAlg + outputTool = CompFactory.AthenaOutputStreamTool("DbStreamTool", OutputFile = flags.WriteAlignment.PoolFileName, + PoolContainerPrefix="ConditionsContainer", + TopLevelContainerName = "<type>", + SubLevelBranchName= "<key>" ) + kwargs.setdefault("AlignDbTool", CompFactory.TrackerAlignDBTool("AlignDbTool", OutputTool = outputTool, OutputLevel=VERBOSE)) + a.addEventAlgo(WriteAlignmentAlg(name, **kwargs)) + + return a + + +if __name__ == "__main__": + # from AthenaCommon.Logging import log, logging + from AthenaCommon.Configurable import Configurable + # from AthenaConfiguration.ComponentFactory import CompFactory + from CalypsoConfiguration.AllConfigFlags import ConfigFlags + + Configurable.configurableRun3Behavior = True + +# Flags for this job + ConfigFlags.Input.isMC = True # Needed to bypass autoconfig + ConfigFlags.GeoModel.FaserVersion = "FASER-02" # Default FASER geometry + ConfigFlags.IOVDb.GlobalTag = "OFLCOND-"+ ConfigFlags.GeoModel.FaserVersion # Always needed; must match FaserVersion + ConfigFlags.IOVDb.DBConnection = "sqlite://;schema=" + ConfigFlags.GeoModel.FaserVersion + "_ALLP200.db;dbname=OFLP200" + ConfigFlags.GeoModel.Align.Disable = True # Hack to avoid loading alignment when we want to create it from scratch + ConfigFlags.addFlag("WriteAlignment.PoolFileName", ConfigFlags.GeoModel.FaserVersion + "_Align.pool.root") + ConfigFlags.lock() + +# Configure components + from CalypsoConfiguration.MainServicesConfig import MainServicesCfg + acc = MainServicesCfg(ConfigFlags) + +# Set things up to create a conditions DB with neutral Tracker alignment transforms + acc.merge(WriteAlignmentCfg(ConfigFlags, ValidRunStart=1, ValidEvtStart=0, ValidRunEnd=9999999, ValidEvtEnd=9999999, CondTag=ConfigFlags.GeoModel.FaserVersion.replace("FASER", "TRACKER-ALIGN"))) + +# Configure verbosity + # ConfigFlags.dump() + # logging.getLogger('forcomps').setLevel(VERBOSE) + acc.foreach_component("*").OutputLevel = VERBOSE + acc.foreach_component("*ClassID*").OutputLevel = INFO + # log.setLevel(VERBOSE) + +# Execute and finish + sys.exit(int(acc.run(maxEvents=1).isFailure())) diff --git a/Control/CalypsoExample/WriteAlignment/python/WriteAlignmentConfig_FaserTB00.py b/Control/CalypsoExample/WriteAlignment/python/WriteAlignmentConfig_FaserTB00.py new file mode 100644 index 0000000000000000000000000000000000000000..d57092f2dd8b8c1dcb3bd6568fdb3dac636d3cf2 --- /dev/null +++ b/Control/CalypsoExample/WriteAlignment/python/WriteAlignmentConfig_FaserTB00.py @@ -0,0 +1,73 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +#!/usr/bin/env python +import sys +from AthenaCommon.Constants import VERBOSE, INFO +from AthenaConfiguration.ComponentFactory import CompFactory + +def WriteAlignmentCfg(flags, name="WriteAlignmentAlg", **kwargs): + + # Initialize GeoModel + from FaserGeoModel.FaserGeoModelConfig import FaserGeometryCfg + a = FaserGeometryCfg(flags) + + # This section is to allow alignment to be written to a conditions DB file + from IOVDbSvc.IOVDbSvcConfig import IOVDbSvcCfg + result = IOVDbSvcCfg(flags) + iovDbSvc = result.getPrimary() + iovDbSvc.dbConnection=flags.IOVDb.DBConnection + a.merge(result) + + AthenaPoolCnvSvc=CompFactory.AthenaPoolCnvSvc + apcs=AthenaPoolCnvSvc() + a.addService(apcs) + EvtPersistencySvc=CompFactory.EvtPersistencySvc + a.addService(EvtPersistencySvc("EventPersistencySvc",CnvServices=[apcs.getFullJobOptName(),])) + + a.addService(CompFactory.IOVRegistrationSvc(PayloadTable=False,OutputLevel=VERBOSE)) + + # Configure the algorithm itself + WriteAlignmentAlg = CompFactory.WriteAlignmentAlg + outputTool = CompFactory.AthenaOutputStreamTool("DbStreamTool", OutputFile = flags.WriteAlignment.PoolFileName, + PoolContainerPrefix="ConditionsContainer", + TopLevelContainerName = "<type>", + SubLevelBranchName= "<key>" ) + kwargs.setdefault("AlignDbTool", CompFactory.TrackerAlignDBTool("AlignDbTool", OutputTool = outputTool, OutputLevel=VERBOSE)) + a.addEventAlgo(WriteAlignmentAlg(name, **kwargs)) + + return a + + +if __name__ == "__main__": + # from AthenaCommon.Logging import log, logging + from AthenaCommon.Configurable import Configurable + # from AthenaConfiguration.ComponentFactory import CompFactory + from CalypsoConfiguration.AllConfigFlags import ConfigFlags + + Configurable.configurableRun3Behavior = True + +# Flags for this job + ConfigFlags.Input.isMC = True # Needed to bypass autoconfig + ConfigFlags.GeoModel.FaserVersion = "FASER-TB00" # Default FASER geometry + ConfigFlags.IOVDb.GlobalTag = "OFLCOND-"+ ConfigFlags.GeoModel.FaserVersion # Always needed; must match FaserVersion + ConfigFlags.IOVDb.DBConnection = "sqlite://;schema=" + ConfigFlags.GeoModel.FaserVersion + "_ALLP200.db;dbname=OFLP200" + ConfigFlags.GeoModel.Align.Disable = True # Hack to avoid loading alignment when we want to create it from scratch + ConfigFlags.addFlag("WriteAlignment.PoolFileName", ConfigFlags.GeoModel.FaserVersion + "_Align.pool.root") + ConfigFlags.lock() + +# Configure components + from CalypsoConfiguration.MainServicesConfig import MainServicesCfg + acc = MainServicesCfg(ConfigFlags) + +# Set things up to create a conditions DB with neutral Tracker alignment transforms + acc.merge(WriteAlignmentCfg(ConfigFlags, ValidRunStart=1, ValidEvtStart=0, ValidRunEnd=9999999, ValidEvtEnd=9999999, CondTag=ConfigFlags.GeoModel.FaserVersion.replace("FASER", "TRACKER-ALIGN"))) + +# Configure verbosity + # ConfigFlags.dump() + # logging.getLogger('forcomps').setLevel(VERBOSE) + acc.foreach_component("*").OutputLevel = VERBOSE + acc.foreach_component("*ClassID*").OutputLevel = INFO + # log.setLevel(VERBOSE) + +# Execute and finish + sys.exit(int(acc.run(maxEvents=1).isFailure())) diff --git a/Control/CalypsoExample/WriteAlignment/scripts/CopyAlignFolder.sh b/Control/CalypsoExample/WriteAlignment/scripts/CopyAlignFolder.sh index ce694ce4759a48ba872a9f1e57a6798b9601095c..4ed49f4d4162bdf40cb4b72aacfc066fa993576b 100644 --- a/Control/CalypsoExample/WriteAlignment/scripts/CopyAlignFolder.sh +++ b/Control/CalypsoExample/WriteAlignment/scripts/CopyAlignFolder.sh @@ -1,5 +1,18 @@ #!/bin/sh -AtlCoolCopy "sqlite://;schema=./ALLP200.db;dbname=OFLP200" "sqlite://;schema=data/ALLP200.db;dbname=OFLP200" -a -fnp -ot "TRACKER-ALIGN-01" -cp -n PoolFileCatalog.xml data/ -cp -n FaserSCT_AlignDb.pool.root data/ \ No newline at end of file +rm -f *_Align.pool.root +rm -f *_ALLP200.db +rm -f PoolFileCatalog.xml +rm -f writeAlignment_*.log + +python python/WriteAlignment/WriteAlignmentConfig_Faser01.py >& writeAlignment_Faser01.log +python python/WriteAlignment/WriteAlignmentConfig_Faser02.py >& writeAlignment_Faser02.log +python python/WriteAlignment/WriteAlignmentConfig_FaserTB00.py >& writeAlignment_FaserTB00.log + +AtlCoolCopy "sqlite://;schema=./FASER-01_ALLP200.db;dbname=OFLP200" "sqlite://;schema=data/sqlite200/ALLP200.db;dbname=OFLP200" -fnp -ot "TRACKER-ALIGN-01" +AtlCoolCopy "sqlite://;schema=./FASER-02_ALLP200.db;dbname=OFLP200" "sqlite://;schema=data/sqlite200/ALLP200.db;dbname=OFLP200" -fnp -ot "TRACKER-ALIGN-02" +AtlCoolCopy "sqlite://;schema=./FASER-TB00_ALLP200.db;dbname=OFLP200" "sqlite://;schema=data/sqlite200/ALLP200.db;dbname=OFLP200" -fnp -ot "TRACKER-ALIGN-TB00" +mkdir data/poolcond +cp -n PoolFileCatalog.xml data/poolcond/ +ln -s ${PWD}/data/poolcond/PoolFileCatalog.xml ${PWD}/data/poolcond/PoolCat_oflcond.xml +cp -n *_Align.pool.root data/poolcond/ \ No newline at end of file diff --git a/Control/CalypsoExample/WriteAlignment/src/WriteAlignmentAlg.cxx b/Control/CalypsoExample/WriteAlignment/src/WriteAlignmentAlg.cxx index 6efcb9b457f0e03096c1067059657b26fa8de4b5..38accc36b69349bf63b2fe8a8d983dbccf7bb08b 100644 --- a/Control/CalypsoExample/WriteAlignment/src/WriteAlignmentAlg.cxx +++ b/Control/CalypsoExample/WriteAlignment/src/WriteAlignmentAlg.cxx @@ -73,7 +73,7 @@ StatusCode WriteAlignmentAlg::execute(const EventContext&) const ATH_CHECK(m_alignTool->createDB()); ATH_CHECK(m_alignTool->sortTrans()); ATH_CHECK(m_alignTool->outputObjs()); - ATH_CHECK(m_alignTool->fillDB("",1,0,9999999,9999999)); + ATH_CHECK(m_alignTool->fillDB(m_conditionsTag, m_validRunStart, m_validEvtStart , m_validRunEnd, m_validEvtEnd)); return StatusCode::SUCCESS; } diff --git a/Control/CalypsoExample/WriteAlignment/src/WriteAlignmentAlg.h b/Control/CalypsoExample/WriteAlignment/src/WriteAlignmentAlg.h index 0797a34fdb88cdecb14021d10f4c188c5134d430..37d8b9033e084e437205dcebb408302234ece576 100644 --- a/Control/CalypsoExample/WriteAlignment/src/WriteAlignmentAlg.h +++ b/Control/CalypsoExample/WriteAlignment/src/WriteAlignmentAlg.h @@ -41,6 +41,13 @@ class WriteAlignmentAlg : public AthReentrantAlgorithm Gaudi::Property<int> m_numSctModulesPerRow {this, "NumSCTModulesPerRow", 2, "Number of modules per row in the SCT detector"}; Gaudi::Property<int> m_numSctStripsPerSensor {this, "NumSCTStripsPerSensor", 768,"Number of readout strips per sensor in the SCT detector"}; + Gaudi::Property<int> m_validRunStart {this, "ValidRunStart", 1, "Run number of IOV start"}; + Gaudi::Property<int> m_validRunEnd {this, "ValidRunEnd", 9999999, "Run number of IOV end"}; + Gaudi::Property<int> m_validEvtStart {this, "ValidEvtStart", 0, "Event number of IOV start"}; + Gaudi::Property<int> m_validEvtEnd {this, "ValidEvtEnd", 9999999, "Event number of IOV end"}; + + Gaudi::Property<std::string> m_conditionsTag {this, "CondTag", "", "Conditions tag for created alignment"}; + int m_numSctStations; ToolHandle<ITrackerAlignDBTool> m_alignTool { this, "AlignDbTool", "TrackerAlignDBTool" }; diff --git a/Control/CalypsoExample/rawdata/Faser-Physics-003613-filtered.raw b/Control/CalypsoExample/rawdata/Faser-Physics-003613-filtered.raw new file mode 100644 index 0000000000000000000000000000000000000000..b35f8e69f595d3ba2dcb5a90afb77fd148e978de Binary files /dev/null and b/Control/CalypsoExample/rawdata/Faser-Physics-003613-filtered.raw differ diff --git a/Database/ConnectionManagement/FaserAuthentication/data/dblookup.xml b/Database/ConnectionManagement/FaserAuthentication/data/dblookup.xml index 91ba81751aec848daa4b45e63b874fb288d013a0..52542a2837125d540824617b1085a5d710c3507f 100644 --- a/Database/ConnectionManagement/FaserAuthentication/data/dblookup.xml +++ b/Database/ConnectionManagement/FaserAuthentication/data/dblookup.xml @@ -2,20 +2,28 @@ <servicelist> <logicalservice name="FASERDD"> + <service name="sqlite_file:data/geomDB/geomDB_sqlite" accessMode="read" /> <service name="sqlite_file:///cvmfs/faser.cern.ch/repo/sw/database/DBRelease/current/geomDB/geomDB_sqlite" accessMode="read" /> </logicalservice> <logicalservice name="COOLOFL_SCT"> + <service name="sqlite_file:data/sqlite200/ALLP200.db" accessMode="read" /> <service name="sqlite_file:///cvmfs/faser.cern.ch/repo/sw/database/DBRelease/current/sqlite200/ALLP200.db" accessMode="read" /> </logicalservice> <logicalservice name="COOLOFL_DCS"> + <service name="sqlite_file:data/sqlite200/ALLP200.db" accessMode="read" /> <service name="sqlite_file:///cvmfs/faser.cern.ch/repo/sw/database/DBRelease/current/sqlite200/ALLP200.db" accessMode="read" /> </logicalservice> <logicalservice name="COOLOFL_GLOBAL"> + <service name="sqlite_file:data/sqlite200/ALLP200.db" accessMode="read" /> <service name="sqlite_file:///cvmfs/faser.cern.ch/repo/sw/database/DBRelease/current/sqlite200/ALLP200.db" accessMode="read" /> </logicalservice> +<logicalservice name="COOLOFL_TDAQ"> + <service name="sqlite_file:data/sqlite200/CABP200.db" accessMode="read" /> + <service name="sqlite_file:///cvmfs/faser.cern.ch/repo/sw/database/DBRelease/current/sqlite200/CABP200.db" accessMode="read" /> +</logicalservice> </servicelist> diff --git a/Event/FaserByteStreamCnvSvc/python/FaserByteStreamCnvSvcConfig.py b/Event/FaserByteStreamCnvSvc/python/FaserByteStreamCnvSvcConfig.py index e2315ae1c6f5ff50b973e6c08377a3cee9da9ef4..5da32c10e6281b4d8547923fd8e5f71095c7e409 100644 --- a/Event/FaserByteStreamCnvSvc/python/FaserByteStreamCnvSvcConfig.py +++ b/Event/FaserByteStreamCnvSvc/python/FaserByteStreamCnvSvcConfig.py @@ -50,6 +50,10 @@ def FaserByteStreamCnvSvcCfg(configFlags, **kwargs): from WaveByteStream.WaveByteStreamConfig import WaveByteStreamCfg result.merge(WaveByteStreamCfg(configFlags)) +# Configure TrackerByteStream converter + from TrackerByteStream.TrackerByteStreamConfig import TrackerByteStreamCfg + result.merge(TrackerByteStreamCfg(configFlags)) + # Load ByteStreamEventStorageInputSvc bsInputSvc = CompFactory.FaserByteStreamInputSvc result.addService(bsInputSvc(name = "FaserByteStreamInputSvc")) diff --git a/Generators/FaserCosmicGenerator/README.md b/Generators/FaserCosmicGenerator/README.md index 512c32c60d6d875dba083a0fc2e5dc34e7dc8499..49199a3cef6173c5f4fed4c41de452ef7713c6ff 100644 --- a/Generators/FaserCosmicGenerator/README.md +++ b/Generators/FaserCosmicGenerator/README.md @@ -2,7 +2,7 @@ ## Setup -In Athena 22.0.40, the scipy module is missing from the LCG environment for some reason. +In Athena 22.0.49, the scipy module is missing from the LCG environment for some reason. To use the generator, the following command is required after the usual steps to setup the release: diff --git a/Generators/FaserParticleGun/python/RadialPosSampler.py b/Generators/FaserParticleGun/python/RadialPosSampler.py new file mode 100644 index 0000000000000000000000000000000000000000..4a14987a142697816b22cbec202f56c8bf3183b5 --- /dev/null +++ b/Generators/FaserParticleGun/python/RadialPosSampler.py @@ -0,0 +1,85 @@ +import random +from math import pi, sin, cos, sqrt, log +from ParticleGun.samplers import Sampler, mksampler +import ROOT + +class RadialPosSampler(Sampler): + """ + Sampler of Position 3-vectors, for modelling a beamspot, based on radius. + """ + + def __init__(self, r, x, y, z, t = 0): + self.radius = r + self.x = x + self.y = y + self.z = z + self.t = t + + @property + def z(self): + "z position sampler" + return self._z + @z.setter + def z(self, z): + self._z = mksampler(z) + + @property + def t(self): + "Time sampler" + return self._t + @t.setter + def t(self, t): + self._t = mksampler(t) + + @property + def r(self): + "r position sampler" + fwhm = 2*self.radius + sig = fwhm/(2 * sqrt(2 * log(2))) + + # return random.uniform(0, self.radius) + return random.gauss(0, self.radius) + # return random.gauss(0, sig) + + @property + def phi(self): + "phi position sampler" + return random.uniform(0, 2*pi) + + def shoot(self): + r = self.r + phi = self.phi + x = self.x + r * cos(phi) + y = self.y + r * sin(phi) + z = self.z() + t = self.t() + + return ROOT.TLorentzVector(x, y, z, t) + +if __name__ == "__main__": +# test when run from command line + + import numpy as np + import matplotlib.pyplot as plt + + xlist = [] + ylist = [] + + r = RadialPosSampler(r = 1, x = 10, y = -10, z = 10) + for i in range (10000): + res = r.shoot() + xlist.append(res.X()) + ylist.append(res.Y()) + + xarr = np.array(xlist) + yarr = np.array(ylist) + + plt.figure(figsize = (5,5)) + plt.subplot(2,2,1) + plt.scatter(xarr, yarr, marker = "*") + plt.subplot(2,2,2) + plt.hist(yarr) + plt.subplot(2,2,3) + plt.hist(xarr) + plt.tight_layout() + plt.show() diff --git a/Generators/GenieReader/CMakeLists.txt b/Generators/GenieReader/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..e2fddd3866d318e776ba8417f1694413dcb1cac8 --- /dev/null +++ b/Generators/GenieReader/CMakeLists.txt @@ -0,0 +1,11 @@ +################################################################################ +# Package: ReadGenie +################################################################################ + +# Declare the package name: +atlas_subdir( GenieReader ) + +# Install files from the package: +atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) + +atlas_install_joboptions( share/*.py ) \ No newline at end of file diff --git a/Generators/GenieReader/python/GenieReaderAlg.py b/Generators/GenieReader/python/GenieReaderAlg.py new file mode 100644 index 0000000000000000000000000000000000000000..c930ae66ae2aa8ef4eddf7f31873acc598d31a5c --- /dev/null +++ b/Generators/GenieReader/python/GenieReaderAlg.py @@ -0,0 +1,61 @@ +# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration + +from AthenaCommon.AppMgr import ServiceMgr as svcMgr +from GeneratorModules.EvgenAlg import EvgenAlg +from AthenaPython.PyAthena import StatusCode +from AthenaCommon.SystemOfUnits import GeV, m + +import ROOT + +__author__ = "Dave Caser <dcasper@uci.edu>" + +class GenieReader(EvgenAlg): + def __init__(self, name="GenieReader", MCEventKey="BeamTruthEvent"): + super(GenieReader,self).__init__(name=name) + self.McEventKey = MCEventKey + return + + def fillEvent(self, evt): + try: + from AthenaPython.PyAthena import HepMC3 as HepMC + except ImportError: + from AthenaPython.PyAthena import HepMC as HepMC + evt.weights().push_back(1.0) + + pos = HepMC.FourVector(self.evtStore["vx"]*m, self.evtStore["vy"]*m, self.evtStore["vz"]*m, 0) + gv = HepMC.GenVertex(pos) + ROOT.SetOwnership(gv, False) + evt.add_vertex(gv) + + nParticles = self.evtStore["n"] + pdgc = list(self.evtStore["pdgc"]) + status = list(self.evtStore["status"]) + px = list(self.evtStore["px"]) + py = list(self.evtStore["py"]) + pz = list(self.evtStore["pz"]) + E = list(self.evtStore["E"]) + M = list(self.evtStore["M"]) + + for i in range(nParticles): + gp = HepMC.GenParticle() + mom = HepMC.FourVector(px[i]*GeV, py[i]*GeV, pz[i]*GeV, E[i]*GeV) + gp.set_momentum(mom) + gp.set_generated_mass(M[i]*GeV) + gp.set_pdg_id(pdgc[i]) + genie_status = status[i] + if (genie_status == 0): # initial particle + hepmc_status = 4 + elif (genie_status == 1): # stable final particle + hepmc_status = 1 + elif (genie_status == 3): # decayed particle + hepmc_status = 2 + else: # catch-all informational particle + hepmc_status = 3 + gp.set_status(hepmc_status) + ROOT.SetOwnership(gp, False) + if (hepmc_status == 4): + gv.add_particle_in(gp) + else: + gv.add_particle_out(gp) + + return StatusCode.Success diff --git a/Generators/GenieReader/python/__init__.py b/Generators/GenieReader/python/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..d13ae164caa4e93bf2899cea4e67d0ec515784a2 --- /dev/null +++ b/Generators/GenieReader/python/__init__.py @@ -0,0 +1 @@ +# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration diff --git a/Generators/GenieReader/share/GenieReader_jobOptions.py b/Generators/GenieReader/share/GenieReader_jobOptions.py new file mode 100644 index 0000000000000000000000000000000000000000..91ad7c1318b772fd8cb015eda03ea274b0a6815a --- /dev/null +++ b/Generators/GenieReader/share/GenieReader_jobOptions.py @@ -0,0 +1,39 @@ +# +# Usage: athena.py -c'INPUT=["faser.1.gfaser.root","faser.2.gfaser.root"]; OUTPUT="gFaser.EVNT.pool.root"; EVTMAX=100' GenieReader/GenieReader_jobOptions.py >& GenieReader.log +# +# INPUT and OUTPUT are mandatory (INPUT can be a list, as shown above) +# EVTMAX can be omitted; then all input files are read to the end +# + +if not 'INPUT' in dir(): + print("Missing INPUT parameter") + exit() + +if not isinstance(INPUT, (list,tuple)): + INPUT = [INPUT] + pass + +if not 'OUTPUT' in dir(): + print("Missing OUTPUT parameter") + exit() + +import AthenaRootComps.ReadAthenaRoot + +svcMgr.EventSelector.InputCollections = INPUT +svcMgr.EventSelector.TupleName = "gFaser" + +from GenieReader.GenieReaderAlg import GenieReader + +from AthenaCommon.AlgSequence import AlgSequence +job = AlgSequence() +job += GenieReader() + +from AthenaPoolCnvSvc.WriteAthenaPool import AthenaPoolOutputStream +ostream = AthenaPoolOutputStream( "StreamEVGEN" , OUTPUT, noTag=True ) +ostream.ItemList += [ "xAOD::EventInfo#*", "xAOD::EventAuxInfo#*", + "EventInfo#*", + "McEventCollection#*" ] +if not 'EVTMAX' in dir(): + EVTMAX = -1 + +theApp.EvtMax = EVTMAX diff --git a/Neutrino/NeutrinoEventCnv/NeutrinoSimEventAthenaPool/src/NeutrinoHitCollectionCnv.cxx b/Neutrino/NeutrinoEventCnv/NeutrinoSimEventAthenaPool/src/NeutrinoHitCollectionCnv.cxx index 36ff6569e3c56cd9551bae75145d1c3d5a610f2e..715a49b37efc4f942c879339debf9f67993aef39 100644 --- a/Neutrino/NeutrinoEventCnv/NeutrinoSimEventAthenaPool/src/NeutrinoHitCollectionCnv.cxx +++ b/Neutrino/NeutrinoEventCnv/NeutrinoSimEventAthenaPool/src/NeutrinoHitCollectionCnv.cxx @@ -4,6 +4,7 @@ #include "NeutrinoSimEventTPCnv/NeutrinoHits/NeutrinoHitCollectionCnv_p1.h" #include "NeutrinoSimEventTPCnv/NeutrinoHits/NeutrinoHit_p1.h" +#include "NeutrinoSimEventTPCnv/NeutrinoHits/NeutrinoHitCollectionCnv_p1a.h" #include "NeutrinoHitCollectionCnv.h" @@ -18,12 +19,16 @@ NeutrinoHitCollection_PERS* NeutrinoHitCollectionCnv::createPersistent(NeutrinoH NeutrinoHitCollection* NeutrinoHitCollectionCnv::createTransient() { MsgStream mlog(msgSvc(), "NeutrinoHitCollectionConverter" ); NeutrinoHitCollectionCnv_p1 converter_p1; + NeutrinoHitCollectionCnv_p1a converter_p1a; static const pool::Guid p1_guid("2CA7AF71-1494-4378-BED4-AFB5C54398AA"); - // static const pool::Guid p1_guid("B2573A16-4B46-4E1E-98E3-F93421680779"); + static const pool::Guid p1a_guid("0A3CD37D-64CE-405D-98CF-595D678B14B7"); NeutrinoHitCollection *trans_cont(0); - if( this->compareClassGuid(p1_guid)) { + if( this->compareClassGuid(p1a_guid)) { + std::unique_ptr< NeutrinoHitCollection_p1a > col_vect( this->poolReadObject< NeutrinoHitCollection_p1a >() ); + trans_cont = converter_p1a.createTransient( col_vect.get(), mlog ); + } else if( this->compareClassGuid(p1_guid)) { std::unique_ptr< NeutrinoHitCollection_p1 > col_vect( this->poolReadObject< NeutrinoHitCollection_p1 >() ); trans_cont = converter_p1.createTransient( col_vect.get(), mlog ); } else { diff --git a/Neutrino/NeutrinoEventCnv/NeutrinoSimEventAthenaPool/src/NeutrinoHitCollectionCnv.h b/Neutrino/NeutrinoEventCnv/NeutrinoSimEventAthenaPool/src/NeutrinoHitCollectionCnv.h index 5ccd3e1bb8675b5f5542032781af7d737aa1a378..a8158c01a6ef7b93b6e32915d758aa9bcad984ed 100644 --- a/Neutrino/NeutrinoEventCnv/NeutrinoSimEventAthenaPool/src/NeutrinoHitCollectionCnv.h +++ b/Neutrino/NeutrinoEventCnv/NeutrinoSimEventAthenaPool/src/NeutrinoHitCollectionCnv.h @@ -6,14 +6,14 @@ #define NEUTRINOHITCOLLECTIONCNV #include "NeutrinoSimEvent/NeutrinoHitCollection.h" -#include "NeutrinoSimEventTPCnv/NeutrinoHits/NeutrinoHitCollection_p1.h" -#include "NeutrinoSimEventTPCnv/NeutrinoHits/NeutrinoHitCollectionCnv_p1.h" +#include "NeutrinoSimEventTPCnv/NeutrinoHits/NeutrinoHitCollection_p1a.h" +#include "NeutrinoSimEventTPCnv/NeutrinoHits/NeutrinoHitCollectionCnv_p1a.h" #include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" // Gaudi #include "GaudiKernel/MsgStream.h" // typedef to the latest persistent version -typedef NeutrinoHitCollection_p1 NeutrinoHitCollection_PERS; -typedef NeutrinoHitCollectionCnv_p1 NeutrinoHitCollectionCnv_PERS; +typedef NeutrinoHitCollection_p1a NeutrinoHitCollection_PERS; +typedef NeutrinoHitCollectionCnv_p1a NeutrinoHitCollectionCnv_PERS; class NeutrinoHitCollectionCnv : public T_AthenaPoolCustomCnv<NeutrinoHitCollection, NeutrinoHitCollection_PERS > { friend class CnvFactory<NeutrinoHitCollectionCnv>; diff --git a/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/CMakeLists.txt b/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/CMakeLists.txt index defef98b76adfaf00e4b4c1da37c685cee6e2d7c..332a16c77b33035a064668b13fe3fe41ad4061ff 100644 --- a/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/CMakeLists.txt +++ b/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/CMakeLists.txt @@ -22,5 +22,5 @@ atlas_add_dictionary( NeutrinoSimEventTPCnvDict NeutrinoSimEventTPCnv/NeutrinoSimEventTPCnvDict.h NeutrinoSimEventTPCnv/selection.xml INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaPoolCnvSvcLib GaudiKernel GeneratorObjectsTPCnv NeutrinoSimEvent TestTools StoreGateLib SGtests Identifier NeutrinoSimEventTPCnv ) + LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaPoolCnvSvcLib GaudiKernel GeneratorObjectsTPCnv NeutrinoSimEvent TestTools StoreGateLib SGtests Identifier NeutrinoSimEventTPCnv AthenaKernel ) diff --git a/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/NeutrinoSimEventTPCnv/NeutrinoHits/NeutrinoHitCollectionCnv_p1a.h b/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/NeutrinoSimEventTPCnv/NeutrinoHits/NeutrinoHitCollectionCnv_p1a.h new file mode 100644 index 0000000000000000000000000000000000000000..5666f66e7e644581cc53cf2ec88a4a0f9f54fb83 --- /dev/null +++ b/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/NeutrinoSimEventTPCnv/NeutrinoHits/NeutrinoHitCollectionCnv_p1a.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef NEUTRINOHITCOLLECTIONCNV_P1A_H +#define NEUTRINOHITCOLLECTIONCNV_P1A_H + +// NeutrinoHitCollectionCnv_p1a, T/P separation of Neutrino Hits +// author D.Costanzo <davide.costanzo@cern.ch> +// author O.Arnaez <olivier.arnaez@cern.ch> + +#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h" +#include "NeutrinoSimEvent/NeutrinoHitCollection.h" +#include "NeutrinoHitCollection_p1a.h" + + +class NeutrinoHitCollectionCnv_p1a : public T_AthenaPoolTPCnvBase<NeutrinoHitCollection, NeutrinoHitCollection_p1a> +{ + public: + + NeutrinoHitCollectionCnv_p1a() {}; + + virtual NeutrinoHitCollection* createTransient(const NeutrinoHitCollection_p1a* persObj, MsgStream &log); + + virtual void persToTrans(const NeutrinoHitCollection_p1a* persCont, + NeutrinoHitCollection* transCont, + MsgStream &log) ; + virtual void transToPers(const NeutrinoHitCollection* transCont, + NeutrinoHitCollection_p1a* persCont, + MsgStream &log) ; + + private: + + static const double m_persEneUnit; + static const double m_persLenUnit; + static const double m_persAngUnit; + static const double m_2bHalfMaximum; + static const int m_2bMaximum; +}; + +#endif diff --git a/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/NeutrinoSimEventTPCnv/NeutrinoHits/NeutrinoHitCollection_p1a.h b/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/NeutrinoSimEventTPCnv/NeutrinoHits/NeutrinoHitCollection_p1a.h new file mode 100644 index 0000000000000000000000000000000000000000..639ff984017e9c002a4d5317c652744751fa1f76 --- /dev/null +++ b/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/NeutrinoSimEventTPCnv/NeutrinoHits/NeutrinoHitCollection_p1a.h @@ -0,0 +1,57 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef NEUTRINOHITCOLLECTION_P1A_H +#define NEUTRINOHITCOLLECTION_P1A_H + +/* + +Authors: Davide Costanzo Rob Duxfield + +*/ + +#include <vector> +#include <string> + +class NeutrinoHitCollection_p1a +{ + public: +/// Default constructor + NeutrinoHitCollection_p1a (); + //private: + + std::vector<float> m_hit1_meanTime; // 1 element per string + std::vector<float> m_hit1_x0; // + std::vector<float> m_hit1_y0; // + std::vector<float> m_hit1_z0; // + std::vector<float> m_hit1_theta; // + std::vector<float> m_hit1_phi; // + std::vector<unsigned long> m_nHits; // + + std::vector<unsigned short> m_hitEne_2b; // 1 element per hit + std::vector<unsigned short> m_hitLength_2b; // + + std::vector<unsigned short> m_dTheta; // 1 element per hit except for first hit in string + std::vector<unsigned short> m_dPhi; // + + std::vector<float> m_hitEne_4b; // 1 element per hit with m_hitEne_2b[i] == 2**16 + + std::vector<float> m_hitLength_4b; // 1 element per hit with m_hitLength_2b[i] == 2**16 + + std::vector<unsigned long> m_barcode; + std::vector<unsigned short> m_mcEvtIndex; + std::vector<char> m_evtColl; + std::vector<unsigned long> m_nBC; + + std::vector<unsigned long> m_id; + std::vector<unsigned long> m_nId; +}; + + +// inlines + +inline +NeutrinoHitCollection_p1a::NeutrinoHitCollection_p1a () {} + +#endif diff --git a/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/NeutrinoSimEventTPCnv/NeutrinoSimEventTPCnvDict.h b/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/NeutrinoSimEventTPCnv/NeutrinoSimEventTPCnvDict.h index 064ad71ac526d7f0a0d826df691f65f1ae648f98..15b7afc5bd3fc0d02690b6edbb5f6fab2012f1d5 100644 --- a/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/NeutrinoSimEventTPCnv/NeutrinoSimEventTPCnvDict.h +++ b/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/NeutrinoSimEventTPCnv/NeutrinoSimEventTPCnvDict.h @@ -15,6 +15,9 @@ #include "NeutrinoSimEventTPCnv/NeutrinoHits/NeutrinoHitCnv_p1.h" #include "NeutrinoSimEventTPCnv/NeutrinoHits/NeutrinoHitCollectionCnv_p1.h" #include "NeutrinoSimEventTPCnv/NeutrinoHits/NeutrinoHitCollection_p1.h" +#include "NeutrinoSimEventTPCnv/NeutrinoHits/NeutrinoHitCollectionCnv_p1a.h" +#include "NeutrinoSimEventTPCnv/NeutrinoHits/NeutrinoHitCollection_p1a.h" + #include "NeutrinoSimEventTPCnv/NeutrinoHits/NeutrinoHit_p1.h" #endif // NEUTRINOEVENTTPCNV_NEUTRINOSIMEVENTTPCNVDICT_H diff --git a/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/NeutrinoSimEventTPCnv/selection.xml b/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/NeutrinoSimEventTPCnv/selection.xml index 6808c217a9a651ba26b4147a58409380ea0cc49b..3332a0a0c69d1929fd89b854102086d5b6745af0 100644 --- a/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/NeutrinoSimEventTPCnv/selection.xml +++ b/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/NeutrinoSimEventTPCnv/selection.xml @@ -4,4 +4,5 @@ <class name="NeutrinoHit_p1" /> <class name="std::vector<NeutrinoHit_p1>" /> <class name="NeutrinoHitCollection_p1" id="2CA7AF71-1494-4378-BED4-AFB5C54398AA" /> + <class name="NeutrinoHitCollection_p1a" id="0A3CD37D-64CE-405D-98CF-595D678B14B7" /> </lcgdict> diff --git a/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/src/NeutrinoHits/NeutrinoHitCollectionCnv_p1.cxx b/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/src/NeutrinoHits/NeutrinoHitCollectionCnv_p1.cxx index 3b85676a61cd4235918207a9deb82659ed1bc5bc..444ad41777263c39b68a5e7a3cd613d787f25e32 100644 --- a/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/src/NeutrinoHits/NeutrinoHitCollectionCnv_p1.cxx +++ b/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/src/NeutrinoHits/NeutrinoHitCollectionCnv_p1.cxx @@ -14,7 +14,10 @@ #include "CLHEP/Geometry/Point3D.h" // Gaudi #include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/ThreadLocalContext.h" + // Athena +#include "AthenaKernel/ExtendedEventContext.h" #include "StoreGate/StoreGateSvc.h" // * * * stolen from eflowRec * * * // @@ -60,7 +63,7 @@ const double NeutrinoHitCollectionCnv_p1::m_2bHalfMaximum = pow(2.0, 15.0); const int NeutrinoHitCollectionCnv_p1::m_2bMaximum = (unsigned short)(-1); -void NeutrinoHitCollectionCnv_p1::transToPers(const NeutrinoHitCollection* transCont, NeutrinoHitCollection_p1* persCont, MsgStream &/*log*/) +void NeutrinoHitCollectionCnv_p1::transToPers(const NeutrinoHitCollection* transCont, NeutrinoHitCollection_p1* persCont, MsgStream &log) { // Finds hits belonging to a "string" (in which the end point of one hit is the same as the start point of the next) and // persistifies the end point of each hit plus the start point of the first hit in each string. @@ -77,6 +80,8 @@ void NeutrinoHitCollectionCnv_p1::transToPers(const NeutrinoHitCollection* trans static const double dRcut = 1.0e-7; static const double dTcut = 1.0; + const EventContext& ctx = Gaudi::Hive::currentContext(); + const IProxyDict* proxy = Atlas::getExtendedEventContext(ctx).proxy(); const HepMcParticleLink * lastLink=nullptr; int lastId = -1; double stringFirstTheta = 0.0; @@ -102,7 +107,18 @@ void NeutrinoHitCollectionCnv_p1::transToPers(const NeutrinoHitCollection* trans lastLink = &(siHit->particleLink()); persCont->m_barcode.push_back(lastLink->barcode()); - persCont->m_mcEvtIndex.push_back(lastLink->eventIndex()); + unsigned short index{0}; + const HepMcParticleLink::index_type position = + HepMcParticleLink::getEventPositionInCollection(lastLink->eventIndex(), + lastLink->getEventCollection(), + proxy).at(0); + if (position!=0) { + index = lastLink->eventIndex(); + if(lastLink->eventIndex()!=static_cast<HepMcParticleLink::index_type>(index)) { + log << MSG::WARNING << "Attempting to persistify an eventIndex larger than max unsigned short!" << endmsg; + } + } + persCont->m_mcEvtIndex.push_back(index); persCont->m_evtColl.push_back(lastLink->getEventCollectionAsChar()); if (idx > 0) { @@ -113,7 +129,7 @@ void NeutrinoHitCollectionCnv_p1::transToPers(const NeutrinoHitCollection* trans if ( (int)siHit->identify() != lastId ) { - // store id once for set of consecutive hits with same barcode + // store barcode, eventIndex and McEventCollection once for set of consecutive hits with same barcode lastId = siHit->identify(); persCont->m_id.push_back(lastId); @@ -250,6 +266,8 @@ NeutrinoHitCollection* NeutrinoHitCollectionCnv_p1::createTransient(const Neutri void NeutrinoHitCollectionCnv_p1::persToTrans(const NeutrinoHitCollection_p1* persCont, NeutrinoHitCollection* transCont, MsgStream &/*log*/) { + const EventContext& ctx = Gaudi::Hive::currentContext(); + unsigned int hitCount = 0; unsigned int angleCount = 0; unsigned int idxBC = 0; @@ -299,7 +317,11 @@ void NeutrinoHitCollectionCnv_p1::persToTrans(const NeutrinoHitCollection_p1* pe HepGeom::Point3D<double> endThis( endLast + r ); - HepMcParticleLink partLink( persCont->m_barcode[idxBC], persCont->m_mcEvtIndex[idxBC], HepMcParticleLink::ExtendedBarCode::eventCollectionFromChar(persCont->m_evtColl[idxBC]), HepMcParticleLink::IS_INDEX ); + HepMcParticleLink::PositionFlag flag = HepMcParticleLink::IS_INDEX; + if (persCont->m_mcEvtIndex[idxBC] == 0) { + flag = HepMcParticleLink::IS_POSITION; + } + HepMcParticleLink partLink( persCont->m_barcode[idxBC], persCont->m_mcEvtIndex[idxBC], HepMcParticleLink::ExtendedBarCode::eventCollectionFromChar(persCont->m_evtColl[idxBC]), flag, ctx ); transCont->Emplace( endLast, endThis, eneLoss, meanTime, partLink, persCont->m_id[idxId]); endLast = endThis; diff --git a/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/src/NeutrinoHits/NeutrinoHitCollectionCnv_p1a.cxx b/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/src/NeutrinoHits/NeutrinoHitCollectionCnv_p1a.cxx new file mode 100644 index 0000000000000000000000000000000000000000..6ef0bb107e46e922ad7b667bf2ae239dfe8cd695 --- /dev/null +++ b/Neutrino/NeutrinoEventCnv/NeutrinoSimEventTPCnv/src/NeutrinoHits/NeutrinoHitCollectionCnv_p1a.cxx @@ -0,0 +1,334 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "NeutrinoSimEvent/NeutrinoHit.h" +#include "NeutrinoSimEvent/NeutrinoHitCollection.h" +#include "NeutrinoSimEventTPCnv/NeutrinoHits/NeutrinoHitCollection_p1a.h" +#include "NeutrinoSimEventTPCnv/NeutrinoHits/NeutrinoHitCollectionCnv_p1a.h" +#include "GeneratorObjects/HepMcParticleLink.h" + +#include <cmath> + +//CLHEP +#include "CLHEP/Geometry/Point3D.h" +// Gaudi +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/ThreadLocalContext.h" + +// Athena +#include "AthenaKernel/ExtendedEventContext.h" +#include "StoreGate/StoreGateSvc.h" + +// * * * stolen from eflowRec * * * // +inline double phicorr(double a) +{ + if (a <= -M_PI) + { + return a+(2*M_PI*floor(-(a-M_PI)/(2*M_PI))); + } + else if (a > M_PI) + { + return a-(2*M_PI*floor((a+M_PI)/(2*M_PI))); + } + else + { + return a; + } +} + +// * * * stolen from eflowRec * * * // +inline double cycle(double a, double b) +{ + double del = b-a; + if (del > M_PI) + { + return a+2.0*M_PI; + } + else if (del < -M_PI) + { + return a-2.0*M_PI; + } + else + { + return a; + } +} + + +const double NeutrinoHitCollectionCnv_p1a::m_persEneUnit = 1.0e-5; +const double NeutrinoHitCollectionCnv_p1a::m_persLenUnit = 1.0e-5; +const double NeutrinoHitCollectionCnv_p1a::m_persAngUnit = 1.0e-5; +const double NeutrinoHitCollectionCnv_p1a::m_2bHalfMaximum = pow(2.0, 15.0); +const int NeutrinoHitCollectionCnv_p1a::m_2bMaximum = (unsigned short)(-1); + + +void NeutrinoHitCollectionCnv_p1a::transToPers(const NeutrinoHitCollection* transCont, NeutrinoHitCollection_p1a* persCont, MsgStream &log) +{ + // Finds hits belonging to a "string" (in which the end point of one hit is the same as the start point of the next) and + // persistifies the end point of each hit plus the start point of the first hit in each string. + // + // Further compression is achieved by optimising the storage of the position vectors:- start (x,y,z) and (theta,phi) of + // first hit are stored as floats, (delta_theta,delta_phi) relative to the fisrst hit are stored as 2 byte numbers and + // used to specify the hit direction. All hit lengths are stored as 2 byte numbers. + // + // Additional savings are achieved by storing the energy loss for each hit as a 2 byte number and only storing the mean + // time of the first hit per string. + // + // See http://indico.cern.ch/getFile.py/access?contribId=11&resId=2&materialId=slides&confId=30893 for more info. + + static const double dRcut = 1.0e-7; + static const double dTcut = 1.0; + + const EventContext& ctx = Gaudi::Hive::currentContext(); + const IProxyDict* proxy = Atlas::getExtendedEventContext(ctx).proxy(); + const HepMcParticleLink * lastLink=nullptr; + int lastId = -1; + double stringFirstTheta = 0.0; + double stringFirstPhi = 0.0; + double lastT = 0.0; + double persSumE = 0.0; + double transSumE = 0.0; + unsigned int idx = 0; + unsigned int endBC = 0; + unsigned int endId = 0; + unsigned int endHit = 0; + HepGeom::Point3D<double> lastTransEnd(0.0, 0.0, 0.0); + HepGeom::Point3D<double> lastPersEnd(0.0, 0.0, 0.0); + + for (NeutrinoHitCollection::const_iterator it = transCont->begin(); it != transCont->end(); ++it) { + + NeutrinoHitCollection::const_iterator siHit = it; + + + if ( !lastLink || (siHit->particleLink() != *lastLink) ) { + + // store barcode once for set of consecutive hits with same barcode + + lastLink = &(siHit->particleLink()); + persCont->m_barcode.push_back(lastLink->barcode()); + unsigned short index{0}; + const HepMcParticleLink::index_type position = + HepMcParticleLink::getEventPositionInCollection(lastLink->eventIndex(), + lastLink->getEventCollection(), + proxy).at(0); + if (position!=0) { + index = lastLink->eventIndex(); + if(lastLink->eventIndex()!=static_cast<HepMcParticleLink::index_type>(index)) { + log << MSG::WARNING << "Attempting to persistify an eventIndex larger than max unsigned short!" << endmsg; + } + } + persCont->m_mcEvtIndex.push_back(index); + persCont->m_evtColl.push_back(lastLink->getEventCollectionAsChar()); + + if (idx > 0) { + persCont->m_nBC.push_back(idx - endBC); + endBC = idx; + } + } + + if ( (int)siHit->identify() != lastId ) { + + // store barcode, eventIndex and McEventCollection once for set of consecutive hits with same barcode + + lastId = siHit->identify(); + persCont->m_id.push_back(lastId); + + if (idx > 0) { + persCont->m_nId.push_back(idx - endId); + endId = idx; + } + } + + HepGeom::Point3D<double> st = siHit->localStartPosition(); + HepGeom::Point3D<double> en = siHit->localEndPosition(); + + const double dx = st.x() - lastTransEnd.x(); + const double dy = st.y() - lastTransEnd.y(); + const double dz = st.z() - lastTransEnd.z(); + const double t = siHit->meanTime(); + + const double dRLast = sqrt(dx * dx + dy * dy + dz * dz); // dR between end of previous hit and start of current one + const double dTLast = fabs(t - lastT); + + CLHEP::Hep3Vector direction(0.0, 0.0, 0.0); + double theta = 0.0; + double phi = 0.0; + bool startNewString = false; + + if (dRLast < dRcut && dTLast < dTcut) { + + // hit is part of existing string + + direction = CLHEP::Hep3Vector( en.x() - lastPersEnd.x(), en.y() - lastPersEnd.y(), en.z() - lastPersEnd.z() ); + + theta = direction.theta(); + phi = phicorr( direction.phi() ); + + const int dTheta_2b = (int)( (theta - stringFirstTheta) / m_persAngUnit + m_2bHalfMaximum + 0.5 ); + const int dPhi_2b = (int)( (cycle(phi, stringFirstPhi) - stringFirstPhi) / m_persAngUnit + m_2bHalfMaximum + 0.5 ); + + if ( dTheta_2b < m_2bMaximum && dTheta_2b >= 0 && dPhi_2b < m_2bMaximum && dPhi_2b >= 0) { + persCont->m_dTheta.push_back(dTheta_2b); + persCont->m_dPhi.push_back(dPhi_2b); + theta = stringFirstTheta + ( (double)dTheta_2b - m_2bHalfMaximum ) * m_persAngUnit; + phi = stringFirstPhi + ( (double)dPhi_2b - m_2bHalfMaximum ) * m_persAngUnit; + phi = phicorr(phi); + } + else { + startNewString = true; + } + } + + if (startNewString || dRLast >= dRcut || dTLast >= dTcut) { + + // begin new hit string + + direction = CLHEP::Hep3Vector( en.x() - st.x(), en.y() - st.y(), en.z() - st.z() ); + + theta = direction.theta(); + phi = phicorr( direction.phi() ); + + persCont->m_hit1_meanTime.push_back(t); + persCont->m_hit1_x0.push_back(st.x()); + persCont->m_hit1_y0.push_back(st.y()); + persCont->m_hit1_z0.push_back(st.z()); + persCont->m_hit1_theta.push_back(theta); + persCont->m_hit1_phi.push_back(phi); + + lastPersEnd = HepGeom::Point3D<double>(st.x(), st.y(), st.z()); + + stringFirstTheta = theta; + stringFirstPhi = phi; + + if (idx > 0) { + persCont->m_nHits.push_back(idx - endHit); + endHit = idx; + } + } + + lastTransEnd = HepGeom::Point3D<double>(en.x(), en.y(), en.z()); + transSumE += siHit->energyLoss(); + + const int eneLoss_2b = (int)((transSumE - persSumE) / m_persEneUnit + 0.5); // calculated to allow recovery sum over + // whole hit string to chosen precision + + const int hitLength_2b = (int)(direction.mag() / m_persLenUnit + 0.5); // calculated to give the correct position to + // the chosen precision, NOT the length of the + // hit (small difference in practice). + double eneLoss = 0.0; + + if (eneLoss_2b >= m_2bMaximum) { + eneLoss = siHit->energyLoss(); + persCont->m_hitEne_2b.push_back(m_2bMaximum); + persCont->m_hitEne_4b.push_back(eneLoss); + } + else { + eneLoss = eneLoss_2b * m_persEneUnit; + persCont->m_hitEne_2b.push_back(eneLoss_2b); + } + + double length = 0.0; + + if (hitLength_2b >= m_2bMaximum) { + length = direction.mag(); + persCont->m_hitLength_2b.push_back(m_2bMaximum); + persCont->m_hitLength_4b.push_back(direction.mag()); + } + else { + length = hitLength_2b * m_persLenUnit; + persCont->m_hitLength_2b.push_back(hitLength_2b); + } + + CLHEP::Hep3Vector persDir(length, 0.0, 0.0); + persDir.setTheta(theta); + persDir.setPhi(phi); + + lastPersEnd = (CLHEP::Hep3Vector)lastPersEnd + persDir; + persSumE += eneLoss; + lastT = t; + + ++idx; + } + + persCont->m_nBC.push_back(idx - endBC); + persCont->m_nId.push_back(idx - endId); + persCont->m_nHits.push_back(idx - endHit); +} + + +NeutrinoHitCollection* NeutrinoHitCollectionCnv_p1a::createTransient(const NeutrinoHitCollection_p1a* persObj, MsgStream &log) { + std::unique_ptr<NeutrinoHitCollection> trans(std::make_unique<NeutrinoHitCollection>("DefaultCollectionName",persObj->m_nHits.size())); + persToTrans(persObj, trans.get(), log); + return(trans.release()); +} + + +void NeutrinoHitCollectionCnv_p1a::persToTrans(const NeutrinoHitCollection_p1a* persCont, NeutrinoHitCollection* transCont, MsgStream &/*log*/) +{ + const EventContext& ctx = Gaudi::Hive::currentContext(); + + unsigned int hitCount = 0; + unsigned int angleCount = 0; + unsigned int idxBC = 0; + unsigned int idxId = 0; + unsigned int idxEne4b = 0; + unsigned int idxLen4b = 0; + unsigned int endHit = 0; + unsigned int endBC = 0; + unsigned int endId = 0; + + for (unsigned int i = 0; i < persCont->m_nHits.size(); i++) { + + if (persCont->m_nHits[i]) { + + const unsigned int start = endHit; + endHit += persCont->m_nHits[i]; + + const double t0 = persCont->m_hit1_meanTime[i]; + const double theta0 = persCont->m_hit1_theta[i]; + const double phi0 = persCont->m_hit1_phi[i]; + HepGeom::Point3D<double> endLast(persCont->m_hit1_x0[i], persCont->m_hit1_y0[i], persCont->m_hit1_z0[i]); + + for (unsigned int j = start; j < endHit; j++) { + + if (j >= endBC + persCont->m_nBC[idxBC]) + endBC += persCont->m_nBC[idxBC++]; + + if (j >= endId + persCont->m_nId[idxId]) + endId += persCont->m_nId[idxId++]; + + const double eneLoss_2b = persCont->m_hitEne_2b[hitCount]; + const double hitLength_2b = persCont->m_hitLength_2b[hitCount]; + + const double eneLoss = (eneLoss_2b < m_2bMaximum) ? eneLoss_2b * m_persEneUnit : persCont->m_hitEne_4b[idxEne4b++]; + const double length = (hitLength_2b < m_2bMaximum) ? hitLength_2b * m_persLenUnit : persCont->m_hitLength_4b[idxLen4b++]; + + const double dTheta = (j > start) ? ((double)persCont->m_dTheta[angleCount] - m_2bHalfMaximum) * m_persAngUnit : 0.0; + const double dPhi = (j > start) ? ((double)persCont->m_dPhi[angleCount] - m_2bHalfMaximum) * m_persAngUnit : 0.0; + + const double meanTime = t0; + const double theta = theta0 + dTheta; + const double phi = phicorr(phi0 + dPhi); + + CLHEP::Hep3Vector r(length, 0.0, 0.0); + r.setTheta(theta); + r.setPhi(phi); + + HepGeom::Point3D<double> endThis( endLast + r ); + + HepMcParticleLink::PositionFlag flag = HepMcParticleLink::IS_INDEX; + if (persCont->m_mcEvtIndex[idxBC] == 0) { + flag = HepMcParticleLink::IS_POSITION; + } + HepMcParticleLink partLink( persCont->m_barcode[idxBC], persCont->m_mcEvtIndex[idxBC], HepMcParticleLink::ExtendedBarCode::eventCollectionFromChar(persCont->m_evtColl[idxBC]), flag, ctx ); + transCont->Emplace( endLast, endThis, eneLoss, meanTime, partLink, persCont->m_id[idxId]); + + endLast = endThis; + + ++hitCount; + if (j > start) ++angleCount; + } + } + } +} diff --git a/Neutrino/NeutrinoG4/EmulsionG4_SD/python/EmulsionG4_SDToolConfig.py b/Neutrino/NeutrinoG4/EmulsionG4_SD/python/EmulsionG4_SDToolConfig.py index 391e572abaef8cc7df72ec56a692c694aab32d74..e61195b70b006059df083bb30ff93b0bd4769daf 100644 --- a/Neutrino/NeutrinoG4/EmulsionG4_SD/python/EmulsionG4_SDToolConfig.py +++ b/Neutrino/NeutrinoG4/EmulsionG4_SD/python/EmulsionG4_SDToolConfig.py @@ -17,5 +17,7 @@ def EmulsionSensorSDCfg(ConfigFlags, name="EmulsionSensorSD", **kwargs): kwargs.setdefault("LogicalVolumeNames", ["Emulsion::FrontFilm", "Emulsion::BackFilm"]) kwargs.setdefault("OutputCollectionNames", [bare_collection_name]) - # result.merge(acc) - return result, EmulsionSensorSDTool(name, **kwargs) + result = ComponentAccumulator() + result.setPrivateTools(CompFactory.EmulsionSensorSDTool(name, **kwargs)) + return result + diff --git a/README.md b/README.md index 310f3646591eae6b890efc2f8f461a11aa0e5c7e..0b334b19690dd56d1a0bae23fd5c0849c1cd83dd 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ git clone --recursive https://:@gitlab.cern.ch:8443/$USERNAME/calypso.git #The next three lines are used to setup the ATLAS release environment export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh -asetup --input=calypso/asetup.faser Athena,22.0.40 +asetup --input=calypso/asetup.faser Athena,22.0.49 #create build directory mkdir build @@ -31,6 +31,15 @@ Don't omit the dot in the `source ./setup.sh` command! It can be convenient to alias the "asetup --input=calypso/asetup.faser" to something like "fsetup" +**Lxplus/afs setup** + +If afs is used to host and run calypso, the user should do so with an afs workspace. + +Instructions for setting up a workspace can be found here: https://resources.web.cern.ch/resources/Help/?kbid=067040 + +When compiling, CERN IT recommends using condor to submit batch jobs. The basics of running condor are found here: https://batchdocs.web.cern.ch/local/quick.html + + ## Known issues: * It is now essential to use the tags `ConfigFlags.GeoModel.FaserVersion` and `ConfigFlags.IOVDb.GlobalTag` in a consistent way. If nothing is specified the first option (baseline) should be chosen by default. @@ -41,8 +50,6 @@ It can be convenient to alias the "asetup --input=calypso/asetup.faser" to somet ** `ConfigFlags.GeoModel.FaserVersion = "FASERNU-02"` and `ConfigFlags.IOVDb.GlobalTag = OFLCOND-FASER-02` enables the full FaserNu (IFT + emulsion) setup -** `ConfigFlags.GeoModel.FaserVersion = "FASER-TB00"` and `ConfigFlags.IOVDb.GlobalTag = OFLCOND-FASER-02` enables the 2021 Test-beam setup. - -* The "FaserActsKalmanFilter" package is temporarily disabled. +** `ConfigFlags.GeoModel.FaserVersion = "FASER-TB00"` and `ConfigFlags.IOVDb.GlobalTag = OFLCOND-FASER-TB00` enables the 2021 Test-beam setup. * The command `lsetup "lcgenv -p LCG_98python3_ATLAS_8 x86_64-centos7-gcc8-opt sqlite"` may be necessary to avoid errors when generating a database diff --git a/Scintillator/ScintEventCnv/ScintSimEventTPCnv/CMakeLists.txt b/Scintillator/ScintEventCnv/ScintSimEventTPCnv/CMakeLists.txt index 89c0c08d0204d449808531439e227498cc824a1a..04ca202da817c0f95b4942bfc62b4c5159a47679 100644 --- a/Scintillator/ScintEventCnv/ScintSimEventTPCnv/CMakeLists.txt +++ b/Scintillator/ScintEventCnv/ScintSimEventTPCnv/CMakeLists.txt @@ -22,5 +22,5 @@ atlas_add_dictionary( ScintSimEventTPCnvDict ScintSimEventTPCnv/ScintSimEventTPCnvDict.h ScintSimEventTPCnv/selection.xml INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaPoolCnvSvcLib GaudiKernel GeneratorObjectsTPCnv ScintSimEvent TestTools StoreGateLib SGtests Identifier ScintSimEventTPCnv ) + LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaPoolCnvSvcLib GaudiKernel GeneratorObjectsTPCnv ScintSimEvent TestTools StoreGateLib SGtests Identifier ScintSimEventTPCnv AthenaKernel ) diff --git a/Scintillator/ScintEventCnv/ScintSimEventTPCnv/src/ScintHits/ScintHitCollectionCnv_p1.cxx b/Scintillator/ScintEventCnv/ScintSimEventTPCnv/src/ScintHits/ScintHitCollectionCnv_p1.cxx index 08e4c55e910be26cd47735c49a11bcebad82f446..42b4160a2176e95919d5930140c5abcd7c0e8dfb 100644 --- a/Scintillator/ScintEventCnv/ScintSimEventTPCnv/src/ScintHits/ScintHitCollectionCnv_p1.cxx +++ b/Scintillator/ScintEventCnv/ScintSimEventTPCnv/src/ScintHits/ScintHitCollectionCnv_p1.cxx @@ -14,7 +14,10 @@ #include "CLHEP/Geometry/Point3D.h" // Gaudi #include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/ThreadLocalContext.h" + // Athena +#include "AthenaKernel/ExtendedEventContext.h" #include "StoreGate/StoreGateSvc.h" // * * * stolen from eflowRec * * * // @@ -60,7 +63,7 @@ const double ScintHitCollectionCnv_p1::m_2bHalfMaximum = pow(2.0, 15.0); const int ScintHitCollectionCnv_p1::m_2bMaximum = (unsigned short)(-1); -void ScintHitCollectionCnv_p1::transToPers(const ScintHitCollection* transCont, ScintHitCollection_p1* persCont, MsgStream &/*log*/) +void ScintHitCollectionCnv_p1::transToPers(const ScintHitCollection* transCont, ScintHitCollection_p1* persCont, MsgStream &log) { // Finds hits belonging to a "string" (in which the end point of one hit is the same as the start point of the next) and // persistifies the end point of each hit plus the start point of the first hit in each string. @@ -77,6 +80,8 @@ void ScintHitCollectionCnv_p1::transToPers(const ScintHitCollection* transCont, static const double dRcut = 1.0e-7; static const double dTcut = 1.0; + const EventContext& ctx = Gaudi::Hive::currentContext(); + const IProxyDict* proxy = Atlas::getExtendedEventContext(ctx).proxy(); const HepMcParticleLink * lastLink=nullptr; int lastId = -1; double stringFirstTheta = 0.0; @@ -98,11 +103,22 @@ void ScintHitCollectionCnv_p1::transToPers(const ScintHitCollection* transCont, if ( !lastLink || (siHit->particleLink() != *lastLink) ) { - // store barcode once for set of consecutive hits with same barcode + // store barcode, eventIndex and McEventCollection once for set of consecutive hits with same barcode lastLink = &(siHit->particleLink()); persCont->m_barcode.push_back(lastLink->barcode()); - persCont->m_mcEvtIndex.push_back(lastLink->eventIndex()); + unsigned short index{0}; + const HepMcParticleLink::index_type position = + HepMcParticleLink::getEventPositionInCollection(lastLink->eventIndex(), + lastLink->getEventCollection(), + proxy).at(0); + if (position!=0) { + index = lastLink->eventIndex(); + if(lastLink->eventIndex()!=static_cast<HepMcParticleLink::index_type>(index)) { + log << MSG::WARNING << "Attempting to persistify an eventIndex larger than max unsigned short!" << endmsg; + } + } + persCont->m_mcEvtIndex.push_back(index); persCont->m_evtColl.push_back(lastLink->getEventCollectionAsChar()); if (idx > 0) { @@ -250,6 +266,8 @@ ScintHitCollection* ScintHitCollectionCnv_p1::createTransient(const ScintHitColl void ScintHitCollectionCnv_p1::persToTrans(const ScintHitCollection_p1* persCont, ScintHitCollection* transCont, MsgStream &/*log*/) { + const EventContext& ctx = Gaudi::Hive::currentContext(); + unsigned int hitCount = 0; unsigned int angleCount = 0; unsigned int idxBC = 0; @@ -299,7 +317,11 @@ void ScintHitCollectionCnv_p1::persToTrans(const ScintHitCollection_p1* persCont HepGeom::Point3D<double> endThis( endLast + r ); - HepMcParticleLink partLink( persCont->m_barcode[idxBC], persCont->m_mcEvtIndex[idxBC], HepMcParticleLink::ExtendedBarCode::eventCollectionFromChar(persCont->m_evtColl[idxBC]), HepMcParticleLink::IS_INDEX ); + HepMcParticleLink::PositionFlag flag = HepMcParticleLink::IS_INDEX; + if (persCont->m_mcEvtIndex[idxBC] == 0) { + flag = HepMcParticleLink::IS_POSITION; + } + HepMcParticleLink partLink( persCont->m_barcode[idxBC], persCont->m_mcEvtIndex[idxBC], HepMcParticleLink::ExtendedBarCode::eventCollectionFromChar(persCont->m_evtColl[idxBC]), flag, ctx ); transCont->Emplace( endLast, endThis, eneLoss, meanTime, partLink, persCont->m_id[idxId]); endLast = endThis; diff --git a/Scintillator/ScintG4/PreshowerG4_SD/python/PreshowerG4_SDToolConfig.py b/Scintillator/ScintG4/PreshowerG4_SD/python/PreshowerG4_SDToolConfig.py index 96b90c45b32b2b96a801ee724f348004b59cc5a5..8dc2325ffc0a104762b605912b7232cad3f88b40 100644 --- a/Scintillator/ScintG4/PreshowerG4_SD/python/PreshowerG4_SDToolConfig.py +++ b/Scintillator/ScintG4/PreshowerG4_SD/python/PreshowerG4_SDToolConfig.py @@ -18,5 +18,7 @@ def PreshowerSensorSDCfg(ConfigFlags, name="PreshowerSensorSD", **kwargs): kwargs.setdefault("LogicalVolumeNames", ["Preshower::Plate"]) kwargs.setdefault("OutputCollectionNames", [bare_collection_name]) - # result.merge(acc) - return result, PreshowerSensorSDTool(name, **kwargs) + result = ComponentAccumulator() + result.setPrivateTools(CompFactory.PreshowerSensorSDTool(name, **kwargs)) + return result + diff --git a/Scintillator/ScintG4/TriggerG4_SD/python/TriggerG4_SDToolConfig.py b/Scintillator/ScintG4/TriggerG4_SD/python/TriggerG4_SDToolConfig.py index dae6ba9784424a43377d5fa2d9d321d0befbdd38..2d049e14e2d104ad36b9dfffcd6b5a0a23aa1ff4 100644 --- a/Scintillator/ScintG4/TriggerG4_SD/python/TriggerG4_SDToolConfig.py +++ b/Scintillator/ScintG4/TriggerG4_SD/python/TriggerG4_SDToolConfig.py @@ -18,5 +18,7 @@ def TriggerSensorSDCfg(ConfigFlags, name="TriggerSensorSD", **kwargs): kwargs.setdefault("LogicalVolumeNames", ["Trigger::Plate"]) kwargs.setdefault("OutputCollectionNames", [bare_collection_name]) - # result.merge(acc) - return result, TriggerSensorSDTool(name, **kwargs) + result = ComponentAccumulator() + result.setPrivateTools(CompFactory.TriggerSensorSDTool(name, **kwargs)) + return result + diff --git a/Scintillator/ScintG4/VetoG4_SD/python/VetoG4_SDToolConfig.py b/Scintillator/ScintG4/VetoG4_SD/python/VetoG4_SDToolConfig.py index ccc50ce9930063c2354d4d6f5d17688295ef9802..95000f8608cacc3b16dd0adf294370cdd80f1207 100644 --- a/Scintillator/ScintG4/VetoG4_SD/python/VetoG4_SDToolConfig.py +++ b/Scintillator/ScintG4/VetoG4_SD/python/VetoG4_SDToolConfig.py @@ -18,5 +18,7 @@ def VetoSensorSDCfg(ConfigFlags, name="VetoSensorSD", **kwargs): kwargs.setdefault("LogicalVolumeNames", ["Veto::Plate"]) kwargs.setdefault("OutputCollectionNames", [bare_collection_name]) - # result.merge(acc) - return result, VetoSensorSDTool(name, **kwargs) + result = ComponentAccumulator() + result.setPrivateTools(CompFactory.VetoSensorSDTool(name, **kwargs)) + return result + diff --git a/Simulation/G4Faser/G4FaserAlg/CMakeLists.txt b/Simulation/G4Faser/G4FaserAlg/CMakeLists.txt index 76828930fd30794c8677e23fed1699158a80b091..dbd7917dbf989e1db8456a1ec6e929b7886d715d 100644 --- a/Simulation/G4Faser/G4FaserAlg/CMakeLists.txt +++ b/Simulation/G4Faser/G4FaserAlg/CMakeLists.txt @@ -37,7 +37,7 @@ atlas_add_test( G4FaserAlgConfig_TestFaserNu PROPERTIES WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) atlas_add_test( G4FaserAlgConfig_TestTestbeam - SCRIPT python ${CMAKE_CURRENT_SOURCE_DIR}/test/G4FaserAlgConfigNew_Test.py GeoModel.FaserVersion="'FASER-TB00'" IOVDb.GlobalTag="'OFLCOND-FASER-02'" Output.HITSFileName='tb.HITS.pool.root' + SCRIPT python ${CMAKE_CURRENT_SOURCE_DIR}/test/G4FaserAlgConfigNew_Test.py GeoModel.FaserVersion="'FASER-TB00'" IOVDb.GlobalTag="'OFLCOND-FASER-TB00'" Output.HITSFileName='tb.HITS.pool.root' PROPERTIES TIMEOUT 300 PROPERTIES WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) diff --git a/Simulation/G4Faser/G4FaserAlg/src/G4FaserAlg.cxx b/Simulation/G4Faser/G4FaserAlg/src/G4FaserAlg.cxx index 3ce528b032fd0ce76494e114623aa753dbc0345c..69ff7cfd61bceff6cebf6a01043012c78c0a379b 100644 --- a/Simulation/G4Faser/G4FaserAlg/src/G4FaserAlg.cxx +++ b/Simulation/G4Faser/G4FaserAlg/src/G4FaserAlg.cxx @@ -30,6 +30,9 @@ #include "G4VModularPhysicsList.hh" #include "G4ParallelWorldPhysics.hh" +#include "G4LogicalVolumeStore.hh" +#include "G4GDMLParser.hh" + // CLHEP includes #include "CLHEP/Random/RandomEngine.h" @@ -197,6 +200,14 @@ void G4FaserAlg::initializeOnce() if(m_userLimitsSvc.retrieve().isFailure()) { throw std::runtime_error("Could not initialize ATLAS UserLimitsSvc!"); } + + if (!m_gdmlFilename.empty()) + { + G4LogicalVolumeStore* store = G4LogicalVolumeStore::GetInstance(); + G4LogicalVolume* world = store->GetVolume("Faser::Faser"); + G4GDMLParser parser {}; + parser.Write(m_gdmlFilename.value(), world); + } if (m_activateParallelGeometries) { G4VModularPhysicsList* thePhysicsList=dynamic_cast<G4VModularPhysicsList*>(m_physListSvc->GetPhysicsList()); diff --git a/Simulation/G4Faser/G4FaserAlg/src/G4FaserAlg.h b/Simulation/G4Faser/G4FaserAlg/src/G4FaserAlg.h index 420e23f7154244d03d1645aeeddcdf95e7c08ba4..1dbadf47ac6ed83bd5012ead048d077d951e624f 100644 --- a/Simulation/G4Faser/G4FaserAlg/src/G4FaserAlg.h +++ b/Simulation/G4Faser/G4FaserAlg/src/G4FaserAlg.h @@ -120,6 +120,8 @@ private: /// Activate multi-threading configuration Gaudi::Property<bool> m_useMT{this,"MultiThreading", false, "Multi-threading specific settings"}; Gaudi::Property<bool> m_activateParallelGeometries{this, "ActivateParallelWorlds", false, "Toggle on/off the G4 parallel geometry system"}; + /// Dump GDML file + Gaudi::Property<std::string> m_gdmlFilename{this, "GDMLfile", "", "GDML geometry file to write"}; /// Random number service ServiceHandle<IAthRNGSvc> m_rndmGenSvc{this, "AtRndmGenSvc", "AthRNGSvc", ""}; // TODO rename property /// Random Stream Name diff --git a/Simulation/G4Faser/G4FaserTools/python/G4FaserToolsConfigNew.py b/Simulation/G4Faser/G4FaserTools/python/G4FaserToolsConfigNew.py index 3520b26d0df3e3bc948c8b69cedf4de6cc5aecb6..f4bb4333d7b62b77b377663d9181e30e64b9f2f8 100644 --- a/Simulation/G4Faser/G4FaserTools/python/G4FaserToolsConfigNew.py +++ b/Simulation/G4Faser/G4FaserTools/python/G4FaserToolsConfigNew.py @@ -2,7 +2,6 @@ from __future__ import print_function from AthenaConfiguration.ComponentFactory import CompFactory - from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from AthenaCommon import CfgMgr SensitiveDetectorMasterTool=CompFactory.SensitiveDetectorMasterTool @@ -21,103 +20,78 @@ def FastSimulationMasterToolCfg(ConfigFlags, **kwargs): result.setPrivateTools(FastSimulationMasterTool(name="FastSimulationMasterTool", **kwargs)) return result -from EmulsionG4_SD.EmulsionG4_SDToolConfig import EmulsionSensorSDCfg -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 -from EcalG4_SD.EcalG4_SDToolConfig import EcalSensorSDCfg +def NeutrinoSensitiveDetectorListCfg(ConfigFlags): + result = ComponentAccumulator() + tools = [] + + if ConfigFlags.Detector.EnableEmulsion: + from EmulsionG4_SD.EmulsionG4_SDToolConfig import EmulsionSensorSDCfg + tools += [ result.popToolsAndMerge(EmulsionSensorSDCfg(ConfigFlags)) ] + + result.setPrivateTools(tools) + return result -def generateNeutrinoSensitiveDetectorList(ConfigFlags): +def CaloSensitiveDetectorListCfg(ConfigFlags): result = ComponentAccumulator() - SensitiveDetectorList=[] + tools = [] - if ConfigFlags.Detector.EnableEmulsion: - accEmulsion,toolEmulsion = EmulsionSensorSDCfg(ConfigFlags) - SensitiveDetectorList += [ toolEmulsion ] - result.merge(accEmulsion) - - return result, SensitiveDetectorList #List of tools here now! (CALL IT TOOL LIST?) + if ConfigFlags.Detector.EnableEcal: + from EcalG4_SD.EcalG4_SDToolConfig import EcalSensorSDCfg + tools += [ result.popToolsAndMerge(EcalSensorSDCfg(ConfigFlags)) ] -def generateScintSensitiveDetectorList(ConfigFlags): + result.setPrivateTools(tools) + return result +def ScintSensitiveDetectorListCfg(ConfigFlags): result = ComponentAccumulator() - SensitiveDetectorList=[] + tools = [] if ConfigFlags.Detector.EnableVeto: - accVeto,toolVeto = VetoSensorSDCfg(ConfigFlags) - SensitiveDetectorList += [ toolVeto ] - result.merge(accVeto) - + from VetoG4_SD.VetoG4_SDToolConfig import VetoSensorSDCfg + tools += [ result.popToolsAndMerge(VetoSensorSDCfg(ConfigFlags)) ] if ConfigFlags.Detector.EnableTrigger: - accTrigger,toolTrigger = TriggerSensorSDCfg(ConfigFlags) - SensitiveDetectorList += [ toolTrigger ] - result.merge(accTrigger) - + from TriggerG4_SD.TriggerG4_SDToolConfig import TriggerSensorSDCfg + tools += [ result.popToolsAndMerge(TriggerSensorSDCfg(ConfigFlags)) ] if ConfigFlags.Detector.EnablePreshower: - accPreshower,toolPreshower = PreshowerSensorSDCfg(ConfigFlags) - SensitiveDetectorList += [ toolPreshower ] - result.merge(accPreshower) - - return result, SensitiveDetectorList #List of tools here now! (CALL IT TOOL LIST?) + from PreshowerG4_SD.PreshowerG4_SDToolConfig import PreshowerSensorSDCfg + tools += [ result.popToolsAndMerge(PreshowerSensorSDCfg(ConfigFlags)) ] -def generateTrackerSensitiveDetectorList(ConfigFlags): + result.setPrivateTools(tools) + return result +def TrackerSensitiveDetectorListCfg(ConfigFlags): result = ComponentAccumulator() - SensitiveDetectorList=[] + tools = [] if ConfigFlags.Detector.EnableFaserSCT: - accSCT,toolSCT = SctSensorSDCfg(ConfigFlags) - SensitiveDetectorList += [ toolSCT ] - result.merge(accSCT) - - return result, SensitiveDetectorList #List of tools here now! (CALL IT TOOL LIST?) - -def generateCaloSensitiveDetectorList(ConfigFlags): + from FaserSCT_G4_SD.FaserSCT_G4_SDToolConfig import SctSensorSDCfg + tools += [ result.popToolsAndMerge(SctSensorSDCfg(ConfigFlags)) ] - result = ComponentAccumulator() - SensitiveDetectorList=[] - - if ConfigFlags.Detector.EnableEcal: - accEcal,toolEcal = EcalSensorSDCfg(ConfigFlags) - SensitiveDetectorList += [ toolEcal ] - result.merge(accEcal) - - return result, SensitiveDetectorList #List of tools here now! (CALL IT TOOL LIST?) + result.setPrivateTools(tools) + return result -def generateSensitiveDetectorList(ConfigFlags): +def SensitiveDetectorListCfg(ConfigFlags): result = ComponentAccumulator() - SensitiveDetectorList=[] - # SensitiveDetectorList += generateEnvelopeSensitiveDetectorList(ConfigFlags) # to update - - acc_NeutrinoSensitiveDetector, NeutrinoSensitiveDetectorList = generateNeutrinoSensitiveDetectorList(ConfigFlags) - SensitiveDetectorList += NeutrinoSensitiveDetectorList + tools = [] - acc_ScintSensitiveDetector, ScintSensitiveDetectorList = generateScintSensitiveDetectorList(ConfigFlags) - SensitiveDetectorList += ScintSensitiveDetectorList + tools += result.popToolsAndMerge(CaloSensitiveDetectorListCfg(ConfigFlags)) + tools += result.popToolsAndMerge(ScintSensitiveDetectorListCfg(ConfigFlags)) + tools += result.popToolsAndMerge(TrackerSensitiveDetectorListCfg(ConfigFlags)) + tools += result.popToolsAndMerge(NeutrinoSensitiveDetectorListCfg(ConfigFlags)) - acc_TrackerSensitiveDetector, TrackerSensitiveDetectorList = generateTrackerSensitiveDetectorList(ConfigFlags) - SensitiveDetectorList += TrackerSensitiveDetectorList - - acc_CaloSensitiveDetector, CaloSensitiveDetectorList = generateCaloSensitiveDetectorList(ConfigFlags) - SensitiveDetectorList += CaloSensitiveDetectorList - - result.merge(acc_NeutrinoSensitiveDetector) - result.merge(acc_ScintSensitiveDetector) - result.merge(acc_TrackerSensitiveDetector) - result.merge(acc_CaloSensitiveDetector) - - result.setPrivateTools(SensitiveDetectorList) + result.setPrivateTools(tools) return result def SensitiveDetectorMasterToolCfg(ConfigFlags, name="SensitiveDetectorMasterTool", **kwargs): result = ComponentAccumulator() - accSensitiveDetector = generateSensitiveDetectorList(ConfigFlags) - kwargs.setdefault("SensitiveDetectors", result.popToolsAndMerge(accSensitiveDetector)) #list of tools + kwargs.setdefault("SensitiveDetectors", result.popToolsAndMerge(SensitiveDetectorListCfg(ConfigFlags))) - result.setPrivateTools(SensitiveDetectorMasterTool(name, **kwargs)) #note -this is still a public tool + result.setPrivateTools(CompFactory.SensitiveDetectorMasterTool(name, **kwargs)) return result def getEmptySensitiveDetectorMasterTool(name="EmptySensitiveDetectorMasterTool", **kwargs): - return CfgMgr.SensitiveDetectorMasterTool(name, **kwargs) + result = ComponentAccumulator() + tool = result.popToolsAndMerge(CompFactory.SensitiveDetectorMasterTool(name, **kwargs)) + result.setPrivateTools(tool) + return result diff --git a/Simulation/G4Faser/G4FaserTools/python/G4GeometryToolConfig.py b/Simulation/G4Faser/G4FaserTools/python/G4GeometryToolConfig.py index 992cfbe4fe506841adbbaa052540dc50168f1155..064cde911986868ace4708e37374a17e20a6de16 100644 --- a/Simulation/G4Faser/G4FaserTools/python/G4GeometryToolConfig.py +++ b/Simulation/G4Faser/G4FaserTools/python/G4GeometryToolConfig.py @@ -1,4 +1,5 @@ # Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +from __future__ import print_function from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from AthenaConfiguration.ComponentFactory import CompFactory @@ -11,6 +12,8 @@ from G4FaserTools.G4PhysicsRegionConfigNew import NeutrinoPhysicsRegionToolCfg, #the field config tools from G4FaserTools.G4FieldConfigNew import FASERFieldManagerToolCfg, EmulsionFieldManagerToolCfg, VetoFieldManagerToolCfg, TriggerFieldManagerToolCfg, PreshowerFieldManagerToolCfg, TrackerFieldManagerToolCfg, DipoleFieldManagerToolCfg, EcalFieldManagerToolCfg +from G4FaserTools.G4FaserToolsConfigNew import SensitiveDetectorMasterToolCfg + GeoDetectorTool=CompFactory.GeoDetectorTool from EmulsionGeoModel.EmulsionGeoModelConfig import EmulsionGeometryCfg from VetoGeoModel.VetoGeoModelConfig import VetoGeometryCfg @@ -20,7 +23,7 @@ from FaserSCT_GeoModel.FaserSCT_GeoModelConfig import FaserSCT_GeometryCfg from DipoleGeoModel.DipoleGeoModelConfig import DipoleGeometryCfg from EcalGeoModel.EcalGeoModelConfig import EcalGeometryCfg -BoxEnvelope, MaterialDescriptionTool, SmartlessnessTool, G4AtlasDetectorConstructionTool = CompFactory.getComps("BoxEnvelope", "MaterialDescriptionTool", "SmartlessnessTool", "G4AtlasDetectorConstructionTool",) +BoxEnvelope, MaterialDescriptionTool, VoxelDensityTool, G4AtlasDetectorConstructionTool = CompFactory.getComps("BoxEnvelope", "MaterialDescriptionTool", "VoxelDensityTool", "G4AtlasDetectorConstructionTool",) from AthenaCommon.SystemOfUnits import mm @@ -163,10 +166,20 @@ def MaterialDescriptionToolCfg(ConfigFlags, name="MaterialDescriptionTool", **kw return result -def SmartlessnessToolCfg(ConfigFlags, name="SmartlessnessTool", **kwargs): +def VoxelDensityToolCfg(ConfigFlags, name="VoxelDensityTool", **kwargs): ## kwargs.setdefault("SomeProperty", aValue) + voxelDensitySettings = {} + # if ConfigFlags.Detector.GeometryITkPixel: + # voxelDensitySettings["ITkPixelDetector"] = 0.05 + # if ConfigFlags.Detector.GeometryITkStrip: + # voxelDensitySettings["ITkStrip::Barrel"] = 0.05 + # voxelDensitySettings["ITkStrip::ITkStrip_Forward"] = 0.05 + # ##The below is only needed temporarily, while we wait for + # ##improved naming to be propagated to all necessary geo tags + # voxelDensitySettings["ITkStrip::SCT_Forward"] = 0.05 + kwargs.setdefault("VolumeVoxellDensityLevel",voxelDensitySettings) result = ComponentAccumulator() - result.setPrivateTools(SmartlessnessTool(name, **kwargs)) + result.setPrivateTools(VoxelDensityTool(name, **kwargs)) return result def getFASER_RegionCreatorList(ConfigFlags): @@ -238,7 +251,7 @@ def getGeometryConfigurationTools(ConfigFlags): # package containing each tool, so G4FaserTools in this case result =ComponentAccumulator() geoConfigToolList += [result.popToolsAndMerge(MaterialDescriptionToolCfg(ConfigFlags))] - geoConfigToolList += [result.popToolsAndMerge(SmartlessnessToolCfg(ConfigFlags))] + geoConfigToolList += [result.popToolsAndMerge(VoxelDensityToolCfg(ConfigFlags))] return result, geoConfigToolList @@ -251,7 +264,9 @@ def G4AtlasDetectorConstructionToolCfg(ConfigFlags, name="G4FaserDetectorConstru kwargs.setdefault("GeometryConfigurationTools", listOfGeoConfTools) # Getting this tool by name works, but not if you use getSensitiveDetectorMasterTool() - kwargs.setdefault('SenDetMasterTool', "SensitiveDetectorMasterTool" ) + tool = result.popToolsAndMerge(SensitiveDetectorMasterToolCfg(ConfigFlags)) + result.addPublicTool(tool) + kwargs.setdefault("SenDetMasterTool", result.getPublicTool(tool.name)) toolGeo = result.popToolsAndMerge(FASEREnvelopeCfg(ConfigFlags)) kwargs.setdefault("World", toolGeo) diff --git a/Simulation/ISF/ISF_Core/FaserISF_Services/src/FaserTruthSvc.cxx b/Simulation/ISF/ISF_Core/FaserISF_Services/src/FaserTruthSvc.cxx index c3e0607252a06e4d439cf298851b6d2884cef3b9..b1a64408271187de69318c448fb727056c66f704 100644 --- a/Simulation/ISF/ISF_Core/FaserISF_Services/src/FaserTruthSvc.cxx +++ b/Simulation/ISF/ISF_Core/FaserISF_Services/src/FaserTruthSvc.cxx @@ -270,7 +270,7 @@ void ISF::FaserTruthSvc::recordIncidentToMCTruth( ISF::IFaserTruthIncident& ti) if (m_ignoreUndefinedBarcodes) { ATH_MSG_WARNING("Unable to generate new Particle Barcode. Continuing due to 'IgnoreUndefinedBarcodes'==True"); } else { - ATH_MSG_FATAL("Unable to generate new Particle Barcode in region " << ti.geoID() << ". Aborting"); + ATH_MSG_FATAL("Unable to generate new Particle Barcode in region " << ti.geoID() << ", at vertex (" << vtx->position().x() << ", " << vtx->position().y() << ", " << vtx->position().z() << "). Aborting"); abort(); } } diff --git a/Simulation/ISF/ISF_HepMC/FaserISF_HepMC_Tools/python/FaserISF_HepMC_ToolsConfigNew.py b/Simulation/ISF/ISF_HepMC/FaserISF_HepMC_Tools/python/FaserISF_HepMC_ToolsConfigNew.py index a49c04991034dd011d9066b5b9116d317a1cd042..0f251682c98dfba7a08fd7e9a7427fb6a330e91b 100644 --- a/Simulation/ISF/ISF_HepMC/FaserISF_HepMC_Tools/python/FaserISF_HepMC_ToolsConfigNew.py +++ b/Simulation/ISF/ISF_HepMC/FaserISF_HepMC_Tools/python/FaserISF_HepMC_ToolsConfigNew.py @@ -163,7 +163,8 @@ def FaserDipoleTruthStrategyCfg(ConfigFlags, name="ISF_FaserDipoleTruthStrategy" # Save truth in Dipole region # kwargs.setdefault('Regions', [FaserRegion.fFaserDipole, - FaserRegion.fFaserNeutrino]) + FaserRegion.fFaserNeutrino, + FaserRegion.fFaserCavern]) kwargs.setdefault('ParentMinEkin', 1000.0*MeV) kwargs.setdefault('ChildMinEkin', 1000.0*MeV) result.setPrivateTools(ISF__FaserTruthStrategy(name, **kwargs)) @@ -182,10 +183,10 @@ def FaserTruthStrategyCfg(ConfigFlags, name="ISF_FaserTruthStrategy", **kwargs): kwargs.setdefault('Regions', [ # FaserRegion.fFaserNeutrino, FaserRegion.fFaserScintillator, - FaserRegion.fFaserTracker, + FaserRegion.fFaserTracker]) # FaserRegion.fFaserDipole, # FaserRegion.fFaserCalorimeter, - FaserRegion.fFaserCavern]) + # FaserRegion.fFaserCavern]) # kwargs.setdefault('ParentMinEkin', 0.1*MeV) # kwargs.setdefault('ChildMinEkin', 0.1*MeV) result.setPrivateTools(ISF__FaserTruthStrategy(name, **kwargs)) diff --git a/Tracker/TrackerAlignTools/TrackerAlignGenTools/src/TrackerAlignDBTool.cxx b/Tracker/TrackerAlignTools/TrackerAlignGenTools/src/TrackerAlignDBTool.cxx index a92e78dc3d2c3aa62464256aaeab5c38caa0072a..77714ac0974d54b0f6292a74a174cc86a6c7cf29 100644 --- a/Tracker/TrackerAlignTools/TrackerAlignGenTools/src/TrackerAlignDBTool.cxx +++ b/Tracker/TrackerAlignTools/TrackerAlignGenTools/src/TrackerAlignDBTool.cxx @@ -99,7 +99,6 @@ StatusCode TrackerAlignDBTool::initialize() for (int i=0;i<3;++i) chan[i]=100*i; - int minStation = 3; std::string man_name; for (const TrackerDD::SiDetectorElement* element : *(m_sctman->getDetectorElementCollection())) { @@ -112,7 +111,7 @@ StatusCode TrackerAlignDBTool::initialize() std::string level[3]; for (int i=TransfLevel_low; i<3; ++i) { - minStation = std::min(station, minStation); + m_stations.insert(station); level[i]=dirkey(station, layer, 1+i, phi); // add this to list if not seen already std::vector<std::string>::const_iterator ix = @@ -130,9 +129,8 @@ StatusCode TrackerAlignDBTool::initialize() ATH_MSG_ERROR("Error translating element identifier." ); } } - } - m_ift =(minStation == 0); - ATH_CHECK(m_outputTool.retrieve()); + } + ATH_CHECK(m_outputTool.retrieve()); if (msgLvl(MSG::DEBUG)) { @@ -246,21 +244,11 @@ StatusCode TrackerAlignDBTool::createDB() const { Amg::Transform3D globshift; globshift.setIdentity(); - // Tracker interface - if (m_ift) + for (int station : m_stations) { - ident1 = m_sctid->wafer_id(0, 0, 0, 0, 0); - pat->add(ident1, Amg::EigenTransformToCLHEP(globshift)); + ident1 = m_sctid->wafer_id(station, 0, 0, 0, 0); + pat->add(ident1, Amg::EigenTransformToCLHEP(globshift)); } - // Tracker upstream - ident1 = m_sctid->wafer_id(1, 0, 0, 0, 0); - pat->add(ident1, Amg::EigenTransformToCLHEP(globshift)); - // Tracker central - ident1 = m_sctid->wafer_id(2, 0, 0, 0, 0); - pat->add(ident1, Amg::EigenTransformToCLHEP(globshift)); - // Tracker downstream - ident1 = m_sctid->wafer_id(3, 0, 0, 0, 0); - pat->add(ident1, Amg::EigenTransformToCLHEP(globshift)); } else { @@ -328,6 +316,7 @@ std::string TrackerAlignDBTool::dirkey(const int station, if (station == 3 ) result << "Downstream"; if (station == 2 ) result << "Central"; if (station == 1 ) result << "Upstream"; + if (station == 0 ) result << "Interface"; result << 1+layer; } } diff --git a/Tracker/TrackerAlignTools/TrackerAlignGenTools/src/TrackerAlignDBTool.h b/Tracker/TrackerAlignTools/TrackerAlignGenTools/src/TrackerAlignDBTool.h index 9ff680075934e2702c4bb8a3aa3902eeaf030a65..2c82c20a10baffab0b01d6c00af036b6adabaa11 100644 --- a/Tracker/TrackerAlignTools/TrackerAlignGenTools/src/TrackerAlignDBTool.h +++ b/Tracker/TrackerAlignTools/TrackerAlignGenTools/src/TrackerAlignDBTool.h @@ -185,8 +185,8 @@ class TrackerAlignDBTool: virtual public ITrackerAlignDBTool, public AthAlgTool const AlignableTransform* cgetTransPtr(const std::string key) const; bool m_dynamicDB; bool m_forceUserDBConfig; - bool m_ift {false}; - + std::set<int> m_stations; + mutable ToolHandle<IAthenaOutputStreamTool> m_outputTool { this, "OutputTool", "AthenaOutputStreamTool/CondStream1"} ; }; diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsData/CMakeLists.txt b/Tracker/TrackerConditions/FaserSCT_ConditionsData/CMakeLists.txt index 9c0b2c7bbd1870169862b8e1279e873840671c9c..f13ae3272499c4b66d5dab008bff2a1b92081f88 100644 --- a/Tracker/TrackerConditions/FaserSCT_ConditionsData/CMakeLists.txt +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsData/CMakeLists.txt @@ -24,6 +24,6 @@ if (INSTALL_CONDB) # Install the generated file: install( FILES ${CMAKE_CURRENT_BINARY_DIR}/ALLP200.db - DESTINATION ${CMAKE_INSTALL_DATADIR} + DESTINATION ${CMAKE_INSTALL_DATADIR}/sqlite200 ) endif() \ No newline at end of file diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsData/data/SCT_Conditions.py b/Tracker/TrackerConditions/FaserSCT_ConditionsData/data/SCT_Conditions.py index 899f0037a6acca662e5c640946e504bdafaacec2..0fb2802c9c0a4135ff3db369038177e2fc1bdb7e 100644 --- a/Tracker/TrackerConditions/FaserSCT_ConditionsData/data/SCT_Conditions.py +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsData/data/SCT_Conditions.py @@ -23,11 +23,17 @@ iftChannels = [ '2583691264', '2585788416', '2587885568', '2589982720', '2592079872', '2594177024', '2596274176', '2598371328', '2600468480', '2602565632', '2604662784', '2606759936', '2608857088', '2610954240', '2613051392', '2615148544', '2617245696', '2619342848', '2621440000', '2623537152', '2625634304', '2627731456', '2629828608', '2631925760', '2634022912', '2636120064', '2638217216', '2640314368', '2642411520', '2644508672', '2646605824', '2648702976' ] +tbChannels = [ + '2147483648', '2151677952', '2155872256', '2160066560', '2164260864', '2168455168', '2172649472', '2176843776', '2181038080', '2185232384', '2189426688', '2193620992', '2197815296', '2202009600', '2206203904', '2210398208', '2214592512', '2218786816', '2222981120', '2227175424', + '2231369728', '2235564032', '2239758336', '2243952640', '2248146944', '2252341248', '2256535552', '2260729856', '2264924160', '2269118464', '2273312768', '2277507072', '2281701376', '2285895680', '2290089984', '2294284288', '2298478592', '2302672896', '2306867200', '2311061504', + '2315255808', '2319450112', '2323644416', '2327838720', '2332033024', '2336227328', '2340421632', '2344615936' ] description = '<timeStamp>run-lumi</timeStamp><addrHeader><address_header clid="1238547719" service_type="71" /></addrHeader><typeName>CondAttrListCollection</typeName>' descriptionDCS = '<timeStamp>time</timeStamp><addrHeader><address_header service_type="71" clid="1238547719" /></addrHeader><typeName>CondAttrListCollection</typeName><cache>600</cache>' +descriptionAlign = '<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type="256" clid="1170039409" /></addrHeader><typeName>AlignableTransformContainer</typeName>' + from PyCool import cool, coral dbSvc = cool.DatabaseSvcFactory.databaseService() @@ -37,27 +43,38 @@ print('recreating database') dbSvc.dropDatabase( connectString ) db = dbSvc.createDatabase( connectString ) +alignSpec = cool.RecordSpecification() +alignSpec.extend( 'PoolRef', cool.StorageType.String4k ) +alignFolderSpec = cool.FolderSpecification(cool.FolderVersioning.MULTI_VERSION, alignSpec, cool.PayloadMode.INLINEPAYLOAD) + tracker = db.createFolderSet("/Tracker") -# tracker_align = db.createFolderSet("/Tracker/Align") +align = db.createFolder("/Tracker/Align", alignFolderSpec, descriptionAlign, True) sct = db.createFolderSet("/SCT") sct_dcs = db.createFolderSet("/SCT/DCS") sct_daq = db.createFolderSet("/SCT/DAQ") sct_daq_calibration = db.createFolderSet("/SCT/DAQ/Calibration") -# tracker_align.createTagRelation("TRACKER-01", "TRACKER-ALIGN-01") +align.createTagRelation("TRACKER-01","TRACKER-ALIGN-01") tracker.createTagRelation("OFLCOND-FASER-01","TRACKER-01") sct_daq_calibration.createTagRelation("SCT-DAQ-01", "SCT-DAQ-Calibration-01") sct_daq.createTagRelation("SCT-01", "SCT-DAQ-01") sct_dcs.createTagRelation("SCT-01", "SCT-DCS-01") sct.createTagRelation("OFLCOND-FASER-01", "SCT-01") -# tracker_align.createTagRelation("TRACKER-02", "TRACKER-ALIGN-02") +align.createTagRelation("TRACKER-02","TRACKER-ALIGN-02") tracker.createTagRelation("OFLCOND-FASER-02","TRACKER-02") sct_daq_calibration.createTagRelation("SCT-DAQ-02", "SCT-DAQ-Calibration-02") sct_daq.createTagRelation("SCT-02", "SCT-DAQ-02") sct_dcs.createTagRelation("SCT-02", "SCT-DCS-02") sct.createTagRelation("OFLCOND-FASER-02", "SCT-02") +align.createTagRelation("TRACKER-TB00","TRACKER-ALIGN-TB00") +tracker.createTagRelation("OFLCOND-FASER-TB00","TRACKER-TB00") +sct_daq_calibration.createTagRelation("SCT-DAQ-TB00", "SCT-DAQ-Calibration-TB00") +sct_daq.createTagRelation("SCT-TB00", "SCT-DAQ-TB00") +sct_dcs.createTagRelation("SCT-TB00", "SCT-DCS-TB00") +sct.createTagRelation("OFLCOND-FASER-TB00", "SCT-TB00") + glob = db.createFolderSet("/GLOBAL") glob_bfield = db.createFolderSet("/GLOBAL/BField") @@ -67,6 +84,8 @@ glob.createTagRelation("OFLCOND-FASER-01", "GLOBAL-01") glob_bfield.createTagRelation("GLOBAL-02", "GLOBAL-BField-02") glob.createTagRelation("OFLCOND-FASER-02", "GLOBAL-02") +glob_bfield.createTagRelation("GLOBAL-TB00", "GLOBAL-BField-TB00") +glob.createTagRelation("OFLCOND-FASER-TB00", "GLOBAL-TB00") gainSpec = cool.RecordSpecification() gainSpec.extend( 'serialNumber' , cool.StorageType.UInt63 ) @@ -325,4 +344,133 @@ scaleRecord['value'] = 1.0 scaleFolder.storeObject( cool.ValidityKeyMin, cool.ValidityKeyMax, scaleRecord, 1, "GLOBAL-BField-Scale-02", True ) scaleFolder.createTagRelation("GLOBAL-BField-02", "GLOBAL-BField-Scale-02") +# Start of TestBeam + +gainSpec = cool.RecordSpecification() +gainSpec.extend( 'serialNumber' , cool.StorageType.UInt63 ) +gainSpec.extend( 'runNumber' , cool.StorageType.UInt32 ) +gainSpec.extend( 'scanNumber' , cool.StorageType.UInt32 ) +gainSpec.extend( 'gainByChip' , cool.StorageType.String4k ) +gainSpec.extend( 'gainRMSByChip' , cool.StorageType.String4k ) +gainSpec.extend( 'offsetByChip' , cool.StorageType.String4k ) +gainSpec.extend( 'offsetRMSByChip' , cool.StorageType.String4k ) +gainSpec.extend( 'noiseByChip' , cool.StorageType.String4k ) +gainSpec.extend( 'noiseRMSByChip' , cool.StorageType.String4k ) + +gainRecord = cool.Record(gainSpec) +gainRecord[ 'serialNumber' ] = 0 +gainRecord[ 'runNumber' ] = 0 +gainRecord[ 'scanNumber' ] = 0 +gainRecord[ 'gainByChip' ] = '52.0 52.0 52.0 52.0 52.0 52.0 52.0 52.0 52.0 52.0 52.0 52.0' +gainRecord[ 'gainRMSByChip' ] = '1.25 1.25 1.25 1.25 1.25 1.25 1.25 1.25 1.25 1.25 1.25 1.25' +gainRecord[ 'offsetByChip' ] = '45.0 45.0 45.0 45.0 45.0 45.0 45.0 45.0 45.0 45.0 45.0 45.0' +gainRecord[ 'offsetRMSByChip' ] = '1.75 1.75 1.75 1.75 1.75 1.75 1.75 1.75 1.75 1.75 1.75 1.75' +gainRecord[ 'noiseByChip' ] = '1600.0 1600.0 1600.0 1600.0 1600.0 1600.0 1600.0 1600.0 1600.0 1600.0 1600.0 1600.0' +gainRecord[ 'noiseRMSByChip' ] = '45.0 45.0 45.0 45.0 45.0 45.0 45.0 45.0 45.0 45.0 45.0 45.0' + +# gainFolderSpec = cool.FolderSpecification(cool.FolderVersioning.MULTI_VERSION, gainSpec) +# gainFolder = db.createFolder('/SCT/DAQ/Calibration/ChipGain', gainFolderSpec, description, True) + +for channel in tbChannels: + gainFolder.storeObject( cool.ValidityKeyMin, cool.ValidityKeyMax, gainRecord, int(channel), "SCT-DAQ-Calibration-ChipGain-TB00", True ) +gainFolder.createTagRelation("SCT-DAQ-Calibration-TB00", "SCT-DAQ-Calibration-ChipGain-TB00") + +noiseSpec = cool.RecordSpecification() +noiseSpec.extend( 'serialNumber' , cool.StorageType.UInt63 ) +noiseSpec.extend( 'runNumber' , cool.StorageType.UInt32 ) +noiseSpec.extend( 'scanNumber' , cool.StorageType.UInt32 ) +noiseSpec.extend( 'offsetByChip' , cool.StorageType.String4k ) +noiseSpec.extend( 'occupancyByChip' , cool.StorageType.String4k ) +noiseSpec.extend( 'occupancyRMSByChip' , cool.StorageType.String4k ) +noiseSpec.extend( 'noiseByChip' , cool.StorageType.String4k ) + +noiseRecord = cool.Record(noiseSpec) +noiseRecord[ 'serialNumber' ] = 0 +noiseRecord[ 'runNumber' ] = 0 +noiseRecord[ 'scanNumber' ] = 0 +noiseRecord[ 'offsetByChip' ] = '60.0 60.0 60.0 60.0 60.0 60.0 60.0 60.0 60.0 60.0 60.0 60.0' +noiseRecord[ 'occupancyByChip' ] = '3.50e-05 3.50e-05 3.50e-05 3.50e-05 3.50e-05 3.50e-05 3.50e-05 3.50e-05 3.50e-05 3.50e-05 3.50e-05 3.50e-05 3.50e-05' +noiseRecord[ 'occupancyRMSByChip' ] = '2.50e-05 2.50e-05 2.50e-05 2.50e-05 2.50e-05 2.50e-05 2.50e-05 2.50e-05 2.50e-05 2.50e-05 2.50e-05 2.50e-05 2.50e-05' + +# noiseFolderSpec = cool.FolderSpecification(cool.FolderVersioning.MULTI_VERSION, noiseSpec) +# noiseFolder = db.createFolder('/SCT/DAQ/Calibration/ChipNoise', noiseFolderSpec, description, True ) + +for channel in tbChannels: + noiseFolder.storeObject( cool.ValidityKeyMin, cool.ValidityKeyMax, noiseRecord, int(channel), "SCT-DAQ-Calibration-Noise-TB00", True ) +noiseFolder.createTagRelation("SCT-DAQ-Calibration-TB00", "SCT-DAQ-Calibration-Noise-TB00") + +chanstatSpec = cool.RecordSpecification() +chanstatSpec.extend( 'LVCHSTAT_RECV' , cool.StorageType.Int32 ) +chanstatSpec.extend( 'STATE' , cool.StorageType.UInt32 ) + +chanstatRecord = cool.Record(chanstatSpec) +chanstatRecord[ 'LVCHSTAT_RECV' ] = 209 +chanstatRecord[ 'STATE' ] = 17 + +# chanstatFolderSpec = cool.FolderSpecification(cool.FolderVersioning.MULTI_VERSION, chanstatSpec) +# chanstatFolder = db.createFolder('/SCT/DCS/CHANSTAT', chanstatFolderSpec, descriptionDCS, True ) + +for channel in tbChannels: + chanstatFolder.storeObject( cool.ValidityKeyMin, cool.ValidityKeyMax, chanstatRecord, int(channel), "SCT-DCS-Status-TB00", True ) +chanstatFolder.createTagRelation("SCT-DCS-TB00", "SCT-DCS-Status-TB00") + +hvSpec = cool.RecordSpecification() +hvSpec.extend( 'HVCHVOLT_RECV' , cool.StorageType.Float ) +hvSpec.extend( 'HVCHCURR_RECV' , cool.StorageType.Float ) + +hvRecord = cool.Record(hvSpec) +hvRecord[ 'HVCHVOLT_RECV' ] = 150.0 +hvRecord[ 'HVCHCURR_RECV' ] = 10.0 + +# hvFolderSpec = cool.FolderSpecification(cool.FolderVersioning.MULTI_VERSION, hvSpec) +# hvFolder = db.createFolder('/SCT/DCS/HV', hvFolderSpec, descriptionDCS, True ) + +for channel in tbChannels: + hvFolder.storeObject( cool.ValidityKeyMin, cool.ValidityKeyMax, hvRecord, int(channel), "SCT-DCS-HV-TB00", True ) +hvFolder.createTagRelation("SCT-DCS-TB00", "SCT-DCS-HV-TB00") + +modtempSpec = cool.RecordSpecification() +modtempSpec.extend( 'MOCH_TM0_RECV' , cool.StorageType.Float ) +modtempSpec.extend( 'MOCH_TM1_RECV' , cool.StorageType.Float ) + +modtempRecord = cool.Record(modtempSpec) +modtempRecord[ 'MOCH_TM0_RECV' ] = 7.0 +modtempRecord[ 'MOCH_TM1_RECV' ] = 7.0 + +# modtempFolderSpec = cool.FolderSpecification(cool.FolderVersioning.MULTI_VERSION, modtempSpec) +# modtempFolder = db.createFolder('/SCT/DCS/MODTEMP', modtempFolderSpec, descriptionDCS, True ) + +for channel in tbChannels: + modtempFolder.storeObject( cool.ValidityKeyMin, cool.ValidityKeyMax, modtempRecord, int(channel), "SCT-DCS-Temp-TB00", True ) +modtempFolder.createTagRelation("SCT-DCS-TB00", "SCT-DCS-Temp-TB00") + + +mapSpec = cool.RecordSpecification() +mapSpec.extend( 'FieldType', cool.StorageType.String4k ) +mapSpec.extend( 'MapFileName', cool.StorageType.String4k ) + +mapRecord = cool.Record(mapSpec) +mapRecord['FieldType'] = "GlobalMap" +mapRecord['MapFileName'] = "file:MagneticFieldMaps/FaserFieldTable.root" + +# mapFolderSpec = cool.FolderSpecification(cool.FolderVersioning.MULTI_VERSION, mapSpec) +# mapFolder = db.createFolder('/GLOBAL/BField/Maps', mapFolderSpec, descriptionDCS, True ) + +mapFolder.storeObject( cool.ValidityKeyMin, cool.ValidityKeyMax, mapRecord, 1, "GLOBAL-BField-Maps-TB00", True ) +mapFolder.createTagRelation("GLOBAL-BField-TB00", "GLOBAL-BField-Maps-TB00") + +scaleSpec = cool.RecordSpecification() +scaleSpec.extend( 'value', cool.StorageType.Float ) + +scaleRecord = cool.Record(scaleSpec) +scaleRecord['value'] = 0.0 + +# scaleFolderSpec = cool.FolderSpecification(cool.FolderVersioning.MULTI_VERSION, scaleSpec) +# scaleFolder = db.createFolder('/GLOBAL/BField/Scales', scaleFolderSpec, descriptionDCS, True ) + +# Channel names don't seem to be handled properly by Athena +# scaleFolder.createChannel( 1, "Dipole_Scale" ) +scaleFolder.storeObject( cool.ValidityKeyMin, cool.ValidityKeyMax, scaleRecord, 1, "GLOBAL-BField-Scale-TB00", True ) +scaleFolder.createTagRelation("GLOBAL-BField-TB00", "GLOBAL-BField-Scale-TB00") + db.closeDatabase() diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/FaserSCT_ConditionsTools/ISCT_CableMappingTool.h b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/FaserSCT_ConditionsTools/ISCT_CableMappingTool.h new file mode 100644 index 0000000000000000000000000000000000000000..e3472b215006d06607c0316ecfdaf09976e0b092 --- /dev/null +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/FaserSCT_ConditionsTools/ISCT_CableMappingTool.h @@ -0,0 +1,37 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS and FAsER collaborations +*/ + +/** @file ISCT_CableMappingTool.h Interface file for SCT_CableMappingTool. + */ + +// Multiple inclusion protection +#ifndef ISCT_CABLE_MAPPING_TOOL +#define ISCT_CABLE_MAPPING_TOOL + +//STL includes +#include <vector> + +//Gaudi Includes +#include "GaudiKernel/IAlgTool.h" +#include "GaudiKernel/EventContext.h" + +class ISCT_CableMappingTool: virtual public IAlgTool { + + public: + + //----------Public Member Functions----------// + // Structors + virtual ~ISCT_CableMappingTool() = default; //!< Destructor + + /// Creates the InterfaceID and interfaceID() method + DeclareInterfaceID(ISCT_CableMappingTool, 1, 0); + + // Methods to return cable-mapping data + virtual std::map<int, std::pair<int,int> > getCableMapping(const EventContext& ctx) const = 0; + virtual std::map<int, std::pair<int,int> > getCableMapping(void) const = 0; + +}; + +//---------------------------------------------------------------------- +#endif // ISCT_CABLE_MAPPING_TOOL diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/python/FaserSCT_CableMappingConfig.py b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/python/FaserSCT_CableMappingConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..2dadb536ac49c9f4c9250e6da0d16aa012f7a6e9 --- /dev/null +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/python/FaserSCT_CableMappingConfig.py @@ -0,0 +1,27 @@ +"""Define methods to configure FaserSCT_CableMapping + +Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +""" +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from AthenaConfiguration.ComponentFactory import CompFactory +from IOVDbSvc.IOVDbSvcConfig import addFolders +FaserSCT_CableMappingTool=CompFactory.FaserSCT_CableMappingTool + +def FaserSCT_CableMappingToolCfg(flags, name="CableMappingTool", **kwargs): + """Return a configured FaserSCT_CableMappingTool""" + return FaserSCT_CableMappingTool(name, **kwargs) + +def FaserSCT_CableMappingCfg(flags, **kwargs): + """Return configured ComponentAccumulator and tool for FaserSCT_CableMapping + + CableMappingTool may be provided in kwargs + """ + acc = ComponentAccumulator() + # tool = kwargs.get("CableMappingTool", FaserSCT_CableMappingToolCfg(flags)) + # folder arguments + dbInstance = kwargs.get("dbInstance", "TDAQ_OFL") + dbFolder = kwargs.get("dbFolder", "/SCT/DAQ/CableMapping") + acc.merge(addFolders(flags, dbFolder, dbInstance, className="CondAttrListCollection")) + # acc.addPublicTool(tool) + return acc + diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/FaserSCT_CableMappingTool.cxx b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/FaserSCT_CableMappingTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..be731ccc6509c890e1150857c57df39f637855d2 --- /dev/null +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/FaserSCT_CableMappingTool.cxx @@ -0,0 +1,89 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS and FASER collaborations +*/ + +/** @file FaserSCT_CableMappingTool.cxx Implementation file for FaserSCT_CableMappingTool. + @author Dave Casper (06/01/22) +*/ + +#include "FaserSCT_CableMappingTool.h" + +// Include Athena stuff + +//---------------------------------------------------------------------- +FaserSCT_CableMappingTool::FaserSCT_CableMappingTool (const std::string& type, const std::string& name, const IInterface* parent) : + base_class(type, name, parent) +{ +} + +//---------------------------------------------------------------------- +StatusCode +FaserSCT_CableMappingTool::initialize() { + // Read Cond Handle Key + + ATH_CHECK(m_readKey.initialize()); + + return StatusCode::SUCCESS; +} // FaserSCT_CableMappingTool::initialize() + +//---------------------------------------------------------------------- +StatusCode +FaserSCT_CableMappingTool::finalize() { + // Print where you are + return StatusCode::SUCCESS; +} // FaserSCT_CableMappingTool::finalize() + +//---------------------------------------------------------------------- +std::map<int, std::pair<int, int> > +FaserSCT_CableMappingTool::getCableMapping(const EventContext& ctx) const { + // Print where you are + ATH_MSG_DEBUG("in getCableMapping()"); + std::map<int, std::pair<int, int> > mappingData; + + // Read Cond Handle + SG::ReadCondHandle<CondAttrListCollection> readHandle{m_readKey, ctx}; + const CondAttrListCollection* readCdo{*readHandle}; + if (readCdo==nullptr) { + ATH_MSG_FATAL("Null pointer to the read conditions object"); + return mappingData; + } + // Get the validitiy range + EventIDRange rangeW; + if (not readHandle.range(rangeW)) { + ATH_MSG_FATAL("Failed to retrieve validity range for " << readHandle.key()); + return mappingData; + } + ATH_MSG_DEBUG("Size of CondAttrListCollection " << readHandle.fullKey() << " readCdo->size()= " << readCdo->size()); + ATH_MSG_DEBUG("Range of input is " << rangeW); + + // Read mapping info + std::string stationParam{"station"}; + std::string planeParam{"plane"}; + CondAttrListCollection::const_iterator attrList{readCdo->begin()}; + CondAttrListCollection::const_iterator end{readCdo->end()}; + // CondAttrListCollection doesn't support C++11 type loops, no generic 'begin' + for (; attrList!=end; ++attrList) { + // A CondAttrListCollection is a map of ChanNum and AttributeList + CondAttrListCollection::ChanNum channelNumber{attrList->first}; + const CondAttrListCollection::AttributeList &payload{attrList->second}; + if (payload.exists(stationParam) and not payload[stationParam].isNull() and + payload.exists(planeParam) and not payload[planeParam].isNull()) + { + int stationVal{payload[stationParam].data<int>()}; + int planeVal {payload[planeParam].data<int>()}; + if (stationVal < 0 || planeVal < 0) continue; // Don't include invalid entries + mappingData.emplace(std::make_pair(channelNumber, std::make_pair(stationVal, planeVal))); + } else { + ATH_MSG_WARNING(stationParam << " and/or " << planeParam << " does not exist for ChanNum " << channelNumber); + } + } + + return mappingData; +} //FaserSCT_ReadCalibChipDataTool::getNPtGainData() + +std::map<int, std::pair<int, int> > +FaserSCT_CableMappingTool::getCableMapping(void) const { + const EventContext& ctx{Gaudi::Hive::currentContext()}; + return getCableMapping(ctx); +} + diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/FaserSCT_CableMappingTool.h b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/FaserSCT_CableMappingTool.h new file mode 100644 index 0000000000000000000000000000000000000000..b2cf0076af23e99195e4283ac563aad846487c4e --- /dev/null +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/FaserSCT_CableMappingTool.h @@ -0,0 +1,62 @@ +// -*- C++ -*- + +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS and CERN collaborations +*/ + +/** @file FaserSCT_CableMappingTool.h Header file for FaserSCT_CableMappingTool. + @author Dave Casper, 06/01/22 +*/ + +// Multiple inclusion protection +#ifndef FASERSCT_CABLE_MAPPING_TOOL +#define FASERSCT_CABLE_MAPPING_TOOL + +// Include interface class +#include "AthenaBaseComps/AthAlgTool.h" +#include "FaserSCT_ConditionsTools/ISCT_CableMappingTool.h" + +// Include Athena stuff +#include "AthenaPoolUtilities/CondAttrListCollection.h" +#include "StoreGate/ReadCondHandleKey.h" + +#include "GaudiKernel/ICondSvc.h" +#include "Gaudi/Property.h" + +// #include "FaserSCT_ConditionsData/FaserSCT_ConditionsParameters.h" +// #include "FaserSCT_ConditionsData/FaserSCT_GainCalibData.h" +// #include "FaserSCT_ConditionsData/FaserSCT_NoiseCalibData.h" + +// Include Gaudi classes +#include "GaudiKernel/EventContext.h" + +/** This class contains a Tool that reads SCT cable mapping data and makes it available to + other algorithms. The current implementation reads the data from a COOL database. +*/ + +class FaserSCT_CableMappingTool: public extends<AthAlgTool, ISCT_CableMappingTool> { + + public: + //----------Public Member Functions----------// + // Structors + FaserSCT_CableMappingTool(const std::string& type, const std::string& name, const IInterface* parent); //!< Constructor + virtual ~FaserSCT_CableMappingTool() = default; //!< Destructor + + // Standard Gaudi functions + virtual StatusCode initialize() override; //!< Gaudi initialiser + virtual StatusCode finalize() override; //!< Gaudi finaliser + + // Methods to return calibration data + virtual std::map<int, std::pair<int, int> > getCableMapping(const EventContext& ctx) const override; + virtual std::map<int, std::pair<int, int> > getCableMapping(void) const override; + + private: + // Read Cond Handle + SG::ReadCondHandleKey<CondAttrListCollection> m_readKey{this, "ReadKey", "/SCT/DAQ/CableMapping", "Key of input cabling folder"}; + + ServiceHandle<ICondSvc> m_condSvc{this, "CondSvc", "CondSvc"}; + +}; + +//---------------------------------------------------------------------- +#endif // FASERSCT_CABLE_MAPPING_TOOL diff --git a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/components/FaserSCT_ConditionsTools_entries.cxx b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/components/FaserSCT_ConditionsTools_entries.cxx index 5cf6ed934a7efda6c107717ff2eb41a70237fa8d..cae3df3c65e74cecd79c4729d2dc57cc8e7e4cf3 100644 --- a/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/components/FaserSCT_ConditionsTools_entries.cxx +++ b/Tracker/TrackerConditions/FaserSCT_ConditionsTools/src/components/FaserSCT_ConditionsTools_entries.cxx @@ -19,6 +19,7 @@ #include "../FaserSCT_SiliconConditionsTool.h" // #include "../SCT_StripVetoTool.h" // #include "../SCT_TdaqEnabledTool.h" +#include "../FaserSCT_CableMappingTool.h" // DECLARE_COMPONENT( SCT_ByteStreamErrorsTool ) // DECLARE_COMPONENT( SCT_ChargeTrappingTool ) @@ -41,3 +42,4 @@ DECLARE_COMPONENT( FaserSCT_ReadCalibChipDataTool ) DECLARE_COMPONENT( FaserSCT_SiliconConditionsTool ) // DECLARE_COMPONENT( SCT_StripVetoTool ) // DECLARE_COMPONENT( SCT_TdaqEnabledTool ) +DECLARE_COMPONENT( FaserSCT_CableMappingTool ) \ No newline at end of file diff --git a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/python/FaserSCT_GeoModelConfig.py b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/python/FaserSCT_GeoModelConfig.py index 88a5b7b1e8b32c6ebf0555a8c485b0cea9ef1677..26dff64f141ad9f22ff4ac430ef2fbdf98065f7e 100644 --- a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/python/FaserSCT_GeoModelConfig.py +++ b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/python/FaserSCT_GeoModelConfig.py @@ -24,6 +24,9 @@ def FaserSCT_GeometryCfg( flags ): sctDetectorTool.useDynamicAlignFolders = flags.GeoModel.Align.Dynamic geoModelSvc.DetectorTools += [ sctDetectorTool ] + if flags.GeoModel.Align.Disable: + return acc + 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")) diff --git a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/python/FaserSCT_GeoModelConfigDb.py b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/python/FaserSCT_GeoModelConfigDb.py index 585ac96728ffd7485b6663086a94c3b518a5455d..c344832b279a351c3619f635d70ee98139ae2b3e 100644 --- a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/python/FaserSCT_GeoModelConfigDb.py +++ b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/python/FaserSCT_GeoModelConfigDb.py @@ -1,6 +1,6 @@ # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -from AthenaCommon.CfgGetter import addAlgorithm,addTool +from AthenaCommon.CfgGetter import addTool # add tools and algorithms to the ConfiguredFactory, see: # https://twiki.cern.ch/twiki/bin/viewauth/AtlasComputing/ConfiguredFactory addTool("FaserSCT_GeoModel.FaserSCT_GeoModelConfig.FasergetSCT_DetectorTool","FaserSCT_DetectorTool") diff --git a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_DetectorFactory.cxx b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_DetectorFactory.cxx index 003173e935bc1e3fd421c99fe6affb574934558f..63763a9aa5d9c7a2dd60cc5fdf5144d8f9078a4d 100644 --- a/Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_DetectorFactory.cxx +++ b/Tracker/TrackerDetDescr/FaserSCT_GeoModel/src/SCT_DetectorFactory.cxx @@ -182,7 +182,10 @@ void SCT_DetectorFactory::create(GeoPhysVol *world) m_detectorManager->addFolder("/Tracker/Align"); m_detectorManager->addChannel("/Tracker/Align/Stations", 3, TrackerDD::global); // Stations in world m_detectorManager->addChannel("/Tracker/Align/Planes", 2, TrackerDD::global); // Planes in world - m_detectorManager->addChannel("/Tracker/Align/Upstream1", 1, TrackerDD::local); // Modules in planes and wafers in modules + m_detectorManager->addChannel("/Tracker/Align/Interface1", 1, TrackerDD::local); // Modules in planes + m_detectorManager->addChannel("/Tracker/Align/Interface2", 1, TrackerDD::local); + m_detectorManager->addChannel("/Tracker/Align/Interface3", 1, TrackerDD::local); + m_detectorManager->addChannel("/Tracker/Align/Upstream1", 1, TrackerDD::local); m_detectorManager->addChannel("/Tracker/Align/Upstream2", 1, TrackerDD::local); m_detectorManager->addChannel("/Tracker/Align/Upstream3", 1, TrackerDD::local); m_detectorManager->addChannel("/Tracker/Align/Central1" , 1, TrackerDD::local); diff --git a/Tracker/TrackerDetDescr/TrackerReadoutGeometry/TrackerReadoutGeometry/SiDetectorElement.h b/Tracker/TrackerDetDescr/TrackerReadoutGeometry/TrackerReadoutGeometry/SiDetectorElement.h index 89fa0e161a3f73b06d54c5630dd7ac763b41bc69..652add49be92b54bcf1b273d8d1da11f1ad4fd52 100644 --- a/Tracker/TrackerDetDescr/TrackerReadoutGeometry/TrackerReadoutGeometry/SiDetectorElement.h +++ b/Tracker/TrackerDetDescr/TrackerReadoutGeometry/TrackerReadoutGeometry/SiDetectorElement.h @@ -178,6 +178,12 @@ namespace TrackerDD { /// SiCellId from Identifier SiCellId cellIdFromIdentifier(const Identifier& identifier) const; + /// Station + bool isInterface() const; + bool isUpstream() const; + bool isCentral() const; + bool isDownstream() const; + //@} diff --git a/Tracker/TrackerDetDescr/TrackerReadoutGeometry/src/SiDetectorElement.cxx b/Tracker/TrackerDetDescr/TrackerReadoutGeometry/src/SiDetectorElement.cxx index 776fb48b7b0866a7f06724dae36d3256dd595cca..c9a29684d559305ac76ad06b2b632701df8cdc3c 100644 --- a/Tracker/TrackerDetDescr/TrackerReadoutGeometry/src/SiDetectorElement.cxx +++ b/Tracker/TrackerDetDescr/TrackerReadoutGeometry/src/SiDetectorElement.cxx @@ -1012,4 +1012,37 @@ namespace TrackerDD { return cellId; } + bool + SiDetectorElement::isInterface() const + { + const FaserSCT_ID* sctId = dynamic_cast<const FaserSCT_ID*>(getIdHelper()); + if (nullptr == sctId) return false; + return ( (sctId->is_sct(m_id)) && (sctId->station(m_id) == 0) ); + } + + bool + SiDetectorElement::isUpstream() const + { + const FaserSCT_ID* sctId = dynamic_cast<const FaserSCT_ID*>(getIdHelper()); + if (nullptr == sctId) return false; + return ( (sctId->is_sct(m_id)) && (sctId->station(m_id) == 1) ); + } + + bool + SiDetectorElement::isCentral() const + { + const FaserSCT_ID* sctId = dynamic_cast<const FaserSCT_ID*>(getIdHelper()); + if (nullptr == sctId) return false; + return ( (sctId->is_sct(m_id)) && (sctId->station(m_id) == 2) ); + } + + bool + SiDetectorElement::isDownstream() const + { + const FaserSCT_ID* sctId = dynamic_cast<const FaserSCT_ID*>(getIdHelper()); + if (nullptr == sctId) return false; + return ( (sctId->is_sct(m_id)) && (sctId->station(m_id) == 3) ); + } + + } // namespace TrackerDD diff --git a/Tracker/TrackerDetDescr/TrackerReadoutGeometry/src/TrackerDetectorManager.cxx b/Tracker/TrackerDetDescr/TrackerReadoutGeometry/src/TrackerDetectorManager.cxx index 41c0ab6061de1a7862abc476b86378bb19196039..ae76706e4b249d815e1e64477a352b073be0823d 100755 --- a/Tracker/TrackerDetDescr/TrackerReadoutGeometry/src/TrackerDetectorManager.cxx +++ b/Tracker/TrackerDetDescr/TrackerReadoutGeometry/src/TrackerDetectorManager.cxx @@ -8,6 +8,7 @@ #include "StoreGate/StoreGateSvc.h" #include "DetDescrConditions/AlignableTransform.h" #include "FaserDetDescr/FaserDetectorID.h" +#include "Identifier/IdentifierHash.h" #include "GeoPrimitives/CLHEPtoEigenConverter.h" #include "AthenaPoolUtilities/CondAttrListCollection.h" #include "AthenaBaseComps/AthMsgStreamMacros.h" diff --git a/Tracker/TrackerDigitization/FaserSCT_Digitization/python/FaserSCT_DigitizationConfig.py b/Tracker/TrackerDigitization/FaserSCT_Digitization/python/FaserSCT_DigitizationConfig.py index 3d9ec7a072ce801067ae843341e5ca9b8f84ce40..d875c327eb2673741a4d0580fe42d0458e285c62 100644 --- a/Tracker/TrackerDigitization/FaserSCT_Digitization/python/FaserSCT_DigitizationConfig.py +++ b/Tracker/TrackerDigitization/FaserSCT_Digitization/python/FaserSCT_DigitizationConfig.py @@ -49,7 +49,7 @@ def getFaserSCT_SurfaceChargesGenerator(name="FaserSCT_SurfaceChargesGenerator", sct_SiPropertiesToolSetup.setSiliconTool(sct_SiliconConditionsToolSetup.getTool()) sct_SiPropertiesToolSetup.setup() ## Charge trapping tool - used by SCT_SurfaceChargesGenerator - from AthenaCommon.AppMgr import ToolSvc +# from AthenaCommon.AppMgr import ToolSvc ## SiLorentzAngleTool for SCT_SurfaceChargesGenerator from SiLorentzAngleTool.SCTLorentzAngleToolSetup import SCTLorentzAngleToolSetup sctLorentzAngleToolSetup = SCTLorentzAngleToolSetup() @@ -185,9 +185,9 @@ def commonFaserSCT_DigitizationConfig(name,**kwargs): # write out SCT1_RawData #kwargs.setdefault("WriteSCT1_RawData", False) - if digitizationFlags.doXingByXingPileUp(): - kwargs.setdefault("FirstXing", SCT_FirstXing()) - kwargs.setdefault("LastXing", SCT_LastXing() ) +# if digitizationFlags.doXingByXingPileUp(): +# kwargs.setdefault("FirstXing", SCT_FirstXing()) +# kwargs.setdefault("LastXing", SCT_LastXing() ) from AthenaCommon import CfgMgr return CfgMgr.FaserSCT_DigitizationTool(name,**kwargs) @@ -198,7 +198,7 @@ def commonFaserSCT_DigitizationConfig(name,**kwargs): ###################################################################################### def FaserSCT_DigitizationTool(name="FaserSCT_DigitizationTool", **kwargs): - from Digitization.DigitizationFlags import digitizationFlags +# from Digitization.DigitizationFlags import digitizationFlags kwargs.setdefault("OutputObjectName", "SCT_RDOs") kwargs.setdefault("OutputSDOName", "SCT_SDO_Map") diff --git a/Tracker/TrackerEventCnv/TrackerByteStream/CMakeLists.txt b/Tracker/TrackerEventCnv/TrackerByteStream/CMakeLists.txt index 2ae44b44d80880acc3f92a74b9e32de0e2e1ee55..37ed93239bfb5f8ce750be0ce355ac72ee3e5f59 100644 --- a/Tracker/TrackerEventCnv/TrackerByteStream/CMakeLists.txt +++ b/Tracker/TrackerEventCnv/TrackerByteStream/CMakeLists.txt @@ -8,7 +8,7 @@ atlas_subdir( TrackerByteStream ) atlas_add_component( TrackerByteStream src/*.cxx src/*.h src/components/*.cxx - LINK_LIBRARIES AthenaKernel GaudiKernel StoreGateLib FaserByteStreamCnvSvcBaseLib FaserEventStorageLib TrackerRawData TrackerReadoutGeometry TrackerIdentifier EventFormats + LINK_LIBRARIES AthenaKernel GaudiKernel StoreGateLib FaserByteStreamCnvSvcBaseLib FaserEventStorageLib TrackerRawData TrackerReadoutGeometry TrackerIdentifier EventFormats FaserSCT_ConditionsToolsLib PRIVATE_LINK_LIBRARIES AthenaBaseComps ) diff --git a/Tracker/TrackerEventCnv/TrackerByteStream/python/TrackerByteStreamConfig.py b/Tracker/TrackerEventCnv/TrackerByteStream/python/TrackerByteStreamConfig.py index 06e029772acd553a6791869ab62dcedbad321bff..f1945e30e6c607f7d107d1ca3c27a4be427d3524 100644 --- a/Tracker/TrackerEventCnv/TrackerByteStream/python/TrackerByteStreamConfig.py +++ b/Tracker/TrackerEventCnv/TrackerByteStream/python/TrackerByteStreamConfig.py @@ -2,8 +2,11 @@ #from AthenaConfiguration.ComponentFactory import CompFactory from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from FaserSCT_ConditionsTools.FaserSCT_CableMappingConfig import FaserSCT_CableMappingCfg +# from FaserSCT_ConditionsTools.FaserSCT_DCSConditionsConfig import FaserSCT_DCSConditionsCfg def TrackerByteStreamCfg(configFlags, **kwargs): - acc = ComponentAccumulator() + acc = FaserSCT_CableMappingCfg(configFlags, **kwargs) + # tool = acc.popToolsAndMerge(acc) return acc \ No newline at end of file diff --git a/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerByteStreamCnv.cxx b/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerByteStreamCnv.cxx index 8a82d3cdd8aac0fd64f28d389402308bdf8525d7..bd6ff38f7fc46fe44c62e5ccb339744e46cad90c 100644 --- a/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerByteStreamCnv.cxx +++ b/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerByteStreamCnv.cxx @@ -26,6 +26,7 @@ TrackerByteStreamCnv::TrackerByteStreamCnv(ISvcLocator* svcloc) : Converter(storageType(), classID(), svcloc) , AthMessaging(svcloc != nullptr ? msgSvc() : nullptr, "TrackerByteStreamCnv") , m_tool("TrackerDataDecoderTool") + , m_mappingTool("FaserSCT_CableMappingTool") , m_rdpSvc("FaserROBDataProviderSvc", "TrackerByteStreamCnv") , m_detStoreSvc("StoreGateSvc/DetectorStore", "TrackerByteStreamCnv") { @@ -46,6 +47,7 @@ StatusCode TrackerByteStreamCnv::initialize() CHECK(Converter::initialize()); CHECK(m_rdpSvc.retrieve()); CHECK(m_tool.retrieve()); + CHECK(m_mappingTool.retrieve()); ATH_CHECK(m_detStoreSvc.retrieve()); ATH_CHECK(m_detStoreSvc->retrieve(m_sctID, "FaserSCT_ID")); @@ -94,9 +96,12 @@ StatusCode TrackerByteStreamCnv::createObj(IOpaqueAddress* pAddr, DataObject*& p FaserSCT_RDO_Container* cont = new FaserSCT_RDO_Container(max); ATH_MSG_DEBUG("New FaserSCT_RDO_Container created of size="<<cont->size()); + auto mapping = m_mappingTool->getCableMapping(); + ATH_MSG_DEBUG("Cable mapping contains " << mapping.size() << " entries"); + // Convert raw data into this container - CHECK( m_tool->convert(re, cont, key) ); + CHECK( m_tool->convert(re, cont, key, mapping) ); pObj = SG::asStorable(cont); diff --git a/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerByteStreamCnv.h b/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerByteStreamCnv.h index 212257deffe468d416c04d1b23ed2dd60496fdc5..de0095b637bc99a9b0e30e2b34fba5842bcdbcf6 100644 --- a/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerByteStreamCnv.h +++ b/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerByteStreamCnv.h @@ -14,6 +14,7 @@ #include "AthenaBaseComps/AthMessaging.h" #include "FaserByteStreamCnvSvcBase/FaserByteStreamAddress.h" +#include "FaserSCT_ConditionsTools/ISCT_CableMappingTool.h" class TrackerDataDecoderTool; class IFaserROBDataProviderSvc; @@ -40,6 +41,7 @@ public: private: ToolHandle<TrackerDataDecoderTool> m_tool; + ToolHandle<ISCT_CableMappingTool> m_mappingTool; ServiceHandle<IFaserROBDataProviderSvc> m_rdpSvc; ServiceHandle<StoreGateSvc> m_detStoreSvc; const FaserSCT_ID* m_sctID{nullptr}; diff --git a/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerDataDecoderTool.cxx b/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerDataDecoderTool.cxx index e3c2b07fddfdc0305326f11a27def61644e1b6d0..9971d0292356a1e8437f5734c2703a0bac10ee2a 100644 --- a/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerDataDecoderTool.cxx +++ b/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerDataDecoderTool.cxx @@ -46,7 +46,7 @@ TrackerDataDecoderTool::initialize() ATH_CHECK(detStore()->retrieve(m_sctID, "FaserSCT_ID")); auto first_wafer = m_sctID->wafer_begin(); - m_trb0Station = m_sctID->station(*first_wafer); + // m_trb0Station = m_sctID->station(*first_wafer); m_sctContext = m_sctID->wafer_context(); m_phiReversed.resize(m_sctID->wafer_hash_max(), false); @@ -80,7 +80,8 @@ TrackerDataDecoderTool::finalize() StatusCode TrackerDataDecoderTool::convert(const DAQFormats::EventFull* re, FaserSCT_RDO_Container* container, - std::string key) + std::string key, + const std::map<int, std::pair<int, int> >& cableMapping) { ATH_MSG_DEBUG("TrackerDataDecoderTool::convert()"); @@ -116,10 +117,17 @@ TrackerDataDecoderTool::convert(const DAQFormats::EventFull* re, if ((frag->source_id()&0xFFFF0000) != DAQFormats::SourceIDs::TrackerSourceID) continue; ATH_MSG_DEBUG("Fragment:\n" << *frag); uint32_t trb = frag->source_id() & 0x0000FFFF; + if (cableMapping.count(trb) == 0) + { + ATH_MSG_ERROR("Invalid trb number " << trb << " not in mapping DB"); + return StatusCode::FAILURE; + } // FIXME: 1 by default; needs to be 0 for IFT - int station = m_trb0Station + trb / TrackerDataFragment::PLANES_PER_STATION; - int plane = trb % TrackerDataFragment::PLANES_PER_STATION; - + // int station = m_trb0Station + trb / TrackerDataFragment::PLANES_PER_STATION; + // int plane = trb % TrackerDataFragment::PLANES_PER_STATION; + int station = cableMapping.at(trb).first; + int plane = cableMapping.at(trb).second; + // Exceptions are a no-no in Athena/Calypso, so catch any thrown by faser-common try { diff --git a/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerDataDecoderTool.h b/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerDataDecoderTool.h index 1d9507c2b6d8ca77467e2685d26ff9d459f83b9f..32b42ced60b494d93661aa4f3ea8dbcbdc6ce63b 100644 --- a/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerDataDecoderTool.h +++ b/Tracker/TrackerEventCnv/TrackerByteStream/src/TrackerDataDecoderTool.h @@ -31,7 +31,7 @@ class TrackerDataDecoderTool : public AthAlgTool { virtual StatusCode initialize(); virtual StatusCode finalize(); - StatusCode convert(const DAQFormats::EventFull* re, FaserSCT_RDO_Container* cont, std::string key); + StatusCode convert(const DAQFormats::EventFull* re, FaserSCT_RDO_Container* cont, std::string key, const std::map<int, std::pair<int, int> >& cableMapping); private: const FaserSCT_ID* m_sctID{nullptr}; @@ -42,7 +42,7 @@ private: {7, 2, 5, 0, 3, 6, 1, 4}, "Mapping from online to offline module numbers" }; - Gaudi::Property<uint32_t> m_trb0Station { this, "Trb0StationNumber", 1, "Station number for TRB #0" }; + // Gaudi::Property<uint32_t> m_trb0Station { this, "Trb0StationNumber", 1, "Station number for TRB #0" }; }; #endif /* TRACKERBYTESTREAM_TRACKERDATADECODERTOOL_H */ diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/CMakeLists.txt b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/CMakeLists.txt index a6ff20cdab5cb61d20b97b17290b0224ee6192fc..87b41d357f9aeeae0a538a1601109cafa103a7fa 100644 --- a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/CMakeLists.txt +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/CMakeLists.txt @@ -16,18 +16,19 @@ atlas_add_library( TrackerEventAthenaPool AthenaBaseComps AthenaKernel SGTools StoreGateLib AthenaPoolCnvSvcLib AthenaPoolUtilities AtlasSealCLHEP GaudiKernel TrackerIdentifier TrackerReadoutGeometry TrackerEventTPCnv TrackerRawData TrackerSimData - TrackerPrepRawData TrkTrack ) + TrackerPrepRawData TrackerSpacePoint TrkTrack ) atlas_add_poolcnv_library( TrackerEventAthenaPoolPoolCnv FILES TrackerRawData/FaserSCT_RDO_Container.h TrackerPrepRawData/FaserSCT_ClusterContainer.h + TrackerSpacePoint/FaserSCT_SpacePointContainer.h src/TrackerTrack.h TrackerSimData/TrackerSimDataCollection.h LINK_LIBRARIES Identifier GeneratorObjectsTPCnv AthAllocators AthContainers AthenaBaseComps AthenaKernel SGTools StoreGateLib AthenaPoolCnvSvcLib AthenaPoolUtilities AtlasSealCLHEP GaudiKernel TrackerIdentifier TrackerReadoutGeometry TrackerEventTPCnv TrackerRawData TrackerSimData - TrackerPrepRawData TrkTrack TrackerEventAthenaPool ) + TrackerPrepRawData TrackerSpacePoint TrkTrack TrackerEventAthenaPool ) atlas_add_dictionary( TrackerEventAthenaPoolCnvDict TrackerEventAthenaPool/TrackerEventAthenaPoolCnvDict.h diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/FaserSCT_SpacePointContainerCnv.cxx b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/FaserSCT_SpacePointContainerCnv.cxx new file mode 100644 index 0000000000000000000000000000000000000000..5a63749a53243fc196ac93ccab92c040359e7d4b --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/FaserSCT_SpacePointContainerCnv.cxx @@ -0,0 +1,77 @@ +/* + Copyright (C) 2021 CERN for the benefit of the FASER collaboration + */ + +#include "FaserSCT_SpacePointContainerCnv.h" + +/* +StatusCode FaserSCT_SpacePointContainerCnv::initialize() { + ATH_MSG_INFO("FaserSCT_SpacePointContainerCnv::initialize()"); + + StatusCode sc = FaserSCT_SpacePointContainerCnvBase::initialize(); + if (sc.isFailure()) { + ATH_MSG_FATAL("Cannot initialize cnv base !"); + return StatusCode::FAILURE; + } + + // get StoreGate service. This is needed only for clients + // that register collections directly to the SG instead of adding + // them to the container. + sc = service("StoreGateSvc", m_storeGate); + if (sc.isFailure()) { + ATH_MSG_FATAL("StoreGate service not found !"); + return StatusCode::FAILURE; + } + + // get DetectorStore service + StoreGateSvc* detStore(nullptr); + if (service("DetectorStore", detStore).isFailure()) { + ATH_MSG_FATAL("DetectorStore service not found !"); + return StatusCode::FAILURE; + } else { + ATH_MSG_DEBUG("Found DetectorStore."); + } + + // Get the SCT helper from the detector store + const FaserSCT_ID* idhelper(nullptr); + if (detStore->retrieve(idhelper, "FaserSCT_ID").isFailure()) { + ATH_MSG_FATAL("Could not get FaserSCT_ID helper !"); + return StatusCode::FAILURE; + } else { + ATH_MSG_DEBUG("Found the FaserSCT_ID helper."); + } + ATH_MSG_DEBUG("Converter initialized"); + + return StatusCode::SUCCESS; +} +*/ + +FaserSCT_SpacePointContainer_PERS* +FaserSCT_SpacePointContainerCnv::createPersistent (FaserSCT_SpacePointContainer* transObj) { + ATH_MSG_INFO("FaserSCT_SpacePointContainerCnv::createPersistent()"); + + FaserSCT_SpacePointContainerCnv_PERS converter; + + FaserSCT_SpacePointContainer_PERS* persObj(nullptr); + persObj = converter.createPersistent(transObj, msg()); + return persObj; +} + + +FaserSCT_SpacePointContainer* +FaserSCT_SpacePointContainerCnv::createTransient() { + ATH_MSG_INFO("FaserSCT_SpacePointContainerCnv::createTransient()"); + + static const pool::Guid p0_guid("DB0397F9-A163-496F-BC17-C7E507A1FA50"); + FaserSCT_SpacePointContainer* transObj(nullptr); + + if (compareClassGuid(p0_guid)) { + std::unique_ptr<FaserSCT_SpacePointContainer_PERS> col_vect(poolReadObject<FaserSCT_SpacePointContainer_PERS>()); + FaserSCT_SpacePointContainerCnv_PERS converter; + transObj = converter.createTransient( col_vect.get(), msg()); + } else { + throw std::runtime_error("Unsupported persistent version of FaserSCT_SpacePointContainer"); + } + + return transObj; +} diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/FaserSCT_SpacePointContainerCnv.h b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/FaserSCT_SpacePointContainerCnv.h new file mode 100644 index 0000000000000000000000000000000000000000..0004da8e97d4c208533f063e53bcf79cb0178231 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/FaserSCT_SpacePointContainerCnv.h @@ -0,0 +1,38 @@ +/* + Copyright 2021 CERN for the benefit of the FASER collaboration +*/ + +#ifndef FASERSCT_SPACEPOINTCONTAINERCNV_H +#define FASERSCT_SPACEPOINTCONTAINERCNV_H + +#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" + +#include "TrackerEventTPCnv/FaserSCT_SpacePointContainerCnv_p0.h" + +#include "TrackerSpacePoint/FaserSCT_SpacePointContainer.h" +#include "TrackerEventTPCnv/FaserSCT_SpacePointContainer_p0.h" +#include "TrackerReadoutGeometry/SiDetectorElementCollection.h" +#include "TrackerIdentifier/FaserSCT_ID.h" +#include "StoreGate/StoreGateSvc.h" +#include "StoreGate/ReadCondHandle.h" + + +typedef FaserSCT_SpacePointContainer_p0 FaserSCT_SpacePointContainer_PERS; +typedef FaserSCT_SpacePointContainerCnv_p0 FaserSCT_SpacePointContainerCnv_PERS; + +typedef T_AthenaPoolCustomCnv<FaserSCT_SpacePointContainer, FaserSCT_SpacePointContainer_PERS> FaserSCT_SpacePointContainerCnvBase; + +class FaserSCT_SpacePointContainerCnv : public FaserSCT_SpacePointContainerCnvBase { + friend class CnvFactory<FaserSCT_SpacePointContainerCnv>; + + public: + FaserSCT_SpacePointContainerCnv (ISvcLocator* svcloc) : FaserSCT_SpacePointContainerCnvBase(svcloc, "FaserSCT_SpacePointContainerCnv") {} + + protected: + // Must initialize ID helpers +// virtual StatusCode initialize(); + virtual FaserSCT_SpacePointContainer_PERS* createPersistent (FaserSCT_SpacePointContainer* transObj); + virtual FaserSCT_SpacePointContainer* createTransient (); +}; + +#endif // SPACEPOINTCONTAINERCNV_H diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/SpacePointContainerCnv.cxx b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/SpacePointContainerCnv.cxx deleted file mode 100644 index 4ea69f69454c3e5683f3202e17b844dde7fb4208..0000000000000000000000000000000000000000 --- a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/SpacePointContainerCnv.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright (C) 2021 CERN for the benefit of the FASER collaboration -*/ - -#include "SpacePointContainerCnv.h" - -SpacePointContainer_PERS* -SpacePointContainerCnv::createPersistent (SpacePointContainer* transObj) { - ATH_MSG_INFO("SpacePointContainerCnv::createPersistent()"); - - SpacePointContainerCnv_PERS converter; - - SpacePointContainer_PERS* persObj(nullptr); - persObj = converter.createPersistent(transObj, msg()); - return persObj; -} - - -SpacePointContainer* -SpacePointContainerCnv::createTransient() { - ATH_MSG_INFO("SpacePointContainerCnv::createTransient()"); - - static const pool::Guid p0_guid("DB0397F9-A163-496F-BC17-C7E507A1FA50"); - SpacePointContainer* transObj(nullptr); - - if (compareClassGuid(p0_guid)) { - std::unique_ptr<SpacePointContainer_PERS> col_vect(poolReadObject<SpacePointContainer_PERS>()); - SpacePointContainerCnv_PERS converter; - transObj = converter.createTransient( col_vect.get(), msg()); - } else { - throw std::runtime_error("Unsupported persistent version of SpacePointContainer"); - } - - return transObj; -} diff --git a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/SpacePointContainerCnv.h b/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/SpacePointContainerCnv.h deleted file mode 100644 index 9537ce3aad9f6327535b90dfef7bda79e9c313c3..0000000000000000000000000000000000000000 --- a/Tracker/TrackerEventCnv/TrackerEventAthenaPool/src/SpacePointContainerCnv.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright 2021 CERN for the benefit of the FASER collaboration -*/ - -#ifndef SPACEPOINTCONTAINERCNV_H -#define SPACEPOINTCONTAINERCNV_H - -#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" - -#include "TrackerEventTPCnv/SpacePointContainerCnv_p0.h" - -#include "TrkSpacePoint/SpacePointContainer.h" -#include "TrackerEventTPCnv/SpacePointContainer_p0.h" - -typedef SpacePointContainer_p0 SpacePointContainer_PERS; -typedef SpacePointContainerCnv_p0 SpacePointContainerCnv_PERS; - -typedef T_AthenaPoolCustomCnv<SpacePointContainer, SpacePointContainer_PERS> SpacePointContainerCnvBase; - -class SpacePointContainerCnv : public SpacePointContainerCnvBase { - friend class CnvFactory<SpacePointContainerCnv>; - - public: - SpacePointContainerCnv (ISvcLocator* svcloc) : SpacePointContainerCnvBase(svcloc) {} - - protected: - virtual SpacePointContainer_PERS* createPersistent (SpacePointContainer* transObj); - virtual SpacePointContainer* createTransient (); -}; - -#endif // SPACEPOINTCONTAINERCNV_H diff --git a/Tracker/TrackerEventCnv/TrackerEventCnvTools/CMakeLists.txt b/Tracker/TrackerEventCnv/TrackerEventCnvTools/CMakeLists.txt index 6053d2790392ae986af95db90127dedf1fc5c0b1..31dad792833d8b5aef2f1dc06a36cc676dbaa724 100644 --- a/Tracker/TrackerEventCnv/TrackerEventCnvTools/CMakeLists.txt +++ b/Tracker/TrackerEventCnv/TrackerEventCnvTools/CMakeLists.txt @@ -5,6 +5,6 @@ atlas_subdir( TrackerEventCnvTools ) # Component(s) in the package: atlas_add_component( TrackerEventCnvTools - src/*.cxx + src/*.cxx TrackerEventCnvTools/*h src/components/*.cxx - LINK_LIBRARIES AthenaBaseComps FaserDetDescr IdDictDetDescr Identifier TrackerIdentifier TrackerReadoutGeometry TrackerPrepRawData TrackerRIO_OnTrack StoreGateLib TrkPrepRawData TrkRIO_OnTrack TrkEventCnvToolsLib ) + LINK_LIBRARIES AthenaBaseComps FaserDetDescr IdDictDetDescr Identifier TrackerIdentifier TrackerReadoutGeometry TrackerPrepRawData TrackerSpacePoint TrackerRIO_OnTrack StoreGateLib TrkPrepRawData TrkRIO_OnTrack TrkEventCnvToolsLib ) diff --git a/Tracker/TrackerEventCnv/TrackerEventCnvTools/TrackerEventCnvTools/TrackerSpacePointCnvTool.h b/Tracker/TrackerEventCnv/TrackerEventCnvTools/TrackerEventCnvTools/TrackerSpacePointCnvTool.h new file mode 100644 index 0000000000000000000000000000000000000000..115139c39fc4987243566831004795de5f8cd820 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventCnvTools/TrackerEventCnvTools/TrackerSpacePointCnvTool.h @@ -0,0 +1,51 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + */ + +#ifndef TRACKERSPACEPOINTCNVTOOL_H +#define TRACKERSPACEPOINTCNVTOOL_H + +#include "AthenaBaseComps/AthAlgTool.h" + +#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" +#include "TrackerSpacePoint/FaserSCT_SpacePoint.h" +#include "TrackerReadoutGeometry/SiDetectorElementCollection.h" +#include "StoreGate/ReadCondHandleKey.h" +#include "StoreGate/ReadHandleKey.h" + +#include <utility> + +class Identifier; +class IdentifierHash; + + +namespace Tracker { + /**Helper tool uses to convert Tracker objects in generic tracking custom convertor TrkEventAthenaPool. + + See "mainpage" for discussion of jobOpts. + */ + class TrackerSpacePointCnvTool : public AthAlgTool + { + public: + + TrackerSpacePointCnvTool(const std::string&,const std::string&,const IInterface*); + + ~TrackerSpacePointCnvTool() = default; + + virtual StatusCode initialize() override; + + + std::pair<const Tracker::FaserSCT_Cluster*, const Tracker::FaserSCT_Cluster*> + sctClusterLinks( const Identifier& id1, const IdentifierHash& idHash1, const Identifier& id2, const IdentifierHash& idHash2 ) const ; + void recreateSpacePoint( Tracker::FaserSCT_SpacePoint *sp, const Identifier& id1, const Identifier& id2, const IdentifierHash& idhash1, const IdentifierHash& idhash2 ) const ; + + + private: + + + SG::ReadHandleKey<Tracker::FaserSCT_ClusterContainer> m_sctClusContName{this, "SCT_ClusterContainer", "SCT_Clusters", "SCT Cluster container name"}; //!< location of container of sct clusters + + }; + +} +#endif // MOORETOTRACKTOOL_H diff --git a/Tracker/TrackerEventCnv/TrackerEventCnvTools/src/TrackerSpacePointCnvTool.cxx b/Tracker/TrackerEventCnv/TrackerEventCnvTools/src/TrackerSpacePointCnvTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..8649c37127b23639a993806971cf35e5124d2ea3 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventCnvTools/src/TrackerSpacePointCnvTool.cxx @@ -0,0 +1,86 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + */ + +#include "TrackerEventCnvTools/TrackerSpacePointCnvTool.h" + +#include "Identifier/Identifier.h" +#include "Identifier/IdentifierHash.h" + +#include "TrackerPrepRawData/FaserSCT_ClusterCollection.h" +#include "TrackerRIO_OnTrack/FaserSCT_ClusterOnTrack.h" + +#include <vector> +#include <cassert> +#include <iostream> + +Tracker::TrackerSpacePointCnvTool::TrackerSpacePointCnvTool(const std::string& t, + const std::string& n, + const IInterface* p ) + : + AthAlgTool(t,n,p) +{ +} + +StatusCode Tracker::TrackerSpacePointCnvTool::initialize() { + + StatusCode sc = AthAlgTool::initialize(); + if (sc.isFailure()) return sc; + + ATH_CHECK( m_sctClusContName.initialize() ); + + return sc; + +} + +void Tracker::TrackerSpacePointCnvTool::recreateSpacePoint( Tracker::FaserSCT_SpacePoint *sp, const Identifier& id1, const Identifier& id2, const IdentifierHash& idhash1, const IdentifierHash& idhash2 ) const { + auto clusters= sctClusterLinks( id1,idhash1, id2,idhash2); + sp->setClusList(clusters); + return; +} + +std::pair<const Tracker::FaserSCT_Cluster*, const Tracker::FaserSCT_Cluster*> +Tracker::TrackerSpacePointCnvTool::sctClusterLinks( const Identifier& id1, const IdentifierHash & idHash1, const Identifier& id2, const IdentifierHash& idHash2 ) const { + const Tracker::FaserSCT_Cluster* clus1=nullptr; + const Tracker::FaserSCT_Cluster* clus2=nullptr; + // need to retrieve pointers to collections + // retrieve Pixel cluster container + + // obviously this can be optimised! EJWM + SG::ReadHandle<Tracker::FaserSCT_ClusterContainer> h_sctClusCont(m_sctClusContName); + if (!h_sctClusCont.isValid()) { + ATH_MSG_ERROR("FaserSCT Cluster container not found at "<<m_sctClusContName); + return std::make_pair(clus1,clus2); + } else { + ATH_MSG_DEBUG("FaserSCT Cluster Container found" ); + } + const Tracker::FaserSCT_ClusterCollection *ptr1 = h_sctClusCont->indexFindPtr(idHash1); + const Tracker::FaserSCT_ClusterCollection *ptr2 = h_sctClusCont->indexFindPtr(idHash2); + // if we find PRD, then recreate link + if (ptr1!=nullptr) { + //loop though collection to find matching PRD. + Tracker::FaserSCT_ClusterCollection::const_iterator collIt = ptr1->begin(); + Tracker::FaserSCT_ClusterCollection::const_iterator collItEnd = ptr1->end(); + // there MUST be a faster way to do this!! + for ( ; collIt!=collItEnd; collIt++) { + if ( (*collIt)->identify()==id1 ) + clus1= &(**collIt); + } + } + // if we find PRD, then recreate link + if (ptr2!=nullptr) { + //loop though collection to find matching PRD. + Tracker::FaserSCT_ClusterCollection::const_iterator collIt = ptr2->begin(); + Tracker::FaserSCT_ClusterCollection::const_iterator collItEnd = ptr2->end(); + // there MUST be a faster way to do this!! + for ( ; collIt!=collItEnd; collIt++) { + if ( (*collIt)->identify()==id2 ) + clus2= &(**collIt); + } + } + if(clus1==nullptr||clus2==nullptr) + ATH_MSG_DEBUG("No matching PRD found" ); + return std::make_pair(clus1,clus2); +} + + diff --git a/Tracker/TrackerEventCnv/TrackerEventCnvTools/src/components/TrackerEventCnvTool_entries.cxx b/Tracker/TrackerEventCnv/TrackerEventCnvTools/src/components/TrackerEventCnvTool_entries.cxx index 3d7144a021d532b496ba19bcba2422c01936ba11..73857c22607ce210ee2480e456e57e70a7796d5b 100644 --- a/Tracker/TrackerEventCnv/TrackerEventCnvTools/src/components/TrackerEventCnvTool_entries.cxx +++ b/Tracker/TrackerEventCnv/TrackerEventCnvTools/src/components/TrackerEventCnvTool_entries.cxx @@ -1,6 +1,8 @@ #include "TrackerEventCnvTools/TrackerEventCnvTool.h" +#include "TrackerEventCnvTools/TrackerSpacePointCnvTool.h" using namespace Tracker; DECLARE_COMPONENT( TrackerEventCnvTool ) +DECLARE_COMPONENT( TrackerSpacePointCnvTool) diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/CMakeLists.txt b/Tracker/TrackerEventCnv/TrackerEventTPCnv/CMakeLists.txt index 259453c94f261532d0e1054ace7259760fada14f..d097ad117081d6de28d584b3d8ea20fb9ba2cf40 100644 --- a/Tracker/TrackerEventCnv/TrackerEventTPCnv/CMakeLists.txt +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/CMakeLists.txt @@ -21,7 +21,7 @@ atlas_add_tpcnv_library( TrackerEventTPCnv TrkPrepRawData TrkSpacePoint TrackerSpacePoint - PRIVATE_LINK_LIBRARIES AthenaBaseComps AthenaKernel + PRIVATE_LINK_LIBRARIES AthenaBaseComps AthenaKernel EventPrimitives TrackerReadoutGeometry TrkSurfaces TrkEventPrimitives TrkMeasurementBase TrkRIO_OnTrack EventContainers ) diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePointCnv_p0.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePointCnv_p0.h new file mode 100644 index 0000000000000000000000000000000000000000..5b0b2afcb3ba4185dc003659c1d45e6d2d613eec --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePointCnv_p0.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2021 CERN for the benefit of the FASER collaboration +*/ + +#ifndef FASERSCT_SPACEPOINTCNV_P0_H +#define FASERSCT_SPACEPOINTCNV_P0_H + +#include "TrackerSpacePoint/FaserSCT_SpacePoint.h" +#include "TrackerEventTPCnv/FaserSCT_SpacePoint_p0.h" + +#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h" +#include "DataModelAthenaPool/ElementLinkCnv_p1.h" +#include "AthLinks/ElementLink.h" +//#include "TrackerEventCnvTools/TrackerSpacePointCnvTool.h" +#include "TrackerPrepRawData/FaserSCT_Cluster.h" +#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" +#include "StoreGate/ReadCondHandleKey.h" +#include "StoreGate/ReadHandleKey.h" +#include "StoreGate/StoreGateSvc.h" + +class FaserSCT_SpacePointCnv_p0 : public T_AthenaPoolTPCnvBase<Tracker::FaserSCT_SpacePoint, FaserSCT_SpacePoint_p0> { + public: + FaserSCT_SpacePointCnv_p0():m_sctClusContName{"SCT_ClusterContainer"} {}; + + virtual void persToTrans(const FaserSCT_SpacePoint_p0* persObj, + Tracker::FaserSCT_SpacePoint* transObj, + MsgStream& log); + + virtual void transToPers(const Tracker::FaserSCT_SpacePoint* transObj, + FaserSCT_SpacePoint_p0* persObj, + MsgStream& log); + virtual StatusCode initialize( MsgStream& log ); + + ElementLinkCnv_p1<ElementLink<Tracker::FaserSCT_ClusterContainer>> m_elCnv; + private: + SG::ReadHandleKey<Tracker::FaserSCT_ClusterContainer> m_sctClusContName; +// ToolHandle<Tracker::TrackerSpacePointCnvTool> m_cnvtool{this, "SpacePointCnvTool","SpacePointCnvTool"}; + +}; + +#endif // SPACEPOINTCNV_P0_H diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePointCollection_p0.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePointCollection_p0.h new file mode 100644 index 0000000000000000000000000000000000000000..56f1b8574a1f08458ab37132687093b79b70ad5b --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePointCollection_p0.h @@ -0,0 +1,29 @@ +/* + Copyright 2021 CERN for the benefit of the FASER collaboration +*/ + +#ifndef FASERSCT_SPACEPOINTCOLLECTION_P0_H +#define FASERSCT_SPACEPOINTCOLLECTION_P0_H + +#include <vector> + +class FaserSCT_SpacePointCollection_p0 { + public: + FaserSCT_SpacePointCollection_p0(); + friend class FaserSCT_SpacePointClusterCnv_p0; + + unsigned int m_idHash; + unsigned long long m_id; + unsigned int m_begin; + unsigned int m_end; + unsigned short m_size; +}; + +inline +FaserSCT_SpacePointCollection_p0::FaserSCT_SpacePointCollection_p0() : m_idHash(0), +m_id(0), +m_begin(0), +m_end(0), +m_size(0){ } + +#endif // SPACEPOINTCOLLECTION_P0_H diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePointContainerCnv_p0.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePointContainerCnv_p0.h new file mode 100644 index 0000000000000000000000000000000000000000..be233dc53618224c46ba209f29ac41fdd8119b93 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePointContainerCnv_p0.h @@ -0,0 +1,29 @@ +/* + Copyright 2021 CERN for the benefit of the FASER collaboration +*/ + +#ifndef FASERSCT_SPACEPOINTCONTAINERCNV_P0_H +#define FASERSCT_SPACEPOINTCONTAINERCNV_P0_H + +#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h" + +#include "TrackerSpacePoint/FaserSCT_SpacePointContainer.h" +#include "TrackerEventTPCnv/FaserSCT_SpacePointContainer_p0.h" + +class FaserSCT_SpacePointContainerCnv_p0 : public T_AthenaPoolTPCnvBase<FaserSCT_SpacePointContainer, FaserSCT_SpacePointContainer_p0> { + public: + FaserSCT_SpacePointContainerCnv_p0() {}; + + virtual void persToTrans(const FaserSCT_SpacePointContainer_p0* persObj, + FaserSCT_SpacePointContainer* transObj, + MsgStream& log); + + virtual void transToPers(const FaserSCT_SpacePointContainer* transObj, + FaserSCT_SpacePointContainer_p0* persObj, + MsgStream& log); + + virtual FaserSCT_SpacePointContainer* createTransient(const FaserSCT_SpacePointContainer_p0* persObj, MsgStream& log); + private: +}; + +#endif // SPACEPOINTCONTAINERCNV_P0_H diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePointContainer_p0.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePointContainer_p0.h new file mode 100644 index 0000000000000000000000000000000000000000..86bc426cd4c3fb74f6120f11b125eda88d8cdc34 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePointContainer_p0.h @@ -0,0 +1,26 @@ +/* + Copyright (C) 2021 CERN for the benefit of the FASER collaboration +*/ + +#ifndef FASERSCT_SPACEPOINTCONTAINER_P0_H +#define FASERSCT_SPACEPOINTCONTAINER_P0_H + +#include <vector> +#include "TrackerEventTPCnv/FaserSCT_SpacePoint_p0.h" +#include "TrackerEventTPCnv/FaserSCT_SpacePointCollection_p0.h" + +class FaserSCT_SpacePointContainer_p0 { + public: + FaserSCT_SpacePointContainer_p0(); + friend class FaserSCT_SpacePointContainerCnv_p0; + private: + std::vector<FaserSCT_SpacePoint_p0> m_spacepoints; + std::vector<FaserSCT_SpacePointCollection_p0> m_spacepoint_collections; +}; + +inline FaserSCT_SpacePointContainer_p0::FaserSCT_SpacePointContainer_p0() { + m_spacepoints.clear(); + m_spacepoint_collections.clear(); +} + +#endif // SPACEPOINTCONTAINER_P0_H diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePoint_p0.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePoint_p0.h new file mode 100644 index 0000000000000000000000000000000000000000..4e3a4e0c14dfc4757a424cb4a6b6976c11f40a2e --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/FaserSCT_SpacePoint_p0.h @@ -0,0 +1,63 @@ +/* + Copyright 2021 CERN for the benefit of the FASER collaboration +*/ + +#ifndef FASERSCT_SPACEPOINT_P0_H +#define FASERSCT_SPACEPOINT_P0_H +#include "Identifier/IdentifierHash.h" +#include "DataModelAthenaPool/ElementLink_p1.h" + +class FaserSCT_SpacePoint_p0 { + public: + FaserSCT_SpacePoint_p0(); + friend class FaserSCT_SpacePointCnv_p0; + + private: + unsigned int m_idHash0; + unsigned int m_idHash1; + unsigned long long m_id0; + unsigned long long m_id1; + + float m_localpos_x; + float m_localpos_y; + float m_localcov00; + float m_localcov01; + float m_localcov11; + + float m_pos_x; + float m_pos_y; + float m_pos_z; + + float m_cov00; + float m_cov01; + float m_cov02; + float m_cov11; + float m_cov12; + float m_cov22; + ElementLinkInt_p1 m_link1; + ElementLinkInt_p1 m_link2; +}; + +inline +FaserSCT_SpacePoint_p0::FaserSCT_SpacePoint_p0() : + m_idHash0(0), + m_idHash1(0), + m_id0(0), + m_id1(0), + m_localpos_x(0), + m_localpos_y(0), + m_localcov00(0), + m_localcov01(0), + m_localcov11(0), + m_pos_x(0), + m_pos_y(0), + m_pos_z(0), + m_cov00(0), + m_cov01(0), + m_cov02(0), + m_cov11(0), + m_cov12(0), + m_cov22(0) +{} + +#endif // SPACEPOINT_P0_H diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/SpacePointCnv_p0.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/SpacePointCnv_p0.h deleted file mode 100644 index 10c3090e3c98fa4a2cfb14afaa0a81b22cdb6900..0000000000000000000000000000000000000000 --- a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/SpacePointCnv_p0.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - Copyright (C) 2021 CERN for the benefit of the FASER collaboration -*/ - -#ifndef SPACEPOINTCNV_P0_H -#define SPACEPOINTCNV_P0_H - -#include "TrackerSpacePoint/FaserSCT_SpacePoint.h" -#include "TrackerEventTPCnv/SpacePoint_p0.h" - -#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h" - -class SpacePointCnv_p0 : public T_AthenaPoolTPCnvBase<Tracker::FaserSCT_SpacePoint, SpacePoint_p0> { - public: - SpacePointCnv_p0() {}; - - virtual void persToTrans(const SpacePoint_p0* persObj, - Tracker::FaserSCT_SpacePoint* transObj, - MsgStream& log); - - virtual void transToPers(const Tracker::FaserSCT_SpacePoint* transObj, - SpacePoint_p0* persObj, - MsgStream& log); -}; - -#endif // SPACEPOINTCNV_P0_H diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/SpacePointCollection_p0.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/SpacePointCollection_p0.h deleted file mode 100644 index 3d71dcf8f1f15bd0bb5628a743f3af614f354e7a..0000000000000000000000000000000000000000 --- a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/SpacePointCollection_p0.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright 2021 CERN for the benefit of the FASER collaboration -*/ - -#ifndef SPACEPOINTCOLLECTION_P0_H -#define SPACEPOINTCOLLECTION_P0_H - -#include <vector> - -class SpacePointCollection_p0 { - public: - SpacePointCollection_p0(); - friend class SpacePointClusterCnv_p0; - - unsigned short m_idHash; - unsigned short m_size; -}; - -inline -SpacePointCollection_p0::SpacePointCollection_p0() : m_idHash(0) { } - -#endif // SPACEPOINTCOLLECTION_P0_H diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/SpacePointContainerCnv_p0.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/SpacePointContainerCnv_p0.h deleted file mode 100644 index 2da19a3ce5880820fcf39fab7cac0a40ce3ffa4a..0000000000000000000000000000000000000000 --- a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/SpacePointContainerCnv_p0.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - Copyright 2021 CERN for the benefit of the FASER collaboration -*/ - -#ifndef SPACEPOINTCONTAINERCNV_P0_H -#define SPACEPOINTCONTAINERCNV_P0_H - -#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h" - -#include "TrkSpacePoint/SpacePointContainer.h" -#include "TrackerEventTPCnv/SpacePointContainer_p0.h" - -class SpacePointContainerCnv_p0 : public T_AthenaPoolTPCnvBase<SpacePointContainer, SpacePointContainer_p0> { - public: - SpacePointContainerCnv_p0() {}; - - virtual void persToTrans(const SpacePointContainer_p0* persObj, - SpacePointContainer* transObj, - MsgStream& log); - - virtual void transToPers(const SpacePointContainer* transObj, - SpacePointContainer_p0* persObj, - MsgStream& log); -}; - -#endif // SPACEPOINTCONTAINERCNV_P0_H diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/SpacePointContainer_p0.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/SpacePointContainer_p0.h deleted file mode 100644 index 0a9cdbe4d8da94c47e96797a486649073ff02ebf..0000000000000000000000000000000000000000 --- a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/SpacePointContainer_p0.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - Copyright (C) 2021 CERN for the benefit of the FASER collaboration -*/ - -#ifndef SPACEPOINTCONTAINER_P0_H -#define SPACEPOINTCONTAINER_P0_H - -#include <vector> -#include "TrackerEventTPCnv/SpacePoint_p0.h" -#include "TrackerEventTPCnv/SpacePointCollection_p0.h" - -class SpacePointContainer_p0 { - public: - SpacePointContainer_p0(); - friend class SpacePointContainerCnv_p0; - private: - std::vector<SpacePoint_p0> m_spacepoints; - std::vector<SpacePointCollection_p0> m_spacepoint_collections; -}; - -inline SpacePointContainer_p0::SpacePointContainer_p0() { - m_spacepoints.clear(); - m_spacepoint_collections.clear(); -} - -#endif // SPACEPOINTCONTAINER_P0_H diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/SpacePoint_p0.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/SpacePoint_p0.h deleted file mode 100644 index 4a648fa58dd681f52f59f91ecac25635b16b7f30..0000000000000000000000000000000000000000 --- a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/SpacePoint_p0.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - Copyright 2021 CERN for the benefit of the FASER collaboration -*/ - -#ifndef SPACEPOINT_P0_H -#define SPACEPOINT_P0_H - -class SpacePoint_p0 { - public: - SpacePoint_p0(); - friend class SpacePointCnv_p0; - - private: - unsigned int m_idHash0; - unsigned int m_idHash1; - - float m_pos_x; - float m_pos_y; - float m_pos_z; - - float m_cov00; - float m_cov01; - float m_cov02; - float m_cov11; - float m_cov12; - float m_cov22; -}; - -inline -SpacePoint_p0::SpacePoint_p0() : - m_idHash0(0), - m_idHash1(0), - m_pos_x(0), - m_pos_y(0), - m_pos_z(0), - m_cov00(0), - m_cov01(0), - m_cov02(0), - m_cov11(0), - m_cov12(0), - m_cov22(0) -{} - -#endif // SPACEPOINT_P0_H diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerEventTPCnvDict.h b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerEventTPCnvDict.h index 1407bd063facddcf4166d72b55c2ce5389adb072..a025de2f061d627315f7ca781ab06e725dd1b174 100644 --- a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerEventTPCnvDict.h +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/TrackerEventTPCnvDict.h @@ -42,9 +42,9 @@ // #include "InDetEventTPCnv/InDetLowBetaInfo/InDetLowBetaContainer_p1.h" // #include "InDetEventTPCnv/InDetLowBetaInfo/InDetLowBetaCandidate_tlp1.h" // #include "InDetEventTPCnv/InDetLowBetaInfo/InDetLowBetaContainer_tlp1.h" -#include "TrackerEventTPCnv/SpacePoint_p0.h" -#include "TrackerEventTPCnv/SpacePointCollection_p0.h" -#include "TrackerEventTPCnv/SpacePointContainer_p0.h" +#include "TrackerEventTPCnv/FaserSCT_SpacePoint_p0.h" +#include "TrackerEventTPCnv/FaserSCT_SpacePointCollection_p0.h" +#include "TrackerEventTPCnv/FaserSCT_SpacePointContainer_p0.h" namespace TrackerEventTPCnvDict { struct tmp @@ -63,8 +63,9 @@ namespace TrackerEventTPCnvDict { // std::vector< InDet::CompetingSCT_ClustersOnTrack_p1> m_v10; // std::vector< InDet::CompetingTRT_DriftCirclesOnTrack_p1> m_v11; // std::vector< InDetLowBetaCandidate_p1> m_v12; - std::vector<SpacePoint_p0> m_v13; - std::vector<SpacePointCollection_p0> m_v14; + std::vector<FaserSCT_SpacePoint_p0> m_v13; + std::vector<FaserSCT_SpacePointCollection_p0> m_v14; + std::vector<FaserSCT_SpacePointContainer_p0> m_v15; }; } //> namespace TrackerEventTPCnvDict diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/selection.xml b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/selection.xml index efe77176618dbe588024e7bd8df2dcde8867e08d..3530369ae3c1eb2bc56a47d2809c48796e37eb23 100644 --- a/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/selection.xml +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/TrackerEventTPCnv/selection.xml @@ -75,11 +75,11 @@ <!-- <class name="std::pair<unsigned int,std::vector<unsigned int> >" /> --> <class name="std::vector< std::pair<unsigned int, std::vector<unsigned int> > >" /> - <!-- SpacePoint --> - <class name="SpacePoint_p0" /> - <class name="std::vector<SpacePoint_p0>" /> - <class name="SpacePointCollection_p0" /> - <class name="std::vector<SpacePointCollection_p0>" /> - <class name="SpacePointContainer_p0" id="DB0397F9-A163-496F-BC17-C7E507A1FA50" /> + <!-- FaserSCT_SpacePoint --> + <class name="FaserSCT_SpacePoint_p0" /> + <class name="std::vector<FaserSCT_SpacePoint_p0>" /> + <class name="FaserSCT_SpacePointCollection_p0" /> + <class name="std::vector<FaserSCT_SpacePointCollection_p0>" /> + <class name="FaserSCT_SpacePointContainer_p0" id="DB0397F9-A163-496F-BC17-C7E507A1FA50" /> -</lcgdict> \ No newline at end of file +</lcgdict> diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/FaserSCT_SpacePointCnv_p0.cxx b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/FaserSCT_SpacePointCnv_p0.cxx new file mode 100644 index 0000000000000000000000000000000000000000..b6cbc9da2508bd734634af3702165b262885ceff --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/FaserSCT_SpacePointCnv_p0.cxx @@ -0,0 +1,144 @@ +/* + Copyright (C) 2021 CERN for the benefit of the FASER collaboration + */ + +#include "TrackerEventTPCnv/FaserSCT_SpacePointCnv_p0.h" +// Athena +#include "AthLinks/ElementLink.h" + +#include "Identifier/Identifier.h" +#include "TrackerPrepRawData/FaserSCT_Cluster.h" +#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" + +StatusCode FaserSCT_SpacePointCnv_p0::initialize(MsgStream& log ) { + +// ISvcLocator* svcLocator = Gaudi::svcLocator(); + + // Get the messaging service, print where you are + log << MSG::INFO << "FaserSCT_SpacePointCnv::initialize()" << endmsg; + if(m_sctClusContName.initialize()!=StatusCode::SUCCESS) + log << MSG::WARNING<< "FaserSCT_SpacePointCnv failed to initialize the sct cluster container" << endmsg; + + return StatusCode::SUCCESS; +} + +void +FaserSCT_SpacePointCnv_p0::persToTrans(const FaserSCT_SpacePoint_p0* persObj, Tracker::FaserSCT_SpacePoint* transObj, MsgStream& log) { + + if(this->initialize(log)!=StatusCode::SUCCESS){ + log << MSG::WARNING << "failed to initialize FaserSCT_SpacePointCnv_p0" << endmsg; + return; + } + + ElementLink<Tracker::FaserSCT_ClusterContainer> link1; + ElementLink<Tracker::FaserSCT_ClusterContainer> link2; + m_elCnv.persToTrans(&persObj->m_link1,&link1,log); + m_elCnv.persToTrans(&persObj->m_link2,&link2,log); + Amg::Vector3D pos(persObj->m_pos_x,persObj->m_pos_y,persObj->m_pos_z); + Amg::Vector2D localpos(persObj->m_localpos_x,persObj->m_localpos_y); + Amg::MatrixX localcov(2,2); + localcov<< + persObj->m_localcov00, persObj->m_localcov01, + persObj->m_localcov01, persObj->m_localcov11; + Amg::MatrixX cov(3,3); + cov<< + persObj->m_cov00, persObj->m_cov01, persObj->m_cov02, + persObj->m_cov01, persObj->m_cov11, persObj->m_cov12, + persObj->m_cov02, persObj->m_cov12, persObj->m_cov22; + const Tracker::FaserSCT_Cluster* clus1=nullptr; + const Tracker::FaserSCT_Cluster* clus2=nullptr; + + SG::ReadHandle<Tracker::FaserSCT_ClusterContainer> h_sctClusCont(m_sctClusContName); + if (!h_sctClusCont.isValid()) { + log<<MSG::ERROR<<"SCT Cluster container not found at "<<m_sctClusContName<<endmsg; + return ; + } else { + log<<MSG::DEBUG<<"SCT Cluster Container found" <<endmsg; + } + const Tracker::FaserSCT_ClusterCollection *ptr = h_sctClusCont->indexFindPtr(IdentifierHash(persObj->m_idHash0)); + // if we find PRD, then recreate link + if (ptr!=nullptr) { + //loop though collection to find matching PRD. + Tracker::FaserSCT_ClusterCollection::const_iterator collIt= ptr->begin(); + Tracker::FaserSCT_ClusterCollection::const_iterator collItEnd = ptr->end(); + // there MUST be a faster way to do this!! + for ( ; collIt!=collItEnd; ++collIt) { + if ( (*collIt)->identify().get_compact()==persObj->m_id0 ) clus1= &(**collIt); + } + } + + const Tracker::FaserSCT_ClusterCollection *ptr1 = h_sctClusCont->indexFindPtr(IdentifierHash(persObj->m_idHash1)); + // if we find PRD, then recreate link + if (ptr1!=nullptr) { + //loop though collection to find matching PRD. + Tracker::FaserSCT_ClusterCollection::const_iterator collIt= ptr1->begin(); + Tracker::FaserSCT_ClusterCollection::const_iterator collItEnd = ptr1->end(); + // there MUST be a faster way to do this!! + for ( ; collIt!=collItEnd; ++collIt) { + if ( (*collIt)->identify().get_compact()==persObj->m_id1 ) clus2= &(**collIt); + } + } + /* + m_cnvtool->recreateSpacePoint(transObj,persObj->m_id0,persObj->m_idHash0,persObj->m_id1,persObj->m_idHash1); + */ + // if(clus2==nullptr)std::cout<<"didnot found the second cluster"<<std::endl; + if(clus1==nullptr||clus2==nullptr){ + log<<MSG::DEBUG<<"could not found the clusters"<<endmsg; + return; + } + // const TrackerDD::SiDetectorElement * de1 = elements->getDetectorElement( persObj->m_idHash0); + // const TrackerDD::SiDetectorElement * de2 = elements->getDetectorElement( persObj->m_idHash1); + // Tracker::FaserSCT_Cluster* clus1=const_cast<Tracker::FaserSCT_Cluster*>(link1.cachedElement()); + // Tracker::FaserSCT_Cluster* clus2=const_cast<Tracker::FaserSCT_Cluster*>(link2.cachedElement()); + // clus1->setDetectorElement(de1); + // clus2->setDetectorElement(de2); + // *transObj=Tracker::FaserSCT_SpacePoint(std::make_pair(persObj->m_idHash0,persObj->m_idHash1),&pos,&cov,&localpos,&localcov,link1,link2); + const std::pair<const Tracker::FaserSCT_Cluster*, const Tracker::FaserSCT_Cluster*> cluslist(clus1,clus2); + // transObj=new Tracker::FaserSCT_SpacePoint(std::make_pair(IdentifierHash(persObj->m_idHash0),IdentifierHash(persObj->m_idHash1)),&pos,&cluslist); + // //*transObj=Tracker::FaserSCT_SpacePoint(std::make_pair(IdentifierHash(persObj->m_idHash0),IdentifierHash(persObj->m_idHash1)),&pos,&cluslist); + // transObj->m_elelink1=link1; + // transObj->m_elelink1=link2; + transObj->setElemIdList(std::make_pair(IdentifierHash(persObj->m_idHash0),IdentifierHash(persObj->m_idHash1))); + transObj->setClusList(cluslist); + transObj->setGlobalParameters(pos); + transObj->setGlobalCovariance(cov); + transObj->setLocalCovariance(localcov); + transObj->setLocalParameters(localpos); + +} + +void +FaserSCT_SpacePointCnv_p0::transToPers(const Tracker::FaserSCT_SpacePoint* transObj, FaserSCT_SpacePoint_p0* persObj, MsgStream& /*log*/) { + + auto idHashs = transObj->elementIdList(); + persObj->m_idHash0 = idHashs.first; + persObj->m_idHash1 = idHashs.second; + + auto globalPosition = transObj->globalPosition(); + persObj->m_pos_x = globalPosition.x(); + persObj->m_pos_y = globalPosition.y(); + persObj->m_pos_z = globalPosition.z(); + + auto cov = transObj->globCovariance(); + persObj->m_cov00 = cov(0,0); + persObj->m_cov01 = cov(0,1); + persObj->m_cov02 = cov(0,2); + persObj->m_cov11 = cov(1,1); + persObj->m_cov12 = cov(1,2); + persObj->m_cov22 = cov(2,2); + + persObj->m_id0= transObj->clusterList().first->identify().get_compact(); + persObj->m_id1= transObj->clusterList().second->identify().get_compact(); + auto localparam=transObj->localParameters(); + persObj->m_localpos_x = localparam.x(); + persObj->m_localpos_y = localparam.y(); + auto localcov = transObj->localCovariance(); + persObj->m_localcov00 = cov(0,0); + persObj->m_localcov01 = cov(0,1); + persObj->m_localcov11 = cov(1,2); + + persObj->m_link1.m_contName = transObj->getElementLink1()->dataID(); + persObj->m_link1.m_elementIndex = transObj->getElementLink1()->index(); + persObj->m_link2.m_contName = transObj->getElementLink2()->dataID(); + persObj->m_link2.m_elementIndex = transObj->getElementLink2()->index(); +} diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/FaserSCT_SpacePointContainerCnv_p0.cxx b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/FaserSCT_SpacePointContainerCnv_p0.cxx new file mode 100644 index 0000000000000000000000000000000000000000..80fc411dcd1469d3af8a1c7bc5c5f781ead630e3 --- /dev/null +++ b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/FaserSCT_SpacePointContainerCnv_p0.cxx @@ -0,0 +1,99 @@ +/* + Copyright (C) 2021 CERN for the benefit of the FASER collaboration + */ + +#include "TrackerEventTPCnv/FaserSCT_SpacePointContainerCnv_p0.h" + +#include "TrackerEventTPCnv/FaserSCT_SpacePoint_p0.h" +#include "TrackerEventTPCnv/FaserSCT_SpacePointCollection_p0.h" +#include "TrackerEventTPCnv/FaserSCT_SpacePointCnv_p0.h" +#include "TrackerSpacePoint/FaserSCT_SpacePointContainer.h" +#include "AthenaKernel/errorcheck.h" +#include "GaudiKernel/StatusCode.h" + +void FaserSCT_SpacePointContainerCnv_p0::persToTrans(const FaserSCT_SpacePointContainer_p0* persObj, FaserSCT_SpacePointContainer* transObj, MsgStream& log) { + + FaserSCT_SpacePointCollection* coll = 0; + FaserSCT_SpacePointCnv_p0 chanCnv; + unsigned int collBegin(0); + + log<<MSG::VERBOSE<<" create Spacepoint container with "<<persObj->m_spacepoint_collections.size()<<" collections"<<endmsg; + + for (unsigned int icoll = 0; icoll < persObj->m_spacepoint_collections.size(); ++icoll) { + const FaserSCT_SpacePointCollection_p0& pcoll = persObj->m_spacepoint_collections[icoll]; + IdentifierHash collIDHash(IdentifierHash(pcoll.m_idHash)); + coll = new FaserSCT_SpacePointCollection(collIDHash); + coll->setIdentifier(Identifier(pcoll.m_id)); + log<<MSG::VERBOSE<<" create Spacepoint collection with identifier "<<pcoll.m_id<<" , and hash "<<pcoll.m_idHash<<" , and size ="<<pcoll.m_end - pcoll.m_begin<<endmsg; + unsigned int nchans = pcoll.m_end - pcoll.m_begin; + coll->resize(nchans); + for (unsigned int ichan = 0; ichan < nchans; ++ ichan) { + const FaserSCT_SpacePoint_p0* pchan=&(persObj->m_spacepoints[ichan+collBegin]); + Tracker::FaserSCT_SpacePoint* transSP=new Tracker::FaserSCT_SpacePoint(); + chanCnv.persToTrans(pchan, transSP, log ); + if(transSP==nullptr) + log << MSG::INFO<<"did not found space"<<endmsg; + (*coll)[ichan]=transSP; + } + collBegin +=nchans; + StatusCode sc = transObj->addCollection(coll, collIDHash); + if (sc.isFailure()) + throw std::runtime_error("Failed to add collection to ID Container"); + + } + +} + +void FaserSCT_SpacePointContainerCnv_p0::transToPers(const FaserSCT_SpacePointContainer* transObj, FaserSCT_SpacePointContainer_p0* persObj, MsgStream& log) { + log << MSG::DEBUG<< "FaserSCT_SpacePointContainerCnv_p0::transToPers()" << endmsg; + + FaserSCT_SpacePointCnv_p0 spCnv; + typedef FaserSCT_SpacePointContainer TRANS; + + TRANS::const_iterator spColl; + TRANS::const_iterator spCollEnd = transObj->end(); + unsigned int spCollId; + unsigned int spId = 0; + unsigned int nextSpId = 0; + //unsigned int lastIdHash = 0; + + // resize data vectors + persObj->m_spacepoint_collections.resize(transObj->numberOfCollections()); + int n_spacepoints = 0; + for (spColl = transObj->begin(); spColl != spCollEnd; spColl++) { + n_spacepoints += (*spColl)->size(); + } + persObj->m_spacepoints.resize(n_spacepoints); + + for (spColl = transObj->begin(), spCollId = 0; spColl != spCollEnd; ++spCollId, ++spColl) { + // create persitent representation of FaserSCT_SpacePointCollections + const FaserSCT_SpacePointCollection& collection = **spColl; + FaserSCT_SpacePointCollection_p0& pcollection = persObj->m_spacepoint_collections[spCollId]; + pcollection.m_size = collection.size(); + pcollection.m_idHash = (unsigned int)collection.identifyHash(); + pcollection.m_id = collection.identify().get_compact(); + log<<MSG::VERBOSE<<"Trans to Pers: create Spacepoint collection with identifier "<<collection.identify().get_compact()<<" , and hash "<<collection.identifyHash()<<" , and size ="<<collection.size()<<endmsg; + //lastIdHash = collection.identifyHash(); + + spId = nextSpId; + nextSpId += collection.size(); + + pcollection.m_begin=spId; + pcollection.m_end=nextSpId; + + // create persitent representation of FaserSCT_SpacePoints + for (std::size_t i = 0; i < collection.size(); ++i) { + FaserSCT_SpacePoint_p0* persSP = &(persObj->m_spacepoints[i + spId]); + const Tracker::FaserSCT_SpacePoint* transSP = dynamic_cast<const Tracker::FaserSCT_SpacePoint*>(collection[i]); + spCnv.transToPers(transSP, persSP, log); + } + } +} + +//================================================================ +FaserSCT_SpacePointContainer* FaserSCT_SpacePointContainerCnv_p0::createTransient(const FaserSCT_SpacePointContainer_p0* persObj, MsgStream& log) { + log << MSG::DEBUG << "FaserSCT_SpacePointContainerCnv_p3::createTransient called " << endmsg; + std::unique_ptr<FaserSCT_SpacePointContainer> trans(std::make_unique<FaserSCT_SpacePointContainer>(persObj->m_spacepoint_collections.size())); + persToTrans(persObj, trans.get(), log); + return(trans.release()); +} diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/SpacePointCnv_p0.cxx b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/SpacePointCnv_p0.cxx deleted file mode 100644 index 63dba18507be95fe780a27de401cc6ac01a57027..0000000000000000000000000000000000000000 --- a/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/SpacePointCnv_p0.cxx +++ /dev/null @@ -1,33 +0,0 @@ -/* - Copyright (C) 2021 CERN for the benefit of the FASER collaboration -*/ - -#include "TrackerEventTPCnv/SpacePointCnv_p0.h" - -void -SpacePointCnv_p0::persToTrans(const SpacePoint_p0* persObj, Tracker::FaserSCT_SpacePoint* transObj, MsgStream& /*log*/) { - - // TODO - -} - -void -SpacePointCnv_p0::transToPers(const Tracker::FaserSCT_SpacePoint* transObj, SpacePoint_p0* persObj, MsgStream& /*log*/) { - - auto idHashs = transObj->elementIdList(); - persObj->m_idHash0 = idHashs.first; - persObj->m_idHash1 = idHashs.second; - - auto globalPosition = transObj->globalPosition(); - persObj->m_pos_x = globalPosition.x(); - persObj->m_pos_y = globalPosition.y(); - persObj->m_pos_z = globalPosition.z(); - - auto cov = transObj->globCovariance(); - persObj->m_cov00 = cov(0,0); - persObj->m_cov01 = cov(0,1); - persObj->m_cov02 = cov(0,2); - persObj->m_cov11 = cov(1,1); - persObj->m_cov12 = cov(2,2); - persObj->m_cov22 = cov(2,2); -} diff --git a/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/SpacePointContainerCnv_p0.cxx b/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/SpacePointContainerCnv_p0.cxx deleted file mode 100644 index 88c0f0b220c45bac9322484e027707ada331bc27..0000000000000000000000000000000000000000 --- a/Tracker/TrackerEventCnv/TrackerEventTPCnv/src/SpacePointContainerCnv_p0.cxx +++ /dev/null @@ -1,56 +0,0 @@ -/* - Copyright (C) 2021 CERN for the benefit of the FASER collaboration -*/ - -#include "TrackerEventTPCnv/SpacePointContainerCnv_p0.h" - -#include "TrackerEventTPCnv/SpacePoint_p0.h" -#include "TrackerEventTPCnv/SpacePointCollection_p0.h" -#include "TrackerEventTPCnv/SpacePointCnv_p0.h" - -void SpacePointContainerCnv_p0::persToTrans(const SpacePointContainer_p0* /*persObj*/, SpacePointContainer* /*transObj*/, MsgStream& /*log*/) { - - // TODO - -} - -void SpacePointContainerCnv_p0::transToPers(const SpacePointContainer* transObj, SpacePointContainer_p0* persObj, MsgStream& log) { - log << MSG::INFO << "SpacePointContainerCnv_p0::transToPers()" << endmsg; - - SpacePointCnv_p0 spCnv; - typedef SpacePointContainer TRANS; - - TRANS::const_iterator spColl; - TRANS::const_iterator spCollEnd = transObj->end(); - unsigned int spCollId; - unsigned int spId = 0; - unsigned int nextSpId = 0; - unsigned int lastIdHash = 0; - - // resize data vectors - persObj->m_spacepoint_collections.resize(transObj->numberOfCollections()); - int n_spacepoints = 0; - for (spColl = transObj->begin(); spColl != spCollEnd; spColl++) { - n_spacepoints += (*spColl)->size(); - } - persObj->m_spacepoints.resize(n_spacepoints); - - for (spColl = transObj->begin(), spCollId = 0; spColl != spCollEnd; ++spCollId, ++spColl) { - // create persitent representation of SpacePointCollections - const SpacePointCollection& collection = **spColl; - SpacePointCollection_p0& pcollection = persObj->m_spacepoint_collections[spCollId]; - pcollection.m_size = collection.size(); - pcollection.m_idHash = collection.identifyHash() - lastIdHash; - lastIdHash = collection.identifyHash(); - - spId = nextSpId; - nextSpId += collection.size(); - - // create persitent representation of SpacePoints - for (std::size_t i = 0; i < collection.size(); ++i) { - SpacePoint_p0* persSP = &(persObj->m_spacepoints[i + spId]); - const Tracker::FaserSCT_SpacePoint* transSP = dynamic_cast<const Tracker::FaserSCT_SpacePoint*>(collection[i]); - spCnv.transToPers(transSP, persSP, log); - } - } -} diff --git a/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/src/FaserSiHitCollectionCnv.cxx b/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/src/FaserSiHitCollectionCnv.cxx index a4725975ac05e81da114e34f703a482c8df7fbf5..51514fb5b599630e9c32d04c406439c5ea891991 100644 --- a/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/src/FaserSiHitCollectionCnv.cxx +++ b/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/src/FaserSiHitCollectionCnv.cxx @@ -2,8 +2,8 @@ Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ -#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollectionCnv_p1.h" -#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHit_p1.h" +#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollectionCnv_p3.h" +//#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHit_p2.h" #include "FaserSiHitCollectionCnv.h" @@ -17,14 +17,14 @@ FaserSiHitCollection_PERS* FaserSiHitCollectionCnv::createPersistent(FaserSiHitC FaserSiHitCollection* FaserSiHitCollectionCnv::createTransient() { MsgStream mlog(msgSvc(), "FaserSiHitCollectionConverter" ); - FaserSiHitCollectionCnv_p1 converter_p1; + FaserSiHitCollectionCnv_p3 converter_p3; - static const pool::Guid p1_guid("FF9508DE-3E25-425D-9556-16D319DCE0E1"); + static const pool::Guid p3_guid("FF9508DE-3E25-425D-9556-16D319DCE0E1"); FaserSiHitCollection *trans_cont(0); - if( this->compareClassGuid(p1_guid)) { - std::unique_ptr< FaserSiHitCollection_p1 > col_vect( this->poolReadObject< FaserSiHitCollection_p1 >() ); - trans_cont = converter_p1.createTransient( col_vect.get(), mlog ); + if( this->compareClassGuid(p3_guid)) { + std::unique_ptr< FaserSiHitCollection_p3 > col_vect( this->poolReadObject< FaserSiHitCollection_p3 >() ); + trans_cont = converter_p3.createTransient( col_vect.get(), mlog ); } else { throw std::runtime_error("Unsupported persistent version of Data container"); } diff --git a/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/src/FaserSiHitCollectionCnv.h b/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/src/FaserSiHitCollectionCnv.h index 1467731fec80812428550f9c75cc3393dcf07047..3a81e19fa0671a028948f7217aa256c06e94c9a1 100644 --- a/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/src/FaserSiHitCollectionCnv.h +++ b/Tracker/TrackerEventCnv/TrackerSimEventAthenaPool/src/FaserSiHitCollectionCnv.h @@ -6,14 +6,14 @@ #define FASERSIHITCOLLECTIONCNV #include "TrackerSimEvent/FaserSiHitCollection.h" -#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollection_p1.h" -#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollectionCnv_p1.h" +#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollection_p3.h" +#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollectionCnv_p3.h" #include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" // Gaudi #include "GaudiKernel/MsgStream.h" // typedef to the latest persistent version -typedef FaserSiHitCollection_p1 FaserSiHitCollection_PERS; -typedef FaserSiHitCollectionCnv_p1 FaserSiHitCollectionCnv_PERS; +typedef FaserSiHitCollection_p3 FaserSiHitCollection_PERS; +typedef FaserSiHitCollectionCnv_p3 FaserSiHitCollectionCnv_PERS; class FaserSiHitCollectionCnv : public T_AthenaPoolCustomCnv<FaserSiHitCollection, FaserSiHitCollection_PERS > { friend class CnvFactory<FaserSiHitCollectionCnv>; diff --git a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/CMakeLists.txt b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/CMakeLists.txt index f18b094587235a28640989f322dd66b1a65d284b..7e51dca0f68d6ec72f510b641c9ab535094db6ba 100644 --- a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/CMakeLists.txt +++ b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/CMakeLists.txt @@ -22,5 +22,5 @@ atlas_add_dictionary( TrackerSimEventTPCnvDict TrackerSimEventTPCnv/TrackerSimEventTPCnvDict.h TrackerSimEventTPCnv/selection.xml INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaPoolCnvSvcLib GaudiKernel GeneratorObjectsTPCnv TrackerSimEvent TestTools StoreGateLib SGtests Identifier TrackerSimEventTPCnv ) + LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaPoolCnvSvcLib GaudiKernel GeneratorObjectsTPCnv TrackerSimEvent TestTools StoreGateLib SGtests Identifier TrackerSimEventTPCnv AthenaKernel ) diff --git a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCnv_p1.h b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCnv_p2.h similarity index 60% rename from Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCnv_p1.h rename to Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCnv_p2.h index 3a4bec3cdaca91575a51d5589310e9b89306c395..791df726101c1e4178b3d9ceb1248174a91b7fd0 100644 --- a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCnv_p1.h +++ b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCnv_p2.h @@ -2,30 +2,30 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -#ifndef FASERSIHITCNV_P1_H -#define FASERSIHITCNV_P1_H +#ifndef FASERSIHITCNV_P2_H +#define FASERSIHITCNV_P2_H /* Transient/Persistent converter for FaserSiHit class */ #include "TrackerSimEvent/FaserSiHit.h" -#include "FaserSiHit_p1.h" +#include "FaserSiHit_p2.h" #include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h" class MsgStream; -class FaserSiHitCnv_p1 : public T_AthenaPoolTPCnvBase<FaserSiHit, FaserSiHit_p1> +class FaserSiHitCnv_p2 : public T_AthenaPoolTPCnvBase<FaserSiHit, FaserSiHit_p2> { public: - FaserSiHitCnv_p1() {} + FaserSiHitCnv_p2() {} - virtual void persToTrans(const FaserSiHit_p1* persObj, FaserSiHit* + virtual void persToTrans(const FaserSiHit_p2* persObj, FaserSiHit* transObj, MsgStream &log); - virtual void transToPers(const FaserSiHit* transObj, FaserSiHit_p1* + virtual void transToPers(const FaserSiHit* transObj, FaserSiHit_p2* persObj, MsgStream &log); }; diff --git a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollectionCnv_p1.h b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollectionCnv_p3.h similarity index 61% rename from Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollectionCnv_p1.h rename to Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollectionCnv_p3.h index 488221edc81c645ae56e453a2cafb18195f1242d..3f2eb8610682ccf021f0c57904dd9487d35e559e 100644 --- a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollectionCnv_p1.h +++ b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollectionCnv_p3.h @@ -2,31 +2,31 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -#ifndef FASERSIHITCOLLECTIONCNV_P1_H -#define FASERSIHITCOLLECTIONCNV_P1_H +#ifndef FASERSIHITCOLLECTIONCNV_P3_H +#define FASERSIHITCOLLECTIONCNV_P3_H -// FaserSiHitCollectionCnv_p1, T/P separation of FaserSi Hits +// FaserSiHitCollectionCnv_p3, T/P separation of FaserSi Hits // author D.Costanzo <davide.costanzo@cern.ch> // author O.Arnaez <olivier.arnaez@cern.ch> #include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h" #include "TrackerSimEvent/FaserSiHitCollection.h" -#include "FaserSiHitCollection_p1.h" +#include "FaserSiHitCollection_p3.h" -class FaserSiHitCollectionCnv_p1 : public T_AthenaPoolTPCnvBase<FaserSiHitCollection, FaserSiHitCollection_p1> +class FaserSiHitCollectionCnv_p3 : public T_AthenaPoolTPCnvBase<FaserSiHitCollection, FaserSiHitCollection_p3> { public: - FaserSiHitCollectionCnv_p1() {}; + FaserSiHitCollectionCnv_p3() {}; - virtual FaserSiHitCollection* createTransient(const FaserSiHitCollection_p1* persObj, MsgStream &log); + virtual FaserSiHitCollection* createTransient(const FaserSiHitCollection_p3* persObj, MsgStream &log); - virtual void persToTrans(const FaserSiHitCollection_p1* persCont, + virtual void persToTrans(const FaserSiHitCollection_p3* persCont, FaserSiHitCollection* transCont, MsgStream &log) ; virtual void transToPers(const FaserSiHitCollection* transCont, - FaserSiHitCollection_p1* persCont, + FaserSiHitCollection_p3* persCont, MsgStream &log) ; private: diff --git a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollection_p1.h b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollection_p3.h similarity index 88% rename from Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollection_p1.h rename to Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollection_p3.h index fa4018a016b99d2bc7baf9e46a8711fa6278e787..b07b2e3810eaed573449bd4c389befee571bea7f 100644 --- a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollection_p1.h +++ b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollection_p3.h @@ -2,8 +2,8 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -#ifndef FASERSIHITCOLLECTION_P1_H -#define FASERSIHITCOLLECTION_P1_H +#ifndef FASERSIHITCOLLECTION_P3_H +#define FASERSIHITCOLLECTION_P3_H /* @@ -14,11 +14,11 @@ Authors: Davide Costanzo Rob Duxfield #include <vector> #include <string> -class FaserSiHitCollection_p1 +class FaserSiHitCollection_p3 { public: /// Default constructor - FaserSiHitCollection_p1 (); + FaserSiHitCollection_p3 (); //private: std::vector<float> m_hit1_meanTime; // 1 element per string @@ -52,6 +52,6 @@ class FaserSiHitCollection_p1 // inlines inline -FaserSiHitCollection_p1::FaserSiHitCollection_p1 () {} +FaserSiHitCollection_p3::FaserSiHitCollection_p3 () {} #endif diff --git a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHit_p1.h b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHit_p2.h similarity index 83% rename from Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHit_p1.h rename to Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHit_p2.h index 159caf56dd047bd4d7d7fa505b3076dd96b07534..fa8e50a85a8fceafa20e4dbed50f60c052510d0e 100644 --- a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHit_p1.h +++ b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerHits/FaserSiHit_p2.h @@ -2,12 +2,12 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -#ifndef FASERSIHIT_P1_H -#define FASERSIHIT_P1_H +#ifndef FASERSIHIT_P2_H +#define FASERSIHIT_P2_H #include "GeneratorObjectsTPCnv/HepMcParticleLink_p2.h" -class FaserSiHit_p1 { +class FaserSiHit_p2 { public: float m_stX, m_stY, m_stZ; float m_enX, m_enY, m_enZ; diff --git a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnvDict.h b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnvDict.h index 6146be90a917d1eaf49b9a7c9996f5cc4eb66262..a730fca90074a9da71420e41651384173aa298cf 100644 --- a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnvDict.h +++ b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnvDict.h @@ -7,14 +7,14 @@ //----------------------------------------------------------------------------- // -// file: TrackerSimEventTPCnvDict_p1.h +// file: TrackerSimEventTPCnvDict.h // //----------------------------------------------------------------------------- -#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCnv_p1.h" -#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollectionCnv_p1.h" -#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollection_p1.h" -#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHit_p1.h" +#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCnv_p2.h" +#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollectionCnv_p3.h" +#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollection_p3.h" +#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHit_p2.h" #endif // TRACKERSIMEVENTTPCNV_TRACKERSIMEVENTTPCNVDICT_H diff --git a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/selection.xml b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/selection.xml index 72a04265e6367e090af8a543dd0a550d4e948af5..7684404421c37267df94656b57ff9067dcce9503 100644 --- a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/selection.xml +++ b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/TrackerSimEventTPCnv/selection.xml @@ -1,6 +1,6 @@ <lcgdict> <!-- FaserSiHits --> - <class name="FaserSiHit_p1" /> - <class name="std::vector<FaserSiHit_p1>" /> - <class name="FaserSiHitCollection_p1" id="FF9508DE-3E25-425D-9556-16D319DCE0E1" /> + <class name="FaserSiHit_p2" /> + <class name="std::vector<FaserSiHit_p2>" /> + <class name="FaserSiHitCollection_p3" id="FF9508DE-3E25-425D-9556-16D319DCE0E1" /> </lcgdict> diff --git a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/src/TrackerHits/FaserSiHitCnv_p1.cxx b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/src/TrackerHits/FaserSiHitCnv_p2.cxx similarity index 85% rename from Tracker/TrackerEventCnv/TrackerSimEventTPCnv/src/TrackerHits/FaserSiHitCnv_p1.cxx rename to Tracker/TrackerEventCnv/TrackerSimEventTPCnv/src/TrackerHits/FaserSiHitCnv_p2.cxx index a6e9c320e1118143f505e4f3ad3f7234a3afd498..5dde908345fee67f41b4f7f5c4b71407d25c926e 100644 --- a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/src/TrackerHits/FaserSiHitCnv_p1.cxx +++ b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/src/TrackerHits/FaserSiHitCnv_p2.cxx @@ -6,12 +6,12 @@ #include "Identifier/Identifier.h" #include "GeneratorObjectsTPCnv/HepMcParticleLinkCnv_p2.h" -#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHit_p1.h" -#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCnv_p1.h" +#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHit_p2.h" +#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCnv_p2.h" void -FaserSiHitCnv_p1::persToTrans(const FaserSiHit_p1* persObj, FaserSiHit* transObj, MsgStream &log) +FaserSiHitCnv_p2::persToTrans(const FaserSiHit_p2* persObj, FaserSiHit* transObj, MsgStream &log) { HepMcParticleLinkCnv_p2 HepMcPLCnv; HepMcParticleLink link; @@ -32,7 +32,7 @@ FaserSiHitCnv_p1::persToTrans(const FaserSiHit_p1* persObj, FaserSiHit* transObj void -FaserSiHitCnv_p1::transToPers(const FaserSiHit* transObj, FaserSiHit_p1* persObj, MsgStream &log) +FaserSiHitCnv_p2::transToPers(const FaserSiHit* transObj, FaserSiHit_p2* persObj, MsgStream &log) { // if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "FaserSiHitCnv_p1::transToPers called " << endmsg; HepMcParticleLinkCnv_p2 HepMcPLCnv; diff --git a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/src/TrackerHits/FaserSiHitCollectionCnv_p1.cxx b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/src/TrackerHits/FaserSiHitCollectionCnv_p3.cxx similarity index 82% rename from Tracker/TrackerEventCnv/TrackerSimEventTPCnv/src/TrackerHits/FaserSiHitCollectionCnv_p1.cxx rename to Tracker/TrackerEventCnv/TrackerSimEventTPCnv/src/TrackerHits/FaserSiHitCollectionCnv_p3.cxx index c31eed267329943e8a0627881057281bcb7248df..ee4b293a83af7fbb970f12a48d63ce67285e476d 100644 --- a/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/src/TrackerHits/FaserSiHitCollectionCnv_p1.cxx +++ b/Tracker/TrackerEventCnv/TrackerSimEventTPCnv/src/TrackerHits/FaserSiHitCollectionCnv_p3.cxx @@ -4,8 +4,8 @@ #include "TrackerSimEvent/FaserSiHit.h" #include "TrackerSimEvent/FaserSiHitCollection.h" -#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollection_p1.h" -#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollectionCnv_p1.h" +#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollection_p3.h" +#include "TrackerSimEventTPCnv/TrackerHits/FaserSiHitCollectionCnv_p3.h" #include "GeneratorObjects/HepMcParticleLink.h" #include <cmath> @@ -14,8 +14,12 @@ #include "CLHEP/Geometry/Point3D.h" // Gaudi #include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/ThreadLocalContext.h" + // Athena #include "StoreGate/StoreGateSvc.h" +#include "AthenaKernel/ExtendedEventContext.h" + // * * * stolen from eflowRec * * * // inline double phicorr(double a) @@ -53,14 +57,14 @@ inline double cycle(double a, double b) } -const double FaserSiHitCollectionCnv_p1::m_persEneUnit = 1.0e-5; -const double FaserSiHitCollectionCnv_p1::m_persLenUnit = 1.0e-5; -const double FaserSiHitCollectionCnv_p1::m_persAngUnit = 1.0e-5; -const double FaserSiHitCollectionCnv_p1::m_2bHalfMaximum = pow(2.0, 15.0); -const int FaserSiHitCollectionCnv_p1::m_2bMaximum = (unsigned short)(-1); +const double FaserSiHitCollectionCnv_p3::m_persEneUnit = 1.0e-5; +const double FaserSiHitCollectionCnv_p3::m_persLenUnit = 1.0e-5; +const double FaserSiHitCollectionCnv_p3::m_persAngUnit = 1.0e-5; +const double FaserSiHitCollectionCnv_p3::m_2bHalfMaximum = pow(2.0, 15.0); +const int FaserSiHitCollectionCnv_p3::m_2bMaximum = (unsigned short)(-1); -void FaserSiHitCollectionCnv_p1::transToPers(const FaserSiHitCollection* transCont, FaserSiHitCollection_p1* persCont, MsgStream &/*log*/) +void FaserSiHitCollectionCnv_p3::transToPers(const FaserSiHitCollection* transCont, FaserSiHitCollection_p3* persCont, MsgStream &log) { // Finds hits belonging to a "string" (in which the end point of one hit is the same as the start point of the next) and // persistifies the end point of each hit plus the start point of the first hit in each string. @@ -77,6 +81,8 @@ void FaserSiHitCollectionCnv_p1::transToPers(const FaserSiHitCollection* transCo static const double dRcut = 1.0e-7; static const double dTcut = 1.0; + const EventContext& ctx = Gaudi::Hive::currentContext(); + const IProxyDict* proxy = Atlas::getExtendedEventContext(ctx).proxy(); const HepMcParticleLink * lastLink=nullptr; int lastId = -1; double stringFirstTheta = 0.0; @@ -98,11 +104,22 @@ void FaserSiHitCollectionCnv_p1::transToPers(const FaserSiHitCollection* transCo if ( !lastLink || (siHit->particleLink() != *lastLink) ) { - // store barcode once for set of consecutive hits with same barcode + // store barcode, eventIndex and McEventCollection once for set of consecutive hits with same barcode lastLink = &(siHit->particleLink()); persCont->m_barcode.push_back(lastLink->barcode()); - persCont->m_mcEvtIndex.push_back(lastLink->eventIndex()); + unsigned short index{0}; + const HepMcParticleLink::index_type position = + HepMcParticleLink::getEventPositionInCollection(lastLink->eventIndex(), + lastLink->getEventCollection(), + proxy).at(0); + if (position!=0) { + index = lastLink->eventIndex(); + if(lastLink->eventIndex()!=static_cast<HepMcParticleLink::index_type>(index)) { + log << MSG::WARNING << "Attempting to persistify an eventIndex larger than max unsigned short!" << endmsg; + } + } + persCont->m_mcEvtIndex.push_back(index); persCont->m_evtColl.push_back(lastLink->getEventCollectionAsChar()); if (idx > 0) { @@ -241,15 +258,17 @@ void FaserSiHitCollectionCnv_p1::transToPers(const FaserSiHitCollection* transCo } -FaserSiHitCollection* FaserSiHitCollectionCnv_p1::createTransient(const FaserSiHitCollection_p1* persObj, MsgStream &log) { +FaserSiHitCollection* FaserSiHitCollectionCnv_p3::createTransient(const FaserSiHitCollection_p3* persObj, MsgStream &log) { std::unique_ptr<FaserSiHitCollection> trans(std::make_unique<FaserSiHitCollection>("DefaultCollectionName",persObj->m_nHits.size())); persToTrans(persObj, trans.get(), log); return(trans.release()); } -void FaserSiHitCollectionCnv_p1::persToTrans(const FaserSiHitCollection_p1* persCont, FaserSiHitCollection* transCont, MsgStream &/*log*/) +void FaserSiHitCollectionCnv_p3::persToTrans(const FaserSiHitCollection_p3* persCont, FaserSiHitCollection* transCont, MsgStream &/*log*/) { + const EventContext& ctx = Gaudi::Hive::currentContext(); + unsigned int hitCount = 0; unsigned int angleCount = 0; unsigned int idxBC = 0; @@ -299,7 +318,11 @@ void FaserSiHitCollectionCnv_p1::persToTrans(const FaserSiHitCollection_p1* pers HepGeom::Point3D<double> endThis( endLast + r ); - HepMcParticleLink partLink( persCont->m_barcode[idxBC], persCont->m_mcEvtIndex[idxBC], HepMcParticleLink::ExtendedBarCode::eventCollectionFromChar(persCont->m_evtColl[idxBC]), HepMcParticleLink::IS_INDEX ); + HepMcParticleLink::PositionFlag flag = HepMcParticleLink::IS_INDEX; + if (persCont->m_mcEvtIndex[idxBC] == 0) { + flag = HepMcParticleLink::IS_POSITION; + } + HepMcParticleLink partLink( persCont->m_barcode[idxBC], persCont->m_mcEvtIndex[idxBC], HepMcParticleLink::ExtendedBarCode::eventCollectionFromChar(persCont->m_evtColl[idxBC]), flag, ctx ); transCont->Emplace( endLast, endThis, eneLoss, meanTime, partLink, persCont->m_id[idxId]); endLast = endThis; diff --git a/Tracker/TrackerG4/FaserSCT_G4_SD/python/FaserSCT_G4_SDToolConfig.py b/Tracker/TrackerG4/FaserSCT_G4_SD/python/FaserSCT_G4_SDToolConfig.py index eb4fb53749d2a8e01bfd52992421322e91115cbd..1e4fa355daf2e1a9c381b80aa5a2ad8002dbc881 100644 --- a/Tracker/TrackerG4/FaserSCT_G4_SD/python/FaserSCT_G4_SDToolConfig.py +++ b/Tracker/TrackerG4/FaserSCT_G4_SD/python/FaserSCT_G4_SDToolConfig.py @@ -18,5 +18,7 @@ def SctSensorSDCfg(ConfigFlags, name="SctSensorSD", **kwargs): kwargs.setdefault("LogicalVolumeNames", ["SCT::BRLSensor"]) kwargs.setdefault("OutputCollectionNames", [bare_collection_name]) - # result.merge(acc) - return result, FaserSctSensorSDTool(name, **kwargs) + result = ComponentAccumulator() + result.setPrivateTools(CompFactory.FaserSctSensorSDTool(name, **kwargs)) + return result + diff --git a/Tracker/TrackerRecAlgs/FaserSpacePoints/src/FaserSpacePoints.cxx b/Tracker/TrackerRecAlgs/FaserSpacePoints/src/FaserSpacePoints.cxx index cda36287ee9cc3b682539c6b7e61e05f8a0b68e7..b9722a7c2f4318fd6d8e4cf2c76437ced6078d8e 100644 --- a/Tracker/TrackerRecAlgs/FaserSpacePoints/src/FaserSpacePoints.cxx +++ b/Tracker/TrackerRecAlgs/FaserSpacePoints/src/FaserSpacePoints.cxx @@ -1,7 +1,7 @@ #include "FaserSpacePoints.h" #include "Identifier/Identifier.h" -#include "TrkSpacePoint/SpacePoint.h" -#include "TrackerPrepRawData/TrackerClusterCollection.h" +#include "TrackerSpacePoint/FaserSCT_SpacePoint.h" +#include "TrackerPrepRawData/FaserSCT_ClusterCollection.h" namespace Tracker { FaserSpacePoints::FaserSpacePoints(const std::string& name, ISvcLocator* pSvcLocator) @@ -55,7 +55,7 @@ namespace Tracker { ATH_MSG_DEBUG("run = " << m_run); ATH_MSG_DEBUG("event = " << m_event); - SG::ReadHandle<SpacePointContainer> sct_spcontainer( m_sct_spcontainer, ctx ); + SG::ReadHandle<FaserSCT_SpacePointContainer> sct_spcontainer( m_sct_spcontainer, ctx ); if (!sct_spcontainer.isValid()){ ATH_MSG_FATAL("Could not find the data object " << sct_spcontainer.name()); return StatusCode::RECOVERABLE; @@ -63,19 +63,19 @@ namespace Tracker { m_nCollections = sct_spcontainer->size(); ATH_MSG_DEBUG("nCollections = " << m_nCollections); - SpacePointContainer::const_iterator it = sct_spcontainer->begin(); - SpacePointContainer::const_iterator it_end = sct_spcontainer->end(); + FaserSCT_SpacePointContainer::const_iterator it = sct_spcontainer->begin(); + FaserSCT_SpacePointContainer::const_iterator it_end = sct_spcontainer->end(); for(; it != it_end; ++it) { - const SpacePointCollection* col = *it; + const FaserSCT_SpacePointCollection* col = *it; m_nSpacepoints = col->size(); ATH_MSG_DEBUG("nSpacepoints = " << m_nSpacepoints); - SpacePointCollection::const_iterator it_sp = col->begin(); - SpacePointCollection::const_iterator it_sp_end = col->end(); + FaserSCT_SpacePointCollection::const_iterator it_sp = col->begin(); + FaserSCT_SpacePointCollection::const_iterator it_sp_end = col->end(); for (; it_sp != it_sp_end; ++it_sp) { - const Trk::SpacePoint* sp = *it_sp; - const Identifier id = sp->clusterList().first->identify(); + const FaserSCT_SpacePoint* sp = *it_sp; + const auto id = sp->clusterList().first->identify(); int station = m_idHelper->station(id); int plane = m_idHelper->layer(id); m_layer = (station - 1) * 3 + plane; @@ -101,4 +101,4 @@ namespace Tracker { m_outputTree->Branch("y", &m_y); m_outputTree->Branch("z", &m_z); } -} \ No newline at end of file +} diff --git a/Tracker/TrackerRecAlgs/FaserSpacePoints/src/FaserSpacePoints.h b/Tracker/TrackerRecAlgs/FaserSpacePoints/src/FaserSpacePoints.h index 0674992912ce4a16fff803b589ffce91f08e6b14..28807d73e7ac7939c5b830a758846028feedb815 100644 --- a/Tracker/TrackerRecAlgs/FaserSpacePoints/src/FaserSpacePoints.h +++ b/Tracker/TrackerRecAlgs/FaserSpacePoints/src/FaserSpacePoints.h @@ -3,7 +3,7 @@ #include "AthenaBaseComps/AthReentrantAlgorithm.h" #include "TrackerIdentifier/FaserSCT_ID.h" -#include "TrkSpacePoint/SpacePointContainer.h" +#include "TrackerSpacePoint/FaserSCT_SpacePointContainer.h" #include <string> #include <atomic> @@ -33,7 +33,7 @@ namespace Tracker { mutable float m_z{0}; const FaserSCT_ID* m_idHelper{nullptr}; - SG::ReadHandleKey<SpacePointContainer> m_sct_spcontainer{this, "SpacePointsSCTName", "SCT spacepoint container"}; + SG::ReadHandleKey<FaserSCT_SpacePointContainer> m_sct_spcontainer{this, "SpacePointsSCTName", "SCT spacepoint container"}; Gaudi::Property<std::string> m_filePath{this, "FilePath", "spacepoints.root", "Output root file for spacepoints"}; Gaudi::Property<std::string> m_treeName{this, "TreeName", "tree", ""}; @@ -43,4 +43,4 @@ namespace Tracker { }; } -#endif // FASERSPACEPOINTS_H \ No newline at end of file +#endif // FASERSPACEPOINTS_H diff --git a/Tracker/TrackerRecAlgs/TrackerClusterFit/src/ClusterFitAlg.cxx b/Tracker/TrackerRecAlgs/TrackerClusterFit/src/ClusterFitAlg.cxx index c9dda96331919df6f3ab97d9d3bcd85c62849360..6192df2510cf15bbe047a7bf7bb75d1da55fdfe2 100644 --- a/Tracker/TrackerRecAlgs/TrackerClusterFit/src/ClusterFitAlg.cxx +++ b/Tracker/TrackerRecAlgs/TrackerClusterFit/src/ClusterFitAlg.cxx @@ -426,8 +426,8 @@ ClusterFitAlg::GetState( const Eigen::Matrix< double, 4, 1 >& fitResult, double qoverp = 1.0/100000.0; Eigen::Matrix< double, 4, 4 > jacobian = Eigen::Matrix< double, 4, 4 >::Zero(); - jacobian << 1, 0, zFit, 0, - 0, 1, 0, zFit, + jacobian << 1, 0, zFit - m_zCenter[station], 0, + 0, 1, 0, zFit - m_zCenter[station], 0, 0, fitResult[3]/(fitResult[2]*fitResult[2]+fitResult[3]*fitResult[3]), fitResult[2]/(fitResult[2]*fitResult[2]+fitResult[3]*fitResult[3]), 0, 0, fitResult[2]/(sqrt(fitResult[2]*fitResult[2]+fitResult[3]*fitResult[3])*(1+fitResult[2]*fitResult[2]+fitResult[3]*fitResult[3])), diff --git a/Tracker/TrackerRecAlgs/TrackerClusterFit/test/TestBeamClusterFitDbg.py b/Tracker/TrackerRecAlgs/TrackerClusterFit/test/TestBeamClusterFitDbg.py index 294e066edfd45ccea5dc75a8291e5ad0fd88d969..2f8ca9fd6861eadac2c0aa2054f899ff05258b12 100755 --- a/Tracker/TrackerRecAlgs/TrackerClusterFit/test/TestBeamClusterFitDbg.py +++ b/Tracker/TrackerRecAlgs/TrackerClusterFit/test/TestBeamClusterFitDbg.py @@ -95,7 +95,7 @@ ConfigFlags.Input.Files = [ #ConfigFlags.Output.ESDFileName = "run608.ESD.pool.root" #ConfigFlags.Output.ESDFileName = "run001332.ESD.pool.root" ConfigFlags.Output.ESDFileName = "tb.ESD.pool.root" -ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-02" # Always needed; must match FaserVersion +ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-TB00" # Always needed; must match FaserVersion ConfigFlags.IOVDb.DatabaseInstance = "OFLP200" # Use MC conditions for now ConfigFlags.Input.ProjectName = "data21" # Needed to bypass autoconfig ConfigFlags.Input.isMC = False # Needed to bypass autoconfig diff --git a/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/python/TrackerPrepRawDataFormationConfig.py b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/python/TrackerPrepRawDataFormationConfig.py index 57c9d3cea350a801b9b07f83a391f2d04ef1efba..8a620210bdcf8ef20d9d505770da6c4581e0293b 100644 --- a/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/python/TrackerPrepRawDataFormationConfig.py +++ b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/python/TrackerPrepRawDataFormationConfig.py @@ -19,8 +19,9 @@ def FaserSCT_ClusterizationCommonCfg(flags, name="FaserSCT_ClusterizationToolCom Tracker__TrackerClusterMakerTool,Tracker__FaserSCT_ClusteringTool=CompFactory.getComps("Tracker::TrackerClusterMakerTool", "Tracker::FaserSCT_ClusteringTool") trackerClusterMakerTool = Tracker__TrackerClusterMakerTool(name = "TrackerClusterMakerTool") faserSCT_LorentzAngleTool=acc.popToolsAndMerge(FaserSCT_LorentzAngleCfg(flags)) - clusteringTool = Tracker__FaserSCT_ClusteringTool(name, globalPosAlg = trackerClusterMakerTool, FaserSiLorentzAngleTool=faserSCT_LorentzAngleTool) - clusteringTool.timeBins = "01X" + kwargs.setdefault("timeBins", "01X") + clusteringTool = Tracker__FaserSCT_ClusteringTool(name, globalPosAlg = trackerClusterMakerTool, FaserSiLorentzAngleTool=faserSCT_LorentzAngleTool, **kwargs) + # clusteringTool.timeBins = "01X" # attach ToolHandles acc.setPrivateTools(clusteringTool) return acc @@ -35,7 +36,13 @@ def FaserSCT_ClusterizationToolCfg(flags, name="FaserSCT_ClusterizationTool", ** def FaserSCT_ClusterizationBasicCfg(flags, **kwargs): """Return ComponentAccumulator for FaserSCT Clusterization""" acc = ComponentAccumulator() - clusterTool = acc.popToolsAndMerge(FaserSCT_ClusterizationToolCfg(flags)) + pattern = kwargs.pop("ClusterToolTimingPattern","") + # print("ClusterToolTimingPattern = ", pattern) + if len(pattern) > 0 : + clusterTool = acc.popToolsAndMerge(FaserSCT_ClusterizationToolCfg(flags, timeBins = pattern )) + else: + clusterTool = acc.popToolsAndMerge(FaserSCT_ClusterizationToolCfg(flags)) + kwargs.setdefault("SCT_ClusteringTool", clusterTool) kwargs.setdefault("DataObjectName", "SCT_RDOs") kwargs.setdefault("ClustersName", "SCT_ClusterContainer") diff --git a/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/src/FaserSCT_Clusterization.cxx b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/src/FaserSCT_Clusterization.cxx index 04568b0e9f0c277ba54c7faf068d0c3107b58b5d..640ba15148970d76ad415f4a6f127f167afe9d62 100644 --- a/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/src/FaserSCT_Clusterization.cxx +++ b/Tracker/TrackerRecAlgs/TrackerPrepRawDataFormation/src/FaserSCT_Clusterization.cxx @@ -113,6 +113,8 @@ StatusCode FaserSCT_Clusterization::execute(const EventContext& ctx) const { if (not dontDoClusterization) { for (; rdoCollections != rdoCollectionsEnd; ++rdoCollections) { ++m_numberOfRDOCollection; +// for (const FaserSCT_RDORawData* rdo: **rdoCollections) { +// } const TrackerRawDataCollection<FaserSCT_RDORawData>* rd{*rdoCollections}; ATH_MSG_DEBUG("RDO collection size=" << rd->size() << ", Hash=" << rd->identifyHash()); Tracker::FaserSCT_ClusterContainer::IDC_WriteHandle lock{clusterContainer->getWriteHandle(rdoCollections.hashId())}; @@ -184,4 +186,4 @@ StatusCode FaserSCT_Clusterization::finalize() return StatusCode::SUCCESS; } -} \ No newline at end of file +} diff --git a/Tracker/TrackerRecAlgs/TrackerSPFit/CMakeLists.txt b/Tracker/TrackerRecAlgs/TrackerSPFit/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..665c1a291f1a87d541ce0166576618e836b9bb42 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSPFit/CMakeLists.txt @@ -0,0 +1,18 @@ +################################################################################ +# Package: TrackerSPFit +################################################################################ + +# Declare the package name: +atlas_subdir( TrackerSPFit) + +# External dependencies: +find_package( Eigen ) + +find_package( ROOT COMPONENTS Core Tree MathCore) + +atlas_add_component( TrackerSPFit + src/components/*.cxx src/*.cxx src/*.h + INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${EIGEN_LIBRARIES} ${ROOT_LIBRARIES} AthenaBaseComps AthContainers GeoPrimitives Identifier GaudiKernel TrackerReadoutGeometry TrackerPrepRawData TrackerSpacePoint AthenaMonitoringKernelLib FaserDetDescr xAODEventInfo TrkEventPrimitives TrackerIdentifier FaserSiSpacePointToolLib TrkSpacePoint ) + +atlas_install_python_modules( python/*.py ) diff --git a/Tracker/TrackerRecAlgs/TrackerSPFit/ReadMe b/Tracker/TrackerRecAlgs/TrackerSPFit/ReadMe new file mode 100644 index 0000000000000000000000000000000000000000..8a853447d3c1b57a281b357d79170cff82ca0d16 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSPFit/ReadMe @@ -0,0 +1,6 @@ +TrackerSPFit: + Use the FaserSCT_SpacePoint to get the residuals for alignment + +For each station, select the spacepoint triplets first, then perform a 3D line fit and require the chi2 less than 10. +Take the difference between the expected position and measured position as the residuals. +In the tree names "spfit", the branch "sp_x_residual" and "sp_y_residual" are the residuals in x and y for each spacepoint, and "sp_station", "sp_layer" and "sp_module" are the stations (1-3), layer (0-2) and module (0-8) ID for. diff --git a/Tracker/TrackerRecAlgs/TrackerSPFit/python/TrackerSPFit.py b/Tracker/TrackerRecAlgs/TrackerSPFit/python/TrackerSPFit.py new file mode 100644 index 0000000000000000000000000000000000000000..8312136a38a664107de347e9808eafa156a16da4 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSPFit/python/TrackerSPFit.py @@ -0,0 +1,99 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +import sys +from AthenaCommon.Logging import log, logging +from AthenaCommon.Constants import DEBUG, VERBOSE, INFO +from AthenaCommon.Configurable import Configurable +from CalypsoConfiguration.AllConfigFlags import ConfigFlags +from CalypsoConfiguration.MainServicesConfig import MainServicesCfg +from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg +# from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg +from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg +# from Digitization.DigitizationParametersConfig import writeDigitizationMetadata +from TrackerPrepRawDataFormation.TrackerPrepRawDataFormationConfig import FaserSCT_ClusterizationCfg +from TrackerSpacePointFormation.TrackerSpacePointFormationConfig import TrackerSpacePointFinderCfg +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from AthenaConfiguration.ComponentFactory import CompFactory +from FaserSCT_GeoModel.FaserSCT_GeoModelConfig import FaserSCT_GeometryCfg + +Tracker__TrackerSPFit, THistSvc=CompFactory.getComps("Tracker::TrackerSPFit", "THistSvc") + + +def TrackerSPFitBasicCfg(flags, **kwargs): + """Return ComponentAccumulator for TrackerSPFit""" + acc = FaserSCT_GeometryCfg(flags) + kwargs.setdefault("SpacePointsSCTName", "SCT_SpacePointContainer") + kwargs.setdefault("SCT_ClustersName", "SCT_ClusterContainer") + kwargs.setdefault("MaxChi2", 20) + kwargs.setdefault("UseBiasedResidual", True) + kwargs.setdefault("SaveAllClusterInfo", True) + kwargs.setdefault("SaveAllSPInfo", True) + acc.addEventAlgo(Tracker__TrackerSPFit(**kwargs)) + # attach ToolHandles + return acc + +def TrackerSPFit_OutputCfg(flags): + """Return ComponentAccumulator with Output for SCT. Not standalone.""" + acc = ComponentAccumulator() + acc.merge(OutputStreamCfg(flags, "ESD")) + ostream = acc.getEventAlgo("OutputStreamESD") + ostream.TakeItemsFromInput = True + return acc + +def TrackerSPFitCfg(flags, **kwargs): + acc=TrackerSPFitBasicCfg(flags, **kwargs) + histSvc= THistSvc() + histSvc.Output += [ "TrackerSPFit DATAFILE='trackerspfit.root' OPT='RECREATE'" ] + acc.addService(histSvc) + acc.merge(TrackerSPFit_OutputCfg(flags)) + return acc + +if __name__ == "__main__": + log.setLevel(DEBUG) + Configurable.configurableRun3Behavior = True + + # Configure + ConfigFlags.Input.Files = ['my.RDO.pool.root'] + ConfigFlags.Output.ESDFileName = "mySeeds.ESD.pool.root" + ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01" # Always needed; must match FaserVersion + ConfigFlags.IOVDb.DatabaseInstance = "OFLP200" # Use MC conditions for now +# ConfigFlags.Input.ProjectName = "data20" # Needed to bypass autoconfig + ConfigFlags.Input.isMC = True + # Needed to bypass autoconfig + ConfigFlags.GeoModel.FaserVersion = "FASER-01" # FASER cosmic ray geometry (station 2 only) + ConfigFlags.Common.isOnline = False + ConfigFlags.GeoModel.Align.Dynamic = False + ConfigFlags.Beam.NumberOfCollisions = 0. + + ConfigFlags.lock() + + # Core components + acc = MainServicesCfg(ConfigFlags) + acc.merge(PoolReadCfg(ConfigFlags)) + + #acc.merge(writeDigitizationMetadata(ConfigFlags)) + + # Inner Detector + acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags)) + acc.merge(TrackerSpacePointFinderCfg(ConfigFlags)) + acc.merge(TrackerSPFitCfg(ConfigFlags)) + + # Timing + #acc.merge(MergeRecoTimingObjCfg(ConfigFlags)) + + # Dump config + logging.getLogger('forcomps').setLevel(VERBOSE) + acc.foreach_component("*").OutputLevel = VERBOSE + acc.foreach_component("*ClassID*").OutputLevel = INFO + # acc.getCondAlgo("FaserSCT_AlignCondAlg").OutputLevel = VERBOSE + # acc.getCondAlgo("FaserSCT_DetectorElementCondAlg").OutputLevel = VERBOSE + acc.getService("StoreGateSvc").Dump = True + acc.getService("ConditionStore").Dump = True + acc.printConfig(withDetails=True) + ConfigFlags.dump() + + # Execute and finish + sc = acc.run(maxEvents=-1) + + # Success should be 0 + sys.exit(not sc.isSuccess()) diff --git a/Tracker/TrackerRecAlgs/TrackerSPFit/python/TrackerSPFitConfig.py b/Tracker/TrackerRecAlgs/TrackerSPFit/python/TrackerSPFitConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..7f273f51e642489b0cdd394b7d1bb053adc33951 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSPFit/python/TrackerSPFitConfig.py @@ -0,0 +1,28 @@ +"""Define methods to construct configured SCT Digitization tools and algorithms + +Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +""" +#from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from AthenaConfiguration.ComponentFactory import CompFactory +Tracker__TrackerSPFit = CompFactory.getComps("Tracker::TrackerSPFit") + +#from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg +from FaserSCT_GeoModel.FaserSCT_GeoModelConfig import FaserSCT_GeometryCfg + +def TrackerSPFitBasicCfg(flags, **kwargs): + """Return ComponentAccumulator for TrackerSpacePointMakerAlg""" +# acc = ComponentAccumulator() + acc = FaserSCT_GeometryCfg(flags) + kwargs.setdefault("SpacePointsSCTName", "SCT_SpacePointContainer") + kwargs.setdefault("SCT_ClustersName", "SCT_ClusterContainer") + acc.addEventAlgo(Tracker__TrackerSPFit(**kwargs)) + return acc + + +def TrackerSPFitCfg(flags, **kwargs): + acc=TrackerSPFitBasicCfg(flags, **kwargs) + THistSvc=CompFactory.THistSvc + histSvc= THistSvc() + histSvc.Output += [ "TrackerSPFit DATAFILE='sp_fit.root' OPT='RECREATE'" ] + acc.addService(histSvc) + return acc diff --git a/Tracker/TrackerRecAlgs/TrackerSPFit/python/TrackerSPFitTI12Data.py b/Tracker/TrackerRecAlgs/TrackerSPFit/python/TrackerSPFitTI12Data.py new file mode 100644 index 0000000000000000000000000000000000000000..63286a5d697c96d4b45034ca989d28b02082241b --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSPFit/python/TrackerSPFitTI12Data.py @@ -0,0 +1,105 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +import sys +from AthenaCommon.Logging import log, logging +from AthenaCommon.Constants import DEBUG, INFO +from AthenaCommon.Configurable import Configurable +from CalypsoConfiguration.AllConfigFlags import ConfigFlags +from CalypsoConfiguration.MainServicesConfig import MainServicesCfg +#from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg +from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg +from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg +from WaveRecAlgs.WaveRecAlgsConfig import WaveformReconstructionCfg +from TrackerPrepRawDataFormation.TrackerPrepRawDataFormationConfig import FaserSCT_ClusterizationCfg +from TrackerSpacePointFormation.TrackerSpacePointFormationConfig import TrackerSpacePointFinderCfg +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator +from AthenaConfiguration.ComponentFactory import CompFactory +from FaserSCT_GeoModel.FaserSCT_GeoModelConfig import FaserSCT_GeometryCfg + +Tracker__TrackerSPFit, THistSvc=CompFactory.getComps("Tracker::TrackerSPFit", "THistSvc") + + +def TrackerSPFitBasicCfg(flags, **kwargs): + """Return ComponentAccumulator for TrackerSPFit""" + acc = FaserSCT_GeometryCfg(flags) + kwargs.setdefault("SpacePointsSCTName", "SCT_SpacePointContainer") + kwargs.setdefault("SCT_ClustersName", "SCT_ClusterContainer") + kwargs.setdefault("MaxChi2", 100) + kwargs.setdefault("UseBiasedResidual", True) + acc.addEventAlgo(Tracker__TrackerSPFit(**kwargs)) + # attach ToolHandles + return acc + +def TrackerSPFit_OutputCfg(flags): + """Return ComponentAccumulator with Output for SCT. Not standalone.""" + acc = ComponentAccumulator() + acc.merge(OutputStreamCfg(flags, "ESD")) + ostream = acc.getEventAlgo("OutputStreamESD") + ostream.TakeItemsFromInput = True + return acc + +def TrackerSPFitCfg(flags, **kwargs): + acc=TrackerSPFitBasicCfg(flags, **kwargs) + histSvc= THistSvc() + histSvc.Output += [ "TrackerSPFit DATAFILE='trackerspfit.root' OPT='RECREATE'" ] + acc.addService(histSvc) + acc.merge(TrackerSPFit_OutputCfg(flags)) + return acc + +if __name__ == "__main__": + log.setLevel(DEBUG) + Configurable.configurableRun3Behavior = True + + # Configure + ConfigFlags.Input.Files = ['/eos/project-f/faser-commissioning/TI12Data/Run-004272/Faser-Physics-004272-00010.raw'] + ConfigFlags.Output.ESDFileName = "mySeeds.ESD.pool.root" + ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01" # Always needed; must match FaserVersion + ConfigFlags.IOVDb.DatabaseInstance = "OFLP200" # Use MC conditions for now + ConfigFlags.Input.ProjectName = "data21" # Needed to bypass autoconfig + ConfigFlags.Input.isMC = False + # Needed to bypass autoconfig + ConfigFlags.GeoModel.FaserVersion = "FASER-01" # FASER cosmic ray geometry (station 2 only) + ConfigFlags.Common.isOnline = False + ConfigFlags.GeoModel.Align.Dynamic = False + ConfigFlags.Beam.NumberOfCollisions = 0. + + ConfigFlags.lock() + + # Core components + acc = MainServicesCfg(ConfigFlags) + acc.merge(PoolWriteCfg(ConfigFlags)) + + from FaserByteStreamCnvSvc.FaserByteStreamCnvSvcConfig import FaserByteStreamCnvSvcCfg + acc.merge(FaserByteStreamCnvSvcCfg(ConfigFlags)) + acc.merge(WaveformReconstructionCfg(ConfigFlags)) + acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags, DataObjectName="SCT_EDGEMODE_RDOs")) +# acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags)) + acc.merge(TrackerSpacePointFinderCfg(ConfigFlags)) + acc.merge(TrackerSPFitCfg(ConfigFlags)) +# from AthenaConfiguration.ComponentFactory import CompFactory +# decoderTool = CompFactory.RawWaveformDecoderTool(name = "RawWaveformDecoderTool", +## CaloChannels = [0, 1, 2,3, 4, 5], +## PreshowerChannels = [6,7], +## TriggerChannels = [8, 9], +# VetoChannels=[]) +# acc.addPublicTool(decoderTool) + + # Timing + #acc.merge(MergeRecoTimingObjCfg(ConfigFlags)) + + # Dump config + logging.getLogger('forcomps').setLevel(INFO) + acc.foreach_component("*").OutputLevel = INFO + acc.foreach_component("*ClassID*").OutputLevel = INFO + # acc.getCondAlgo("FaserSCT_AlignCondAlg").OutputLevel = VERBOSE + # acc.getCondAlgo("FaserSCT_DetectorElementCondAlg").OutputLevel = VERBOSE + acc.getService("StoreGateSvc").Dump = True + acc.getService("ConditionStore").Dump = True + acc.printConfig(withDetails=True) + ConfigFlags.dump() + + # Execute and finish + sc = acc.run(maxEvents=-1) + + # Success should be 0 + sys.exit(not sc.isSuccess()) diff --git a/Tracker/TrackerRecAlgs/TrackerSPFit/src/TrackerSPFit.cxx b/Tracker/TrackerRecAlgs/TrackerSPFit/src/TrackerSPFit.cxx new file mode 100755 index 0000000000000000000000000000000000000000..6902a70138cdad5f8957f0f7e0886d36e6d8213e --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSPFit/src/TrackerSPFit.cxx @@ -0,0 +1,949 @@ +/* + Copyright (C) 2002-2021 ChRN for the benefit of the ATLAS collaboration + */ + +/*************************************************************************** + ------------------- + ***************************************************************************/ + +//<<<<<< INCLUDES >>>>>> + + +#include "TrackerSPFit.h" + +// For processing clusters +#include "TrackerReadoutGeometry/SiLocalPosition.h" +#include "TrackerReadoutGeometry/SiDetectorDesign.h" +#include "TrackerReadoutGeometry/SiDetectorElement.h" + +// Space point Classes, +#include "TrackerSpacePoint/FaserSCT_SpacePointContainer.h" +#include "TrackerIdentifier/FaserSCT_ID.h" + + +// general Atlas classes +#include "FaserDetDescr/FaserDetectorID.h" +#include "xAODEventInfo/EventInfo.h" +#include "StoreGate/ReadCondHandle.h" + +#include "AthenaMonitoringKernel/Monitored.h" + +namespace Tracker +{ + //------------------------------------------------------------------------ + TrackerSPFit::TrackerSPFit(const std::string& name, + ISvcLocator* pSvcLocator) + : AthReentrantAlgorithm(name, pSvcLocator) + , m_hist_x(0) + , m_hist_y(0) + , m_hist_z(0) + , m_hist_r(0) + , m_hist_eta(0) + , m_hist_phi(0) + , m_hist_station(0) + , m_hist_strip(0) + , m_hist_layer(0) + , m_hist_x_y_plane0(0) + , m_hist_x_y_plane1(0) + , m_hist_x_y_plane2(0) + , m_hist_x_y_plane3(0) + , m_hist_x_y_plane4(0) + , m_hist_x_y_plane5(0) + , m_hist_x_y_plane6(0) + , m_hist_x_y_plane7(0) + , m_hist_x_y_plane8(0) + , m_residual_y_plane0(0) + , m_residual_y_plane1(0) + , m_residual_y_plane2(0) + , m_residual_y_plane3(0) + , m_residual_y_plane4(0) + , m_residual_y_plane5(0) + , m_residual_y_plane6(0) + , m_residual_y_plane7(0) + , m_residual_y_plane8(0) + , m_residual_x_plane0(0) + , m_residual_x_plane1(0) + , m_residual_x_plane2(0) + , m_residual_x_plane3(0) + , m_residual_x_plane4(0) + , m_residual_x_plane5(0) + , m_residual_x_plane6(0) + , m_residual_x_plane7(0) + , m_residual_x_plane8(0) + , m_chi2(0) + , m_edm(0) + , m_ndf(0) + , m_preYhistX_s1l1m0(0) + , m_preYhistY_s1l1m0(0) + , m_preXhistX_s1l1m0(0) + , m_preXhistY_s1l1m0(0) + , m_preYhistX_s1l1m1(0) + , m_preYhistY_s1l1m1(0) + , m_preXhistX_s1l1m1(0) + , m_preXhistY_s1l1m1(0) + , m_preYhistX_s1l1m2(0) + , m_preYhistY_s1l1m2(0) + , m_preXhistX_s1l1m2(0) + , m_preXhistY_s1l1m2(0) + , m_preYhistX_s1l1m3(0) + , m_preYhistY_s1l1m3(0) + , m_preXhistX_s1l1m3(0) + , m_preXhistY_s1l1m3(0) + , m_preYhistX_s1l1m4(0) + , m_preYhistY_s1l1m4(0) + , m_preXhistX_s1l1m4(0) + , m_preXhistY_s1l1m4(0) + , m_preYhistX_s1l1m5(0) + , m_preYhistY_s1l1m5(0) + , m_preXhistX_s1l1m5(0) + , m_preXhistY_s1l1m5(0) + , m_preYhistX_s1l1m6(0) + , m_preYhistY_s1l1m6(0) + , m_preXhistX_s1l1m6(0) + , m_preXhistY_s1l1m6(0) + , m_preYhistX_s1l1m7(0) + , m_preYhistY_s1l1m7(0) + , m_preXhistX_s1l1m7(0) + , m_preXhistY_s1l1m7(0) + , m_thistSvc("THistSvc", name) + { + declareProperty("MaxChi2", m_maxchi2=20); + declareProperty("UseBiasedResidual", m_bias=true); + declareProperty("SaveAllClusterInfo", m_saveallcluster=true); + declareProperty("SaveAllSPInfo", m_saveallsp=true); + } + + //----------------------------------------------------------------------- + StatusCode TrackerSPFit::initialize() + { + ATH_MSG_DEBUG( "TrackerSPFit::initialize()" ); + + CHECK(m_thistSvc.retrieve()); + // Check that clusters, space points and ids have names + if(m_Sct_clcontainerKey.key().empty()){ + ATH_MSG_FATAL( "SCTs selected and no name set for SCT clusters"); + return StatusCode::FAILURE; + } + ATH_CHECK( m_Sct_clcontainerKey.initialize() ); + + if ( m_Sct_spcontainerKey.key().empty()){ + ATH_MSG_FATAL( "SCTs selected and no name set for SCT clusters"); + return StatusCode::FAILURE; + } + ATH_CHECK( m_Sct_spcontainerKey.initialize() ); + + m_tree= new TTree("spfit","tree"); + TrackerSPFit::initializeTree(); + + // create containers (requires the Identifier Helpers) + ATH_CHECK(detStore()->retrieve(m_idHelper,"FaserSCT_ID")); + + // Initialize the key of input SiElementPropertiesTable and SiDetectorElementCollection for SCT + ATH_CHECK(m_SCTDetEleCollKey.initialize()); + + + m_hist_x=new TH1D("sp_x","sp_x",100,-200,200); + m_hist_y=new TH1D("sp_y","sp_y",100,-200,200); + m_hist_z=new TH1D("sp_z","sp_z",100,0,300); + m_hist_r=new TH1D("sp_r","sp_r",100,0,300); + m_hist_eta=new TH1D("sp_eta","sp_eta",100,0,5); + m_hist_phi=new TH1D("sp_phi","sp_phi",100,-3.2,3.2); + m_hist_strip=new TH1D("sp_strip","sp_strip",100,0,2000); + m_hist_layer=new TH1D("sp_layer","sp_layer",100,-10,10); + m_hist_station=new TH1D("sp_station","sp_station",100,-10,10); + m_hist_x_y_plane0=new TH2D("sp_x_y_plane0","sp_x_y_plane0",100,-200,200,100,-200,200); + m_hist_x_y_plane1=new TH2D("sp_x_y_plane1","sp_x_y_plane1",100,-200,200,100,-200,200); + m_hist_x_y_plane2=new TH2D("sp_x_y_plane2","sp_x_y_plane2",100,-200,200,100,-200,200); + m_hist_x_y_plane3=new TH2D("sp_x_y_plane3","sp_x_y_plane3",100,-200,200,100,-200,200); + m_hist_x_y_plane4=new TH2D("sp_x_y_plane4","sp_x_y_plane4",100,-200,200,100,-200,200); + m_hist_x_y_plane5=new TH2D("sp_x_y_plane5","sp_x_y_plane5",100,-200,200,100,-200,200); + m_hist_x_y_plane6=new TH2D("sp_x_y_plane6","sp_x_y_plane6",100,-200,200,100,-200,200); + m_hist_x_y_plane7=new TH2D("sp_x_y_plane7","sp_x_y_plane7",100,-200,200,100,-200,200); + m_hist_x_y_plane8=new TH2D("sp_x_y_plane8","sp_x_y_plane8",100,-200,200,100,-200,200); + m_residual_y_plane0=new TH1D("sp_residual_y_plane0","sp_residual_y_plane0",2000,-1,1); + m_residual_y_plane1=new TH1D("sp_residual_y_plane1","sp_residual_y_plane1",2000,-1,1); + m_residual_y_plane2=new TH1D("sp_residual_y_plane2","sp_residual_y_plane2",2000,-1,1); + m_residual_y_plane3=new TH1D("sp_residual_y_plane3","sp_residual_y_plane3",2000,-1,1); + m_residual_y_plane4=new TH1D("sp_residual_y_plane4","sp_residual_y_plane4",2000,-1,1); + m_residual_y_plane5=new TH1D("sp_residual_y_plane5","sp_residual_y_plane5",2000,-1,1); + m_residual_y_plane6=new TH1D("sp_residual_y_plane6","sp_residual_y_plane6",2000,-1,1); + m_residual_y_plane7=new TH1D("sp_residual_y_plane7","sp_residual_y_plane7",2000,-1,1); + m_residual_y_plane8=new TH1D("sp_residual_y_plane8","sp_residual_y_plane8",2000,-1,1); + m_residual_x_plane0=new TH1D("sp_residual_x_plane0","sp_residual_x_plane0",2000,-1,1); + m_residual_x_plane1=new TH1D("sp_residual_x_plane1","sp_residual_x_plane1",2000,-1,1); + m_residual_x_plane2=new TH1D("sp_residual_x_plane2","sp_residual_x_plane2",2000,-1,1); + m_residual_x_plane3=new TH1D("sp_residual_x_plane3","sp_residual_x_plane3",2000,-1,1); + m_residual_x_plane4=new TH1D("sp_residual_x_plane4","sp_residual_x_plane4",2000,-1,1); + m_residual_x_plane5=new TH1D("sp_residual_x_plane5","sp_residual_x_plane5",2000,-1,1); + m_residual_x_plane6=new TH1D("sp_residual_x_plane6","sp_residual_x_plane6",2000,-1,1); + m_residual_x_plane7=new TH1D("sp_residual_x_plane7","sp_residual_x_plane7",2000,-1,1); + m_residual_x_plane8=new TH1D("sp_residual_x_plane8","sp_residual_x_plane8",2000,-1,1); + m_chi2=new TH1D("chi2","chi2",100,0,100); + m_edm=new TH1D("edm","edm",100,0,0.01); + m_ndf=new TH1D("ndf","ndf",10,0,10); + m_preYhistX_s1l1m0=new TProfile("YvsX_s1l1m0","residual vs x for staion 1 layer 1 module 0",100,-150,150,-0.1,0.1); + m_preXhistX_s1l1m0=new TProfile("XvsX_s1l1m0","residual vs x for staion 1 layer 1 module 0",100,-150,150,-0.1,0.1); + m_preXhistY_s1l1m0=new TProfile("XvsY_s1l1m0","residual vs x for staion 1 layer 1 module 0",100,-150,150,-0.1,0.1); + m_preYhistY_s1l1m0=new TProfile("YvsY_s1l1m0","residual vs x for staion 1 layer 1 module 0",100,-150,150,-0.1,0.1); + m_preYhistX_s1l1m1=new TProfile("YvsX_s1l1m1","residual vs x for staion 1 layer 1 module 1",100,-150,150,-0.1,0.1); + m_preXhistX_s1l1m1=new TProfile("XvsX_s1l1m1","residual vs x for staion 1 layer 1 module 1",100,-150,150,-0.1,0.1); + m_preXhistY_s1l1m1=new TProfile("XvsY_s1l1m1","residual vs x for staion 1 layer 1 module 1",100,-150,150,-0.1,0.1); + m_preYhistY_s1l1m1=new TProfile("YvsY_s1l1m1","residual vs x for staion 1 layer 1 module 1",100,-150,150,-0.1,0.1); + m_preYhistX_s1l1m2=new TProfile("YvsX_s1l1m2","residual vs x for staion 1 layer 1 module 2",100,-150,150,-0.1,0.1); + m_preXhistX_s1l1m2=new TProfile("XvsX_s1l1m2","residual vs x for staion 1 layer 1 module 2",100,-150,150,-0.1,0.1); + m_preXhistY_s1l1m2=new TProfile("XvsY_s1l1m2","residual vs x for staion 1 layer 1 module 2",100,-150,150,-0.1,0.1); + m_preYhistY_s1l1m2=new TProfile("YvsY_s1l1m2","residual vs x for staion 1 layer 1 module 2",100,-150,150,-0.1,0.1); + m_preYhistX_s1l1m3=new TProfile("YvsX_s1l1m3","residual vs x for staion 1 layer 1 module 3",100,-150,150,-0.1,0.1); + m_preXhistX_s1l1m3=new TProfile("XvsX_s1l1m3","residual vs x for staion 1 layer 1 module 3",100,-150,150,-0.1,0.1); + m_preXhistY_s1l1m3=new TProfile("XvsY_s1l1m3","residual vs x for staion 1 layer 1 module 3",100,-150,150,-0.1,0.1); + m_preYhistY_s1l1m3=new TProfile("YvsY_s1l1m3","residual vs x for staion 1 layer 1 module 3",100,-150,150,-0.1,0.1); + m_preYhistX_s1l1m4=new TProfile("YvsX_s1l1m4","residual vs x for staion 1 layer 1 module 4",100,-150,150,-0.1,0.1); + m_preXhistX_s1l1m4=new TProfile("XvsX_s1l1m4","residual vs x for staion 1 layer 1 module 4",100,-150,150,-0.1,0.1); + m_preXhistY_s1l1m4=new TProfile("XvsY_s1l1m4","residual vs x for staion 1 layer 1 module 4",100,-150,150,-0.1,0.1); + m_preYhistY_s1l1m4=new TProfile("YvsY_s1l1m4","residual vs x for staion 1 layer 1 module 4",100,-150,150,-0.1,0.1); + m_preYhistX_s1l1m5=new TProfile("YvsX_s1l1m5","residual vs x for staion 1 layer 1 module 5",100,-150,150,-0.1,0.1); + m_preXhistX_s1l1m5=new TProfile("XvsX_s1l1m5","residual vs x for staion 1 layer 1 module 5",100,-150,150,-0.1,0.1); + m_preXhistY_s1l1m5=new TProfile("XvsY_s1l1m5","residual vs x for staion 1 layer 1 module 5",100,-150,150,-0.1,0.1); + m_preYhistY_s1l1m5=new TProfile("YvsY_s1l1m5","residual vs x for staion 1 layer 1 module 5",100,-150,150,-0.1,0.1); + m_preYhistX_s1l1m6=new TProfile("YvsX_s1l1m6","residual vs x for staion 1 layer 1 module 6",100,-150,150,-0.1,0.1); + m_preXhistX_s1l1m6=new TProfile("XvsX_s1l1m6","residual vs x for staion 1 layer 1 module 6",100,-150,150,-0.1,0.1); + m_preXhistY_s1l1m6=new TProfile("XvsY_s1l1m6","residual vs x for staion 1 layer 1 module 6",100,-150,150,-0.1,0.1); + m_preYhistY_s1l1m6=new TProfile("YvsY_s1l1m6","residual vs x for staion 1 layer 1 module 6",100,-150,150,-0.1,0.1); + m_preYhistX_s1l1m7=new TProfile("YvsX_s1l1m7","residual vs x for staion 1 layer 1 module 7",100,-150,150,-0.1,0.1); + m_preXhistX_s1l1m7=new TProfile("XvsX_s1l1m7","residual vs x for staion 1 layer 1 module 7",100,-150,150,-0.1,0.1); + m_preXhistY_s1l1m7=new TProfile("XvsY_s1l1m7","residual vs x for staion 1 layer 1 module 7",100,-150,150,-0.1,0.1); + m_preYhistY_s1l1m7=new TProfile("YvsY_s1l1m7","residual vs x for staion 1 layer 1 module 7",100,-150,150,-0.1,0.1); + CHECK(m_thistSvc->regTree("/TrackerSPFit/spfit",m_tree)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualY_x_s1l1m0",m_preYhistX_s1l1m0)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualX_x_s1l1m0",m_preXhistX_s1l1m0)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualX_y_s1l1m0",m_preXhistY_s1l1m0)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualY_y_s1l1m0",m_preYhistY_s1l1m0)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualY_x_s1l1m1",m_preYhistX_s1l1m1)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualX_x_s1l1m1",m_preXhistX_s1l1m1)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualX_y_s1l1m1",m_preXhistY_s1l1m1)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualY_y_s1l1m1",m_preYhistY_s1l1m1)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualY_x_s1l1m2",m_preYhistX_s1l1m2)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualX_x_s1l1m2",m_preXhistX_s1l1m2)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualX_y_s1l1m2",m_preXhistY_s1l1m2)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualY_y_s1l1m2",m_preYhistY_s1l1m2)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualY_x_s1l1m3",m_preYhistX_s1l1m3)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualX_x_s1l1m3",m_preXhistX_s1l1m3)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualX_y_s1l1m3",m_preXhistY_s1l1m3)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualY_y_s1l1m3",m_preYhistY_s1l1m3)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualY_x_s1l1m4",m_preYhistX_s1l1m4)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualX_x_s1l1m4",m_preXhistX_s1l1m4)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualX_y_s1l1m4",m_preXhistY_s1l1m4)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualY_y_s1l1m4",m_preYhistY_s1l1m4)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualY_x_s1l1m5",m_preYhistX_s1l1m5)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualX_x_s1l1m5",m_preXhistX_s1l1m5)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualX_y_s1l1m5",m_preXhistY_s1l1m5)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualY_y_s1l1m5",m_preYhistY_s1l1m5)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualY_x_s1l1m6",m_preYhistX_s1l1m6)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualX_x_s1l1m6",m_preXhistX_s1l1m6)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualX_y_s1l1m6",m_preXhistY_s1l1m6)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualY_y_s1l1m6",m_preYhistY_s1l1m6)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualY_x_s1l1m7",m_preYhistX_s1l1m7)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualX_x_s1l1m7",m_preXhistX_s1l1m7)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualX_y_s1l1m7",m_preXhistY_s1l1m7)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residualY_y_s1l1m7",m_preYhistY_s1l1m7)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_x",m_hist_x)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_y",m_hist_y)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_z",m_hist_z)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_r",m_hist_r)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_eta",m_hist_eta)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_phi",m_hist_phi)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_strip",m_hist_strip)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_layer",m_hist_layer)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_station",m_hist_station)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_x_y_plane0",m_hist_x_y_plane0)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_x_y_plane1",m_hist_x_y_plane1)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_x_y_plane2",m_hist_x_y_plane2)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_x_y_plane3",m_hist_x_y_plane3)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_x_y_plane4",m_hist_x_y_plane4)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_x_y_plane5",m_hist_x_y_plane5)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_x_y_plane6",m_hist_x_y_plane6)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_x_y_plane7",m_hist_x_y_plane7)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_x_y_plane8",m_hist_x_y_plane8)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residual_y_plane0",m_residual_y_plane0)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residual_y_plane1",m_residual_y_plane1)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residual_y_plane2",m_residual_y_plane2)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residual_y_plane3",m_residual_y_plane3)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residual_y_plane4",m_residual_y_plane4)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residual_y_plane5",m_residual_y_plane5)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residual_y_plane6",m_residual_y_plane6)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residual_y_plane7",m_residual_y_plane7)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residual_y_plane8",m_residual_y_plane8)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residual_x_plane0",m_residual_x_plane0)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residual_x_plane1",m_residual_x_plane1)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residual_x_plane2",m_residual_x_plane2)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residual_x_plane3",m_residual_x_plane3)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residual_x_plane4",m_residual_x_plane4)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residual_x_plane5",m_residual_x_plane5)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residual_x_plane6",m_residual_x_plane6)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residual_x_plane7",m_residual_x_plane7)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_residual_x_plane8",m_residual_x_plane8)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_chi2",m_chi2)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_edm",m_edm)); + CHECK(m_thistSvc->regHist("/TrackerSPFit/sp/sp_ndf",m_ndf)); + ATH_MSG_INFO( "TrackerSPFit::initialized" ); + return StatusCode::SUCCESS; + } + + //------------------------------------------------------------------------- + void TrackerSPFit::initializeTree(){ + m_tree->Branch("evtId",&m_eventNumber); + m_tree->Branch("sp_track_x",&m_sp_track_x); + m_tree->Branch("sp_track_y",&m_sp_track_y); + m_tree->Branch("sp_track_z",&m_sp_track_z); + m_tree->Branch("sp_track_x_err",&m_sp_track_x_err); + m_tree->Branch("sp_track_y_err",&m_sp_track_y_err); + m_tree->Branch("sp_track_z_err",&m_sp_track_z_err); + m_tree->Branch("sp_track_x_predicted",&m_sp_track_x_predicted); + m_tree->Branch("sp_track_y_predicted",&m_sp_track_y_predicted); + m_tree->Branch("sp_track_z_predicted",&m_sp_track_z_predicted); + m_tree->Branch("sp_track_x_residual",&m_sp_track_x_residual); + m_tree->Branch("sp_track_y_residual",&m_sp_track_y_residual); + m_tree->Branch("sp_track_z_residual",&m_sp_track_z_residual); + m_tree->Branch("sp_track_station",&m_sp_track_station); + m_tree->Branch("sp_track_layer",&m_sp_track_layer); + m_tree->Branch("sp_track_module",&m_sp_track_module); + m_tree->Branch("trackId",&m_trackId); + m_tree->Branch("track_chi2",&m_track_chi2); + m_tree->Branch("track_edm",&m_track_edm); + m_tree->Branch("track_ndf",&m_track_ndf); + m_tree->Branch("track_p0",&m_track_p0); + m_tree->Branch("track_p1",&m_track_p1); + m_tree->Branch("track_p2",&m_track_p2); + m_tree->Branch("track_p3",&m_track_p3); + if(m_saveallcluster){ + m_tree->Branch("cluster_all_identify",&m_cluster_all_identify); + m_tree->Branch("cluster_all_local_x",&m_cluster_all_local_x); + m_tree->Branch("cluster_all_local_y",&m_cluster_all_local_y); + m_tree->Branch("cluster_global_x",&m_cluster_all_global_x); + m_tree->Branch("cluster_global_y",&m_cluster_all_global_y); + m_tree->Branch("cluster_global_z",&m_cluster_all_global_z); + m_tree->Branch("cluster_all_phiwidth",&m_cluster_all_phiwidth); + m_tree->Branch("cluster_all_size",&m_cluster_all_size); + m_tree->Branch("cluster_all_station",&m_cluster_all_station); + m_tree->Branch("cluster_all_layer",&m_cluster_all_layer); + m_tree->Branch("cluster_all_module",&m_cluster_all_module); + m_tree->Branch("cluster_all_side",&m_cluster_all_side); + m_tree->Branch("cluster_all_strip",&m_cluster_all_strip); + } + if(m_saveallsp){ + m_tree->Branch("sp_all_identify0", &m_sp_all_identify0); + m_tree->Branch("sp_all_identify1", &m_sp_all_identify1); + m_tree->Branch("sp_all_x_local", &m_sp_all_x_local); + m_tree->Branch("sp_all_y_local", &m_sp_all_y_local); + m_tree->Branch("sp_all_x", &m_sp_all_x); + m_tree->Branch("sp_all_y", &m_sp_all_y); + m_tree->Branch("sp_all_z", &m_sp_all_z); + m_tree->Branch("sp_all_station", &m_sp_all_station); + m_tree->Branch("sp_all_layer", &m_sp_all_layer); + m_tree->Branch("sp_all_module", &m_sp_all_module); + // if(m_saveallcluster){ + // m_tree->Branch("sp_all_clus1_index", &m_sp_all_clus1_index); + // m_tree->Branch("sp_all_clus2_index", &m_sp_all_clus2_index); + // } + } + } + //------------------------------------------------------------------------- + void TrackerSPFit::clearVariables() const { + if(m_saveallcluster){ + m_cluster_all_identify.clear(); + m_cluster_all_local_x.clear(); + m_cluster_all_local_y.clear(); + m_cluster_all_global_x.clear(); + m_cluster_all_global_y.clear(); + m_cluster_all_global_z.clear(); + m_cluster_all_phiwidth.clear(); + m_cluster_all_size.clear(); + m_cluster_all_station.clear(); + m_cluster_all_layer.clear(); + m_cluster_all_module.clear(); + m_cluster_all_side.clear(); + m_cluster_all_strip.clear(); + } + if(m_saveallsp){ + m_sp_all_identify0.clear(); + m_sp_all_identify1.clear(); + m_sp_all_x_local.clear(); + m_sp_all_y_local.clear(); + m_sp_all_x.clear(); + m_sp_all_y.clear(); + m_sp_all_z.clear(); + // if(m_saveallcluster){ + // m_sp_all_clus1_index.clear(); + // m_sp_all_clus2_index.clear(); + // } + m_sp_all_station.clear(); + m_sp_all_layer.clear(); + m_sp_all_module.clear(); + } + m_sp_track_x.clear(); + m_sp_track_y.clear(); + m_sp_track_z.clear(); + m_sp_track_x_err.clear(); + m_sp_track_y_err.clear(); + m_sp_track_z_err.clear(); + m_sp_track_x_predicted.clear(); + m_sp_track_y_predicted.clear(); + m_sp_track_z_predicted.clear(); + m_sp_track_x_residual.clear(); + m_sp_track_y_residual.clear(); + m_sp_track_z_residual.clear(); + m_sp_track_station.clear(); + m_sp_track_layer.clear(); + m_sp_track_module.clear(); + m_trackId.clear(); + m_track_chi2.clear(); + m_track_edm.clear(); + m_track_ndf.clear(); + m_track_p0.clear(); + m_track_p1.clear(); + m_track_p2.clear(); + m_track_p3.clear(); + } + //------------------------------------------------------------------------- + + StatusCode TrackerSPFit::execute (const EventContext& ctx) const + { + + ++m_numberOfEvents; + m_eventNumber=m_numberOfEvents; + clearVariables(); + const TrackerDD::SiDetectorElementCollection* elements = nullptr; + + + SG::ReadCondHandle<TrackerDD::SiDetectorElementCollection> sctDetEle(m_SCTDetEleCollKey, ctx); + elements = sctDetEle.retrieve(); + if (elements==nullptr) { + ATH_MSG_FATAL("Pointer of SiDetectorElementCollection (" << m_SCTDetEleCollKey.fullKey() << ") could not be retrieved"); + return StatusCode::SUCCESS; + } + + //read cluster + SG::ReadHandle<Tracker::FaserSCT_ClusterContainer> sct_clcontainer( m_Sct_clcontainerKey, ctx ); + if ((!sct_clcontainer.isValid())&&m_saveallcluster){ + msg(MSG:: FATAL) << "Could not find the data object "<< sct_clcontainer.name() << " !" << endmsg; + return StatusCode::RECOVERABLE; + } + // save all the cluster information + if(m_saveallcluster){ + ATH_MSG_DEBUG( "SCT cluster container found: " << sct_clcontainer->size() << " collections" ); + Tracker::FaserSCT_ClusterContainer::const_iterator clusit = sct_clcontainer->begin(); + Tracker::FaserSCT_ClusterContainer::const_iterator clusend = sct_clcontainer->end(); + for (; clusit != clusend; ++clusit){ + ++m_numberOfClusterCol; + const Tracker::FaserSCT_ClusterCollection *colNext=&(**clusit); + FaserSCT_ClusterCollection::const_iterator clusters {colNext->begin()} ; + FaserSCT_ClusterCollection::const_iterator clustersEnd {colNext->end() }; + for (; clusters != clustersEnd; ++clusters) + { + ++m_numberOfCluster; + const Tracker::FaserSCT_Cluster* clus=&(**clusters); + m_cluster_all_global_x.push_back(clus->globalPosition().x()); + m_cluster_all_global_y.push_back(clus->globalPosition().y()); + m_cluster_all_global_z.push_back(clus->globalPosition().z()); + m_cluster_all_local_x.push_back(clus->localPosition().x()); + m_cluster_all_local_y.push_back(clus->localPosition().y()); + m_cluster_all_phiwidth.push_back(clus->width().phiR()); + Identifier elementID = clus->identify(); + m_cluster_all_station.push_back( m_idHelper->station(elementID)); + m_cluster_all_identify.push_back( elementID.get_compact()); + m_cluster_all_layer.push_back( m_idHelper->layer(elementID)); + int ietamodule = m_idHelper->eta_module(elementID); + int iphimodule = m_idHelper->phi_module(elementID); + if(ietamodule<0)iphimodule+=4; + m_cluster_all_module.push_back(iphimodule); + m_cluster_all_side.push_back(m_idHelper->side(elementID)); + m_cluster_all_strip.push_back(m_idHelper->strip(elementID)); + m_cluster_all_size.push_back(clus->rdoList().size()); + } + } + + } + + + // retrieve SCT spacepoint container + SG::ReadHandle<FaserSCT_SpacePointContainer> sct_spcontainer( m_Sct_spcontainerKey, ctx ); + if (!sct_spcontainer.isValid()){ + msg(MSG:: FATAL) << "Could not find the data object "<< sct_spcontainer.name() << " !" << endmsg; + return StatusCode::RECOVERABLE; + } + + // save all the sp information + if(m_saveallsp){ + ATH_MSG_DEBUG( "SCT spacepoint container found: " << sct_spcontainer->size() << " collections" ); + FaserSCT_SpacePointContainer::const_iterator it = sct_spcontainer->begin(); + FaserSCT_SpacePointContainer::const_iterator itend = sct_spcontainer->end(); + + for (; it != itend; ++it){ + ++m_numberOfSPCol; + const FaserSCT_SpacePointCollection *colNext=&(**it); + FaserSCT_SpacePointCollection::const_iterator sp_begin= colNext->begin(); + FaserSCT_SpacePointCollection::const_iterator sp_end= colNext->end(); + Identifier elementID = colNext->identify(); + for (; sp_begin != sp_end; ++sp_begin){ + ++m_numberOfSP; + const Tracker::FaserSCT_SpacePoint* sp=&(**sp_begin); + m_sp_all_x_local.push_back(sp->localParameters().x()); + m_sp_all_y_local.push_back(sp->localParameters().y()); + m_sp_all_x.push_back(sp->globalPosition().x()); + m_sp_all_y.push_back(sp->globalPosition().y()); + m_sp_all_z.push_back(sp->globalPosition().z()); + m_sp_all_station.push_back(m_idHelper->station(elementID)); + m_sp_all_layer.push_back(m_idHelper->layer(elementID)); + m_sp_all_identify0.push_back(sp->clusterList().first->identify().get_compact()); + m_sp_all_identify1.push_back(sp->clusterList().second->identify().get_compact()); + int ietamodule = m_idHelper->eta_module(elementID); + int iphimodule = m_idHelper->phi_module(elementID); + if(ietamodule<0)iphimodule+=4; + m_sp_all_module.push_back(iphimodule); + ATH_MSG_DEBUG( "SCT spacepoint found: " << sp->globalPosition().x()<<" , "<<sp->globalPosition().y()<<" , "<<sp->globalPosition().z()<<" , "<<m_idHelper->station(elementID)<<" , "<<m_idHelper->layer(elementID)<<" , "<<m_idHelper->eta_module(elementID)<<" , "<<m_idHelper->phi_module(elementID) ); + /* to be updated + if(m_saveallcluster){ + const Tracker::FaserSCT_ClusterCollection *ptr1 = sct_clcontainer->indexFindPtr(sp->elemIDList().first()); + const Tracker::FaserSCT_ClusterCollection *ptr2 = sct_clcontainer->indexFindPtr(sp->elemIDList().second()); + m_sp_all_clus1_index.push_back(findClusterIndex(sp,ptr1)); + m_sp_all_clus2_index.push_back(findClusterIndex(sp,ptr2)); + } + */ + } + } + } + + // register the IdentifiableContainer into StoreGate + + ATH_MSG_DEBUG( "SCT spacepoint container found: " << sct_spcontainer->size() << " collections" ); + FaserSCT_SpacePointContainer::const_iterator it = sct_spcontainer->begin(); + FaserSCT_SpacePointContainer::const_iterator itend = sct_spcontainer->end(); + + std::vector<SP_Seed> sp_sta0; + std::vector<SP_Seed> sp_sta1; + std::vector<SP_Seed> sp_sta2; + sp_sta0.clear(); + sp_sta1.clear(); + sp_sta2.clear(); + for (; it != itend; ++it){ + const FaserSCT_SpacePointCollection *colNext=&(**it); + // int nReceivedSPSCT = colNext->size(); + + // Create SpacePointCollection + // IdentifierHash idHash = colNext->identifyHash(); + Identifier elementID = colNext->identify(); + + ATH_MSG_VERBOSE("reading SpacePoints collection "<<elementID.get_compact()<<" , and hash = "<<colNext->identifyHash() ); + int istation = m_idHelper->station(elementID); + int ilayer = m_idHelper->layer(elementID); + int ietamodule = m_idHelper->eta_module(elementID); + int iphimodule = m_idHelper->phi_module(elementID); + int imodule=iphimodule; + if(ietamodule<0)imodule+=4; + m_hist_strip->Fill(m_idHelper->strip(elementID)); + m_hist_station->Fill(istation); + m_hist_layer->Fill(ilayer); + size_t size = colNext->size(); + if (size == 0){ + ATH_MSG_DEBUG( "TrackerSPFit algorithm found no space points" ); + } else { + //In a MT environment the cache maybe filled by another thread in which case this will delete the duplicate + FaserSCT_SpacePointCollection::const_iterator sp_begin= colNext->begin(); + FaserSCT_SpacePointCollection::const_iterator sp_end= colNext->end(); + for (; sp_begin != sp_end; ++sp_begin){ + const FaserSCT_SpacePoint* sp=&(**sp_begin); + m_hist_r->Fill(sp->r()); + m_hist_eta->Fill(sp->eta()); + m_hist_phi->Fill(sp->phi()); + Amg::Vector3D gloPos=sp->globalPosition(); + Amg::Vector3D newgloPos; + m_hist_x->Fill(gloPos.x()); + m_hist_y->Fill(gloPos.y()); + m_hist_z->Fill(gloPos.z()); + struct SP_Seed tmp{gloPos,sp->globCovariance(),ilayer,imodule}; + ATH_MSG_DEBUG( "TrackerSPFit algorithm found no space points" ); + if(istation==1) + sp_sta0.push_back(tmp); + else if(istation==2) + sp_sta1.push_back(tmp); + else + sp_sta2.push_back(tmp); + + if ( ((istation-1)*3+ilayer) == 0 ) m_hist_x_y_plane0->Fill(gloPos.x(),gloPos.y()); + if ( ((istation-1)*3+ilayer) == 1 ) m_hist_x_y_plane1->Fill(gloPos.x(),gloPos.y()); + if ( ((istation-1)*3+ilayer) == 2 ) m_hist_x_y_plane2->Fill(gloPos.x(),gloPos.y()); + if ( ((istation-1)*3+ilayer) == 3 ) m_hist_x_y_plane3->Fill(gloPos.x(),gloPos.y()); + if ( ((istation-1)*3+ilayer) == 4 ) m_hist_x_y_plane4->Fill(gloPos.x(),gloPos.y()); + if ( ((istation-1)*3+ilayer) == 5 ) m_hist_x_y_plane5->Fill(gloPos.x(),gloPos.y()); + if ( ((istation-1)*3+ilayer) == 6 ) m_hist_x_y_plane6->Fill(gloPos.x(),gloPos.y()); + if ( ((istation-1)*3+ilayer) == 7 ) m_hist_x_y_plane7->Fill(gloPos.x(),gloPos.y()); + if ( ((istation-1)*3+ilayer) == 8 ) m_hist_x_y_plane8->Fill(gloPos.x(),gloPos.y()); + } + ATH_MSG_VERBOSE( size << " SpacePoints successfully added to Container !" ); + } + } + ATH_MSG_INFO( "TrackerSPFit number of spacepoints in each stations: "<<sp_sta0.size()<<" "<<sp_sta1.size()<<" "<<sp_sta2.size() ); + + bool ifTrack=false; + if(sp_sta0.size()>2&&sp_sta0.size()<100) { + auto tracks_sta0=makeTrackSeg(sp_sta0,m_maxchi2); + ATH_MSG_INFO( "TrackerSPFit found "<<tracks_sta0.size()<<" track segments in station 0 " ); + if(tracks_sta0.size()>0){ + ifTrack=true; + ATH_MSG_DEBUG( "TrackerSPFit fill the track info0 " ); + for(auto track:tracks_sta0){ + auto pre=track.predicted; + auto pos=track.pos; + ++m_numberOfTrack; + m_trackId.push_back(int(m_numberOfTrack/3)); + m_sp_track_x.push_back(pos.x()); + m_sp_track_y.push_back(pos.y()); + m_sp_track_z.push_back(pos.z()); + m_sp_track_x_err.push_back(track.err.x()); + m_sp_track_y_err.push_back(track.err.y()); + m_sp_track_z_err.push_back(track.err.z()); + m_sp_track_x_predicted.push_back(pre.x()); + m_sp_track_y_predicted.push_back(pre.y()); + m_sp_track_z_predicted.push_back(pre.z()); + m_sp_track_x_residual.push_back(pre.x()-pos.x()); + m_sp_track_y_residual.push_back(pre.y()-pos.y()); + m_sp_track_z_residual.push_back(pre.z()-pos.z()); + ATH_MSG_DEBUG(" fill the result "<<pre.x()<<" "<<pre.y()<<" "<<pre.z()<<" "<<pos.x()<<" "<<pos.y()<<" "<<pos.z()); + ATH_MSG_DEBUG(" Station/layer/module =1"<<"/"<<track.layer<<"/"<<track.module<<" , and track ID "<<m_numberOfTrack/3); + m_sp_track_station.push_back(0); + m_sp_track_layer.push_back(track.layer); + m_sp_track_module.push_back(track.module); + + if(m_bias){ + m_track_chi2.push_back(track.chi2); + m_track_edm.push_back(track.edm); + m_track_ndf.push_back(track.ndf); + m_track_p0.push_back(track.p0); + m_track_p1.push_back(track.p1); + m_track_p2.push_back(track.p2); + m_track_p3.push_back(track.p3); + } + if(track.layer==0){ m_residual_x_plane0->Fill(pre.x()-pos.x());m_residual_y_plane0->Fill(pre.y()-pos.y());} + if(track.layer==1){ m_residual_x_plane1->Fill(pre.x()-pos.x());m_residual_y_plane1->Fill(pre.y()-pos.y());} + if(track.layer==2){ m_residual_x_plane2->Fill(pre.x()-pos.x());m_residual_y_plane2->Fill(pre.y()-pos.y());} + if(track.layer==1){ + ATH_MSG_DEBUG(" only fill the layer 1, module = "<<track.module); + ATH_MSG_DEBUG(" measured = "<<pos.x()<<" , "<<pos.y()<<" , "<<pos.z()); + ATH_MSG_DEBUG(" predicted = "<<pre.x()<<" , "<<pre.y()<<" , "<<pre.z()); + if(track.module==0){ + m_preYhistX_s1l1m0->Fill(pos.x(),pos.y()-pre.y()); + m_preYhistY_s1l1m0->Fill(pos.y(),pos.y()-pre.y()); + m_preXhistX_s1l1m0->Fill(pos.x(),pos.x()-pre.x()); + m_preXhistY_s1l1m0->Fill(pos.y(),pos.x()-pre.x()); + } + if(track.module==1){ + m_preYhistX_s1l1m1->Fill(pos.x(),pos.y()-pre.y()); + m_preYhistY_s1l1m1->Fill(pos.y(),pos.y()-pre.y()); + m_preXhistX_s1l1m1->Fill(pos.x(),pos.x()-pre.x()); + m_preXhistY_s1l1m1->Fill(pos.y(),pos.x()-pre.x()); + } + if(track.module==2){ + m_preYhistX_s1l1m2->Fill(pos.x(),pos.y()-pre.y()); + m_preYhistY_s1l1m2->Fill(pos.y(),pos.y()-pre.y()); + m_preXhistX_s1l1m2->Fill(pos.x(),pos.x()-pre.x()); + m_preXhistY_s1l1m2->Fill(pos.y(),pos.x()-pre.x()); + } + if(track.module==3){ + m_preYhistX_s1l1m3->Fill(pos.x(),pos.y()-pre.y()); + m_preYhistY_s1l1m3->Fill(pos.y(),pos.y()-pre.y()); + m_preXhistX_s1l1m3->Fill(pos.x(),pos.x()-pre.x()); + m_preXhistY_s1l1m3->Fill(pos.y(),pos.x()-pre.x()); + } + if(track.module==4){ + m_preYhistX_s1l1m4->Fill(pos.x(),pos.y()-pre.y()); + m_preYhistY_s1l1m4->Fill(pos.y(),pos.y()-pre.y()); + m_preXhistX_s1l1m4->Fill(pos.x(),pos.x()-pre.x()); + m_preXhistY_s1l1m4->Fill(pos.y(),pos.x()-pre.x()); + } + if(track.module==5){ + m_preYhistX_s1l1m5->Fill(pos.x(),pos.y()-pre.y()); + m_preYhistY_s1l1m5->Fill(pos.y(),pos.y()-pre.y()); + m_preXhistX_s1l1m5->Fill(pos.x(),pos.x()-pre.x()); + m_preXhistY_s1l1m5->Fill(pos.y(),pos.x()-pre.x()); + } + if(track.module==6){ + m_preYhistX_s1l1m6->Fill(pos.x(),pos.y()-pre.y()); + m_preYhistY_s1l1m6->Fill(pos.y(),pos.y()-pre.y()); + m_preXhistX_s1l1m6->Fill(pos.x(),pos.x()-pre.x()); + m_preXhistY_s1l1m6->Fill(pos.y(),pos.x()-pre.x()); + } + if(track.module==7){ + m_preYhistX_s1l1m7->Fill(pos.x(),pos.y()-pre.y()); + m_preYhistY_s1l1m7->Fill(pos.y(),pos.y()-pre.y()); + m_preXhistX_s1l1m7->Fill(pos.x(),pos.x()-pre.x()); + m_preXhistY_s1l1m7->Fill(pos.y(),pos.x()-pre.x()); + } + } + } + } + } + if(sp_sta1.size()>2&&sp_sta1.size()<100) { + auto tracks_sta1=makeTrackSeg(sp_sta1,m_maxchi2); + ATH_MSG_INFO( "TrackerSPFit found "<<tracks_sta1.size()<<" track segments in station 1 " ); + if(tracks_sta1.size()>0){ + ifTrack=true; + for(auto track:tracks_sta1){ + auto pre=track.predicted; + auto pos=track.pos; + ++m_numberOfTrack; + m_trackId.push_back(int(m_numberOfTrack/3)); + m_sp_track_x.push_back(pos.x()); + m_sp_track_y.push_back(pos.y()); + m_sp_track_z.push_back(pos.z()); + m_sp_track_x_err.push_back(track.err.x()); + m_sp_track_y_err.push_back(track.err.y()); + m_sp_track_z_err.push_back(track.err.z()); + m_sp_track_x_predicted.push_back(pre.x()); + m_sp_track_y_predicted.push_back(pre.y()); + m_sp_track_z_predicted.push_back(pre.z()); + m_sp_track_x_residual.push_back(pre.x()-pos.x()); + m_sp_track_y_residual.push_back(pre.y()-pos.y()); + m_sp_track_z_residual.push_back(pre.z()-pos.z()); + m_sp_track_station.push_back(1); + m_sp_track_layer.push_back(track.layer); + m_sp_track_module.push_back(track.module); + if(m_bias){ + m_track_chi2.push_back(track.chi2); + m_track_edm.push_back(track.edm); + m_track_ndf.push_back(track.ndf); + m_track_p0.push_back(track.p0); + m_track_p1.push_back(track.p1); + m_track_p2.push_back(track.p2); + m_track_p3.push_back(track.p3); + } + if(track.layer==0){ m_residual_x_plane3->Fill(pre.x()-pos.x());m_residual_y_plane3->Fill(pre.y()-pos.y());} + if(track.layer==1){ m_residual_x_plane4->Fill(pre.x()-pos.x());m_residual_y_plane4->Fill(pre.y()-pos.y());} + if(track.layer==2){ m_residual_x_plane5->Fill(pre.x()-pos.x());m_residual_y_plane5->Fill(pre.y()-pos.y());} + } + } + } + if(sp_sta2.size()>2&&sp_sta2.size()<100) { + auto tracks_sta2=makeTrackSeg(sp_sta2,m_maxchi2); + ATH_MSG_INFO( "TrackerSPFit found "<<tracks_sta2.size()<<" track segments in station 2 " ); + if(tracks_sta2.size()>0){ + ifTrack=true; + for(auto track:tracks_sta2){ + auto pre=track.predicted; + auto pos=track.pos; + ++m_numberOfTrack; + m_trackId.push_back(int(m_numberOfTrack/3)); + m_sp_track_x.push_back(pos.x()); + m_sp_track_y.push_back(pos.y()); + m_sp_track_z.push_back(pos.z()); + m_sp_track_x_err.push_back(track.err.x()); + m_sp_track_y_err.push_back(track.err.y()); + m_sp_track_z_err.push_back(track.err.z()); + m_sp_track_x_predicted.push_back(pre.x()); + m_sp_track_y_predicted.push_back(pre.y()); + m_sp_track_z_predicted.push_back(pre.z()); + m_sp_track_x_residual.push_back(pre.x()-pos.x()); + m_sp_track_y_residual.push_back(pre.y()-pos.y()); + m_sp_track_z_residual.push_back(pre.z()-pos.z()); + m_sp_track_station.push_back(2); + m_sp_track_layer.push_back(track.layer); + m_sp_track_module.push_back(track.module); + if(m_bias){ + m_track_chi2.push_back(track.chi2); + m_track_edm.push_back(track.edm); + m_track_ndf.push_back(track.ndf); + m_track_p0.push_back(track.p0); + m_track_p1.push_back(track.p1); + m_track_p2.push_back(track.p2); + m_track_p3.push_back(track.p3); + } + if(track.layer==0){ m_residual_x_plane6->Fill(pre.x()-pos.x());m_residual_y_plane6->Fill(pre.y()-pos.y());} + if(track.layer==1){ m_residual_x_plane7->Fill(pre.x()-pos.x());m_residual_y_plane7->Fill(pre.y()-pos.y());} + if(track.layer==2){ m_residual_x_plane8->Fill(pre.x()-pos.x());m_residual_y_plane8->Fill(pre.y()-pos.y());} + } + } + } + + if(ifTrack) + m_tree->Fill(); + else if(m_saveallcluster||m_saveallsp) + m_tree->Fill(); + return StatusCode::SUCCESS; + } + + //--------------------------------------------------------------------------- + StatusCode TrackerSPFit::finalize() + { + ATH_MSG_INFO( "TrackerSPFit::finalize()" ); + ATH_MSG_INFO( m_numberOfEvents << " events processed" ); + ATH_MSG_INFO( m_numberOfClusterCol<< " sct Cluster collections processed" ); + ATH_MSG_INFO( m_numberOfCluster<< " sct Cluster processed" ); + ATH_MSG_INFO( m_numberOfSPCol<< " sct SP collections processed" ); + ATH_MSG_INFO( m_numberOfSP<< " sct SP processed" ); + + + //do a fitting + TF1* fpol1=new TF1("fpol1","pol1(0)"); + m_preYhistX_s1l1m0->Fit(fpol1); + ATH_MSG_INFO("Fitting the residualY vs X for module 0 : parameter = "<<fpol1->GetParameter(0)<<" "<<fpol1->GetParameter(1)); + m_preYhistX_s1l1m1->Fit(fpol1); + ATH_MSG_INFO("Fitting the residualY vs X for module 1 : parameter = "<<fpol1->GetParameter(0)<<" "<<fpol1->GetParameter(1)); + m_preYhistX_s1l1m2->Fit(fpol1); + ATH_MSG_INFO("Fitting the residualY vs X for module 2 : parameter = "<<fpol1->GetParameter(0)<<" "<<fpol1->GetParameter(1)); + m_preYhistX_s1l1m3->Fit(fpol1); + ATH_MSG_INFO("Fitting the residualY vs X for module 3 : parameter = "<<fpol1->GetParameter(0)<<" "<<fpol1->GetParameter(1)); + m_preYhistX_s1l1m4->Fit(fpol1); + ATH_MSG_INFO("Fitting the residualY vs X for module 4 : parameter = "<<fpol1->GetParameter(0)<<" "<<fpol1->GetParameter(1)); + m_preYhistX_s1l1m5->Fit(fpol1); + ATH_MSG_INFO("Fitting the residualY vs X for module 5 : parameter = "<<fpol1->GetParameter(0)<<" "<<fpol1->GetParameter(1)); + m_preYhistX_s1l1m6->Fit(fpol1); + ATH_MSG_INFO("Fitting the residualY vs X for module 6 : parameter = "<<fpol1->GetParameter(0)<<" "<<fpol1->GetParameter(1)); + m_preYhistX_s1l1m7->Fit(fpol1); + ATH_MSG_INFO("Fitting the residualY vs X for module 7 : parameter = "<<fpol1->GetParameter(0)<<" "<<fpol1->GetParameter(1)); + return StatusCode::SUCCESS; + } + + //-------------------------------------------------------------------------- + std::vector<TrackerSPFit::SP_TSOS> TrackerSPFit::makeTrackSeg(std::vector<SP_Seed> sps, double maxchi2) const { + std::vector<SP_Seed> layer0; + std::vector<SP_Seed> layer1; + std::vector<SP_Seed> layer2; + layer0.clear();layer1.clear();layer2.clear(); + std::vector<SP_TSOS> tracks; + tracks.clear(); + for(unsigned int isp=0;isp<sps.size();isp++){ + if(sps[isp].layer==0)layer0.push_back(sps[isp]); + if(sps[isp].layer==1)layer1.push_back(sps[isp]); + if(sps[isp].layer==2)layer2.push_back(sps[isp]); + } + if(layer0.size()>0&&layer1.size()>0&&layer2.size()>0){ + for(unsigned int i0=0;i0<layer0.size();i0++){ + for(unsigned int i1=0;i1<layer1.size();i1++){ + for(unsigned int i2=0;i2<layer2.size();i2++){ + auto tmp_bias=makeTrackSeg(layer0[i0],layer1[i1],layer2[i2],maxchi2); + if(tmp_bias.size()>0){ + if(m_bias){ + //for biased residual + tracks.insert(tracks.end(),tmp_bias.begin(),tmp_bias.end()); + } + else{ + //for un-biased residual + auto tmp=makeTrackSeg(layer0[i0],layer1[i1],layer2[i2]); + tracks.insert(tracks.end(),tmp.begin(),tmp.end()); + } + } + } + } + } + } + return tracks; + } + + std::vector<TrackerSPFit::SP_TSOS> TrackerSPFit::makeTrackSeg(SP_Seed sp0, SP_Seed sp1, SP_Seed sp2) const{ + std::vector<SP_TSOS> spt; + spt.clear(); + for(int isp=0;isp<3;isp++){ + Amg::Vector3D error; + + if(isp==0){ + error=Amg::Vector3D(sqrt((sp0.cov)(0,0)),sqrt((sp0.cov)(1,1)),sqrt((sp0.cov)(2,2))); + //double resx= sp0.pos.x()-(sp1.pos.x()+sp2.pos.x())/2.;//from Jamie's code + double posx= (sp1.pos.x()-((sp1.pos.x()-sp2.pos.x())*(sp1.pos.z()-sp0.pos.z())/(sp1.pos.z()-sp2.pos.z()))); + double posy= (sp1.pos.y()-((sp1.pos.y()-sp2.pos.y())*(sp1.pos.z()-sp0.pos.z())/(sp1.pos.z()-sp2.pos.z()))); + Amg::Vector3D predictedpoint2(posx,posy,sp0.pos.z()); + + struct SP_TSOS tsos0{sp0.pos,predictedpoint2,error,sp0.layer,sp0.module}; + spt.push_back(tsos0); + } + else if(isp==1){ + error=Amg::Vector3D(sqrt((sp1.cov)(0,0)),sqrt((sp1.cov)(1,1)),sqrt((sp1.cov)(2,2))); + double posx= (sp2.pos.x()-((sp2.pos.x()-sp0.pos.x())*(sp2.pos.z()-sp1.pos.z())/(sp2.pos.z()-sp0.pos.z()))); + double posy= (sp2.pos.y()-((sp2.pos.y()-sp0.pos.y())*(sp2.pos.z()-sp1.pos.z())/(sp2.pos.z()-sp0.pos.z()))); + Amg::Vector3D predictedpoint2(posx,posy,sp1.pos.z()); + + struct SP_TSOS tsos0{sp1.pos,predictedpoint2,error,sp1.layer,sp1.module}; + spt.push_back(tsos0); + } + else{ + error=Amg::Vector3D(sqrt((sp2.cov)(0,0)),sqrt((sp2.cov)(1,1)),sqrt((sp2.cov)(2,2))); + double posx= (sp1.pos.x()-((sp1.pos.x()-sp0.pos.x())*(sp1.pos.z()-sp2.pos.z())/(sp1.pos.z()-sp0.pos.z()))); + double posy= (sp1.pos.y()-((sp1.pos.y()-sp0.pos.y())*(sp1.pos.z()-sp2.pos.z())/(sp1.pos.z()-sp0.pos.z()))); + Amg::Vector3D predictedpoint2(posx,posy,sp2.pos.z()); + + struct SP_TSOS tsos0{sp2.pos,predictedpoint2,error,sp2.layer,sp2.module}; + spt.push_back(tsos0); + } + + } + return spt; + } + std::vector<TrackerSPFit::SP_TSOS> TrackerSPFit::makeTrackSeg(SP_Seed sp0, SP_Seed sp1, SP_Seed sp2, double maxchi2) const{ + std::vector<SP_TSOS> spt; + spt.clear(); + TGraph2DErrors* gra= new TGraph2DErrors(); + gra->SetPoint(0,sp0.pos.x(),sp0.pos.y(),sp0.pos.z()); + gra->SetPoint(1,sp1.pos.x(),sp1.pos.y(),sp1.pos.z()); + gra->SetPoint(2,sp2.pos.x(),sp2.pos.y(),sp2.pos.z()); + gra->SetPointError(0,sqrt((sp0.cov)(0,0)),sqrt((sp0.cov)(1,1)),sqrt((sp0.cov)(2,2))); + gra->SetPointError(1,sqrt((sp1.cov)(0,0)),sqrt((sp1.cov)(1,1)),sqrt((sp1.cov)(2,2))); + gra->SetPointError(2,sqrt((sp2.cov)(0,0)),sqrt((sp2.cov)(1,1)),sqrt((sp2.cov)(2,2))); + ATH_MSG_DEBUG(" spacepoints in the station"); + ATH_MSG_DEBUG("sp 0 "<<sp0.pos.x()<<" "<<sp0.pos.y()<<" "<<sp0.pos.z()<<" "<<sqrt((sp0.cov)(0,0))<<" "<<sqrt((sp0.cov)(1,1))<<" "<<sqrt((sp0.cov)(2.2))); + ATH_MSG_DEBUG("sp 1 "<<sp1.pos.x()<<" "<<sp1.pos.y()<<" "<<sp1.pos.z()<<" "<<sqrt((sp1.cov)(0,0))<<" "<<sqrt((sp1.cov)(1,1))<<" "<<sqrt((sp1.cov)(2.2))); + ATH_MSG_DEBUG("sp 2 "<<sp2.pos.x()<<" "<<sp2.pos.y()<<" "<<sp2.pos.z()<<" "<<sqrt((sp2.cov)(0,0))<<" "<<sqrt((sp2.cov)(1,1))<<" "<<sqrt((sp2.cov)(2.2))); + ROOT::Fit::Fitter fitter; + SumDistance2 sumdist(gra); + ROOT::Math::Functor fcn(sumdist,4); + double initParam[4]={1,1,1,1}; + fitter.SetFCN(fcn,initParam); + // for (int i = 0; i < 4; ++i) fitter.Config().ParSettings(i).SetStepSize(0.01); + if(fitter.FitFCN()){ + const ROOT::Fit::FitResult & result =fitter.Result(); + double chi2=result.MinFcnValue(); + double edm=result.Edm(); + int ndf=result.Ndf(); + ATH_MSG_DEBUG( "TrackerSPFit::makeTrackSeg(), track chi2 = "<<chi2<<" ; edm = "<<edm<<" ; ndf = "<<ndf ); + m_chi2->Fill(chi2); + m_edm->Fill(edm); + m_ndf->Fill(ndf); + + if(chi2<maxchi2){ + // result.Print(std::cout); + const double *fitParam=result.GetParams(); + ATH_MSG_DEBUG(" fit status: ook "<<chi2<<" "<<edm<<" "<<ndf<<" "<<fitParam[0]<<" "<<fitParam[1]<<" "<<fitParam[2]<<" "<<fitParam[3]); + Amg::Vector3D err0(sqrt((sp0.cov)(0,0)),sqrt((sp0.cov)(1,1)),sqrt((sp0.cov)(2,2))); + Amg::Vector3D err1(sqrt((sp1.cov)(0,0)),sqrt((sp1.cov)(1,1)),sqrt((sp1.cov)(2,2))); + Amg::Vector3D err2(sqrt((sp2.cov)(0,0)),sqrt((sp2.cov)(1,1)),sqrt((sp2.cov)(2,2))); + struct SP_TSOS tsos0{sp0.pos,predicted(sp0.pos.z(),fitParam),err0,sp0.layer,sp0.module,chi2,edm,ndf,fitParam[0],fitParam[1],fitParam[2],fitParam[3]}; + struct SP_TSOS tsos1{sp1.pos,predicted(sp1.pos.z(),fitParam),err1,sp1.layer,sp0.module,chi2,edm,ndf,fitParam[0],fitParam[1],fitParam[2],fitParam[3]}; + struct SP_TSOS tsos2{sp2.pos,predicted(sp2.pos.z(),fitParam),err2,sp2.layer,sp0.module,chi2,edm,ndf,fitParam[0],fitParam[1],fitParam[2],fitParam[3]}; + spt.push_back(tsos0); + spt.push_back(tsos1); + spt.push_back(tsos2); + } + } + + return spt; + } + + Amg::Vector3D TrackerSPFit::predicted(double z, const double *p) const { + return Amg::Vector3D(p[0]+p[1]*z,p[2]+p[3]*z,z); + } + + + /* + * need to be updated + int TrackerSPFit::findClusterIndex(const Tracker::FaserSCT_SpacePoint* sp, const Tracker::FaserSCT_ClusterCollection* ptr)const { + if (ptr!=nullptr) { +//loop though collection to find matching PRD. +Tracker::FaserSCT_ClusterCollection::const_iterator collIt = ptr->begin(); +Tracker::FaserSCT_ClusterCollection::const_iterator collItEnd = ptr->end(); +for ( ; collIt!=collItEnd; collIt++) { +if ( (*collIt)->identify()==id1 ) +clus1= &(**collIt); +} +} + +} +*/ + +} diff --git a/Tracker/TrackerRecAlgs/TrackerSPFit/src/TrackerSPFit.h b/Tracker/TrackerRecAlgs/TrackerSPFit/src/TrackerSPFit.h new file mode 100755 index 0000000000000000000000000000000000000000..3db42689651f647cb465eb6f671346780ec96940 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSPFit/src/TrackerSPFit.h @@ -0,0 +1,254 @@ +// -*- C++ -*- + +/* + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration + */ + +#ifndef TRACKERSPFIT_TRACKERSPACEPOINTMAKERALG_H +#define TRACKERSPFIT_TRACKERSPACEPOINTMAKERALG_H + +#include "StoreGate/ReadCondHandleKey.h" +#include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "Identifier/Identifier.h" + +#include "TrackerPrepRawData/FaserSCT_ClusterCollection.h" +#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" +#include "TrackerPrepRawData/TrackerClusterContainer.h" +#include "TrackerReadoutGeometry/SiDetectorElementCollection.h" +#include "TrackerSpacePoint/FaserSCT_SpacePoint.h" +#include "TrackerSpacePoint/FaserSCT_SpacePointContainer.h" +#include "TrackerSpacePoint/FaserSCT_SpacePointOverlapCollection.h" +#include "TrkEventPrimitives/LocalParameters.h" + +#include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/ITHistSvc.h" + +#include <string> +#include <vector> +#include "TH1.h" +#include "TH2.h" +#include "TF1.h" +#include "TTree.h" +#include "TGraph2DErrors.h" +#include "TMath.h" +#include "Math/Functor.h" +#include "Fit/Fitter.h" +#include "Math/Vector3D.h" + +#include <string> + +class FaserSCT_ID; +namespace Tracker +{ + + class TrackerSPFit:public AthReentrantAlgorithm { + + public: + + /** + * @name AthReentrantAlgorithm methods + */ + //@{ + TrackerSPFit(const std::string& name, + ISvcLocator* pSvcLocator); + + virtual ~TrackerSPFit() = default; + + virtual StatusCode initialize() override; + + virtual StatusCode execute (const EventContext& ctx) const override; + + virtual StatusCode finalize() override; + + struct SP_Seed{Amg::Vector3D pos; Amg::MatrixX cov; int layer; int module;}; + struct SP_TSOS{Amg::Vector3D pos; Amg::Vector3D predicted; Amg::Vector3D err; int layer;int module; double chi2=-1.; double edm=-1.; int ndf=-1;double p0=0.;double p1=0.;double p2=0.;double p3=0;}; + //struct SP_TSOS{Amg::Vector3D pos; Amg::Vector3D predicted; Amg::Vector3D err; int layer;int module; const double *p;}; + std::vector<SP_TSOS> makeTrackSeg(std::vector<SP_Seed> sps, double maxchi2) const; + std::vector<SP_TSOS> makeTrackSeg(SP_Seed sp0, SP_Seed sp1, SP_Seed sp2, double maxchi2) const; + std::vector<SP_TSOS> makeTrackSeg(SP_Seed sp0, SP_Seed sp1, SP_Seed sp2) const; + Amg::Vector3D predicted(double z, const double *p) const; + + // function Object to be minimized + struct SumDistance2 { + // the TGraph is a data member of the object + TGraph2DErrors *fGraph; + SumDistance2(TGraph2DErrors *g) : fGraph(g) {} + // calculate distance line-point + double distance2(double x,double y,double z, double xe, double ye, const double *p) { + double xpred=p[0]+p[1]*z; + double ypred=p[2]+p[3]*z; + double xchi2= (xpred-x)*(xpred-x)/xe/xe; + double ychi2= (ypred-y)*(ypred-y)/ye/ye; + double d2=xchi2+ychi2; + return d2; + } + // implementation of the function to be minimized + double operator() (const double *par) { + assert(fGraph != 0); + double * x = fGraph->GetX(); + double * y = fGraph->GetY(); + double * z = fGraph->GetZ(); + double * xe = fGraph->GetEX(); + double * ye = fGraph->GetEY(); + int npoints = fGraph->GetN(); + double sum = 0; + for (int i = 0; i < npoints; ++i) { + double d = distance2(x[i],y[i],z[i],xe[i],ye[i],par); + sum += d; + } + return sum; + } + }; + + private: + void initializeTree(); + void clearVariables() const; + mutable TTree* m_tree; + TrackerSPFit() = delete; + TrackerSPFit(const TrackerSPFit&) =delete; + TrackerSPFit &operator=(const TrackerSPFit&) = delete; + + SG::ReadHandleKey<FaserSCT_SpacePointContainer> m_Sct_spcontainerKey{this, "SpacePointsSCTName", "SCT_SpacePointContainer"}; + SG::ReadHandleKey<Tracker::FaserSCT_ClusterContainer> m_Sct_clcontainerKey{this, "SCT_ClustersName", "SCT clContainer"}; + + SG::ReadCondHandleKey<TrackerDD::SiDetectorElementCollection> m_SCTDetEleCollKey{this, "SCTDetEleCollKey", "SCT_DetectorElementCollection", "Key of SiDetectorElementCollection for SCT"}; + + const FaserSCT_ID* m_idHelper{nullptr}; + mutable std::atomic<int> m_numberOfEvents{0}; + mutable std::atomic<int> m_numberOfSCT{0}; + mutable std::atomic<int> m_numberOfTrack{0}; + mutable std::atomic<int> m_numberOfSP{0}; + mutable std::atomic<int> m_numberOfCluster{0}; + mutable std::atomic<int> m_numberOfSPCol{0}; + mutable std::atomic<int> m_numberOfClusterCol{0}; + //@} + TH1* m_hist_x; + TH1* m_hist_y; + TH1* m_hist_z; + TH1* m_hist_r; + TH1* m_hist_eta; + TH1* m_hist_phi; + TH1* m_hist_station; + TH1* m_hist_strip; + TH1* m_hist_layer; + TH2* m_hist_x_y_plane0; + TH2* m_hist_x_y_plane1; + TH2* m_hist_x_y_plane2; + TH2* m_hist_x_y_plane3; + TH2* m_hist_x_y_plane4; + TH2* m_hist_x_y_plane5; + TH2* m_hist_x_y_plane6; + TH1* m_hist_x_y_plane7; + TH1* m_hist_x_y_plane8; + TH1* m_residual_y_plane0; + TH1* m_residual_y_plane1; + TH1* m_residual_y_plane2; + TH1* m_residual_y_plane3; + TH1* m_residual_y_plane4; + TH1* m_residual_y_plane5; + TH1* m_residual_y_plane6; + TH1* m_residual_y_plane7; + TH1* m_residual_y_plane8; + TH1* m_residual_x_plane0; + TH1* m_residual_x_plane1; + TH1* m_residual_x_plane2; + TH1* m_residual_x_plane3; + TH1* m_residual_x_plane4; + TH1* m_residual_x_plane5; + TH1* m_residual_x_plane6; + TH1* m_residual_x_plane7; + TH1* m_residual_x_plane8; + TH1* m_chi2; + TH1* m_edm; + TH1* m_ndf; + ServiceHandle<ITHistSvc> m_thistSvc; + //for alignment constants + TProfile* m_preYhistX_s1l1m0; + TProfile* m_preYhistY_s1l1m0; + TProfile* m_preXhistX_s1l1m0; + TProfile* m_preXhistY_s1l1m0; + TProfile* m_preYhistX_s1l1m1; + TProfile* m_preYhistY_s1l1m1; + TProfile* m_preXhistX_s1l1m1; + TProfile* m_preXhistY_s1l1m1; + TProfile* m_preYhistX_s1l1m2; + TProfile* m_preYhistY_s1l1m2; + TProfile* m_preXhistX_s1l1m2; + TProfile* m_preXhistY_s1l1m2; + TProfile* m_preYhistX_s1l1m3; + TProfile* m_preYhistY_s1l1m3; + TProfile* m_preXhistX_s1l1m3; + TProfile* m_preXhistY_s1l1m3; + TProfile* m_preYhistX_s1l1m4; + TProfile* m_preYhistY_s1l1m4; + TProfile* m_preXhistX_s1l1m4; + TProfile* m_preXhistY_s1l1m4; + TProfile* m_preYhistX_s1l1m5; + TProfile* m_preYhistY_s1l1m5; + TProfile* m_preXhistX_s1l1m5; + TProfile* m_preXhistY_s1l1m5; + TProfile* m_preYhistX_s1l1m6; + TProfile* m_preYhistY_s1l1m6; + TProfile* m_preXhistX_s1l1m6; + TProfile* m_preXhistY_s1l1m6; + TProfile* m_preYhistX_s1l1m7; + TProfile* m_preYhistY_s1l1m7; + TProfile* m_preXhistX_s1l1m7; + TProfile* m_preXhistY_s1l1m7; + + mutable int m_eventNumber; + mutable std::vector<double> m_sp_track_x; + mutable std::vector<double> m_sp_track_y; + mutable std::vector<double> m_sp_track_z; + mutable std::vector<double> m_sp_track_x_err; + mutable std::vector<double> m_sp_track_y_err; + mutable std::vector<double> m_sp_track_z_err; + mutable std::vector<double> m_sp_track_x_predicted; + mutable std::vector<double> m_sp_track_y_predicted; + mutable std::vector<double> m_sp_track_z_predicted; + mutable std::vector<double> m_sp_track_x_residual; + mutable std::vector<double> m_sp_track_y_residual; + mutable std::vector<double> m_sp_track_z_residual; + mutable std::vector<int> m_sp_track_station; + mutable std::vector<int> m_sp_track_layer; + mutable std::vector<int> m_sp_track_module; + mutable std::vector<int> m_trackId; + mutable std::vector<double> m_track_chi2; + mutable std::vector<double> m_track_edm; + mutable std::vector<int> m_track_ndf; + mutable std::vector<double> m_track_p0; + mutable std::vector<double> m_track_p1; + mutable std::vector<double> m_track_p2; + mutable std::vector<double> m_track_p3; + double m_maxchi2; + bool m_bias; + bool m_saveallcluster; + mutable std::vector<double> m_cluster_all_global_x; + mutable std::vector<double> m_cluster_all_global_y; + mutable std::vector<double> m_cluster_all_global_z; + mutable std::vector<double> m_cluster_all_local_x; + mutable std::vector<double> m_cluster_all_local_y; + mutable std::vector<double> m_cluster_all_phiwidth; + mutable std::vector<long long int> m_cluster_all_identify; + mutable std::vector<int> m_cluster_all_size; + mutable std::vector<int> m_cluster_all_station; + mutable std::vector<int> m_cluster_all_layer; + mutable std::vector<int> m_cluster_all_module; + mutable std::vector<int> m_cluster_all_side; + mutable std::vector<int> m_cluster_all_strip; + bool m_saveallsp; + mutable std::vector<double> m_sp_all_x_local; + mutable std::vector<double> m_sp_all_y_local; + mutable std::vector<double> m_sp_all_x; + mutable std::vector<double> m_sp_all_y; + mutable std::vector<double> m_sp_all_z; + mutable std::vector<int> m_sp_all_station; + mutable std::vector<int> m_sp_all_layer; + mutable std::vector<int> m_sp_all_module; + mutable std::vector<long long int> m_sp_all_identify0; + mutable std::vector<long long int> m_sp_all_identify1; + + }; + +} +#endif // TrackerSpacePointMakerAlg_TRACKERSPACEPOINTMAKERALG_H diff --git a/Tracker/TrackerRecAlgs/TrackerSPFit/src/components/TrackerSPFit_entries.cxx b/Tracker/TrackerRecAlgs/TrackerSPFit/src/components/TrackerSPFit_entries.cxx new file mode 100644 index 0000000000000000000000000000000000000000..dae3ad64eaa4a78be1459c5a8294d9db692e524d --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSPFit/src/components/TrackerSPFit_entries.cxx @@ -0,0 +1,4 @@ +#include "../TrackerSPFit.h" + +DECLARE_COMPONENT( Tracker::TrackerSPFit ) + diff --git a/Tracker/TrackerRecAlgs/TrackerSPFit/test/TrackerSPFitDbg.py b/Tracker/TrackerRecAlgs/TrackerSPFit/test/TrackerSPFitDbg.py new file mode 100644 index 0000000000000000000000000000000000000000..6734b9ccadb9e9732f405eec826c00319bbf6a45 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSPFit/test/TrackerSPFitDbg.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +"""Test various ComponentAccumulator Digitization configuration modules + +Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +""" +import sys +from AthenaCommon.Logging import log, logging +from AthenaCommon.Constants import DEBUG, VERBOSE, INFO +from AthenaCommon.Configurable import Configurable +from CalypsoConfiguration.AllConfigFlags import ConfigFlags +from AthenaConfiguration.TestDefaults import defaultTestFiles +from CalypsoConfiguration.MainServicesConfig import MainServicesCfg +from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg +from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg +from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg +from TrackerSpacePointFormation.TrackerSpacePointFormationConfig import TrackerSpacePointFinderCfg +from TrackerSPFit.TrackerSPFitConfig import TrackerSPFitCfg +from TrackerPrepRawDataFormation.TrackerPrepRawDataFormationConfig import FaserSCT_ClusterizationCfg +#from MCTruthSimAlgs.RecoTimingConfig import MergeRecoTimingObjCfg + +# Set up logging and new style config +log.setLevel(DEBUG) +Configurable.configurableRun3Behavior = True + +# Configure +ConfigFlags.Input.Files = ['my.RDO.pool.root'] +ConfigFlags.Output.ESDFileName = "mySpacePoints.ESD.pool.root" +ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01" # Always needed; must match FaserVersion +ConfigFlags.GeoModel.Align.Dynamic = False +ConfigFlags.Beam.NumberOfCollisions = 0. + +ConfigFlags.lock() + +# Core components +acc = MainServicesCfg(ConfigFlags) +acc.merge(PoolReadCfg(ConfigFlags)) +acc.merge(PoolWriteCfg(ConfigFlags)) + +#acc.merge(writeDigitizationMetadata(ConfigFlags)) + +# Inner Detector +acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags)) +acc.merge(TrackerSpacePointFinderCfg(ConfigFlags)) +acc.merge(TrackerSPFitCfg(ConfigFlags)) + +# Timing +#acc.merge(MergeRecoTimingObjCfg(ConfigFlags)) + +# Dump config +# logging.getLogger('forcomps').setLevel(VERBOSE) +acc.foreach_component("*").OutputLevel = VERBOSE +acc.foreach_component("*ClassID*").OutputLevel = INFO +acc.getCondAlgo("FaserSCT_AlignCondAlg").OutputLevel = VERBOSE +acc.getCondAlgo("FaserSCT_DetectorElementCondAlg").OutputLevel = VERBOSE +# acc.getService("StoreGateSvc").Dump = True +# acc.getService("ConditionStore").Dump = True +# acc.printConfig(withDetails=True) +# ConfigFlags.dump() + +# Execute and finish +sc = acc.run(maxEvents=-1) + +# Success should be 0 +sys.exit(not sc.isSuccess()) diff --git a/Tracker/TrackerRecAlgs/TrackerSeedFinder/CMakeLists.txt b/Tracker/TrackerRecAlgs/TrackerSeedFinder/CMakeLists.txt index b37eb389da8103ef92ad755e133465b92c3b9afa..f7c60bc83df79b7ee538b2cfe4f5e12842f50e68 100644 --- a/Tracker/TrackerRecAlgs/TrackerSeedFinder/CMakeLists.txt +++ b/Tracker/TrackerRecAlgs/TrackerSeedFinder/CMakeLists.txt @@ -10,13 +10,14 @@ find_package( Eigen ) # Component(s) in the package: atlas_add_library( TrackerSeedFinderLib - src/components/*.cxx src/*.cxx src/*.h - NO_PUBLIC_HEADERS + src/components/*.cxx src/*.cxx TrackerSeedFinder/*.h + PUBLIC_HEADERS TrackerSeedFinder INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps AthContainers GeoPrimitives Identifier GaudiKernel TrackerReadoutGeometry TrackerRawData TrackerSimData GeneratorObjects TrackerSimEvent TrackerSpacePoint VxVertex FaserDetDescr xAODEventInfo TrackerIdentifier TrackerPrepRawData AthenaMonitoringKernelLib) atlas_add_component( TrackerSeedFinder - src/components/*.cxx src/*.cxx src/*.h + src/components/*.cxx src/*.cxx TrackerSeedFinder/*.h + PUBLIC_HEADERS TrackerSeedFinder INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps AthContainers GeoPrimitives Identifier GaudiKernel TrackerReadoutGeometry TrackerRawData TrackerSimData GeneratorObjects TrackerSimEvent TrackerSpacePoint VxVertex FaserDetDescr xAODEventInfo TrackerIdentifier TrackerPrepRawData AthenaMonitoringKernelLib) diff --git a/Tracker/TrackerRecAlgs/TrackerSeedFinder/src/TrackerSeedFinder.h b/Tracker/TrackerRecAlgs/TrackerSeedFinder/TrackerSeedFinder/TrackerSeedFinder.h similarity index 80% rename from Tracker/TrackerRecAlgs/TrackerSeedFinder/src/TrackerSeedFinder.h rename to Tracker/TrackerRecAlgs/TrackerSeedFinder/TrackerSeedFinder/TrackerSeedFinder.h index eabebe327c8d693b2f30e803ed778bd8b4916176..ab9d99ab5bf4868fda22b830d5d2076ae82bf576 100755 --- a/Tracker/TrackerRecAlgs/TrackerSeedFinder/src/TrackerSeedFinder.h +++ b/Tracker/TrackerRecAlgs/TrackerSeedFinder/TrackerSeedFinder/TrackerSeedFinder.h @@ -21,13 +21,13 @@ #include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" #include "TrackerPrepRawData/TrackerClusterContainer.h" #include "TrackerReadoutGeometry/SiDetectorElementCollection.h" -#include "TrkSpacePoint/SpacePoint.h" -#include "TrkSpacePoint/SpacePointContainer.h" +#include "TrackerSpacePoint/FaserSCT_SpacePoint.h" +#include "TrackerSpacePoint/FaserSCT_SpacePointContainer.h" +#include "TrackerSpacePoint/FaserSCT_SpacePointOverlapCollection.h" #include "TrackerSpacePoint/SpacePointForSeedCollection.h" -#include "TrackerPrepRawData/TrackerSeedCollection.h" -#include "TrackerPrepRawData/TrackerSeed.h" -#include "TrkSpacePoint/SpacePointOverlapCollection.h" +#include "TrackerSpacePoint/TrackerSeedCollection.h" +#include "TrackerSpacePoint/TrackerSeed.h" #include "TrackerSimEvent/FaserSiHitCollection.h" #include "TrackerRawData/FaserSCT_RDO_Container.h" #include "TrackerSimData/TrackerSimDataCollection.h" @@ -67,29 +67,29 @@ namespace Tracker { private: struct seed { - vector<const Trk::SpacePoint*> vsp; + vector<const FaserSCT_SpacePoint*> vsp; double axz, bxz, ayz, byz; double chi2_xz, chi2_yz; string station; int num; - void add_sp(const Trk::SpacePoint* sp) { + void add_sp(const FaserSCT_SpacePoint* sp) { vsp.push_back(sp); } - void add_vsp(vector<const Trk::SpacePoint*> v) { - for (vector<const Trk::SpacePoint*>::iterator it = v.begin(); it != v.end(); ++it) { + void add_vsp(vector<const FaserSCT_SpacePoint*> v) { + for (vector<const FaserSCT_SpacePoint*>::iterator it = v.begin(); it != v.end(); ++it) { vsp.push_back((*it)); } } }; - StatusCode make_triplets(vector< vector<const Trk::SpacePoint*> >&, vector<seed>&, string) const; + StatusCode make_triplets(vector< vector<const FaserSCT_SpacePoint*> >&, vector<seed>&, string) const; TrackerSeedFinder() = delete; TrackerSeedFinder(const TrackerSeedFinder&) =delete; TrackerSeedFinder &operator=(const TrackerSeedFinder&) = delete; - SG::ReadHandleKey<SpacePointContainer> m_Sct_spcontainerKey{this, "SpacePointsSCTName", "SCT spContainer"}; + SG::ReadHandleKey<FaserSCT_SpacePointContainer> m_Sct_spcontainerKey{this, "SpacePointsSCTName", "SCT spContainer"}; SG::WriteHandleKey<SpacePointForSeedCollection> m_seed_spcontainerKey{this, "FaserSpacePointsSeedsName", "SpacePointForSeedCollection", "SpacePointForSeedCollection"}; SG::WriteHandleKey<Tracker::TrackerSeedCollection> m_trackerSeedContainerKey{this, "FaserTrackerSeedName", "FaserTrackerSeedCollection", "FaserTrackerSeedCollection"}; @@ -124,6 +124,9 @@ namespace Tracker { TH1* m_hist_dx_intercept; TH1* m_hist_dx_intercept_after; TH1* m_hist_line; + TH1* m_hist_nseed; + TH1* m_hist_nsp1; + TH1* m_hist_nsp2; ServiceHandle<ITHistSvc> m_thistSvc; diff --git a/Tracker/TrackerRecAlgs/TrackerSeedFinder/src/TrackerSeedFinder.cxx b/Tracker/TrackerRecAlgs/TrackerSeedFinder/src/TrackerSeedFinder.cxx index 53ffec6a238914461c8780138a4f36704c36f49c..96dbd3269a1a20e7ebdf884069ef08b9ab4693de 100755 --- a/Tracker/TrackerRecAlgs/TrackerSeedFinder/src/TrackerSeedFinder.cxx +++ b/Tracker/TrackerRecAlgs/TrackerSeedFinder/src/TrackerSeedFinder.cxx @@ -10,7 +10,7 @@ //<<<<<< INCLUDES >>>>>> -#include "TrackerSeedFinder.h" +#include "TrackerSeedFinder/TrackerSeedFinder.h" // For processing clusters #include "TrackerReadoutGeometry/SiLocalPosition.h" @@ -18,7 +18,7 @@ #include "TrackerReadoutGeometry/SiDetectorElement.h" // Space point Classes, -#include "TrkSpacePoint/SpacePointCollection.h" +#include "TrackerSpacePoint/FaserSCT_SpacePointCollection.h" #include "TrackerIdentifier/FaserSCT_ID.h" // general Atlas classes @@ -56,9 +56,12 @@ namespace Tracker , m_hist_station(0) , m_hist_x_z(0) , m_hist_y_z(0) - , m_hist_sp_plane (0) - , m_hist_sp_layer (0) - , m_hist_sp_station (0) + , m_hist_sp_plane(0) + , m_hist_sp_layer(0) + , m_hist_sp_station(0) + , m_hist_nseed(0) + , m_hist_nsp1(0) + , m_hist_nsp2(0) , m_thistSvc("THistSvc", name) {} @@ -104,7 +107,10 @@ namespace Tracker m_hist_layer=new TH1D("sp_layer","sp_layer",100,-10,10); m_hist_station=new TH1D("sp_station","sp_station",100,-10,10); m_hist_sp_station=new TH1D("sp_all_station","sp_station",100,-10,10); - m_hist_sp_plane=new TH1D("sp_all_plane","sp_station",100,-10,10); + m_hist_nseed=new TH1D("sp_nseed","n track seeds",1000,0,1000); + m_hist_nsp1=new TH1D("sp_nsp1","n triplets in first station",100,0,100); + m_hist_nsp2=new TH1D("sp_nsp2","n triplets in second station",100,0,100); + m_hist_sp_plane=new TH1D("sp_all_plane","sp_station",10,0,10); m_hist_sp_layer=new TH1D("sp_all_layer","sp_station",100,-10,10); m_hist_x_z=new TH2D("sp_x_z","sp_x_z",100,-200,200,3500,0,3500); m_hist_y_z=new TH2D("sp_y_z","sp_y_z",100,-200,200,3500,0,3500); @@ -126,6 +132,9 @@ namespace Tracker CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_layer",m_hist_layer)); CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_station",m_hist_station)); CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_all_station",m_hist_sp_station)); + CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_nseed",m_hist_nseed)); + CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_nsp1",m_hist_nsp1)); + CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_nsp2",m_hist_nsp2)); CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_all_layer",m_hist_sp_layer)); CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_all_plane",m_hist_sp_plane)); CHECK(m_thistSvc->regHist("/TrackerSeedFinder/sp/sp_x_z",m_hist_x_z)); @@ -144,7 +153,7 @@ namespace Tracker //------------------------------------------------------------------------- - StatusCode TrackerSeedFinder::make_triplets(vector<vector<const Trk::SpacePoint*> >& vsp, vector<seed>& vt, string st) const { + StatusCode TrackerSeedFinder::make_triplets(vector<vector<const FaserSCT_SpacePoint*> >& vsp, vector<seed>& vt, string st) const { int count=0; double xs=0, ys=0, zs=0, z2s=0, xzs=0, yzs=0; @@ -206,37 +215,42 @@ namespace Tracker ++m_numberOfEvents; N_1_0=0, N_1_1=0, N_1_2=0, N_2_0=0, N_2_1=0, N_2_2=0, N_3_0=0, N_3_1=0, N_3_2=0; + int nseed=0,nsp1=0,nsp2=0; // retrieve tracker spacepoint container - SG::ReadHandle<SpacePointContainer> sct_spcontainer( m_Sct_spcontainerKey, ctx ); + SG::ReadHandle<FaserSCT_SpacePointContainer> sct_spcontainer( m_Sct_spcontainerKey, ctx ); if (!sct_spcontainer.isValid()){ msg(MSG:: FATAL) << "Could not find the data object "<< sct_spcontainer.name() << " !" << endmsg; return StatusCode::RECOVERABLE; } ATH_MSG_DEBUG( "Tracker spacepoint container found: " << sct_spcontainer->size() << " collections" ); - SpacePointContainer::const_iterator it = sct_spcontainer->begin(); - SpacePointContainer::const_iterator itend = sct_spcontainer->end(); + FaserSCT_SpacePointContainer::const_iterator it = sct_spcontainer->begin(); + FaserSCT_SpacePointContainer::const_iterator itend = sct_spcontainer->end(); + + SG::WriteHandle<TrackerSeedCollection> seedContainer(m_trackerSeedContainerKey, ctx); + ATH_CHECK(seedContainer.record( std::make_unique<TrackerSeedCollection>() ) ); + ATH_MSG_DEBUG("Created track seed container " << m_trackerSeedContainerKey.key()); int i=0; - vector<vector<const Trk::SpacePoint*> > vsp1(3); - vector<vector<const Trk::SpacePoint*> > vsp2(3); - vector<vector<const Trk::SpacePoint*> > vsp3(3); + vector<vector<const FaserSCT_SpacePoint*> > vsp1(3); + vector<vector<const FaserSCT_SpacePoint*> > vsp2(3); + vector<vector<const FaserSCT_SpacePoint*> > vsp3(3); - vector<pair<int, const Trk::SpacePoint*>> msp; + vector<pair<int, const FaserSCT_SpacePoint*>> msp; - vector<vector<pair<int, const Trk::SpacePoint*>>> mseeds; + vector<vector<pair<int, const FaserSCT_SpacePoint*>>> mseeds; vector<int> pos; ATH_MSG_DEBUG( "Start iteration of spacepoint collections" ); for (; it != itend; ++it){ ++m_numberOfSPCollection; - const SpacePointCollection *colNext=&(**it); + const FaserSCT_SpacePointCollection *colNext=&(**it); int nReceivedSPSCT = colNext->size(); - // Create SpacePointCollection + // Create FaserSCT_SpacePointCollection IdentifierHash idHash = colNext->identifyHash(); Identifier elementID = colNext->identify(); @@ -245,8 +259,8 @@ namespace Tracker ATH_MSG_VERBOSE( "Algorithm found no space points" ); ++m_numberOfEmptySPCollection; } else { - SpacePointCollection::const_iterator sp_begin= colNext->begin(); - SpacePointCollection::const_iterator sp_end= colNext->end(); + FaserSCT_SpacePointCollection::const_iterator sp_begin= colNext->begin(); + FaserSCT_SpacePointCollection::const_iterator sp_end= colNext->end(); ATH_MSG_DEBUG( "Iterate the spacepoint in collection " ); @@ -254,7 +268,7 @@ namespace Tracker ++i; ++m_numberOfSP; - const Trk::SpacePoint* sp=&(**sp_begin); + const FaserSCT_SpacePoint* sp=&(**sp_begin); const auto identifier = sp->clusterList().first->identify(); int station = m_idHelper->station(identifier); @@ -270,6 +284,10 @@ namespace Tracker vsp3.at(plane).push_back(sp); } + m_hist_sp_plane->Fill((station-1)*3+plane); + m_hist_sp_station->Fill(station); + m_hist_sp_layer->Fill(plane); + if (station==1 && plane==0) {N_1_0++;} if (station==1 && plane==1) {N_1_1++;} if (station==1 && plane==2) {N_1_2++;} if (station==2 && plane==0) {N_2_0++;} if (station==2 && plane==1) {N_2_1++;} if (station==2 && plane==2) {N_2_2++;} if (station==3 && plane==0) {N_3_0++;} if (station==3 && plane==1) {N_3_1++;} if (station==3 && plane==2) {N_3_2++;} @@ -299,6 +317,8 @@ namespace Tracker ATH_MSG_VERBOSE( " 1st station " << N_1_0+N_1_1+N_1_2 << " (" << vsp1.at(0).size() << ";" << vsp1.at(1).size() << ";" << vsp1.at(2).size() << ")"); ATH_MSG_VERBOSE( " 2nd station " << N_2_0+N_2_1+N_2_2 << " (" << vsp2.at(0).size() << ";" << vsp2.at(1).size() << ";" << vsp2.at(2).size() << ")"); ATH_MSG_VERBOSE( " 3rd station " << N_3_0+N_3_1+N_3_2 << " (" << vsp3.at(0).size() << ";" << vsp3.at(1).size() << ";" << vsp3.at(2).size() << ")"); + if((N_1_0+N_1_1+N_1_2)<3||(N_2_0+N_2_1+N_2_2)<3) + return StatusCode::SUCCESS; vector<seed> vseed; ATH_CHECK(make_triplets(vsp1, vseed, "1")); @@ -306,6 +326,10 @@ namespace Tracker vector<seed> vfseed; for (vector<seed>::iterator it1 = vseed.begin(); it1 != vseed.end(); ++it1) { + if((*it1).station=="1") + nsp1++; + if((*it1).station=="2") + nsp2++; for (vector<seed>::iterator it2 = vseed.begin(); it2 != vseed.end(); ++it2) { if ((*it1).station == "1" && (*it2).station == "2") { @@ -320,12 +344,7 @@ namespace Tracker } } } - - SG::WriteHandle<TrackerSeedCollection> seedContainer(m_trackerSeedContainerKey, ctx); - ATH_CHECK(seedContainer.record( std::make_unique<TrackerSeedCollection>() ) ); - ATH_MSG_INFO("Created track seed container " << m_trackerSeedContainerKey.key()); - int nseed=0; for (vector<seed>::iterator it = vfseed.begin(); it != vfseed.end(); ++it) { @@ -333,7 +352,7 @@ namespace Tracker nseed++; - vector<const Trk::SpacePoint*> mseed = (*it).vsp; + vector<const FaserSCT_SpacePoint*> mseed = (*it).vsp; Tracker::TrackerSeed* trackerSeed = new Tracker::TrackerSeed(); trackerSeed->set_id(TrackerSeed::TRIPLET_SP_FIRSTSTATION); @@ -342,7 +361,10 @@ namespace Tracker seedContainer->push_back(trackerSeed); } - ATH_MSG_INFO("Saved " << nseed << " seeds in container"); + m_hist_nsp1->Fill(nsp1); + m_hist_nsp2->Fill(nsp2); + m_hist_nseed->Fill(nseed); + ATH_MSG_DEBUG("Saved " << nseed << " seeds in container"); return StatusCode::SUCCESS; } diff --git a/Tracker/TrackerRecAlgs/TrackerSeedFinder/src/components/TrackerSeedFinder_entries.cxx b/Tracker/TrackerRecAlgs/TrackerSeedFinder/src/components/TrackerSeedFinder_entries.cxx index 89e6db22cc8de4124d9ed41045ace3a79f430cb8..7423e761a0cbc679f7ef89c9fa6f9305559ca26a 100644 --- a/Tracker/TrackerRecAlgs/TrackerSeedFinder/src/components/TrackerSeedFinder_entries.cxx +++ b/Tracker/TrackerRecAlgs/TrackerSeedFinder/src/components/TrackerSeedFinder_entries.cxx @@ -1,3 +1,3 @@ -#include "../TrackerSeedFinder.h" +#include "TrackerSeedFinder/TrackerSeedFinder.h" DECLARE_COMPONENT( Tracker::TrackerSeedFinder ) diff --git a/Tracker/TrackerRecAlgs/TrackerSeedFinder/test/TrackerSeedFinderDbg.py b/Tracker/TrackerRecAlgs/TrackerSeedFinder/test/TrackerSeedFinderDbg.py index c6334704f6aef383a1057cd6266efa8398d16a04..d47891b213ebd487d3719c3c244e75064204fcbb 100644 --- a/Tracker/TrackerRecAlgs/TrackerSeedFinder/test/TrackerSeedFinderDbg.py +++ b/Tracker/TrackerRecAlgs/TrackerSeedFinder/test/TrackerSeedFinderDbg.py @@ -26,7 +26,8 @@ Configurable.configurableRun3Behavior = True # Configure ConfigFlags.Input.Files = ['my.RDO.pool.root'] ConfigFlags.Output.ESDFileName = "mySeeds.ESD.pool.root" -ConfigFlags.IOVDb.GlobalTag = "OFLCOND-XXXX-XXX-XX" +ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01" +# ConfigFlags.GeoModel.FaserVersion = "FASER-01" ConfigFlags.GeoModel.Align.Dynamic = False #ConfigFlags.Concurrency.NumThreads = 1 ConfigFlags.Beam.NumberOfCollisions = 0. diff --git a/Tracker/TrackerRecAlgs/TrackerSegmentFit/CMakeLists.txt b/Tracker/TrackerRecAlgs/TrackerSegmentFit/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..9f308c1d4074ec52d11bf3e36aef5c4649fe0dc4 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSegmentFit/CMakeLists.txt @@ -0,0 +1,22 @@ +################################################################################ +# Package: TrackerSegmentFIt +################################################################################ + +# Declare the package name: +atlas_subdir( TrackerSegmentFit ) + +# External dependencies +find_package( Eigen ) +find_package( Boost ) + +# Component(s) in the package: +atlas_add_component( TrackerSegmentFit + src/*.cxx src/*.h + src/components/*.cxx + INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} + LINK_LIBRARIES ${EIGEN_LIBRARIES} AthenaBaseComps AthViews StoreGateLib SGtests Identifier GaudiKernel TrackerRawData TrackerPrepRawData FaserDetDescr TrackerIdentifier TrackerReadoutGeometry xAODFaserTrigger + TrkTrack TrkEventPrimitives TrackerRIO_OnTrack TrkRIO_OnTrack TrackerEventTPCnv ) + +atlas_install_python_modules( python/*.py ) + +atlas_install_scripts( test/*.py ) diff --git a/Tracker/TrackerRecAlgs/TrackerSegmentFit/python/TrackerSegmentFitConfig.py b/Tracker/TrackerRecAlgs/TrackerSegmentFit/python/TrackerSegmentFitConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..1ac1f94d55b030b729a1fc1f000142f275d127fb --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSegmentFit/python/TrackerSegmentFitConfig.py @@ -0,0 +1,29 @@ +"""Define methods to construct configured SCT Cluster Fit tools and algorithms + +Copyright (C) 2021 CERN for the benefit of the FASER collaboration +""" +from AthenaConfiguration.ComponentFactory import CompFactory +from FaserSCT_GeoModel.FaserSCT_GeoModelConfig import FaserSCT_GeometryCfg + +def SegmentFitAlgBasicCfg(flags, **kwargs): + """Return ComponentAccumulator for Tracker SegmentFitAlg""" + acc = FaserSCT_GeometryCfg( flags ) + # clusterTool = acc.popToolsAndMerge(FaserSCT_ClusterizationToolCfg(flags)) + # kwargs.setdefault("SCT_ClusteringTool", clusterTool) + # kwargs.setdefault("DataObjectName", "SCT_RDOs") + kwargs.setdefault("ClustersName", "SCT_ClusterContainer") + # kwargs.setdefault("SCT_FlaggedCondData", "SCT_Flags") + Tracker__SegmentFitAlg=CompFactory.Tracker.SegmentFitAlg + acc.addEventAlgo(Tracker__SegmentFitAlg(**kwargs)) + + thistSvc = CompFactory.THistSvc() + thistSvc.Output += ["HIST DATAFILE='SegmentFitHistograms.root' OPT='RECREATE'"] + acc.addService(thistSvc) + return acc + +# with output defaults +def SegmentFitAlgCfg(flags, **kwargs): + """Return ComponentAccumulator for Tracker SegmentFitAlg and Output""" + acc = SegmentFitAlgBasicCfg(flags, **kwargs) + # acc.merge(SegmentFitAlgOutputCfg(flags)) + return acc diff --git a/Tracker/TrackerRecAlgs/TrackerSegmentFit/python/__init__.py b/Tracker/TrackerRecAlgs/TrackerSegmentFit/python/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..1cfd6fff21cebf8406490ff35fce52a5e3bbef15 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSegmentFit/python/__init__.py @@ -0,0 +1 @@ +#TrackerSegmentFit \ No newline at end of file diff --git a/Tracker/TrackerRecAlgs/TrackerSegmentFit/src/SegmentFitAlg.cxx b/Tracker/TrackerRecAlgs/TrackerSegmentFit/src/SegmentFitAlg.cxx new file mode 100644 index 0000000000000000000000000000000000000000..ff163e105d51b02267ce35e3fdfe43737c5a184c --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSegmentFit/src/SegmentFitAlg.cxx @@ -0,0 +1,748 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + */ + +/** @file SegmentFitAlg.cxx + * Implementation file for the SegmentFitAlg class. + * @author Dave Casper + * @date 28 February 2021 + */ + +#include "SegmentFitAlg.h" + +#include "TrackerPrepRawData/FaserSCT_Cluster.h" +#include "TrackerRIO_OnTrack/FaserSCT_ClusterOnTrack.h" +#include "FaserDetDescr/FaserDetectorID.h" +#include "TrackerReadoutGeometry/SCT_DetectorManager.h" +#include "TrkEventPrimitives/FitQuality.h" +#include "TrkEventPrimitives/ParticleHypothesis.h" +#include "TrkEventPrimitives/LocalParameters.h" +#include "TrkRIO_OnTrack/RIO_OnTrack.h" +#include "StoreGate/ReadHandle.h" + +#include <list> + +namespace Tracker +{ + +int SegmentFitAlg::clusterInfo::nEdgeStrips {0}; +size_t SegmentFitAlg::clusterInfo::nClusters {0}; +double SegmentFitAlg::fitInfo::zCenter {0.0}; +static const std::string moduleFailureReason{"SegmentFitAlg: Exceeds max clusters"}; + +// Constructor with parameters: +SegmentFitAlg::SegmentFitAlg(const std::string& name, ISvcLocator* pSvcLocator) : + AthReentrantAlgorithm(name, pSvcLocator) + , m_idHelper{nullptr} +{ +} + +// Initialize method: +StatusCode SegmentFitAlg::initialize() { + ATH_MSG_INFO("SegmentFitAlg::initialize()"); + if (m_maxClustersPerStation > compatibilityMaxSize) + { + ATH_MSG_WARNING("Requested ceiling on maximum clusters per station exceeds the allowed range. " << compatibilityMaxSize << " will be used instead."); + m_maxClustersPerStation = compatibilityMaxSize; + } + + if (m_minClustersPerStation > m_maxClustersPerStation) + { + ATH_MSG_ERROR("Requested minimum number of clusters per station exceeds the maximum number allowed. Check your job configuration."); + return StatusCode::FAILURE; + } + + ATH_CHECK(m_clusterContainerKey.initialize()); + ATH_CHECK(m_trackCollection.initialize()); + + // Get the SCT ID helper + ATH_CHECK(detStore()->retrieve(m_idHelper, "FaserSCT_ID")); + + // Get the detector manager + ATH_CHECK(detStore()->retrieve(m_detMgr, "SCT")); + + // Define the edge region + clusterInfo::nEdgeStrips = m_edgeStrips; + + return StatusCode::SUCCESS; +} + +// Process one station +StatusCode SegmentFitAlg::reconstructStation(ClusterContainerHandle container, int index, std::unique_ptr<TrackCollection>& tracks) const +{ + int station = m_detMgr->numerology().stationId(index); + ATH_MSG_VERBOSE("Processing station " << station); + + // Quickly determine whether to trash the data from this station due to excessive noise or not enough hits + auto occupancy = stationOccupancy(container, station); + if (occupancy < m_minClustersPerStation) + { + ATH_MSG_VERBOSE("Station " << station << ": not enough clusters (" << occupancy << ")."); + m_numberLowOccupancy++; + return StatusCode::SUCCESS; + } + if (occupancy > m_maxClustersPerStation) + { + ATH_MSG_VERBOSE("Station " << station << ": too many clusters (" << occupancy << ")."); + m_numberExcessOccupancy++; + return StatusCode::SUCCESS; + } + // We can proceed... + m_numberOfGoodStations++; + + // find station center (the reference point for fits) + fitInfo::zCenter = findCenter(station); + + clusterInfo::nClusters = occupancy; + ClusterList l = tabulateClusters(container, station); + ATH_MSG_VERBOSE("Station " << station << ": tabulated " << l.size() << " clusters."); + if (l.size() < m_minClustersPerStation) return StatusCode::SUCCESS; + + // flag clusters that are compatible with each other + checkCompatibility(l); + + int pairs {0}; + for (auto c : l) + { + pairs += (c->compatible.count() - 1); // every cluster is compatible with itself + } + ATH_MSG_VERBOSE("Found " << pairs/2 << " compatible cluster pairs from " << l.size() << " clusters (average " << ((double)pairs/2)/l.size() << ")."); + + // form viable (containing both views) groups of four compatible clusters + FitList f = enumerateSeeds(l); + ATH_MSG_VERBOSE("Found " << f.size() << " fit seeds from " << l.size() << " clusters."); + + // fit the seeds + FitMap goodSeeds; + MaskSet badSeeds; + findGoodSeeds(f, goodSeeds, badSeeds); + if (goodSeeds.size() == 0) return StatusCode::SUCCESS; + + // try adding clusters to the good seeds + FitMap allFits = enumerateFits(goodSeeds, badSeeds); + ATH_MSG_VERBOSE("Found " << allFits.size() << " fits after enumeration from " << goodSeeds.size() << " seeds."); + FitMap goodFits = checkFitQuality(allFits); + ATH_MSG_VERBOSE(goodFits.size() << " out of " << allFits.size() << " fits pass quality cut."); + for (auto f : goodFits) + { + auto fit = f.second; + if (fit->candidates.size() > 4) + { + ATH_MSG_VERBOSE("Fit Parameters: (" << fit->fitParams(0) << ", " << fit->fitParams(1) << ", " << fit->fitParams(2) << ", " << fit->fitParams(3) << "); chi2 = " << fit->fitChi2 << "; DoF = " << fit->candidates.size() - 4 ); + for (size_t i = fit->clusterMask.find_first(); i != ClusterSet::npos; i = fit->clusterMask.find_next(i)) + { + Amg::Vector3D seedPos = l[i]->cluster.globalPosition(); + ATH_MSG_VERBOSE("Fit cluster [" << l[i]->layer << "|" << l[i]->eta << "|" << l[i]->phi << + "|" << l[i]->side << "] at (" << seedPos.x() << ", " << seedPos.y() << ", " << seedPos.z() << ")"); + } + } + } + FitMap selectedFits = selectFits(goodFits); + ATH_MSG_VERBOSE("Selected " << selectedFits.size() << " fits for output."); + for (auto f : selectedFits) + { + auto fit = f.second; + ATH_MSG_VERBOSE("Fit Parameters: (" << fit->fitParams(0) << ", " << fit->fitParams(1) << ", " << fit->fitParams(2) << ", " << fit->fitParams(3) << "); chi2 = " << fit->fitChi2 << "; DoF = " << fit->candidates.size() - 4 ); + for (size_t i = fit->clusterMask.find_first(); i != ClusterSet::npos; i = fit->clusterMask.find_next(i)) + { + Amg::Vector3D seedPos = l[i]->cluster.globalPosition(); + ATH_MSG_VERBOSE("Fit cluster [" << l[i]->layer << "|" << l[i]->eta << "|" << l[i]->phi << + "|" << l[i]->side << "] at (" << seedPos.x() << ", " << seedPos.y() << ", " << seedPos.z() << ")"); + } + ATH_CHECK(AddTrack(tracks, fit)); + } + return StatusCode::SUCCESS; +} + +size_t SegmentFitAlg::stationOccupancy(ClusterContainerHandle container, int station) const +{ + size_t occupancy {0}; + FaserSCT_ClusterContainer::const_iterator clusterCollections {container->begin()}; + FaserSCT_ClusterContainer::const_iterator clusterCollectionsEnd {container->end()}; + for (; clusterCollections != clusterCollectionsEnd; ++clusterCollections) + { + if (getStation(*clusterCollections) == station) occupancy += (*clusterCollections)->size(); + } + return occupancy; +} + +double SegmentFitAlg::findCenter(int station) const +{ + double zMean = 0.0; + size_t zCount = 0; + for (auto element : *(m_detMgr->getDetectorElementCollection())) + { + if (m_idHelper->station(element->identify()) == station) + { + zMean += element->center().z(); + zCount++; + } + } + if (zCount == 0) + { + ATH_MSG_ERROR("No detector elements found for station " << station); + return zMean; + } + return zMean/zCount; +} + +SegmentFitAlg::ClusterList SegmentFitAlg::tabulateClusters(ClusterContainerHandle container, int station) const +{ + ClusterList clusters; + int index {0}; + FaserSCT_ClusterContainer::const_iterator clusterCollections {container->begin()}; + FaserSCT_ClusterContainer::const_iterator clusterCollectionsEnd {container->end()}; + for (; clusterCollections != clusterCollectionsEnd; ++clusterCollections) + { + if (getStation(*clusterCollections) == station) + { + m_numberOfClusterCollection++; + for (auto cluster : **clusterCollections) + { + m_numberOfClusters++; + clusters.push_back(std::make_shared<clusterInfo>(index++, *cluster, m_idHelper)); + } + } + } + return clusters; +} + +void SegmentFitAlg::checkCompatibility(ClusterList& clusters) const +{ + for (size_t i = 0; i < clusters.size() - 1; i++) + { + if (clusters[i]->view == 0) continue; + for (size_t j = i + 1; j < clusters.size(); j++) + { + if (clusters[j]->view == 0) continue; + // + // Rule 1: Clusters in different layers are compatible + // + if (clusters[i]->layer != clusters[j]->layer) + { + m_numberOfRule1Pairs++; + clusters[i]->compatible.set(j, true); + clusters[j]->compatible.set(i, true); + continue; + } + // + // Rule 2: Clusters on opposite sides of same module are compatible + // + if (clusters[i]->layer == clusters[j]->layer && + clusters[i]->moduleIndex == clusters[j]->moduleIndex && + clusters[i]->side != clusters[j]->side) + { + m_numberOfRule2Pairs++; + clusters[i]->compatible.set(j, true); + clusters[j]->compatible.set(i, true); + continue; + } + if (clusters[i]->moduleIndex == clusters[j]->moduleIndex) continue; // same-module clusters are incompatible if they get here + // + // Rule 3: Clusters in modules of the same layer with same phi + different eta may be compatible if their ends are close enough + // + if (m_allowEtaOverlap && clusters[i]->phi == clusters[j]->phi && abs(clusters[i]->yEnd - clusters[j]->yEnd) <= 2 * m_edgeStrips) + { + m_numberOfRule3Pairs++; + clusters[i]->compatible.set(j, true); + clusters[j]->compatible.set(i, true); + continue; + } + // + // Rule 4: Edge clusters in modules of the same layer with different phi may be compatible with edge clusters in neighboring modules + // + const double maximumEdgeSeparation = 20 * Gaudi::Units::mm; // Loose cut just to ensure both clusters are on neighboring edges + if (m_allowPhiOverlap && clusters[i]->edge && clusters[j]->edge && + (clusters[i]->phi != clusters[j]->phi) && (abs(clusters[i]->yCenter - clusters[j]->yCenter) <= maximumEdgeSeparation) ) + { + if (clusters[i]->eta == clusters[j]->eta) + { + m_numberOfRule4Pairs++; + clusters[i]->compatible.set(j, true); + clusters[j]->compatible.set(i, true); + continue; + } + if (m_allowEtaOverlap && clusters[i]->eta != clusters[j]->eta) + { + m_numberOfRule4Pairs++; + clusters[i]->compatible.set(j, true); + clusters[j]->compatible.set(i, true); + continue; + } + } + } + } +} + +SegmentFitAlg::FitList +SegmentFitAlg::enumerateSeeds(const ClusterList& clusters) const +{ + FitList fits; + for (size_t i = 0; i < clusters.size()-3; i++) + { + size_t i_views[2] {0 , 0}; + if (clusters[i]->view == 0) + { + continue; + } + else if (clusters[i]->view > 0) + { + i_views[1] = 1; + } + else + { + i_views[0]= 1; + } + auto i_compat = clusters[i]->compatible; + std::vector<size_t> i_vec {i}; + for (size_t j = i_compat.find_next(i); j != ClusterSet::npos; j = i_compat.find_next(j)) + { + size_t ij_views[2] {i_views[0], i_views[1]}; + if (clusters[j]->view > 0) + { + ij_views[1]++; + } + else if (clusters[j]->view < 0) + { + ij_views[0]++; + } + auto ij_compat = clusters[j]->compatible & i_compat; + for (size_t k = ij_compat.find_next(j); k != ClusterSet::npos; k = ij_compat.find_next(k)) + { + size_t ijk_views[2] {ij_views[0], ij_views[1]}; + if (clusters[k]->view > 0) + { + ijk_views[1]++; + } + else if (clusters[k]->view < 0) + { + ijk_views[0]++; + } + if (ijk_views[0] == 0 || ijk_views[1] == 0) continue; // Need two hits in each view to fit + auto ijk_compat = clusters[k]->compatible & ij_compat; + for (size_t l = ijk_compat.find_next(k); l != ClusterSet::npos; l = ijk_compat.find_next(l)) + { + size_t ijkl_views[2] {ijk_views[0], ijk_views[1]}; + if (clusters[l]->view > 0) + { + ijkl_views[1]++; + } + else if (clusters[l]->view < 0) + { + ijkl_views[0]++; + } + if (ijkl_views[0] != 2 || ijkl_views[1] != 2) continue; // Need two hits in each view to fit + if ((clusters[i]->layer == clusters[j]->layer && clusters[j]->layer == clusters[k]->layer) || + (clusters[j]->layer == clusters[k]->layer && clusters[k]->layer == clusters[l]->layer) || + (clusters[k]->layer == clusters[l]->layer && clusters[l]->layer == clusters[i]->layer)) continue; // Can't fit 3+ hits in same layer + m_numberOfSeeds++; + fits.push_back(std::make_shared<fitInfo>(clusters, std::vector<size_t> {i, j, k, l})); + } + } + } + } + return fits; +} + +void +SegmentFitAlg::findGoodSeeds(FitList& allSeeds, FitMap& goodSeeds, MaskSet& badSeeds) const +{ + int nGoodSeeds {0}; + for (auto seed : allSeeds) + { + fitClusters(*seed); + + bool seedOK = checkFit(*seed); + if (seedOK) + { + ATH_MSG_VERBOSE("Seed Parameters: (" << seed->fitParams(0) << ", " << seed->fitParams(1) << ", " << seed->fitParams(2) << ", " << seed->fitParams(3) << "); chi2 = " << seed->fitChi2 << "; additional compatible clusters: " << seed->compatibleMask.count()); + goodSeeds[seed->clusterMask] = std::shared_ptr<fitInfo> {seed}; + nGoodSeeds++; + } + else + { + badSeeds.insert(seed->clusterMask); + } + } + ATH_MSG_VERBOSE("Found " << nGoodSeeds << " good seeds out of " << allSeeds.size()); + m_numberOfGoodSeeds += nGoodSeeds; +} + +void +SegmentFitAlg::fitClusters(fitInfo& fit) const +{ + m_numberOfFits++; + Eigen::Matrix< double, 5, 5 > s; + s << fit.sums[1] , fit.sums[2] , fit.sums[4] , fit.sums[5] , fit.sums[10] , + fit.sums[2] , fit.sums[3] , fit.sums[5] , fit.sums[6] , fit.sums[11] , + fit.sums[4] , fit.sums[5] , fit.sums[7] , fit.sums[8] , fit.sums[12] , + fit.sums[5] , fit.sums[6] , fit.sums[8] , fit.sums[9] , fit.sums[13] , + fit.sums[10] , fit.sums[11] , fit.sums[12] , fit.sums[13] , fit.sums[14]; + Eigen::Matrix< double, 4, 4 > s4 = s.block<4,4>(0,0); + Eigen::Matrix< double, 4, 1 > v; + v << fit.sums[10] , fit.sums[11] , fit.sums[12] , fit.sums[13]; + // ATH_MSG_VERBOSE("s4 \n" << s4); + // ATH_MSG_VERBOSE("v \n" << v); + // ATH_MSG_VERBOSE("s4^-1 \n" << s4.inverse()); +// Eigen::Matrix< double, 4, 1 > x = s4.colPivHouseholderQr().solve(v); + fit.fitParams = s4.fullPivLu().solve(v); + // ATH_MSG_VERBOSE("x \n" << fit.fitParams); + // ATH_MSG_VERBOSE("Check solution"); + // ATH_MSG_VERBOSE("solution: \n" << s4*fit.fitParams); + // ATH_MSG_VERBOSE("target: \n" << v); + Eigen::Matrix< double, 5, 1 > x5; + x5 << fit.fitParams(0), fit.fitParams(1), fit.fitParams(2), fit.fitParams(3), -1; + fit.fitChi2 = x5.transpose()*s*x5; + s4.computeInverseWithCheck(fit.fitCovariance, fit.hasCovariance); + // ATH_MSG_VERBOSE("covariance \n" << fit.fitCovariance); + // ATH_MSG_VERBOSE("chi2: " << fit.fitChi2); + return; +} + +bool +SegmentFitAlg::checkFit(const Tracker::SegmentFitAlg::fitInfo& seed) const +{ + if (!seed.hasCovariance) + { + ATH_MSG_VERBOSE("Rejected fit without covariance matrix."); + return false; + } + if (m_tanThetaCut > 0.0 && pow(seed.fitParams(2),2.0) + pow(seed.fitParams(3), 2.0) > m_tanThetaCut * m_tanThetaCut) return false; + for (auto i : seed.candidates) + { + double z = seed.clusters[i]->cluster.globalPosition().z(); + HepGeom::Point3D<double> extrapolation = seed.extrapolateFit(z); + if (seed.clusters[i]->cluster.detectorElement()->inDetector(extrapolation, m_waferTolerance, m_waferTolerance).out()) + { + // ATH_MSG_VERBOSE("Extrapolation out of tolerance at z = " << seed.clusters[i]->cluster.globalPosition().z() << " : (" << extrapolation.x() << ", " << extrapolation.y() << ")"); + return false; + } + else + { + // ATH_MSG_VERBOSE("Extrapolation inside tolerance at z = " << seed.clusters[i]->cluster.globalPosition().z() << " : (" << extrapolation.x() << ", " << extrapolation.y() << ")"); + } + } + return true; +} + +SegmentFitAlg::FitMap +SegmentFitAlg::enumerateFits(const FitMap& seeds, const MaskSet& veto) const +{ + FitMap allFits {seeds}; + FitMap newSeeds {seeds}; + MaskSet allFailures {veto}; + while (true) + { + FitMap addedFits; + for (auto p : newSeeds) + { + auto seed = p.second; + for (size_t i = seed->compatibleMask.find_first(); i != ClusterSet::npos; i = seed->compatibleMask.find_next(i)) + { + if (abs(seed->fitParams(1) + seed->fitParams(3) * (seed->clusters[i]->z - fitInfo::zCenter) - seed->clusters[i]->yCenter) > m_yResidualCut) + continue; + ClusterSet mask { seed->clusterMask }; + mask.set(i); + if (allFits.find(mask) == allFits.end() && !vetoFit(allFailures, mask)) + { + auto candidate = std::make_shared<fitInfo>(*seed); + candidate->addCluster(i); + fitClusters(*candidate); + if (checkFit(*candidate)) + { + allFits[candidate->clusterMask] = candidate; + addedFits[candidate->clusterMask] = candidate; + } + else + { + allFailures.insert(candidate->clusterMask); + } + } + } + } + + if (addedFits.size() == 0) break; + newSeeds = std::move(addedFits); + } + return allFits; +} + +SegmentFitAlg::FitMap +SegmentFitAlg::checkFitQuality(const FitMap& fits) const +{ + FitMap goodFits { }; + for (auto f : fits) + { + auto candidate = f.second; + size_t nDoF = candidate->clusterMask.count() - 4; + if (nDoF == 0 || candidate->fitChi2/nDoF <= m_reducedChi2Cut) goodFits[candidate->clusterMask] = candidate; + } + m_numberOfGoodFits += goodFits.size(); + return goodFits; +} + +SegmentFitAlg::FitMap +SegmentFitAlg::selectFits(const FitMap& fits) const +{ + // Select the input fit with the most clusters (using lowest chi2 as tie-breaker) + // Discard any other input fits using those clusters + // Repeat until no input fits remain + FitMap selectedFits { }; + std::list<std::shared_ptr<fitInfo> > info {}; + for (auto fit : fits) + { + info.push_back(fit.second); + } + info.sort([](const std::shared_ptr<fitInfo>& left, const std::shared_ptr<fitInfo>& right) + { + if (left->clusterMask.count() > right->clusterMask.count()) return true; + if (left->clusterMask.count() < right->clusterMask.count()) return false; + if (left->fitChi2 < right->fitChi2) return true; + return false; + }); + + ATH_MSG_VERBOSE("Sorted input fits:"); + for (auto it = info.begin(); it != info.end(); ++it) + { + auto content = *it; + ATH_MSG_VERBOSE("clusters: " << content->clusterMask.count() << " / chi2: " << content->fitChi2) ; + } + ClusterSet usedClusters { clusterInfo::nClusters }; + + while (info.size() > 0) + { + auto selected = info.front(); + ATH_MSG_VERBOSE("Selected nclust = " << selected->clusterMask.count() << " with chi2 = " << selected->fitChi2); + selectedFits[selected->clusterMask] = selected; + usedClusters |= selected->clusterMask; + + info.remove_if([&](std::shared_ptr<fitInfo> p) {return (p->clusterMask & ~usedClusters) != p->clusterMask;}); + } + + m_numberOfSelectedFits += selectedFits.size(); + return selectedFits; +} + +bool +SegmentFitAlg::vetoFit(const MaskSet& badSeeds, const ClusterSet& hypothesis) const +{ + if (badSeeds.count(hypothesis) > 0) return true; + return false; +} + + +// Execute method: +StatusCode +SegmentFitAlg::execute(const EventContext& ctx) const +{ + ++m_numberOfEvents; +// setFilterPassed(false, ctx); + + SG::WriteHandle trackContainer{m_trackCollection, ctx}; + std::unique_ptr<TrackCollection> outputTracks = std::make_unique<TrackCollection>(); + + ClusterContainerHandle clusterContainer{m_clusterContainerKey, ctx}; + ATH_CHECK(clusterContainer.isValid()); + ATH_MSG_VERBOSE("Retrieved cluster data from event store"); + + for (int stationIdx = 0; stationIdx < m_detMgr->numerology().numStations(); stationIdx++) + { + ATH_CHECK(reconstructStation(clusterContainer, stationIdx, outputTracks)); + } + + // Loop over stations +// if (!stations.empty()) +// { +// for (int thisStation : stations) +// { +// if (nGoodLayers == 3) +// { +// Eigen::Matrix< double, 4, 1 > bestFit; +// Amg::MatrixX bestCov(4,4); +// std::vector<const clusterInfo*> bestClusters; +// double bestChi2 = -1; +// for (auto info : bestClusters) +// { +// if (info->sinAlpha * info->cosAlpha < 0) continue; +// double dz = info->z - m_zCenter[thisStation]; +// double xFit = bestFit(0) + bestFit(2) * dz; +// double yFit = bestFit(1) + bestFit(3) * dz; +// double uFit = yFit * info->cosAlpha + xFit * info->sinAlpha; +// } +// for (auto info : bestClusters) +// { +// if (info->sinAlpha * info->cosAlpha > 0) continue; +// double dz = info->z - m_zCenter[thisStation]; +// double xFit = bestFit(0) + bestFit(2) * dz; +// double yFit = bestFit(1) + bestFit(3) * dz; +// double uFit = yFit * info->cosAlpha + xFit * info->sinAlpha; +// ATH_MSG_VERBOSE("Event: " << eventNumber << " z: " << info->z << " z-zC: " << dz<< " uFit: " << uFit << " u: " << info->u); +// } +// //Residuals(bestClusters); +// ATH_CHECK(AddTrack(outputTracks, bestFit, bestCov, bestClusters, bestChi2, bestClusters.size()-4)); +// setFilterPassed(true, ctx); +// ++m_numberOfFits; +// } +// // clean-up +// for (auto layerEntry : layerCombos) +// { +// for (auto combo : layerEntry) +// { +// if (combo != nullptr) delete combo; +// } +// layerEntry.clear(); +// } +// layerCombos.clear(); +// } +// } +// else +// { +// ATH_MSG_DEBUG("No stations with clusters found."); +// } + + ATH_CHECK(trackContainer.record(std::move(outputTracks))); + +// // Clean up +// for (auto entry : clusterMap) +// { +// for (clusterInfo* info : entry.second.first) +// { +// if (info != nullptr) delete info; +// } +// entry.second.first.clear(); +// for (clusterInfo* info : entry.second.second) +// { +// if (info != nullptr) delete info; +// } +// entry.second.second.clear(); +// } +// clusterMap.clear(); + + // Done + return StatusCode::SUCCESS; +} + +// Finalize method: +StatusCode SegmentFitAlg::finalize() +{ + ATH_MSG_INFO("SegmentFitAlg::finalize()"); + ATH_MSG_INFO( m_numberOfEvents << " events processed." ); + ATH_MSG_INFO( m_numberLowOccupancy << " stations rejected for low occupancy."); + ATH_MSG_INFO( m_numberExcessOccupancy << " stations rejected for high occupancy."); + ATH_MSG_INFO( m_numberOfGoodStations << " good stations processed."); + ATH_MSG_INFO( m_numberOfClusterCollection << " cluster collections processed." ); + ATH_MSG_INFO( m_numberOfClusters << " clusters processed." ); + ATH_MSG_INFO( m_numberOfRule1Pairs << " Rule 1 (different layer) pairs" ); + ATH_MSG_INFO( m_numberOfRule2Pairs << " Rule 2 (same module different side) pairs" ); + ATH_MSG_INFO( m_numberOfRule3Pairs << " Rule 3 (eta overlap) pairs" ); + ATH_MSG_INFO( m_numberOfRule4Pairs << " Rule 4 (phi overlap) pairs" ); + ATH_MSG_INFO( m_numberOfSeeds << " seeds fit."); + ATH_MSG_INFO( m_numberOfGoodSeeds << " good seed fits."); + ATH_MSG_INFO( m_numberOfFits << " fits performed." ); + ATH_MSG_INFO( m_numberOfGoodFits << " fits passed quality cuts." ); + ATH_MSG_INFO( m_numberOfSelectedFits << " fits selected for output." ); + + + return StatusCode::SUCCESS; +} + +// Method to create and store Trk::Track from fit results +StatusCode +SegmentFitAlg::AddTrack(std::unique_ptr<TrackCollection>& tracks, + const std::shared_ptr<fitInfo>& theFit) const +{ + Trk::TrackInfo i { Trk::TrackInfo::TrackFitter::Unknown, Trk::ParticleHypothesis::muon }; + Trk::FitQuality* q = new Trk::FitQuality {theFit->fitChi2, static_cast<double>(theFit->clusterMask.count() - 4)}; + DataVector<const Trk::TrackStateOnSurface>* s = new DataVector<const Trk::TrackStateOnSurface> {}; + + // translate parameters to nominal fit point + s->push_back( GetState(theFit->fitParams, theFit->fitCovariance, nullptr) ); + + for (int clusterIndex : theFit->candidates) + { + s->push_back( GetState( theFit->fitParams, theFit->fitCovariance, &theFit->clusters[clusterIndex]->cluster) ); + } + + // for (const clusterInfo* cInfo : fitClusters) + // { + // s->push_back( GetState(fitResult, fitCovariance, cInfo->cluster, station) ); + // } + + // Create and store track + std::unique_ptr<DataVector<const Trk::TrackStateOnSurface>> sink(s); + tracks->push_back(new Trk::Track(i, std::move(*sink) , q)); + return StatusCode::SUCCESS; +} + +Trk::TrackStateOnSurface* +SegmentFitAlg::GetState( const Eigen::Matrix< double, 4, 1 >& fitResult, + const Eigen::Matrix< double, 4, 4 >& fitCovariance, + const FaserSCT_Cluster* fitCluster) const +{ + // position of fit point: + // int station = m_idHelper->station(fitCluster->detectorElement()->identify()); + double zFit = fitInfo::zCenter; + if (fitCluster != nullptr) zFit = fitCluster->globalPosition()[2]; + Amg::Vector3D pos { fitResult[0] + fitResult[2] * (zFit - fitInfo::zCenter), fitResult[1] + fitResult[3] * (zFit - fitInfo::zCenter), zFit }; + double phi = atan2( fitResult[3], fitResult[2] ); + double theta = atan( sqrt(fitResult[2]*fitResult[2] + fitResult[3]*fitResult[3]) ); + double qoverp = 1.0/100000.0; + + Eigen::Matrix< double, 4, 4 > jacobian = Eigen::Matrix< double, 4, 4 >::Zero(); + jacobian << 1, 0, zFit - fitInfo::zCenter, 0, + 0, 1, 0, zFit - fitInfo::zCenter, + 0, 0, fitResult[3]/(fitResult[2]*fitResult[2]+fitResult[3]*fitResult[3]), + fitResult[2]/(fitResult[2]*fitResult[2]+fitResult[3]*fitResult[3]), + 0, 0, fitResult[2]/(sqrt(fitResult[2]*fitResult[2]+fitResult[3]*fitResult[3])*(1+fitResult[2]*fitResult[2]+fitResult[3]*fitResult[3])), + fitResult[3]/(sqrt(fitResult[2]*fitResult[2]+fitResult[3]*fitResult[3])*(1+fitResult[2]*fitResult[2]+fitResult[3]*fitResult[3])); + Eigen::Matrix< double, 4, 4 > covPar {jacobian * fitCovariance * jacobian.transpose()}; + std::unique_ptr<AmgSymMatrix(5)> covPar5 { new AmgSymMatrix(5){ AmgSymMatrix(5)::Zero() } }; + covPar5->block<4,4>(0,0) = covPar; + covPar5->block<1,1>(4,4) = Eigen::Matrix< double, 1, 1 > { (50000.0)*qoverp*qoverp }; + + FaserSCT_ClusterOnTrack* rot = nullptr; + if (fitCluster != nullptr) + { + rot = new FaserSCT_ClusterOnTrack{ fitCluster, + Trk::LocalParameters { Trk::DefinedParameter { fitCluster->localPosition()[0], Trk::loc1 }, + Trk::DefinedParameter { fitCluster->localPosition()[1], Trk::loc2 } }, + fitCluster->localCovariance(), + m_idHelper->wafer_hash(fitCluster->detectorElement()->identify())}; + } + std::unique_ptr<Trk::TrackParameters> p { new Trk::CurvilinearParameters { pos, phi, theta, qoverp, *(covPar5.release()) } }; + return new Trk::TrackStateOnSurface { rot, p.release() }; +} + +// void +// SegmentFitAlg::Residuals(std::vector<const clusterInfo*>& fitClusters) const +// { +// for (const clusterInfo* cI : fitClusters) +// { +// double zFit = cI->z; +// layerCombo* zero = new layerCombo{ }; +// layerCombo* one = new layerCombo{ }; +// layerCombo* two = new layerCombo{ }; +// zero->initialize(); +// one->initialize(); +// two->initialize(); +// if (fitClusters[0]->z != zFit) zero->addCluster(fitClusters[0], zFit); +// if (fitClusters[1]->z != zFit) zero->addCluster(fitClusters[1], zFit); +// if (fitClusters[2]->z != zFit) one->addCluster(fitClusters[2], zFit); +// if (fitClusters[3]->z != zFit) one->addCluster(fitClusters[3], zFit); +// if (fitClusters[4]->z != zFit) two->addCluster(fitClusters[4], zFit); +// if (fitClusters[5]->z != zFit) two->addCluster(fitClusters[5], zFit); +// std::tuple<Eigen::Matrix<double, 4, 1>, Eigen::Matrix<double, 4, 4>, double> newFit = ClusterFit( zero, one, two); +// double deltaU = std::get<0>(newFit)[1] * cI->cosAlpha + std::get<0>(newFit)[0] * cI->sinAlpha - cI->u; +// double pullU = deltaU/sqrt(cI->sigmaSq + std::get<1>(newFit)(0,0)*cI->sinAlpha*cI->sinAlpha + std::get<1>(newFit)(1,1)*cI->cosAlpha*cI->cosAlpha); + +// const TrackerDD::SiDetectorElement* elem = cI->cluster->detectorElement(); +// IdentifierHash hash = m_idHelper->wafer_hash(elem->identify()); +// ATH_MSG_VERBOSE("hash, residual, pull, n:" << hash << " : " << deltaU << " : " << pullU << " : " << zero->sums[0] + one->sums[0] + two->sums[0]); + +// delete zero; +// delete one; +// delete two; +// } +// } + +} diff --git a/Tracker/TrackerRecAlgs/TrackerSegmentFit/src/SegmentFitAlg.h b/Tracker/TrackerRecAlgs/TrackerSegmentFit/src/SegmentFitAlg.h new file mode 100644 index 0000000000000000000000000000000000000000..eb41946cd0a9094a24919eaf6824705094afa234 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSegmentFit/src/SegmentFitAlg.h @@ -0,0 +1,441 @@ +/* + Copyright (C) 2021 CERN for the benefit of the FASER collaboration + */ + +/** @file SegmentFitAlg + * Header file for the SegmentFitAlg class (an Algorithm). + * @author Dave Casper + * @date 28 February 2021 + */ + +#ifndef FASERSEGMENTFIT_SEGMENTFITALG_H +#define FASERSEGMENTFIT_SEGMENTFITALG_H + +// Base class +#include "AthenaBaseComps/AthReentrantAlgorithm.h" + +////Next contains a typedef so cannot be fwd declared +#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" +#include "TrackerPrepRawData/FaserSCT_ClusterCollection.h" +#include "TrackerPrepRawData/TrackerClusterContainer.h" +#include "TrackerIdentifier/FaserSCT_ID.h" +#include "Identifier/IdentifierHash.h" +#include "TrkTrack/TrackCollection.h" + +//Gaudi +#include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/ToolHandle.h" + +//STL +#include <map> +#include <string> + +//Boost +#include <boost/dynamic_bitset.hpp> + +class ISvcLocator; +class StatusCode; +namespace Trk +{ + class TrackStateOnSurface; +} + +namespace TrackerDD +{ + class SCT_DetectorManager; +} + +namespace Tracker +{ + typedef boost::dynamic_bitset<> ClusterSet; + +/** + * @class SCT_Clusterization + * @brief Form clusters from SCT Raw Data Objects + * The class loops over an RDO grouping strips and creating collections of clusters, subsequently recorded in StoreGate + * Uses SCT_ConditionsTools to determine which strips to include. + */ +class SegmentFitAlg : public AthReentrantAlgorithm + { + public: + /// Constructor with parameters: + SegmentFitAlg(const std::string& name, ISvcLocator* pSvcLocator); + + /** @name Usual algorithm methods */ + //@{ + ///Retrieve the tools used and initialize variables + virtual StatusCode initialize() override; + ///Form segments and record them in StoreGate (detector store) + virtual StatusCode execute(const EventContext& ctx) const override; + ///Clean up and release the collection containers + virtual StatusCode finalize() override; + //Make this algorithm clonable. + virtual bool isClonable() const override { return true; }; + //@} + + + private: + /** @name Disallow default instantiation, copy, assignment */ + //@{ + SegmentFitAlg() = delete; + SegmentFitAlg(const SegmentFitAlg&) = delete; + SegmentFitAlg &operator=(const SegmentFitAlg&) = delete; + //@} + + static constexpr size_t compatibilityMaxSize = 128; + + struct clusterInfo + { + public: + clusterInfo(uint theIndex, const FaserSCT_Cluster& theCluster, const FaserSCT_ID* idHelper) + : index(theIndex) + , cluster(theCluster) + , compatible(nClusters) + { + const TrackerDD::SiDetectorElement* elem = cluster.detectorElement(); + if (elem == nullptr) + { + view = 0; + return; + } + Identifier id = elem->identify(); + double alpha = std::abs(asin(elem->sinStereo())); + layer = idHelper->layer(id); + eta = idHelper->eta_module(id); // -1 or +1 + etaIndex = (eta + 1)/2; // 0 or 1 + phi = idHelper->phi_module(id); // 0 to 3 + moduleIndex = ((etaIndex + phi)%2 == 1 ? phi : phi + 4); // 0 to 7 + switch (moduleIndex) + { + case 0: + case 2: + { + // info->sinAlpha = sin(alpha); + // info->cosAlpha = -cos(alpha); + sinAlpha = -sin(alpha); + cosAlpha = cos(alpha); + break; + } + case 1: + case 3: + { + sinAlpha = -sin(alpha); + cosAlpha = cos(alpha); + break; + } + case 4: + case 6: + { + // info->sinAlpha = -sin(alpha); + // info->cosAlpha = -cos(alpha); + sinAlpha = sin(alpha); + cosAlpha = cos(alpha); + break; + } + case 5: + case 7: + { + sinAlpha = sin(alpha); + cosAlpha = cos(alpha); + break; + } + } + side = idHelper->side(id); + if (side > 0) sinAlpha = - sinAlpha; // always reverse angle for back side wafer + u = cluster.globalPosition().y() * cosAlpha + cluster.globalPosition().x() * sinAlpha; + z = cluster.globalPosition().z(); + sigmaSq = cluster.localCovariance()(0,0); + if (sinAlpha * cosAlpha < 0) + { + view = -1; + compatible.set(index, true); + } + else if (sinAlpha * cosAlpha > 0) + { + view = 1; + compatible.set(index, true); + } + else + { + view = 0; // will be silently ignored + compatible.set(index, false); + } + yCenter = cluster.globalPosition().y(); + edge = false; + const std::vector<Identifier>& rdoList = cluster.rdoList(); + for (auto id : rdoList) + { + int stripNumber = idHelper->strip(id); + if (stripNumber < nEdgeStrips || stripNumber >= idHelper->strip_max(id) - nEdgeStrips + 1) + { + edge = true; + break; + } + } + double pitch = elem->design().phiPitch(); + auto ends = elem->endsOfStrip(cluster.localPosition()); + if (abs(ends.first.x()) < abs(ends.second.x())) + { + yEnd = ends.first.y()/pitch; + } + else + { + yEnd = ends.second.y()/pitch; + } + } + // Data members + static int nEdgeStrips; + static size_t nClusters; + uint index; + const FaserSCT_Cluster& cluster; + ClusterSet compatible; + double sinAlpha; + double cosAlpha; + double u; + double z; + double sigmaSq; + double yCenter; + double yEnd; + int layer; + int moduleIndex; + int side; + int phi; + int eta; + int etaIndex; + int view; + bool edge; + }; + typedef std::vector<std::shared_ptr<clusterInfo> > ClusterList; + + struct fitInfo + { + public: + fitInfo(const ClusterList& theClusters, + std::vector<size_t> theCandidates) + : clusters { theClusters } + , clusterMask { clusterInfo::nClusters } + , compatibleMask { clusterInfo::nClusters } + , fitChi2 { 0 } + , hasCovariance { false } + { + for (auto n = 0; n < 15; n++) sums[n] = 0.0; + compatibleMask.set(); + for (auto index : theCandidates) + { + addCluster(index); + } + } + // fitInfo(const fitInfo& f) + // : clusters { f.clusters } + // , candidates { f.candidates } + // , clusterMask { f.clusterMask } + // , compatibleMask { f.compatibleMask } + // , fitParams { f.fitParams } + // , fitCovariance { f.fitCovariance } + // , fitChi2 { f.fitChi2 } + // , hasCovariance { f.hasCovariance } + // { + // for (size_t i = 0; i < 15; i++) + // { + // sums[i] = f.sums[i]; + // } + // } + void addCluster(size_t n) + { + candidates.push_back(n); + clusterMask.set(n); + compatibleMask &= clusters[n]->compatible; + compatibleMask.set(n, false); + double sinA = clusters[n]->sinAlpha; + double cosA = clusters[n]->cosAlpha; + double u = clusters[n]->u; + double z = clusters[n]->z - zCenter; + double sSq = clusters[n]->sigmaSq; + sums[0] += 1; + sums[1] += sinA * sinA / sSq; + sums[2] += sinA * cosA / sSq; + sums[3] += cosA * cosA / sSq; + sums[4] += z * sinA * sinA / sSq; + sums[5] += z * sinA * cosA / sSq; + sums[6] += z * cosA * cosA / sSq; + sums[7] += z * z * sinA * sinA / sSq; + sums[8] += z * z * sinA * cosA / sSq; + sums[9] += z * z * cosA * cosA / sSq; + sums[10] += u * sinA / sSq; + sums[11] += u * cosA / sSq; + sums[12] += u * z * sinA / sSq; + sums[13] += u * z * cosA / sSq; + sums[14] += u * u / sSq; + if (fitChi2 != 0 || hasCovariance) + { + fitParams.setZero(); + fitCovariance.setZero(); + fitChi2 = 0; + hasCovariance = false; + } + } + HepGeom::Point3D<double> extrapolateFit(double z) const + { + return HepGeom::Point3D<double> { fitParams(0) + fitParams(2) * (z - zCenter), fitParams(1) + fitParams(3) * (z - zCenter), z }; + } + const ClusterList& clusters; + std::vector<size_t> candidates; + ClusterSet clusterMask; + ClusterSet compatibleMask; + double sums[15]; + static double zCenter; + Eigen::Matrix<double, 4, 1> fitParams; + Eigen::Matrix<double, 4, 4> fitCovariance; + double fitChi2; + bool hasCovariance; + }; + + typedef std::vector<std::shared_ptr<fitInfo> > FitList; + + typedef std::unordered_map<ClusterSet, std::shared_ptr<fitInfo> > FitMap; + typedef std::unordered_set<ClusterSet> MaskSet; + + typedef SG::ReadHandle<FaserSCT_ClusterContainer> ClusterContainerHandle; + StatusCode reconstructStation(ClusterContainerHandle clusters, int index, std::unique_ptr<TrackCollection>& tracks) const; + size_t stationOccupancy(ClusterContainerHandle clusters, int station) const; + double findCenter(int station) const; + ClusterList tabulateClusters(ClusterContainerHandle clusters, int station) const; + void checkCompatibility(ClusterList& clusters) const; + FitList enumerateSeeds(const ClusterList& clusters) const; + void findGoodSeeds(FitList& allSeeds, FitMap& goodSeeds, MaskSet& badSeeds) const; + void fitClusters(fitInfo& fit) const; + bool checkFit(const fitInfo& fit) const; + FitMap enumerateFits(const FitMap& seeds, const MaskSet& veto) const; + FitMap checkFitQuality(const FitMap& fits) const; + FitMap selectFits(const FitMap& fits) const; + bool vetoFit(const MaskSet& badSeeds, const ClusterSet& hypothesis) const; + int getStation(const Tracker::FaserSCT_ClusterCollection* collection) const; + + // struct layerCombo + // { + // const clusterInfo* stereoPlus; // no ownership + // const clusterInfo* stereoMinus; + // double sums[15]; + + // void initialize() + // { + // stereoPlus = nullptr; + // stereoMinus = nullptr; + // for (auto i = 0; i < 15; i++) sums[i] = 0.0; + // } + + // void addCluster(const clusterInfo* cluster, double zCenter) + // { + // double sinA = cluster->sinAlpha; + // double cosA = cluster->cosAlpha; + // double u = cluster->u; + // double z = cluster->z - zCenter; + // double sSq = cluster->sigmaSq; + // sums[0] += 1; + // sums[1] += sinA * sinA / sSq; + // sums[2] += sinA * cosA / sSq; + // sums[3] += cosA * cosA / sSq; + // sums[4] += z * sinA * sinA / sSq; + // sums[5] += z * sinA * cosA / sSq; + // sums[6] += z * cosA * cosA / sSq; + // sums[7] += z * z * sinA * sinA / sSq; + // sums[8] += z * z * sinA * cosA / sSq; + // sums[9] += z * z * cosA * cosA / sSq; + // sums[10] += u * sinA / sSq; + // sums[11] += u * cosA / sSq; + // sums[12] += u * z * sinA / sSq; + // sums[13] += u * z * cosA / sSq; + // sums[14] += u * u / sSq; + // if (sinA > 0) + // { + // stereoPlus = cluster; + // } + // else if (sinA < 0) + // { + // stereoMinus = cluster; + // } + // } + + // void removeCluster(const clusterInfo* cluster, double zCenter) + // { + // double sinA = cluster->sinAlpha; + // double cosA = cluster->cosAlpha; + // double u = cluster->u; + // double z = cluster->z - zCenter; + // double sSq = cluster->sigmaSq; + // sums[0] -= 1; + // sums[1] -= sinA * sinA / sSq; + // sums[2] -= sinA * cosA / sSq; + // sums[3] -= cosA * cosA / sSq; + // sums[4] -= z * sinA * sinA / sSq; + // sums[5] -= z * sinA * cosA / sSq; + // sums[6] -= z * cosA * cosA / sSq; + // sums[7] -= z * z * sinA * sinA / sSq; + // sums[8] -= z * z * sinA * cosA / sSq; + // sums[9] -= z * z * cosA * cosA / sSq; + // sums[10] -= u * sinA / sSq; + // sums[11] -= u * cosA / sSq; + // sums[12] -= u * z * sinA / sSq; + // sums[13] -= u * z * cosA / sSq; + // sums[14] -= u * u / sSq; + // if (sinA > 0) + // { + // stereoPlus = nullptr; + // } + // else if (sinA < 0) + // { + // stereoMinus = nullptr; + // } + // } + // }; + + StatusCode AddTrack(std::unique_ptr<TrackCollection>& tracks, + const std::shared_ptr<fitInfo>& theFit) const; + + Trk::TrackStateOnSurface* GetState( const Eigen::Matrix< double, 4, 1 >& fitResult, + const Eigen::Matrix< double, 4, 4 >& fitCovariance, + const FaserSCT_Cluster* fitCluster ) const; + + // void + // Residuals(std::vector<const clusterInfo*>& fitClusters) const; + + const FaserSCT_ID* m_idHelper; + const TrackerDD::SCT_DetectorManager* m_detMgr {nullptr}; + + SG::ReadHandleKey<FaserSCT_ClusterContainer> m_clusterContainerKey { this, "ClustersName", "SCT_ClusterContainer", "FaserSCT cluster container" }; + SG::WriteHandleKey<TrackCollection> m_trackCollection { this, "OutputCollection", "SegmentFit", "Output track collection name" }; + + UnsignedIntegerProperty m_minClustersPerStation { this, "MinClusters", 4, "Minimum number of clusters allowed in a station" }; + UnsignedIntegerProperty m_maxClustersPerStation { this, "MaxClusters", 36, "Maximum number of clusters allowed in a station" }; + BooleanProperty m_allowEtaOverlap { this, "EtaOverlap", true, "Allow overlapping clusters in the same face with neighboring eta" }; + BooleanProperty m_allowPhiOverlap { this, "PhiOverlap", true, "Allow overlapping edge clusters in the same face with neighboring phi" }; + IntegerProperty m_edgeStrips { this, "EdgeStrips", 32, "Number of strips from either edge of sensor considered for overlap" }; + DoubleProperty m_waferTolerance { this, "WaferTolerance", 3 * Gaudi::Units::mm, "Wafer boundary tolerance for extrapolated fit." }; + DoubleProperty m_yResidualCut { this, "ResidualCut", 3 * Gaudi::Units::mm, "Cluster y tolerance for compatibility with extrapolated fit." }; + DoubleProperty m_tanThetaCut { this, "TanThetaCut", 0.0, "Maximum accepted tangent of track angle from beam axis; 0 means no cut."}; + DoubleProperty m_reducedChi2Cut { this, "ReducedChi2Cut", 10.0, "Maximum accepted chi^2 per degree of freedom for final fits; 0 means no cut." }; + + mutable std::atomic<int> m_numberOfEvents{0}; + mutable std::atomic<int> m_numberExcessOccupancy{0}; + mutable std::atomic<int> m_numberLowOccupancy{0}; + mutable std::atomic<int> m_numberOfGoodStations{0}; + mutable std::atomic<int> m_numberOfClusterCollection{0}; + mutable std::atomic<int> m_numberOfClusters{0}; + mutable std::atomic<int> m_numberOfRule1Pairs{0}; + mutable std::atomic<int> m_numberOfRule2Pairs{0}; + mutable std::atomic<int> m_numberOfRule3Pairs{0}; + mutable std::atomic<int> m_numberOfRule4Pairs{0}; + mutable std::atomic<int> m_numberOfSeeds{0}; + mutable std::atomic<int> m_numberOfGoodSeeds{0}; + mutable std::atomic<int> m_numberOfFits{0}; + mutable std::atomic<int> m_numberOfGoodFits{0}; + mutable std::atomic<int> m_numberOfSelectedFits{0}; +}; + +inline int SegmentFitAlg::getStation(const Tracker::FaserSCT_ClusterCollection* collection) const +{ + return m_idHelper->station(m_idHelper->wafer_id(collection->identifyHash())); +} + +} +#endif // FASERSEGMENTFIT_SEGMENTFITALG_H diff --git a/Tracker/TrackerRecAlgs/TrackerSegmentFit/src/components/TrackerSegmentFit_entries.cxx b/Tracker/TrackerRecAlgs/TrackerSegmentFit/src/components/TrackerSegmentFit_entries.cxx new file mode 100644 index 0000000000000000000000000000000000000000..41900a40e067ac1b763cd1c35b0ccc0960c8d1e1 --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSegmentFit/src/components/TrackerSegmentFit_entries.cxx @@ -0,0 +1,3 @@ +#include "../SegmentFitAlg.h" + +DECLARE_COMPONENT( Tracker::SegmentFitAlg ) \ No newline at end of file diff --git a/Tracker/TrackerRecAlgs/TrackerSegmentFit/test/TestBeamSegmentFitDbg.py b/Tracker/TrackerRecAlgs/TrackerSegmentFit/test/TestBeamSegmentFitDbg.py new file mode 100755 index 0000000000000000000000000000000000000000..15685a42401d76962c2cc233e5ed62e57a3e66ad --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSegmentFit/test/TestBeamSegmentFitDbg.py @@ -0,0 +1,132 @@ +#!/usr/bin/env python +"""Test various ComponentAccumulator Digitization configuration modules + +Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +""" +import sys +from AthenaCommon.Logging import log, logging +from AthenaCommon.Constants import DEBUG, VERBOSE, INFO +from AthenaCommon.Configurable import Configurable +from CalypsoConfiguration.AllConfigFlags import ConfigFlags +from AthenaConfiguration.TestDefaults import defaultTestFiles +from CalypsoConfiguration.MainServicesConfig import MainServicesCfg +from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg +from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg +from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg +#from Digitization.DigitizationParametersConfig import writeDigitizationMetadata +from WaveRecAlgs.WaveRecAlgsConfig import WaveformReconstructionCfg +from TrackerPrepRawDataFormation.TrackerPrepRawDataFormationConfig import FaserSCT_ClusterizationCfg +from TrackerSegmentFit.TrackerSegmentFitConfig import SegmentFitAlgCfg +from TrackerSpacePointFormation.TrackerSpacePointFormationConfig import TrackerSpacePointFinderCfg +#from MCTruthSimAlgs.RecoTimingConfig import MergeRecoTimingObjCfg + +# Set up logging and new style config +log.setLevel(DEBUG) +Configurable.configurableRun3Behavior = True + +# Configure +ConfigFlags.Input.Files = [ + 'tbMu.raw', +] +ConfigFlags.Output.ESDFileName = "tbMu.ESD.pool.root" +ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-TB00" # Always needed; must match FaserVersion +ConfigFlags.IOVDb.DatabaseInstance = "OFLP200" # Use MC conditions for now +ConfigFlags.Input.ProjectName = "data21" # Needed to bypass autoconfig +ConfigFlags.Input.isMC = False # Needed to bypass autoconfig +ConfigFlags.GeoModel.FaserVersion = "FASER-TB00" # FASER geometry +ConfigFlags.Common.isOnline = False +ConfigFlags.GeoModel.Align.Dynamic = False +ConfigFlags.Beam.NumberOfCollisions = 0. + +# ConfigFlags.Detector.GeometryFaserSCT = True + +ConfigFlags.lock() + +# Core components +acc = MainServicesCfg(ConfigFlags) +#acc.merge(PoolReadCfg(ConfigFlags)) +acc.merge(PoolWriteCfg(ConfigFlags)) + +#acc.merge(writeDigitizationMetadata(ConfigFlags)) + +from FaserByteStreamCnvSvc.FaserByteStreamCnvSvcConfig import FaserByteStreamCnvSvcCfg +acc.merge(FaserByteStreamCnvSvcCfg(ConfigFlags)) +acc.merge(WaveformReconstructionCfg(ConfigFlags)) +acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags, DataObjectName="SCT_EDGEMODE_RDOs")) +acc.merge(SegmentFitAlgCfg(ConfigFlags, TanThetaCut = 0.0, MaxClusters = 25)) +acc.merge(TrackerSpacePointFinderCfg(ConfigFlags)) +acc.getEventAlgo("Tracker::SegmentFitAlg").OutputLevel = VERBOSE + +# from AthenaConfiguration.ComponentFactory import CompFactory +# decoderTool = CompFactory.ScintWaveformDecoderTool(name = "ScintWaveformDecoderTool", +# CaloChannels = [0, 1, 2, 3, 4, 5], +# PreshowerChannels = [6, 7], +# TriggerChannels = [8, 9], +# VetoChannels=[]) +# acc.addPublicTool(decoderTool) + +# # explicitly save RDO information +# from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg +# itemList = [ "xAOD::EventInfo#*", +# "xAOD::EventAuxInfo#*", +# "FaserSCT_RDO_Container#*", +# "xAOD::FaserTriggerData#*", +# "xAOD::FaserTriggerDataAux#*", +# "ScintWaveformContainer#*", +# "TrackCollection#*", +# "xAOD::WaveformHitContainer#*", +# "xAOD::WaveformHitAuxContainer#*", +# "xAOD::WaveformClock#*", +# "xAOD::WaveformClockAuxInfo#*", +# ] +# acc.merge(OutputStreamCfg(ConfigFlags, "ESD", itemList)) +# acc.getEventAlgo("OutputStreamESD").AcceptAlgs = ["Tracker::SegmentFitAlg"] + +# +# Configure output +from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg +itemList = [ "xAOD::EventInfo#*" + , "xAOD::EventAuxInfo#*" + , "xAOD::FaserTriggerData#*" + , "xAOD::FaserTriggerDataAux#*" + , "FaserSCT_RDO_Container#*" + , "Tracker::FaserSCT_ClusterContainer#*" + #, "Tracker::SCT_SpacePointContainer#*" + #, "Tracker::SCT_SpacePointOverlapCollection#*" + , "TrackCollection#*" +] +acc.merge(OutputStreamCfg(ConfigFlags, "ESD", itemList)) + +# Waveform reconstruction +from WaveRecAlgs.WaveRecAlgsConfig import WaveformReconstructionOutputCfg +acc.merge(WaveformReconstructionOutputCfg(ConfigFlags)) + + + +# Hack to avoid problem with our use of MC databases when isMC = False +replicaSvc = acc.getService("DBReplicaSvc") +replicaSvc.COOLSQLiteVetoPattern = "" +replicaSvc.UseCOOLSQLite = True +replicaSvc.UseCOOLFrontier = False +replicaSvc.UseGeomSQLite = True + + +# Timing +#acc.merge(MergeRecoTimingObjCfg(ConfigFlags)) + +# Dump config +# logging.getLogger('forcomps').setLevel(VERBOSE) +# acc.foreach_component("*").OutputLevel = VERBOSE +# acc.foreach_component("*ClassID*").OutputLevel = INFO +# acc.getCondAlgo("FaserSCT_AlignCondAlg").OutputLevel = VERBOSE +# acc.getCondAlgo("FaserSCT_DetectorElementCondAlg").OutputLevel = VERBOSE +# acc.getService("StoreGateSvc").Dump = True +# acc.getService("ConditionStore").Dump = True +# acc.printConfig(withDetails=True) +# ConfigFlags.dump() + +# Execute and finish +sc = acc.run(maxEvents=-1) + +# Success should be 0 +sys.exit(not sc.isSuccess()) diff --git a/Tracker/TrackerRecAlgs/TrackerSegmentFit/test/TrackerSegmentFitDbg.py b/Tracker/TrackerRecAlgs/TrackerSegmentFit/test/TrackerSegmentFitDbg.py new file mode 100644 index 0000000000000000000000000000000000000000..75c46defbbb45d3c815f9d11e0091c83836a6e1e --- /dev/null +++ b/Tracker/TrackerRecAlgs/TrackerSegmentFit/test/TrackerSegmentFitDbg.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python +"""Test various ComponentAccumulator Digitization configuration modules + +Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +""" +import sys +from AthenaCommon.Logging import log, logging +from AthenaCommon.Constants import DEBUG, VERBOSE, INFO +from AthenaCommon.Configurable import Configurable +from CalypsoConfiguration.AllConfigFlags import ConfigFlags +from AthenaConfiguration.TestDefaults import defaultTestFiles +from CalypsoConfiguration.MainServicesConfig import MainServicesCfg +from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg +from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg +from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg +#from Digitization.DigitizationParametersConfig import writeDigitizationMetadata +from WaveRecAlgs.WaveRecAlgsConfig import WaveformReconstructionCfg +from TrackerPrepRawDataFormation.TrackerPrepRawDataFormationConfig import FaserSCT_ClusterizationCfg +from TrackerSegmentFit.TrackerSegmentFitConfig import SegmentFitAlgCfg +from TrackerSpacePointFormation.TrackerSpacePointFormationConfig import TrackerSpacePointFinderCfg +#from MCTruthSimAlgs.RecoTimingConfig import MergeRecoTimingObjCfg + +# Set up logging and new style config +log.setLevel(DEBUG) +Configurable.configurableRun3Behavior = True + +# Configure +ConfigFlags.Input.Files = [ + '/eos/project-f/faser-commissioning/TI12Data/Run-005684/Faser-Physics-005684-00000.raw', +] +ConfigFlags.Output.ESDFileName = "run005684-00000.ESD.pool.root" +ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-02" # Always needed; must match FaserVersion +ConfigFlags.IOVDb.DatabaseInstance = "OFLP200" # Use MC conditions for now +ConfigFlags.Input.ProjectName = "data21" # Needed to bypass autoconfig +ConfigFlags.Input.isMC = False # Needed to bypass autoconfig +ConfigFlags.GeoModel.FaserVersion = "FASER-02" # FASER geometry +ConfigFlags.Common.isOnline = False +ConfigFlags.GeoModel.Align.Dynamic = False +ConfigFlags.Beam.NumberOfCollisions = 0. + +ConfigFlags.Detector.GeometryFaserSCT = True + +ConfigFlags.lock() + +# Core components +acc = MainServicesCfg(ConfigFlags) +#acc.merge(PoolReadCfg(ConfigFlags)) +acc.merge(PoolWriteCfg(ConfigFlags)) + +#acc.merge(writeDigitizationMetadata(ConfigFlags)) + +from FaserByteStreamCnvSvc.FaserByteStreamCnvSvcConfig import FaserByteStreamCnvSvcCfg +acc.merge(FaserByteStreamCnvSvcCfg(ConfigFlags)) +acc.merge(WaveformReconstructionCfg(ConfigFlags)) +acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags, DataObjectName="SCT_EDGEMODE_RDOs")) +acc.merge(SegmentFitAlgCfg(ConfigFlags)) +acc.merge(TrackerSpacePointFinderCfg(ConfigFlags)) +#acc.getEventAlgo("Tracker::SegmentFitAlg").OutputLevel = DEBUG + +# explicitly save RDO information +from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg +itemList = [ "xAOD::EventInfo#*" + , "xAOD::EventAuxInfo#*" + , "xAOD::FaserTriggerData#*" + , "xAOD::FaserTriggerDataAux#*" + , "FaserSCT_RDO_Container#*" + , "Tracker::FaserSCT_ClusterContainer#*" + , "TrackCollection#*" +] +acc.merge(OutputStreamCfg(ConfigFlags, "ESD", itemList)) + +# Waveform reconstruction +from WaveRecAlgs.WaveRecAlgsConfig import WaveformReconstructionOutputCfg +acc.merge(WaveformReconstructionOutputCfg(ConfigFlags)) + +# Hack to avoid problem with our use of MC databases when isMC = False +replicaSvc = acc.getService("DBReplicaSvc") +replicaSvc.COOLSQLiteVetoPattern = "" +replicaSvc.UseCOOLSQLite = True +replicaSvc.UseCOOLFrontier = False +replicaSvc.UseGeomSQLite = True + +# Timing +#acc.merge(MergeRecoTimingObjCfg(ConfigFlags)) + +# Dump config +# logging.getLogger('forcomps').setLevel(VERBOSE) +# acc.foreach_component("*").OutputLevel = VERBOSE +# acc.foreach_component("*ClassID*").OutputLevel = INFO +# acc.getCondAlgo("FaserSCT_AlignCondAlg").OutputLevel = VERBOSE +# acc.getCondAlgo("FaserSCT_DetectorElementCondAlg").OutputLevel = VERBOSE +# acc.getService("StoreGateSvc").Dump = True +# acc.getService("ConditionStore").Dump = True +# acc.printConfig(withDetails=True) +# ConfigFlags.dump() + +# Execute and finish +sc = acc.run(maxEvents=-1) + +# Success should be 0 +sys.exit(not sc.isSuccess()) \ No newline at end of file diff --git a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/python/TrackerSpacePointFormationConfig.py b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/python/TrackerSpacePointFormationConfig.py index de8355dedc7b23a05ec50fe6757fcba0d00f759b..4bd7402d130957407bdf9d3ca3a660b18530060a 100644 --- a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/python/TrackerSpacePointFormationConfig.py +++ b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/python/TrackerSpacePointFormationConfig.py @@ -49,13 +49,14 @@ def StatisticsBasicCfg(flags, **kwargs): acc = ComponentAccumulator() acc.popToolsAndMerge(TrackerSpacePointMakerToolCfg(flags)) kwargs.setdefault("SpacePointsSCTName", "SCT_SpacePointContainer") + kwargs.setdefault("SCT_ClustersName", "SCT_ClusterContainer") acc.addEventAlgo(Tracker__StatisticsAlg(**kwargs)) return acc def TrackerSpacePointFinder_OutputCfg(flags): """Return ComponentAccumulator with Output for SCT. Not standalone.""" acc = ComponentAccumulator() - itemList = [ "SpacePointContainer#*"] + itemList = [ "FaserSCT_SpacePointContainer#*"] acc.merge(OutputStreamCfg(flags, "ESD", itemList)) ostream = acc.getEventAlgo("OutputStreamESD") ostream.TakeItemsFromInput = True @@ -66,7 +67,7 @@ def TrackerSpacePointFinderCfg(flags, **kwargs): """Return ComponentAccumulator for SCT SpacePoints and Output""" acc=TrackerDDSiElementPropertiesTableCondAlgCfg(flags) acc.merge(TrackerSpacePointFinderBasicCfg(flags, **kwargs)) - # acc.merge(TrackerSpacePointFinder_OutputCfg(flags)) + acc.merge(TrackerSpacePointFinder_OutputCfg(flags)) return acc def StatisticsCfg(flags, **kwargs): diff --git a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/StatisticsAlg.cxx b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/StatisticsAlg.cxx index 5589297e584762c57a6450790c2a6d65a170a50e..68e9695ef1b05723ac2539b947ed9af644a621a0 100755 --- a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/StatisticsAlg.cxx +++ b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/StatisticsAlg.cxx @@ -18,7 +18,7 @@ #include "TrackerReadoutGeometry/SiDetectorElement.h" // Space point Classes, -// #include "TrkSpacePoint/SpacePointContainer.h" + #include "TrackerSpacePoint/FaserSCT_SpacePointContainer.h" // #include "TrackerSpacePoint/TrackerSpacePointCLASS_DEF.h" #include "TrackerIdentifier/FaserSCT_ID.h" @@ -64,6 +64,11 @@ StatusCode StatisticsAlg::initialize() ATH_MSG_DEBUG( "StatisticsAlg::initialize()" ); CHECK(m_thistSvc.retrieve()); + if(m_Sct_clcontainerKey.key().empty()){ + ATH_MSG_FATAL( "SCTs selected and no name set for SCT clusters"); + return StatusCode::FAILURE; + } + ATH_CHECK( m_Sct_clcontainerKey.initialize() ); // Check that clusters, space points and ids have names if ( m_Sct_spcontainerKey.key().empty()){ ATH_MSG_FATAL( "SCTs selected and no name set for SCT clusters"); @@ -137,9 +142,35 @@ StatusCode StatisticsAlg::execute (const EventContext& ctx) const // register the IdentifiableContainer into StoreGate + //retrieve SCT cluster container + SG::ReadHandle<Tracker::FaserSCT_ClusterContainer> sct_clcontainer( m_Sct_clcontainerKey, ctx ); + if (!sct_clcontainer.isValid()){ + msg(MSG:: FATAL) << "Could not find the data object "<< sct_clcontainer.name() << " !" << endmsg; + return StatusCode::RECOVERABLE; + } + std::cout<<"read sct"<<std::endl; + Tracker::FaserSCT_ClusterContainer::const_iterator clusit = sct_clcontainer->begin(); + Tracker::FaserSCT_ClusterContainer::const_iterator clusend = sct_clcontainer->end(); + + for (; clusit != clusend; ++clusit){ + const Tracker::FaserSCT_ClusterCollection *colNext=&(**clusit); + Identifier elementID = colNext->identify(); + std::cout<<"SCT hash "<<colNext->identify()<<" "<<colNext->identifyHash()<<" "<<colNext->size()<<std::endl; + FaserSCT_ClusterCollection::const_iterator clusters {colNext->begin()}; + FaserSCT_ClusterCollection::const_iterator clustersEnd {colNext->end()}; + for (; clusters != clustersEnd; ++clusters) + { + + const TrackerDD::SiDetectorElement* elem = (*clusters)->detectorElement(); + if (elem == nullptr)std::cout<<"not found detectorelement "<<std::endl; + else std::cout<<"element id "<<elem->identify(); + } + } + + std::cout<<"finish read sct"<<std::endl; // retrieve SCT cluster container - SG::ReadHandle<SpacePointContainer> sct_spcontainer( m_Sct_spcontainerKey, ctx ); + SG::ReadHandle<FaserSCT_SpacePointContainer> sct_spcontainer( m_Sct_spcontainerKey, ctx ); if (!sct_spcontainer.isValid()){ msg(MSG:: FATAL) << "Could not find the data object "<< sct_spcontainer.name() << " !" << endmsg; return StatusCode::RECOVERABLE; @@ -147,11 +178,11 @@ StatusCode StatisticsAlg::execute (const EventContext& ctx) const ATH_MSG_DEBUG( "SCT spacepoint container found: " << sct_spcontainer->size() << " collections" ); - SpacePointContainer::const_iterator it = sct_spcontainer->begin(); - SpacePointContainer::const_iterator itend = sct_spcontainer->end(); + FaserSCT_SpacePointContainer::const_iterator it = sct_spcontainer->begin(); + FaserSCT_SpacePointContainer::const_iterator itend = sct_spcontainer->end(); for (; it != itend; ++it){ - const SpacePointCollection *colNext=&(**it); + const FaserSCT_SpacePointCollection *colNext=&(**it); // int nReceivedSPSCT = colNext->size(); // Create SpacePointCollection @@ -167,15 +198,16 @@ StatusCode StatisticsAlg::execute (const EventContext& ctx) const ATH_MSG_VERBOSE( "StatisticsAlg algorithm found no space points" ); } else { //In a MT environment the cache maybe filled by another thread in which case this will delete the duplicate - SpacePointCollection::const_iterator sp_begin= colNext->begin(); - SpacePointCollection::const_iterator sp_end= colNext->end(); + FaserSCT_SpacePointCollection::const_iterator sp_begin= colNext->begin(); + FaserSCT_SpacePointCollection::const_iterator sp_end= colNext->end(); for (; sp_begin != sp_end; ++sp_begin){ - const Trk::SpacePoint* sp=&(**sp_begin); + const FaserSCT_SpacePoint* sp=&(**sp_begin); m_hist_r->Fill(sp->r()); m_hist_eta->Fill(sp->eta()); m_hist_phi->Fill(sp->phi()); Amg::Vector3D gloPos=sp->globalPosition(); m_hist_x->Fill(gloPos.x()); + ATH_MSG_DEBUG( "SCT spacepoint positions in container : " << gloPos.x()<<" "<<gloPos.y()<<" "<<gloPos.z() ); m_hist_y->Fill(gloPos.y()); m_hist_z->Fill(gloPos.z()); if ( ((istation-1)*3+ilayer) == 0 ) m_hist_x_y_plane0->Fill(gloPos.x(),gloPos.y()); @@ -208,4 +240,4 @@ StatusCode StatisticsAlg::finalize() //-------------------------------------------------------------------------- -} \ No newline at end of file +} diff --git a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/StatisticsAlg.h b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/StatisticsAlg.h index 2683f2ec561400dae90233c055029f6aeccca4f1..26add4b59a62d9c5a6819ec695396b56bcbbf987 100755 --- a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/StatisticsAlg.h +++ b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/StatisticsAlg.h @@ -15,11 +15,9 @@ #include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" #include "TrackerPrepRawData/TrackerClusterContainer.h" #include "TrackerReadoutGeometry/SiDetectorElementCollection.h" -// #include "TrackerSpacePointMakerAlg/SiElementPropertiesTable.h" -// #include "TrackerSpacePointMakerTool/TrackerSpacePointMakerTool.h" -#include "TrkSpacePoint/SpacePoint.h" -#include "TrkSpacePoint/SpacePointContainer.h" -#include "TrkSpacePoint/SpacePointOverlapCollection.h" +#include "TrackerSpacePoint/FaserSCT_SpacePoint.h" +#include "TrackerSpacePoint/FaserSCT_SpacePointContainer.h" +#include "TrackerSpacePoint/FaserSCT_SpacePointOverlapCollection.h" #include "GaudiKernel/ServiceHandle.h" #include "GaudiKernel/ITHistSvc.h" @@ -31,9 +29,6 @@ #include <string> -// class TrackerSpacePointCollection; -// class TrackerSpacePointOverlapCollection; -// class TrackerSpacePointContainer; class FaserSCT_ID; namespace Tracker { @@ -64,8 +59,9 @@ namespace Tracker StatisticsAlg &operator=(const StatisticsAlg&) = delete; //@} - SG::ReadHandleKey<SpacePointContainer> m_Sct_spcontainerKey{this, "SpacePointsSCTName", "SCT spContainer"}; + SG::ReadHandleKey<FaserSCT_SpacePointContainer> m_Sct_spcontainerKey{this, "SpacePointsSCTName", "SCT spContainer"}; //@} + SG::ReadHandleKey<Tracker::FaserSCT_ClusterContainer> m_Sct_clcontainerKey{this, "SCT_ClustersName", "SCT clContainer"}; SG::ReadCondHandleKey<TrackerDD::SiDetectorElementCollection> m_SCTDetEleCollKey{this, "SCTDetEleCollKey", "SCT_DetectorElementCollection", "Key of SiDetectorElementCollection for SCT"}; //@} diff --git a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/TrackerSpacePointFinder.cxx b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/TrackerSpacePointFinder.cxx index 62f63d8db08a27d9c04a347347954e07e4ee8968..4ccfe875bc7a7145520463997ee21fbe51e6749e 100755 --- a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/TrackerSpacePointFinder.cxx +++ b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/TrackerSpacePointFinder.cxx @@ -18,7 +18,7 @@ #include "TrackerReadoutGeometry/SiDetectorElement.h" // Space point Classes, -#include "TrkSpacePoint/SpacePointCollection.h" +#include "TrackerSpacePoint/FaserSCT_SpacePointCollection.h" // #include "TrkSpacePoint/SpacePointCLASS_DEF.h" #include "TrackerIdentifier/FaserSCT_ID.h" @@ -138,22 +138,22 @@ StatusCode TrackerSpacePointFinder::execute (const EventContext& ctx) const // } // register the IdentifiableContainer into StoreGate - SG::WriteHandle<SpacePointContainer> spacePointContainer_SCT; + SG::WriteHandle<FaserSCT_SpacePointContainer> spacePointContainer_SCT; if (m_selectSCTs){ - spacePointContainer_SCT = SG::WriteHandle<SpacePointContainer>( m_SpacePointContainer_SCTKey, ctx ); + spacePointContainer_SCT = SG::WriteHandle<FaserSCT_SpacePointContainer>( m_SpacePointContainer_SCTKey, ctx ); if(m_SpacePointCache_SCTKey.key().empty()){ - ATH_CHECK( spacePointContainer_SCT.record( std::make_unique<SpacePointContainer>(m_idHelper->wafer_hash_max()) ) ); + ATH_CHECK( spacePointContainer_SCT.record( std::make_unique<FaserSCT_SpacePointContainer>(m_idHelper->wafer_hash_max()) ) ); ATH_MSG_DEBUG("Created SpacePointContainer " << m_SpacePointContainer_SCTKey.key() << " N= " << m_idHelper->wafer_hash_max()); }else{ - SG::UpdateHandle<SpacePointCache> updateH( m_SpacePointCache_SCTKey, ctx ); + SG::UpdateHandle<FaserSCT_SpacePointCache> updateH( m_SpacePointCache_SCTKey, ctx ); ATH_CHECK(updateH.isValid()); - ATH_CHECK( spacePointContainer_SCT.record( std::make_unique<SpacePointContainer>(updateH.ptr()) ) ); + ATH_CHECK( spacePointContainer_SCT.record( std::make_unique<FaserSCT_SpacePointContainer>(updateH.ptr()) ) ); ATH_MSG_DEBUG("Created SpacePointContainer " << m_SpacePointContainer_SCTKey.key() << " from cache " << m_SpacePointCache_SCTKey.key()); } } - SG::WriteHandle<SpacePointOverlapCollection> spacepointoverlapCollection( m_spacepointoverlapCollectionKey, ctx ); - ATH_CHECK( spacepointoverlapCollection.record( std::make_unique<SpacePointOverlapCollection>() ) ); + SG::WriteHandle<FaserSCT_SpacePointOverlapCollection> spacepointoverlapCollection( m_spacepointoverlapCollectionKey, ctx ); + ATH_CHECK( spacepointoverlapCollection.record( std::make_unique<FaserSCT_SpacePointOverlapCollection>() ) ); ATH_MSG_DEBUG( "Container '" << spacepointoverlapCollection.name() << "' initialised" ); @@ -187,7 +187,7 @@ StatusCode TrackerSpacePointFinder::execute (const EventContext& ctx) const // Create SpacePointCollection IdentifierHash idHash = colNext->identifyHash(); - SpacePointContainer::IDC_WriteHandle lock = spacePointContainer_SCT->getWriteHandle(idHash); + FaserSCT_SpacePointContainer::IDC_WriteHandle lock = spacePointContainer_SCT->getWriteHandle(idHash); if(lock.alreadyPresent()){ ATH_MSG_DEBUG("SCT Hash " << idHash << " is already in cache"); ++sctCacheCount; @@ -195,9 +195,10 @@ StatusCode TrackerSpacePointFinder::execute (const EventContext& ctx) const } Identifier elementID = colNext->identify(); - auto spacepointCollection = std::make_unique<SpacePointCollection>(idHash); + auto spacepointCollection = std::make_unique<FaserSCT_SpacePointCollection>(idHash); spacepointCollection->setIdentifier(elementID); + ATH_MSG_DEBUG( "SCT cluster collection size "<<colNext->size() ); if ( colNext->size() != 0){ addSCT_SpacePoints(colNext, properties, elements, spacepointCollection.get(), spacepointoverlapCollection.ptr(), r_cache); @@ -270,10 +271,9 @@ void TrackerSpacePointFinder:: addSCT_SpacePoints(const Tracker::FaserSCT_ClusterCollection* next, const TrackerDD::SiElementPropertiesTable* properties, const TrackerDD::SiDetectorElementCollection* elements, - SpacePointCollection* spacepointCollection, SpacePointOverlapCollection* spacepointOverlapCollection, SPFCache &r_cache) const + FaserSCT_SpacePointCollection* spacepointCollection, FaserSCT_SpacePointOverlapCollection* spacepointOverlapCollection, SPFCache &r_cache) const { - // Do nothing unless this is a side 1 detector (strips of const phi). IdentifierHash thisHash(next->identifyHash()); // if it is not the stereo side @@ -352,7 +352,7 @@ checkForSCT_Points(const Tracker::FaserSCT_ClusterCollection* clusters1, const IdentifierHash id2, const TrackerDD::SiDetectorElementCollection* elements, double min, double max, - SpacePointCollection* spacepointCollection, bool overlapColl, SpacePointOverlapCollection* spacepointOverlapCollection, SPFCache &r_cache) const + FaserSCT_SpacePointCollection* spacepointCollection, bool overlapColl, FaserSCT_SpacePointOverlapCollection* spacepointOverlapCollection, SPFCache &r_cache) const { @@ -376,7 +376,7 @@ checkForSCT_Points(const Tracker::FaserSCT_ClusterCollection* clusters1, checkForSCT_Points(const Tracker::FaserSCT_ClusterCollection* clusters1, const IdentifierHash id2, const TrackerDD::SiDetectorElementCollection* elements, - double min1, double max1, double min2, double max2, SpacePointOverlapCollection* spacepointOverlapCollection, SPFCache &r_cache) const + double min1, double max1, double min2, double max2, FaserSCT_SpacePointOverlapCollection* spacepointOverlapCollection, SPFCache &r_cache) const { // get the cluster collections for these two detectors. Clus1 must lie @@ -388,4 +388,4 @@ checkForSCT_Points(const Tracker::FaserSCT_ClusterCollection* clusters1, m_SiSpacePointMakerTool->fillSCT_SpacePointPhiOverlapCollection(clusters1, clusters2, min1, max1, min2, max2, m_allClusters, r_cache.vertex, elements, spacepointOverlapCollection); } -} \ No newline at end of file +} diff --git a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/TrackerSpacePointFinder.h b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/TrackerSpacePointFinder.h index ae698bc3916d29c8c825732df5e4641cb628d4c0..c63cc6bb64e9f48300f7d6727e74a24fe8936198 100755 --- a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/TrackerSpacePointFinder.h +++ b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/src/TrackerSpacePointFinder.h @@ -21,15 +21,12 @@ #include "TrackerReadoutGeometry/SiDetectorElementCollection.h" #include "SiElementPropertiesTable.h" #include "FaserSiSpacePointTool/TrackerSpacePointMakerTool.h" -#include "TrkSpacePoint/SpacePoint.h" -#include "TrkSpacePoint/SpacePointContainer.h" -#include "TrkSpacePoint/SpacePointOverlapCollection.h" +#include "TrackerSpacePoint/FaserSCT_SpacePoint.h" +#include "TrackerSpacePoint/FaserSCT_SpacePointContainer.h" +#include "TrackerSpacePoint/FaserSCT_SpacePointOverlapCollection.h" #include <string> -// class TrackerSpacePointCollection; -// class TrackerSpacePointOverlapCollection; -// class TrackerSpacePointContainer; class FaserSCT_ID; @@ -125,21 +122,21 @@ namespace Tracker (const Tracker::FaserSCT_ClusterCollection* next, const TrackerDD::SiElementPropertiesTable* properties, const TrackerDD::SiDetectorElementCollection* elements, - SpacePointCollection* spacepointCollection, SpacePointOverlapCollection* spacepointOverlapCollection, SPFCache&) const; + FaserSCT_SpacePointCollection* spacepointCollection, FaserSCT_SpacePointOverlapCollection* spacepointOverlapCollection, SPFCache&) const; void checkForSCT_Points (const Tracker::FaserSCT_ClusterCollection* clusters1, const IdentifierHash id2, const TrackerDD::SiDetectorElementCollection* elements, double minDiff, double maxDiff, - SpacePointCollection* spacepointCollection, bool overlapColl, SpacePointOverlapCollection* spacepointOverlapCollection, SPFCache&) const; + FaserSCT_SpacePointCollection* spacepointCollection, bool overlapColl, FaserSCT_SpacePointOverlapCollection* spacepointOverlapCollection, SPFCache&) const; void checkForSCT_Points (const Tracker::FaserSCT_ClusterCollection* clusters1, const IdentifierHash id2, const TrackerDD::SiDetectorElementCollection* elements, double min1, double max1, - double min2, double max2, SpacePointOverlapCollection* spacepointOverlapCollection, SPFCache&) const; + double min2, double max2, FaserSCT_SpacePointOverlapCollection* spacepointOverlapCollection, SPFCache&) const; //@} // data members @@ -167,15 +164,15 @@ namespace Tracker * @name Output data using SG::WriteHandleKey */ //@{ - SG::WriteHandleKey<SpacePointContainer> m_SpacePointContainer_SCTKey{this, "SpacePointsSCTName", "SCT_SpacePoints", "SpacePoint SCT container"}; - SG::WriteHandleKey<SpacePointOverlapCollection> m_spacepointoverlapCollectionKey{this, "SpacePointsOverlapName", "OverlapSpacePoints", "Space Point Overlap collection"}; + SG::WriteHandleKey<FaserSCT_SpacePointContainer> m_SpacePointContainer_SCTKey{this, "SpacePointsSCTName", "SCT_SpacePoints", "SpacePoint SCT container"}; + SG::WriteHandleKey<FaserSCT_SpacePointOverlapCollection> m_spacepointoverlapCollectionKey{this, "SpacePointsOverlapName", "OverlapSpacePoints", "Space Point Overlap collection"}; //@} /** * @name Caches for HLT using SG::UpdateHandleKey */ //@{ - SG::UpdateHandleKey<SpacePointCache> m_SpacePointCache_SCTKey; + SG::UpdateHandleKey<FaserSCT_SpacePointCache> m_SpacePointCache_SCTKey; //@} /** diff --git a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/test/StatisticsDbg.py b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/test/StatisticsDbg.py index 55d4ee20812ac529068a8f233524a18a035ab3c8..5ad2fc49b5bbae6d3bf17bfd9b9e77708bc5e96c 100644 --- a/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/test/StatisticsDbg.py +++ b/Tracker/TrackerRecAlgs/TrackerSpacePointFormation/test/StatisticsDbg.py @@ -48,10 +48,10 @@ acc.merge(StatisticsCfg(ConfigFlags)) # Dump config # logging.getLogger('forcomps').setLevel(VERBOSE) -# acc.foreach_component("*").OutputLevel = VERBOSE -# acc.foreach_component("*ClassID*").OutputLevel = INFO -# acc.getCondAlgo("FaserSCT_AlignCondAlg").OutputLevel = VERBOSE -# acc.getCondAlgo("FaserSCT_DetectorElementCondAlg").OutputLevel = VERBOSE +acc.foreach_component("*").OutputLevel = VERBOSE +acc.foreach_component("*ClassID*").OutputLevel = INFO +acc.getCondAlgo("FaserSCT_AlignCondAlg").OutputLevel = VERBOSE +acc.getCondAlgo("FaserSCT_DetectorElementCondAlg").OutputLevel = VERBOSE # acc.getService("StoreGateSvc").Dump = True # acc.getService("ConditionStore").Dump = True # acc.printConfig(withDetails=True) diff --git a/Tracker/TrackerRecAlgs/TruthSeededTrackFinder/src/TruthSeededTrackFinder.cxx b/Tracker/TrackerRecAlgs/TruthSeededTrackFinder/src/TruthSeededTrackFinder.cxx index 1094424fb0cbd11f0a9618aedbd2813bfca4ded8..d23327e1c5b6c8d59bcf7e41e7a9dbf58ca164bf 100755 --- a/Tracker/TrackerRecAlgs/TruthSeededTrackFinder/src/TruthSeededTrackFinder.cxx +++ b/Tracker/TrackerRecAlgs/TruthSeededTrackFinder/src/TruthSeededTrackFinder.cxx @@ -18,7 +18,7 @@ #include "TrackerReadoutGeometry/SiDetectorElement.h" // Space point Classes, -#include "TrkSpacePoint/SpacePointCollection.h" +#include "TrackerSpacePoint/FaserSCT_SpacePointCollection.h" #include "TrackerIdentifier/FaserSCT_ID.h" @@ -219,7 +219,7 @@ namespace Tracker // retrieve SCT cluster container - SG::ReadHandle<SpacePointContainer> sct_spcontainer( m_Sct_spcontainerKey, ctx ); + SG::ReadHandle<FaserSCT_SpacePointContainer> sct_spcontainer( m_Sct_spcontainerKey, ctx ); if (!sct_spcontainer.isValid()){ msg(MSG:: FATAL) << "Could not find the data object "<< sct_spcontainer.name() << " !" << endmsg; return StatusCode::RECOVERABLE; @@ -234,14 +234,14 @@ namespace Tracker //!!!!!!!!!!!!!!!!!!!! ATH_MSG_DEBUG( "SCT spacepoint container found: " << sct_spcontainer->size() << " collections" ); - SpacePointContainer::const_iterator it = sct_spcontainer->begin(); - SpacePointContainer::const_iterator itend = sct_spcontainer->end(); + FaserSCT_SpacePointContainer::const_iterator it = sct_spcontainer->begin(); + FaserSCT_SpacePointContainer::const_iterator itend = sct_spcontainer->end(); int nTruthSP=0; ATH_MSG_DEBUG( "Start iteration of spacepoint collections" ); for (; it != itend; ++it){ ++m_numberOfSPCollection; - const SpacePointCollection *colNext=&(**it); + const FaserSCT_SpacePointCollection *colNext=&(**it); int nReceivedSPSCT = colNext->size(); // Create SpacePointCollection @@ -254,13 +254,13 @@ namespace Tracker ATH_MSG_VERBOSE( "Algorithm found no space points" ); ++m_numberOfEmptySPCollection; } else { - SpacePointCollection::const_iterator sp_begin= colNext->begin(); - SpacePointCollection::const_iterator sp_end= colNext->end(); + FaserSCT_SpacePointCollection::const_iterator sp_begin= colNext->begin(); + FaserSCT_SpacePointCollection::const_iterator sp_end= colNext->end(); ATH_MSG_DEBUG( "Iterate the spacepoint in collection " ); for (; sp_begin != sp_end; ++sp_begin){ ++m_numberOfSP; - const Trk::SpacePoint* sp=&(**sp_begin); + const FaserSCT_SpacePoint* sp=&(**sp_begin); bool match=false; //get truth hit const auto identifier = sp->clusterList().first->identify(); @@ -451,11 +451,11 @@ namespace Tracker Acts::Vector3 pos2_1(0., 0., 0.); Acts::Vector3 pos2_2(0., 0., 0.); - SpacePointContainer::const_iterator it = sct_spcontainer->begin(); - SpacePointContainer::const_iterator itend = sct_spcontainer->end(); + FaserSCT_SpacePointContainer::const_iterator it = sct_spcontainer->begin(); + FaserSCT_SpacePointContainer::const_iterator itend = sct_spcontainer->end(); for (; it != itend; ++it){ - const SpacePointCollection *colNext=&(**it); + const FaserSCT_SpacePointCollection *colNext=&(**it); // Create SpacePointCollection IdentifierHash idHash = colNext->identifyHash(); @@ -467,10 +467,10 @@ namespace Tracker ATH_MSG_VERBOSE( "StatisticsAlg algorithm found no space points" ); } else { //In a MT environment the cache maybe filled by another thread in which case this will delete the duplicate - SpacePointCollection::const_iterator sp_begin= colNext->begin(); - SpacePointCollection::const_iterator sp_end= colNext->end(); + FaserSCT_SpacePointCollection::const_iterator sp_begin= colNext->begin(); + FaserSCT_SpacePointCollection::const_iterator sp_end= colNext->end(); for (; sp_begin != sp_end; ++sp_begin){ - const Trk::SpacePoint* sp=&(**sp_begin); + const FaserSCT_SpacePoint* sp=&(**sp_begin); Amg::Vector3D gloPos=sp->globalPosition(); if ( ((istation-1)*3+ilayer) == 0 ) pos1_0 = Acts::Vector3(gloPos.x(), gloPos.y(), gloPos.z()); if ( ((istation-1)*3+ilayer) == 1 ) pos1_1 = Acts::Vector3(gloPos.x(), gloPos.y(), gloPos.z()); diff --git a/Tracker/TrackerRecAlgs/TruthSeededTrackFinder/src/TruthSeededTrackFinder.h b/Tracker/TrackerRecAlgs/TruthSeededTrackFinder/src/TruthSeededTrackFinder.h index bb09dfc937b252c2e4af9e4d8dd8e5e49e24358d..35a8c05f3dacb17018bbb40f5c97df11407b2590 100755 --- a/Tracker/TrackerRecAlgs/TruthSeededTrackFinder/src/TruthSeededTrackFinder.h +++ b/Tracker/TrackerRecAlgs/TruthSeededTrackFinder/src/TruthSeededTrackFinder.h @@ -16,10 +16,10 @@ #include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" #include "TrackerPrepRawData/TrackerClusterContainer.h" #include "TrackerReadoutGeometry/SiDetectorElementCollection.h" -#include "TrkSpacePoint/SpacePoint.h" -#include "TrkSpacePoint/SpacePointContainer.h" +#include "TrackerSpacePoint/FaserSCT_SpacePoint.h" +#include "TrackerSpacePoint/FaserSCT_SpacePointContainer.h" #include "TrackerSpacePoint/SpacePointForSeedCollection.h" -#include "TrkSpacePoint/SpacePointOverlapCollection.h" +#include "TrackerSpacePoint/FaserSCT_SpacePointOverlapCollection.h" #include "TrackerSimEvent/FaserSiHitCollection.h" #include "TrackerRawData/FaserSCT_RDO_Container.h" #include "TrackerSimData/TrackerSimDataCollection.h" @@ -63,7 +63,7 @@ class TruthSeededTrackFinder:public AthReentrantAlgorithm { TruthSeededTrackFinder() = delete; TruthSeededTrackFinder(const TruthSeededTrackFinder&) =delete; TruthSeededTrackFinder &operator=(const TruthSeededTrackFinder&) = delete; - SG::ReadHandleKey<SpacePointContainer> m_Sct_spcontainerKey{this, "SpacePointsSCTName", "SCT spContainer"}; + SG::ReadHandleKey<FaserSCT_SpacePointContainer> m_Sct_spcontainerKey{this, "SpacePointsSCTName", "SCT spContainer"}; SG::WriteHandleKey<SpacePointForSeedCollection> m_seed_spcontainerKey{this, "FaserSpacePointsSeedsName", "SpacePointForSeedCollection", "SpacePointForSeedCollection"}; diff --git a/Tracker/TrackerRecEvent/TrackerPrepRawData/CMakeLists.txt b/Tracker/TrackerRecEvent/TrackerPrepRawData/CMakeLists.txt index d1630abf233ec25789022973377d7c17956c7dd0..fa3b4bb2fbd2b8c845cd9e4f0ab795b432cbbca2 100644 --- a/Tracker/TrackerRecEvent/TrackerPrepRawData/CMakeLists.txt +++ b/Tracker/TrackerRecEvent/TrackerPrepRawData/CMakeLists.txt @@ -15,7 +15,7 @@ atlas_add_library( TrackerPrepRawData PUBLIC_HEADERS TrackerPrepRawData INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${EIGEN_LIBRARIES} AthLinks CxxUtils AthenaKernel GeoPrimitives Identifier EventPrimitives GaudiKernel TrackerReadoutGeometry TrkSurfaces TrkEventPrimitives TrkPrepRawData TrackerRawData EventContainers TrkSpacePoint + LINK_LIBRARIES ${EIGEN_LIBRARIES} AthLinks CxxUtils AthenaKernel GeoPrimitives Identifier EventPrimitives GaudiKernel TrackerReadoutGeometry TrkSurfaces TrkEventPrimitives TrkPrepRawData TrackerRawData EventContainers TrkSpacePoint PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} ) atlas_add_dictionary( TrackerPrepRawDataDict diff --git a/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/FaserSCT_ClusterContainer.h b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/FaserSCT_ClusterContainer.h index 80768c29db91f4b66498dcac8826f0e9c046face..153646cdd2081be60bc57500deffb209f22c008c 100755 --- a/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/FaserSCT_ClusterContainer.h +++ b/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/FaserSCT_ClusterContainer.h @@ -13,8 +13,8 @@ // Version 1.0 25/09/2002 Veronique Boisvert /////////////////////////////////////////////////////////////////// -#ifndef SCT_CLUSTERCONTAINER_H -#define SCT_CLUSTERCONTAINER_H +#ifndef FASERSCT_CLUSTERCONTAINER_H +#define FASERSCT_CLUSTERCONTAINER_H #include "AthenaKernel/CLASS_DEF.h" #include "TrkPrepRawData/PrepRawDataContainer.h" diff --git a/Tracker/TrackerRecEvent/TrackerSpacePoint/CMakeLists.txt b/Tracker/TrackerRecEvent/TrackerSpacePoint/CMakeLists.txt index e00ba940671bf57fc6b94ca18a58c30d1ef243a6..bd83f9e974868a8e42bcf1f21562bd527df687c2 100644 --- a/Tracker/TrackerRecEvent/TrackerSpacePoint/CMakeLists.txt +++ b/Tracker/TrackerRecEvent/TrackerSpacePoint/CMakeLists.txt @@ -10,9 +10,14 @@ find_package( Eigen ) # Component(s) in the package: atlas_add_library( TrackerSpacePoint - src/*.cxx src/*.h + src/*.cxx src/*.h PUBLIC_HEADERS TrackerSpacePoint PRIVATE_INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} - LINK_LIBRARIES Identifier TrkDetElementBase TrkSpacePoint - PRIVATE_LINK_LIBRARIES ${EIGEN_LIBRARIES} GeoPrimitives EventPrimitives TrkSurfaces TrkEventPrimitives TrkPrepRawData ) + LINK_LIBRARIES Identifier TrkDetElementBase TrkSpacePoint AthLinks TrackerPrepRawData + PRIVATE_LINK_LIBRARIES ${EIGEN_LIBRARIES} GeoPrimitives EventPrimitives TrkSurfaces TrkEventPrimitives TrkPrepRawData ) + +atlas_add_dictionary( TrackerSpacePointDict + TrackerSpacePoint/TrackerSpacePointDict.h + TrackerSpacePoint/selection.xml + LINK_LIBRARIES TrackerSpacePoint) diff --git a/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/FaserSCT_SpacePoint.h b/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/FaserSCT_SpacePoint.h index 28c5cc2663b61019656504e176ff273779bb4820..f21facf6ae0533bcd14a0bd29ebbc92157328d39 100755 --- a/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/FaserSCT_SpacePoint.h +++ b/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/FaserSCT_SpacePoint.h @@ -1,6 +1,6 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -*/ + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + */ /////////////////////////////////////////////////////////////////// // SCT_SpacePoint.h @@ -13,79 +13,244 @@ #ifndef TRACKERSPACEPOINT_SCTSPACEPOINT_H #define TRACKERSPACEPOINT_SCTSPACEPOINT_H -#include "TrkSpacePoint/SpacePoint.h" +#include "AthLinks/ElementLink.h" #include "Identifier/IdentifierHash.h" +#include "TrkEventPrimitives/LocalParameters.h" +#include "TrkSurfaces/Surface.h" +#include "TrackerPrepRawData/FaserSCT_Cluster.h" +#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" + +class FaserSCT_SpacePointContainerCnv; +class FaserSCT_SpacePointContainerCnv_p0; +class FaserSCT_SpacePointCnv_p0; -namespace Trk +namespace Tracker { class TrackerCluster; } +namespace Trk{ + class LocalParameters; + class ErrorMatrix; + class Surface; +} + namespace Tracker { /** * @class SCT_SpacePoint * An SCT_SpacePoint is created from two SCT_Cluster's from two different wafers. */ - - class FaserSCT_SpacePoint : public Trk::SpacePoint - { - - /////////////////////////////`////////////////////////////////////// - // Public methods: - /////////////////////////////////////////////////////////////////// + + class FaserSCT_SpacePoint + { + friend class FaserSCT_SpacePointContainerCnv; + friend class FaserSCT_SpacePointContainerCnv_p0; + friend class FaserSCT_SpacePointCnv_p0; + + /////////////////////////////`////////////////////////////////////// + // Public methods: + /////////////////////////////////////////////////////////////////// public: - - /** Default constructor */ - FaserSCT_SpacePoint() ; - - /** - * @name Parametrised constructors - * In order to ensure initialisation, the global Position has to be - * on the surface associated to the FIRST member of the PRD-pair clusList. - */ - //@{ - FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, - const Amg::Vector3D& position, - const std::pair<const Trk::PrepRawData*, const Trk::PrepRawData*>& clusList) ; - //@} - - /** Copy Constructor */ - FaserSCT_SpacePoint(const FaserSCT_SpacePoint &) ; - - /** Destructor */ - virtual ~FaserSCT_SpacePoint() = default; - - /** Overloading Assignment Operator */ - FaserSCT_SpacePoint &operator=(const FaserSCT_SpacePoint &); - - /** Clones */ - virtual Trk::SpacePoint* clone() const ; - - /**Interface method for output, to be overloaded by child classes* */ - virtual MsgStream& dump( MsgStream& out ) const ; - - /**Interface method for output, to be overloaded by child classes* */ - virtual std::ostream& dump( std::ostream& out ) const ; - - private: - /** method to set up the local Covariance Matrix. */ - void setupLocalCovarianceSCT() ; + /** Default constructor */ + FaserSCT_SpacePoint() ; + + /** + * @name Parametrised constructors + * In order to ensure initialisation, the global Position has to be + * on the surface associated to the FIRST member of the PRD-pair clusList. + */ + //@{ + FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, + const Amg::Vector3D* position, + const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>* clusList) ; + + FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, + const Amg::Vector3D* position, + const Amg::MatrixX* loccov,//assumes ownership of loccov + const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>* clusList) ; + + FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, + const Amg::Vector3D& position, + const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>* clusList) ; + FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, + const Amg::Vector3D* position, + Amg::MatrixX* globallcov, + const Amg::Vector2D* localpos, + Amg::MatrixX* localcov, + const ElementLink<Tracker::FaserSCT_ClusterContainer>& link1, const ElementLink<Tracker::FaserSCT_ClusterContainer>& link2) ; + + FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, + const Amg::Vector3D& position, + const Amg::MatrixX& loccov,//assumes ownership of loccov + const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>* clusList) ; + FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, + const Amg::Vector3D* position, + const ElementLink<Tracker::FaserSCT_ClusterContainer>& link1, const ElementLink<Tracker::FaserSCT_ClusterContainer>& link2) ; + //@} + + /** Copy Constructor */ + // FaserSCT_SpacePoint(const FaserSCT_SpacePoint &) ; + + /** Destructor */ + ~FaserSCT_SpacePoint() = default; + + /** Overloading Assignment Operator */ + // FaserSCT_SpacePoint &operator=(const FaserSCT_SpacePoint &); + + /** Clones */ + FaserSCT_SpacePoint* clone() const ; + /** return the pair of Ids of the element by reference*/ + const std::pair<IdentifierHash, IdentifierHash>& elementIdList() const; + + /** return the pair of cluster pointers by reference */ + const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>& clusterList() const; + + /** return the error matrix by reference + The Matrix is calculated from the local Covariance Matrix when demanded and the cached */ + const Amg::MatrixX& globCovariance() const; + + /** calculate eta (not cached), needs z0 info */ + double eta(double z0=0) const; + + /**returns the r value of the SpacePoint's position (in cylindrical coordinates). + This is calculated once in the ctor and then cached*/ + double r() const ; + + /**returns the phi value of the SpacePoint's position (in cylindrical coordinates). + 0070 This is calculated once in the ctor and then cached*/ + double phi() const ; + + + /**Interface method for output, to be overloaded by child classes* */ + MsgStream& dump( MsgStream& out ) const ; + + /**Interface method for output, to be overloaded by child classes* */ + std::ostream& dump( std::ostream& out ) const ; + + /**Interface method to get the LocalParameters*/ + const Trk::LocalParameters& localParameters() const; + + /**Interface method to get the localError*/ + const Amg::MatrixX& localCovariance() const; - /** common method used in constructors. */ - void setup(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, - const Amg::Vector3D& position, - const std::pair<const Trk::PrepRawData*, const Trk::PrepRawData*>&clusList); + /**Interface method to get the associated Surface*/ + const Trk::Surface& associatedSurface() const ; + + /**Interface method to get the global Position*/ + const Amg::Vector3D& globalPosition() const ; + + // Here to help implement the relevant semantics for + // the derived classes + FaserSCT_SpacePoint(const FaserSCT_SpacePoint&) = default; + FaserSCT_SpacePoint(FaserSCT_SpacePoint&&) noexcept = default; + FaserSCT_SpacePoint& operator=(const FaserSCT_SpacePoint&); + FaserSCT_SpacePoint& operator=(FaserSCT_SpacePoint&&) noexcept = default; + + //Element link to FaserSCT_Cluster + ElementLink<Tracker::FaserSCT_ClusterContainer>* getElementLink1(){return (&m_elelink1);} + ElementLink<Tracker::FaserSCT_ClusterContainer>* getElementLink2(){return (&m_elelink2);} + const ElementLink<Tracker::FaserSCT_ClusterContainer>* getElementLink1()const {return (&m_elelink1);} + const ElementLink<Tracker::FaserSCT_ClusterContainer>* getElementLink2()const {return (&m_elelink2);} + const Tracker::FaserSCT_Cluster* cluster1() const{if(m_elelink1.isValid())return m_elelink1.cachedElement();else return 0;} + const Tracker::FaserSCT_Cluster* cluster2() const{if(m_elelink2.isValid())return m_elelink2.cachedElement();else return 0;} + + void setLocalParameters(Amg::Vector2D& loc){m_localParams = Trk::LocalParameters(loc);}; + void setGlobalParameters(Amg::Vector3D& glo){m_position=glo;}; + void setGlobalCovariance(Amg::MatrixX& glo){m_globalCovariance=glo;}; + void setLocalCovariance(Amg::MatrixX& loc){m_localCovariance=loc;}; + void setClusList(std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*> list){m_clusList=list; m_elelink1.setElement(list.first); + m_elelink2.setElement(list.second); }; - + void setElemIdList(std::pair<IdentifierHash, IdentifierHash> list){m_elemIdList=list;}; + + protected: + + Trk::LocalParameters m_localParams; + Amg::MatrixX m_localCovariance; + std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*> m_clusList; + std::pair<IdentifierHash, IdentifierHash> m_elemIdList; + Amg::Vector3D m_position; + Amg::MatrixX m_globalCovariance; + + private: + + + ElementLink<Tracker::FaserSCT_ClusterContainer> m_elelink1, m_elelink2; + void setupGlobalFromLocalCovariance(); + /** method to set up the local Covariance Matrix. */ + void setupLocalCovarianceSCT() ; + + /** common method used in constructors. */ + void setup(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, + const Amg::Vector3D& position, + const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>* clusList); + }; + /////////////////////////////////////////////////////////////////// // Inline methods: /////////////////////////////////////////////////////////////////// - inline Trk::SpacePoint* FaserSCT_SpacePoint::clone() const - { return new FaserSCT_SpacePoint(*this) ; } - + inline FaserSCT_SpacePoint* FaserSCT_SpacePoint::clone() const + { return new FaserSCT_SpacePoint(*this) ; } + + inline const Trk::LocalParameters& + FaserSCT_SpacePoint::localParameters() const + { + return m_localParams; + } + + inline const Amg::MatrixX& + FaserSCT_SpacePoint::localCovariance() const + { + return m_localCovariance; + } + + /**Overload of << operator for MsgStream for debug output*/ + inline MsgStream& + operator<<(MsgStream& sl, const FaserSCT_SpacePoint& mbase) + { + return mbase.dump(sl); + } + + /**Overload of << operator for std::ostream for debug output*/ + inline std::ostream& + operator<<(std::ostream& sl, const FaserSCT_SpacePoint& mbase) + { + return mbase.dump(sl); + } + inline const std::pair<IdentifierHash, IdentifierHash>& FaserSCT_SpacePoint::elementIdList() const + { return m_elemIdList; } + + + inline const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>& FaserSCT_SpacePoint::clusterList() const + { + return m_clusList; + } + + inline double FaserSCT_SpacePoint::eta(double z0) const + { + // double zr = (m_z-z0)/m_r; + double zr = (m_position.z() - z0)/m_position.perp(); + return std::log(zr+std::sqrt(1.+zr*zr)); + } + + inline double FaserSCT_SpacePoint::r() const + { return m_position.perp(); } + + inline double FaserSCT_SpacePoint::phi() const + { return m_position.phi(); } + + // The methods required by MeasurementBase + inline const Amg::Vector3D& FaserSCT_SpacePoint::globalPosition() const + { + return m_position; + } + inline const Amg::MatrixX& FaserSCT_SpacePoint::globCovariance() const { + return m_globalCovariance; + } + } #endif // TRACKERSPACEPOINT_SCTSPACEPOINT_H diff --git a/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/FaserSCT_SpacePointCollection.h b/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/FaserSCT_SpacePointCollection.h new file mode 100755 index 0000000000000000000000000000000000000000..a68c658e1137e77ac95a5a0244659d92b3079e0c --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/FaserSCT_SpacePointCollection.h @@ -0,0 +1,101 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// FaserSCT_SpacePointCollection.h +// Header file for class FaserSCT_SpacePointCollection +/////////////////////////////////////////////////////////////////// +// (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// +// Class to contain all the SPs of a detector element: +// module for Pixel or wafer for SCT or layer for TRT, +// for Muons: +// For SCT the DE is ambiguous, we are using the id of the R module (not the one with +// the stereo angle ) +// The overlap space points are contained in the FaserSCT_SpacePointOverlapCollection +/////////////////////////////////////////////////////////////////// +// Version 1.0 14/10/2003 Veronique Boisvert +/////////////////////////////////////////////////////////////////// + +#ifndef TRACKERSPACEPOINT_FASERSCT_SPACEPOINTCOLLECTION_H +#define TRACKERSPACEPOINT_FASERSCT_SPACEPOINTCOLLECTION_H + +// Base classes +#include "Identifier/Identifier.h" +#include "Identifier/Identifiable.h" +#include "Identifier/IdentifierHash.h" +#include "AthContainers/DataVector.h" +#include "GaudiKernel/DataObject.h" +//class SpacePoint; +#include "TrackerSpacePoint/FaserSCT_SpacePoint.h" + + +class FaserSCT_SpacePointCollectionCopyConstructorCalled{}; + + +class FaserSCT_SpacePointCollection + : public Identifiable, + public DataVector< Tracker::FaserSCT_SpacePoint > +{ + /////////////////////////////////////////////////////////////////// + // Public methods: + /////////////////////////////////////////////////////////////////// + public: + + // Standard thinning code won't work on this type because + // we have no default constructor. + static bool constexpr supportsThinning = false; + + // Constructor with parameters: + // Hashed offline identifier of the DE + FaserSCT_SpacePointCollection(const IdentifierHash idHash); + + // Destructor: + virtual ~FaserSCT_SpacePointCollection(); + + /**added for 10.0.0 as a hack for HLT. DO NOT USE IT. It will throw an exception*/ + FaserSCT_SpacePointCollection(const FaserSCT_SpacePointCollection& spc); + + + /////////////////////////////////////////////////////////////////// + // Const methods: + /////////////////////////////////////////////////////////////////// + + virtual Identifier identify() const override final; + + virtual IdentifierHash identifyHash() const override final; + + void setIdentifier(Identifier id); + + virtual std::string type() const; + + /////////////////////////////////////////////////////////////////// + // Private methods: + /////////////////////////////////////////////////////////////////// + private: + + FaserSCT_SpacePointCollection() = delete; + FaserSCT_SpacePointCollection &operator=(const FaserSCT_SpacePointCollection&) = delete; + + /////////////////////////////////////////////////////////////////// + // Private data: + /////////////////////////////////////////////////////////////////// + private: + const IdentifierHash m_idHash; + Identifier m_id; // identifier of the DE +}; + +/**Overload of << operator for MsgStream for debug output*/ +MsgStream& operator << ( MsgStream& sl, const FaserSCT_SpacePointCollection& coll); + +/**Overload of << operator for std::ostream for debug output*/ +std::ostream& operator << ( std::ostream& sl, const FaserSCT_SpacePointCollection& coll); +/////////////////////////////////////////////////////////////////// +// Inline methods: +/////////////////////////////////////////////////////////////////// + +#include "AthenaKernel/CLASS_DEF.h" +CLASS_DEF(FaserSCT_SpacePointCollection,1129085627,1) + +#endif // TRKSPACEPOINT_SPACEPOINTCOLLECTION_H diff --git a/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/FaserSCT_SpacePointContainer.h b/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/FaserSCT_SpacePointContainer.h new file mode 100755 index 0000000000000000000000000000000000000000..420d7579d53312267c1b1be5234db3c21bd4ad02 --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/FaserSCT_SpacePointContainer.h @@ -0,0 +1,95 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// SpacePointContaine.h +// Header file for class SpacePointContainer +/////////////////////////////////////////////////////////////////// +// (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// +// Container for SpacePoints collections for InnerDetector and Muons +/////////////////////////////////////////////////////////////////// +// Version 1.0 14/10/2003 Veronique Boisvert +/////////////////////////////////////////////////////////////////// + +#ifndef TRACKERSPACEPOINT_FASERSCT_SPACEPOINTCONTAINER_H +#define TRACKERSPACEPOINT_FASERSCT_SPACEPOINTCONTAINER_H + +// Base classes +#include "EventContainers/IdentifiableContainer.h" +//Needed Classes +#include "TrackerSpacePoint/FaserSCT_SpacePointCollection.h" + + +typedef EventContainers::IdentifiableCache< FaserSCT_SpacePointCollection > FaserSCT_SpacePointCache; + +class FaserSCT_SpacePointContainer +: public IdentifiableContainer<FaserSCT_SpacePointCollection>{ + + /////////////////////////////////////////////////////////////////// + // Public methods: + /////////////////////////////////////////////////////////////////// +public: + + // Constructor with parameters: + FaserSCT_SpacePointContainer(unsigned int max); + + FaserSCT_SpacePointContainer(FaserSCT_SpacePointCache*); + + // Destructor: + virtual ~FaserSCT_SpacePointContainer(); + + /** return class ID */ + static const CLID& classID() + { + static const CLID id = 1306592743; + return id; + // we do not know why using the traits does not work + //return ClassID_traits<SpacePointContainer>::ID(); + } + + /** return class ID */ + virtual const CLID& clID() const + { + return classID(); + } + + + /////////////////////////////////////////////////////////////////// + // Const methods: + /////////////////////////////////////////////////////////////////// + + + /////////////////////////////////////////////////////////////////// + // Non-const methods: + /////////////////////////////////////////////////////////////////// + + + + /////////////////////////////////////////////////////////////////// + // Private methods: + /////////////////////////////////////////////////////////////////// +private: + + FaserSCT_SpacePointContainer() = delete; + FaserSCT_SpacePointContainer(const FaserSCT_SpacePointContainer&) = delete; + FaserSCT_SpacePointContainer &operator=(const FaserSCT_SpacePointContainer&) = delete; + /////////////////////////////////////////////////////////////////// + // Private data: + /////////////////////////////////////////////////////////////////// +private: + +}; +/////////////////////////////////////////////////////////////////// +// Inline methods: +/////////////////////////////////////////////////////////////////// + +#include "AthenaKernel/CLASS_DEF.h" +CLASS_DEF(FaserSCT_SpacePointContainer,1306592743,1) + + +CLASS_DEF( FaserSCT_SpacePointCache , 180888152, 1 ) + + +#endif // TRKSPACEPOINT_SPACEPOINTCONTAINER_H diff --git a/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/FaserSCT_SpacePointOverlapCollection.h b/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/FaserSCT_SpacePointOverlapCollection.h new file mode 100755 index 0000000000000000000000000000000000000000..75bf587a3831c2f51afbf9cdeda1ebbb7f8fb512 --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/FaserSCT_SpacePointOverlapCollection.h @@ -0,0 +1,70 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// SpacePointCollection.h +// Header file for class SpacePointCollection +/////////////////////////////////////////////////////////////////// +// (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// +// Class to contain all the overlap SPs, the other ones are in +// the SpacePointCollection +/////////////////////////////////////////////////////////////////// +// Version 1.0 14/10/2003 Veronique Boisvert +/////////////////////////////////////////////////////////////////// + +#ifndef TRACKERSPACEPOINT_FASERSCTSPACEPOINTOVERLAPCOLLECTION_H +#define TRACKERSPACEPOINT_FASERSCTSPACEPOINTOVERLAPCOLLECTION_H + +// Base classes +#include "AthContainers/DataVector.h" +#include "GaudiKernel/DataObject.h" +//class SpacePoint; +#include "TrackerSpacePoint/FaserSCT_SpacePoint.h" + +class FaserSCT_SpacePointOverlapCollection : public DataVector< Tracker::FaserSCT_SpacePoint >{ + + /////////////////////////////////////////////////////////////////// + // Public methods: + /////////////////////////////////////////////////////////////////// +public: + + // Constructor + FaserSCT_SpacePointOverlapCollection(); + + // Destructor: + virtual ~FaserSCT_SpacePointOverlapCollection(); + + + /////////////////////////////////////////////////////////////////// + // Const methods: + /////////////////////////////////////////////////////////////////// + + + + /////////////////////////////////////////////////////////////////// + // Private methods: + /////////////////////////////////////////////////////////////////// +private: + + // FaserSCT_SpacePointOverlapCollection(); + FaserSCT_SpacePointOverlapCollection(const FaserSCT_SpacePointOverlapCollection&) = delete; + FaserSCT_SpacePointOverlapCollection &operator=(const FaserSCT_SpacePointOverlapCollection&) = delete; + + /////////////////////////////////////////////////////////////////// + // Private data: + /////////////////////////////////////////////////////////////////// +private: + + +}; +/////////////////////////////////////////////////////////////////// +// Inline methods: +/////////////////////////////////////////////////////////////////// + +#include "AthenaKernel/CLASS_DEF.h" +CLASS_DEF(FaserSCT_SpacePointOverlapCollection,1114023127, 1) + + +#endif // TRKSPACEPOINT_SPACEPOINTOVERLAPCOLLECTION_H diff --git a/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/SpacePointForSeed.h b/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/SpacePointForSeed.h index 9b3f7fcf67b830190245546fe0923e19b08e4b61..41d19025428a8a7c1626ef5d3595938870288a48 100644 --- a/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/SpacePointForSeed.h +++ b/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/SpacePointForSeed.h @@ -1,23 +1,23 @@ #ifndef SpacePointForSeed_h #define SpacePointForSeed_h -#include "TrkSpacePoint/SpacePoint.h" +#include "TrackerSpacePoint/FaserSCT_SpacePoint.h" -namespace Trk{ - class SpacePoint; -} +//namespace Trk{ +// class SpacePoint; +//} class SpacePointForSeed{ public: SpacePointForSeed() = delete; - SpacePointForSeed(const Trk::SpacePoint* sp) : m_spacepoint(sp) {}; + SpacePointForSeed(const Tracker::FaserSCT_SpacePoint* sp) : m_spacepoint(sp) {}; ~SpacePointForSeed() = default; - const Trk::SpacePoint* SpacePoint() const { + const Tracker::FaserSCT_SpacePoint* SpacePoint() const { return m_spacepoint; } private: - const Trk::SpacePoint * m_spacepoint; + const Tracker::FaserSCT_SpacePoint * m_spacepoint; }; #endif diff --git a/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerSeed.h b/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/TrackerSeed.h similarity index 68% rename from Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerSeed.h rename to Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/TrackerSeed.h index 02d6a193aa081bbd2188288131a98a6bb2708096..80983149d647e9f5e41ec0c330a1e73ca78c8c43 100755 --- a/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerSeed.h +++ b/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/TrackerSeed.h @@ -1,7 +1,7 @@ -#ifndef TRACKERRAWDATA_TRACKERSEED_H -#define TRACKERRAWDATA_TRACKERSEED_H +#ifndef TRACKERSPACEPOINT_TRACKERSEED_H +#define TRACKERSPACEPOINT_TRACKERSEED_H -#include "TrkSpacePoint/SpacePoint.h" +#include "TrackerSpacePoint/FaserSCT_SpacePoint.h" #include <vector> @@ -21,13 +21,14 @@ namespace Tracker { TrackerSeed(const StrategyId, const TrackerSeed &); virtual ~TrackerSeed(); - TrackerSeed(const StrategyId, vector<const Trk::SpacePoint*> seed); + TrackerSeed(const StrategyId, vector<const FaserSCT_SpacePoint*> seed); void set_id(const StrategyId id) { m_strategyId = id; } StrategyId id() const { return m_strategyId; } - void add(vector<const Trk::SpacePoint*> seed); + void add(vector<const FaserSCT_SpacePoint*> seed); + vector<const FaserSCT_SpacePoint*> getSpacePoints() const {return m_seed;}; int size() const; TrackerSeed &operator=(const TrackerSeed &); @@ -38,7 +39,7 @@ namespace Tracker { private: StrategyId m_strategyId; - vector<const Trk::SpacePoint*> m_seed; + vector<const FaserSCT_SpacePoint*> m_seed; }; diff --git a/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerSeedCollection.h b/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/TrackerSeedCollection.h similarity index 88% rename from Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerSeedCollection.h rename to Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/TrackerSeedCollection.h index a90dedca94ed8580d9fe74dac784fc9c0ee70e69..2cfd8eda282b144c8d582af1526934947108808f 100755 --- a/Tracker/TrackerRecEvent/TrackerPrepRawData/TrackerPrepRawData/TrackerSeedCollection.h +++ b/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/TrackerSeedCollection.h @@ -4,7 +4,7 @@ #include "AthenaKernel/CLASS_DEF.h" #include "AthContainers/DataVector.h" #include "GaudiKernel/DataObject.h" -#include "TrackerPrepRawData/TrackerSeed.h" +#include "TrackerSpacePoint/TrackerSeed.h" namespace Tracker { typedef DataVector<TrackerSeed> TrackerSeedCollection; diff --git a/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/TrackerSpacePointDict.h b/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/TrackerSpacePointDict.h new file mode 100644 index 0000000000000000000000000000000000000000..07b3407c20c2c2d33a8cf54fa37e147d3cfcc39e --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/TrackerSpacePointDict.h @@ -0,0 +1,13 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS and FASER collaborations +*/ + +#ifndef TRACKERSPACEPOINTDICT_H +#define TRACKERSPACEPOINTDICT_H + +#include "TrackerSpacePoint/FaserSCT_SpacePoint.h" +#include "TrackerSpacePoint/FaserSCT_SpacePointCollection.h" +#include "TrackerSpacePoint/FaserSCT_SpacePointOverlapCollection.h" +#include "TrackerSpacePoint/FaserSCT_SpacePointContainer.h" + +#endif diff --git a/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/selection.xml b/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/selection.xml new file mode 100644 index 0000000000000000000000000000000000000000..e94170445195d4267bcbd1ab99b657a1691f7b52 --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerSpacePoint/TrackerSpacePoint/selection.xml @@ -0,0 +1,6 @@ +<lcgdict> + <class name="Tracker::FaserSCT_SpacePoint" > + </class> + <class name="FaserSCT_SpacePointCollection<Tracker::FaserSCT_SpacePoint>" id="B1069307-0EEF-48D8-B545-A47D2DFFD8FC" /> + <class name="FaserSCT_SpacePointContainer" /> + </lcgdict> diff --git a/Tracker/TrackerRecEvent/TrackerSpacePoint/src/FaserSCT_SpacePoint.cxx b/Tracker/TrackerRecEvent/TrackerSpacePoint/src/FaserSCT_SpacePoint.cxx index 68554d010e724fbe59f5c07cbfbb2c02b64d97f9..4b7ec0ff4a74691bea1b079ea1cfa31bf5f0cf6e 100755 --- a/Tracker/TrackerRecEvent/TrackerSpacePoint/src/FaserSCT_SpacePoint.cxx +++ b/Tracker/TrackerRecEvent/TrackerSpacePoint/src/FaserSCT_SpacePoint.cxx @@ -4,6 +4,8 @@ #include "TrkPrepRawData/PrepRawData.h" #include "TrackerSpacePoint/FaserSCT_SpacePoint.h" +#include "TrackerPrepRawData/FaserSCT_Cluster.h" +#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" #include "TrkEventPrimitives/LocalParameters.h" #include "TrkSurfaces/Surface.h" #include "EventPrimitives/EventPrimitivesToStringConverter.h" @@ -14,53 +16,123 @@ namespace Tracker //------------------------------------------------------------- FaserSCT_SpacePoint::FaserSCT_SpacePoint() - : - Trk::SpacePoint() {} //------------------------------------------------------------- + FaserSCT_SpacePoint::FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, + const Amg::Vector3D* position, + Amg::MatrixX* globalcov, + const Amg::Vector2D* localpos, + Amg::MatrixX* localcov, + const ElementLink<Tracker::FaserSCT_ClusterContainer>& link1, const ElementLink<Tracker::FaserSCT_ClusterContainer>& link2): m_elelink1(link1),m_elelink2(link2) + { + m_elemIdList.first = elementIdList.first ; + m_elemIdList.second = elementIdList.second ; + const FaserSCT_Cluster* clus1=link1.cachedElement(); + const FaserSCT_Cluster* clus2=link2.cachedElement(); + std::cout<<*clus1<<std::endl;; + std::cout<<clus1->identify()<<" "<<std::endl; + m_clusList.first = clus1; + m_clusList.second = clus2; + m_position = *position ; + m_globalCovariance = *globalcov; + m_localParams = Trk::LocalParameters(*localpos) ; + m_localCovariance = *localcov; + } + //------------------------------------------------------------- + + FaserSCT_SpacePoint::FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, + const Amg::Vector3D* position, + const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>* clusList) + { + setup(elementIdList,*position,clusList); + setupLocalCovarianceSCT(); + setupGlobalFromLocalCovariance(); + m_elelink1.setElement(clusList->first); + m_elelink2.setElement(clusList->second); +// delete position; + } + + //------------------------------------------------------------- + + FaserSCT_SpacePoint::FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, + const Amg::Vector3D* position, + const ElementLink<Tracker::FaserSCT_ClusterContainer>& link1, const ElementLink<Tracker::FaserSCT_ClusterContainer>& link2): m_elelink1(link1),m_elelink2(link2) + { + const FaserSCT_Cluster* clus1=link1.cachedElement(); + const FaserSCT_Cluster* clus2=link2.cachedElement(); + const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*> clusList(clus1,clus2); + setup(elementIdList,*position,&clusList); + setupLocalCovarianceSCT(); + setupGlobalFromLocalCovariance(); + delete position; + } + + //------------------------------------------------------------- + + FaserSCT_SpacePoint::FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, + const Amg::Vector3D* position, + const Amg::MatrixX* loccov, + const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>* clusList) + { + m_localCovariance = *loccov; + setup(elementIdList,*position,clusList); + setupGlobalFromLocalCovariance(); + m_elelink1.setElement(clusList->first); + m_elelink2.setElement(clusList->second); + delete loccov; + delete position; + } + FaserSCT_SpacePoint::FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, const Amg::Vector3D& position, - const std::pair<const Trk::PrepRawData*, const Trk::PrepRawData*>& clusList) - : - Trk::SpacePoint() + const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>* clusList) { setup(elementIdList,position,clusList); setupLocalCovarianceSCT(); setupGlobalFromLocalCovariance(); + m_elelink1.setElement(clusList->first); + m_elelink2.setElement(clusList->second); + } + + //------------------------------------------------------------- + + FaserSCT_SpacePoint::FaserSCT_SpacePoint(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, + const Amg::Vector3D& position, + const Amg::MatrixX& loccov, + const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>* clusList) + { + m_localCovariance = loccov; + setup(elementIdList,position,clusList); + setupGlobalFromLocalCovariance(); + m_elelink1.setElement(clusList->first); + m_elelink2.setElement(clusList->second); } + //------------------------------------------------------------- void FaserSCT_SpacePoint::setup(const std::pair<IdentifierHash, IdentifierHash>& elementIdList, const Amg::Vector3D& position, - const std::pair<const Trk::PrepRawData*, const Trk::PrepRawData*>& clusList) + const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*>* clusList) { - m_clusList = clusList; + m_clusList.first = clusList->first; + m_clusList.second = clusList->second; m_position = position ; m_elemIdList.first = elementIdList.first ; m_elemIdList.second = elementIdList.second ; - assert( (clusList.first!=0) && (clusList.second!=0) ); + assert( (clusList->first!=0) && (clusList->second!=0) ); assert(clusList->first->detectorElement()) ; - std::optional<Amg::Vector2D> locpos{ - clusList.first->detectorElement()->surface().globalToLocal(position) - }; + std::optional<Amg::Vector2D> locpos{ + clusList->first->detectorElement()->surface().globalToLocal(position)}; assert(locpos); - Trk::MeasurementBase::m_localParams = Trk::LocalParameters(*locpos ) ; + m_localParams = Trk::LocalParameters(*locpos ) ; } //------------------------------------------------------------- - FaserSCT_SpacePoint::FaserSCT_SpacePoint(const FaserSCT_SpacePoint &o) - : - Trk::SpacePoint(o) - { - } - - //------------------------------------------------------------- - //--------------------------------------------------------------- void FaserSCT_SpacePoint::setupLocalCovarianceSCT() @@ -77,7 +149,7 @@ namespace Tracker 1.*deltaY, 25.*deltaY, 25.*deltaY, 1600.*deltaY; - Trk::MeasurementBase::m_localCovariance = cov; + m_localCovariance = cov; } //------------------------------------------------------------- @@ -115,16 +187,41 @@ std::ostream& FaserSCT_SpacePoint::dump( std::ostream& out ) const return out; } - // ------------------------------------------------------------------ - - //assignment operator - FaserSCT_SpacePoint& FaserSCT_SpacePoint::operator=(const FaserSCT_SpacePoint& o) +// ------------------------------------------------------------------ + +//assignment operator +FaserSCT_SpacePoint& FaserSCT_SpacePoint::operator=(const FaserSCT_SpacePoint& o) +{ + if (&o !=this) { - if (&o !=this) - { - Trk::SpacePoint::operator=(o); - } - return *this; + FaserSCT_SpacePoint::operator=(o); } + return *this; +} + +/** set up the global covariance matrix by rotating the local one */ + +void FaserSCT_SpacePoint::setupGlobalFromLocalCovariance() +{ + const Amg::MatrixX& lc = this->localCovariance(); + + Amg::MatrixX cov(3,3); -} \ No newline at end of file + cov<< + lc(0,0),lc(0,1),0., + lc(1,0),lc(1,1),0., + // cppcheck-suppress constStatement + 0. ,0. ,0.; + + const Amg::RotationMatrix3D& R = associatedSurface().transform().rotation(); + m_globalCovariance = R*cov*R.transpose(); + +} + +const Trk::Surface& FaserSCT_SpacePoint::associatedSurface() const +{ + assert(m_clusList.first->detectorElement()); + return m_clusList.first->detectorElement()->surface(); +} + +} diff --git a/Tracker/TrackerRecEvent/TrackerSpacePoint/src/FaserSCT_SpacePointCollection.cxx b/Tracker/TrackerRecEvent/TrackerSpacePoint/src/FaserSCT_SpacePointCollection.cxx new file mode 100755 index 0000000000000000000000000000000000000000..63643d726fbbe3c1035bc6feb169404b0103fd74 --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerSpacePoint/src/FaserSCT_SpacePointCollection.cxx @@ -0,0 +1,78 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// SpacePointCollection.cxx +// Implementation file for class SpacePointCollection +/////////////////////////////////////////////////////////////////// +// (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// +// Version 1.0 14/10/2003 Veronique Boisvert +/////////////////////////////////////////////////////////////////// + +#include "TrackerSpacePoint/FaserSCT_SpacePointCollection.h" +#include "GaudiKernel/MsgStream.h" +// Constructor with parameters: +FaserSCT_SpacePointCollection::FaserSCT_SpacePointCollection(const IdentifierHash idHash) : + m_idHash(idHash), + m_id() +{} + +// Constructor with parameters: +FaserSCT_SpacePointCollection::FaserSCT_SpacePointCollection(const FaserSCT_SpacePointCollection& spc) : + DataVector< Tracker::FaserSCT_SpacePoint >( spc ), + m_idHash(), + m_id() +{ + // added this ctor as a temporary hack for HLT + // it should never be called. + throw FaserSCT_SpacePointCollectionCopyConstructorCalled(); +} + +// Destructor: +FaserSCT_SpacePointCollection::~FaserSCT_SpacePointCollection() +{ } + +Identifier FaserSCT_SpacePointCollection::identify() const +{ + return m_id; +} + +IdentifierHash FaserSCT_SpacePointCollection::identifyHash() const +{ + return m_idHash; +} + +void FaserSCT_SpacePointCollection::setIdentifier(Identifier id) +{ + m_id = id; +} + +std::string FaserSCT_SpacePointCollection::type() const +{ + return "FaserSCT_SpacePointCollection"; +} +/**Overload of << operator for MsgStream for debug output*/ +MsgStream& operator << ( MsgStream& sl, const FaserSCT_SpacePointCollection& coll) { + sl << "FaserSCT_SpacePointCollection: " + << "identify()="<< coll.identify() + << ", SP=["; + FaserSCT_SpacePointCollection::const_iterator it = coll.begin(); + FaserSCT_SpacePointCollection::const_iterator itEnd = coll.end(); + for (;it!=itEnd;++it) { sl<< (**it)<<", ";} + sl <<" ]"<<std::endl; + return sl; +} + +/**Overload of << operator for std::ostream for debug output*/ +std::ostream& operator << ( std::ostream& sl, const FaserSCT_SpacePointCollection& coll) { + sl << "FaserSCT_SpacePointCollection: " + << "identify()="<< coll.identify() + << ", SP=["; + FaserSCT_SpacePointCollection::const_iterator it = coll.begin(); + FaserSCT_SpacePointCollection::const_iterator itEnd = coll.end(); + for (;it!=itEnd;++it) { sl<< (**it)<<", ";} + sl <<" ]"<<std::endl; + return sl; +} diff --git a/Tracker/TrackerRecEvent/TrackerSpacePoint/src/FaserSCT_SpacePointContainer.cxx b/Tracker/TrackerRecEvent/TrackerSpacePoint/src/FaserSCT_SpacePointContainer.cxx new file mode 100755 index 0000000000000000000000000000000000000000..a67f15d794562b4a2344e66100264777c02a245f --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerSpacePoint/src/FaserSCT_SpacePointContainer.cxx @@ -0,0 +1,34 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// SpacePointContainer.cxx +// Implementation file for class SpacePointContainer +/////////////////////////////////////////////////////////////////// +// (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// +// Version 1.0 14/10/2003 Veronique Boisvert +/////////////////////////////////////////////////////////////////// + +#include "TrackerSpacePoint/FaserSCT_SpacePointContainer.h" + +// Constructor with parameters: +FaserSCT_SpacePointContainer::FaserSCT_SpacePointContainer(unsigned int max) : + IdentifiableContainer<FaserSCT_SpacePointCollection>(max) +{ +} + +// Constructor with parameters: +FaserSCT_SpacePointContainer::FaserSCT_SpacePointContainer(FaserSCT_SpacePointCache *cache) : + IdentifiableContainer<FaserSCT_SpacePointCollection>(cache) +{ +} + +// Destructor: +FaserSCT_SpacePointContainer::~FaserSCT_SpacePointContainer() +{ + +} + + diff --git a/Tracker/TrackerRecEvent/TrackerSpacePoint/src/FaserSCT_SpacePointOverlapCollection.cxx b/Tracker/TrackerRecEvent/TrackerSpacePoint/src/FaserSCT_SpacePointOverlapCollection.cxx new file mode 100755 index 0000000000000000000000000000000000000000..aa875eb14851eb71a5cb0b2789c53678bfbc7359 --- /dev/null +++ b/Tracker/TrackerRecEvent/TrackerSpacePoint/src/FaserSCT_SpacePointOverlapCollection.cxx @@ -0,0 +1,23 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// SpacePointOverlapCollection.cxx +// Implementation file for class SpacePointOverlapCollection +/////////////////////////////////////////////////////////////////// +// (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// +// Version 1.0 14/10/2003 Veronique Boisvert +/////////////////////////////////////////////////////////////////// + +#include "TrackerSpacePoint/FaserSCT_SpacePointOverlapCollection.h" +// Constructor with parameters: +FaserSCT_SpacePointOverlapCollection::FaserSCT_SpacePointOverlapCollection() + +{} + +// Destructor: +FaserSCT_SpacePointOverlapCollection::~FaserSCT_SpacePointOverlapCollection() +{ } + diff --git a/Tracker/TrackerRecEvent/TrackerPrepRawData/src/TrackerSeed.cxx b/Tracker/TrackerRecEvent/TrackerSpacePoint/src/TrackerSeed.cxx similarity index 80% rename from Tracker/TrackerRecEvent/TrackerPrepRawData/src/TrackerSeed.cxx rename to Tracker/TrackerRecEvent/TrackerSpacePoint/src/TrackerSeed.cxx index bd217ec892f499994db0f6eb5d557669357a6ef7..2e0f255193cc27af7b4f7b1ba76f36154f1d1faf 100755 --- a/Tracker/TrackerRecEvent/TrackerPrepRawData/src/TrackerSeed.cxx +++ b/Tracker/TrackerRecEvent/TrackerSpacePoint/src/TrackerSeed.cxx @@ -1,4 +1,4 @@ -#include "TrackerPrepRawData/TrackerSeed.h" +#include "TrackerSpacePoint/TrackerSeed.h" namespace Tracker { @@ -8,9 +8,9 @@ namespace Tracker { TrackerSeed::~TrackerSeed() {} - TrackerSeed::TrackerSeed(const StrategyId id, vector<const Trk::SpacePoint*> seed) { m_strategyId = id; m_seed = seed; } + TrackerSeed::TrackerSeed(const StrategyId id, vector<const FaserSCT_SpacePoint*> seed) { m_strategyId = id; m_seed = seed; } - void TrackerSeed::add(vector<const Trk::SpacePoint*> seed) { m_seed = seed; } + void TrackerSeed::add(vector<const FaserSCT_SpacePoint*> seed) { m_seed = seed; } int TrackerSeed::size() const { return m_seed.size(); } diff --git a/Tracker/TrackerRecTools/FaserSiSpacePointTool/FaserSiSpacePointTool/FaserSCTinformation.h b/Tracker/TrackerRecTools/FaserSiSpacePointTool/FaserSiSpacePointTool/FaserSCTinformation.h index dccb140241e894b4cf21788acd05b98f040462cf..dc825852fcb0304839c2a3df703b54fce587d765 100644 --- a/Tracker/TrackerRecTools/FaserSiSpacePointTool/FaserSiSpacePointTool/FaserSCTinformation.h +++ b/Tracker/TrackerRecTools/FaserSiSpacePointTool/FaserSiSpacePointTool/FaserSCTinformation.h @@ -19,7 +19,7 @@ #define FaserSCTinformation_h -class TrackerCluster; +class FaserSCT_Cluster; namespace Tracker { @@ -31,13 +31,13 @@ namespace Tracker public: - FaserSCTinformation(const Tracker::TrackerCluster* CL, const Amg::Vector3D& a, const Amg::Vector3D& b, const Amg::Vector3D& vec); + FaserSCTinformation(const Tracker::FaserSCT_Cluster* CL, const Amg::Vector3D& a, const Amg::Vector3D& b, const Amg::Vector3D& vec); FaserSCTinformation(const FaserSCTinformation&) = default; virtual ~FaserSCTinformation() = default; FaserSCTinformation& operator = (const FaserSCTinformation&) = default; - const Tracker::TrackerCluster* cluster() const; + const Tracker::FaserSCT_Cluster* cluster() const; const Amg::Vector3D& a() const; const Amg::Vector3D& q() const; const Amg::Vector3D& s() const; @@ -49,7 +49,7 @@ namespace Tracker private: - const Tracker::TrackerCluster* m_CL; + const Tracker::FaserSCT_Cluster* m_CL; Amg::Vector3D m_A; Amg::Vector3D m_Q; Amg::Vector3D m_S; @@ -67,7 +67,7 @@ namespace Tracker ///////////////////////////////////////////////////////////////////////////////// inline FaserSCTinformation::FaserSCTinformation - (const Tracker::TrackerCluster* CL, const Amg::Vector3D& a, const Amg::Vector3D& b, const Amg::Vector3D& vec) + (const Tracker::FaserSCT_Cluster* CL, const Amg::Vector3D& a, const Amg::Vector3D& b, const Amg::Vector3D& vec) { m_CL = CL ; m_A = 0.5*(a+b) ; // Center of strip @@ -80,7 +80,7 @@ namespace Tracker ///////////////////////////////////////////////////////////////////////////////// // Getter methods ///////////////////////////////////////////////////////////////////////////////// - inline const Tracker::TrackerCluster* FaserSCTinformation::cluster() const + inline const Tracker::FaserSCT_Cluster* FaserSCTinformation::cluster() const { return m_CL; } diff --git a/Tracker/TrackerRecTools/FaserSiSpacePointTool/FaserSiSpacePointTool/TrackerSpacePointMakerTool.h b/Tracker/TrackerRecTools/FaserSiSpacePointTool/FaserSiSpacePointTool/TrackerSpacePointMakerTool.h index d6245810e9e61a9614a5044855b6c425b5c5b05a..aac1d65775356b508461468ab380593c47beb53f 100644 --- a/Tracker/TrackerRecTools/FaserSiSpacePointTool/FaserSiSpacePointTool/TrackerSpacePointMakerTool.h +++ b/Tracker/TrackerRecTools/FaserSiSpacePointTool/FaserSiSpacePointTool/TrackerSpacePointMakerTool.h @@ -11,21 +11,21 @@ #include "GeoPrimitives/GeoPrimitives.h" #include "TrackerPrepRawData/FaserSCT_ClusterCollection.h" #include "FaserSiSpacePointTool/FaserSCTinformation.h" -#include "TrkSpacePoint/SpacePoint.h" +#include "TrackerSpacePoint/FaserSCT_SpacePoint.h" #include <mutex> #include <string> class FaserSCT_ID; -class SpacePointCollection; -class SpacePointOverlapCollection; +class FaserSCT_SpacePointCollection; +class FaserSCT_SpacePointOverlapCollection; namespace TrackerDD { class SiDetectorElementCollection; class SiDetectorElement; } namespace Tracker { - class TrackerCluster; + class FaserSCT_Cluster; } @@ -60,7 +60,7 @@ namespace Tracker void newEvent() const; /// Convert clusters to space points: SCT_Clusters -> SCT_SpacePoints - Trk::SpacePoint* makeSCT_SpacePoint(const TrackerCluster& cluster1, const TrackerCluster& cluster2, + FaserSCT_SpacePoint* makeSCT_SpacePoint(const FaserSCT_Cluster& cluster1, const FaserSCT_Cluster& cluster2, const Amg::Vector3D& vertexVec, const TrackerDD::SiDetectorElement* element1, const TrackerDD::SiDetectorElement* element2, double stripLengthGapTolerance) const; @@ -68,21 +68,21 @@ namespace Tracker void fillSCT_SpacePointCollection(const FaserSCT_ClusterCollection* clusters1, const FaserSCT_ClusterCollection* clusters2, double min, double max, bool allClusters, const Amg::Vector3D& vertexVec, const TrackerDD::SiDetectorElementCollection* elements, - SpacePointCollection* spacepointCollection) const; + FaserSCT_SpacePointCollection* spacepointCollection) const; /// Convert clusters to space points using eta direction overlaps: SCT_Clusters -> OverlapSpacePoints void fillSCT_SpacePointEtaOverlapCollection(const FaserSCT_ClusterCollection* clusters1, const FaserSCT_ClusterCollection* clusters2, double min, double max, bool allClusters, const Amg::Vector3D& vertexVec, const TrackerDD::SiDetectorElementCollection* elements, - SpacePointOverlapCollection* spacepointOverlapCollection) const; + FaserSCT_SpacePointOverlapCollection* spacepointOverlapCollection) const; /// Convert clusters to space points using phi direction overlaps: SCT_Clusters -> OverlapSpacePoints void fillSCT_SpacePointPhiOverlapCollection(const FaserSCT_ClusterCollection* clusters1, const FaserSCT_ClusterCollection* clusters2, double min1, double max1, double min2, double max2, bool allClusters, const Amg::Vector3D& vertexVec , const TrackerDD::SiDetectorElementCollection* elements, - SpacePointOverlapCollection* spacepointOverlapCollection) const; + FaserSCT_SpacePointOverlapCollection* spacepointOverlapCollection) const; private: /// @name Cut parameters @@ -110,7 +110,7 @@ namespace Tracker /// To hold event dependent data struct CacheEntry { EventContext::ContextEvt_t m_evt{EventContext::INVALID_CONTEXT_EVT}; //!< Event number, slot number, used to check if already processed event or not. - std::vector<Trk::SpacePoint*> m_tmpSpacePoints{}; //!< SpacePoint cache + std::vector<FaserSCT_SpacePoint*> m_tmpSpacePoints{}; //!< SpacePoint cache std::vector<FaserSCTinformation> m_SCT0{}; //!< SCTinformation vector for 0-th element (side 0) std::vector<FaserSCTinformation> m_SCT1{}; //!< SCTinformation vector for 1-st element (side 1) const TrackerDD::SiDetectorElement* m_element0{nullptr}; //!< SiDetectorElement for 0-th element (side 0) @@ -119,7 +119,7 @@ namespace Tracker /// Clear all members of event dependent data void clear() { if (m_tmpSpacePoints.size()) { - for (Trk::SpacePoint* sp : m_tmpSpacePoints) { + for (FaserSCT_SpacePoint* sp : m_tmpSpacePoints) { delete sp; } } diff --git a/Tracker/TrackerRecTools/FaserSiSpacePointTool/src/TrackerSpacePointMakerTool.cxx b/Tracker/TrackerRecTools/FaserSiSpacePointTool/src/TrackerSpacePointMakerTool.cxx index d04d721c7a748433d02087fc9ac981e46eeb205d..814fc31a5b82c9705472a283ba8abfd074ed067b 100644 --- a/Tracker/TrackerRecTools/FaserSiSpacePointTool/src/TrackerSpacePointMakerTool.cxx +++ b/Tracker/TrackerRecTools/FaserSiSpacePointTool/src/TrackerSpacePointMakerTool.cxx @@ -5,8 +5,8 @@ #include "FaserSiSpacePointTool/TrackerSpacePointMakerTool.h" // Cluster and space point collections -#include "TrkSpacePoint/SpacePointCollection.h" -#include "TrkSpacePoint/SpacePointOverlapCollection.h" +#include "TrackerSpacePoint/FaserSCT_SpacePointCollection.h" +#include "TrackerSpacePoint/FaserSCT_SpacePointOverlapCollection.h" // For processing clusters #include "TrackerIdentifier/FaserSCT_ID.h" @@ -59,8 +59,8 @@ void TrackerSpacePointMakerTool::newEvent() const { } } //-------------------------------------------------------------------------- -Trk::SpacePoint* TrackerSpacePointMakerTool::makeSCT_SpacePoint(const Tracker::TrackerCluster& cluster1, - const Tracker::TrackerCluster& cluster2, +FaserSCT_SpacePoint* TrackerSpacePointMakerTool::makeSCT_SpacePoint(const Tracker::FaserSCT_Cluster& cluster1, + const Tracker::FaserSCT_Cluster& cluster2, const Amg::Vector3D& vertexVec, const TrackerDD::SiDetectorElement* element1, const TrackerDD::SiDetectorElement* element2, @@ -184,8 +184,8 @@ Trk::SpacePoint* TrackerSpacePointMakerTool::makeSCT_SpacePoint(const Tracker::T if (ok) { ATH_MSG_VERBOSE( "SpacePoint generated at: ( " << point.x() << " , " << point.y() << " , " << point.z() << " ) " ); std::pair<IdentifierHash,IdentifierHash> elementIdList( element1->identifyHash() , element2->identifyHash() ); - std::pair<const Trk::PrepRawData*, const Trk::PrepRawData*> clusList {&cluster1, &cluster2 }; - return new FaserSCT_SpacePoint(elementIdList, point, clusList); + std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*> clusList {&cluster1, &cluster2 }; + return new FaserSCT_SpacePoint(elementIdList, point, &clusList); } return nullptr; @@ -197,7 +197,7 @@ void TrackerSpacePointMakerTool::fillSCT_SpacePointCollection(const Tracker::Fas double min, double max, bool allClusters, const Amg::Vector3D& vertexVec, const TrackerDD::SiDetectorElementCollection* elements, - SpacePointCollection* spacepointCollection) const { + FaserSCT_SpacePointCollection* spacepointCollection) const { double stripLengthGapTolerance = 0.; // Try all combinations of clusters for space points @@ -217,7 +217,7 @@ void TrackerSpacePointMakerTool::fillSCT_SpacePointCollection(const Tracker::Fas } //tmpSpacePoints changed to local variable to enable rentrancy - std::vector<Trk::SpacePoint*> tmpSpacePoints; + std::vector<FaserSCT_SpacePoint*> tmpSpacePoints; for (; clusters1Next!=clusters1Finish; ++clusters1Next){ Amg::Vector2D locpos = (*clusters1Next)->localPosition(); @@ -248,7 +248,7 @@ void TrackerSpacePointMakerTool::fillSCT_SpacePointCollection(const Tracker::Fas Amg::Vector2D localPos = Amg::Vector2D(locpos[0], locpos[1]); double diff = TrackerDD::SiLocalPosition(localPos.y(), localPos.x(), 0.).xPhi() - xPhi1; if (((min <= diff) and (diff <= max)) or allClusters) { - Trk::SpacePoint* sp = + FaserSCT_SpacePoint* sp = makeSCT_SpacePoint(**clusters1Next, **clusters2Next, vertexVec, element1, element2, stripLengthGapTolerance); if (sp) { tmpSpacePoints.push_back(sp); @@ -258,7 +258,7 @@ void TrackerSpacePointMakerTool::fillSCT_SpacePointCollection(const Tracker::Fas } spacepointCollection->reserve(spacepointCollection->size() + tmpSpacePoints.size()); - for (Trk::SpacePoint* sp: tmpSpacePoints) { + for (FaserSCT_SpacePoint* sp: tmpSpacePoints) { spacepointCollection->push_back(sp); } } @@ -271,7 +271,7 @@ void TrackerSpacePointMakerTool::fillSCT_SpacePointEtaOverlapCollection(const Tr double min, double max, bool allClusters, const Amg::Vector3D& vertexVec, const TrackerDD::SiDetectorElementCollection* elements, - SpacePointOverlapCollection* spacepointoverlapCollection) const { + FaserSCT_SpacePointOverlapCollection* spacepointoverlapCollection) const { double stripLengthGapTolerance = 0.; @@ -318,7 +318,7 @@ void TrackerSpacePointMakerTool::fillSCT_SpacePointEtaOverlapCollection(const Tr Amg::Vector2D localPos = Amg::Vector2D(locpos[0], locpos[1]); double diff = TrackerDD::SiLocalPosition(localPos.y(), localPos.x(), 0.).xPhi() - xPhi1; if (((min <= diff) and (diff <= max)) or allClusters){ - Trk::SpacePoint* sp = + FaserSCT_SpacePoint* sp = makeSCT_SpacePoint(**clusters1Next, **clusters2Next, vertexVec, element1, element2, stripLengthGapTolerance); if (sp) { spacepointoverlapCollection->push_back(sp); @@ -337,7 +337,7 @@ void TrackerSpacePointMakerTool::fillSCT_SpacePointPhiOverlapCollection(const Tr bool allClusters, const Amg::Vector3D& vertexVec, const TrackerDD::SiDetectorElementCollection* elements, - SpacePointOverlapCollection* spacepointoverlapCollection) const { + FaserSCT_SpacePointOverlapCollection* spacepointoverlapCollection) const { double stripLengthGapTolerance = 0.; if (m_SCTgapParameter != 0.) { @@ -390,7 +390,7 @@ void TrackerSpacePointMakerTool::fillSCT_SpacePointPhiOverlapCollection(const Tr Amg::Vector2D localPos = Amg::Vector2D(locpos[0], locpos[1]); double xPhi2 = TrackerDD::SiLocalPosition(localPos.y(), localPos.x(), 0.).xPhi(); if (((min2<= xPhi2) and (xPhi2 <= max2)) or allClusters) { - Trk::SpacePoint* sp = + FaserSCT_SpacePoint* sp = makeSCT_SpacePoint(**clusters1Next, **clusters2Next, vertexVec, element1, element2, stripLengthGapTolerance); if (sp) { spacepointoverlapCollection->push_back(sp); @@ -475,7 +475,7 @@ void TrackerSpacePointMakerTool::makeSCT_SpacePoints(const double stripLengthGap ent->m_evt = ctx.evt(); } else { if (ent->m_tmpSpacePoints.size()) { - for (Trk::SpacePoint* sp : ent->m_tmpSpacePoints) { + for (FaserSCT_SpacePoint* sp : ent->m_tmpSpacePoints) { delete sp; } } @@ -530,10 +530,10 @@ void TrackerSpacePointMakerTool::makeSCT_SpacePoints(const double stripLengthGap ATH_MSG_VERBOSE("SpacePoint generated at: ( " << point.x() << " , " << point.y() << " , " << point.z() << " ) "); const std::pair<IdentifierHash, IdentifierHash> elementIdList(ent->m_element0->identifyHash(), ent->m_element1->identifyHash()); - const std::pair<const Trk::PrepRawData*, const Trk::PrepRawData*> clusList {(*I).cluster(), (*J).cluster()}; - ent->m_tmpSpacePoints.push_back(new FaserSCT_SpacePoint(elementIdList, point, clusList)); + const std::pair<const FaserSCT_Cluster*, const FaserSCT_Cluster*> clusList {(*I).cluster(), (*J).cluster()}; + ent->m_tmpSpacePoints.push_back(new FaserSCT_SpacePoint(elementIdList, point, &clusList)); } } } -} \ No newline at end of file +} diff --git a/Tracker/TrackerSimEvent/src/SiCharge.cxx b/Tracker/TrackerSimEvent/src/SiCharge.cxx index f24f342adb044ab4f6c79708207efff3b7193f2b..7d089dc004420ab9759be31c3f2bf3e90738c752 100644 --- a/Tracker/TrackerSimEvent/src/SiCharge.cxx +++ b/Tracker/TrackerSimEvent/src/SiCharge.cxx @@ -35,7 +35,7 @@ SiCharge::SiCharge(const double& charge,const double& time, m_charge(charge), m_time(time), m_processType(processType), - m_partLink(HepMcParticleLink((unsigned int) 0, 0)) + m_partLink(HepMcParticleLink()) {} diff --git a/Tracker/TrackerSimEvent/src/SiTotalCharge.cxx b/Tracker/TrackerSimEvent/src/SiTotalCharge.cxx index 2d17b4d1144e899f7d098bb3657f2d27ab669b98..f04abd9f70130ca4d77cf6293d9bf94c86ebecbb 100644 --- a/Tracker/TrackerSimEvent/src/SiTotalCharge.cxx +++ b/Tracker/TrackerSimEvent/src/SiTotalCharge.cxx @@ -18,14 +18,14 @@ SiTotalCharge::SiTotalCharge(const alloc_t& alloc) : m_charge(0), m_chargeComposition(alloc), - m_emptyLink((unsigned int) 0, 0) + m_emptyLink() {} // Copy constructor: SiTotalCharge::SiTotalCharge(const SiTotalCharge &totalCharge) : m_charge(totalCharge.m_charge), m_chargeComposition(totalCharge.m_chargeComposition), - m_emptyLink((unsigned int) 0, 0) + m_emptyLink() {} // Assignment operator: diff --git a/Tracking/Acts/FaserActsGeometry/CMakeLists.txt b/Tracking/Acts/FaserActsGeometry/CMakeLists.txt index bd4c0658954dc8c5e1fb0adde80e36c2e2b0583d..a121316e188cc27c35f3d90f9a81b569089b9d19 100755 --- a/Tracking/Acts/FaserActsGeometry/CMakeLists.txt +++ b/Tracking/Acts/FaserActsGeometry/CMakeLists.txt @@ -17,7 +17,7 @@ atlas_add_library( FaserActsGeometryLib src/FaserActsDetectorElement.cxx src/FaserActsLayerBuilder.cxx src/CuboidVolumeBuilder.cxx - src/FaserActsJsonGeometryConverter.cxx +# src/FaserActsJsonGeometryConverter.cxx src/util/*.cxx PUBLIC_HEADERS FaserActsGeometry INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} ${BOOST_INCLUDE_DIRS} @@ -51,8 +51,8 @@ atlas_add_component( FaserActsGeometry ##src/*.cxx src/FaserActsSurfaceMappingTool.cxx src/FaserActsMaterialMapping.cxx - src/FaserActsMaterialJsonWriterTool.cxx - src/FaserActsJsonGeometryConverter.cxx +# src/FaserActsMaterialJsonWriterTool.cxx +# src/FaserActsJsonGeometryConverter.cxx src/FaserActsTrackingGeometrySvc.cxx src/FaserActsTrackingGeometryTool.cxx src/FaserActsWriteTrackingGeometry.cxx diff --git a/Tracking/Acts/FaserActsGeometry/python/FaserActsMaterialMapping_jobOptions.py b/Tracking/Acts/FaserActsGeometry/python/FaserActsMaterialMapping_jobOptions.py index feb3b04d2f978297bfcbea4229d0ff35862d5aee..6466848fb515373c2b33bd8c0978d4f162e053bb 100644 --- a/Tracking/Acts/FaserActsGeometry/python/FaserActsMaterialMapping_jobOptions.py +++ b/Tracking/Acts/FaserActsGeometry/python/FaserActsMaterialMapping_jobOptions.py @@ -18,7 +18,7 @@ from FaserActsGeometry.ActsGeometryConfig import ActsMaterialStepConverterToolCf from FaserActsGeometry.ActsGeometryConfig import ActsSurfaceMappingToolCfg, ActsVolumeMappingToolCfg from FaserActsGeometry.ActsGeometryConfig import ActsMaterialJsonWriterToolCfg -from FaserActsGeometry.ActsGeometryConfig import ActsAlignmentCondAlgCfg +#from FaserActsGeometry.ActsGeometryConfig import ActsAlignmentCondAlgCfg from FaserGeoModel.FaserGeoModelConfig import FaserGeometryCfg def ActsMaterialMappingCfg(configFlags, name = "FaserActsMaterialMapping", **kwargs): @@ -52,7 +52,7 @@ def ActsMaterialMappingCfg(configFlags, name = "FaserActsMaterialMapping", **kwa if "__main__" == __name__: from AthenaCommon.Configurable import Configurable from AthenaCommon.Logging import log - from AthenaCommon.Constants import VERBOSE, INFO + from AthenaCommon.Constants import INFO from CalypsoConfiguration.AllConfigFlags import ConfigFlags from CalypsoConfiguration.MainServicesConfig import MainServicesCfg from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg diff --git a/Tracking/Acts/FaserActsGeometry/src/components/FaserActsGeometry_entries.cxx b/Tracking/Acts/FaserActsGeometry/src/components/FaserActsGeometry_entries.cxx index 9be7649a9397fa25de520848ede7ecad3bcc4cc7..7beb0342f184a3c72a4fa4c154fdc00cc5bd9522 100755 --- a/Tracking/Acts/FaserActsGeometry/src/components/FaserActsGeometry_entries.cxx +++ b/Tracking/Acts/FaserActsGeometry/src/components/FaserActsGeometry_entries.cxx @@ -17,7 +17,7 @@ //#include "FaserActsGeometry/GeomShiftCondAlg.h" //#include "FaserActsGeometry/FaserActsWriteTrackingGeometryTransforms.h" #include "FaserActsGeometry/FaserActsVolumeMappingTool.h" -#include "FaserActsGeometry/FaserActsMaterialJsonWriterTool.h" +//#include "FaserActsGeometry/FaserActsMaterialJsonWriterTool.h" #include "FaserActsGeometry/FaserActsMaterialMapping.h" #include "FaserActsGeometry/FaserActsSurfaceMappingTool.h" @@ -36,6 +36,6 @@ DECLARE_COMPONENT( FaserActsAlignmentCondAlg ) //DECLARE_COMPONENT( FaserActsWriteTrackingGeometryTransforms ) //DECLARE_COMPONENT( FaserGeomShiftCondAlg ) DECLARE_COMPONENT( FaserActsVolumeMappingTool ) -DECLARE_COMPONENT( FaserActsMaterialJsonWriterTool ) +//DECLARE_COMPONENT( FaserActsMaterialJsonWriterTool ) DECLARE_COMPONENT( FaserActsMaterialMapping ) DECLARE_COMPONENT( FaserActsSurfaceMappingTool ) diff --git a/Tracking/Acts/FaserActsKalmanFilter/CMakeLists.txt b/Tracking/Acts/FaserActsKalmanFilter/CMakeLists.txt index 2feb67193700e480376545dd8d14d05d22c71b83..21e5ed799d3caeaf33d4fc85102b9be48e18e599 100755 --- a/Tracking/Acts/FaserActsKalmanFilter/CMakeLists.txt +++ b/Tracking/Acts/FaserActsKalmanFilter/CMakeLists.txt @@ -22,10 +22,24 @@ atlas_add_library( FaserActsKalmanFilterLib ) atlas_add_component(FaserActsKalmanFilter - src/*.cxx - src/components/*.cxx - FaserActsKalmanFilter/*.h - FaserActsKalmanFilter/src/*.cxx + FaserActsKalmanFilter/CombinatorialKalmanFilterAlg.h + FaserActsKalmanFilter/FaserActsGeometryContainers.h + FaserActsKalmanFilter/FaserActsRecMultiTrajectory.h + FaserActsKalmanFilter/IndexSourceLink.h + FaserActsKalmanFilter/Measurement.h + FaserActsKalmanFilter/SimWriterTool.h + FaserActsKalmanFilter/SPSeedBasedInitialParameterTool.h + FaserActsKalmanFilter/SPSimpleInitialParameterTool.h + FaserActsKalmanFilter/TrajectoryWriterTool.h + FaserActsKalmanFilter/TruthBasedInitialParameterTool.h + src/CombinatorialKalmbanFilterAlg.cxx + src/SimWriterTool.cxx + src/SPSeedBasedInitialParameterTool.cxx + src/SPSimpleInitialParameterTool.cxx + src/TrackFindingAlgorithmFunction.cxx + src/TrajectoryWriterTool.cxx + src/TruthBasedInitialParameterTool.cxx + src/components/FaserActsKalmanFilter_entries.cxx PUBLIC_HEADERS FaserActsKalmanFilter INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} ${BOOST_INCLUDE_DIRS} LINK_LIBRARIES ${CLHEP_LIBRARIES} ${EIGEN_LIBRARIES} @@ -39,7 +53,10 @@ atlas_add_component(FaserActsKalmanFilter MagFieldElements MagFieldConditions TrkPrepRawData + TrkTrack TrackerPrepRawData + TrackerRIO_OnTrack + TrkRIO_OnTrack TrackerSpacePoint GeoModelFaserUtilities GeneratorObjects @@ -47,6 +64,7 @@ atlas_add_component(FaserActsKalmanFilter TrackerReadoutGeometry Identifier TrackerSimData + TrackerSeedFinderLib ) # Install files from the package: diff --git a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/.__afsCDFD b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/.__afsCDFD new file mode 100644 index 0000000000000000000000000000000000000000..c066165b27f5fabec539af3ca012c6ab0585c276 --- /dev/null +++ b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/.__afsCDFD @@ -0,0 +1,71 @@ +#ifndef COMBINATORIALKALMANFILTERALG_H +#define COMBINATORIALKALMANFILTERALG_H + +#include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "TrackerSpacePoint/FaserSCT_SpacePointContainer.h" +#include "FaserActsGeometryInterfaces/IFaserActsTrackingGeometryTool.h" +#include "FaserActsKalmanFilter/TruthBasedInitialParameterTool.h" +#include "FaserActsKalmanFilter/SPSimpleInitialParameterTool.h" +#include "FaserActsKalmanFilter/SPSeedBasedInitialParameterTool.h" +#include "Acts/TrackFinding/CombinatorialKalmanFilter.hpp" +#include "Acts/TrackFinding/MeasurementSelector.hpp" +#include "FaserActsKalmanFilter/Measurement.h" +#include "MagFieldConditions/FaserFieldCacheCondObj.h" +#include "FaserActsKalmanFilter/TrajectoryWriterTool.h" +#include "TrkTrack/TrackCollection.h" + +class FaserSCT_ID; + +namespace Trk +{ +class TrackStateOnSurface; +} + +namespace TrackerDD { + class SCT_DetectorManager; +} + +class CombinatorialKalmanFilterAlg : public AthReentrantAlgorithm { + public: + CombinatorialKalmanFilterAlg(const std::string& name, ISvcLocator* pSvcLocator); + virtual ~CombinatorialKalmanFilterAlg() = default; + + StatusCode initialize() override; + StatusCode execute(const EventContext& ctx) const override; + StatusCode finalize() override; + + using TrackFinderOptions = + Acts::CombinatorialKalmanFilterOptions<IndexSourceLinkAccessor, MeasurementCalibrator, Acts::MeasurementSelector>; + using FitterResult = Acts::Result<Acts::CombinatorialKalmanFilterResult<IndexSourceLink>>; + using TrackFinderResult = std::vector<FitterResult>; +// using TrackFinderResult = std::vector< +// Acts::Result<Acts::CombinatorialKalmanFilterResult<IndexSourceLink>>>; + using TrackFinderFunction = std::function<TrackFinderResult( + const IndexSourceLinkContainer&, const std::vector<Acts::CurvilinearTrackParameters>&, + const TrackFinderOptions&)>; + + static TrackFinderFunction makeTrackFinderFunction( + std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry); + + Acts::MagneticFieldContext getMagneticFieldContext(const EventContext& ctx) const; + + + private: + const FaserSCT_ID* m_idHelper{nullptr}; + const TrackerDD::SCT_DetectorManager* m_detManager{nullptr}; + + std::unique_ptr<Trk::Track> makeTrack(Acts::GeometryContext& tgContext, FitterResult& fitResult, std::vector<Tracker::FaserSCT_SpacePoint> seed_spcollection) const; + const Trk::TrackParameters* ConvertActsTrackParameterToATLAS(const Acts::BoundTrackParameters &actsParameter, const Acts::GeometryContext& gctx) const; + + SG::WriteHandleKey<TrackCollection> m_trackCollection { this, "FaserActsCKFTrackCollection", "FaserActsCKFTrackCollection", "Output trackcollectionname" }; + + ToolHandle<IFaserActsTrackingGeometryTool> m_trackingGeometryTool{this, "TrackingGeometryTool", "FaserActsTrackingGeometryTool"}; + ToolHandle<SPSeedBaseInitialParameterTool> m_initialParameterTool{this, "InitialParameterTool", "SPSeedBaseInitialParameterTool"}; + //ToolHandle<SPSimpleInitialParameterTool> m_initialParameterTool{this, "InitialParameterTool", "SPSimpleInitialParameterTool"}; + //ToolHandle<TruthBasedInitialParameterTool> m_initialParameterTool{this, "InitialParameterTool", "TruthBasedInitialParameterTool"}; + ToolHandle<TrajectoryWriterTool> m_trajectoryWriterTool{this, "OutputTool", "TrajectoryWriterTool"}; + SG::ReadCondHandleKey<FaserFieldCacheCondObj> m_fieldCondObjInputKey {this, "FaserFieldCacheCondObj", "fieldCondObj", "Name of the Magnetic Field conditions object key"}; + SG::ReadHandleKey<FaserSCT_SpacePointContainer> m_SpacePointContainerKey{this, "SpacePointsSCTName", "SCT_SpacePointContainer", "SCT space point container"}; +}; + +#endif // COMBINATORIALKALMANFILTERALG_H diff --git a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/CombinatorialKalmanFilterAlg.h b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/CombinatorialKalmanFilterAlg.h index 3d147019b115c7d7f6818bb06c7aef1c65c6bfec..4b750614a3f496a9cabef0352c223d9b9e5a9658 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/CombinatorialKalmanFilterAlg.h +++ b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/CombinatorialKalmanFilterAlg.h @@ -2,15 +2,29 @@ #define COMBINATORIALKALMANFILTERALG_H #include "AthenaBaseComps/AthReentrantAlgorithm.h" -#include "TrkSpacePoint/SpacePointContainer.h" +#include "TrackerSpacePoint/FaserSCT_SpacePointContainer.h" +#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" #include "FaserActsGeometryInterfaces/IFaserActsTrackingGeometryTool.h" #include "FaserActsKalmanFilter/TruthBasedInitialParameterTool.h" +#include "FaserActsKalmanFilter/SPSimpleInitialParameterTool.h" +#include "FaserActsKalmanFilter/SPSeedBasedInitialParameterTool.h" #include "Acts/TrackFinding/CombinatorialKalmanFilter.hpp" #include "Acts/TrackFinding/MeasurementSelector.hpp" #include "FaserActsKalmanFilter/Measurement.h" #include "MagFieldConditions/FaserFieldCacheCondObj.h" #include "FaserActsKalmanFilter/TrajectoryWriterTool.h" +#include "TrkTrack/TrackCollection.h" +class FaserSCT_ID; + +namespace Trk +{ +class TrackStateOnSurface; +} + +namespace TrackerDD { + class SCT_DetectorManager; +} class CombinatorialKalmanFilterAlg : public AthReentrantAlgorithm { public: @@ -23,8 +37,10 @@ class CombinatorialKalmanFilterAlg : public AthReentrantAlgorithm { using TrackFinderOptions = Acts::CombinatorialKalmanFilterOptions<IndexSourceLinkAccessor, MeasurementCalibrator, Acts::MeasurementSelector>; - using TrackFinderResult = std::vector< - Acts::Result<Acts::CombinatorialKalmanFilterResult<IndexSourceLink>>>; + using FitterResult = Acts::Result<Acts::CombinatorialKalmanFilterResult<IndexSourceLink>>; + using TrackFinderResult = std::vector<FitterResult>; +// using TrackFinderResult = std::vector< +// Acts::Result<Acts::CombinatorialKalmanFilterResult<IndexSourceLink>>>; using TrackFinderFunction = std::function<TrackFinderResult( const IndexSourceLinkContainer&, const std::vector<Acts::CurvilinearTrackParameters>&, const TrackFinderOptions&)>; @@ -36,11 +52,32 @@ class CombinatorialKalmanFilterAlg : public AthReentrantAlgorithm { private: + const FaserSCT_ID* m_idHelper{nullptr}; + const TrackerDD::SCT_DetectorManager* m_detManager{nullptr}; + +// std::unique_ptr<Trk::Track> makeTrack(Acts::GeometryContext& tgContext, FitterResult& fitResult, std::vector<Tracker::FaserSCT_Cluster> seed_spcollection) const; + std::unique_ptr<Trk::Track> makeTrack(Acts::GeometryContext& tgContext, FitterResult& fitResult, std::vector<Tracker::FaserSCT_SpacePoint> seed_spcollection) const; + const Trk::TrackParameters* ConvertActsTrackParameterToATLAS(const Acts::BoundTrackParameters &actsParameter, const Acts::GeometryContext& gctx) const; + + SG::WriteHandleKey<TrackCollection> m_trackCollection { this, "FaserActsCKFTrackCollection", "FaserActsCKFTrackCollection", "Output trackcollectionname" }; + ToolHandle<IFaserActsTrackingGeometryTool> m_trackingGeometryTool{this, "TrackingGeometryTool", "FaserActsTrackingGeometryTool"}; +// ToolHandle<SPSeedBasedInitialParameterTool> m_initialParameterTool{this, "InitialParameterTool", "SPSeedBasedInitialParameterTool"}; +// ToolHandle<SPSimpleInitialParameterTool> m_initialParameterTool{this, "InitialParameterTool", "SPSimpleInitialParameterTool"}; ToolHandle<TruthBasedInitialParameterTool> m_initialParameterTool{this, "InitialParameterTool", "TruthBasedInitialParameterTool"}; ToolHandle<TrajectoryWriterTool> m_trajectoryWriterTool{this, "OutputTool", "TrajectoryWriterTool"}; SG::ReadCondHandleKey<FaserFieldCacheCondObj> m_fieldCondObjInputKey {this, "FaserFieldCacheCondObj", "fieldCondObj", "Name of the Magnetic Field conditions object key"}; - SG::ReadHandleKey<SpacePointContainer> m_SpacePointContainerKey{this, "SpacePointsSCTName", "SCT_SpacePointContainer", "SCT space point container"}; + SG::ReadHandleKey<FaserSCT_SpacePointContainer> m_SpacePointContainerKey{this, "SpacePointsSCTName", "SCT_SpacePointContainer", "SCT space point container"}; + SG::ReadHandleKey<Tracker::FaserSCT_ClusterContainer> m_Sct_clcontainerKey{this, "SCT_ClusterContainer", "SCT_ClusterContainer"}; + mutable int m_nevents; + mutable int m_ntracks; + mutable int m_nseeds; + mutable int m_nsp1; + mutable int m_nsp2; + mutable int m_nsp3; + mutable int m_nsp10; + mutable int m_nsp11; + mutable int m_ncom; }; #endif // COMBINATORIALKALMANFILTERALG_H diff --git a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/FaserActsKalmanFilterAlg.h b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/FaserActsKalmanFilterAlg.h index fd7801c9eef4aa76b4f71215996983cc1a9efd5e..8e90ed858c09efc3d46985a7edb354ea2de6c280 100755 --- a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/FaserActsKalmanFilterAlg.h +++ b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/FaserActsKalmanFilterAlg.h @@ -15,14 +15,15 @@ #include "StoreGate/StoreGateSvc.h" #include "StoreGate/ReadCondHandleKey.h" #include "TrackerPrepRawData/FaserSCT_ClusterCollection.h" -#include "TrkSpacePoint/SpacePoint.h" +#include "TrackerSpacePoint/FaserSCT_SpacePoint.h" +#include "TrackerSpacePoint/SpacePointForSeedCollection.h" #include "MagFieldConditions/FaserFieldCacheCondObj.h" #include "MagFieldElements/FaserFieldCache.h" #include "TrackerReadoutGeometry/SiDetectorElementCollection.h" -#include "TrackerSpacePoint/SpacePointForSeedCollection.h" #include "Identifier/Identifier.h" #include "GeneratorObjects/McEventCollection.h" #include "TrackerSimData/TrackerSimDataCollection.h" +#include "TrkTrack/TrackCollection.h" // ACTS #include "Acts/MagneticField/ConstantBField.hpp" @@ -103,6 +104,10 @@ public: void fillFitResult(const Acts::GeometryContext& geoctx, const TrajectoryContainer& trajectories, const Acts::BoundTrackParameters& truthParam); + // Create a track from the fitter result + std::unique_ptr<Trk::Track> makeTrack(Acts::GeometryContext& tgContext, FitterResult& fitResult,const SpacePointForSeedCollection* seed_spcollection ) const; + const Trk::TrackParameters* ConvertActsTrackParameterToATLAS(const Acts::BoundTrackParameters &actsParameter, const Acts::GeometryContext& gctx) const; + void clearTrackVariables(); private: @@ -122,6 +127,8 @@ private: SG::ReadHandleKey<TrackerSimDataCollection> m_sctMap {this, "TrackerSimDataCollection", "SCT_SDO_Map"}; const TrackerDD::SCT_DetectorManager* m_detManager{nullptr}; + SG::WriteHandleKey<TrackCollection> m_trackCollection { this, "FaserActsCKFTrackCollection", "FaserActsCKFTrackCollection", "Output trackcollection name" }; + ServiceHandle<ITHistSvc> m_thistSvc; TTree *m_trackTree{nullptr}; diff --git a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/SPSeedBasedInitialParameterTool.h b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/SPSeedBasedInitialParameterTool.h new file mode 100644 index 0000000000000000000000000000000000000000..678fef289c9f5b01a1e4a566a24ebee0353ba386 --- /dev/null +++ b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/SPSeedBasedInitialParameterTool.h @@ -0,0 +1,36 @@ +#ifndef SPSEEDBASEDINITIALPARAMETERTOOL_H +#define SPSEEDBASEDINITIALPARAMETERTOOL_H + +#include "AthenaBaseComps/AthAlgTool.h" +#include "TrackerSeedFinder/TrackerSeedFinder.h" +#include "TrackerSpacePoint/TrackerSeedCollection.h" +#include "TrackerSpacePoint/TrackerSeed.h" + +class FaserSCT_ID; + +namespace Acts { + struct SinglyCharged; + template <typename charge_t> class SingleCurvilinearTrackParameters; + using CurvilinearTrackParameters = + SingleCurvilinearTrackParameters<SinglyCharged>; +} + + +class SPSeedBasedInitialParameterTool : public AthAlgTool { + public: + SPSeedBasedInitialParameterTool (const std::string& type, + const std::string& name, const IInterface* parent); + ~SPSeedBasedInitialParameterTool() = default; + + virtual StatusCode initialize() override; + virtual StatusCode finalize() override; + + std::vector<Acts::CurvilinearTrackParameters> getInitialParameters() const; + //Acts::CurvilinearTrackParameters getInitialParameters(std::vector<Identifier> ids) const; + + private: + const FaserSCT_ID* m_idHelper{nullptr}; + SG::ReadHandleKey<Tracker::TrackerSeedCollection> m_trackerSeedContainerKey{this, "FaserTrackerSeedName", "FaserTrackerSeedCollection", "FaserTrackerSeedCollection"}; +}; + +#endif // TRUTHBASEDINITIALPARAMETERTOOL_H diff --git a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/SPSimpleInitialParameterTool.h b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/SPSimpleInitialParameterTool.h new file mode 100644 index 0000000000000000000000000000000000000000..9db75f35f692669dfd3739872697d9309a967228 --- /dev/null +++ b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/SPSimpleInitialParameterTool.h @@ -0,0 +1,37 @@ +#ifndef SPSIMPLEBASEDINITIALPARAMETERTOOL_H +#define SPSIMPLEBASEDINITIALPARAMETERTOOL_H + +#include "AthenaBaseComps/AthAlgTool.h" +#include "Acts/EventData/TrackParameters.hpp" +#include "Acts/Definitions/Units.hpp" +#include "Acts/Geometry/GeometryIdentifier.hpp" +#include "Acts/Definitions/Algebra.hpp" + +class FaserSCT_ID; + +namespace Acts { + struct SinglyCharged; + template <typename charge_t> class SingleCurvilinearTrackParameters; + using CurvilinearTrackParameters = + SingleCurvilinearTrackParameters<SinglyCharged>; +} + + +class SPSimpleInitialParameterTool : public AthAlgTool { + public: + SPSimpleInitialParameterTool (const std::string& type, + const std::string& name, const IInterface* parent); + ~SPSimpleInitialParameterTool() = default; + + virtual StatusCode initialize() override; + virtual StatusCode finalize() override; + + Acts::CurvilinearTrackParameters getInitialParameters(Acts::Vector3 pos1, Acts::Vector3 pos2, Acts::Vector3 pos3) const; + Acts::CurvilinearTrackParameters getInitialParameters_2stations(Acts::Vector3 pos1, Acts::Vector3 pos2, Acts::Vector3 pos3) const; + std::vector<Acts::CurvilinearTrackParameters> getInitialParameters_1station(std::vector<Acts::Vector3> pos1, std::vector<Acts::Vector3> pos2, std::vector<Acts::Vector3> pos3) const; + //Acts::CurvilinearTrackParameters getInitialParameters(std::vector<Identifier> ids) const; + + private: +}; + +#endif // TRUTHBASEDINITIALPARAMETERTOOL_H diff --git a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/TrajectoryWriterTool.h b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/TrajectoryWriterTool.h index 2a3f348b0b467348eb9924c3e93b1c6482922bad..659cea7fa08321bb43a38fcc598a7054b119262c 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/TrajectoryWriterTool.h +++ b/Tracking/Acts/FaserActsKalmanFilter/FaserActsKalmanFilter/TrajectoryWriterTool.h @@ -3,6 +3,7 @@ #include "AthenaBaseComps/AthAlgTool.h" #include "Acts/Geometry/GeometryContext.hpp" +#include "Acts/TrackFinding/MeasurementSelector.hpp" class TFile; class TTree; @@ -20,7 +21,7 @@ class TrajectoryWriterTool : public AthAlgTool { virtual StatusCode finalize() override; void writeout(TrajectoriesContainer trajectories, - Acts::GeometryContext geoContext) const; + Acts::GeometryContext geoContext,std::vector<Acts::CurvilinearTrackParameters> traj ) const; void clearVariables() const; @@ -162,6 +163,27 @@ class TrajectoryWriterTool : public AthAlgTool { mutable std::vector<float> m_pz_smt; mutable std::vector<float> m_eta_smt; mutable std::vector<float> m_pT_smt; + + mutable std::vector<float> m_eLOC0_ini; + mutable std::vector<float> m_eLOC1_ini; + mutable std::vector<float> m_ePHI_ini; + mutable std::vector<float> m_eTHETA_ini; + mutable std::vector<float> m_eQOP_ini; + mutable std::vector<float> m_eT_ini; + mutable std::vector<float> m_err_eLOC0_ini; + mutable std::vector<float> m_err_eLOC1_ini; + mutable std::vector<float> m_err_ePHI_ini; + mutable std::vector<float> m_err_eTHETA_ini; + mutable std::vector<float> m_err_eQOP_ini; + mutable std::vector<float> m_err_eT_ini; + mutable std::vector<float> m_x_ini; + mutable std::vector<float> m_y_ini; + mutable std::vector<float> m_z_ini; + mutable std::vector<float> m_px_ini; + mutable std::vector<float> m_py_ini; + mutable std::vector<float> m_pz_ini; + mutable std::vector<float> m_eta_ini; + mutable std::vector<float> m_pT_ini; }; #endif // TRAJECTORYWRITERTOOL_H diff --git a/Tracking/Acts/FaserActsKalmanFilter/python/CombinatorialKalmanFilterConfig.py b/Tracking/Acts/FaserActsKalmanFilter/python/CombinatorialKalmanFilterConfig.py index b4bef9af0883abd8219a5d908e3c39603674da55..46c01fd06268dddf34867f76d358e4ab10f961e3 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/python/CombinatorialKalmanFilterConfig.py +++ b/Tracking/Acts/FaserActsKalmanFilter/python/CombinatorialKalmanFilterConfig.py @@ -12,6 +12,26 @@ def CombinatorialKalmanFilter_OutputCfg(flags): ostream.TakeItemsFromInput = True return acc +def CombinatorialKalmanFilter_OutputAODCfg(flags): + acc = ComponentAccumulator() + itemList = ["xAOD::EventInfo#*", + "xAOD::EventAuxInfo#*", + "FaserSCT_RDO_Container#*", + "xAOD::FaserTriggerData#*", + "xAOD::FaserTriggerDataAux#*", + "ScintWaveformContainer#*", + "TrackCollection#*", + "xAOD::WaveformHitContainer#*", + "xAOD::WaveformHitAuxContainer#*", + "xAOD::WaveformClock#*", + "xAOD::WaveformClockAuxInfo#*" + ] + acc.merge(OutputStreamCfg(flags, "AOD",itemList)) + ostream = acc.getEventAlgo("OutputStreamAOD") + ostream.TakeItemsFromInput = True + return acc + + def CombinatorialKalmanFilterCfg(flags, **kwargs): acc = ComponentAccumulator() @@ -19,4 +39,5 @@ def CombinatorialKalmanFilterCfg(flags, **kwargs): combinatorialKalmanFilterAlg = CompFactory.CombinatorialKalmanFilterAlg(**kwargs) acc.addEventAlgo(combinatorialKalmanFilterAlg) acc.merge(CombinatorialKalmanFilter_OutputCfg(flags)) + acc.merge(CombinatorialKalmanFilter_OutputAODCfg(flags)) return acc diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/CombinatorialKalmbanFilterAlg.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/CombinatorialKalmbanFilterAlg.cxx index 564760f72f7e5a502d4e21f9474a1f00c9e52221..f5c547e61418ca7d5d0e4eb8b1cbdb9651e9316b 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/src/CombinatorialKalmbanFilterAlg.cxx +++ b/Tracking/Acts/FaserActsKalmanFilter/src/CombinatorialKalmbanFilterAlg.cxx @@ -2,9 +2,13 @@ #include "StoreGate/ReadHandle.h" #include "StoreGate/ReadCondHandleKey.h" -#include "TrkSpacePoint/SpacePointCollection.h" -#include "TrkSpacePoint/SpacePoint.h" +#include "TrackerSpacePoint/FaserSCT_SpacePointCollection.h" +#include "TrackerSpacePoint/FaserSCT_SpacePoint.h" +#include "TrackerIdentifier/FaserSCT_ID.h" #include "TrkPrepRawData/PrepRawData.h" +#include "TrackerPrepRawData/FaserSCT_Cluster.h" +#include "TrackerRIO_OnTrack/FaserSCT_ClusterOnTrack.h" +#include "TrkRIO_OnTrack/RIO_OnTrack.h" #include "TrkSurfaces/Surface.h" #include "Identifier/Identifier.h" #include "Acts/Geometry/GeometryIdentifier.hpp" @@ -28,48 +32,115 @@ CombinatorialKalmanFilterAlg::CombinatorialKalmanFilterAlg( StatusCode CombinatorialKalmanFilterAlg::initialize() { ATH_MSG_INFO("CombinatorialKalmanFilterAlg::initialize"); + m_nevents=0; + m_ntracks=0; + m_nseeds=0; + m_nsp10=0; + m_nsp11=0; + m_ncom=0; + m_nsp1=0; + m_nsp2=0; + m_nsp3=0; ATH_CHECK(m_trackingGeometryTool.retrieve()); ATH_CHECK(m_initialParameterTool.retrieve()); ATH_CHECK(m_trajectoryWriterTool.retrieve()); + ATH_CHECK(detStore()->retrieve(m_idHelper,"FaserSCT_ID")); ATH_CHECK( m_fieldCondObjInputKey.initialize() ); + ATH_CHECK(m_trackCollection.initialize()); + if (m_SpacePointContainerKey.key().empty()) { ATH_MSG_FATAL("empty space point container key"); return StatusCode::FAILURE; } ATH_CHECK(m_SpacePointContainerKey.initialize()); + ATH_CHECK(m_Sct_clcontainerKey.initialize() ); return StatusCode::SUCCESS; } StatusCode CombinatorialKalmanFilterAlg::execute(const EventContext& ctx) const { - ATH_MSG_INFO("CombinatorialKalmanFilterAlg::execute"); + ATH_MSG_DEBUG("CombinatorialKalmanFilterAlg::execute"); + m_nevents++; - SG::ReadHandle<SpacePointContainer> spcontainer(m_SpacePointContainerKey, ctx); + SG::ReadHandle<FaserSCT_SpacePointContainer> spcontainer(m_SpacePointContainerKey, ctx); if (!spcontainer.isValid()) { ATH_MSG_FATAL( "Could not find the data object "<< spcontainer.name()); return StatusCode::FAILURE; } + SG::ReadHandle<Tracker::FaserSCT_ClusterContainer> sct_clcontainer( m_Sct_clcontainerKey, ctx ); +if (!sct_clcontainer.isValid()){ +msg(MSG:: FATAL) << "Could not find the data object "<< sct_clcontainer.name() << " !" << endmsg; +return StatusCode::RECOVERABLE; +} + + + //make TrackCollection + SG::WriteHandle<TrackCollection> trackContainer{m_trackCollection,ctx}; + std::unique_ptr<TrackCollection> outputTracks = std::make_unique<TrackCollection>(); const std::shared_ptr<IdentifierMap> identifierMap = m_trackingGeometryTool->getIdentifierMap(); + /* // Create measurement and source link containers IndexSourceLinkContainer sourceLinks; MeasurementContainer measurements; std::vector<Identifier> sp_ids; + std::vector<Tracker::FaserSCT_Cluster> sps; + + std::vector<Acts::Vector3> pos1; + std::vector<Acts::Vector3> pos2; + std::vector<Acts::Vector3> pos3; + pos1.clear();pos2.clear();pos3.clear(); + Tracker::FaserSCT_ClusterContainer::const_iterator coll_it = sct_clcontainer->begin(); + Tracker::FaserSCT_ClusterContainer::const_iterator coll_itend = sct_clcontainer->end(); + for (; coll_it != coll_itend; ++coll_it) { + const Tracker::FaserSCT_ClusterCollection* spcollection = *coll_it; + Tracker::FaserSCT_ClusterCollection::const_iterator sp_it = spcollection->begin(); + Tracker::FaserSCT_ClusterCollection::const_iterator sp_end = spcollection->end(); + for (; sp_it != sp_end; ++sp_it) { + const Tracker::FaserSCT_Cluster* sp = *sp_it; + Identifier id = sp->detectorElement()->identify(); + //Identifier id = sp->associatedSurface().associatedDetectorElementIdentifier(); + Acts::GeometryIdentifier geoId = identifierMap->at(id); + IndexSourceLink sourceLink(geoId, measurements.size()); + sourceLinks.emplace_hint(sourceLinks.end(), std::move(sourceLink)); + ThisMeasurement meas(sourceLink, indices, sp->localPosition(), sp->localCovariance()); + //ThisMeasurement meas(sourceLink, indices, sp->localParameters(), sp->localCovariance()); + measurements.emplace_back(std::move(meas)); - SpacePointContainer::const_iterator coll_it = spcontainer->begin(); - SpacePointContainer::const_iterator coll_itend = spcontainer->end(); + if(m_idHelper->station(sp->identify())==1)pos1.push_back(Acts::Vector3(sp->globalPosition().x(),sp->globalPosition().y(),sp->globalPosition().z())); + if(m_idHelper->station(sp->identify())==2)pos2.push_back(Acts::Vector3(sp->globalPosition().x(),sp->globalPosition().y(),sp->globalPosition().z())); + if(m_idHelper->station(sp->identify())==3)pos3.push_back(Acts::Vector3(sp->globalPosition().x(),sp->globalPosition().y(),sp->globalPosition().z())); + sp_ids.push_back(sp->identify()); + sps.push_back(*sp); + } + } +*/ + // Create measurement and source link containers + IndexSourceLinkContainer sourceLinks; + MeasurementContainer measurements; + std::vector<Identifier> sp_ids; + std::vector<Tracker::FaserSCT_SpacePoint> sps; + +// std::vector<Acts::Vector3> pos1; +// std::vector<Acts::Vector3> pos2; +// std::vector<Acts::Vector3> pos3; +// pos1.clear();pos2.clear();pos3.clear(); + std::vector<int> layer1; + layer1.clear(); + FaserSCT_SpacePointContainer::const_iterator coll_it = spcontainer->begin(); + FaserSCT_SpacePointContainer::const_iterator coll_itend = spcontainer->end(); for (; coll_it != coll_itend; ++coll_it) { - const SpacePointCollection* spcollection = *coll_it; - SpacePointCollection::const_iterator sp_it = spcollection->begin(); - SpacePointCollection::const_iterator sp_end = spcollection->end(); + const FaserSCT_SpacePointCollection* spcollection = *coll_it; + FaserSCT_SpacePointCollection::const_iterator sp_it = spcollection->begin(); + FaserSCT_SpacePointCollection::const_iterator sp_end = spcollection->end(); for (; sp_it != sp_end; ++sp_it) { - const Trk::SpacePoint* sp = *sp_it; + const Tracker::FaserSCT_SpacePoint* sp = *sp_it; Identifier id = sp->associatedSurface().associatedDetectorElementIdentifier(); Acts::GeometryIdentifier geoId = identifierMap->at(id); IndexSourceLink sourceLink(geoId, measurements.size()); @@ -77,15 +148,89 @@ StatusCode CombinatorialKalmanFilterAlg::execute(const EventContext& ctx) const ThisMeasurement meas(sourceLink, indices, sp->localParameters(), sp->localCovariance()); measurements.emplace_back(std::move(meas)); +// if(m_idHelper->station(sp->clusterList().first->identify())==1) { +// pos1.push_back(Acts::Vector3(sp->globalPosition().x(),sp->globalPosition().y(),sp->globalPosition().z())); +// layer1.push_back(m_idHelper->layer(sp->clusterList().first->identify())); +// } +// if(m_idHelper->station(sp->clusterList().first->identify())==2)pos2.push_back(Acts::Vector3(sp->globalPosition().x(),sp->globalPosition().y(),sp->globalPosition().z())); +// if(m_idHelper->station(sp->clusterList().first->identify())==3)pos3.push_back(Acts::Vector3(sp->globalPosition().x(),sp->globalPosition().y(),sp->globalPosition().z())); sp_ids.push_back(sp->clusterList().first->identify()); - } - } - - // Get initial parameters - // FIXME: Get initial parameters from clusterFitter or SeedFinder not MC! - std::vector<Acts::CurvilinearTrackParameters> initialParameters; - auto initialParameter = m_initialParameterTool->getInitialParameters(sp_ids); - initialParameters.push_back(initialParameter); + sps.push_back(*sp); + } + } + + // Get initial parameters + // FIXME: Get initial parameters from clusterFitter or SeedFinder not MC! + std::vector<Acts::CurvilinearTrackParameters> initialParameters; + auto initialParameter = m_initialParameterTool->getInitialParameters(sp_ids); + initialParameters.push_back(initialParameter); +// if(pos1.size()<1||pos2.size()<1||pos3.size()<1) return StatusCode::SUCCESS; +// std::vector<Acts::CurvilinearTrackParameters> initialParameters; +// initialParameters.clear(); +// Acts::Vector3 pos1a(0,0,0); +// Acts::Vector3 pos2a(0,0,0); +// Acts::Vector3 pos3a(0,0,0); +// for(long unsigned int i1=0;i1<pos1.size();i1++)pos1a+=pos1[i1]; +// for(long unsigned int i1=0;i1<pos2.size();i1++)pos2a+=pos2[i1]; +// for(long unsigned int i1=0;i1<pos3.size();i1++)pos3a+=pos3[i1]; +// pos1a/=pos1.size(); +// pos2a/=pos2.size(); +// pos3a/=pos3.size(); +// m_nsp1+=pos1.size(); +// m_nsp2+=pos2.size(); +// m_nsp3+=pos3.size(); +// for(int i1=0;i1<pos1.size();i1++){ +// for(int i2=0;i2<pos2.size();i2++){ +// for(int i3=0;i3<pos3.size();i3++){ +// auto initialParameter=m_initialParameterTool->getInitialParameters(pos1[i1],pos2[i2],pos3[i3]); +// initialParameters.push_back(initialParameter); +// } +// } +// } + /* + if(pos1.size()>0&&pos2.size()>0&&pos3.size()>0) { + auto initialParameter=m_initialParameterTool->getInitialParameters(pos1a,pos2a,pos3a); + if(initialParameter.momentum().z()>0){ + m_nseeds++; + initialParameters.push_back(initialParameter); + */ + // for one stations +// if(pos1.size()>2) { +// std::vector<Acts::Vector3> pos10; +// std::vector<Acts::Vector3> pos11; +// std::vector<Acts::Vector3> pos12; +// pos10.clear();pos11.clear();pos12.clear(); +// for(std::size_t ipos=0;ipos<pos1.size();ipos++){ +// if(layer1[ipos]==0)pos10.push_back(pos1[ipos]); +// if(layer1[ipos]==1)pos11.push_back(pos1[ipos]); +// if(layer1[ipos]==2)pos12.push_back(pos1[ipos]); +// } +// if(pos10.size()>0&&pos11.size()>0&&pos12.size()>0){ +// auto initialParameter=m_initialParameterTool->getInitialParameters_1station(pos10,pos11,pos12); +// initialParameters.insert(initialParameters.end(),initialParameter.begin(),initialParameter.end()); + /* + //for two stations + if(pos1.size()>1&&pos2.size()>0) { + Acts::Vector3 pos10a(0,0,0); + Acts::Vector3 pos11a(0,0,0); + int n10a=0,n11a=0; + for(int ipos=0;ipos<pos1.size();ipos++){ + if(layer1[ipos]==0){pos10a+=pos1[ipos];n10a++;} + if(layer1[ipos]>0){pos11a+=pos1[ipos];n11a++;} + } + m_nsp10+=n10a; + m_nsp11+=n11a; + if(n10a>0&&n11a>0){ + m_ncom++; + pos10a/=n10a; + pos11a/=n11a; + Acts::Vector3 dir1=(pos11a-pos10a).normalized(); + auto initialParameter=m_initialParameterTool->getInitialParameters_2stations(pos1a,pos2a,dir1); + if(initialParameter.momentum().z()>0){ + m_nseeds++; + initialParameters.push_back(initialParameter); + } + */ // Prepare the output data with MultiTrajectory TrajectoriesContainer trajectories; @@ -97,6 +242,16 @@ StatusCode CombinatorialKalmanFilterAlg::execute(const EventContext& ctx) const Acts::PropagatorPlainOptions pOptions; pOptions.maxSteps = 10000; + /* + Acts::DirectNavigator navigator; + std::unique_ptr<ActsExtrapolationDetail::VariantPropagator> varProp; + Acts::Vector3 constantFieldVector = Acts::Vector3(0,0,0.55); + auto bField = std::make_shared<Acts::ConstantBField>(constantFieldVector); + auto stepper = Acts::EigenStepper<>(std::move(bField)); + auto propagator = Acts::Propagator<decltype(stepper), Acts::DirectNavigator>(std::move(stepper), + std::move(navigator)); + varProp = std::make_unique<VariantPropagator>(propagator); + */ Acts::GeometryContext geoContext = m_trackingGeometryTool->getNominalGeometryContext().context(); Acts::MagneticFieldContext magFieldContext = getMagneticFieldContext(ctx); @@ -107,13 +262,14 @@ StatusCode CombinatorialKalmanFilterAlg::execute(const EventContext& ctx) const {Acts::GeometryIdentifier(), {chi2Max, nMax}}, }; std::unique_ptr<const Acts::Logger> logger - = Acts::getDefaultLogger("CombinatorialKalmanFilter", Acts::Logging::VERBOSE); + = Acts::getDefaultLogger("CombinatorialKalmanFilter", Acts::Logging::INFO); // Set the CombinatorialKalmanFilter options CombinatorialKalmanFilterAlg::TrackFinderOptions options( geoContext, magFieldContext, calibContext, IndexSourceLinkAccessor(), MeasurementCalibrator(measurements), Acts::MeasurementSelector(measurementSelectorCfg), + //Acts::LoggerWrapper{*logger}, varProp, &(*pSurface)); Acts::LoggerWrapper{*logger}, pOptions, &(*pSurface)); std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry @@ -133,6 +289,13 @@ StatusCode CombinatorialKalmanFilterAlg::execute(const EventContext& ctx) const if (result.ok()) { // Get the track finding output object const auto& trackFindingOutput = result.value(); + std::unique_ptr<Trk::Track> track = makeTrack(geoContext, result,sps); + m_ntracks++; + if(track!=nullptr) { + outputTracks->push_back(std::move(track)); + } else { + ATH_MSG_DEBUG("No Trk::Track is created" ); + } // Create a Trajectories result struct trajectories.emplace_back(std::move(trackFindingOutput.fittedStates), std::move(trackFindingOutput.lastMeasurementIndices), @@ -146,14 +309,27 @@ StatusCode CombinatorialKalmanFilterAlg::execute(const EventContext& ctx) const } } - m_trajectoryWriterTool->writeout(trajectories, geoContext); + m_trajectoryWriterTool->writeout(trajectories, geoContext,initialParameters); +// } +// } + if(outputTracks->size()>0) { + ATH_MSG_DEBUG("Found " << outputTracks->size() << " tracks"); + } else { + ATH_MSG_WARNING("No track is found"); + } + + ATH_CHECK(trackContainer.record(std::move(outputTracks))); return StatusCode::SUCCESS; } StatusCode CombinatorialKalmanFilterAlg::finalize() { ATH_MSG_INFO("CombinatorialKalmanFilterAlg::finalize"); + ATH_MSG_INFO("Summary info"); + ATH_MSG_INFO("In total, "<<m_nevents<<" events, and "<<m_nseeds<<" seeds, and "<<m_ntracks<<" tracks"); + ATH_MSG_INFO("In total, "<<m_nsp1<<" , "<<m_nsp2<<" , "<<m_nsp3<<" ,"<<m_nsp10<<" , "<<m_nsp11<<" , "<<m_ncom); + return StatusCode::SUCCESS; } @@ -169,3 +345,105 @@ Acts::MagneticFieldContext CombinatorialKalmanFilterAlg::getMagneticFieldContext return Acts::MagneticFieldContext(fieldCondObj); } + +std::unique_ptr<Trk::Track> +CombinatorialKalmanFilterAlg::makeTrack(Acts::GeometryContext& tgContext, FitterResult& fitResult, std::vector<Tracker::FaserSCT_SpacePoint> sps) const { + std::unique_ptr<Trk::Track> newtrack = nullptr; + //Get the fit output object + const auto& fitOutput = fitResult.value(); + if (fitOutput.fittedParameters.size()>0) { + DataVector<const Trk::TrackStateOnSurface>* finalTrajectory = new DataVector<const Trk::TrackStateOnSurface>{}; + std::vector<std::unique_ptr<const Acts::BoundTrackParameters>> actsSmoothedParam; + ATH_MSG_DEBUG("makeTrack : trackTip "<<fitOutput.lastMeasurementIndices.size()); + // Loop over all the output state to create track state + fitOutput.fittedStates.visitBackwards(fitOutput.lastMeasurementIndices.front(), [&](const auto &state) { + auto flag = state.typeFlags(); + if (state.referenceSurface().associatedDetectorElement() != nullptr) { + // const auto* actsElement = dynamic_cast<const FaserActsDetectorElement*>(state.referenceSurface().associatedDetectorElement()); + // if (actsElement != nullptr ){ + // We need to determine the type of state + std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern; + const Trk::TrackParameters *parm; + + // State is a hole (no associated measurement), use predicted para meters + if (flag[Acts::TrackStateFlag::HoleFlag] == true) { + const Acts::BoundTrackParameters actsParam(state.referenceSurface().getSharedPtr(), + state.predicted(), + state.predictedCovariance()); + parm = ConvertActsTrackParameterToATLAS(actsParam, tgContext); + // auto boundaryCheck = m_boundaryCheckTool->boundaryCheck(*p arm); + typePattern.set(Trk::TrackStateOnSurface::Hole); + } + // The state was tagged as an outlier, use filtered parameters + else if (flag[Acts::TrackStateFlag::OutlierFlag] == true) { + const Acts::BoundTrackParameters actsParam(state.referenceSurface().getSharedPtr(), + state.filtered(), state.filteredCovariance()); + parm = ConvertActsTrackParameterToATLAS(actsParam, tgContext); + typePattern.set(Trk::TrackStateOnSurface::Outlier); + } + // The state is a measurement state, use smoothed parameters + else { + const Acts::BoundTrackParameters actsParam(state.referenceSurface().getSharedPtr(), + state.smoothed(), state.smoothedCovariance()); + actsSmoothedParam.push_back(std::make_unique<const Acts::BoundTrackParameters>(Acts::BoundTrackParameters(actsParam))); + // const auto& psurface=actsParam.referenceSurface(); + Acts::Vector2 local(actsParam.parameters()[Acts::eBoundLoc0], actsParam.parameters()[Acts::eBoundLoc1]); + // const Acts::Vector3 dir = Acts::makeDirectionUnitFromPhiTheta(actsParam.parameters()[Acts::eBoundPhi], actsParam.parameters()[Acts::eBoundTheta]); + // auto pos=actsParam.position(tgContext); + parm = ConvertActsTrackParameterToATLAS(actsParam, tgContext); + typePattern.set(Trk::TrackStateOnSurface::Measurement); + } + Tracker::FaserSCT_ClusterOnTrack* measState = nullptr; + if (state.hasUncalibrated()) { + auto sp= sps.at(state.uncalibrated().index()); + //const Tracker::FaserSCT_Cluster* fitCluster=&sp; + const Tracker::FaserSCT_Cluster* fitCluster=sp.clusterList().first; + if(fitCluster !=nullptr) { + measState = new Tracker::FaserSCT_ClusterOnTrack{ fitCluster, Trk::LocalParameters { Trk::DefinedParameter { fitCluster->localPosition()[0], Trk::loc1 }, Trk::DefinedParameter { fitCluster->localPosition()[1], Trk::loc2 } }, fitCluster->localCovariance(), m_idHelper->wafer_hash(fitCluster->detectorElement()->identify())}; + } + } + double nDoF = state.calibratedSize(); + const Trk::FitQualityOnSurface *quality = new Trk::FitQualityOnSurface(state.chi2(), nDoF); + const Trk::TrackStateOnSurface *perState = new Trk::TrackStateOnSurface(measState, parm, quality, nullptr, typePattern); + // If a state was succesfully created add it to the trajectory + if (perState) { + finalTrajectory->insert(finalTrajectory->begin(), perState); + } + } + return; + }); + + // Create the track using the states + const Trk::TrackInfo newInfo(Trk::TrackInfo::TrackFitter::KalmanFitter, Trk::ParticleHypothesis::muon); + // Trk::FitQuality* q = nullptr; + // newInfo.setTrackFitter(Trk::TrackInfo::TrackFitter::KalmanFitter ); //Mark the fitter as KalmanFitter + newtrack = std::make_unique<Trk::Track>(newInfo, std::move(*finalTrajectory), nullptr); + } + return newtrack; +} + +const Trk::TrackParameters* +CombinatorialKalmanFilterAlg ::ConvertActsTrackParameterToATLAS(const Acts::BoundTrackParameters &actsParameter, const Acts::GeometryContext& gctx) const { + using namespace Acts::UnitLiterals; + std::optional<AmgSymMatrix(5)> cov = std::nullopt; + if (actsParameter.covariance()){ + AmgSymMatrix(5) newcov(actsParameter.covariance()->topLeftCorner(5, 5)); + // Convert the covariance matrix to GeV + for(int i=0; i < newcov.rows(); i++){ + newcov(i, 4) = newcov(i, 4)*1_MeV; + } + for(int i=0; i < newcov.cols(); i++){ + newcov(4, i) = newcov(4, i)*1_MeV; + } + cov = std::optional<AmgSymMatrix(5)>(newcov); + } + const Amg::Vector3D& pos=actsParameter.position(gctx); + double tphi=actsParameter.get<Acts::eBoundPhi>(); + double ttheta=actsParameter.get<Acts::eBoundTheta>(); + double tqOverP=actsParameter.get<Acts::eBoundQOverP>()*1_MeV; + double p = std::abs(1. / tqOverP); + Amg::Vector3D tmom(p * std::cos(tphi) * std::sin(ttheta), p * std::sin(tphi) * std::sin(ttheta), p * std::cos(ttheta)); + const Trk::CurvilinearParameters * curv = new Trk::CurvilinearParameters(pos,tmom,tqOverP>0, cov); + return curv; +} + diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/FaserActsKalmanFilterAlg.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/FaserActsKalmanFilterAlg.cxx index 9d11c2f800b559ebb694765e7286cea85d62ee8d..c9427a0f8f9940f6d181e4f4775bcb9a8e2ae527 100755 --- a/Tracking/Acts/FaserActsKalmanFilter/src/FaserActsKalmanFilterAlg.cxx +++ b/Tracking/Acts/FaserActsKalmanFilter/src/FaserActsKalmanFilterAlg.cxx @@ -265,7 +265,7 @@ StatusCode FaserActsKalmanFilterAlg::execute() SpacePointForSeedCollection::const_iterator it = seed_spcollection->begin(); SpacePointForSeedCollection::const_iterator itend = seed_spcollection->end(); for (; it != itend; ++it){ - const Trk::SpacePoint *sp = (&(**it))->SpacePoint(); + const Tracker::FaserSCT_SpacePoint *sp = (&(**it))->SpacePoint(); const Identifier id = sp->clusterList().first->identify(); const TrackerDD::SiDetectorElement* siSpElement = m_detManager->getDetectorElement(id); @@ -453,8 +453,8 @@ StatusCode FaserActsKalmanFilterAlg::execute() std::shared_ptr<const Acts::Surface> initSurface = Acts::Surface::makeShared<Acts::PlaneSurface>(center, normal); // extrapolate the particle from production point to the first layer const Acts::Vector4 truthPosTime (pPos.x(), pPos.y(), pPos.z(), time); - const Acts::Vector3 truthMomentum_dir = pMom.normalized(); - double truthMomentum_abs = pMom.norm(); +// const Acts::Vector3 truthMomentum_dir = pMom.normalized(); +// double truthMomentum_abs = pMom.norm(); BoundVector params = BoundVector::Zero(); params[Acts::eBoundLoc0] = pPos.x(); diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/SPSeedBasedInitialParameterTool.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/SPSeedBasedInitialParameterTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..f29ce6e80e65a9ca759f931174318fd1c1a68b68 --- /dev/null +++ b/Tracking/Acts/FaserActsKalmanFilter/src/SPSeedBasedInitialParameterTool.cxx @@ -0,0 +1,123 @@ +#include "FaserActsKalmanFilter/SPSeedBasedInitialParameterTool.h" + +#include "StoreGate/ReadHandle.h" +#include "HepMC/GenVertex.h" +#include "Acts/EventData/TrackParameters.hpp" +#include "Acts/Definitions/Units.hpp" +#include "TrackerIdentifier/FaserSCT_ID.h" +#include <random> +#include <cmath> + + +using namespace Acts::UnitLiterals; + +SPSeedBasedInitialParameterTool::SPSeedBasedInitialParameterTool( + const std::string& type, const std::string& name, const IInterface* parent) : + AthAlgTool(type, name, parent) {} + + + StatusCode SPSeedBasedInitialParameterTool::initialize() { + ATH_MSG_INFO("SPSeedBasedInitialParameterTool::initialize"); + ATH_CHECK(m_trackerSeedContainerKey.initialize()); + ATH_CHECK(detStore()->retrieve(m_idHelper,"FaserSCT_ID")); + return StatusCode::SUCCESS; + } + + +StatusCode SPSeedBasedInitialParameterTool::finalize() { + ATH_MSG_INFO("SPSeedBasedInitialParameterTool::finalize"); + return StatusCode::SUCCESS; +} + + +std::vector<Acts::CurvilinearTrackParameters> SPSeedBasedInitialParameterTool::getInitialParameters() const { + std::vector<Acts::CurvilinearTrackParameters> initialParameters; + initialParameters.clear(); + SG::ReadHandle<Tracker::TrackerSeedCollection> trackerSeedCollection(m_trackerSeedContainerKey); + if (!trackerSeedCollection.isValid()){ + msg(MSG::FATAL) << "Could not find the data object "<< trackerSeedCollection.name() << " !" << endmsg; + return initialParameters; + } + // msg(MSG::INFO) << "found "<< trackerSeedCollection.size()<< " seeds" << endmsg; + + double charge = 1; + double B = 0.55; + + Tracker::TrackerSeedCollection::const_iterator it = trackerSeedCollection->begin(); + Tracker::TrackerSeedCollection::const_iterator itend = trackerSeedCollection->end(); + for (; it != itend; ++it){ + const Tracker::TrackerSeed *colNext=&(**it); + auto sps=colNext->getSpacePoints(); + msg(MSG::DEBUG) << "found "<< sps.size()<< "spacepoints in the seed" << endmsg; + + Acts::Vector3 pos1_0(0., 0., 0.); + Acts::Vector3 pos1_1(0., 0., 0.); + Acts::Vector3 pos1_2(0., 0., 0.); + Acts::Vector3 pos2_0(0., 0., 0.); + Acts::Vector3 pos2_1(0., 0., 0.); + Acts::Vector3 pos2_2(0., 0., 0.); + for(auto isp : sps){ + //get the cluster ID + const Identifier id = isp->clusterList().first->identify(); + Amg::Vector3D gloPos=isp->globalPosition(); + int station = m_idHelper->station(id); + int plane = m_idHelper->layer(id); + if (station==1 && plane==0) pos1_0 = Acts::Vector3(gloPos.x(), gloPos.y(), gloPos.z()); + if (station==1 && plane==1) pos1_1 = Acts::Vector3(gloPos.x(), gloPos.y(), gloPos.z()); + if (station==1 && plane==2) pos1_2 = Acts::Vector3(gloPos.x(), gloPos.y(), gloPos.z()); + if (station==2 && plane==0) pos2_0 = Acts::Vector3(gloPos.x(), gloPos.y(), gloPos.z()); + if (station==2 && plane==1) pos2_1 = Acts::Vector3(gloPos.x(), gloPos.y(), gloPos.z()); + if (station==2 && plane==2) pos2_2 = Acts::Vector3(gloPos.x(), gloPos.y(), gloPos.z()); + } + if((pos1_0.z()==0)||(pos1_1.z()==0)||(pos1_2.z()==0)||(pos2_0.z()==0)||(pos2_1.z()==0)||(pos2_2.z()==0)){ + msg(MSG::WARNING) << "failed to find 2 triplets "<< endmsg; + continue; + } + + //const Acts::Vector3 pos = pos1_0; + const Acts::Vector3 pos(pos1_0.x(), pos1_0.y(), pos1_0.z()); + Acts::Vector3 d1 = pos1_2 - pos1_0; + Acts::Vector3 d2 = pos2_2 - pos2_0; + // the direction of momentum in the first station + Acts::Vector3 direct1 = d1.normalized(); + // the direction of momentum in the second station + Acts::Vector3 direct2 = d2.normalized(); + // the vector pointing from the center of circle to the particle at la yer 2 in Y-Z plane + double R1_z = charge * direct1.y() / std::sqrt(direct1.y()*direct1.y() + direct1.z()*direct1.z()); + // double R1_y = -charge * direct1.z() / std::sqrt(direct1.y()*direct1 .y() + direct1.z()*direct1.z()); + double R2_z = charge * direct2.y() / std::sqrt(direct2.y()*direct2.y() + direct2.z()*direct2.z()); + double R = (pos2_0.z() - pos1_2.z()) / (R2_z - R1_z); + // the norm of momentum in Y-Z plane + double p_yz = 0.3*B*R / 1000.0; // R(mm), p(GeV), B(T) + double p_z = p_yz * direct1.z() / std::sqrt(direct1.y()*direct1.y() + direct1.z()*direct1.z()); + double p_y = p_yz * direct1.y() / std::sqrt(direct1.y()*direct1.y() + direct1.z()*direct1.z()); + double p_x = direct1.x() * p_z / direct1.z(); + // total momentum at the layer 0 + const Acts::Vector3 mom(p_x, p_y, p_z); + double p = mom.norm(); + msg(MSG::DEBUG)<<"!!!!!!!!!!! InitTrack momentum on layer 0: ( "<<mom.x()*1000<<", "<<mom.y()*1000<<", "<<mom.z()*1000<<", "<<p*1000<<") "<<endmsg; + // build the track covariance matrix using the smearing sigmas + double sigmaU = 200_um; + double sigmaV = 200_um; + double sigmaPhi = 1_degree; + double sigmaTheta = 1_degree; + double sigmaQOverP = 0.01*p / (p*p); + double sigmaT0 = 1_ns; + Acts::BoundSymMatrix cov = Acts::BoundSymMatrix::Zero(); + cov(Acts::eBoundLoc0, Acts::eBoundLoc0) = sigmaU * sigmaU; + cov(Acts::eBoundLoc1, Acts::eBoundLoc1) = sigmaV * sigmaV; + cov(Acts::eBoundPhi, Acts::eBoundPhi) = sigmaPhi * sigmaPhi; + cov(Acts::eBoundTheta, Acts::eBoundTheta) = sigmaTheta * sigmaTheta; + cov(Acts::eBoundQOverP, Acts::eBoundQOverP) = sigmaQOverP * sigmaQOverP; + cov(Acts::eBoundTime, Acts::eBoundTime) = sigmaT0 * sigmaT0; + double time =0; + const Acts::Vector4 postime(pos.x(), pos.y(), pos.z(),time); + Acts::CurvilinearTrackParameters InitTrackParam(postime, mom.normalized(), mom.norm(), charge, std::make_optional(std::move(cov))); + + // Acts::CurvilinearTrackParameters InitTrackParam(std::make_optional(std::move(cov)), pos, mom, charge, time); // calculated initial parameters + initialParameters.push_back(InitTrackParam); + } + + + return initialParameters; +} diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/SPSimpleInitialParameterTool.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/SPSimpleInitialParameterTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..f3d227dcb6e81085b28a12d6e68a5161d171dba3 --- /dev/null +++ b/Tracking/Acts/FaserActsKalmanFilter/src/SPSimpleInitialParameterTool.cxx @@ -0,0 +1,169 @@ +#include "FaserActsKalmanFilter/SPSimpleInitialParameterTool.h" + +#include "StoreGate/ReadHandle.h" +#include "HepMC/GenVertex.h" +#include "TrackerIdentifier/FaserSCT_ID.h" +#include <random> +#include <cmath> + + +using namespace Acts::UnitLiterals; + +SPSimpleInitialParameterTool::SPSimpleInitialParameterTool( + const std::string& type, const std::string& name, const IInterface* parent) : + AthAlgTool(type, name, parent) {} + + + StatusCode SPSimpleInitialParameterTool::initialize() { + ATH_MSG_INFO("SPSimpleInitialParameterTool::initialize"); + return StatusCode::SUCCESS; + } + + +StatusCode SPSimpleInitialParameterTool::finalize() { + ATH_MSG_INFO("SPSimpleInitialParameterTool::finalize"); + return StatusCode::SUCCESS; +} + + +Acts::CurvilinearTrackParameters SPSimpleInitialParameterTool::getInitialParameters(Acts::Vector3 pos1, Acts::Vector3 pos2, Acts::Vector3 pos3) const { + + double charge = pos1.y()+pos3.y()>2.*pos2.y()?1:-1; + double B = 0.55; + + Acts::Vector3 amc=pos3-pos1; + Acts::Vector3 amb=pos2-pos1; + Acts::Vector3 bmc=pos3-pos2; + Acts::Vector3 apc=(pos3+pos1)/2.; + double tmpa=sqrt(amc.y()*amc.y()+amc.z()*amc.z())/2.; + double tmpb=sqrt((pos2.y()-apc.y())*(pos2.y()-apc.y())+(pos2.z()-apc.z())*(pos2.z()-apc.z())); + double R=(tmpa*tmpa+tmpb*tmpb)/2./tmpb; + double p_yz = 0.3*B*R / 1000.0; // R(mm), p(GeV), B(T) + + Acts::Vector3 d1=amc.normalized()+amb.normalized()-bmc.normalized(); + Acts::Vector3 d2=(pos3+pos2)/2.-pos1; + double p_z=p_yz*d1.z()/sqrt(d1.z()*d1.z()+d1.y()*d1.y()); + double p_y=p_z*d1.y()/d1.z(); + double p_x=p_z*d2.x()/d2.z(); + + const Acts::Vector3 mom(p_x, p_y, p_z); + double p = mom.norm(); + msg(MSG::DEBUG)<<"!!!!!!!!!!! InitTrack momentum on layer 0: ( "<<mom.x()*1000<<", "<<mom.y()*1000<<", "<<mom.z()*1000<<", "<<p*1000<<") "<<endmsg; + // build the track covariance matrix using the smearing sigmas + double sigmaU = 10000_um; + double sigmaV = 10000_um; + double sigmaPhi = 20_degree; + double sigmaTheta = 10_degree; + double sigmaQOverP = 10.00*p / (p*p); + //double sigmaQOverP = 0.02*p / (p*p); + double sigmaT0 = 1_ns; + Acts::BoundSymMatrix cov = Acts::BoundSymMatrix::Zero(); + cov(Acts::eBoundLoc0, Acts::eBoundLoc0) = sigmaU * sigmaU; + cov(Acts::eBoundLoc1, Acts::eBoundLoc1) = sigmaV * sigmaV; + cov(Acts::eBoundPhi, Acts::eBoundPhi) = sigmaPhi * sigmaPhi; + cov(Acts::eBoundTheta, Acts::eBoundTheta) = sigmaTheta * sigmaTheta; + cov(Acts::eBoundQOverP, Acts::eBoundQOverP) = sigmaQOverP * sigmaQOverP; + cov(Acts::eBoundTime, Acts::eBoundTime) = sigmaT0 * sigmaT0; + double time =0; + const Acts::Vector4 postime(pos1.x(), pos1.y(), pos1.z(),time); + Acts::CurvilinearTrackParameters InitTrackParam(postime, mom.normalized(), mom.norm(), charge, std::make_optional(std::move(cov))); + + return InitTrackParam; +} + +Acts::CurvilinearTrackParameters SPSimpleInitialParameterTool::getInitialParameters_2stations(Acts::Vector3 pos1, Acts::Vector3 pos2, Acts::Vector3 dir1) const { + + Acts::Vector3 dir2=(pos2-pos1).normalized(); + dir1*=1./sqrt(dir1.y()*dir1.y()+dir1.z()*dir1.z()); + dir2*=1./sqrt(dir2.y()*dir2.y()+dir2.z()*dir2.z()); + Acts::Vector3 dir1p2=(dir1+dir2)/2.; + Acts::Vector3 dir1m2=(dir1-dir2)/2.; + double charge = dir2.y()>dir1.y()?1:-1; + double B = 0.55; + double st=2.*sqrt(dir1p2.y()*dir1p2.y()+dir1p2.z()*dir1p2.z())*sqrt(dir1m2.y()*dir1m2.y()+dir1m2.z()*dir1m2.z()); + dir2=(pos2-pos1)/2.; + double R=sqrt(dir2.y()*dir2.y()+dir2.z()*dir2.z())/st; + + double p_yz = 0.3*B*R / 1000.0; // R(mm), p(GeV), B(T) + double p_z=p_yz*dir1.z()/sqrt(dir1.y()*dir1.y()+dir1.z()*dir1.z()); + double p_y=p_z*dir1.y()/dir1.z(); + double p_x=p_z*dir1.x()/dir1.z(); + + + const Acts::Vector3 mom(p_x, p_y, p_z); + double p = mom.norm(); + msg(MSG::DEBUG)<<"!!!!!!!!!!! InitTrack momentum on layer 0: ( "<<mom.x()*1000<<", "<<mom.y()*1000<<", "<<mom.z()*1000<<", "<<p*1000<<") "<<st<<" "<<charge<<endmsg; + // build the track covariance matrix using the smearing sigmas + double sigmaU = 1000_um; + double sigmaV = 1000_um; + double sigmaPhi = 10_degree; + double sigmaTheta = 2_degree; + double sigmaQOverP = 0.20*p / (p*p); + //double sigmaQOverP = 0.02*p / (p*p); + double sigmaT0 = 1_ns; + Acts::BoundSymMatrix cov = Acts::BoundSymMatrix::Zero(); + cov(Acts::eBoundLoc0, Acts::eBoundLoc0) = sigmaU * sigmaU; + cov(Acts::eBoundLoc1, Acts::eBoundLoc1) = sigmaV * sigmaV; + cov(Acts::eBoundPhi, Acts::eBoundPhi) = sigmaPhi * sigmaPhi; + cov(Acts::eBoundTheta, Acts::eBoundTheta) = sigmaTheta * sigmaTheta; + cov(Acts::eBoundQOverP, Acts::eBoundQOverP) = sigmaQOverP * sigmaQOverP; + cov(Acts::eBoundTime, Acts::eBoundTime) = sigmaT0 * sigmaT0; + double time =0; + const Acts::Vector4 postime(pos1.x(), pos1.y(), pos1.z(),time); + Acts::CurvilinearTrackParameters InitTrackParam(postime, mom.normalized(), mom.norm(), charge, std::make_optional(std::move(cov))); + + return InitTrackParam; +} + +std::vector<Acts::CurvilinearTrackParameters> SPSimpleInitialParameterTool::getInitialParameters_1station(std::vector<Acts::Vector3> pos1, std::vector<Acts::Vector3> pos2, std::vector<Acts::Vector3> pos3) const { + std::vector<Acts::CurvilinearTrackParameters> InitTrackParams; + InitTrackParams.clear(); + + for(std::size_t i1=0;i1<pos1.size();i1++){ + for(std::size_t i2=0;i2<pos2.size();i2++){ + for(std::size_t i3=0;i3<pos3.size();i3++){ + if(fabs(pos3[i3].y()-pos2[i2].y())>1.5*fabs(pos2[i2].y()-pos1[i1].y()))continue; + if(fabs(pos3[i3].x()-pos2[i2].x())>1.5*fabs(pos2[i2].x()-pos1[i1].x()))continue; + Acts::Vector3 pstart=pos1[i1]; + Acts::Vector3 pend=(pos2[i2]+pos3[i3])/2.; + Acts::Vector3 dir=pend-pstart; + + double charge = 1; + // double B = 0.55; + + double p_yz = 100.; + //double p_yz = 0.3*B*R / 1000.0; // R(mm), p(GeV), B(T) + double p_z=p_yz*dir.y()/sqrt(dir.y()*dir.y()+dir.z()*dir.z()); + if(p_z<0)continue; + double p_y=p_z*dir.y()/dir.z(); + double p_x=p_z*dir.x()/dir.z(); + + + const Acts::Vector3 mom(p_x, p_y, p_z); + double p = mom.norm(); + msg(MSG::DEBUG)<<"!!!!!!!!!!! InitTrack momentum on layer 0: ( "<<mom.x()*1000<<", "<<mom.y()*1000<<", "<<mom.z()*1000<<", "<<p*1000<<") "<<endmsg; + // build the track covariance matrix using the smearing sigmas + double sigmaU = 2000_um; + double sigmaV = 2000_um; + double sigmaPhi = 30_degree; + double sigmaTheta = 10_degree; + double sigmaQOverP = 1.20*p / (p*p); + //double sigmaQOverP = 0.02*p / (p*p); + double sigmaT0 = 1_ns; + Acts::BoundSymMatrix cov = Acts::BoundSymMatrix::Zero(); + cov(Acts::eBoundLoc0, Acts::eBoundLoc0) = sigmaU * sigmaU; + cov(Acts::eBoundLoc1, Acts::eBoundLoc1) = sigmaV * sigmaV; + cov(Acts::eBoundPhi, Acts::eBoundPhi) = sigmaPhi * sigmaPhi; + cov(Acts::eBoundTheta, Acts::eBoundTheta) = sigmaTheta * sigmaTheta; + cov(Acts::eBoundQOverP, Acts::eBoundQOverP) = sigmaQOverP * sigmaQOverP; + cov(Acts::eBoundTime, Acts::eBoundTime) = sigmaT0 * sigmaT0; + double time =0; + const Acts::Vector4 postime(pstart.x(), pstart.y(), pstart.z(),time); + Acts::CurvilinearTrackParameters InitTrackParam(postime, mom.normalized(), mom.norm(), charge, std::make_optional(std::move(cov))); + InitTrackParams.push_back(InitTrackParam); + } + } + } + + return InitTrackParams; +} diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/TrajectoryWriterTool.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/TrajectoryWriterTool.cxx index 5eaf25b910681d92dd53a31975c6f451037f13cc..aca7bd57a3df15bfbecffc5e6afb996daffb7020 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/src/TrajectoryWriterTool.cxx +++ b/Tracking/Acts/FaserActsKalmanFilter/src/TrajectoryWriterTool.cxx @@ -162,11 +162,31 @@ void TrajectoryWriterTool::initializeTree() { m_tree->Branch("pz_smt", &m_pz_smt); m_tree->Branch("eta_smt", &m_eta_smt); m_tree->Branch("pT_smt", &m_pT_smt); + m_tree->Branch("eLOC0_ini", &m_eLOC0_ini); + m_tree->Branch("eLOC1_ini", &m_eLOC1_ini); + m_tree->Branch("ePHI_ini", &m_ePHI_ini); + m_tree->Branch("eTHETA_ini", &m_eTHETA_ini); + m_tree->Branch("eQOP_ini", &m_eQOP_ini); + m_tree->Branch("eT_ini", &m_eT_ini); + m_tree->Branch("err_eLOC0_ini", &m_err_eLOC0_ini); + m_tree->Branch("err_eLOC1_ini", &m_err_eLOC1_ini); + m_tree->Branch("err_ePHI_ini", &m_err_ePHI_ini); + m_tree->Branch("err_eTHETA_ini", &m_err_eTHETA_ini); + m_tree->Branch("err_eQOP_ini", &m_err_eQOP_ini); + m_tree->Branch("err_eT_ini", &m_err_eT_ini); + m_tree->Branch("g_x_ini", &m_x_ini); + m_tree->Branch("g_y_ini", &m_y_ini); + m_tree->Branch("g_z_ini", &m_z_ini); + m_tree->Branch("px_ini", &m_px_ini); + m_tree->Branch("py_ini", &m_py_ini); + m_tree->Branch("pz_ini", &m_pz_ini); + m_tree->Branch("eta_ini", &m_eta_ini); + m_tree->Branch("pT_ini", &m_pT_ini); } void TrajectoryWriterTool::writeout(TrajectoriesContainer trajectories, - Acts::GeometryContext geoContext) const { + Acts::GeometryContext geoContext,std::vector<Acts::CurvilinearTrackParameters> initialparameters) const { m_eventNumber = Gaudi::Hive::currentContext().eventID().event_number(); @@ -176,33 +196,60 @@ void TrajectoryWriterTool::writeout(TrajectoriesContainer trajectories, for (const auto& traj : trajectories) { m_trajNumber = iTraj; + //initial paramter + m_eLOC0_ini.push_back(initialparameters[iTraj].parameters()[Acts::eBoundLoc0]); + m_eLOC1_ini.push_back(initialparameters[iTraj].parameters()[Acts::eBoundLoc1]); + m_ePHI_ini.push_back(initialparameters[iTraj].parameters()[Acts::eBoundPhi]); + m_eTHETA_ini.push_back(initialparameters[iTraj].parameters()[Acts::eBoundTheta]); + m_eQOP_ini.push_back(initialparameters[iTraj].parameters()[Acts::eBoundQOverP]); + m_eT_ini.push_back(initialparameters[iTraj].parameters()[Acts::eBoundTime]); + + /// Smoothed parameter uncertainties + const auto &covariance_ini = *(initialparameters[iTraj]).covariance(); + m_err_eLOC0_ini.push_back( + sqrt(covariance_ini(Acts::eBoundLoc0, Acts::eBoundLoc0))); + m_err_eLOC1_ini.push_back( + sqrt(covariance_ini(Acts::eBoundLoc1, Acts::eBoundLoc1))); + m_err_ePHI_ini.push_back( + sqrt(covariance_ini(Acts::eBoundPhi, Acts::eBoundPhi))); + m_err_eTHETA_ini.push_back( + sqrt(covariance_ini(Acts::eBoundTheta, Acts::eBoundTheta))); + m_err_eQOP_ini.push_back( + sqrt(covariance_ini(Acts::eBoundQOverP, Acts::eBoundQOverP))); + m_err_eT_ini.push_back( + sqrt(covariance_ini(Acts::eBoundTime, Acts::eBoundTime))); + m_x_ini.push_back(initialparameters[iTraj].position(geoContext).x()); + m_y_ini.push_back(initialparameters[iTraj].position(geoContext).y()); + m_z_ini.push_back(initialparameters[iTraj].position(geoContext).z()); + m_px_ini.push_back(initialparameters[iTraj].momentum().x()); + m_py_ini.push_back(initialparameters[iTraj].momentum().y()); + m_pz_ini.push_back(initialparameters[iTraj].momentum().z()); + m_pT_ini.push_back(initialparameters[iTraj].transverseMomentum()); + m_eta_ini.push_back(eta(initialparameters[iTraj].position(geoContext))); + // The trajectory entry indices and the multiTrajectory const auto& [trackTips, mj] = traj.trajectory(); if (trackTips.empty()) { ATH_MSG_WARNING("Empty multiTrajectory."); + m_nMeasurements = -1; continue; } // Get the entry index for the single trajectory auto& trackTip = trackTips.front(); - std::cout<<"trackTip = "<<trackTip<<std::endl; // Collect the trajectory summary info auto trajState = Acts::MultiTrajectoryHelpers::trajectoryState(mj, trackTip); m_nMeasurements = trajState.nMeasurements; +// if(m_nMeasurements<2)continue; m_nStates = trajState.nStates; m_nOutliers = trajState.nOutliers; m_nHoles = trajState.nHoles; m_chi2_fit = trajState.chi2Sum; m_ndf_fit = trajState.NDF; - std::cout << "Track has " << trajState.nMeasurements - << " measurements and " << trajState.nHoles - << " holes and " << trajState.nOutliers - << " outliers and " << trajState.nStates - << " states " << std::endl; - + /// If it has track parameters, fill the values if (traj.hasTrackParameters(trackTip)) { @@ -261,9 +308,10 @@ void TrajectoryWriterTool::writeout(TrajectoriesContainer trajectories, // extract local and global position Acts::Vector2 local(meas[Acts::eBoundLoc0], meas[Acts::eBoundLoc1]); +const Acts::Vector3 dir = Acts::makeDirectionUnitFromPhiTheta(meas[Acts::eBoundPhi], meas[Acts::eBoundTheta]); Acts::Vector3 mom(1, 1, 1); Acts::Vector3 global = - surface.localToGlobal(geoContext, local, mom); + surface.localToGlobal(geoContext, local, dir); // fill the measurement info m_lx_hit.push_back(local[Acts::ePos0]); @@ -676,5 +724,25 @@ void TrajectoryWriterTool::clearVariables() const { m_pz_smt.clear(); m_eta_smt.clear(); m_pT_smt.clear(); + m_eLOC0_ini.clear(); + m_eLOC1_ini.clear(); + m_ePHI_ini.clear(); + m_eTHETA_ini.clear(); + m_eQOP_ini.clear(); + m_eT_ini.clear(); + m_err_eLOC0_ini.clear(); + m_err_eLOC1_ini.clear(); + m_err_ePHI_ini.clear(); + m_err_eTHETA_ini.clear(); + m_err_eQOP_ini.clear(); + m_err_eT_ini.clear(); + m_x_ini.clear(); + m_y_ini.clear(); + m_z_ini.clear(); + m_px_ini.clear(); + m_py_ini.clear(); + m_pz_ini.clear(); + m_eta_ini.clear(); + m_pT_ini.clear(); } diff --git a/Tracking/Acts/FaserActsKalmanFilter/src/components/FaserActsKalmanFilter_entries.cxx b/Tracking/Acts/FaserActsKalmanFilter/src/components/FaserActsKalmanFilter_entries.cxx index d933e0f480d2c488361f93f2dee2c9087c2e5c79..0b86d895fdd266b4df4bb9ba6ecb3b928581c9db 100755 --- a/Tracking/Acts/FaserActsKalmanFilter/src/components/FaserActsKalmanFilter_entries.cxx +++ b/Tracking/Acts/FaserActsKalmanFilter/src/components/FaserActsKalmanFilter_entries.cxx @@ -2,15 +2,19 @@ Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ -#include "FaserActsKalmanFilter/FaserActsKalmanFilterAlg.h" +//#include "FaserActsKalmanFilter/FaserActsKalmanFilterAlg.h" #include "FaserActsKalmanFilter/CombinatorialKalmanFilterAlg.h" #include "FaserActsKalmanFilter/TruthBasedInitialParameterTool.h" +#include "FaserActsKalmanFilter/SPSeedBasedInitialParameterTool.h" +#include "FaserActsKalmanFilter/SPSimpleInitialParameterTool.h" #include "FaserActsKalmanFilter/TrajectoryWriterTool.h" #include "FaserActsKalmanFilter/SimWriterTool.h" -DECLARE_COMPONENT(FaserActsKalmanFilterAlg) +//DECLARE_COMPONENT(FaserActsKalmanFilterAlg) DECLARE_COMPONENT(CombinatorialKalmanFilterAlg) DECLARE_COMPONENT(TruthBasedInitialParameterTool) +DECLARE_COMPONENT(SPSeedBasedInitialParameterTool) +DECLARE_COMPONENT(SPSimpleInitialParameterTool) DECLARE_COMPONENT(TrajectoryWriterTool) DECLARE_COMPONENT(SimWriterTool) diff --git a/Tracking/Acts/FaserActsKalmanFilter/test/CombinatorialKalmanFilterAlg.py b/Tracking/Acts/FaserActsKalmanFilter/test/CombinatorialKalmanFilterAlg.py index 3a18e531c7a862da30939e0fc03bbbd9dee99fa4..eef29095e39bc064e2dde11149be503b0d0d79ea 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/test/CombinatorialKalmanFilterAlg.py +++ b/Tracking/Acts/FaserActsKalmanFilter/test/CombinatorialKalmanFilterAlg.py @@ -10,6 +10,7 @@ from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg # from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg from TrackerPrepRawDataFormation.TrackerPrepRawDataFormationConfig import FaserSCT_ClusterizationCfg from TrackerSpacePointFormation.TrackerSpacePointFormationConfig import TrackerSpacePointFinderCfg +from TrackerSeedFinder.TrackerSeedFinderConfig import TrackerSeedFinderCfg from FaserActsKalmanFilter.CombinatorialKalmanFilterConfig import CombinatorialKalmanFilterCfg log.setLevel(DEBUG) @@ -17,6 +18,7 @@ Configurable.configurableRun3Behavior = True ConfigFlags.Input.Files = ['my.RDO.pool.root'] ConfigFlags.Output.ESDFileName = "myCKF.ESD.pool.root" +ConfigFlags.Output.AODFileName = "myCKF.AOD.pool.root" ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01" # ConfigFlags.GeoModel.FaserVersion = "FASER-01" ConfigFlags.GeoModel.Align.Dynamic = False @@ -29,16 +31,17 @@ acc.merge(PoolReadCfg(ConfigFlags)) acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags)) acc.merge(TrackerSpacePointFinderCfg(ConfigFlags)) +acc.merge(TrackerSeedFinderCfg(ConfigFlags)) acc.merge(CombinatorialKalmanFilterCfg(ConfigFlags)) -logging.getLogger('forcomps').setLevel(VERBOSE) -acc.foreach_component("*").OutputLevel = VERBOSE -acc.foreach_component("*ClassID*").OutputLevel = INFO -acc.getService("StoreGateSvc").Dump = True -acc.getService("ConditionStore").Dump = True -acc.printConfig(withDetails=True) -ConfigFlags.dump() +# logging.getLogger('forcomps').setLevel(INFO) +# acc.foreach_component("*").OutputLevel = INFO +# acc.foreach_component("*ClassID*").OutputLevel = INFO +# acc.getService("StoreGateSvc").Dump = True +# acc.getService("ConditionStore").Dump = True +# acc.printConfig(withDetails=True) +# ConfigFlags.dump() -sc = acc.run(maxEvents=-1) +sc = acc.run(maxEvents=1000) sys.exit(not sc.isSuccess()) diff --git a/Tracking/Acts/FaserActsKalmanFilter/test/CombinatorialKalmanFilterAlg_Data.py b/Tracking/Acts/FaserActsKalmanFilter/test/CombinatorialKalmanFilterAlg_Data.py new file mode 100644 index 0000000000000000000000000000000000000000..5cf53fa5fb7cb4262c4c276374d54a8ea51402ef --- /dev/null +++ b/Tracking/Acts/FaserActsKalmanFilter/test/CombinatorialKalmanFilterAlg_Data.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python + +import sys +from AthenaCommon.Logging import log, logging +from AthenaCommon.Constants import DEBUG, VERBOSE, INFO +from AthenaCommon.Configurable import Configurable +from CalypsoConfiguration.AllConfigFlags import ConfigFlags +from CalypsoConfiguration.MainServicesConfig import MainServicesCfg +from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg +from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg +from WaveRecAlgs.WaveRecAlgsConfig import WaveformReconstructionCfg +from TrackerPrepRawDataFormation.TrackerPrepRawDataFormationConfig import FaserSCT_ClusterizationCfg +from TrackerSpacePointFormation.TrackerSpacePointFormationConfig import TrackerSpacePointFinderCfg +from TrackerSeedFinder.TrackerSeedFinderConfig import TrackerSeedFinderCfg +from FaserActsKalmanFilter.CombinatorialKalmanFilterConfig import CombinatorialKalmanFilterCfg + +log.setLevel(DEBUG) +Configurable.configurableRun3Behavior = True + +ConfigFlags.Input.Files = ['/eos/project-f/faser-commissioning/TI12Data/Run-004411/Faser-Physics-004411-00000.raw'] +ConfigFlags.Output.ESDFileName = "myCKF.ESD.pool.root" +ConfigFlags.Output.AODFileName = "myCKF.AOD.pool.root" +ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01" +ConfigFlags.IOVDb.DatabaseInstance = "OFLP200" # Use MC conditions for now +ConfigFlags.Input.ProjectName = "data21" # Needed to bypass autoconfig +ConfigFlags.Input.isMC = False # Needed to bypass autoconfig +ConfigFlags.GeoModel.FaserVersion = "FASER-01" # FASER geometry +ConfigFlags.Common.isOnline = False +ConfigFlags.GeoModel.Align.Dynamic = False +ConfigFlags.Beam.NumberOfCollisions = 0. +ConfigFlags.Detector.GeometryFaserSCT = True +ConfigFlags.lock() + +acc = MainServicesCfg(ConfigFlags) +#acc.merge(PoolReadCfg(ConfigFlags)) +acc.merge(PoolWriteCfg(ConfigFlags)) +from FaserByteStreamCnvSvc.FaserByteStreamCnvSvcConfig import FaserByteStreamCnvSvcCfg +acc.merge(FaserByteStreamCnvSvcCfg(ConfigFlags)) +acc.merge(WaveformReconstructionCfg(ConfigFlags)) +acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags, DataObjectName="SCT_EDGEMODE_RDOs")) +acc.merge(TrackerSpacePointFinderCfg(ConfigFlags)) +acc.merge(TrackerSeedFinderCfg(ConfigFlags)) +acc.merge(CombinatorialKalmanFilterCfg(ConfigFlags)) + +logging.getLogger('forcomps').setLevel(VERBOSE) +acc.foreach_component("*").OutputLevel = VERBOSE +acc.foreach_component("*ClassID*").OutputLevel = INFO +acc.getService("StoreGateSvc").Dump = True +acc.getService("ConditionStore").Dump = True +acc.printConfig(withDetails=True) +ConfigFlags.dump() + +sc = acc.run(maxEvents=-1) + +sys.exit(not sc.isSuccess()) diff --git a/Waveform/WaveRecAlgs/share/PseudoSimToWaveformRecExample_jobOptions.py b/Waveform/WaveRecAlgs/share/PseudoSimToWaveformRecExample_jobOptions.py index cbcb5836850f8f1958d5e55e22eca9f6afe1f0e4..76262b58491f336ff91dab04ddb21a0b4aaeb94d 100644 --- a/Waveform/WaveRecAlgs/share/PseudoSimToWaveformRecExample_jobOptions.py +++ b/Waveform/WaveRecAlgs/share/PseudoSimToWaveformRecExample_jobOptions.py @@ -16,7 +16,7 @@ if __name__ == "__main__": log.setLevel(INFO) - ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-02" # Always needed; must match FaserVersion + ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-TB00" # Always needed; must match FaserVersion ConfigFlags.IOVDb.DatabaseInstance = "OFLP200" # Use MC conditions for now ConfigFlags.Input.ProjectName = "mc21" # Needed to bypass autoconfig ConfigFlags.Input.isMC = True # Needed to bypass autoconfig diff --git a/Waveform/WaveRecAlgs/src/RawWaveformRecAlg.cxx b/Waveform/WaveRecAlgs/src/RawWaveformRecAlg.cxx index 3c6da1c0eb5a365f469dba9acd0b2027c433c2f4..f1320c41e7dc75f5c9c8cd701dc06a92c3bab1c3 100644 --- a/Waveform/WaveRecAlgs/src/RawWaveformRecAlg.cxx +++ b/Waveform/WaveRecAlgs/src/RawWaveformRecAlg.cxx @@ -69,16 +69,8 @@ RawWaveformRecAlg::execute(const EventContext& ctx) const { ATH_MSG_DEBUG("WaveformsHitContainer '" << hitContainerHandle.name() << "' initialized"); - // Reconstruct each waveform - for( const auto& wave : *waveformHandle) { - - ATH_MSG_DEBUG("Reconstruct waveform for channel " << wave->channel()); - - // Reconstruct the hits, may be more than one, so pass container - CHECK( m_recoTool->reconstruct(*wave, clockptr, - hitContainerHandle.ptr()) ); - - } + // Reconstruct all waveforms + CHECK( m_recoTool->reconstructAll(*waveformHandle, clockptr, hitContainerHandle.ptr()) ); ATH_MSG_DEBUG("WaveformsHitContainer '" << hitContainerHandle.name() << "' filled with "<< hitContainerHandle->size() <<" items"); diff --git a/Waveform/WaveRecTools/WaveRecTools/IWaveformReconstructionTool.h b/Waveform/WaveRecTools/WaveRecTools/IWaveformReconstructionTool.h index e985cb1d66b81e0bddbee05e682798fdb0f61be8..cc10197b262f0695327f7304a84998d198300678 100644 --- a/Waveform/WaveRecTools/WaveRecTools/IWaveformReconstructionTool.h +++ b/Waveform/WaveRecTools/WaveRecTools/IWaveformReconstructionTool.h @@ -20,6 +20,7 @@ #include "xAODFaserWaveform/WaveformClock.h" class RawWaveform; +class RawWaveformContainer; ///Interface for Waveform reco algorithms class IWaveformReconstructionTool : virtual public IAlgTool @@ -31,6 +32,11 @@ class IWaveformReconstructionTool : virtual public IAlgTool virtual ~IWaveformReconstructionTool() = default; + // Reconstruct all waveforms + virtual StatusCode reconstructAll(const RawWaveformContainer& waveContainer, + const xAOD::WaveformClock* clock, + xAOD::WaveformHitContainer* container) const = 0; + // Reconstruct all peaks in a raw waveform virtual StatusCode reconstruct(const RawWaveform& wave, const xAOD::WaveformClock* clock, diff --git a/Waveform/WaveRecTools/src/WaveformReconstructionTool.cxx b/Waveform/WaveRecTools/src/WaveformReconstructionTool.cxx index 5de393166579eef162e308acd31b0b12b6a12039..7e564dae08c401bf51130dfb0813046e62cb4251 100644 --- a/Waveform/WaveRecTools/src/WaveformReconstructionTool.cxx +++ b/Waveform/WaveRecTools/src/WaveformReconstructionTool.cxx @@ -10,13 +10,12 @@ #include "WaveformReconstructionTool.h" -#include "xAODFaserWaveform/WaveformHit.h" - #include "TH1F.h" #include "TF1.h" #include "TFitResult.h" #include "TFitResultPtr.h" #include "TGraph.h" +#include "TError.h" #include <vector> #include <tuple> @@ -33,6 +32,8 @@ StatusCode WaveformReconstructionTool::initialize() { ATH_MSG_INFO( name() << "::initalize()" ); + gErrorIgnoreLevel = kFatal; // STFU! + if (m_useSimpleBaseline.value()) { ATH_MSG_INFO("Will use simple baseline estimation"); } else { @@ -42,6 +43,215 @@ WaveformReconstructionTool::initialize() { } // Reconstruction step +StatusCode +WaveformReconstructionTool::reconstructAll( + const RawWaveformContainer& waveContainer, + const xAOD::WaveformClock* clock, + xAOD::WaveformHitContainer* hitContainer) const { + + ATH_MSG_DEBUG(" reconstructAll called "); + + // Reconstruct each waveform + for( const auto& wave : waveContainer) { + + ATH_MSG_DEBUG("Reconstruct waveform for channel " << wave->channel()); + + // Reconstruct the hits, may be more than one, so pass container + CHECK( this->reconstruct(*wave, clock, hitContainer) ); + } + + if (m_ensureChannelHits) { + ATH_MSG_DEBUG("Ensure all channels have hits at peak time"); + ensureHits(waveContainer, clock, hitContainer); + } + + return StatusCode::SUCCESS; +} + +// +// Make sure we have a hit for each channel at the time when +// there is a significant pulse found in the detector +// +void +WaveformReconstructionTool::ensureHits( + const RawWaveformContainer& waveContainer, + const xAOD::WaveformClock* clock, + xAOD::WaveformHitContainer* hitContainer) const { + + ATH_MSG_DEBUG(" ensureHits called "); + + // Find peak time (most significant hit) + xAOD::WaveformHit* peakHit = NULL; + + for( const auto& hit : *hitContainer) { + + if (peakHit == NULL) { + peakHit = hit; + } else { + if ( hit->peak() > peakHit->peak() ) peakHit = hit; + } + + } + + // Didn't find anything? + if (peakHit == NULL) return; + if (peakHit->status_bit(xAOD::WaveformStatus::THRESHOLD_FAILED)) return; + + ATH_MSG_DEBUG("Found peak hit in channel " << peakHit->channel() << " at time " << peakHit->localtime()); + + // Now go through all of the channels and check if there is a hit + // close in time to the peakHit + for( const auto& wave : waveContainer) { + + // Don't worry about the peak channel, we know this has a hit... + if (wave->channel() == peakHit->channel()) continue; + + ATH_MSG_DEBUG("Checking for hit in channel " << wave->channel()); + + bool found = false; + // Look for a baseline-only hit that we can update + xAOD::WaveformHit* baselineHit = NULL; + + // There aren't so many hits, just loop over container + for( const auto& hit : *hitContainer) { + if (hit->channel() != wave->channel()) continue; + + // Is this above threshold? + if (hit->status_bit(xAOD::WaveformStatus::THRESHOLD_FAILED)) { + baselineHit = hit; + continue; + } + + // OK, this is the right channel, check the time + float dtime = abs(hit->localtime() - peakHit->localtime()); + if (dtime > m_hitTimeDifference) continue; + + // We have found a hit in the right channel at the right time + found = true; + ATH_MSG_DEBUG("Found hit in channel " << hit->channel() + << " at time " << hit->localtime()); + break; + } + + // Is there a hit? If so, go to next waveform/channel + if (found) continue; + + ATH_MSG_DEBUG("No hit found for channel " << wave->channel() + << " at time " << peakHit->localtime()); + + // Do we have a baseline-only hit we can use? + xAOD::WaveformHit* newhit = NULL; + if (baselineHit == NULL) { + // No, make a new hit here + newhit = new xAOD::WaveformHit(); + hitContainer->push_back(newhit); + + // Mark this as a secondary hit + newhit->set_status_bit(xAOD::WaveformStatus::THRESHOLD_FAILED); + newhit->set_status_bit(xAOD::WaveformStatus::SECONDARY); + + // Set digitizer channel and identifier + newhit->set_channel(wave->channel()); + newhit->set_id(wave->identify32().get_compact()); + + // Make sure we have ADC counts + if (wave->adc_counts().size() == 0) { + ATH_MSG_WARNING( "Found waveform for channel " << wave->channel() + << " with size " << wave->adc_counts().size() << "!"); + + newhit->set_status_bit(xAOD::WaveformStatus::WAVEFORM_MISSING); + continue; + } + + if (wave->adc_counts().size() != wave->n_samples()) { + ATH_MSG_WARNING( "Found waveform for channel " << wave->channel() + << " with size " << wave->adc_counts().size() + << " not equal to number of samples " << wave->n_samples()); + + newhit->set_status_bit(xAOD::WaveformStatus::WAVEFORM_INVALID); + continue; + } + + findBaseline(*wave, newhit); + + } else { + // Use the existing baseline hit + newhit = baselineHit; + } + + // Check for problems + if (newhit->status_bit(xAOD::WaveformStatus::BASELINE_FAILED)) continue; + + // Set range for windowed data + unsigned int lo_edge = peakHit->time_vector().front()/2.; + unsigned int hi_edge = peakHit->time_vector().back()/2.; + + ATH_MSG_DEBUG("Windowing waveform from " << lo_edge << " to " << hi_edge); + std::vector<float> wtime(hi_edge-lo_edge+1); + std::vector<float> wwave(hi_edge-lo_edge+1); + for (unsigned int i=lo_edge; i<=hi_edge; i++) { + unsigned int j = i-lo_edge; + wtime[j] = 2.*i; + wwave[j] = newhit->baseline_mean() - wave->adc_counts()[i]; + //ATH_MSG_DEBUG(" Time: " << wtime[j] << " Wave: " << wwave[j]); + } + + newhit->set_time_vector(wtime); + newhit->set_wave_vector(wwave); + + // + // Find some raw values + WaveformFitResult raw = findRawHitValues(wtime, wwave); + newhit->set_peak(raw.peak); + newhit->set_mean(raw.mean); + newhit->set_width(raw.sigma); + newhit->set_integral(raw.integral); + newhit->set_localtime(raw.mean); + newhit->set_raw_peak(raw.peak); + newhit->set_raw_integral(raw.integral); + + // + // Find time from clock + if (!clock || (clock->frequency() <= 0.)) { + newhit->set_status_bit(xAOD::WaveformStatus::CLOCK_INVALID); + newhit->set_bcid_time(-1.); + } else { + newhit->set_bcid_time(clock->time_from_clock(newhit->localtime())); + } + + } // End of loop over waveContainer +} + +// Find the baseline +WaveformBaselineData& +WaveformReconstructionTool::findBaseline(const RawWaveform& raw_wave, + xAOD::WaveformHit* hit) const { + + // + // Find baseline + static WaveformBaselineData baseline; + + if (m_useSimpleBaseline.value()) + baseline = findSimpleBaseline(raw_wave); + else + baseline = findAdvancedBaseline(raw_wave); + + if (!(baseline.valid)) { + ATH_MSG_WARNING("Failed to reconstruct baseline!"); + + hit->set_baseline_mean(0.); + hit->set_baseline_rms(-1.); + hit->set_status_bit(xAOD::WaveformStatus::BASELINE_FAILED); + + } else { + // Save baseline to hit collection object + hit->set_baseline_mean(baseline.mean); + hit->set_baseline_rms(baseline.rms); + } + + return baseline; +} + StatusCode WaveformReconstructionTool::reconstruct(const RawWaveform& raw_wave, const xAOD::WaveformClock* clock, @@ -64,16 +274,15 @@ WaveformReconstructionTool::reconstruct(const RawWaveform& raw_wave, hit->set_channel(raw_wave.channel()); hit->set_id(raw_wave.identify32().get_compact()); - // - // Make some sanity checks on the waveform data + // Make sure we have ADC counts if (raw_wave.adc_counts().size() == 0) { ATH_MSG_WARNING( "Found waveform for channel " << raw_wave.channel() << " with size " << raw_wave.adc_counts().size() << "!"); hit->set_status_bit(xAOD::WaveformStatus::WAVEFORM_MISSING); return StatusCode::SUCCESS; - } - + } + if (raw_wave.adc_counts().size() != raw_wave.n_samples()) { ATH_MSG_WARNING( "Found waveform for channel " << raw_wave.channel() << " with size " << raw_wave.adc_counts().size() @@ -83,28 +292,12 @@ WaveformReconstructionTool::reconstruct(const RawWaveform& raw_wave, return StatusCode::SUCCESS; } - // - // Find baseline - WaveformBaselineData baseline; - - if (m_useSimpleBaseline.value()) - baseline = findSimpleBaseline(raw_wave); - else - baseline = findAdvancedBaseline(raw_wave); - - if (!(baseline.valid)) { - ATH_MSG_WARNING("Failed to reconstruct baseline!"); - - hit->set_baseline_mean(0.); - hit->set_baseline_rms(-1.); - hit->set_status_bit(xAOD::WaveformStatus::BASELINE_FAILED); - - return StatusCode::SUCCESS; - } + // Find the baseline + WaveformBaselineData baseline = findBaseline(raw_wave, hit); - // Save baseline to hit collection object - hit->set_baseline_mean(baseline.mean); - hit->set_baseline_rms(baseline.rms); + // Check that we have data to work with + // If any status bits are set, this is bad + if (hit->status()) return StatusCode::SUCCESS; // // Create baseline-subtracted data array for both time and signal @@ -349,10 +542,19 @@ WaveformReconstructionTool::findAdvancedBaseline(const RawWaveform& raw_wave) co TH1F h1("", "", nbins, xlo, xhi); // Fill this histogram with the waveform + // Only use a subset, based on where we think there won't be signal + const std::vector<unsigned int>& counts = raw_wave.adc_counts(); + for (int i=m_baselineSampleLo; i<=m_baselineSampleHi; i++) { + //ATH_MSG_INFO( "Entry " << i << " Value " << counts[i] ); + h1.Fill(counts[i]); + } + + /* for (auto value : raw_wave.adc_counts()) { //ATH_MSG_DEBUG( "Found value " << value ); h1.Fill(value); } + */ // Find max bin int maxbin = h1.GetMaximumBin(); @@ -366,8 +568,8 @@ WaveformReconstructionTool::findAdvancedBaseline(const RawWaveform& raw_wave) co ATH_MSG_DEBUG( "Filling 2nd histogram from " << xlo << " to " << xhi); TH1F h2("", "", nbins, xlo, xhi); - for (auto value : raw_wave.adc_counts()) { - h2.Fill(value); + for (int i=m_baselineSampleLo; i<=m_baselineSampleHi; i++) { + h2.Fill(counts[i]); } // Start with full histogram range @@ -459,7 +661,12 @@ WaveformReconstructionTool::findRawHitValues(const std::vector<float> time, cons rfit.integral = 2*tot; // Factor of 2 because at 500 MHz, dt = 2 ns rfit.time = rfit.mean; - ATH_MSG_DEBUG( "Initial Mean: " << rfit.mean << " RMS: " << rfit.sigma << " Peak: " << rfit.peak); + ATH_MSG_DEBUG( + "Initial Mean: " << rfit.mean + << " RMS: " << rfit.sigma + << " Peak: " << rfit.peak + << " Integral: " << rfit.integral + ); // Fix bad values if (isnan(rfit.sigma)) { @@ -467,6 +674,12 @@ WaveformReconstructionTool::findRawHitValues(const std::vector<float> time, cons rfit.sigma = 2.; } + if (rfit.mean < time.front() || rfit.mean > time.back()) { + rfit.mean = (3*time.front() + time.back())/4.; // Set time to 1/4 of way through window + ATH_MSG_DEBUG("Found mean: " << rfit.time << " out of range " << time.front() << "-" << time.back() << " Replace with " << rfit.mean); + rfit.time = rfit.mean; + } + return rfit; } diff --git a/Waveform/WaveRecTools/src/WaveformReconstructionTool.h b/Waveform/WaveRecTools/src/WaveformReconstructionTool.h index 1bb0f20d4d2901468fa9982fd7bbed26c9c2d73b..7a39f883434051173099d3702e9643fb64cc9f51 100644 --- a/Waveform/WaveRecTools/src/WaveformReconstructionTool.h +++ b/Waveform/WaveRecTools/src/WaveformReconstructionTool.h @@ -14,6 +14,8 @@ #include "WaveRecTools/IWaveformReconstructionTool.h" #include "WaveRawEvent/RawWaveform.h" +#include "WaveRawEvent/RawWaveformContainer.h" +#include "xAODFaserWaveform/WaveformHit.h" #include "WaveformBaselineData.h" #include "WaveformFitResult.h" @@ -35,25 +37,40 @@ class WaveformReconstructionTool: public extends<AthAlgTool, IWaveformReconstruc /// Retrieve the necessary services in initialize StatusCode initialize(); + /// Reconstruct all hits from waveform container + virtual StatusCode reconstructAll(const RawWaveformContainer& waveContainer, + const xAOD::WaveformClock* clock, + xAOD::WaveformHitContainer* hitContainer) const; + /// Reconstruct hits from waveform virtual StatusCode reconstruct(const RawWaveform& wave, const xAOD::WaveformClock* clock, - xAOD::WaveformHitContainer* container) const; + xAOD::WaveformHitContainer* hitContainer) const; private: // // Baseline Estimation Parameters BooleanProperty m_useSimpleBaseline{this, "UseSimpleBaseline", false}; + + // Minimum number of samples needed to calculate simple baseline + // Just average these first n values IntegerProperty m_samplesForBaselineAverage{this, "SamplesForBaselineAverage", 40}; + // - // Parameters of initial histogram to find baseline max + // Parameters for advanced baseline determination + // Parameters of initial histogram to find most likely ADC reading // Range and bins to use, ratio should be an integer (bin width) IntegerProperty m_baselineRange{this, "BaselineRange", 16000}; IntegerProperty m_baselineRangeBins{this, "BaselineRangeBins", 320}; + // Range of samples to use to find baseline (to avoid signal contamination) + // In samples (2 ns intervals) so 350 -> 700 ns in digitizer window + IntegerProperty m_baselineSampleLo{this, "BaselineSampleLo", 0}; + IntegerProperty m_baselineSampleHi{this, "BaselineSampleHi", 350}; + // // Parameters for the Gaussian fit to the baseline peak (in counts) // Range is total range to use to find truncated mean and width @@ -67,8 +84,8 @@ class WaveformReconstructionTool: public extends<AthAlgTool, IWaveformReconstruc // // Window to define fitting range, in samples (2ns/sample) - IntegerProperty m_windowStart{this, "FitWindowStart", -10}; - IntegerProperty m_windowWidth{this, "FitWindowWidth", 50}; + IntegerProperty m_windowStart{this, "FitWindowStart", -15}; + IntegerProperty m_windowWidth{this, "FitWindowWidth", 60}; // // Remove overflow values from CB fit @@ -82,9 +99,19 @@ class WaveformReconstructionTool: public extends<AthAlgTool, IWaveformReconstruc // Fraction of peak to set local hit time FloatProperty m_timingPeakFraction{this, "TimingPeakFraction", 0.45}; + // + // Ensure each channel has a waveform hit at time of most significant + // hit in the event + BooleanProperty m_ensureChannelHits{this, "EnsureChannelHits", true}; + // Max Time difference in ns to say a hit exists in a different channel + FloatProperty m_hitTimeDifference{this, "HitTimeDifference", 10.}; + // Baseline algorithms WaveformBaselineData& findSimpleBaseline(const RawWaveform& wave) const; WaveformBaselineData& findAdvancedBaseline(const RawWaveform& wave) const; + WaveformBaselineData& findBaseline(const RawWaveform& wave, + xAOD::WaveformHit* hit) const; + // Find peak in wave, return windowed region in windowed_time and windowed_wave // Windowed region is removed from original vectors @@ -112,6 +139,11 @@ class WaveformReconstructionTool: public extends<AthAlgTool, IWaveformReconstruc const std::vector<float> wave) const; + /// Create hit in all channels at time of peak signal + void ensureHits(const RawWaveformContainer& waveContainer, + const xAOD::WaveformClock* clock, + xAOD::WaveformHitContainer* hitContainer) const; + }; #endif // WAVERECTOOLS_WAVEFORMRECONSTRUCTIONTOOL_H diff --git a/faser-common b/faser-common index 89ce6a07128eb2ebc367b6b68f29c9c88220e3e6..5124b0e78dbcc4a05c22f511700d5dbcdb4808df 160000 --- a/faser-common +++ b/faser-common @@ -1 +1 @@ -Subproject commit 89ce6a07128eb2ebc367b6b68f29c9c88220e3e6 +Subproject commit 5124b0e78dbcc4a05c22f511700d5dbcdb4808df diff --git a/graphics/VTI12/README.md b/graphics/VTI12/README.md index d6e0311a08559002da6f750fb31e984be5a42564..708260f7e77ac3591b3d629b1f6f76107b0a6eb8 100644 --- a/graphics/VTI12/README.md +++ b/graphics/VTI12/README.md @@ -10,6 +10,6 @@ Note that VP1PLUGINPATH can be ninja-changed by asetup, and if it does not inclu You can also give the -detdescr="FASER-01" (baseline detector), -detdescr="FASER-02" (baseline + IFT), -detdescr="FASERNU-02" (baseline + IFT + emulsion) or -detdescr="FASER-TB00" (2021 Test-beam) to specify the geometry. -You also need either -globcond="OFLCOND-FASER-01" (baseline) or -globcond="OFLCOND-FASER-02" (IFT with or without emulsion, or Test-beam) flags to specify the conditions. +You also need either -globcond="OFLCOND-FASER-01" (baseline) or -globcond="OFLCOND-FASER-02" (IFT with or without emulsion), or -globcond="OFLCOND-FASER-TB00" (test-beam) flags to specify the conditions. The event display has no way to determine the right values for these settings (it defaults to FASER-01 and OFLCOND-FASER-01). \ No newline at end of file diff --git a/graphics/VTI12/VTI12Plugins/VTI12FaserPlugin/CMakeLists.txt b/graphics/VTI12/VTI12Plugins/VTI12FaserPlugin/CMakeLists.txt index 0b3f7d70f2a29d83f80db64ff20521b05b90d69c..da838e26dfb3c16ffacee2b4a6f6c851467bfaff 100644 --- a/graphics/VTI12/VTI12Plugins/VTI12FaserPlugin/CMakeLists.txt +++ b/graphics/VTI12/VTI12Plugins/VTI12FaserPlugin/CMakeLists.txt @@ -16,4 +16,4 @@ atlas_add_library( VTI12FaserPlugin VTI12FaserPlugin/*.h src/*.cxx src/*.qrc PUBLIC_HEADERS VTI12FaserPlugin LINK_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets - PRIVATE_LINK_LIBRARIES VP1Base VTI12GuideLineSystems VTI12GeometrySystems VTI12SimHitSystems VTI12RawDataSystems VTI12TrackSystems) + PRIVATE_LINK_LIBRARIES VP1Base VTI12GuideLineSystems VTI12GeometrySystems VTI12SimHitSystems VTI12RawDataSystems VTI12PRDSystems VTI12TrackSystems) diff --git a/graphics/VTI12/VTI12Plugins/VTI12FaserPlugin/src/VP1FaserChannel.cxx b/graphics/VTI12/VTI12Plugins/VTI12FaserPlugin/src/VP1FaserChannel.cxx index 478b929050e0daab47b4b7a3df1b3bd375cc142e..daef7351c106196be0292cacac462645034360a4 100755 --- a/graphics/VTI12/VTI12Plugins/VTI12FaserPlugin/src/VP1FaserChannel.cxx +++ b/graphics/VTI12/VTI12Plugins/VTI12FaserPlugin/src/VP1FaserChannel.cxx @@ -18,11 +18,12 @@ #include "VTI12GuideLineSystems/VP1GuideLineSystem.h" #include "VTI12SimHitSystems/VP1SimHitSystem.h" #include "VTI12RawDataSystems/VP1RawDataSystem.h" +#include "VTI12PRDSystems/VP1PrepRawDataSystem.h" #include "VP1Base/VP1QtUtils.h" VP1FaserChannel::VP1FaserChannel() : IVP13DStandardChannelWidget(VP1CHANNELNAMEINPLUGIN(VP1FaserChannel,"Faser"), - "This channel shows geometry, hits and tracks.", + "This channel shows geometry, hits, clusters, spacepoints and tracks.", "Dave Casper dcasper@uci.edu") { } @@ -30,6 +31,7 @@ VP1FaserChannel::VP1FaserChannel() void VP1FaserChannel::init() { addSystem(new VP1TrackSystem); + addSystem(new VP1PrepRawDataSystem); addSystem(new VP1RawDataSystem); addSystem(new VP1SimHitSystem); addSystem(new VP1GeometrySystem); diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/CMakeLists.txt b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..c065a1849b34c23bfae3986eac831a6c86dbea9a --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration + +# Declare the package name: +atlas_subdir( VTI12PRDSystems ) + +# External dependencies: +find_package( Coin3D ) +find_package( Qt5 COMPONENTS Core Gui Widgets) +find_package( GeoModel COMPONENTS GeoModelKernel ) + +# Generate UI files automatically: +set( CMAKE_AUTOUIC TRUE ) +# Generate MOC files automatically: +set( CMAKE_AUTOMOC TRUE ) + +# Component(s) in the package: +atlas_add_library( VTI12PRDSystems VTI12PRDSystems/*.h src/*.cxx + PUBLIC_HEADERS VTI12PRDSystems + PRIVATE_INCLUDE_DIRS ${COIN3D_INCLUDE_DIRS} + ${CMAKE_CURRENT_BINARY_DIR} + LINK_LIBRARIES ${GEOMODEL_LIBRARIES} GeoPrimitives TrackerPrepRawData TrackerReadoutGeometry TrkPrepRawData TrackerSpacePoint VP1Base VTI12Utils Qt5::Core Qt5::Gui + PRIVATE_LINK_LIBRARIES ${COIN3D_LIBRARIES} AthContainers EventPrimitives GeoModelUtilities TrackerIdentifier TrkCompetingRIOsOnTrack TrkMeasurementBase TrkRIO_OnTrack TrkSegment TrkSurfaces TrkTrack VTI12GuideLineSystems VP1HEPVis ) diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDCollHandleBase.h b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDCollHandleBase.h new file mode 100644 index 0000000000000000000000000000000000000000..b28bfea064a4ecef295aae29bd136d3f4f60f962 --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDCollHandleBase.h @@ -0,0 +1,154 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS and FASER collaborations +*/ + +#ifndef PRDCOLLECTIONHANDLEBASE_H +#define PRDCOLLECTIONHANDLEBASE_H + +#include "VP1Base/VP1StdCollection.h" +#include "VTI12PRDSystems/PRDDetTypes.h" +#include <vector> + +class PRDSysCommonData; +class PRDSystemController; +class PRDHandleBase; +class VP1ExtraSepLayerHelper; +class SoSeparator; +class SoMaterial; +namespace Trk { class PrepRawData; } + +class PRDCollHandleBase : public VP1StdCollection { + + Q_OBJECT + +public: + + PRDCollHandleBase(PRDDetType::Type,PRDSysCommonData*,const QString& key) ; + virtual void init(VP1MaterialButtonBase* mat=0);//reimplementations must start with a call to this. + virtual ~PRDCollHandleBase(); + + //Called from init(). Should set current cut values and + //connections with controller to monitor future changes. Reimplement + //the ..Specific method to setup subsystem specific settings. + void setupSettingsFromController(PRDSystemController*); +protected: + virtual void setupSettingsFromControllerSpecific(PRDSystemController*) {}; +public: + + /////////////////////////////////////////////////////////// + // For loading the data and resetting after each event: // + /////////////////////////////////////////////////////////// + + virtual bool load(); + + PRDSysCommonData * common() const { return m_common; } + + //For use by the handles: + VP1ExtraSepLayerHelper * sephelperDetailedNodes () const; + VP1ExtraSepLayerHelper * sephelperSimpleNodes() const; + SoMaterial * highLightMaterial() const; + + //If highlight outliers is set, other highlight modes (TRT HT, ...) will be ignored. + //Other highlight modes are indicated by the return value of highLight() in the PRDHandleBase's + bool highLightOutliers() const; + double highLightWeight() const { return m_highlightweight; } + + bool drawErrors() const; + bool drawRDOs() const; + + + //Detail level of shown prds: + enum DETAIL { SIMPLE, DETAILED, AUTO };//AUTO => Use Level of detail (SoLOD nodes) to switch between simple/detailed shapes. + static QString toString(const DETAIL&); + + void getLODSeparators(int index, VP1ExtraSepLayerHelper*& sephelper_detail,VP1ExtraSepLayerHelper*& sephelper_simple); + + enum COLOURMETHOD { ByTechOnly, BySegment, ByTrack, BySegmentAndTrack }; + static QString toString(const COLOURMETHOD&); + COLOURMETHOD colourMethod() const { return m_colourmethod; } + bool colourByTracks() const { return m_colourmethod==ByTrack||m_colourmethod==BySegmentAndTrack; } + bool colourBySegments() const { return m_colourmethod==BySegment||m_colourmethod==BySegmentAndTrack; } + + DETAIL detailLevel() const; + bool simpleDetailLevel() const { return detailLevel()==SIMPLE; } +signals: + void detailLevelChanged(); +public slots: + void setGeneralPRDDetailLevel(DETAIL); + void setColourMethod(PRDCollHandleBase::COLOURMETHOD); + void setDrawErrors(bool); + void setDrawRDOs(bool); + void setHighLightOutliers(bool); + void setHighLightWeight(const double&); + void setAllowedEta(const VP1Interval&); + void setAllowedPhi(const QList<VP1Interval>&); + +private slots: + void detailComboBoxItemChanged(); + +protected: + virtual PRDHandleBase* addPRD(const Trk::PrepRawData*) = 0;//Return pointer to the handle. Base class (this) will own it. + + virtual DETAIL defaultDetailLevel() const { return AUTO; } + //Use to loop over prds in derived classes: + void addHandle(PRDHandleBase*);//All handles must be added here (so they can be retrieved by the next methods). + std::vector<PRDHandleBase*>& getPrdHandles(); + const std::vector<PRDHandleBase*>& getPrdHandles() const; + + virtual void postLoadInitialisation() {} + virtual bool cut(PRDHandleBase*) = 0;//Return true if should be shown (based on various cuts), false otherwise. + virtual void eraseEventDataSpecific() {} + + //Utility (fixme: put in utility class elsewhere). + template <class T> void cleanupPtrContainer(T&) const;//Delete pointers and calls .clear() + // template <class T> void cleanupNodeContainer(T&) const;//unref's pointers and calls .clear() + + virtual float lodArea() const { return 500.0f*500.0f; }//Reimplement Override to tune LOD shift for a given collection. + + void recheckCutStatus(PRDHandleBase*);//Call in derived classes for handles that might be effected by a change in cuts. + + //Convenience methods which can be called from derived classes (but specialised procedures might be more optimal) + void recheckCutStatusOfAllHandles(); + void recheckCutStatusOfAllVisibleHandles(); + void recheckCutStatusOfAllNotVisibleHandles(); + +public: + int nShownHandles() { return m_nshownhandles; } + + //For use only by PRDHandleBase::setVisible(..): + void incrementNShownHandles() { ++m_nshownhandles; } + void decrementNShownHandles() { --m_nshownhandles; } + +protected: + qint32 provideCollTypeID() const; + virtual QString provideText() const; + virtual void assignDefaultMaterial(SoMaterial*) const; + virtual QColor defaultColor() const = 0;//Will be used in assignDefaultMaterial + QString provideSection() const; + QString provideSectionToolTip() const; + QList<QWidget*> provideExtraWidgetsForGuiRow() const; + QByteArray extraWidgetsState() const; + void setExtraWidgetsState(const QByteArray&); +private slots: + void collVisibilityChanged(bool); +private: + + class Imp; + Imp * m_d; + + PRDSysCommonData * m_common; + int m_nshownhandles; + COLOURMETHOD m_colourmethod; + double m_highlightweight; +}; + +//Fixme: Move elsewhere (at least to our cxx!): +template <class T> void PRDCollHandleBase::cleanupPtrContainer(T&t) const +{ + typename T::iterator it(t.begin()), itE(t.end()); + for (;it!=itE;++it) + delete *it; + t.clear(); +} + +#endif diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDCollHandle_SCT.h b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDCollHandle_SCT.h new file mode 100644 index 0000000000000000000000000000000000000000..5aed81dfa215ef0c967091edce87a3212ccda0c4 --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDCollHandle_SCT.h @@ -0,0 +1,43 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PRDCOLLHANDLE_SCT_H +#define PRDCOLLHANDLE_SCT_H + +#include "VTI12PRDSystems/PRDCollHandleBase.h" +#include "VTI12PRDSystems/PRDCommonFlags.h" + +class PRDCollHandle_SCT : public PRDCollHandleBase { + + Q_OBJECT + +public: + + static QStringList availableCollections(IVP1System*);//For the collection widget. + + PRDCollHandle_SCT(PRDSysCommonData *,const QString& key); + virtual ~PRDCollHandle_SCT(); + +public slots: + void setPartsFlags(PRDCommonFlags::TrackerPartsFlags);//BarrelA, BarrelC, EndcapA, EndcapC + void setExcludeIsolatedClusters(bool); + +protected: + virtual PRDHandleBase * addPRD(const Trk::PrepRawData*) override; + virtual bool cut(PRDHandleBase*) override; + + virtual void eraseEventDataSpecific() override; + virtual void postLoadInitialisation() override; + virtual void setupSettingsFromControllerSpecific(PRDSystemController*) override; + virtual float lodArea() const override { return 800.0f*800.0f; } + virtual QColor defaultColor() const override; + +private: + + class Imp; + Imp * m_d; + +}; + +#endif diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDCollHandle_SpacePoints.h b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDCollHandle_SpacePoints.h new file mode 100644 index 0000000000000000000000000000000000000000..3727c491885bccee19611358d1abe1cfa0d2cdf7 --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDCollHandle_SpacePoints.h @@ -0,0 +1,56 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS and FASER collaborations +*/ + + +//////////////////////////////////////////////////////////////// +// // +// Header file for class PRDCollHandle_SpacePoints // +// // +// Description: Collection handles for space points. // +// For historical reasons this inherits from // +// the PRD class. // +// // +// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) // +// Initial version: September 2008 // +// // +//////////////////////////////////////////////////////////////// + +#ifndef PRDCOLLHANDLE_SPACEPOINTS_H +#define PRDCOLLHANDLE_SPACEPOINTS_H + +#include "VTI12PRDSystems/PRDCollHandleBase.h" +#include "VTI12PRDSystems/PRDCommonFlags.h" + +class PRDCollHandle_SpacePoints : public PRDCollHandleBase { + + Q_OBJECT + +public: + + static QStringList availableCollections(IVP1System*);//For the collection widget. + + PRDCollHandle_SpacePoints(PRDSysCommonData*,const QString& key); + virtual ~PRDCollHandle_SpacePoints(); + +protected: + virtual PRDHandleBase* addPRD(const Trk::PrepRawData*) override { return 0; } + virtual bool load() override; + virtual bool cut(PRDHandleBase*) override; + virtual void eraseEventDataSpecific() override; + virtual void postLoadInitialisation() override; + virtual void setupSettingsFromControllerSpecific(PRDSystemController*) override; + virtual float lodArea() const override { return 800.0f*800.0f; } + virtual QColor defaultColor() const override; + +public slots: + void setPartsFlags(PRDCommonFlags::TrackerPartsFlags);//Interface, Upstream, Central, Downstream + +private: + + class Imp; + Imp * m_d; + +}; + +#endif diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDCommonFlags.h b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDCommonFlags.h new file mode 100644 index 0000000000000000000000000000000000000000..4a82f911cb779cea06922d5b6af52c32ada769ce --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDCommonFlags.h @@ -0,0 +1,40 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS and FASER collaborations +*/ + +//////////////////////////////////////////////////////////////// +// // +// Common flags shared by several subsystems // +// // +// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) // +// Initial version: November 2007 // +// // +//////////////////////////////////////////////////////////////// + +#ifndef PRDCOMMONFLAGS_H +#define PRDCOMMONFLAGS_H + +#include <QFlags> + +class PRDCommonFlags { +public: + + enum TrackerPartsFlag { + None = 0x000000, + Interface = 0x000001, + Upstream = 0x000002, + Central = 0x000004, + Downstream = 0x000008, + AllBaseline = 0x00000E, + All = 0x00000F + }; + Q_DECLARE_FLAGS(TrackerPartsFlags, TrackerPartsFlag) + +private: + PRDCommonFlags(); + ~PRDCommonFlags(); +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(PRDCommonFlags::TrackerPartsFlags) + +#endif diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDDetTypes.h b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDDetTypes.h new file mode 100644 index 0000000000000000000000000000000000000000..dc3c0f31a866a1d381f7631118438aa88bcebaf9 --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDDetTypes.h @@ -0,0 +1,25 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS and FASER collaborations +*/ + +#ifndef PRDDETTYPES_H +#define PRDDETTYPES_H + +#include <QString> + +class PRDDetType { +public: + enum Type { + SCT, SpacePoints + }; + static QString typeToString(const Type&); + static Type stringToType(const QString&str, bool & status); + static qint32 typeToInt(const Type& t); + static Type intToType(const qint32&i, bool & status); + +private: + PRDDetType(); +}; + + +#endif diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDHandleBase.h b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDHandleBase.h new file mode 100644 index 0000000000000000000000000000000000000000..c91208db1851db786955f52347e5479703482b4d --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDHandleBase.h @@ -0,0 +1,87 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef PRDHANDLEBASE_H +#define PRDHANDLEBASE_H + +//Fixme: check and doublecheck how to reduce memory used per prd (also includes maps in collhandle). + +#include "VTI12PRDSystems/PRDSysCommonData.h" + +#include "GeoModelKernel/GeoPVConstLink.h" + +//#include "CLHEP/Geometry/Transform3D.h" +#include "GeoPrimitives/GeoPrimitives.h" + +#include <QFlags> +#include <QStringList> + + + + +class PRDCollHandleBase; +class SoMaterial; +class SoNode; +class SoTransform; +class SoSeparator; + +namespace Trk { + class PrepRawData; +} + +class TracksAndSegments; + +class PRDHandleBase { +public: + + PRDHandleBase(PRDCollHandleBase*); + virtual ~PRDHandleBase(); + + void setVisible(bool);//use by the collection handle. + bool visible() const { return m_visible; } + virtual void buildShapes(SoNode*&shape_simple, SoNode*&shape_detailed) = 0; + virtual int regionIndex() { return 0; }//prds near each other should return same index (used for optimal LOD usage in AUTO detail mode) (only called once/event) + virtual bool highLight() const { return false; }//Return true to get hit highlighted (for e.g. a TRT hits with HT). + //Outlier highlighting overrides this and is handled in the base classes. + virtual bool transformUsesSurfacePositionOnly() const { return false; }//Override and return true if should use just the surface position. + + //Return current shapes (0 if not built at the moment): + SoSeparator* sepSimple() const; + SoSeparator* sepDetailed() const; + + PRDSysCommonData * common() const { return m_common; } + + virtual Amg::Vector3D center() const;//Default impl. returns positionPRD() + Amg::Vector3D positionPRD() const;// The center of the getPRD() + Amg::Vector3D positionSecondPRD() const;//The center of the getSecondPRD(). returns (0,0,0) if not available. + + //For PRDCollHandleBase only: + Amg::Transform3D getTransform_CLHEP() const; + virtual SoTransform * createTransform() const; + void update3DObjects();//Call whenever some setting changes in a way which requires changes to the shape of the 3D representation of the prd. + void updateMaterial(); + + virtual QStringList clicked() const;//Called when user selects the node. The returned strings will be displayed in the textbox. + + PRDCollHandleBase * collHandle() const; + + virtual const Trk::PrepRawData * getPRD() const = 0;//Reimplement to allow access to prd pointer in a generic way. + virtual const Trk::PrepRawData * getSecondPRD() const { return 0; }//For SCT spacepoints + + virtual bool isSane() const {return true;} //!< Returns false if the PRD is not safe to draw +private: + + // Illegal to copy/assign a PRDHandleBase: + PRDHandleBase(const PRDHandleBase & ); + PRDHandleBase & operator= (const PRDHandleBase & ); + + class Imp; + Imp * m_d; + PRDSysCommonData * m_common; +// inline void registerTransform(SoTransform*); + bool m_visible;//Here for inlining + +}; + +#endif diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDHandle_SCT.h b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDHandle_SCT.h new file mode 100644 index 0000000000000000000000000000000000000000..59aad50caf42a92f7a4245285642c0c6239dc584 --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDHandle_SCT.h @@ -0,0 +1,34 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS and FASER collaborations +*/ + +#ifndef PRDHANDLE_SCT_H +#define PRDHANDLE_SCT_H + +#include "VTI12PRDSystems/PRDHandleBase.h" +#include "TrackerPrepRawData/FaserSCT_Cluster.h" + +class PRDCollHandle_SCT; + +class PRDHandle_SCT : public PRDHandleBase { +public: + + PRDHandle_SCT(PRDCollHandle_SCT*,const Tracker::FaserSCT_Cluster*); + virtual ~PRDHandle_SCT() {}; + + void buildShapes(SoNode*&shape_simple, SoNode*&shape_detailed); + int regionIndex(); + + const Tracker::FaserSCT_Cluster * cluster() const { return m_cluster; } + const Trk::PrepRawData * getPRD() const { return m_cluster; } + bool isInterface() const { return m_cluster->detectorElement()->isInterface(); } + bool isUpstream() const { return m_cluster->detectorElement()->isUpstream(); } + bool isCentral() const { return m_cluster->detectorElement()->isCentral(); } + bool isDownstream() const { return m_cluster->detectorElement()->isDownstream(); } + +private: + const Tracker::FaserSCT_Cluster* m_cluster; + +}; + +#endif diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDHandle_SpacePoint.h b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDHandle_SpacePoint.h new file mode 100644 index 0000000000000000000000000000000000000000..55fcc919ee95d632ab335b7e9cdbb34e2cf8c67e --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDHandle_SpacePoint.h @@ -0,0 +1,70 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS and FASER collaborations +*/ + + +//////////////////////////////////////////////////////////////// +// // +// Header file for class PRDHandle_SpacePoint // +// // +// Description: Handles for SpacePoints (not really "PRDs") // +// // +// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) // +// Initial version: September 2008 // +// // +//////////////////////////////////////////////////////////////// + +#ifndef PRDHANDLE_SPACEPOINT_H +#define PRDHANDLE_SPACEPOINT_H + +#include "VTI12PRDSystems/PRDHandleBase.h" + +#include "TrackerReadoutGeometry/SiDetectorElement.h" +#include "TrackerSpacePoint/FaserSCT_SpacePoint.h" +#include "TrkPrepRawData/PrepRawData.h" + +#include "GeoPrimitives/GeoPrimitives.h" + + + +// namespace Trk { class SpacePoint; } +class PRDCollHandle_SpacePoints; + +class PRDHandle_SpacePoint : public PRDHandleBase { +public: + + PRDHandle_SpacePoint(PRDCollHandle_SpacePoints*, const Tracker::FaserSCT_SpacePoint*); + virtual ~PRDHandle_SpacePoint(); + + void buildShapes(SoNode*&shape_simple, SoNode*&shape_detailed); + int regionIndex(); + + Amg::Vector3D center() const { return m_sp->globalPosition(); } + +//SCT spacepoints have two clusters, Pixels one: + bool isSCT() { return getSecondPRD(); } + + const Tracker::FaserSCT_SpacePoint * spacePoint() const { return m_sp; } + const Trk::PrepRawData * getPRD() const { return m_sp->clusterList().first; } + const Trk::PrepRawData * getSecondPRD() const { return m_sp->clusterList().second; } + bool isInterface() const { return dynamic_cast<const TrackerDD::SiDetectorElement*>(getPRD()->detectorElement())->isInterface(); } + bool isUpstream() const { return dynamic_cast<const TrackerDD::SiDetectorElement*>(getPRD()->detectorElement())->isUpstream(); } + bool isCentral() const { return dynamic_cast<const TrackerDD::SiDetectorElement*>(getPRD()->detectorElement())->isCentral(); } + bool isDownstream() const { return dynamic_cast<const TrackerDD::SiDetectorElement*>(getPRD()->detectorElement())->isDownstream(); } + // bool isBarrel() const + // { return static_cast<const InDetDD::SiDetectorElement*>(getPRD()->detectorElement())->isBarrel(); } + // bool isPositiveZ() const { return m_sp->globalPosition().z() > 0.0; } + +private: + + // Uncomment to make it illegal to copy/assign a PRDHandle_SpacePoint: + // PRDHandle_SpacePoint( const PRDHandle_SpacePoint & ); + // PRDHandle_SpacePoint & operator= ( const PRDHandle_SpacePoint & ); + + const Tracker::FaserSCT_SpacePoint* m_sp; + class Imp; + Imp * m_d; + +}; + +#endif diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDSysCommonData.h b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDSysCommonData.h new file mode 100644 index 0000000000000000000000000000000000000000..3c522891b4234932237f9d0f793cfe9b49e72063 --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDSysCommonData.h @@ -0,0 +1,75 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS and FASER collaborations +*/ + + +//////////////////////////////////////////////////////////////// +// // +// Header file for class PRDSysCommonData // +// // +// Description: Common pointers, data, node-to-object maps // +// etc. for the prd system // +// // +// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) // +// Initial version: July 2008 // +// // +//////////////////////////////////////////////////////////////// + +#ifndef PRDSYSCOMMONDATA_H +#define PRDSYSCOMMONDATA_H + +#include "VP1Base/VP1HelperClassBase.h" +class IVP13DSystem; +class HitsSoNodeManager; +class PRDSystemController; +class VP1SoMaterialMixer; +// class InDetProjHelper; +class PRDTrackSegmentHelper; +class SoTransform; +class SoPath; +class PRDHandleBase; +namespace Trk { class PrepRawData; } + +class PRDSysCommonData : public VP1HelperClassBase { +public: + + PRDSysCommonData(IVP13DSystem *, PRDSystemController*); + virtual ~PRDSysCommonData(); + + IVP13DSystem * system() const; + HitsSoNodeManager * nodeManager() const; + PRDSystemController * controller() const; + VP1SoMaterialMixer * materialMixer() const; +// InDetProjHelper * indetProjHelper_SCT() const; + PRDTrackSegmentHelper * trackAndSegmentHelper() const; + + void registerTransform2Handle(SoTransform*transform,PRDHandleBase*handle); + void registerPRD2Handle(const Trk::PrepRawData*prd,PRDHandleBase*handle); + //Access pick->handle association (and pop path): + PRDHandleBase * pickedPathToHandle( SoPath*pickedPath ); + + void clearEventData(); //Deletes AscObjSelectionManager + +private: + + class Imp; + Imp * m_d; + + IVP13DSystem * m_3dsystem; + HitsSoNodeManager * m_nodeManager; + PRDSystemController * m_controller; + VP1SoMaterialMixer * m_materialMixer; +// InDetProjHelper * m_indetProjHelper_SCT; + + PRDTrackSegmentHelper * m_trackAndSegmentHelper; + +}; + +inline IVP13DSystem* PRDSysCommonData::system() const { return m_3dsystem; } +inline HitsSoNodeManager* PRDSysCommonData::nodeManager() const { return m_nodeManager; } +inline PRDSystemController * PRDSysCommonData::controller() const { return m_controller; } +inline VP1SoMaterialMixer * PRDSysCommonData::materialMixer() const { return m_materialMixer; } +// inline InDetProjHelper * PRDSysCommonData::indetProjHelper_SCT() const { return m_indetProjHelper_SCT; } +inline PRDTrackSegmentHelper * PRDSysCommonData::trackAndSegmentHelper() const { return m_trackAndSegmentHelper; } + +#endif diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDSystemController.h b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDSystemController.h new file mode 100644 index 0000000000000000000000000000000000000000..c5455f38db8e97755a4952ffc54a9116709644ca --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDSystemController.h @@ -0,0 +1,149 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS and FASER collaborations +*/ + + +//////////////////////////////////////////////////////////////// +// // +// Header file for class PRDSystemController // +// // +// Description: Controller widget for the PRD system. // +// Keeps all nasty gui stuff internally, and // +// only presents the actual interesting data // +// with specialised access methods and signals. // +// // +// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) // +// Initial version: November 2007 // +// // +//////////////////////////////////////////////////////////////// + +#ifndef PRDSYSTEMCONTROLLER_H +#define PRDSYSTEMCONTROLLER_H + +#include "VP1Base/VP1Controller.h" +#include "VTI12PRDSystems/PRDCollHandleBase.h" +#include "VTI12PRDSystems/PRDCommonFlags.h" +#include "VTI12PRDSystems/PRDDetTypes.h" +// #include "VTI12Utils/InDetProjFlags.h" +#include <QByteArray> +#include <set> +class VP1CollectionWidget; +class SoMaterial; +class SoGroup; + +class PRDSystemController : public VP1Controller { + + Q_OBJECT + +public: + + PRDSystemController(IVP1System * sys); + virtual ~PRDSystemController(); + + void actualRestoreSettings(VP1Deserialise&); + int currentSettingsVersion() const; + void actualSaveSettings(VP1Serialise&) const; + + //Use by the system to access the collection widget, which again is + //the main entry point for communication with the prd collections + //(loading/hiding/etc.). + VP1CollectionWidget * collWidget() const; + + SoGroup * drawOptions(PRDDetType::Type) const; + + SoMaterial * getHighLightMaterial(); + double highLightMaterialWeight() const;//value indicates relative weight + //of highlight material. 0.0 + //obviously means no high light + //material, and values > 999.0 + //should be taken to mean infinite + //weight + + //Stateless on-click info: + bool printInfoOnClick() const; + bool zoomOnClick() const; + bool muonOrientToChambersOnClick() const; + + //Access relevant information of controller: + PRDCollHandleBase::COLOURMETHOD colourMethod() const; + + bool selectionModeMultiple() const; + bool showSelectionLine() const; + SoMaterial * getMultiSelectionLineMaterial() const; + + bool highLightOutliers() const; + bool drawErrors() const; + bool drawRDOs() const; + + bool projectSCTHits() const; + + //Cuts; + VP1Interval cutAllowedEta() const; + QList<VP1Interval> cutAllowedPhi() const;//All off: empty list. All on: list with one entry: ]-inf,inf[ + PRDCommonFlags::TrackerPartsFlags trackerPartsFlags() const; + bool sctExcludeIsolatedClusters() const; + //Used ID parts: +// InDetProjFlags::DetTypeFlags inDetPartsUsingProjections() const; + + std::set<PRDDetType::Type> shownCollectionTypes() const; + +signals: + //The following signals are emitted when any of the relevant information in the controller changes value: + + //Display modes and projections: + // void generalPRDDetailLevelChanged(PRDCollHandleBase::DETAIL); + void colourMethodChanged(PRDCollHandleBase::COLOURMETHOD); + void selectionModeMultipleChanged(bool); + void showSelectionLineChanged(bool); + void clearSelection() const;//only signal + void highLightMaterialWeightChanged(const double&); + void highLightOutliersChanged(bool); + void drawErrorsChanged(bool); + void drawRDOsChanged(bool); +// void projectSCTHitsChanged(bool); + + //Cuts: + void cutAllowedEtaChanged(const VP1Interval&); + void cutAllowedPhiChanged(const QList<VP1Interval>&); + void trackerPartsFlagsChanged(PRDCommonFlags::TrackerPartsFlags); + void sctExcludeIsolatedClustersChanged(bool); + + //Used ID parts: +// void inDetPartsUsingProjectionsChanged(InDetProjFlags::DetTypeFlags); + void shownCollectionTypesChanged(const std::set<PRDDetType::Type>&); + +private: + + class Imp; + Imp * m_d; + + //For verbose output: + template <class T> static QString toString( const T& t ) { return VP1Controller::toString(t); }//unhide base methods + + static QString toString( const PRDCollHandleBase::DETAIL& par ) { return PRDCollHandleBase::toString(par); } + static QString toString( const PRDCollHandleBase::COLOURMETHOD& par ) { return PRDCollHandleBase::toString(par); } + static QString toString( const std::set<PRDDetType::Type>& s ) { return "["+str(s.size())+" types]"; } + + +private slots: + void emitClearSelection(); + // void updateHighlightGui(); + void possibleChange_colourMethod(); + void possibleChange_selectionModeMultiple(); + void possibleChange_showSelectionLine(); + void possibleChange_highLightMaterialWeight(); + void possibleChange_highLightOutliers(); + void possibleChange_drawErrors(); + void possibleChange_drawRDOs(); + void possibleChange_cutAllowedEta(); + void possibleChange_cutAllowedPhi(); + void possibleChange_trackerPartsFlags(); + void possibleChange_sctExcludeIsolatedClusters(); + +// void possibleChange_projectSCTHits(); +// void possibleChange_inDetPartsUsingProjections(); + void possibleChange_shownCollectionTypes(); + +}; + +#endif diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDTrackSegmentHelper.h b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDTrackSegmentHelper.h new file mode 100644 index 0000000000000000000000000000000000000000..fa3880118207b8aaf86e0a112a1c789c18955722 --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/PRDTrackSegmentHelper.h @@ -0,0 +1,67 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS and FASER collaborations +*/ + + +//////////////////////////////////////////////////////////////// +// // +// Header file for class PRDTrackSegmentHelper // +// // +// Description: Class for keeping track of visible tracks // +// and segments and their materials, for // +// colour-prd-by-XXX modes. // +// // +// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) // +// Initial version: December 2007 // +// // +//////////////////////////////////////////////////////////////// + +#ifndef PRDTRACKSEGMENTHELPER_H +#define PRDTRACKSEGMENTHELPER_H + +#include "VP1Base/VP1HelperClassBase.h" +#include <QObject> +#include <vector> +#include <map> + +class SoMaterial; +class PRDHandleBase; +namespace Trk +{ + class Track; + class Segment; + class PrepRawData; +} + +class PRDTrackSegmentHelper : public QObject, public VP1HelperClassBase { + + Q_OBJECT + +public: + + PRDTrackSegmentHelper( std::map< const Trk::PrepRawData *, QList<PRDHandleBase *> >* prd2handle, + IVP1System* sys = 0, QObject * parent = 0); + virtual ~PRDTrackSegmentHelper(); + + //This is used to inform the class of changes in visible tracks and segments: + void visibleTracksChanged(const std::vector< std::pair<const Trk::Track*, const SoMaterial*> >&); + void visibleSegmentsChanged(const std::vector< std::pair<const Trk::Segment*, const SoMaterial*> >&); + + SoMaterial * trackMaterial(const Trk::Track*) const; + SoMaterial * segmentMaterial(const Trk::Segment*) const; + class TracksAndSegments { + public: + inline TracksAndSegments(const std::vector<const Trk::Track*>&,const std::vector<const Trk::Track*>&,const std::vector< const Trk::Segment* >& ); + std::vector<const Trk::Track*> tracks;//tracks using the given prd in the fit + std::vector<const Trk::Track*> tracks_outliers;//tracks where the given prd is associated as 'outlier' + std::vector< const Trk::Segment* > segments;//segments using the given prd + }; + const TracksAndSegments * tracksAndSegments(const Trk::PrepRawData*);//0 means no tracks/segments +private: + + class Imp; + Imp * m_d; + +}; + +#endif diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/VP1PrepRawDataSystem.h b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/VP1PrepRawDataSystem.h new file mode 100644 index 0000000000000000000000000000000000000000..b4957860c7fd71b769a6285148ed08570dc62471 --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/VTI12PRDSystems/VP1PrepRawDataSystem.h @@ -0,0 +1,69 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VP1PREPRAWDATASYSTEM_H +#define VP1PREPRAWDATASYSTEM_H + +#include "VP1Base/IVP13DSystemSimple.h" +#include "GeoModelKernel/GeoPVConstLink.h"//It would be good to get rid of this. +// #include "VTI12Utils/InDetProjFlags.h" +#include <vector> +#include <QList> + +class SoMaterial; +namespace Trk +{ + class Track; + class Segment; + class PrepRawData; +} + +class VP1PrepRawDataSystem : public IVP13DSystemSimple { + + Q_OBJECT + +public: + VP1PrepRawDataSystem(); + virtual ~VP1PrepRawDataSystem(); + void buildEventSceneGraph(StoreGateSvc* sg, SoSeparator *root); + void buildPermanentSceneGraph(StoreGateSvc* detstore, SoSeparator *root);//For TRT Projection surfaces + void systemcreate(StoreGateSvc* detstore); + void systemerase(); + void systemuncreate(); + + void userPickedNode(SoNode* pickedNode, SoPath * pickedPath); + void userSelectedSingleNode(SoCooperativeSelection*, SoNode* , SoPath*);//SINGLE + void userDeselectedSingleNode(SoCooperativeSelection*, SoNode* , SoPath*);//SINGLE + void userChangedSelection(SoCooperativeSelection*, QSet<SoNode*>, QSet<SoPath*>);//TOGGLE/SHIFT + void userClickedOnBgd(); + + virtual void deselectAll(SoCooperativeSelection* exception_sel = 0); + + virtual QWidget * buildController(); + + QByteArray saveState(); + void restoreFromState(QByteArray); + +public slots: + void visibleTracksChanged(const std::vector< std::pair<const Trk::Track*, const SoMaterial*> >&); + void visibleSegmentsChanged(const std::vector< std::pair<const Trk::Segment*, const SoMaterial*> >&); +// void setApplicableIDProjections( InDetProjFlags::InDetProjPartsFlags sct ); + +signals: +// void usedIDProjectionsChanged( InDetProjFlags::DetTypeFlags ); + void selectedPRDsChanged(const QList<const Trk::PrepRawData*>&); + +private slots: +// void emitUsedIDProjectionsChanged(InDetProjFlags::DetTypeFlags);//for controller + void selectionModeChanged(); + void selectionVisualsChanged(); + void clearSelection(); + void updateSelectionVisualsAndPossiblyEmitPRDList(); +private: + class Imp; + Imp * m_d; +}; + +#endif + diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDCollHandleBase.cxx b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDCollHandleBase.cxx new file mode 100644 index 0000000000000000000000000000000000000000..ab77031616aea40c79363999e224542b4c124987 --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDCollHandleBase.cxx @@ -0,0 +1,832 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS and FASER collaborations +*/ + +#include "VTI12PRDSystems/PRDCollHandleBase.h" +#include "VTI12PRDSystems/PRDSysCommonData.h" +#include "VTI12PRDSystems/PRDHandleBase.h" +#include "VTI12PRDSystems/VP1PrepRawDataSystem.h" +#include "VTI12PRDSystems/PRDSystemController.h" +#include "VTI12Utils/VP1JobConfigInfo.h" +#include "VTI12Utils/VP1SGAccessHelper.h" +#include "VTI12Utils/VP1SGContentsHelper.h" +#include "VP1Base/VP1ExtraSepLayerHelper.h" +#include "VP1Base/VP1Serialise.h" +#include "VP1Base/VP1QtInventorUtils.h" +#include "VP1Base/VP1Deserialise.h" +#include "VP1Base/VP1Msg.h" + +#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" + +#include "EventPrimitives/EventPrimitives.h" + +#include <Inventor/nodes/SoSeparator.h> +#include <Inventor/nodes/SoLevelOfDetail.h> +#include <Inventor/nodes/SoMaterial.h> + +#include <QComboBox> + +//____________________________________________________________________ +class PRDCollHandleBase::Imp { +public: + PRDCollHandleBase * theclass = nullptr; + + //Collection definition: + QString storegate_key; + PRDDetType::Type detType; + + template <class T> + bool actualLoad();//Templated according to collection type. + + VP1ExtraSepLayerHelper * sephelper_detail = nullptr; + VP1ExtraSepLayerHelper * sephelper_simple = nullptr; + SoSeparator * sep_lods = nullptr; + std::map<int,std::pair<SoLevelOfDetail*,std::pair<VP1ExtraSepLayerHelper*,VP1ExtraSepLayerHelper*> > > regionindex2lodhelpers;//idx->(sephelperdetailed,sephelpersimple) + DETAIL generalprddetaillevel; + void updateDetailSepAttachments(); + + SoMaterial * highlightmaterial = nullptr; + bool highlightoutliers = false; + bool drawerrors = false; + bool drawrdos = false; + + VP1Interval allowedEta; + QList<VP1Interval> allowedPhi; + + bool ensureLoaded();//first call each event will attempt to load + //PRDs from storegate. Returns false in case of + //problems this events. (This is inexpensive to + //call) + + //Vector of prd handles: + std::vector<PRDHandleBase*> prdhandles; + + bool etaPhiCut(PRDHandleBase*); + + //Extra widgets: + QComboBox * comboBox_detailLevel = nullptr; +}; + +//____________________________________________________________________ +PRDCollHandleBase::PRDCollHandleBase(PRDDetType::Type type,PRDSysCommonData*cd,const QString& key) + : VP1StdCollection(cd->system(),"PRDCollHandle_"+PRDDetType::typeToString(type)+"_"+key), m_d(new Imp), m_common(cd),m_nshownhandles(0), + m_colourmethod(ByTechOnly), m_highlightweight(999999.0) +{ + m_d->theclass = this; + m_d->detType = type; + m_d->storegate_key = key; + m_d->highlightmaterial = 0; + m_d->highlightoutliers = false; + m_d->drawerrors = false; + m_d->drawrdos = false; + m_d->sephelper_detail = 0; + m_d->sephelper_simple = 0; + m_d->sep_lods = 0; + m_d->comboBox_detailLevel = new QComboBox; + m_d->comboBox_detailLevel->setToolTip("Level of realism in representation" + " (\"Auto\" switches mode based on distance to camera)"); + m_d->comboBox_detailLevel->addItems(QStringList()<<"Low"<<"Auto"<<"High");//Low==simple, High==detailed. Don't change order. + m_d->generalprddetaillevel = SIMPLE; + m_d->comboBox_detailLevel->setCurrentIndex(0);//corresponds to simple. + connect(m_d->comboBox_detailLevel,SIGNAL(currentIndexChanged(int)),this,SLOT(detailComboBoxItemChanged())); + connect(this,SIGNAL(visibilityChanged(bool)),this,SLOT(collVisibilityChanged(bool))); +} + +//____________________________________________________________________ +void PRDCollHandleBase::init(VP1MaterialButtonBase*) +{ + VP1StdCollection::init();//this call is required + + SoSeparator * sep_detail = new SoSeparator; + sep_detail->setName("PRDColl_sep_detail"); + SoSeparator * sep_simple = new SoSeparator; + sep_simple->setName("PRDColl_sep_simple"); + m_d->sep_lods = new SoSeparator; + m_d->sep_lods->setName("PRDColl_sep_lods"); + sep_detail->ref(); + sep_simple->ref(); + m_d->sep_lods->ref(); + + m_d->sephelper_detail = new VP1ExtraSepLayerHelper(sep_detail,128); + m_d->sephelper_simple = new VP1ExtraSepLayerHelper(sep_simple,128); + + setupSettingsFromController(common()->controller()); + + //Setup detail level: + setGeneralPRDDetailLevel(defaultDetailLevel()); + m_d->updateDetailSepAttachments(); + +} + + +//____________________________________________________________________ +PRDCollHandleBase::~PRDCollHandleBase() +{ + //Lod sep-helpers: + std::map<int,std::pair<SoLevelOfDetail*,std::pair<VP1ExtraSepLayerHelper*,VP1ExtraSepLayerHelper*> > >::iterator it, itE = m_d->regionindex2lodhelpers.end(); + for (it = m_d->regionindex2lodhelpers.begin();it!=itE;++it) { + delete it->second.second.first; + delete it->second.second.second; + it->second.first->unref(); + } + m_d->regionindex2lodhelpers.clear(); + + //Cleanup separators: + if (m_d->sephelper_detail) { + SoSeparator * sep_detail = m_d->sephelper_detail->topSeparator(); + delete m_d->sephelper_detail; + sep_detail->unref(); + } + if (m_d->sephelper_simple) { + SoSeparator * sep_simple = m_d->sephelper_simple->topSeparator(); + delete m_d->sephelper_simple; + sep_simple->unref(); + } + if (m_d->sep_lods) + m_d->sep_lods->unref(); + + cleanupPtrContainer(m_d->prdhandles); + + if (m_d->highlightmaterial) + m_d->highlightmaterial->unref(); + + delete m_d; +} + +//____________________________________________________________________ +bool PRDCollHandleBase::load() { + bool safeToLoad(false); + switch (m_d->detType){ + case PRDDetType::SCT: + safeToLoad = VP1JobConfigInfo::hasSCTGeometry(); + break; + default: + safeToLoad = false; + } + + if (!safeToLoad){ + message("Required geometry not enabled in job."); + return false; + } + + switch (m_d->detType){ + case PRDDetType::SCT: return m_d->actualLoad<Tracker::FaserSCT_ClusterContainer>(); + //SpacePoints implements their own load. + default: + return false; + } +} + +//____________________________________________________________________ +void PRDCollHandleBase::collVisibilityChanged(bool vis) +{ + if (VP1Msg::verbose()) + messageVerbose("TrackCollHandleBase::collVisibilityChanged => "+str(vis)); + if (vis) + recheckCutStatusOfAllNotVisibleHandles();//Fixme -> ofallhandles? All must be not visible anyway... + else + recheckCutStatusOfAllVisibleHandles(); +} + +//____________________________________________________________________ +template <class T> +bool PRDCollHandleBase::Imp::actualLoad() +{ + ///////////////////////////////////////////////////////////////////////// + // Retrieve element container from event store: + const T* container; + VP1SGAccessHelper sg_access(theclass->systemBase()); + if(!sg_access.retrieve(container,storegate_key)) + return false; + + typename T::const_iterator element, lastElement(container->end()); + + ///////////////////////////////////////////////////////////////////////// + // Sanity check: + if ( container->size()==0 && container->begin()!=lastElement ) { + theclass->message("ERROR: container '"+storegate_key+"' has size()==0, but different begin() and end() iterators!"); + return false; + } + + ///////////////////////////////////////////////////////////////////////// + // In case the container was created incorrectly we must fallback to a different method of getting the prds: + bool fallback(false); + const DataHandle<typename T::base_value_type> firstElementD, lastElementD; + if ( container->size()!=0 && container->begin()==lastElement ) { + //This is either an empty container, or it is a case of an incorrectly created container which we must get by datahandles. + theclass->messageDebug("Retrieved empty container. This might be misleading. Now going to attempt to load prds via datahandles instead."); + if (VP1SGContentsHelper(theclass->systemBase()).getKeys<T>().count()!=1) { + theclass->messageDebug("But seems that there is not exactly one collection of type "+QString(typeid(T).name()) + +", so we won't attempt that anyway!! Thus we assume there there are simply no prd's."); + } else { + if(sg_access.retrieve(firstElementD, lastElementD,true)) { + if (firstElementD==lastElementD) { + theclass->messageDebug("No prd's found when accessed by datahandles either. It seems that there really are just no prds in this collection."); + } else { + fallback = true; + } + } else { + theclass->messageDebug("Failed retrieval by datahandles. We take that as a sign that there really are just no prds in this collection "); + } + } + } + + theclass->messageVerbose("Loop over actual prd's and create handles"); + //Retrieve prds and create handles: + + int ignoredUnsafeHandle_NoPRD(0); + int ignoredUnsafeHandle_NoDetElem(0); + int ignoredUnsafeHandle_NotSane(0); + typename T::base_value_type::const_iterator prd, prdLast; + int iprds(0); + if (!fallback) { + // element = container->begin(); + // prd = (*element)->begin(); + // ++iprds; + // PRDHandleBase * handle = theclass->addPRD(*prd); + // theclass->addHandle(handle); + // theclass->common()->registerPRD2Handle(*prd,handle); + // theclass->systemBase()->updateGUI(); + for ( element = container->begin(); element!=lastElement ; ++element) { + prd = (*element)->begin(), prdLast = (*element)->end(); + for ( ; prd!=prdLast ; ++prd) { + ++iprds; + if (!*prd) { + ++ignoredUnsafeHandle_NoPRD; + continue; + } + PRDHandleBase * handle = theclass->addPRD(*prd); + if (handle) { + if (!handle->isSane()) ignoredUnsafeHandle_NotSane++; + if (!handle->getPRD()->detectorElement()) { + ++ignoredUnsafeHandle_NoDetElem; + delete handle; + } else { + theclass->addHandle(handle); + theclass->common()->registerPRD2Handle(*prd,handle); + } + } + } + if (!(iprds%100)) + theclass->systemBase()->updateGUI(); + } + + } else { + + for ( const DataHandle<typename T::base_value_type> elementD(firstElementD); elementD!=lastElementD; ++elementD ) { + prd = (*elementD).begin(), prdLast = (*elementD).end(); + for ( ; prd!=prdLast ; ++prd) { + ++iprds; + if (!*prd) { + ++ignoredUnsafeHandle_NoPRD; + continue; + } + PRDHandleBase * handle = theclass->addPRD(*prd); + if (handle) { + if (!handle->isSane()) ignoredUnsafeHandle_NotSane++; + + if (!handle->getPRD()->detectorElement()) { + ++ignoredUnsafeHandle_NoDetElem; + delete handle; + } else { + theclass->addHandle(handle); + theclass->common()->registerPRD2Handle(*prd,handle); + } + } + if (!(iprds%100)) + theclass->systemBase()->updateGUI(); + } + } + } + theclass->systemBase()->updateGUI(); + prdhandles.resize(prdhandles.size()); + + if (ignoredUnsafeHandle_NoPRD) + theclass->message("WARNING - ignoring "+str(ignoredUnsafeHandle_NoPRD)+" null prd pointer(s)."); + if (ignoredUnsafeHandle_NoDetElem) + theclass->message("WARNING - ignoring "+str(ignoredUnsafeHandle_NoDetElem)+" prd pointer(s) with null detector elements."); + if (ignoredUnsafeHandle_NotSane) + theclass->message("WARNING - found "+str(ignoredUnsafeHandle_NotSane)+" prd pointer(s) which fail sanity checks (i.e. contain NaNs)."); + + //Perform initialisation needed for cuts (e.g. those of the "global" type, such as requiring a number of PRDs in the same detector module): + theclass->messageVerbose("postLoadInitialisation"); + theclass->postLoadInitialisation(); + + theclass->systemBase()->updateGUI(); + + //Show the handles that need to be shown: + theclass->recheckCutStatusOfAllNotVisibleHandles();//Use this method to not get the deselectAll call + + theclass->message("Found "+QString::number(iprds)+" ("+QString::number(theclass->nShownHandles())+" shown) PRDs in container '"+storegate_key+"'"); + + return true; + +} + +//____________________________________________________________________ +void PRDCollHandleBase::Imp::updateDetailSepAttachments() +{ + SoSeparator * collsep = theclass->collSep(); + if (!collsep) + return; + bool save = collsep->enableNotify(false); + if (generalprddetaillevel==PRDCollHandleBase::DETAILED) { + //Detail + if (collsep->findChild(sephelper_detail->topSeparator())<0) + collsep->addChild(sephelper_detail->topSeparator()); + } else { + //No detail + if (collsep->findChild(sephelper_detail->topSeparator())>-1) + collsep->removeChild(sephelper_detail->topSeparator()); + } + if (generalprddetaillevel==PRDCollHandleBase::SIMPLE) { + //Simple + if (collsep->findChild(sephelper_simple->topSeparator())<0) + collsep->addChild(sephelper_simple->topSeparator()); + } else { + //No simple + if (collsep->findChild(sephelper_simple->topSeparator())>-1) + collsep->removeChild(sephelper_simple->topSeparator()); + } + if (generalprddetaillevel==PRDCollHandleBase::AUTO) { + //LOD + if (collsep->findChild(sep_lods)<0) + collsep->addChild(sep_lods); + } else { + //No LOD + if (collsep->findChild(sep_lods)>-1) + collsep->removeChild(sep_lods); + } + if (save) { + collsep->enableNotify(true); + collsep->touch(); + } +} + +//____________________________________________________________________ +VP1ExtraSepLayerHelper * PRDCollHandleBase::sephelperDetailedNodes() const +{ + return m_d->sephelper_detail; +} + +//____________________________________________________________________ +VP1ExtraSepLayerHelper * PRDCollHandleBase::sephelperSimpleNodes() const +{ + return m_d->sephelper_simple; +} + +//____________________________________________________________________ +void PRDCollHandleBase::detailComboBoxItemChanged() +{ + messageVerbose("Collection detail level combo box changed index"); + switch(m_d->comboBox_detailLevel->currentIndex()) { + case 1: + setGeneralPRDDetailLevel(AUTO); + break; + case 2: + setGeneralPRDDetailLevel(DETAILED); + break; + default: + case 0: + setGeneralPRDDetailLevel(SIMPLE); + break; + } +} + +//____________________________________________________________________ +PRDCollHandleBase::DETAIL PRDCollHandleBase::detailLevel() const +{ + return m_d->generalprddetaillevel; +} + +//____________________________________________________________________ +void PRDCollHandleBase::setGeneralPRDDetailLevel( DETAIL dm ) +{ + if (m_d->generalprddetaillevel==dm) + return; + m_d->generalprddetaillevel = dm; + messageVerbose("Detail level changed"); +// common()->system()->deselectAll(); + + //Update gui combobox: + int targetIndex(0); + switch(m_d->generalprddetaillevel) { + case AUTO: + targetIndex = 1; + break; + case DETAILED: + targetIndex = 2; + break; + default: + case SIMPLE: + targetIndex = 0; + break; + } + if (targetIndex!=m_d->comboBox_detailLevel->currentIndex()) { + bool save = m_d->comboBox_detailLevel->blockSignals(true); + m_d->comboBox_detailLevel->setCurrentIndex(targetIndex); + m_d->comboBox_detailLevel->blockSignals(save); + } + + //Actual changes to 3D representation: + m_d->updateDetailSepAttachments(); + + detailLevelChanged(); + +} + +//____________________________________________________________________ +void PRDCollHandleBase::getLODSeparators(int index, VP1ExtraSepLayerHelper*& sephelper_detail,VP1ExtraSepLayerHelper*& sephelper_simple) +{ + const float complexity = 0.3f;//Fixme: Hardcoded here. + std::map<int,std::pair<SoLevelOfDetail*,std::pair<VP1ExtraSepLayerHelper*,VP1ExtraSepLayerHelper*> > >::iterator it = m_d->regionindex2lodhelpers.find(index); + if (it!=m_d->regionindex2lodhelpers.end()) { + sephelper_detail = it->second.second.first; + sephelper_simple = it->second.second.second; + //To try to scale somehow different regions to change at "the same time": + it->second.first->screenArea.setValue(lodArea()*(sephelper_detail->topSeparator()->getNumChildren()+1)/(complexity+0.5f)); + return; + } + SoLevelOfDetail * lod = new SoLevelOfDetail; + SoSeparator * sep_detail = new SoSeparator; + SoSeparator * sep_simple = new SoSeparator; + lod->addChild(sep_detail); + lod->addChild(sep_simple); + lod->screenArea.setValue(lodArea()/(complexity+0.5f)); + m_d->sep_lods->addChild(lod); + sephelper_detail = new VP1ExtraSepLayerHelper(sep_detail); + sephelper_simple = new VP1ExtraSepLayerHelper(sep_simple); + + lod->ref(); + m_d->regionindex2lodhelpers[index] = + std::pair<SoLevelOfDetail*,std::pair<VP1ExtraSepLayerHelper*,VP1ExtraSepLayerHelper*> > + (lod,std::pair<VP1ExtraSepLayerHelper*,VP1ExtraSepLayerHelper*>(sephelper_detail,sephelper_simple)); +} + +//____________________________________________________________________ +void PRDCollHandleBase::addHandle(PRDHandleBase*handle) +{ + if (handle) + m_d->prdhandles.push_back(handle); +} + +//____________________________________________________________________ +std::vector<PRDHandleBase*>& PRDCollHandleBase::getPrdHandles() +{ + return m_d->prdhandles; +} + +//____________________________________________________________________ +const std::vector<PRDHandleBase*>& PRDCollHandleBase::getPrdHandles() const +{ + return m_d->prdhandles; +} + +//____________________________________________________________________ +void PRDCollHandleBase::recheckCutStatus(PRDHandleBase*handle) +{ + handle->setVisible( visible() && cut(handle) && m_d->etaPhiCut(handle) ); +} + +//Fixme: A few of the methods of this class should be inlined (requires a few more public data members) + +//____________________________________________________________________ +void PRDCollHandleBase::setupSettingsFromController(PRDSystemController*controller) +{ + assert(controller); + largeChangesBegin(); + + collSep()->addChild(controller->drawOptions(m_d->detType)); + + m_d->highlightmaterial = controller->getHighLightMaterial(); + m_d->highlightmaterial->ref(); + + connect(controller,SIGNAL(highLightOutliersChanged(bool)),this,SLOT(setHighLightOutliers(bool))); + setHighLightOutliers(controller->highLightOutliers()); + + connect(controller,SIGNAL(colourMethodChanged(PRDCollHandleBase::COLOURMETHOD)),this,SLOT(setColourMethod(PRDCollHandleBase::COLOURMETHOD))); + setColourMethod(controller->colourMethod()); + + connect(controller,SIGNAL(drawErrorsChanged(bool)),this,SLOT(setDrawErrors(bool))); + setDrawErrors(controller->drawErrors()); + + connect(controller,SIGNAL(drawRDOsChanged(bool)),this,SLOT(setDrawRDOs(bool))); + setDrawRDOs(controller->drawRDOs()); + + connect(controller,SIGNAL(highLightMaterialWeightChanged(const double&)),this,SLOT(setHighLightWeight(const double&))); + setHighLightWeight(controller->highLightMaterialWeight()); + + connect(controller,SIGNAL(cutAllowedEtaChanged(const VP1Interval&)), + this,SLOT(setAllowedEta(const VP1Interval&))); + setAllowedEta(controller->cutAllowedEta()); + + connect(controller,SIGNAL(cutAllowedPhiChanged(const QList<VP1Interval>&)), + this,SLOT(setAllowedPhi(const QList<VP1Interval>&))); + setAllowedPhi(controller->cutAllowedPhi()); + + setupSettingsFromControllerSpecific(controller); + largeChangesEnd(); +} + + +//____________________________________________________________________ +void PRDCollHandleBase::recheckCutStatusOfAllHandles() +{ + messageVerbose("PRDCollHandleBase::recheckCutStatusOfAllHandles"); + + common()->system()->deselectAll(); + + largeChangesBegin(); + std::vector<PRDHandleBase*>::iterator it(m_d->prdhandles.begin()),itE(m_d->prdhandles.end()); + int i(0); + for (;it!=itE;++it) { + recheckCutStatus(*it); + if (!(i++%200)) + systemBase()->updateGUI();//since called from ::actualLoad<..>(..) + } + largeChangesEnd(); + if (visible()) message("Have "+QString::number(getPrdHandles().size())+" ("+QString::number(nShownHandles())+" shown) PRDs"); +} + +//____________________________________________________________________ +void PRDCollHandleBase::recheckCutStatusOfAllVisibleHandles() +{ + messageVerbose("PRDCollHandleBase::recheckCutStatusOfAllVisibleHandles"); + if (!visible()) return; + //This method is called when a cut is tightened - thus we better start by deselectAll to avoid weird highlighting issues. + common()->system()->deselectAll(); + + largeChangesBegin(); + std::vector<PRDHandleBase*>::iterator it(m_d->prdhandles.begin()),itE(m_d->prdhandles.end()); + for (;it!=itE;++it) { + if ((*it)->visible()) + recheckCutStatus(*it); + } + largeChangesEnd(); + if (visible()) message("Have "+QString::number(getPrdHandles().size())+" ("+QString::number(nShownHandles())+" shown) PRDs"); +} + +//____________________________________________________________________ +void PRDCollHandleBase::recheckCutStatusOfAllNotVisibleHandles() +{ + messageVerbose("PRDCollHandleBase::recheckCutStatusOfAllNotVisibleHandles"); + + largeChangesBegin(); + std::vector<PRDHandleBase*>::iterator it(m_d->prdhandles.begin()),itE(m_d->prdhandles.end()); + for (;it!=itE;++it) { + if (!(*it)->visible()) + recheckCutStatus(*it); + } + largeChangesEnd(); + if (visible()) message("Have "+QString::number(getPrdHandles().size())+" ("+QString::number(nShownHandles())+" shown) PRDs"); +} + + +//____________________________________________________________________ +bool PRDCollHandleBase::highLightOutliers() const +{ + return m_d->highlightoutliers; +} + +//____________________________________________________________________ +bool PRDCollHandleBase::drawErrors() const +{ + return m_d->drawerrors; +} + +//____________________________________________________________________ +bool PRDCollHandleBase::drawRDOs() const +{ + return m_d->drawrdos; +} + +//____________________________________________________________________ +SoMaterial * PRDCollHandleBase::highLightMaterial() const +{ + return m_d->highlightmaterial; +} + +//____________________________________________________________________ +void PRDCollHandleBase::setHighLightOutliers(bool b) +{ + if (m_d->highlightoutliers==b) + return; + m_d->highlightoutliers = b; + largeChangesBegin(); + std::vector<PRDHandleBase*>::iterator it(m_d->prdhandles.begin()),itE(m_d->prdhandles.end()); + for (;it!=itE;++it) { + (*it)->updateMaterial(); + //Fixme: Improve performance by only calling updateMaterial() on + //those that are outliers on at least one track. + } + largeChangesEnd(); +} + +//____________________________________________________________________ +void PRDCollHandleBase::setDrawErrors(bool b) +{ + if (m_d->drawerrors==b) + return; + m_d->drawerrors = b; + largeChangesBegin(); + std::vector<PRDHandleBase*>::iterator it(m_d->prdhandles.begin()),itE(m_d->prdhandles.end()); + for (;it!=itE;++it) { + (*it)->update3DObjects(); + //Fixme: Improve performance by only calling updateMaterial() on + //those that are outliers on at least one track. + } + largeChangesEnd(); +} + +//____________________________________________________________________ +void PRDCollHandleBase::setDrawRDOs(bool b) +{ + if (m_d->drawrdos==b) + return; + m_d->drawrdos = b; + largeChangesBegin(); + std::vector<PRDHandleBase*>::iterator it(m_d->prdhandles.begin()),itE(m_d->prdhandles.end()); + for (;it!=itE;++it) { + (*it)->update3DObjects(); + //Fixme: Improve performance by only calling updateMaterial() on + //those that are outliers on at least one track. + } + largeChangesEnd(); +} + + +//____________________________________________________________________ +void PRDCollHandleBase::setHighLightWeight(const double& hlw) +{ + if (m_highlightweight == hlw) + return; + m_highlightweight = hlw; + largeChangesBegin(); + std::vector<PRDHandleBase*>::iterator it(m_d->prdhandles.begin()),itE(m_d->prdhandles.end()); + for (;it!=itE;++it) { + if (m_d->highlightoutliers || (*it)->highLight()) + (*it)->updateMaterial(); + //Fixme: We can improve performance here by investigating whether + //the handle actually is an outlier for at least one track, or if + //highlighting is at all applicable for the collection (maybe it is turned off). + } + largeChangesEnd(); +} + +//____________________________________________________________________ +void PRDCollHandleBase::setColourMethod(PRDCollHandleBase::COLOURMETHOD cm) +{ + if (m_colourmethod==cm) + return; + m_colourmethod = cm; + + largeChangesBegin(); + std::vector<PRDHandleBase*>::iterator it(m_d->prdhandles.begin()),itE(m_d->prdhandles.end()); + for (;it!=itE;++it) { + (*it)->updateMaterial(); + //Fixme: Improve performance by only calling on those that are on tracks/segments as relevant. + } + largeChangesEnd(); + +} + +//____________________________________________________________________ +QString PRDCollHandleBase::toString(const PRDCollHandleBase::DETAIL& d) +{ + switch (d) { + case SIMPLE: return "SIMPLE"; + case DETAILED: return "DETAILED"; + case AUTO: return "AUTO"; + default: return "Unknown (ERROR)"; + } +} + +//____________________________________________________________________ +QString PRDCollHandleBase::toString(const COLOURMETHOD& cm) +{ + switch (cm) { + case ByTechOnly: return "ByTechOnly"; + case BySegment: return "BySegment"; + case ByTrack: return "ByTrack"; + case BySegmentAndTrack: return "BySegmentAndTrack"; + default: return "Unknown (ERROR)"; + } +} + +//____________________________________________________________________ +qint32 PRDCollHandleBase::provideCollTypeID() const +{ + return PRDDetType::typeToInt(m_d->detType); +} + +//____________________________________________________________________ +QString PRDCollHandleBase::provideText() const +{ + return m_d->storegate_key; +} + +//____________________________________________________________________ +void PRDCollHandleBase::assignDefaultMaterial(SoMaterial*m) const +{ + VP1QtInventorUtils::setMatColor( m, defaultColor(), 0.18/*brightness*/ ); +} + +//____________________________________________________________________ +QString PRDCollHandleBase::provideSection() const +{ + switch (m_d->detType) { + case PRDDetType::SCT: + return "Tracker PRDs"; + case PRDDetType::SpacePoints: + return "Tracker Space Points"; + default: return "Unknown Section"; + } +} + +//____________________________________________________________________ +QString PRDCollHandleBase::provideSectionToolTip() const +{ + switch (m_d->detType) { + case PRDDetType::SCT: + return "Tracker PRD collections in event"; + case PRDDetType::SpacePoints: + return "Space Point collections in event"; + default: return "Error: PRDDetType not recognised."; + } +} + +//____________________________________________________________________ +QList<QWidget*> PRDCollHandleBase::provideExtraWidgetsForGuiRow() const +{ + return QList<QWidget*>() << m_d->comboBox_detailLevel; +} + +//____________________________________________________________________ +QByteArray PRDCollHandleBase::extraWidgetsState() const +{ + VP1Serialise serialise(0/*version*/,systemBase()); + serialise.save(m_d->comboBox_detailLevel); + serialise.disableUnsavedChecks(); + return serialise.result(); +} + +//____________________________________________________________________ +void PRDCollHandleBase::setExtraWidgetsState(const QByteArray& ba) +{ + VP1Deserialise state(ba, systemBase()); + if (state.version()!=0) + return;//just ignore silently... i guess we ought to warn? + state.restore(m_d->comboBox_detailLevel); + state.disableUnrestoredChecks(); + detailComboBoxItemChanged(); +} + +//____________________________________________________________________ +void PRDCollHandleBase::setAllowedEta(const VP1Interval& e) +{ + if (m_d->allowedEta==e) + return; + bool relaxed(e.contains(m_d->allowedEta)); + bool tightened(m_d->allowedEta.contains(e)); + m_d->allowedEta=e; + if (relaxed) + recheckCutStatusOfAllNotVisibleHandles(); + else if (tightened) + recheckCutStatusOfAllVisibleHandles(); + else + recheckCutStatusOfAllHandles(); +} + +//____________________________________________________________________ +void PRDCollHandleBase::setAllowedPhi(const QList<VP1Interval>& l) +{ + if (m_d->allowedPhi==l) + return; + m_d->allowedPhi=l; + recheckCutStatusOfAllHandles(); +} + +//____________________________________________________________________ +bool PRDCollHandleBase::Imp::etaPhiCut(PRDHandleBase* handle) +{ + bool allPhiAllowed = allowedPhi.count()==1&&allowedPhi.at(0).isAllR(); + bool allEtaAllowed = allowedEta.isAllR(); + if (allEtaAllowed&&allPhiAllowed) + return true; + if (allowedPhi.isEmpty()||allowedEta.isEmpty()) + return false; + Amg::Vector3D p = handle->center(); + if (!allEtaAllowed) { + if (!allowedEta.contains(p.eta())) + return false; + } + if (!allPhiAllowed) { + double phi(p.phi()); + foreach(VP1Interval i,allowedPhi) { + if (i.contains(phi)||i.contains(phi+2*M_PI)||i.contains(phi-2*M_PI)) + return true; + } + return false; + } + return true; +} diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDCollHandle_SCT.cxx b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDCollHandle_SCT.cxx new file mode 100644 index 0000000000000000000000000000000000000000..48e348aaa6efc971326179f7fd375e639eac91b1 --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDCollHandle_SCT.cxx @@ -0,0 +1,158 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VTI12PRDSystems/PRDCollHandle_SCT.h" +#include "VTI12PRDSystems/PRDHandle_SCT.h" +#include "VTI12PRDSystems/PRDSystemController.h" +#include "TrackerPrepRawData/FaserSCT_Cluster.h" +#include <QColor> + +#include "VTI12Utils/VP1JobConfigInfo.h" +#include "VTI12Utils/VP1SGContentsHelper.h" +#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h" + +//____________________________________________________________________ +QStringList PRDCollHandle_SCT::availableCollections(IVP1System*sys) +{ + return VP1JobConfigInfo::hasSCTGeometry() ? VP1SGContentsHelper(sys).getKeys<Tracker::FaserSCT_ClusterContainer>() : QStringList(); +} + +//____________________________________________________________________ +class PRDCollHandle_SCT::Imp { +public: + std::set<const TrackerDD::SiDetectorElement*> touchedelements; + + PRDCommonFlags::TrackerPartsFlags trackerpartsflags; + bool excludeisolatedclusters = false; +}; + +//____________________________________________________________________ +PRDCollHandle_SCT::PRDCollHandle_SCT(PRDSysCommonData * cd,const QString& key) + : PRDCollHandleBase(PRDDetType::SCT,cd,key), m_d(new Imp) +{ + m_d->trackerpartsflags = PRDCommonFlags::All; + m_d->excludeisolatedclusters = true; +} + +//____________________________________________________________________ +PRDCollHandle_SCT::~PRDCollHandle_SCT() +{ + delete m_d; +} + +//____________________________________________________________________ +QColor PRDCollHandle_SCT::defaultColor() const +{ + return QColor::fromRgbF(1.0, 1.0, 0.5 );//light yellow +} + +//____________________________________________________________________ +PRDHandleBase* PRDCollHandle_SCT::addPRD( const Trk::PrepRawData * prd ) +{ + assert(dynamic_cast<const Tracker::FaserSCT_Cluster*>(prd)); + return new PRDHandle_SCT(this,static_cast<const Tracker::FaserSCT_Cluster*>(prd)); +} + +//____________________________________________________________________ +void PRDCollHandle_SCT::postLoadInitialisation() +{ + std::vector<PRDHandleBase*>::iterator it(getPrdHandles().begin()),itE(getPrdHandles().end()); + for (;it!=itE;++it) + m_d->touchedelements.insert(static_cast<PRDHandle_SCT*>(*it)->cluster()->detectorElement()); + m_d->touchedelements.insert(0);//To always show clusters whose elements have no otherSide() pointer. +} + +//____________________________________________________________________ +void PRDCollHandle_SCT::eraseEventDataSpecific() +{ + m_d->touchedelements.clear(); +} + +//____________________________________________________________________ +bool PRDCollHandle_SCT::cut(PRDHandleBase*handlebase) +{ + PRDHandle_SCT * handle = static_cast<PRDHandle_SCT*>(handlebase); + assert(handle); + + if (m_d->trackerpartsflags!=PRDCommonFlags::All) { + if (handle->isInterface()) + if (!(m_d->trackerpartsflags & PRDCommonFlags::Interface)) return false; + if (handle->isUpstream()) + if (!(m_d->trackerpartsflags & PRDCommonFlags::Upstream)) return false; + if (handle->isCentral()) + if (!(m_d->trackerpartsflags & PRDCommonFlags::Central)) return false; + if (handle->isDownstream()) + if (!(m_d->trackerpartsflags & PRDCommonFlags::Downstream)) return false; + } + + if (m_d->excludeisolatedclusters) { + if (!m_d->touchedelements.count(handle->cluster()->detectorElement()->otherSide())) + return false; + } + + return true; +} + +//____________________________________________________________________ +void PRDCollHandle_SCT::setPartsFlags(PRDCommonFlags::TrackerPartsFlags flags ) { + //NB: The code is this method is very similar in PRDCollHandle_Pixel::setPartsFlags, PRDCollHandle_SCT::setPartsFlags, + //PRDCollHandle_TRT::setPartsFlags and and PRDCollHandle_SpacePoints::setPartsFlags + //Fixme: base decision to recheck on visibility also! + + if (m_d->trackerpartsflags==flags) + return; + + bool interfaceChanged = (m_d->trackerpartsflags&PRDCommonFlags::Interface)!=(flags&PRDCommonFlags::Interface); + bool upstreamChanged = (m_d->trackerpartsflags&PRDCommonFlags::Upstream)!=(flags&PRDCommonFlags::Upstream); + bool centralChanged = (m_d->trackerpartsflags&PRDCommonFlags::Central)!=(flags&PRDCommonFlags::Central); + bool downstreamChanged = (m_d->trackerpartsflags&PRDCommonFlags::Downstream)!=(flags&PRDCommonFlags::Downstream); + + m_d->trackerpartsflags=flags; + + largeChangesBegin(); + std::vector<PRDHandleBase*>::iterator it(getPrdHandles().begin()),itE(getPrdHandles().end()); + for (;it!=itE;++it) { + PRDHandle_SCT* handle = static_cast<PRDHandle_SCT*>(*it); + if (handle->isInterface()) + { + if (interfaceChanged) recheckCutStatus(handle); + } + else if (handle->isUpstream()) + { + if (upstreamChanged) recheckCutStatus(handle); + } + else if (handle->isCentral()) + { + if (centralChanged) recheckCutStatus(handle); + } + else if (handle->isDownstream()) + { + if (downstreamChanged) recheckCutStatus(handle); + } + } + largeChangesEnd(); + +} + +//____________________________________________________________________ +void PRDCollHandle_SCT::setExcludeIsolatedClusters(bool excludeisolated) +{ + if (m_d->excludeisolatedclusters==excludeisolated) + return; + m_d->excludeisolatedclusters=excludeisolated; + if (excludeisolated) + recheckCutStatusOfAllVisibleHandles(); + else + recheckCutStatusOfAllNotVisibleHandles(); +} + +//____________________________________________________________________ +void PRDCollHandle_SCT::setupSettingsFromControllerSpecific(PRDSystemController*controller) +{ + connect(controller,SIGNAL(trackerPartsFlagsChanged(PRDCommonFlags::TrackerPartsFlags)),this,SLOT(setPartsFlags(PRDCommonFlags::TrackerPartsFlags))); + setPartsFlags(controller->trackerPartsFlags()); + + connect(controller,SIGNAL(sctExcludeIsolatedClustersChanged(bool)),this,SLOT(setExcludeIsolatedClusters(bool))); + setExcludeIsolatedClusters(controller->sctExcludeIsolatedClusters()); +} diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDCollHandle_SpacePoints.cxx b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDCollHandle_SpacePoints.cxx new file mode 100644 index 0000000000000000000000000000000000000000..59ede3c1eaba3f234ba3800fd0bc3c2095693579 --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDCollHandle_SpacePoints.cxx @@ -0,0 +1,185 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + +//////////////////////////////////////////////////////////////// +// // +// Implementation of class PRDCollHandle_SpacePoints // +// // +// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) // +// Initial version: September 2008 // +// // +//////////////////////////////////////////////////////////////// + +#include "VTI12PRDSystems/PRDCollHandle_SpacePoints.h" +#include "VTI12PRDSystems/PRDHandle_SpacePoint.h" +#include "VTI12PRDSystems/PRDSystemController.h" +#include "VP1Base/IVP1System.h" +#include "VTI12Utils/VP1JobConfigInfo.h" +#include "VTI12Utils/VP1SGContentsHelper.h" +#include "VTI12Utils/VP1SGAccessHelper.h" +#include "TrackerSpacePoint/FaserSCT_SpacePointContainer.h" +#include <QColor> + +//____________________________________________________________________ +QStringList PRDCollHandle_SpacePoints::availableCollections(IVP1System*sys) +{ + if (!VP1JobConfigInfo::hasSCTGeometry()) + return QStringList(); + QStringList keys = VP1SGContentsHelper(sys).getKeys<FaserSCT_SpacePointContainer>(); + QStringList unsafekeys; + if (!VP1JobConfigInfo::hasSCTGeometry()) { + foreach (QString key,keys) { + if (key.contains("sct",Qt::CaseInsensitive)) + unsafekeys << key; + } + } + foreach (QString unsafekey,unsafekeys) + keys.removeAll(unsafekey); + return keys; +} + +//____________________________________________________________________ +class PRDCollHandle_SpacePoints::Imp { +public: + PRDCommonFlags::TrackerPartsFlags trackerpartsflags; +}; + + +//____________________________________________________________________ +PRDCollHandle_SpacePoints::PRDCollHandle_SpacePoints(PRDSysCommonData* common,const QString& key) + : PRDCollHandleBase(PRDDetType::SpacePoints,common,key), m_d(new Imp) +{ + m_d->trackerpartsflags = (PRDCommonFlags::All); +} + +//____________________________________________________________________ +PRDCollHandle_SpacePoints::~PRDCollHandle_SpacePoints() +{ + delete m_d; +} + +//____________________________________________________________________ +QColor PRDCollHandle_SpacePoints::defaultColor() const +{ + return QColor::fromRgbF(1.0, 1.0, 0.5 );//light yellow +} + +//____________________________________________________________________ +bool PRDCollHandle_SpacePoints::load() +{ + ///////////////////////////////////////////////////////////////////////// + // Retrieve element container from event store: + const FaserSCT_SpacePointContainer* container; + if(!VP1SGAccessHelper(systemBase()).retrieve(container,text())) + return false; + + int isp(0); + FaserSCT_SpacePointContainer::const_iterator itElement, itElementE(container->end()); + for (itElement=container->begin();itElement!=itElementE;++itElement) { + FaserSCT_SpacePointContainer::base_value_type::const_iterator it, itE((*itElement)->end()); + for (it=(*itElement)->begin();it!=itE;++it) { + const Tracker::FaserSCT_SpacePoint * sp = *it; + ++isp; + if (!sp) { + message("WARNING - ignoring null spacepoint pointer."); + continue; + } + if (!sp->clusterList().first) { + message("WARNING - ignoring spacepoint with null first cluster."); + continue; + } + PRDHandleBase * handle = new PRDHandle_SpacePoint(this,sp); + if (handle) { + addHandle(handle); + //We just register the first of the (possibly) two prds here (fixme: check that it works): + common()->registerPRD2Handle(handle->getPRD(),handle); + } else { + message("WARNING - ignoring null handle pointer."); + } + if (!(isp%100)) + systemBase()->updateGUI(); + } + } + return true; +} + +//____________________________________________________________________ +bool PRDCollHandle_SpacePoints::cut(PRDHandleBase*handlebase) +{ + PRDHandle_SpacePoint * handle = static_cast<PRDHandle_SpacePoint*>(handlebase); + assert(handle); + + if (m_d->trackerpartsflags!=PRDCommonFlags::All) { + if (handle->isInterface()) + if (!(m_d->trackerpartsflags & PRDCommonFlags::Interface)) return false; + if (handle->isUpstream()) + if (!(m_d->trackerpartsflags & PRDCommonFlags::Upstream)) return false; + if (handle->isCentral()) + if (!(m_d->trackerpartsflags & PRDCommonFlags::Central)) return false; + if (handle->isDownstream()) + if (!(m_d->trackerpartsflags & PRDCommonFlags::Downstream)) return false; + } + + return true; +} + +//____________________________________________________________________ +void PRDCollHandle_SpacePoints::eraseEventDataSpecific() +{ +} + +//____________________________________________________________________ +void PRDCollHandle_SpacePoints::postLoadInitialisation() +{ +} + +//____________________________________________________________________ +void PRDCollHandle_SpacePoints::setupSettingsFromControllerSpecific(PRDSystemController*controller) +{ + connect(controller,SIGNAL(trackerPartsFlagsChanged(PRDCommonFlags::TrackerPartsFlags)), + this,SLOT(setPartsFlags(PRDCommonFlags::TrackerPartsFlags))); + setPartsFlags(controller->trackerPartsFlags()); +} + +//____________________________________________________________________ +void PRDCollHandle_SpacePoints::setPartsFlags(PRDCommonFlags::TrackerPartsFlags flags) +{ + //NB: The code is this method is very similar in PRDCollHandle_Pixel::setPartsFlags, PRDCollHandle_SCT::setPartsFlags, + //PRDCollHandle_TRT::setPartsFlags and and PRDCollHandle_SpacePoints::setPartsFlags + //Fixme: base decision to recheck on visibility also! + + if (m_d->trackerpartsflags==flags) + return; + + bool interfaceChanged = (m_d->trackerpartsflags&PRDCommonFlags::Interface)!=(flags&PRDCommonFlags::Interface); + bool upstreamChanged = (m_d->trackerpartsflags&PRDCommonFlags::Upstream)!=(flags&PRDCommonFlags::Upstream); + bool centralChanged = (m_d->trackerpartsflags&PRDCommonFlags::Central)!=(flags&PRDCommonFlags::Central); + bool downstreamChanged = (m_d->trackerpartsflags&PRDCommonFlags::Downstream)!=(flags&PRDCommonFlags::Downstream); + + m_d->trackerpartsflags=flags; + + largeChangesBegin(); + std::vector<PRDHandleBase*>::iterator it(getPrdHandles().begin()),itE(getPrdHandles().end()); + for (;it!=itE;++it) { + PRDHandle_SpacePoint* handle = static_cast<PRDHandle_SpacePoint*>(*it); + if (handle->isInterface()) + { + if (interfaceChanged) recheckCutStatus(handle); + } + else if (handle->isUpstream()) + { + if (upstreamChanged) recheckCutStatus(handle); + } + else if (handle->isCentral()) + { + if (centralChanged) recheckCutStatus(handle); + } + else if (handle->isDownstream()) + { + if (downstreamChanged) recheckCutStatus(handle); + } + } + largeChangesEnd(); +} diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDDetTypes.cxx b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDDetTypes.cxx new file mode 100644 index 0000000000000000000000000000000000000000..86332ea0175acb0902ed2b6e32d8f7b9864a5e17 --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDDetTypes.cxx @@ -0,0 +1,49 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VTI12PRDSystems/PRDDetTypes.h" + +//______________________________________________ +QString PRDDetType::typeToString(const Type& t) +{ + switch (t) { + case SCT: return "SCT"; + case SpacePoints: return "SpacePoints"; + default: return "UNKNOWN"; + } +} + +//______________________________________________ +PRDDetType::Type PRDDetType::stringToType(const QString&str, bool & status) +{ + status = true; + if (str=="SCT") return SCT; + if (str=="SpacePoints") return SpacePoints; + status = false; + return SCT;//people better watch the return status! +} + + +//______________________________________________ +qint32 PRDDetType::typeToInt(const Type& t) +{ + switch (t) { + case SCT: return 0; + case SpacePoints: return 1; + default: return -1; + } +} + +//______________________________________________ +PRDDetType::Type PRDDetType::intToType(const qint32&i, bool & status) +{ + status = true; + switch (i) { + case 0: return SCT; + case 1: return SpacePoints; + default: + status = false; + return SCT;//people better watch the return status! + } +} diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDHandleBase.cxx b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDHandleBase.cxx new file mode 100644 index 0000000000000000000000000000000000000000..2e1c76e306c937a995938f83446d56fd5d826e81 --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDHandleBase.cxx @@ -0,0 +1,471 @@ +/* + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VTI12PRDSystems/PRDHandleBase.h" +#include "VTI12Utils/HitsSoNodeManager.h" +#include "VTI12PRDSystems/PRDCollHandleBase.h" +#include "VTI12PRDSystems/VP1PrepRawDataSystem.h" +#include "VTI12PRDSystems/PRDTrackSegmentHelper.h" + +#include "VP1Base/VP1ExtraSepLayerHelper.h" +#include "VP1Base/VP1SoMaterialMixer.h" +#include "VP1Base/VP1Msg.h" + +#include "VTI12Utils/VP1LinAlgUtils.h" + +#include <Inventor/C/errors/debugerror.h> +#include <Inventor/nodes/SoSeparator.h> +#include <Inventor/nodes/SoTransform.h> +#include <Inventor/nodes/SoMaterial.h> + +#include "TrkSurfaces/Surface.h" +#include "TrkPrepRawData/PrepRawData.h" + +#include "GeoPrimitives/GeoPrimitives.h" +#include "GeoPrimitives/GeoPrimitivesHelpers.h" + +#include <vector> +#include <algorithm> +#include <sstream> + +//____________________________________________________________________ +class PRDHandleBase::Imp { +public: + PRDCollHandleBase* colhandle; + void rebuild3DObjects(PRDHandleBase*); + void attach3DObjects(PRDHandleBase*); + void detach3DObjects(); + + static Amg::Vector3D positionPRD(const Trk::PrepRawData* prd); + + //Child 0 is the transform, then follows the node representing the shapes. + SoSeparator * sepDetailed; + SoSeparator * sepSimple; + SoMaterial * currentmaterial; + VP1ExtraSepLayerHelper* sephelper_lod_detail; + VP1ExtraSepLayerHelper* sephelper_lod_simple; + + SoMaterial * determineMaterial(PRDHandleBase*); +}; + +//____________________________________________________________________ +SoSeparator* PRDHandleBase::sepSimple() const +{ + return m_d->sepSimple; +} + +//____________________________________________________________________ +SoSeparator* PRDHandleBase::sepDetailed() const +{ + return m_d->sepDetailed; +} + +//____________________________________________________________________ +PRDHandleBase::PRDHandleBase(PRDCollHandleBase*colhandle) + : m_d(new Imp), m_common(colhandle->common()),m_visible(false) +{ + m_d->colhandle = colhandle; + m_d->sepDetailed = 0; + m_d->sepSimple = 0; + m_d->currentmaterial = 0; + m_d->sephelper_lod_detail = 0; + m_d->sephelper_lod_simple = 0; +} + + +//____________________________________________________________________ +PRDHandleBase::~PRDHandleBase() +{ + if (m_d->sepDetailed) + m_d->sepDetailed->unref(); + if (m_d->sepSimple) + m_d->sepSimple->unref(); + if (m_d->currentmaterial) + m_d->currentmaterial->unref(); + + delete m_d; +} + +//____________________________________________________________________ +void PRDHandleBase::Imp::rebuild3DObjects(PRDHandleBase*theclass) +{ + //Fixme: + SoTransform * transform(0); + //If visible and already build: Detach separators (and ensure we got the sephelpers): + if (theclass->m_visible) { + if (!sephelper_lod_detail) { + int idx = theclass->regionIndex(); + colhandle->getLODSeparators(idx, sephelper_lod_detail,sephelper_lod_simple); + } + detach3DObjects(); + } + + //Ensure separators are built and with no children: + if (sepDetailed) { + //We might get transform from this one: + if (sepDetailed->getNumChildren()>0) { + transform = static_cast<SoTransform*>(sepDetailed->getChild(0)); + transform->ref(); + } + sepDetailed->removeAllChildren(); + } else { + sepDetailed = new SoSeparator; + sepDetailed->ref(); + // sepDetailed->renderCaching.setValue(SoSeparator::ON); + // sepDetailed->boundingBoxCaching.setValue(SoSeparator::ON); + } + if (sepSimple) { + sepSimple->removeAllChildren(); + } else { + sepSimple = new SoSeparator; + // sepSimple->renderCaching.setValue(SoSeparator::ON); + // sepSimple->boundingBoxCaching.setValue(SoSeparator::ON); + sepSimple->ref(); + } + //Attach transforms: + if (!transform) { + transform = theclass->createTransform(); + transform->ref(); + theclass->common()->registerTransform2Handle(transform,theclass); + } + sepDetailed->addChild(transform);//For efficiency it is important that this happens BEFORE buildShapes(..) is called. + sepSimple->addChild(transform); + transform->unref(); + + SoNode* shape_simple(0), * shape_detailed(0); + theclass->buildShapes(shape_simple, shape_detailed); + if (!shape_simple) + shape_simple = theclass->common()->nodeManager()->getShapeNode_Point();//Add single point as a stop-gap measure. + if (!shape_detailed) + shape_detailed = shape_simple;//Could not create detailed shape for some reason. Use simple shape instead. + + sepSimple->addChild(shape_simple); + sepDetailed->addChild(shape_detailed); + + //Attach if visible: + if (theclass->m_visible) + attach3DObjects(theclass); +} + +// //____________________________________________________________________ +// inline void PRDHandleBase::registerTransform(SoTransform*transform)//FIXME: Pass-through not needed +// { +// //Use this pass-through method to get around a friend-problem +// //FIXME common()->system()->registerTransform2Handle(transform,this); +// } + +//____________________________________________________________________ +void PRDHandleBase::updateMaterial() +{ + //We need to change the current material. This means we need to + //clear the cache. Only if we are visible do we need to do a + //detach->clear material->attach cycle to trigger attachment under new material. + + if (!m_d->currentmaterial) + return;//We have no material cached and is thus not attached either. + if (m_visible) { + //See if the material changed. If it did, detach, update the material, attach again. + SoMaterial * newmat = m_d->determineMaterial(this); + newmat->ref(); + if (newmat!=m_d->currentmaterial) { + m_d->detach3DObjects(); + m_d->currentmaterial->unref(); + m_d->currentmaterial = newmat; + m_d->attach3DObjects(this); + } else { + newmat->unref(); + } + } else { + //Just clear material. + m_d->currentmaterial->unref(); + m_d->currentmaterial = 0; + } +} + +//____________________________________________________________________ +void PRDHandleBase::Imp::attach3DObjects(PRDHandleBase*theclass) +{ + if (!currentmaterial) { + currentmaterial = determineMaterial(theclass); + currentmaterial->ref(); + } + if (sepDetailed) { + if (colhandle->sephelperDetailedNodes()) + colhandle->sephelperDetailedNodes()->addNodeUnderMaterial(sepDetailed,currentmaterial); + if (sephelper_lod_detail) + sephelper_lod_detail->addNodeUnderMaterial(sepDetailed,currentmaterial); + } + if (sepSimple) { + if (colhandle->sephelperSimpleNodes()) + colhandle->sephelperSimpleNodes()->addNodeUnderMaterial(sepSimple,currentmaterial); + if (sephelper_lod_simple) + sephelper_lod_simple->addNodeUnderMaterial(sepSimple,currentmaterial); + } +} + +//____________________________________________________________________ +void PRDHandleBase::Imp::detach3DObjects() +{ + if (!currentmaterial) + return;//Can never have been attached! + if (sepDetailed) { + if (colhandle->sephelperDetailedNodes()) + colhandle->sephelperDetailedNodes()->removeNodeUnderMaterial(sepDetailed,currentmaterial); + if (sephelper_lod_detail) + sephelper_lod_detail->removeNodeUnderMaterial(sepDetailed,currentmaterial); + } + if (sepSimple) { + if (colhandle->sephelperSimpleNodes()) + colhandle->sephelperSimpleNodes()->removeNodeUnderMaterial(sepSimple,currentmaterial); + if (sephelper_lod_simple) + sephelper_lod_simple->removeNodeUnderMaterial(sepSimple,currentmaterial); + } +} + +//____________________________________________________________________ +PRDCollHandleBase * PRDHandleBase::collHandle() const +{ + return m_d->colhandle; +} + +//____________________________________________________________________ +void PRDHandleBase::setVisible(bool vis) +{ + if (vis==m_visible) + return; + //std::cout<<"Changing visible status from "<<m_visible<<" to "<<vis<<" for: "<<*getPRD()<<std::endl; + m_visible=vis; + if (vis) { + m_d->colhandle->incrementNShownHandles(); + if (!m_d->sepSimple||!m_d->sepDetailed) + m_d->rebuild3DObjects(this);//The call to rebuild also fixes attached state. + else + m_d->attach3DObjects(this); + } else { + m_d->colhandle->decrementNShownHandles(); + m_d->detach3DObjects(); + } +} + +//____________________________________________________________________ +void PRDHandleBase::update3DObjects() { + //Fixme: If selected we really need to redo selection updates!!! + if (m_visible) { + m_d->rebuild3DObjects(this); + } else { + //Simply clear the present 3D objects. They will only be recreated if/when the prd becomes visible again. + if (m_d->sepDetailed) { + m_d->sepDetailed->unref(); + m_d->sepDetailed = 0; + } + if (m_d->sepSimple) { + m_d->sepSimple->unref(); + m_d->sepSimple = 0; + } + } + +} + +//____________________________________________________________________ +QStringList PRDHandleBase::clicked() const +{ + const Trk::PrepRawData * prd = getPRD(); + if (!prd) + return QStringList("Null PRD"); + std::ostringstream os; + os << *(prd); + return QString(os.str().c_str()).split("\n"); +} + + +//____________________________________________________________________ +Amg::Vector3D PRDHandleBase::Imp::positionPRD(const Trk::PrepRawData* prd) +{ + if (!prd) + return Amg::Vector3D(0,0,0); + if (!prd->detectorElement()) + return Amg::Vector3D(0.0,0.0,0.0); + const Trk::Surface& theSurface = prd->detectorElement()->surface(prd->identify()); + + const Amg::Vector3D hitpos = theSurface.localToGlobal(prd->localPosition()); + + const Amg::Vector3D pos(hitpos); + return pos; +} + +//____________________________________________________________________ +Amg::Vector3D PRDHandleBase::positionPRD() const +{ + return Imp::positionPRD(getPRD()); +} + +//____________________________________________________________________ +Amg::Vector3D PRDHandleBase::positionSecondPRD() const +{ + return Imp::positionPRD(getSecondPRD()); +} + + +//____________________________________________________________________ +Amg::Vector3D PRDHandleBase::center() const +{ + return positionPRD(); +} + +//____________________________________________________________________ +Amg::Transform3D PRDHandleBase::getTransform_CLHEP() const +{ + if (m_d->sepDetailed&&m_d->sepDetailed->getNumChildren()>0) { + //For efficiency/consistency we simply copy the transform from the + //inventor transformation (only loose slight precision in the + //double->float->double conversions): + SoTransform * transform = static_cast<SoTransform*>(m_d->sepDetailed->getChild(0)); + float tx, ty, tz; + transform->translation.getValue().getValue(tx,ty,tz); + SbVec3f so_rotaxis; + float so_rotangle; + transform->rotation.getValue().getValue(so_rotaxis, so_rotangle); + float rx, ry, rz; + so_rotaxis.getValue(rx,ry,rz); + Amg::Vector3D axis(rx,ry,rz); +// Amg::AngleAxis3D angleAxis = Amg::getRotation3DfromAngleAxis( so_rotangle, axis ); +// Amg::Rotation3D rot; +// rot = angleAxis; + Amg::Rotation3D rot = Amg::getRotation3DfromAngleAxis( so_rotangle, axis ); + return Amg::Translation3D(tx,ty,tz) * rot; + } + std::cout<<"VP1 PRDHandleBase Warning: getTransform_CLHEP called at inopportune moment!!"<<std::endl; + + //NB: Some code duplicated here and in the createTransform() method. + + const Trk::PrepRawData * prd = getPRD(); + if (!prd) { + return Amg::Transform3D::Identity(); + } + const Trk::Surface& theSurface = prd->detectorElement()->surface(prd->identify()); + Amg::Vector3D theHitGPos; + if ( transformUsesSurfacePositionOnly() ) { + // for tubes, should use position of center of tube (if drawing full tube) + theHitGPos= Amg::Vector3D(theSurface.center()); + } else { + // for clusters or short tubes, use position of hit. + theHitGPos = theSurface.localToGlobal(prd->localPosition()); //theSurface 'new s' a Vector3D and returns pointer + } + +// CLHEP::Hep3Vector t(theSurface.transform().getTranslation()); +// return HepGeom::Transform3D( HepGeom::Translate3D(theHitGPos->x()-t.x(),theHitGPos->y()-t.y(),theHitGPos->z()-t.z()) * (theSurface.transform()) ); + Amg::Vector3D t; + t = Amg::getTranslationVectorFromTransform(theSurface.transform()); + Amg::Translation3D transl = Amg::Translation3D(theHitGPos.x()-t.x(), theHitGPos.y()-t.y(), theHitGPos.z()-t.z()); + Amg::Transform3D transf = transl * (theSurface.transform()); + return transf; +} + +//____________________________________________________________________ +SoTransform * PRDHandleBase::createTransform() const +{ + //NB: Some code duplicated here and in the getTransform_CLHEP() method. + const Trk::PrepRawData * prd = getPRD(); + if (!prd) { + std::cerr<<"PRDHandleBase::createTransform() No prd!"<<std::endl; + return new SoTransform; + } + const Trk::Surface& theSurface = prd->detectorElement()->surface(prd->identify()); + SoTransform * theHitTransform = VP1LinAlgUtils::toSoTransform(theSurface.transform()); + + Amg::Vector3D theHitGPos; + if ( transformUsesSurfacePositionOnly() ) { + // for tubes, should use position of center of tube (if drawing full tube) + theHitGPos= Amg::Vector3D (theSurface.center()); + } else { + // for strips, clusters or short tubes, use position of hit. + theHitGPos = theSurface.localToGlobal(prd->localPosition()); + } + if ((theHitGPos)[0]!=(theHitGPos)[0] || (theHitGPos)[1]!=(theHitGPos)[1] || (theHitGPos)[2]!=(theHitGPos)[2]){ + std::cerr<<"PRDHandleBase::createTransform() NaN in globalposition"<<std::endl; + } + theHitTransform->translation.setValue((theHitGPos)[0], (theHitGPos)[1], (theHitGPos)[2]); + return theHitTransform; +} + +//____________________________________________________________________ +SoMaterial * PRDHandleBase::Imp::determineMaterial(PRDHandleBase*theclass) +{ + double hlw = colhandle->highLightWeight(); + //Get most frequent special case (i.e. no highlighting ) out of the + //way first for efficiency: + if (colhandle->colourMethod()!=PRDCollHandleBase::ByTechOnly) { + std::map<SoMaterial*,double> materials; + //-> Retrieve tracks/segments. + const PRDTrackSegmentHelper::TracksAndSegments * ts = theclass->common()->trackAndSegmentHelper()->tracksAndSegments(theclass->getPRD()); + if (ts) { + //-> Add all materials from tracks as appropriate + if (colhandle->colourByTracks()) { + for (unsigned i = 0; i < ts->tracks.size(); ++i) { + SoMaterial * mat = theclass->common()->trackAndSegmentHelper()->trackMaterial(ts->tracks[i]); + if (mat) + materials[mat]=1.0; + else + std::cout<< "PRDHandleBase ERROR: Did not find track material!"<<std::endl; + } + } + //-> Add all materials from segments as appropriate + if (colhandle->colourBySegments()) { + for (unsigned i = 0; i < ts->segments.size(); ++i) { + SoMaterial * mat = theclass->common()->trackAndSegmentHelper()->segmentMaterial(ts->segments[i]); + if (mat) + materials[mat]=1.0; + else + std::cout<< "PRDHandleBase ERROR: Did not find segment material (2)!"<<std::endl; + } + } + if (hlw>0.0&&colhandle->highLightOutliers()) { + //Add outliers (if colourbytracks) + a highlightmaterial, all with appropriate weights. + if (colhandle->colourByTracks()&&!ts->tracks_outliers.empty()) { + if (hlw>999.0) { + materials[colhandle->highLightMaterial()] = ts->tracks_outliers.size(); + } else { + for (unsigned i = 0; i < ts->tracks_outliers.size(); ++i) { + SoMaterial * mat = theclass->common()->trackAndSegmentHelper()->trackMaterial(ts->tracks_outliers[i]); + if (mat) + materials[mat]=1.0/(hlw+1.0); + else + std::cout<< "PRDHandleBase ERROR: Did not find track material (3)!"<<std::endl; + } + materials[colhandle->highLightMaterial()] = ts->tracks_outliers.size()*hlw/(hlw+1.0); + } + } + } else { + //Just add materials from outliers - and see if we need highlighting also. + if (colhandle->colourByTracks()) { + for (unsigned i = 0; i < ts->tracks_outliers.size(); ++i) { + SoMaterial * mat = theclass->common()->trackAndSegmentHelper()->trackMaterial(ts->tracks_outliers[i]); + if (mat) + materials[mat]=1.0; + else + std::cout<< "PRDHandleBase ERROR: Did not find track material (4)!"<<std::endl; + } + } + if (hlw>0.0&&!colhandle->highLightOutliers()&&theclass->highLight()) { + unsigned ntrackssegments= (colhandle->colourByTracks()?ts->tracks.size()+ts->tracks_outliers.size():0) + +(colhandle->colourBySegments()?ts->segments.size():0); + if (ntrackssegments) + materials[colhandle->highLightMaterial()] = hlw*ntrackssegments; + } + } + if (!materials.empty()) + return theclass->common()->materialMixer()->getMixedMaterial(materials); + } + } + + + //OK, just use the tech colour - and possibly some non-outlier-highlighting. + if (hlw>0.0&&!colhandle->highLightOutliers()&&theclass->highLight()) { + if (hlw>999.0) + return colhandle->highLightMaterial(); + return theclass->common()->materialMixer()->getMixedMaterial(colhandle->highLightMaterial(),hlw,colhandle->material(),1.0); + } else { + return colhandle->material(); + } +} diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDHandle_SCT.cxx b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDHandle_SCT.cxx new file mode 100644 index 0000000000000000000000000000000000000000..62a3eb28abf74da4a63d062ff83f1e5cf8c990bc --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDHandle_SCT.cxx @@ -0,0 +1,104 @@ +/* + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS and FASER collaborations +*/ + +#include "VTI12PRDSystems/PRDHandle_SCT.h" +#include "VTI12Utils/HitsSoNodeManager.h" +#include "VTI12PRDSystems/PRDCollHandle_SCT.h" +#include "VP1HEPVis/nodes/SoTransparency.h" + +#include <Inventor/nodes/SoSeparator.h> +#include <Inventor/nodes/SoTranslation.h> +#include <Inventor/nodes/SoMaterial.h> + +#include "TrackerReadoutGeometry/SiDetectorElement.h" + +#include "GeoPrimitives/GeoPrimitives.h" + + +//____________________________________________________________________ +PRDHandle_SCT::PRDHandle_SCT(PRDCollHandle_SCT*collhandle, const Tracker::FaserSCT_Cluster*clus) + : PRDHandleBase(static_cast<PRDCollHandleBase*>(collhandle)), m_cluster(clus) +{ + SoTransparency::initClass(); +} + +//____________________________________________________________________ +void PRDHandle_SCT::buildShapes(SoNode*&shape_simple, SoNode*&shape_detailed) +{ + double striplength = m_cluster->detectorElement()->etaPitch(); + + //SoSeparator * errSimple = new SoSeparator; + SoSeparator * errDetailed = new SoSeparator; + + //errSimple->addChild(common()->nodeManager()->getShapeNode_Strip(striplength)); + shape_simple=common()->nodeManager()->getShapeNode_Strip(striplength); + + const Amg::Vector2D& localpos = m_cluster->localPosition(); + const Amg::Vector2D& localposHIT = m_cluster->detectorElement()->rawLocalPositionOfCell( m_cluster->identify() ); // Lorentz shift is not corrected because this class cannot use SiLorentzAngleTool + SoTranslation * localtrans0 = new SoTranslation; + localtrans0->translation.setValue(localposHIT[Trk::locX]-localpos[Trk::locX],localposHIT[Trk::locY]-localpos[Trk::locY],0); + + const std::vector<Identifier> rdolist = m_cluster->rdoList(); + if (rdolist.size() == 1 || !collHandle()->drawRDOs()) + { + errDetailed->addChild(localtrans0); + errDetailed->addChild(common()->nodeManager()->getShapeNode_Strip(striplength, + m_cluster->detectorElement()->phiPitch( m_cluster->localPosition() ),//strip width + m_cluster->detectorElement()->thickness()*3.0)); + //strip thickness - scaled up by factor of 3 (looks better) + //Fixme: Should we drop this upscaling of thickness? + + //Translate back so errDetailed is left sane (eg. when drawing errors later) + SoTranslation * localtransBack = new SoTranslation; + localtransBack->translation.setValue(-(localtrans0->translation.getValue())); + errDetailed->addChild(localtransBack); + } else + { + SoSeparator * rdos = new SoSeparator; + rdos->addChild(localtrans0); + + rdos->addChild(common()->nodeManager()->getShapeNode_Strip(striplength, + m_cluster->detectorElement()->phiPitch( m_cluster->localPosition() ),//strip width + m_cluster->detectorElement()->thickness()*3.0)); + //strip thickness - scaled up by factor of 3 (looks better) + //Fixme: Should we drop this upscaling of thickness? + + SoTransparency * transparent = new SoTransparency; + transparent->transparency.setValue(0.5); + rdos->addChild( transparent ); + Amg::Vector2D localposOLD = localposHIT; + for (const Identifier& rdo_id : rdolist) + { + if (rdo_id == m_cluster->identify() ) + continue; + + const Amg::Vector2D& localposRDO = m_cluster->detectorElement()->rawLocalPositionOfCell(rdo_id); // Lorentz shift is not corrected because this class cannot use SiLorentzAngleTool + + SoTranslation * localtrans = new SoTranslation; + localtrans->translation.setValue(localposRDO[Trk::locX]-localposOLD[Trk::locX],localposRDO[Trk::locY]-localposOLD[Trk::locY],0); + rdos->addChild(localtrans); + + rdos->addChild(common()->nodeManager()->getShapeNode_Strip(striplength, + m_cluster->detectorElement()->phiPitch( m_cluster->localPosition() ),//strip width + m_cluster->detectorElement()->thickness()*3.0)); + + localposOLD = localposRDO; + } + errDetailed->addChild(rdos); + } + +// shape_simple = errSimple; + shape_detailed = errDetailed; +} + +//____________________________________________________________________ +int PRDHandle_SCT::regionIndex() +{ + //instead of identifier juggling, we simply discretize by center coordinate. + static const double l=100.0;//CLHEP::mm + return static_cast<int>(m_cluster->detectorElement()->center().z()/l) + +1000*static_cast<int>(m_cluster->detectorElement()->center().y()/l) + +1000000*static_cast<int>(m_cluster->detectorElement()->center().x()/l); + //Fixme: Use identifiers instead for more intuitive regions. +} diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDHandle_SpacePoint.cxx b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDHandle_SpacePoint.cxx new file mode 100644 index 0000000000000000000000000000000000000000..0616dc8168c609e7db9d2367659f022a3d2da63a --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDHandle_SpacePoint.cxx @@ -0,0 +1,69 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS and FASER collaborations +*/ + + +//////////////////////////////////////////////////////////////// +// // +// Implementation of class PRDHandle_SpacePoint // +// // +// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) // +// Initial version: September 2008 // +// // +// update: March 2014 Riccardo.Maria.Bianchi@cern.ch// +// // +//////////////////////////////////////////////////////////////// + +#include "VTI12PRDSystems/PRDHandle_SpacePoint.h" +#include "VTI12PRDSystems/PRDCollHandle_SpacePoints.h" +#include "VTI12Utils/HitsSoNodeManager.h" + +#include <Inventor/C/errors/debugerror.h> +#include <Inventor/nodes/SoPointSet.h> +#include <Inventor/nodes/SoVertexProperty.h> + +//____________________________________________________________________ +class PRDHandle_SpacePoint::Imp { +public: +}; + + +//____________________________________________________________________ +PRDHandle_SpacePoint::PRDHandle_SpacePoint(PRDCollHandle_SpacePoints* ch, const Tracker::FaserSCT_SpacePoint* sp) + : PRDHandleBase(ch), m_sp(sp), m_d(new Imp) +{ +} + +//____________________________________________________________________ +PRDHandle_SpacePoint::~PRDHandle_SpacePoint() +{ + delete m_d; +} + +//____________________________________________________________________ +int PRDHandle_SpacePoint::regionIndex() { + static const double l=isSCT() ? 100.0 : 200.0;//CLHEP::mm + Amg::Vector3D c(center()); + return static_cast<int>(c.z()/l) + +1000*static_cast<int>(c.y()/l) + +1000000*static_cast<int>(c.x()/l); + //Fixme: Use identifiers instead for more intuitive regions. +} + +//____________________________________________________________________ +void PRDHandle_SpacePoint::buildShapes(SoNode*&shape_simple, SoNode*&shape_detailed) +{ + if (getSecondPRD()) { + Amg::Transform3D prdtransform(getTransform_CLHEP()); + Amg::Vector3D p((prdtransform.inverse())*(m_sp->globalPosition())); + SoPointSet * points = new SoPointSet; + SoVertexProperty * vertices = new SoVertexProperty; + vertices->vertex.set1Value(0,p.x(),p.y(),p.z()); + points->numPoints=1; + points->vertexProperty.setValue(vertices); + shape_simple = points; + } else { + shape_simple = common()->nodeManager()->getShapeNode_Point(); + } + shape_detailed = shape_simple; +} diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDSysCommonData.cxx b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDSysCommonData.cxx new file mode 100644 index 0000000000000000000000000000000000000000..088878c57065aa5129d6a86fa71092cae83a34f6 --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDSysCommonData.cxx @@ -0,0 +1,111 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS and FASER collaborations +*/ + + +//////////////////////////////////////////////////////////////// +// // +// Implementation of class PRDSysCommonData // +// // +// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) // +// Initial version: July 2008 // +// // +//////////////////////////////////////////////////////////////// + +#include "VTI12PRDSystems/PRDSysCommonData.h" +#include "VP1Base/IVP13DSystem.h" + +#include "VTI12Utils/HitsSoNodeManager.h" +#include "VTI12PRDSystems/PRDSystemController.h" +#include "VTI12PRDSystems/PRDTrackSegmentHelper.h" + +// #include "VP1GuideLineSystems/InDetProjHelper.h" +#include "VP1Base/VP1SoMaterialMixer.h" + +#include <Inventor/C/errors/debugerror.h> +#include <Inventor/nodes/SoSeparator.h> +#include <Inventor/nodes/SoTransform.h> +#include <Inventor/SoPath.h> + + +//____________________________________________________________________ +class PRDSysCommonData::Imp { +public: + //The following map is used to figure out which handle a clicked node corresponds to. + //We use the SoTransform node to uniquely identify this association. + std::map<SoNode*,PRDHandleBase*> sotransform2prdhandle; + PRDHandleBase * pickedPathToHandle( SoPath*pickedPath ); + + //The following map is used to find handles for a given prd pointer: + std::map< const Trk::PrepRawData *, QList<PRDHandleBase *> > prd2handles; +}; + + +//____________________________________________________________________ +PRDSysCommonData::PRDSysCommonData(IVP13DSystem *sys, PRDSystemController*controller) + : VP1HelperClassBase(sys,"PRDSysCommonData"), m_d(new Imp), + m_controller(controller) +{ + m_3dsystem = sys; + m_nodeManager = new HitsSoNodeManager(sys); + m_materialMixer = new VP1SoMaterialMixer; +// m_indetProjHelper_SCT = InDetProjHelper::createSCTHelper(sys); + + m_trackAndSegmentHelper = new PRDTrackSegmentHelper(&(m_d->prd2handles),sys); +} + +//____________________________________________________________________ +PRDSysCommonData::~PRDSysCommonData() +{ + delete m_nodeManager; + delete m_materialMixer; +// delete m_indetProjHelper_SCT; + delete m_trackAndSegmentHelper; + delete m_d; +} + +//____________________________________________________________________ +void PRDSysCommonData::clearEventData() +{ + m_d->sotransform2prdhandle.clear(); + m_d->prd2handles.clear(); +} + + +//_____________________________________________________________________________________ +void PRDSysCommonData::registerTransform2Handle(SoTransform*transform,PRDHandleBase*handle) +{ + assert(m_d->sotransform2prdhandle.find(transform)==m_d->sotransform2prdhandle.end()); + m_d->sotransform2prdhandle[transform] = handle; +} + +//_____________________________________________________________________________________ +void PRDSysCommonData::registerPRD2Handle(const Trk::PrepRawData*prd,PRDHandleBase*handle) +{ + if (m_d->prd2handles.find(prd)==m_d->prd2handles.end()) { + QList<PRDHandleBase*> l; + l<<handle; + m_d->prd2handles[prd] = l; + } else { + m_d->prd2handles[prd] << handle; + } +} + +//_____________________________________________________________________________________ +PRDHandleBase * PRDSysCommonData::pickedPathToHandle( SoPath*pickedPath ) +{ + while (pickedPath->getLength()>4) {//4 is a bit arbitrary... + if (pickedPath->getNodeFromTail(0)->getTypeId()==SoSeparator::getClassTypeId()) { + //If at least two children and the first is an SoTransform, then it might be what we are looking for. + SoSeparator * sep = static_cast<SoSeparator*>(pickedPath->getNodeFromTail(0)); + if (sep->getNumChildren()>1&&sep->getChild(0)->getTypeId()==SoTransform::getClassTypeId()) { + std::map<SoNode*,PRDHandleBase*>::iterator it = m_d->sotransform2prdhandle.find(sep->getChild(0)); + if ( it!=m_d->sotransform2prdhandle.end()) + return it->second; + } + } + pickedPath->pop();//FIXME: NO NEED TO DO ANYTHING ELSE THAN FIND THE HANDLE!! + } + return 0; +} + diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDSystemController.cxx b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDSystemController.cxx new file mode 100644 index 0000000000000000000000000000000000000000..ab57c6cb1b4facb4de3639b23185887940b03273 --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDSystemController.cxx @@ -0,0 +1,501 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS and FASER collaborations +*/ + +//////////////////////////////////////////////////////////////// +// // +// Implementation of class PRDSystemController // +// // +// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) // +// Initial version: November 2007 // +// // +//////////////////////////////////////////////////////////////// + +#define VP1IMPVARNAME m_d + +#include "VTI12PRDSystems/PRDSystemController.h" +#include "ui_vp1prdcontrollerform.h" +#include "ui_prd_settings_cuts_form.h" +#include "ui_prd_settings_display_form.h" +#include "ui_prd_settings_interactions_form.h" +#include "VP1Base/VP1QtInventorUtils.h" +#include "VP1Base/VP1Serialise.h" +#include "VP1Base/VP1Deserialise.h" +#include "VP1Base/VP1QtUtils.h" +#include "VP1Base/VP1CollectionWidget.h" +#include <Inventor/nodes/SoMaterial.h> +#include <QBuffer> +#include <QTimer> +#include <QSet> + +//____________________________________________________________________ +class PRDSystemController::Imp { +public: + PRDSystemController * theclass = nullptr; + Ui::VP1PrdControllerForm ui{}; + Ui::PRDSysSettingsInteractionsForm ui_int{}; + Ui::PRDSysSettingsDisplayForm ui_disp{}; + Ui::PRDSysSettingsCutsForm ui_cuts{}; + VP1CollectionWidget * collWidget = nullptr; + + SoMaterial * highlightmaterial = nullptr; + + PRDCollHandleBase::COLOURMETHOD last_colourMethod; + bool last_drawErrors = false; + bool last_drawRDOs = false; + bool last_highLightOutliers = false; + double last_highLightMaterialWeight = 0.0; + bool last_projectSCTHits = false; + //Cuts: + VP1Interval last_cutAllowedEta; + QList<VP1Interval> last_cutAllowedPhi;//All off: empty list. All on: list with one entry: ]-inf,inf[ + PRDCommonFlags::TrackerPartsFlags last_trackerPartsFlags; + bool last_sctExcludeIsolatedClusters = false; + std::set<PRDDetType::Type> last_shownCollectionTypes; + bool last_selectionModeMultiple = false; + bool last_showSelectionLine = false; + //Used ID parts: +// InDetProjFlags::DetTypeFlags last_inDetPartsUsingProjections; + + QSet<PRDDetType::Type> shownCollectionTypes() const; +}; + +//____________________________________________________________________ +PRDSystemController::PRDSystemController(IVP1System * sys) + : VP1Controller(sys,"PRDSystemController"),m_d(new Imp) +{ + m_d->theclass = this; + m_d->ui.setupUi(this); + + //FIXME: Dialogs and collwidget! + m_d->collWidget = new VP1CollectionWidget; + // m_d->trackcollwidget = new TrackCollWidget; + setupCollWidgetInScrollArea(m_d->ui.collWidgetScrollArea,m_d->collWidget); + initDialog(m_d->ui_cuts, m_d->ui.pushButton_settings_cuts); + initDialog(m_d->ui_disp, m_d->ui.pushButton_settings_display); + initDialog(m_d->ui_int, m_d->ui.pushButton_settings_interactions); + + m_d->highlightmaterial = 0; + + m_d->ui_int.matButton_multiselline->setMaterial(VP1MaterialButton::createMaterial(1,1,0)); + + m_d->ui_cuts.groupBox_cuts_tracksegmentassociation->setVisible(false);//Since it is not used at the moment! + if (!VP1QtUtils::environmentVariableIsOn("VP1_DEVEL_ENABLEREFIT")) + m_d->ui_int.groupBox_selectionMode->setVisible(false); + + m_d->ui_disp.widget_drawOptions_PixelSCT->setComplexityDisabled(); + m_d->ui_disp.widget_drawOptions_PixelSCT->setPointSizes(3.0); + + m_d->ui_cuts.etaPhiCutWidget->setEtaCutEnabled(false); + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Setup connections which monitor changes in the controller so that we may emit signals as appropriate: // + ///////////////////////////////////////////////////////////////////////////////////////////////////////////// + + addUpdateSlot(SLOT(possibleChange_colourMethod())); + connectToLastUpdateSlot(m_d->ui_disp.checkBox_colourByTrack); + connectToLastUpdateSlot(m_d->ui_disp.checkBox_colourBySegment); + + addUpdateSlot(SLOT(possibleChange_drawErrors())); + connectToLastUpdateSlot(m_d->ui_disp.checkBox_drawErrors); + + addUpdateSlot(SLOT(possibleChange_drawRDOs())); + connectToLastUpdateSlot(m_d->ui_disp.checkBox_drawRDOs); + + addUpdateSlot(SLOT(possibleChange_highLightOutliers())); + connectToLastUpdateSlot(m_d->ui_disp.horizontalSlider_highlights_intensity); + + addUpdateSlot(SLOT(possibleChange_highLightMaterialWeight())); + connectToLastUpdateSlot(m_d->ui_disp.horizontalSlider_highlights_intensity); + + addUpdateSlot(SLOT(possibleChange_highLightOutliers())); + connectToLastUpdateSlot(m_d->ui_disp.checkBox_highlight_trackoutliers); + connectToLastUpdateSlot(m_d->ui_disp.checkBox_colourByTrack); + connectToLastUpdateSlot(m_d->ui_disp.horizontalSlider_highlights_intensity); + +// addUpdateSlot(SLOT(possibleChange_projectSCTHits())); +// connectToLastUpdateSlot(m_d->ui_disp.checkBox_showsct_projected); + + addUpdateSlot(SLOT(possibleChange_cutAllowedEta())); + connectToLastUpdateSlot(m_d->ui_cuts.etaPhiCutWidget,SIGNAL(allowedEtaChanged(const VP1Interval&))); + + addUpdateSlot(SLOT(possibleChange_cutAllowedPhi())); + connectToLastUpdateSlot(m_d->ui_cuts.etaPhiCutWidget,SIGNAL(allowedPhiChanged(const QList<VP1Interval>&))); + + addUpdateSlot(SLOT(possibleChange_trackerPartsFlags())); + connectToLastUpdateSlot(m_d->ui_cuts.checkBox_cut_tracker_interface); + connectToLastUpdateSlot(m_d->ui_cuts.checkBox_cut_tracker_upstream); + connectToLastUpdateSlot(m_d->ui_cuts.checkBox_cut_tracker_central); + connectToLastUpdateSlot(m_d->ui_cuts.checkBox_cut_tracker_downstream); + + addUpdateSlot(SLOT(possibleChange_sctExcludeIsolatedClusters())); + connectToLastUpdateSlot(m_d->ui_cuts.checkBox_cut_sct_excludeisolatedclusters); + + // addUpdateSlot(SLOT(possibleChange_inDetPartsUsingProjections())); + // connectToLastUpdateSlot(this,SIGNAL(projectSCTHitsChanged(bool))); + // connectToLastUpdateSlot(this,SIGNAL(trackerPartsFlagsChanged(PRDCommonFlags::TrackerPartsFlags))); + // connectToLastUpdateSlot(collWidget(),SIGNAL(visibleStdCollectionTypesChanged(const QList<qint32>&))); + + addUpdateSlot(SLOT(possibleChange_selectionModeMultiple())); + connectToLastUpdateSlot(m_d->ui_int.checkBox_selModeMultiple); + + addUpdateSlot(SLOT(possibleChange_showSelectionLine())); + connectToLastUpdateSlot(m_d->ui_int.checkBox_showSelectionLine); + + addUpdateSlot(SLOT(possibleChange_shownCollectionTypes())); + connectToLastUpdateSlot(collWidget(),SIGNAL(visibleStdCollectionTypesChanged(const QList<qint32>&))); + + // addUpdateSlot(SLOT(updateHighlightGui())); + // connectToLastUpdateSlot(this,SIGNAL(highLightOutliersChanged(bool))); + + //Stateless: + connect(m_d->ui_int.pushButton_clearSelection,SIGNAL(clicked()),this,SLOT(emitClearSelection())); + + initLastVars(); + +} + +//____________________________________________________________________ +PRDSystemController::~PRDSystemController() +{ + if (m_d->highlightmaterial) + m_d->highlightmaterial->unref(); + delete m_d; +} + +//____________________________________________________________________ +VP1CollectionWidget * PRDSystemController::collWidget() const +{ + return m_d->collWidget; +} + +//____________________________________________________________________ +SoGroup * PRDSystemController::drawOptions(PRDDetType::Type t) const +{ + //FIXME: SET APPROPRIATE DEFAULTS!!!! + switch (t) { + case PRDDetType::SCT: + case PRDDetType::SpacePoints: + return m_d->ui_disp.widget_drawOptions_PixelSCT->drawOptionsGroup(); + default: + return m_d->ui_disp.widget_drawOptions_PixelSCT->drawOptionsGroup(); + } +} + +//____________________________________________________________________ +QSet<PRDDetType::Type> PRDSystemController::Imp::shownCollectionTypes() const +{ + QSet<PRDDetType::Type> s; + foreach (qint32 i,collWidget->visibleStdCollectionTypes()) { + bool ok; + PRDDetType::Type t = PRDDetType::intToType(i,ok); + if (ok) + s.insert(t); + } + return s; +} + +//____________________________________________________________________ +SoMaterial * PRDSystemController::getMultiSelectionLineMaterial() const +{ + QList<SoMaterial*> mats = m_d->ui_int.matButton_multiselline->handledMaterials(); + if (mats.count()!=1) { + message("ERROR: No material in button!"); + return 0;//probably giving a crash... + } + return mats.at(0); +} + +//____________________________________________________________________ +void PRDSystemController::emitClearSelection() +{ + messageVerbose("Emitting clearSelection()"); + emit clearSelection(); +} + +//____________________________________________________________________ +SoMaterial * PRDSystemController::getHighLightMaterial() +{ + if (!m_d->highlightmaterial) { + m_d->highlightmaterial = new SoMaterial; + m_d->highlightmaterial->ref(); + m_d->highlightmaterial->diffuseColor.setValue( 1.0f, 0.0f, 0.0f ); + m_d->ui_disp.materialbutton_highlights_material->copyValuesFromMaterial(m_d->highlightmaterial); + m_d->ui_disp.materialbutton_highlights_material->handleMaterial(m_d->highlightmaterial); + } + return m_d->highlightmaterial; +} + +//____________________________________________________________________ +bool PRDSystemController::printInfoOnClick() const +{ + return m_d->ui_int.checkBox_printinfo->isChecked(); +} + +//____________________________________________________________________ +bool PRDSystemController::zoomOnClick() const +{ + return m_d->ui_int.checkBox_zoom->isChecked(); +} + +//____________________________________________________________________ +VP1Interval PRDSystemController::cutAllowedEta() const +{ + return m_d->ui_cuts.etaPhiCutWidget->allowedEta(); +} + +//____________________________________________________________________ +QList<VP1Interval> PRDSystemController::cutAllowedPhi() const +{ + return m_d->ui_cuts.etaPhiCutWidget->allowedPhi(); +} + +//____________________________________________________________________ +PRDCommonFlags::TrackerPartsFlags PRDSystemController::trackerPartsFlags() const +{ + PRDCommonFlags::TrackerPartsFlags flag = PRDCommonFlags::None; + if (m_d->ui_cuts.checkBox_cut_tracker_interface->isChecked()) flag |= PRDCommonFlags::Interface; + if (m_d->ui_cuts.checkBox_cut_tracker_upstream->isChecked()) flag |= PRDCommonFlags::Upstream; + if (m_d->ui_cuts.checkBox_cut_tracker_central->isChecked()) flag |= PRDCommonFlags::Central; + if (m_d->ui_cuts.checkBox_cut_tracker_downstream->isChecked()) flag |= PRDCommonFlags::Downstream; + return flag; +} + +//____________________________________________________________________ +bool PRDSystemController::sctExcludeIsolatedClusters() const +{ + return m_d->ui_cuts.checkBox_cut_sct_excludeisolatedclusters->isChecked(); +} + +//____________________________________________________________________ +PRDCollHandleBase::COLOURMETHOD PRDSystemController::colourMethod() const +{ + if (m_d->ui_disp.checkBox_colourByTrack->isChecked()) { + if (m_d->ui_disp.checkBox_colourBySegment->isChecked()) + return PRDCollHandleBase::BySegmentAndTrack; + else + return PRDCollHandleBase::ByTrack; + } else { + if (m_d->ui_disp.checkBox_colourBySegment->isChecked()) + return PRDCollHandleBase::BySegment; + else + return PRDCollHandleBase::ByTechOnly; + } +} + +//____________________________________________________________________ +bool PRDSystemController::drawErrors() const +{ + if (m_d->ui_disp.checkBox_drawErrors->isChecked()) return true; + return false; +} + +//____________________________________________________________________ +bool PRDSystemController::drawRDOs() const +{ + if (m_d->ui_disp.checkBox_drawRDOs->isChecked()) return true; + return false; +} + + +//____________________________________________________________________ +bool PRDSystemController::highLightOutliers() const +{ + return highLightMaterialWeight() != 0.0 + && m_d->ui_disp.checkBox_highlight_trackoutliers->isChecked() && m_d->ui_disp.checkBox_colourByTrack->isChecked(); +} + +// //____________________________________________________________________ +// void PRDSystemController::updateHighlightGui() +// { +// const bool outlierHLEnabledInGui(m_d->ui_disp.checkBox_highlight_trackoutliers->isChecked() && m_d->ui_disp.checkBox_colourByTrack->isChecked()); +// m_d->ui_disp.checkBox_highlight_trtht->setEnabled(!outlierHLEnabledInGui); +// m_d->ui_disp.checkBox_highlight_maskedmdts->setEnabled(!outlierHLEnabledInGui); +// m_d->ui_disp.checkBox_highlight_mdt_ADC_below->setEnabled(!outlierHLEnabledInGui); +// m_d->ui_disp.spinBox_highlight_mdt_ADC_below->setEnabled(!outlierHLEnabledInGui); +// } + +//____________________________________________________________________ +double PRDSystemController::highLightMaterialWeight() const +{ + int val = m_d->ui_disp.horizontalSlider_highlights_intensity->value(); + if (val<=1) return 0.0; + if (val==2) return 1.0; + if (val==3) return 1.9; + if (val==4) return 2.8; + if (val==5) return 5.0; + return 99999.0; +} + +//____________________________________________________________________ +// bool PRDSystemController::projectSCTHits() const { return m_d->ui_disp.checkBox_showsct_projected->isChecked(); } + +// //____________________________________________________________________ +// InDetProjFlags::DetTypeFlags PRDSystemController::inDetPartsUsingProjections() const +// { +// std::set<PRDDetType::Type> showncolltypes = shownCollectionTypes(); +// PRDCommonFlags::InDetPartsFlags indetparts = inDetPartsFlags(); + +// InDetProjFlags::DetTypeFlags flag = InDetProjFlags::NoDet; + +// if ( projectPixelHits() && showncolltypes.find(PRDDetType::Pixel)!=showncolltypes.end() ) { +// if (indetparts & PRDCommonFlags::BarrelPositive) +// flag |= InDetProjFlags::Pixel_brlpos; +// if (indetparts & PRDCommonFlags::BarrelNegative) +// flag |= InDetProjFlags::Pixel_brlneg; +// if (indetparts & PRDCommonFlags::EndCapPositive) +// flag |= InDetProjFlags::Pixel_ecpos; +// if (indetparts & PRDCommonFlags::EndCapNegative) +// flag |= InDetProjFlags::Pixel_ecneg; +// } + +// if ( projectSCTHits() && showncolltypes.find(PRDDetType::SCT)!=showncolltypes.end() ) { +// if (indetparts & PRDCommonFlags::BarrelPositive) +// flag |= InDetProjFlags::SCT_brlpos; +// if (indetparts & PRDCommonFlags::BarrelNegative) +// flag |= InDetProjFlags::SCT_brlneg; +// if (indetparts & PRDCommonFlags::EndCapPositive) +// flag |= InDetProjFlags::SCT_ecpos; +// if (indetparts & PRDCommonFlags::EndCapNegative) +// flag |= InDetProjFlags::SCT_ecneg; +// } + +// if ( projectTRTHits() && showncolltypes.find(PRDDetType::TRT)!=showncolltypes.end() ) { +// if (indetparts & PRDCommonFlags::BarrelPositive) +// flag |= InDetProjFlags::TRT_brlpos; +// if (indetparts & PRDCommonFlags::BarrelNegative) +// flag |= InDetProjFlags::TRT_brlneg; +// if (indetparts & PRDCommonFlags::EndCapPositive) +// flag |= InDetProjFlags::TRT_ecpos; +// if (indetparts & PRDCommonFlags::EndCapNegative) +// flag |= InDetProjFlags::TRT_ecneg; +// } + +// return flag; +// } + +//____________________________________________________________________ +bool PRDSystemController::selectionModeMultiple() const +{ + return m_d->ui_int.checkBox_selModeMultiple->isChecked(); +} + +//____________________________________________________________________ +bool PRDSystemController::showSelectionLine() const +{ + return m_d->ui_int.checkBox_showSelectionLine->isChecked(); +} + +//____________________________________________________________________ +std::set<PRDDetType::Type> PRDSystemController::shownCollectionTypes() const +{ + std::set<PRDDetType::Type> s; + foreach(qint32 i, collWidget()->visibleStdCollectionTypes()) { + bool ok; + PRDDetType::Type t = PRDDetType::intToType(i, ok); + if (ok) + s.insert(t); + else + message("shownCollectionTypes ERROR: Could not decode collection type"); + } + return s; +} + + +//____________________________________________________________________ +int PRDSystemController::currentSettingsVersion() const +{ + return 1; +} + +//____________________________________________________________________ +void PRDSystemController::actualSaveSettings(VP1Serialise&s) const +{ + s.save(m_d->ui_disp.checkBox_colourByTrack); + s.save(m_d->ui_disp.checkBox_colourBySegment); + s.save(m_d->ui_disp.checkBox_highlight_trackoutliers); + s.save(m_d->ui_cuts.checkBox_cut_tracker_interface); + s.save(m_d->ui_cuts.checkBox_cut_tracker_upstream); + s.save(m_d->ui_cuts.checkBox_cut_tracker_central); + s.save(m_d->ui_cuts.checkBox_cut_tracker_downstream); + s.save(m_d->ui_cuts.checkBox_cut_sct_excludeisolatedclusters); +// s.save(m_d->ui_disp.checkBox_showsct_projected); + s.save(m_d->ui_disp.horizontalSlider_highlights_intensity); + s.save(m_d->ui_disp.materialbutton_highlights_material); + s.save(m_d->ui_int.checkBox_selModeMultiple); + s.save(m_d->ui_int.checkBox_showSelectionLine); + s.save(m_d->ui_int.matButton_multiselline); + s.save(m_d->ui_cuts.etaPhiCutWidget); + s.save(m_d->ui_disp.widget_drawOptions_PixelSCT); + s.save(m_d->ui_int.checkBox_printinfo); + s.save(m_d->ui_int.checkBox_zoom); + + s.save(m_d->ui_disp.checkBox_drawErrors); + s.save(m_d->ui_disp.checkBox_drawRDOs); + + //Not used yet: + s.ignoreWidget(m_d->ui_cuts.checkBox_cuts_ts_exclude_hits_on_track); + s.ignoreWidget(m_d->ui_cuts.checkBox_cuts_ts_exclude_hits_not_on_track); + s.ignoreWidget(m_d->ui_cuts.checkBox_cuts_ts_exclude_hits_on_segments); + s.ignoreWidget(m_d->ui_cuts.checkBox_cuts_ts_exclude_not_on_segments); + +} + + +//____________________________________________________________________ +void PRDSystemController::actualRestoreSettings(VP1Deserialise& s) +{ + if (s.version()<0||s.version()>1) { + message("Warning: State data in .vp1 file has unsupported version ("+str(s.version())+")"); + return; + } + s.restore(m_d->ui_disp.checkBox_colourByTrack); + s.restore(m_d->ui_disp.checkBox_colourBySegment); + s.restore(m_d->ui_disp.checkBox_highlight_trackoutliers); + s.restore(m_d->ui_cuts.checkBox_cut_tracker_interface); + s.restore(m_d->ui_cuts.checkBox_cut_tracker_upstream); + s.restore(m_d->ui_cuts.checkBox_cut_tracker_central); + s.restore(m_d->ui_cuts.checkBox_cut_tracker_downstream); + s.restore(m_d->ui_cuts.checkBox_cut_sct_excludeisolatedclusters); +// s.restore(m_d->ui_disp.checkBox_showsct_projected); + s.restore(m_d->ui_disp.horizontalSlider_highlights_intensity); + s.restore(m_d->ui_disp.materialbutton_highlights_material); + s.restore(m_d->ui_int.checkBox_selModeMultiple); + s.restore(m_d->ui_int.checkBox_showSelectionLine); + s.restore(m_d->ui_int.matButton_multiselline); + s.restore(m_d->ui_cuts.etaPhiCutWidget); + s.restore(m_d->ui_disp.widget_drawOptions_PixelSCT); + s.restore(m_d->ui_int.checkBox_printinfo); + s.restore(m_d->ui_int.checkBox_zoom); + + s.restore(m_d->ui_disp.checkBox_drawErrors); + s.restore(m_d->ui_disp.checkBox_drawRDOs); + + //Not used yet: + s.ignoreWidget(m_d->ui_cuts.checkBox_cuts_ts_exclude_hits_on_track); + s.ignoreWidget(m_d->ui_cuts.checkBox_cuts_ts_exclude_hits_not_on_track); + s.ignoreWidget(m_d->ui_cuts.checkBox_cuts_ts_exclude_hits_on_segments); + s.ignoreWidget(m_d->ui_cuts.checkBox_cuts_ts_exclude_not_on_segments); +} + +/////////////////////////////////////////////////////////////////////////// +// Test for possible changes in values and emit signals as appropriate: +// (possibleChange_XXX() slots code provided by macros) +#define VP1CONTROLLERCLASSNAME PRDSystemController +#include "VP1Base/VP1ControllerMacros.h" + +//The actual code for each variable: +// POSSIBLECHANGE_IMP(projectSCTHits) +POSSIBLECHANGE_IMP(highLightMaterialWeight) +// POSSIBLECHANGE_IMP(inDetPartsUsingProjections) +POSSIBLECHANGE_IMP(cutAllowedEta) +POSSIBLECHANGE_IMP(cutAllowedPhi) +POSSIBLECHANGE_IMP(trackerPartsFlags) +POSSIBLECHANGE_IMP(sctExcludeIsolatedClusters) +POSSIBLECHANGE_IMP(shownCollectionTypes) +POSSIBLECHANGE_IMP(selectionModeMultiple) +POSSIBLECHANGE_IMP(showSelectionLine) +POSSIBLECHANGE_IMP(colourMethod) +POSSIBLECHANGE_IMP(highLightOutliers) +POSSIBLECHANGE_IMP(drawErrors) +POSSIBLECHANGE_IMP(drawRDOs) diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDTrackSegmentHelper.cxx b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDTrackSegmentHelper.cxx new file mode 100644 index 0000000000000000000000000000000000000000..6c95319ca563ca46604349f10e4ad53dde1ec378 --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/PRDTrackSegmentHelper.cxx @@ -0,0 +1,532 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS and FASER collaborations +*/ + + +//////////////////////////////////////////////////////////////// +// // +// Implementation of class PRDTrackSegmentHelper // +// // +// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) // +// Initial version: December 2007 // +// // +//////////////////////////////////////////////////////////////// + +#include "VTI12PRDSystems/PRDTrackSegmentHelper.h" +#include "VTI12PRDSystems/PRDCollHandleBase.h" +#include "VTI12PRDSystems/PRDHandleBase.h" + +#include "TrkMeasurementBase/MeasurementBase.h" +#include "TrkRIO_OnTrack/RIO_OnTrack.h" +#include "TrkCompetingRIOsOnTrack/CompetingRIOsOnTrack.h" +#include "AthContainers/DataVector.h" +#include "TrkTrack/Track.h" +#include "TrkSegment/Segment.h" + +#include <set> + +//____________________________________________________________________ +class PRDTrackSegmentHelper::Imp { +public: + PRDTrackSegmentHelper * theclass = nullptr; + std::map< const Trk::PrepRawData *, QList<PRDHandleBase *> >* prd2handles = nullptr; + + std::map< const Trk::Track*, const SoMaterial* > tracks2mat; + std::map< const Trk::Segment*, const SoMaterial* > segments2mat; + + + void addTrackToPRDs(const Trk::Track *, bool outliers ); + void removeTrackFromPRDs(const Trk::Track *, bool outliers); + void updateMaterialOfPRDs(const Trk::Track *, bool outliers ); + + void addSegmentToPRDs(const Trk::Segment * ); + void removeSegmentFromPRDs(const Trk::Segment *); + void updateMaterialOfPRDs(const Trk::Segment * ); + + template <class T> + void removeEntryFromVector(std::vector<T*>&v,T*t);//Removes first occurrence of t from v (does nothing if not found). + //Element order is not preserved. FIXME: To utility class. + + //static inline const Trk::PrepRawData* measurementToPRD(const Trk::MeasurementBase*);//Might return null. + static inline std::vector<const Trk::PrepRawData*> measurementToPRDs(const Trk::MeasurementBase*);//Might return empty vector. + + //We keep this map around in order to give track associations for + //prds (in particular those whose handles are created after the + //change in visible tracks): + // + //NB (TK): I guess a track association tool could do this too - but + //why add that dependency for something which is dead simple? + std::map< const Trk::PrepRawData*,TracksAndSegments > prdsOnTracksAndSegments; + +}; + +//____________________________________________________________________ +template <class T> +void PRDTrackSegmentHelper::Imp::removeEntryFromVector(std::vector<T*>&v,T*t) +{ + const unsigned n(v.size()); + for (unsigned i(0); i<n;++i) { + if (v[i]==t) { + if (i==n-1) { + v.resize(n-1); + return; + } else { + v[i]=v[n-1]; + v.resize(n-1); + return; + } + } + } +} + +//____________________________________________________________________ +PRDTrackSegmentHelper::PRDTrackSegmentHelper(std::map< const Trk::PrepRawData *, QList<PRDHandleBase *> >* prd2handles, + IVP1System* sys, QObject * parent) + : QObject(parent), VP1HelperClassBase(sys,"PRDTrackSegmentHelper"), m_d(new Imp) +{ + m_d->theclass = this; + m_d->prd2handles = prd2handles; +} + +//____________________________________________________________________ +PRDTrackSegmentHelper::~PRDTrackSegmentHelper() +{ + delete m_d; +} + +//____________________________________________________________________ +void PRDTrackSegmentHelper::visibleTracksChanged(const std::vector< std::pair<const Trk::Track*, const SoMaterial*> >& tracks) +{ + //NB: Code here is very similar to code in visibleSegmentsChanged!! + messageVerbose("visibleTracksChanged start (old ntracks = "+QString::number(m_d->tracks2mat.size()) + +", new ntracks = "+QString::number(tracks.size())+")"); + + if (tracks.empty()) { + //Special case #1 - loop over previous track's, remove their pointers from the relevant prd handles + update their materials. + messageVerbose("special case #1 - new track list is empty"); + std::map< const Trk::Track*, const SoMaterial* >::iterator it, itE = m_d->tracks2mat.end(); + for (it=m_d->tracks2mat.begin();it!=itE;++it) { + m_d->removeTrackFromPRDs(it->first,false);//measurements + m_d->removeTrackFromPRDs(it->first,true);//outliers + } + m_d->tracks2mat.clear(); + messageVerbose("visibleTracksChanged end"); + return; + } + + if (m_d->tracks2mat.empty()) { + //special case #2 - no previous tracks, so just loop over incoming + //tracks, and add their pointers to the relevant prd handles + update their materials. + messageVerbose("special case #2 - old track list is empty"); + std::vector< std::pair<const Trk::Track*, const SoMaterial*> >::const_iterator it(tracks.begin()), itE(tracks.end()); + for (;it!=itE;++it) { + m_d->tracks2mat.insert(*it); + m_d->addTrackToPRDs(it->first, false );//measurements + m_d->addTrackToPRDs(it->first, true );//outliers + } + messageVerbose("visibleTracksChanged end"); + return; + } + + //Normal case - need to remove some trackpointers, add some, and for others possibly just update their materials. + messageVerbose("normal case - neither old, nor new, track lists are empty"); + + //First check if any previously visible tracks simply disappeared. + // --> Create std::set for faster searches. + std::set<const Trk::Track*> newtracksset; + std::vector< std::pair<const Trk::Track*, const SoMaterial*> >::const_iterator it(tracks.begin()), itE(tracks.end()); + for (;it!=itE;++it) + newtracksset.insert(it->first); + std::set<const Trk::Track*>::const_iterator newtrackssetEnd(newtracksset.end()); + + // --> Check old tracks versus this set - remove if no match: + std::map< const Trk::Track*, const SoMaterial* >::iterator it2, it2E = m_d->tracks2mat.end(); + for (it2=m_d->tracks2mat.begin();it2!=it2E;) { + if (newtracksset.find(it2->first)==newtrackssetEnd) { + m_d->removeTrackFromPRDs(it2->first,false);//measurements + m_d->removeTrackFromPRDs(it2->first,true);//outliers + m_d->tracks2mat.erase(it2++);//postfix ++ operator must be used as here (due to the erase call) + } else { + it2++; + } + } + + // Next, check all tracks that are now visible - if not previously + // visible we add their pointers to the relevant handles. If just + // the material changed, we make sure the prd handle updates its + // material. + it2E=m_d->tracks2mat.end(); + for (it=tracks.begin();it!=itE;++it) { + it2 = m_d->tracks2mat.find(it->first); + if (it2==it2E) { + m_d->tracks2mat[it->first] = it->second; + m_d->addTrackToPRDs(it->first, false );//measurements + m_d->addTrackToPRDs(it->first, true );//outliers + } else { + //we need to update the track material - but only if it changed of course. + if (it->second!=it2->second) { + m_d->tracks2mat[it->first] = it->second; + m_d->updateMaterialOfPRDs(it->first, false );//measurements + m_d->updateMaterialOfPRDs(it->first, true );//outliers + } + } + } + messageVerbose("visibleTracksChanged end"); + +} + +//____________________________________________________________________ +void PRDTrackSegmentHelper::visibleSegmentsChanged(const std::vector< std::pair<const Trk::Segment*, const SoMaterial*> >& segments) +{ + //NB: Code here is very similar to code in visibleTracksChanged!! + messageVerbose("visibleSegmentsChanged start (old nsegments = "+QString::number(m_d->segments2mat.size()) + +", new nsegments = "+QString::number(segments.size())+")"); + + if (segments.empty()) { + //Special case #1 - loop over previous segment's, remove their pointers from the relevant prd handles + update their materials. + messageVerbose("special case #1 - new segment list is empty"); + std::map< const Trk::Segment*, const SoMaterial* >::iterator it, itE = m_d->segments2mat.end(); + for (it=m_d->segments2mat.begin();it!=itE;++it) { + m_d->removeSegmentFromPRDs(it->first); + } + m_d->segments2mat.clear(); + messageVerbose("visibleSegmentsChanged end"); + return; + } + + if (m_d->segments2mat.empty()) { + //special case #2 - no previous segments, so just loop over incoming + //segments, and add their pointers to the relevant prd handles + update their materials. + messageVerbose("special case #2 - old segment list is empty"); + std::vector< std::pair<const Trk::Segment*, const SoMaterial*> >::const_iterator it(segments.begin()), itE(segments.end()); + for (;it!=itE;++it) { + m_d->segments2mat.insert(*it); + m_d->addSegmentToPRDs(it->first ); + } + messageVerbose("visibleSegmentsChanged end"); + return; + } + + //Normal case - need to remove some segmentpointers, add some, and for others possibly just update their materials. + messageVerbose("normal case - neither old, nor new, segment lists are empty"); + + //First check if any previously visible segments simply disappeared. + // --> Create std::set for faster searches. + std::set<const Trk::Segment*> newsegmentsset; + std::vector< std::pair<const Trk::Segment*, const SoMaterial*> >::const_iterator it(segments.begin()), itE(segments.end()); + for (;it!=itE;++it) + newsegmentsset.insert(it->first); + std::set<const Trk::Segment*>::const_iterator newsegmentssetEnd(newsegmentsset.end()); + + // --> Check old segments versus this set - remove if no match: + std::map< const Trk::Segment*, const SoMaterial* >::iterator it2, it2E = m_d->segments2mat.end(); + for (it2=m_d->segments2mat.begin();it2!=it2E;) { + if (newsegmentsset.find(it2->first)==newsegmentssetEnd) { + m_d->removeSegmentFromPRDs(it2->first); + m_d->segments2mat.erase(it2++);//postfix ++ operator must be used as here (due to the erase call) + } else { + it2++; + } + } + + // Next, check all segments that are now visible - if not previously + // visible we add their pointers to the relevant handles. If just + // the material changed, we make sure the prd handle updates its + // material. + it2E=m_d->segments2mat.end(); + for (it=segments.begin();it!=itE;++it) { + it2 = m_d->segments2mat.find(it->first); + if (it2==it2E) { + m_d->segments2mat[it->first] = it->second; + m_d->addSegmentToPRDs(it->first); + } else { + //we need to update the segment material - but only if it changed of course. + if (it->second!=it2->second) { + m_d->segments2mat[it->first] = it->second; + m_d->updateMaterialOfPRDs(it->first); + } + } + } + messageVerbose("visibleSegmentsChanged end"); +} + +//____________________________________________________________________ +void PRDTrackSegmentHelper::Imp::addSegmentToPRDs(const Trk::Segment * seg) +{ + // if (verbose()) + // theclass->messageVerbose("addSegmentToPRDs start"); + if (!seg) { + theclass->message("ERROR: Received null segment pointer!"); + return; + } + std::map< const Trk::PrepRawData*,TracksAndSegments >::iterator itInfo; + std::map< const Trk::PrepRawData *, QList<PRDHandleBase *> >::const_iterator itHandle, itHandleEnd(prd2handles->end()); + std::vector<const Trk::MeasurementBase*>::const_iterator + it (seg->containedMeasurements().begin()), itE(seg->containedMeasurements().end()); + const Trk::PrepRawData * prd; + for (;it!=itE;++it) { + std::vector<const Trk::PrepRawData*> prds = Imp::measurementToPRDs(*it); // need to handle compound measurements too. + std::vector<const Trk::PrepRawData*>::const_iterator itPrd = prds.begin(), itEnd=prds.end(); + for (;itPrd!=itEnd;itPrd++){ + prd = *itPrd; + itInfo = prdsOnTracksAndSegments.find(prd); + if (itInfo==prdsOnTracksAndSegments.end()) { + prdsOnTracksAndSegments.insert(std::pair<const Trk::PrepRawData*,TracksAndSegments>(prd, + TracksAndSegments(std::vector<const Trk::Track*>(), + std::vector<const Trk::Track*>(), + std::vector< const Trk::Segment* >(1,seg)))); + + } else { + itInfo->second.segments.push_back(seg); + } + itHandle = prd2handles->find(prd); + if (itHandle!=itHandleEnd) { + QList<PRDHandleBase*> handles = itHandle->second; + foreach (PRDHandleBase*handle,handles) + if (handle->collHandle()->colourBySegments()) + handle->updateMaterial(); + } + + } + } + // theclass->messageVerbose("addSegmentToPRDs end"); +} + +//____________________________________________________________________ +void PRDTrackSegmentHelper::Imp::removeSegmentFromPRDs(const Trk::Segment * seg) +{ + // if (verbose()) + // theclass->messageVerbose("removeSegmentFromPRDs start"); + if (!seg) { + theclass->message("ERROR: Received null segment pointer!"); + return; + } + std::map< const Trk::PrepRawData*,TracksAndSegments >::iterator itInfo; + std::map< const Trk::PrepRawData *, QList<PRDHandleBase *> >::const_iterator itHandle, itHandleEnd(prd2handles->end()); + std::vector<const Trk::MeasurementBase*>::const_iterator + it (seg->containedMeasurements().begin()), itE(seg->containedMeasurements().end()); + const Trk::PrepRawData * prd; + for (;it!=itE;++it) { + std::vector<const Trk::PrepRawData*> prds = Imp::measurementToPRDs(*it); // need to handle compound measurements too. + std::vector<const Trk::PrepRawData*>::const_iterator itPrd = prds.begin(), itEnd=prds.end(); + for (;itPrd!=itEnd;itPrd++){ + prd = *itPrd; + itInfo = prdsOnTracksAndSegments.find(prd); + if (itInfo!=prdsOnTracksAndSegments.end()) { + removeEntryFromVector(itInfo->second.segments,seg); + itHandle = prd2handles->find(prd); + if (itHandle!=itHandleEnd) { + QList<PRDHandleBase*> handles = itHandle->second; + foreach (PRDHandleBase*handle,handles) + if (handle->collHandle()->colourBySegments()) + handle->updateMaterial(); + } + } + } + } + + // if (verbose()) + // theclass->messageVerbose("removeSegmentToPRDs end"); +} + +//____________________________________________________________________ +void PRDTrackSegmentHelper::Imp::updateMaterialOfPRDs(const Trk::Segment * seg) +{ + // if (verbose()) + // theclass->messageVerbose("updateMaterialOfPRDs(segment) start"); + if (!seg) { + theclass->message("ERROR: Received null segment pointer!"); + return; + } + std::map< const Trk::PrepRawData *, QList<PRDHandleBase *> >::const_iterator itHandle, itHandleEnd(prd2handles->end()); + std::vector<const Trk::MeasurementBase*>::const_iterator + it (seg->containedMeasurements().begin()), itE(seg->containedMeasurements().end()); + const Trk::PrepRawData * prd; + for (;it!=itE;++it) { + std::vector<const Trk::PrepRawData*> prds = Imp::measurementToPRDs(*it); // need to handle compound measurements too. + std::vector<const Trk::PrepRawData*>::const_iterator itPrd = prds.begin(), itEnd=prds.end(); + for (;itPrd!=itEnd;itPrd++){ + prd = *itPrd; + itHandle = prd2handles->find(prd); + if (itHandle!=itHandleEnd) { + QList<PRDHandleBase*> handles = itHandle->second; + foreach (PRDHandleBase*handle,handles) + if (handle->collHandle()->colourByTracks()) + handle->updateMaterial(); + } + } + } + + // if (verbose()) + // theclass->messageVerbose("updateMaterialOfPRDs(segment) end"); +} + +//____________________________________________________________________ +void PRDTrackSegmentHelper::Imp::addTrackToPRDs(const Trk::Track * trk, bool outliers ) +{ + // if (verbose()) + // theclass->messageVerbose("addTrackToPRDs start"); + if (!trk) { + theclass->message("ERROR: Received null track pointer!"); + return; + } + std::map< const Trk::PrepRawData*,TracksAndSegments >::iterator itInfo; + std::map< const Trk::PrepRawData *, QList<PRDHandleBase *> >::const_iterator itHandle, itHandleEnd(prd2handles->end()); + DataVector<const Trk::MeasurementBase>::const_iterator + it ( outliers ? trk->outliersOnTrack()->begin() : trk->measurementsOnTrack()->begin() ), + itE( outliers ? trk->outliersOnTrack()->end() : trk->measurementsOnTrack()->end() ); + const Trk::PrepRawData * prd; + for (;it!=itE;++it) { + std::vector<const Trk::PrepRawData*> prds = Imp::measurementToPRDs(*it); // need to handle compound measurements too. + std::vector<const Trk::PrepRawData*>::const_iterator itPrd = prds.begin(), itEnd=prds.end(); + for (;itPrd!=itEnd;itPrd++){ + prd = *itPrd; + if (prd) { + itInfo = prdsOnTracksAndSegments.find(prd); + if (itInfo==prdsOnTracksAndSegments.end()) { + prdsOnTracksAndSegments.insert(std::pair<const Trk::PrepRawData*,TracksAndSegments>(prd, + TracksAndSegments((outliers?std::vector<const Trk::Track*>():std::vector<const Trk::Track*>(1,trk)), + (outliers?std::vector<const Trk::Track*>(1,trk):std::vector<const Trk::Track*>()), + std::vector< const Trk::Segment* >()))); + } else { + if (outliers) + itInfo->second.tracks_outliers.push_back(trk); + else + itInfo->second.tracks.push_back(trk); + } + itHandle = prd2handles->find(prd); + if (itHandle!=itHandleEnd) { + QList<PRDHandleBase*> handles = itHandle->second; + foreach (PRDHandleBase*handle,handles) + if (handle->collHandle()->colourByTracks()) + handle->updateMaterial(); + } + } + } + } + // if (verbose()) + // theclass->messageVerbose("addTrackToPRDs end"); +} + +//____________________________________________________________________ +void PRDTrackSegmentHelper::Imp::removeTrackFromPRDs(const Trk::Track * trk, bool outliers) +{ + // if (verbose()) + // theclass->messageVerbose("removeTrackFromPRDs start"); + if (!trk) { + theclass->message("ERROR: Received null track pointer!"); + return; + } + std::map< const Trk::PrepRawData*,TracksAndSegments >::iterator itInfo; + std::map< const Trk::PrepRawData *, QList<PRDHandleBase *> >::const_iterator itHandle, itHandleEnd(prd2handles->end()); + DataVector<const Trk::MeasurementBase>::const_iterator + it ( outliers ? trk->outliersOnTrack()->begin() : trk->measurementsOnTrack()->begin() ), + itE( outliers ? trk->outliersOnTrack()->end() : trk->measurementsOnTrack()->end() ); + const Trk::PrepRawData * prd; + for (;it!=itE;++it) { + std::vector<const Trk::PrepRawData*> prds = Imp::measurementToPRDs(*it); // need to handle compound measurements too. + std::vector<const Trk::PrepRawData*>::const_iterator itPrd = prds.begin(), itEnd=prds.end(); + for (;itPrd!=itEnd;itPrd++){ + prd = *itPrd; + itInfo = prdsOnTracksAndSegments.find(prd); + if (itInfo!=prdsOnTracksAndSegments.end()) { + removeEntryFromVector((outliers?itInfo->second.tracks_outliers:itInfo->second.tracks),trk); + itHandle = prd2handles->find(prd); + if (itHandle!=itHandleEnd) { + QList<PRDHandleBase*> handles = itHandle->second; + foreach (PRDHandleBase*handle,handles) + if (handle->collHandle()->colourByTracks()) + handle->updateMaterial(); + } + } + } + } + + // if (verbose()) + // theclass->messageVerbose("removeTrackToPRDs end"); +} + +//____________________________________________________________________ +void PRDTrackSegmentHelper::Imp::updateMaterialOfPRDs(const Trk::Track * trk, bool outliers ) +{ + // if (verbose()) + // theclass->messageVerbose("updateMaterialOfPRDs(track) start"); + if (!trk) { + theclass->message("ERROR: Received null track pointer!"); + return; + } + std::map< const Trk::PrepRawData *, QList<PRDHandleBase *> >::const_iterator itHandle, itHandleEnd(prd2handles->end()); + DataVector<const Trk::MeasurementBase>::const_iterator + it ( outliers ? trk->outliersOnTrack()->begin() : trk->measurementsOnTrack()->begin() ), + itE( outliers ? trk->outliersOnTrack()->end() : trk->measurementsOnTrack()->end() ); + const Trk::PrepRawData * prd; + for (;it!=itE;++it) { + std::vector<const Trk::PrepRawData*> prds = Imp::measurementToPRDs(*it); // need to handle compound measurements too. + std::vector<const Trk::PrepRawData*>::const_iterator itPrd = prds.begin(), itEnd=prds.end(); + for (;itPrd!=itEnd;itPrd++){ + prd = *itPrd; + itHandle = prd2handles->find(prd); + if (itHandle!=itHandleEnd) { + QList<PRDHandleBase*> handles = itHandle->second; + foreach (PRDHandleBase*handle,handles) + if (handle->collHandle()->colourByTracks()) + handle->updateMaterial(); + } + } + } + + // if (verbose()) + // theclass->messageVerbose("updateMaterialOfPRDs(track) end"); +} + +//____________________________________________________________________ +const PRDTrackSegmentHelper::TracksAndSegments * PRDTrackSegmentHelper::tracksAndSegments(const Trk::PrepRawData* prd) +{ + std::map< const Trk::PrepRawData*,TracksAndSegments >::iterator itInfo = m_d->prdsOnTracksAndSegments.find(prd); + return itInfo == m_d->prdsOnTracksAndSegments.end() ? 0 : &(itInfo->second); +} + + +//____________________________________________________________________ +inline std::vector<const Trk::PrepRawData *> PRDTrackSegmentHelper::Imp::measurementToPRDs(const Trk::MeasurementBase* measbase) +{ + std::vector<const Trk::PrepRawData *>prds; + const Trk::RIO_OnTrack * rio = dynamic_cast<const Trk::RIO_OnTrack *>(measbase); + if (rio) prds.push_back( rio->prepRawData() ); + const Trk::CompetingRIOsOnTrack * crot = dynamic_cast<const Trk::CompetingRIOsOnTrack *>(measbase); + if (crot) { + + // for (unsigned int i=0; i< crot->numberOfContainedROTs (); ++i) prds.push_back( crot->rioOnTrack(i) ? crot->rioOnTrack(i)->prepRawData() : 0 ); + for (unsigned int i=0; i< crot->numberOfContainedROTs (); ++i) { + if (crot->rioOnTrack(i).identify().getString() != "") { // FIXME: search for a better way to see if the rioOnTrack is present + prds.push_back(crot->rioOnTrack(i).prepRawData()); + } + else { + prds.push_back(0); + } + } + } + return prds; +} + +//____________________________________________________________________ +inline PRDTrackSegmentHelper::TracksAndSegments::TracksAndSegments(const std::vector<const Trk::Track*>& t, + const std::vector<const Trk::Track*>& to, + const std::vector< const Trk::Segment* >& s ) + : tracks(t), tracks_outliers(to), segments(s) +{ +} + +//____________________________________________________________________ +SoMaterial * PRDTrackSegmentHelper::trackMaterial(const Trk::Track* t) const +{ + std::map< const Trk::Track*, const SoMaterial* >::const_iterator it = m_d->tracks2mat.find(t); + return it == m_d->tracks2mat.end() ? 0 : const_cast<SoMaterial *>(it->second);//fixme; const_cast is temporary hack. Remove const from materials! +} + +//____________________________________________________________________ +SoMaterial * PRDTrackSegmentHelper::segmentMaterial(const Trk::Segment* s) const +{ + std::map< const Trk::Segment*, const SoMaterial* >::const_iterator it = m_d->segments2mat.find(s); + return it == m_d->segments2mat.end() ? 0 : const_cast<SoMaterial *>(it->second);//fixme; const_cast is temporary hack. Remove const from materials! +} diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/VP1PrepRawDataSystem.cxx b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/VP1PrepRawDataSystem.cxx new file mode 100644 index 0000000000000000000000000000000000000000..8aaa32ec8be75b88a88de538c4a011516c29e6b5 --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/VP1PrepRawDataSystem.cxx @@ -0,0 +1,523 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +//Fixme: cleanup includes. +#include "VTI12Utils/VP1JobConfigInfo.h" +#include "VTI12Utils/VP1DetInfo.h" +#include "VTI12PRDSystems/VP1PrepRawDataSystem.h" +#include "VTI12PRDSystems/PRDSystemController.h" +#include "VTI12PRDSystems/PRDSysCommonData.h" +#include "VTI12PRDSystems/PRDHandleBase.h" +#include "VTI12PRDSystems/PRDTrackSegmentHelper.h" +#include "VTI12PRDSystems/PRDCollHandle_SCT.h" +#include "VTI12PRDSystems/PRDCollHandle_SpacePoints.h" + +#include "VP1Base/VP1Serialise.h" +#include "VP1Base/VP1Deserialise.h" +#include "VP1Base/VP1CollectionWidget.h" +#include "VP1Base/SoCooperativeSelection.h" +#include "VP1Base/VP1QtInventorUtils.h" +#include "VP1Base/VP1CameraHelper.h" + +#include <QBuffer> +#include <QByteArray> + +#include <Inventor/nodes/SoSeparator.h> +#include <Inventor/nodes/SoComplexity.h> +#include <Inventor/nodes/SoTransform.h> +#include <Inventor/nodes/SoMaterial.h> +#include <Inventor/nodes/SoDrawStyle.h> +#include <Inventor/nodes/SoSwitch.h> +#include <Inventor/nodes/SoLineSet.h> +#include <Inventor/nodes/SoPickStyle.h> +#include <Inventor/nodes/SoVertexProperty.h> +#include <Inventor/SoPath.h> + +#include <map> + +//Fixme: Update visuals if any detail level changes! + +//____________________________________________________________________ +class VP1PrepRawDataSystem::Imp { +public: + VP1PrepRawDataSystem * theclass = nullptr; + PRDSysCommonData * common = nullptr; + PRDSystemController * controller = nullptr; + SoCooperativeSelection * selNode_click = nullptr; + SoCooperativeSelection * selNode_highlight = nullptr; + +// InDetProjFlags::InDetProjPartsFlags idprojflags_sct; + + SoSeparator * multisel_sep = nullptr; + void clearMultiSelLine() { + while (multisel_sep&&multisel_sep->getNumChildren()>2) + multisel_sep->removeChild(2); + } + + QList<PRDHandleBase*> currentlySelectedHandles; + QList<const Trk::PrepRawData*> lastEmittedPRDList; + void selectionChanged() { + currentlySelectedHandles.removeAll(0);//just to be sure + clearMultiSelLine(); + + //Proper highlighting: + if (selNode_highlight) { + selNode_highlight->deselectAll(); + foreach(PRDHandleBase*handle,currentlySelectedHandles) { + // theclass->messageDebug("Highlighting handle..."); + SoSeparator* target = handle->collHandle()->simpleDetailLevel() ? handle->sepSimple() : handle->sepDetailed(); + SoPath * path = new SoPath(selNode_highlight); + path->ref(); + // theclass->messageDebug("Attempting to highlight sep="+str(target)); + if (!VP1QtInventorUtils::changePathTail(path,selNode_highlight,target)) { + theclass->message("ERROR: Failed to relocate picked node."); + path->unref(); + continue; + } + selNode_highlight->select(path); + path->unref(); + } + selNode_highlight->touch(); + if (multisel_sep&¤tlySelectedHandles.count()>1&&controller->showSelectionLine()) { + SoLineSet * line = new SoLineSet; + SoVertexProperty * vertices = new SoVertexProperty; + line->vertexProperty = vertices; + line->numVertices.set1Value(0,currentlySelectedHandles.count()); + int i(0); + foreach(PRDHandleBase*handle,currentlySelectedHandles) { + Amg::Vector3D pos(handle->center()); + vertices->vertex.set1Value(i++,pos.x(),pos.y(),pos.z()); + } + multisel_sep->addChild(line); + //Fixme: make this unpickable!! + + } + } + + //emit signal if appropriate: + QList<const Trk::PrepRawData*> currentPRDs; + for(int i = 0; i < currentlySelectedHandles.count(); ++i) { + PRDHandleBase*handle = currentlySelectedHandles.at(i); + const Trk::PrepRawData* prd1 = handle->getPRD(); + const Trk::PrepRawData* prd2 = handle->getSecondPRD(); + if (prd1&¤tPRDs.contains(prd1)) prd1 = 0; + if (prd2&¤tPRDs.contains(prd2)) prd2 = 0; + if (!prd2) { + if (!prd1) + continue; + currentPRDs << prd1; + } else { + //both prd1 and prd2 are non-zero and not in the list + //already. Which should be first? We order them by distance to + //the preceding or following prd. + + Amg::Vector3D p1(handle->positionPRD()); + Amg::Vector3D p2(handle->positionSecondPRD()); + + if (i>0) { + Amg::Vector3D prevpos = currentlySelectedHandles.at(i-1)->center(); + if ((p1-prevpos).mag2()>(p2-prevpos).mag2()) { + //prd2 before prd1 + currentPRDs << prd2; + currentPRDs << prd1; + } else { + //prd1 before prd2 + currentPRDs << prd1; + currentPRDs << prd2; + } + } else { + if (i+1<currentlySelectedHandles.count()) { + Amg::Vector3D nextpos = currentlySelectedHandles.at(i+1)->center(); + if ((p1-nextpos).mag2()>(p2-nextpos).mag2()) { + //prd1 before prd2 + currentPRDs << prd1; + currentPRDs << prd2; + } else { + //prd2 before prd1 + currentPRDs << prd2; + currentPRDs << prd1; + } + } else { + //Only this one. Just add them: + currentPRDs << prd1; + currentPRDs << prd2; + } + } + } + } + if (currentPRDs!=lastEmittedPRDList) { + lastEmittedPRDList = currentPRDs; + theclass->messageVerbose("Emitting list of "+str(lastEmittedPRDList.count())+" selected PRDs"); + emit theclass->selectedPRDsChanged(lastEmittedPRDList); + } + } + + template <class T> + QList<PRDCollHandleBase*> createSpecificCollections() { + QList<PRDCollHandleBase*> l; + foreach (QString name, T::availableCollections(theclass)) { + T * col = new T(common,name); + col->init(); + l << col; + } + return l; + } + QList<PRDCollHandleBase*> createCollections() { + QList<PRDCollHandleBase*> l; + l << createSpecificCollections<PRDCollHandle_SCT>(); + l << createSpecificCollections<PRDCollHandle_SpacePoints>(); + return l; + } + + void ensureInitCommonData() { + if (!common) { + theclass->ensureBuildController(); + common = new PRDSysCommonData(theclass,controller); + } + } +}; + +//_____________________________________________________________________________________ +VP1PrepRawDataSystem::VP1PrepRawDataSystem() +: IVP13DSystemSimple("Hits", + "System showing tracking hits (PRD's)", + "Edward.Moyse@cern.ch, Thomas.Kittelmann@cern.ch"), m_d(new Imp) +{ + m_d->theclass = this; + m_d->common = 0; + m_d->controller = 0; +// m_d->idprojflags_sct = InDetProjFlags::NoProjections; + m_d->selNode_click = 0; + m_d->selNode_highlight = 0; + m_d->multisel_sep = 0; + +} + +//_____________________________________________________________________________________ +VP1PrepRawDataSystem::~VP1PrepRawDataSystem() +{ + delete m_d; +} + +//_____________________________________________________________________________________ +void VP1PrepRawDataSystem::systemcreate(StoreGateSvc* /*detstore*/) +{ + messageVerbose("systemcreate"); + m_d->ensureInitCommonData(); +} + +//_____________________________________________________________________________________ +void VP1PrepRawDataSystem::systemuncreate() +{ + if (m_d->multisel_sep) { + m_d->multisel_sep->unref(); + m_d->multisel_sep=0; + } + + delete m_d->common; m_d->common = 0; + m_d->controller = 0; +} + +//_____________________________________________________________________________________ +void VP1PrepRawDataSystem::systemerase() +{ + messageVerbose("systemerase"); + + deselectAll(); + + m_d->common->controller()->collWidget()->clear(); + + m_d->common->clearEventData(); + + if (m_d->selNode_click) { + unregisterSelectionNode(m_d->selNode_click); + unregisterSelectionNode(m_d->selNode_highlight); + m_d->selNode_click->unref(); + m_d->selNode_click=0; + m_d->selNode_highlight->unref(); + m_d->selNode_highlight=0; + } + + m_d->clearMultiSelLine(); + +} + +//_____________________________________________________________________________________ +void VP1PrepRawDataSystem::buildPermanentSceneGraph(StoreGateSvc* /*detstore*/, SoSeparator * /*root*/) +{ + messageVerbose("buildPermanentSceneGraph (does not do anything)"); +} + +//_____________________________________________________________________________________ +void VP1PrepRawDataSystem::buildEventSceneGraph(StoreGateSvc*, SoSeparator *root) +{ + messageVerbose("buildEventSceneGraph"); + + // set complexity to a lower value, so that e.g. the straws are manageable + SoComplexity * complexity = new SoComplexity; + complexity->value.setValue(0.3f);//Fixme: Hardcoded here and elsewhere + root->addChild(complexity); + + // //Point sizes and line widths: + // root->addChild(m_d->controller->prdDrawStyle()); + + //Create collection list based on contents of event store, inform + //about projections, populate gui and apply states: + QList<PRDCollHandleBase*> cols = m_d->createCollections(); + + //Inform about appropriate projects: + foreach (PRDCollHandleBase* col,cols) { + + connect(col,SIGNAL(detailLevelChanged()),this,SLOT(updateSelectionVisualsAndPossiblyEmitPRDList())); + + } + + m_d->controller->collWidget()->setCollections(cols); + + + //Add collections to event scenegraph: + m_d->selNode_click = new SoCooperativeSelection; + m_d->selNode_click->ref(); + m_d->selNode_highlight = new SoCooperativeSelection; + m_d->selNode_highlight->ref(); + m_d->selNode_click->activePolicy = SoCooperativeSelection::ACTIVE; + m_d->selNode_highlight->activePolicy = SoCooperativeSelection::INERT; + m_d->selNode_click->policy = SoCooperativeSelection::SINGLE; + m_d->selNode_highlight->policy = SoCooperativeSelection::SINGLE; + + foreach (VP1StdCollection* col,m_d->controller->collWidget()->collections<VP1StdCollection>()) + m_d->selNode_click->addChild(col->collSwitch()); + m_d->selNode_highlight->addChild(m_d->selNode_click); + root->addChild(m_d->selNode_highlight); + + registerSelectionNode(m_d->selNode_click); + registerSelectionNode(m_d->selNode_highlight); + + if (!m_d->multisel_sep) { + m_d->multisel_sep = new SoSeparator; + m_d->multisel_sep->ref(); + SoPickStyle * ps = new SoPickStyle; + ps->style= SoPickStyle::UNPICKABLE; + m_d->multisel_sep->addChild(ps); + m_d->multisel_sep->addChild(m_d->controller->getMultiSelectionLineMaterial()); + } + root->addChild(m_d->multisel_sep); + + + messageVerbose("buildEventSceneGraph done"); + +} + + +//_____________________________________________________________________________________ +void VP1PrepRawDataSystem::deselectAll(SoCooperativeSelection* exception_sel) +{ + if (exception_sel) + message("WARNING: The PRD system always deselects all registered nodes/"); + IVP13DSystemSimple::deselectAll(0); + m_d->currentlySelectedHandles.clear(); + m_d->selectionChanged(); +} + +//_____________________________________________________________________________________ +void VP1PrepRawDataSystem::selectionVisualsChanged() +{ + m_d->selectionChanged(); +} + +//_____________________________________________________________________________________ +void VP1PrepRawDataSystem::clearSelection() +{ + messageVerbose("clearSelection"); + deselectAll(); +} + +//_____________________________________________________________________________________ +void VP1PrepRawDataSystem::selectionModeChanged() +{ + messageVerbose("selectionModeChanged"); + deselectAll(); +} + +//_____________________________________________________________________________________ +void VP1PrepRawDataSystem::updateSelectionVisualsAndPossiblyEmitPRDList() +{ + messageVerbose("updateSelectionVisualsAndPossiblyEmitPRDList"); + m_d->selectionChanged(); +} + +//_____________________________________________________________________________________ +void VP1PrepRawDataSystem::userPickedNode(SoNode*, SoPath *) +{ + messageVerbose("userPickedNode"); +} + +//_____________________________________________________________________________________ +void VP1PrepRawDataSystem::userSelectedSingleNode(SoCooperativeSelection* sel, SoNode*, SoPath*pickedPath) +{ + if (m_d->selNode_highlight==sel) + return; + messageVerbose("userSelectedSingleNode"); + PRDHandleBase * handle = m_d->common->pickedPathToHandle(pickedPath);//This also pops the path, so that all shape nodes + //making up the whole shape will be highlighted + sel->deselectAll(); + + if (!handle) { + deselectAll(); + message("Error: Could not identify picked node"); + return; + } + + if (!m_d->controller->selectionModeMultiple()) { + if (m_d->currentlySelectedHandles.count()==1&&*(m_d->currentlySelectedHandles.begin())==handle) + return; + m_d->currentlySelectedHandles.clear(); + m_d->currentlySelectedHandles<<handle; + if (m_d->controller->zoomOnClick()) { + std::set<SoCamera*> cameras(getCameraList()); + std::set<SoCamera*>::iterator it,itE = cameras.end(); + for (it=cameras.begin();it!=itE;++it) + VP1CameraHelper::animatedZoomToPath(*it,handle->collHandle()->collSep(),pickedPath,2.0,1.0); + } + if (m_d->controller->printInfoOnClick()) { + foreach (QString line, handle->clicked()) + message(line); + } + } else { + if (m_d->currentlySelectedHandles.contains(handle)) { + m_d->currentlySelectedHandles.removeAll(handle); + } else { + m_d->currentlySelectedHandles << handle; + } + } + + m_d->selectionChanged(); + +} + +//_____________________________________________________________________________________ +void VP1PrepRawDataSystem::userDeselectedSingleNode(SoCooperativeSelection* sel, SoNode*, SoPath*) +{ + if (m_d->selNode_highlight==sel) + return; + // messageVerbose("userDeselectedSingleNode"); +} + +//_____________________________________________________________________________________ +void VP1PrepRawDataSystem::userChangedSelection(SoCooperativeSelection*sel , QSet<SoNode*>, QSet<SoPath*>) +{ + if (m_d->selNode_highlight==sel) + return; + messageVerbose("userChangedSelection"); +} + +//_____________________________________________________________________________________ +void VP1PrepRawDataSystem::userClickedOnBgd() +{ + messageVerbose("userClickedOnBgd"); + if (!m_d->controller->selectionModeMultiple()) { + m_d->currentlySelectedHandles.clear(); + m_d->selectionChanged(); + } +} + + +//_____________________________________________________________________________________ +QWidget * VP1PrepRawDataSystem::buildController() +{ + messageVerbose("buildController"); + m_d->controller = new PRDSystemController(this); + +// messageVerbose("Passing ID projection settings on to collWidget"); + + connect(m_d->controller,SIGNAL(selectionModeMultipleChanged(bool)),this,SLOT(selectionModeChanged())); + connect(m_d->controller,SIGNAL(showSelectionLineChanged(bool)),this,SLOT(selectionVisualsChanged())); + connect(m_d->controller,SIGNAL(clearSelection()),this,SLOT(clearSelection())); + +// connect(m_d->controller,SIGNAL(inDetPartsUsingProjectionsChanged(InDetProjFlags::DetTypeFlags)), +// this,SLOT(emitUsedIDProjectionsChanged(InDetProjFlags::DetTypeFlags))); +// InDetProjFlags::DetTypeFlags f = m_d->controller->inDetPartsUsingProjections(); +// if ( f != InDetProjFlags::NoDet) +// emitUsedIDProjectionsChanged(f);//Fixme: Check that this is actually sufficiently late for the guideline sys!!! + + return m_d->controller; +} + +//_____________________________________________________________________________________ +QByteArray VP1PrepRawDataSystem::saveState() { + + VP1Serialise serialise(0/*version*/,this); + serialise.save(IVP13DSystemSimple::saveState()); + + ensureBuildController(); + + serialise.save(m_d->controller->saveSettings()); + serialise.save(m_d->controller->collWidget()); + + serialise.disableUnsavedChecks();//We do the testing in the controller + return serialise.result(); +} + +//_____________________________________________________________________________________ +void VP1PrepRawDataSystem::restoreFromState(QByteArray ba) { + //Version & base state: + VP1Deserialise state(ba,this); + if (state.version()!=0) { + message("Warning: State data in .vp1 file is in wrong format - ignoring!"); + return; + } + ensureBuildController(); + + IVP13DSystemSimple::restoreFromState(state.restoreByteArray()); + + m_d->controller->restoreSettings(state.restoreByteArray()); + state.restore(m_d->controller->collWidget());//We do the testing in the controller + + state.disableUnrestoredChecks();//We do the testing in the controller +} + +//_____________________________________________________________________________________ +void VP1PrepRawDataSystem::visibleTracksChanged(const std::vector< std::pair<const Trk::Track*, const SoMaterial*> >& tracks) +{ + m_d->ensureInitCommonData(); + if (!m_d->common) + return;//for signals received after uncreate + m_d->common->trackAndSegmentHelper()->visibleTracksChanged(tracks); + selectionVisualsChanged(); +} + +//_____________________________________________________________________________________ +void VP1PrepRawDataSystem::visibleSegmentsChanged(const std::vector< std::pair<const Trk::Segment*, const SoMaterial*> >& segments) +{ + m_d->ensureInitCommonData(); + if (!m_d->common) + return;//for signals received after uncreate + m_d->common->trackAndSegmentHelper()->visibleSegmentsChanged(segments); + selectionVisualsChanged(); +} + +// //_____________________________________________________________________________________ +// void VP1PrepRawDataSystem::emitUsedIDProjectionsChanged(InDetProjFlags::DetTypeFlags f) +// { +// messageVerbose("emits usedIDProjectionsChanged"); +// emit usedIDProjectionsChanged(f); +// } + +// //_____________________________________________________________________________________ +// void VP1PrepRawDataSystem::setApplicableIDProjections( InDetProjFlags::InDetProjPartsFlags sct) +// { +// messageVerbose("Signal received in setApplicableProjections (from " +// +QString(sender()?sender()->objectName():"NULL sender")+")"); +// if (m_d->idprojflags_sct==sct) { +// return; +// } + +// m_d->idprojflags_sct = sct; + +// if (!m_d->controller) +// return;//applied upon creation of collections instead + +// //NB: Add for pixel/sct as well once supported! + +// } diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/prd_settings_cuts_form.ui b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/prd_settings_cuts_form.ui new file mode 100644 index 0000000000000000000000000000000000000000..e7ae1dbecd13c7219377e730d4e2a8fe28cb92f3 --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/prd_settings_cuts_form.ui @@ -0,0 +1,229 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>PRDSysSettingsCutsForm</class> + <widget class="QWidget" name="PRDSysSettingsCutsForm"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>528</width> + <height>536</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="0" column="0"> + <widget class="QGroupBox" name="groupBox_2"> + <property name="title"> + <string>Direction</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <item> + <widget class="VP1EtaPhiCutWidget" name="etaPhiCutWidget" native="true"/> + </item> + </layout> + </widget> + </item> + <item row="1" column="0"> + <widget class="QGroupBox" name="groupBox_cuts_idgeneral"> + <property name="title"> + <string>Tracker General</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <item> + <layout class="QGridLayout" name="_3"> + <property name="horizontalSpacing"> + <number>6</number> + </property> + <property name="verticalSpacing"> + <number>0</number> + </property> + <item row="0" column="0" colspan="2"> + <widget class="QLabel" name="label_9"> + <property name="text"> + <string>Show data from stations:</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QCheckBox" name="checkBox_cut_tracker_interface"> + <property name="text"> + <string>Interface (Station 0)</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QCheckBox" name="checkBox_cut_tracker_upstream"> + <property name="text"> + <string>Upstream (Station 1)</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QCheckBox" name="checkBox_cut_tracker_central"> + <property name="text"> + <string>Central (Station 2)</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QCheckBox" name="checkBox_cut_tracker_downstream"> + <property name="text"> + <string>Downstream (Station 3)</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>1</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + <item row="2" column="0"> + <widget class="QGroupBox" name="groupBox_cuts_sct"> + <property name="title"> + <string>SCT</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QCheckBox" name="checkBox_cut_sct_excludeisolatedclusters"> + <property name="toolTip"> + <string><html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Require the neighbouring wafer to have at least one cluster.</p></body></html></string> + </property> + <property name="text"> + <string>Exclude isolated SCT clusters</string> + </property> + <property name="checked"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="3" column="0" colspan="2"> + <widget class="QGroupBox" name="groupBox_cuts_tracksegmentassociation"> + <property name="title"> + <string>Track/Segment association cuts</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_5"> + <item> + <layout class="QVBoxLayout" name="_9"> + <property name="spacing"> + <number>0</number> + </property> + <item> + <widget class="QCheckBox" name="checkBox_cuts_ts_exclude_hits_on_track"> + <property name="text"> + <string>Exclude hits on tracks</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_cuts_ts_exclude_hits_not_on_track"> + <property name="text"> + <string>Exclude hits not on tracks</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_cuts_ts_exclude_hits_on_segments"> + <property name="text"> + <string>Exclude hits on segments</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_cuts_ts_exclude_not_on_segments"> + <property name="text"> + <string>Exclude hits not on segments</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>1</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + <item row="4" column="0" colspan="2"> + <layout class="QHBoxLayout" name="horizontalLayout_6"> + <property name="spacing"> + <number>0</number> + </property> + <item> + <spacer> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="pushButton_close"> + <property name="text"> + <string>&Close</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>VP1EtaPhiCutWidget</class> + <extends>QWidget</extends> + <header>VP1Base/VP1EtaPhiCutWidget.h</header> + <container>1</container> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/prd_settings_display_form.ui b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/prd_settings_display_form.ui new file mode 100644 index 0000000000000000000000000000000000000000..da8809026fdd23debd96ddb4884db5ea5b208954 --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/prd_settings_display_form.ui @@ -0,0 +1,244 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>PRDSysSettingsDisplayForm</class> + <widget class="QWidget" name="PRDSysSettingsDisplayForm"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>470</width> + <height>437</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QGridLayout" name="gridLayout_3"> + <item row="4" column="0" colspan="2"> + <layout class="QHBoxLayout"> + <property name="spacing"> + <number>0</number> + </property> + <item> + <spacer> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="pushButton_close"> + <property name="text"> + <string>&Close</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="0" column="1" rowspan="4"> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <item> + <widget class="QGroupBox" name="groupBox_2"> + <property name="title"> + <string>Draw style - SCT</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="VP1DrawOptionsWidget" name="widget_drawOptions_PixelSCT" native="true"/> + </item> + </layout> + </widget> + </item> + </layout> + </item> + <item row="1" column="0"> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>Association Colouring</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Colour by:</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_colourByTrack"> + <property name="toolTip"> + <string>If selected, PrepRawData which are assigned to a track will take the colour of that track.</string> + </property> + <property name="text"> + <string>Tracks</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_colourBySegment"> + <property name="toolTip"> + <string>If selected, PrepRawData which are assigned to a segment will take the colour of that segment.</string> + </property> + <property name="text"> + <string>Segments</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="3" column="0"> + <widget class="QGroupBox" name="groupBox_highlights"> + <property name="title"> + <string>Highlights</string> + </property> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="4" column="0" colspan="2"> + <layout class="QHBoxLayout" name="_5"> + <property name="spacing"> + <number>0</number> + </property> + </layout> + </item> + <item row="0" column="0"> + <layout class="QHBoxLayout" name="_7"> + <item> + <widget class="QLabel" name="label_highlights_material"> + <property name="text"> + <string>Colour:</string> + </property> + </widget> + </item> + <item> + <widget class="VP1MaterialButton" name="materialbutton_highlights_material"> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> + </item> + <item row="0" column="1"> + <layout class="QHBoxLayout" name="_8"> + <property name="spacing"> + <number>5</number> + </property> + <item> + <widget class="QLabel" name="label_highlights_intensity"> + <property name="text"> + <string>Intensity:</string> + </property> + </widget> + </item> + <item> + <widget class="QSlider" name="horizontalSlider_highlights_intensity"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimum"> + <number>1</number> + </property> + <property name="maximum"> + <number>6</number> + </property> + <property name="pageStep"> + <number>1</number> + </property> + <property name="value"> + <number>3</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="tickPosition"> + <enum>QSlider::TicksBelow</enum> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="0" colspan="2"> + <widget class="QCheckBox" name="checkBox_highlight_trackoutliers"> + <property name="text"> + <string>Track Outliers</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="2" column="0"> + <widget class="QGroupBox" name="groupBox_5"> + <property name="title"> + <string>Details</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Draw</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_drawErrors"> + <property name="toolTip"> + <string>If selected, PrepRawData which are assigned to a track will take the colour of that track.</string> + </property> + <property name="text"> + <string>Errors</string> + </property> + <property name="checked"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_drawRDOs"> + <property name="toolTip"> + <string>If selected, PrepRawData which are assigned to a track will take the colour of that track.</string> + </property> + <property name="text"> + <string>RDOs</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>VP1MaterialButton</class> + <extends>QPushButton</extends> + <header>VP1Base/VP1MaterialButton.h</header> + </customwidget> + <customwidget> + <class>VP1DrawOptionsWidget</class> + <extends>QWidget</extends> + <header>VP1Base/VP1DrawOptionsWidget.h</header> + <container>1</container> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/prd_settings_interactions_form.ui b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/prd_settings_interactions_form.ui new file mode 100644 index 0000000000000000000000000000000000000000..81889b9b33c19ebef0f18567cfa6b475d684bf77 --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/prd_settings_interactions_form.ui @@ -0,0 +1,178 @@ +<ui version="4.0" > + <class>PRDSysSettingsInteractionsForm</class> + <widget class="QWidget" name="PRDSysSettingsInteractionsForm" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>256</width> + <height>260</height> + </rect> + </property> + <property name="windowTitle" > + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_4" > + <item> + <widget class="QGroupBox" name="groupBox" > + <property name="title" > + <string>Action on PRD selection</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2" > + <item> + <layout class="QVBoxLayout" > + <property name="spacing" > + <number>-1</number> + </property> + <item> + <widget class="QCheckBox" name="checkBox_printinfo" > + <property name="text" > + <string>Print information (a dump)</string> + </property> + <property name="checked" > + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout" > + <item> + <widget class="QCheckBox" name="checkBox_zoom" > + <property name="text" > + <string>Zoom</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="_2" > + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType" > + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0" > + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_selectionMode" > + <property name="title" > + <string>Selection mode</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_3" > + <property name="margin" > + <number>4</number> + </property> + <item> + <widget class="QCheckBox" name="checkBox_selModeMultiple" > + <property name="text" > + <string>Select multiple (for interactive track fits)</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2" > + <item> + <spacer name="horizontalSpacer" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType" > + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0" > + <size> + <width>20</width> + <height>10</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="pushButton_clearSelection" > + <property name="text" > + <string>Clear</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout" > + <item> + <widget class="QCheckBox" name="checkBox_showSelectionLine" > + <property name="text" > + <string>Line</string> + </property> + <property name="checked" > + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="VP1MaterialButton" name="matButton_multiselline" > + <property name="text" > + <string/> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </widget> + </item> + <item> + <layout class="QHBoxLayout" > + <property name="spacing" > + <number>0</number> + </property> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0" > + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="pushButton_close" > + <property name="text" > + <string>&Close</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>VP1MaterialButton</class> + <extends>QPushButton</extends> + <header>VP1Base/VP1MaterialButton.h</header> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> diff --git a/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/vp1prdcontrollerform.ui b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/vp1prdcontrollerform.ui new file mode 100644 index 0000000000000000000000000000000000000000..a380fad4163f26b55837e480bdab137209d98ca4 --- /dev/null +++ b/graphics/VTI12/VTI12Systems/VTI12PRDSystems/src/vp1prdcontrollerform.ui @@ -0,0 +1,102 @@ +<ui version="4.0" > + <class>VP1PrdControllerForm</class> + <widget class="QWidget" name="VP1PrdControllerForm" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>234</width> + <height>135</height> + </rect> + </property> + <property name="windowTitle" > + <string>Form</string> + </property> + <layout class="QGridLayout" > + <property name="leftMargin" > + <number>6</number> + </property> + <property name="topMargin" > + <number>6</number> + </property> + <property name="rightMargin" > + <number>0</number> + </property> + <property name="bottomMargin" > + <number>4</number> + </property> + <property name="horizontalSpacing" > + <number>0</number> + </property> + <item row="0" column="0" > + <widget class="QWidget" native="1" name="widget_settingsButtonsPlaceholder" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <layout class="QGridLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>0</number> + </property> + <item row="0" column="0" > + <widget class="QPushButton" name="pushButton_settings_cuts" > + <property name="toolTip" > + <string>Configure track cuts on quantities such as eta, phi and momentum</string> + </property> + <property name="text" > + <string>Cuts</string> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QPushButton" name="pushButton_settings_display" > + <property name="toolTip" > + <string>Configure track colours</string> + </property> + <property name="text" > + <string>Display</string> + </property> + </widget> + </item> + <item row="0" column="2" > + <widget class="QPushButton" name="pushButton_settings_interactions" > + <property name="toolTip" > + <string>Settings for what happens in response to selections (printout, zooms, ...)</string> + </property> + <property name="text" > + <string>Interactions</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="0" column="1" > + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType" > + <enum>QSizePolicy::Preferred</enum> + </property> + <property name="sizeHint" stdset="0" > + <size> + <width>1</width> + <height>3</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="0" colspan="2" > + <widget class="QScrollArea" name="collWidgetScrollArea" /> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/graphics/VTI12/VTI12Systems/VTI12RawDataSystems/VTI12RawDataSystems/VP1RawDataColl_SCT_RDO.h b/graphics/VTI12/VTI12Systems/VTI12RawDataSystems/VTI12RawDataSystems/VP1RawDataColl_SCT_RDO.h index 78870c26b9c2dedbbb75c4b3434511c8c2bc253e..3c2eb6a6aae29cc407f019c41db8094e1ccb9c2a 100644 --- a/graphics/VTI12/VTI12Systems/VTI12RawDataSystems/VTI12RawDataSystems/VP1RawDataColl_SCT_RDO.h +++ b/graphics/VTI12/VTI12Systems/VTI12RawDataSystems/VTI12RawDataSystems/VP1RawDataColl_SCT_RDO.h @@ -30,8 +30,6 @@ public: bool cut(VP1RawDataHandleBase*); - bool usesInDetPartsCuts() { return true; }//To get InDet parts cuts - protected: void assignDefaultMaterial(SoMaterial*) const; bool load(); diff --git a/graphics/VTI12/VTI12Systems/VTI12TrackSystems/CMakeLists.txt b/graphics/VTI12/VTI12Systems/VTI12TrackSystems/CMakeLists.txt index f8dfd19e8d3c13e9df693506262f6963d17f4e23..6f1fb47a2f414fc7dcd5316a89da7421eed8b59a 100644 --- a/graphics/VTI12/VTI12Systems/VTI12TrackSystems/CMakeLists.txt +++ b/graphics/VTI12/VTI12Systems/VTI12TrackSystems/CMakeLists.txt @@ -40,5 +40,4 @@ atlas_add_library( VTI12TrackSystems VTI12TrackSystems/*.h src/*.cxx TrkMaterialOnTrack TrkMeasurementBase TrkPrepRawData TrkPseudoMeasurementOnTrack TrkRIO_OnTrack TrkSegment TrkTrack TrkTrackSummary TrkExInterfaces TrkFitterInterfaces VP1HEPVis - #VP1PRDSystems ) diff --git a/graphics/VTI12/VTI12Systems/VTI12TrackSystems/VTI12TrackSystems/TrackHandleBase.h b/graphics/VTI12/VTI12Systems/VTI12TrackSystems/VTI12TrackSystems/TrackHandleBase.h index af1985583ddd4ead227901aca0586270e8b20c83..0dcde264b470b19dc82f306d4eacb3b5542f98af 100644 --- a/graphics/VTI12/VTI12Systems/VTI12TrackSystems/VTI12TrackSystems/TrackHandleBase.h +++ b/graphics/VTI12/VTI12Systems/VTI12TrackSystems/VTI12TrackSystems/TrackHandleBase.h @@ -29,6 +29,7 @@ #include <QTreeWidgetItem> #include <vector> #include <set> +#include <optional> #include <QList> #include <QFlags> diff --git a/graphics/VTI12/VTI12Systems/VTI12TrackSystems/src/TrackCollHandleBase.cxx b/graphics/VTI12/VTI12Systems/VTI12TrackSystems/src/TrackCollHandleBase.cxx index f36256e23acf7d939432d9f84308cbed0319c8df..9ebac1b2ed7f32092f68e0a23734bb889e1afe0b 100644 --- a/graphics/VTI12/VTI12Systems/VTI12TrackSystems/src/TrackCollHandleBase.cxx +++ b/graphics/VTI12/VTI12Systems/VTI12TrackSystems/src/TrackCollHandleBase.cxx @@ -194,7 +194,7 @@ void TrackCollHandleBase::setupSettingsFromController(TrackSystemController* con assert(controller); largeChangesBegin(); - connect(controller->customTourEditor(),SIGNAL(clipVolumeRadiusChanged(double)),this,SLOT(clipVolumeChanged(double))); + if (controller->customTourEditor()) connect(controller->customTourEditor(),SIGNAL(clipVolumeRadiusChanged(double)),this,SLOT(clipVolumeChanged(double))); connect(controller,SIGNAL(propagatorChanged(Trk::IExtrapolator *)),this,SLOT(setPropagator(Trk::IExtrapolator *))); setPropagator(controller->propagator()); diff --git a/graphics/VTI12/VTI12Systems/VTI12TrackSystems/src/TrackPropagationHelper.cxx b/graphics/VTI12/VTI12Systems/VTI12TrackSystems/src/TrackPropagationHelper.cxx index f5545c729ec9007f9f2823ec2f5e968ceac35b17..49444e861d8ffa69c07a6b6857447cb4e93b8c9b 100644 --- a/graphics/VTI12/VTI12Systems/VTI12TrackSystems/src/TrackPropagationHelper.cxx +++ b/graphics/VTI12/VTI12Systems/VTI12TrackSystems/src/TrackPropagationHelper.cxx @@ -303,7 +303,9 @@ bool TrackPropagationHelper::makePointsCharged( std::vector<Amg::Vector3D >& poi //get individual surfaces //TODO - optimise this! - const std::vector< const Trk::Surface * > * bsurfs = volume->volumeBounds ().decomposeToSurfaces (volume->transform ()); + const std::vector<const Trk::Surface*>* bsurfs = + const_cast<Trk::VolumeBounds&>(volume->volumeBounds()) + .decomposeToSurfaces(volume->transform()); if (bsurfs){ messageVerbose("Has this many surfaces:"+str(bsurfs->size())); diff --git a/version.txt b/version.txt index cdbc15874e55b47fb45012cbf75daefe3196299b..140125644054770fe54c322164c33e7cd9395b79 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -22.0.40 +22.0.49 diff --git a/xAOD/xAODFaserCalorimeter/CMakeLists.txt b/xAOD/xAODFaserCalorimeter/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..ec4c8c09788e92fb799c2e5119ad6c1a9a626454 --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (C) 2020 CERN for the benefit of the FASER collaboration + +# Declare the package name. +atlas_subdir( xAODFaserCalorimeter ) + +# External dependencies. +find_package( xAODUtilities ) + +# Component(s) in the package. +atlas_add_library( xAODFaserCalorimeter + xAODFaserCalorimeter/*.h xAODFaserCalorimeter/versions/*.h Root/*.cxx + PUBLIC_HEADERS xAODFaserCalorimeter + LINK_LIBRARIES Identifier xAODCore xAODFaserWaveform ) + +atlas_add_xaod_smart_pointer_dicts( + INPUT xAODFaserCalorimeter/selection.xml + OUTPUT _selectionFile + CONTAINERS "xAOD::CalorimeterHitContainer_v1") + +atlas_add_dictionary( xAODFaserCalorimeterDict + xAODFaserCalorimeter/xAODFaserCalorimeterDict.h + ${_selectionFile} + LINK_LIBRARIES Identifier xAODCore xAODFaserCalorimeter + EXTRA_FILES Root/dict/*.cxx ) + diff --git a/xAOD/xAODFaserCalorimeter/README b/xAOD/xAODFaserCalorimeter/README new file mode 100644 index 0000000000000000000000000000000000000000..02dcfa45e9fafa3fa8edb77dbba4158f5ac09d59 --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/README @@ -0,0 +1,2 @@ +ElementLinks added following DiTauJet example here: +https://gitlab.cern.ch/atlas/athena/-/tree/master/Event/xAOD/xAODTau \ No newline at end of file diff --git a/xAOD/xAODFaserCalorimeter/Root/CalorimeterHitAuxContainer_v1.cxx b/xAOD/xAODFaserCalorimeter/Root/CalorimeterHitAuxContainer_v1.cxx new file mode 100644 index 0000000000000000000000000000000000000000..6f6edf3e4c520dbf32bb816addb74f4ad3eae23f --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/Root/CalorimeterHitAuxContainer_v1.cxx @@ -0,0 +1,21 @@ +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +// Local include(s): +#include "xAODFaserCalorimeter/versions/CalorimeterHitAuxContainer_v1.h" + +namespace xAOD { + + CalorimeterHitAuxContainer_v1::CalorimeterHitAuxContainer_v1() + : AuxContainerBase() { + + AUX_VARIABLE(localtime); + AUX_VARIABLE(bcid_time); + AUX_VARIABLE(raw_energy); + + AUX_VARIABLE(caloLinks); + } + +} // namespace xAOD + diff --git a/xAOD/xAODFaserCalorimeter/Root/CalorimeterHit_v1.cxx b/xAOD/xAODFaserCalorimeter/Root/CalorimeterHit_v1.cxx new file mode 100644 index 0000000000000000000000000000000000000000..5e7a69ecc024dc3ecb70df95f1e623c4bc4e09fc --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/Root/CalorimeterHit_v1.cxx @@ -0,0 +1,67 @@ +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +// EDM include(s): +#include "xAODCore/AuxStoreAccessorMacros.h" + +// Local include(s): +#include "xAODFaserCalorimeter/versions/CalorimeterHit_v1.h" + +namespace xAOD { + + CalorimeterHit_v1::CalorimeterHit_v1() : SG::AuxElement() { + } + + AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( CalorimeterHit_v1, float, localtime, set_localtime ) + + AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( CalorimeterHit_v1, float, bcidtime, set_bcidtime ) + + AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( CalorimeterHit_v1, float, raw_energy, set_raw_energy ) + + // setters and getters for the Calo WaveformHit links + + AUXSTORE_OBJECT_SETTER_AND_GETTER( CalorimeterHit_v1, + CalorimeterHit_v1::WaveformHitLinks_t, + caloWaveformLinks, + setCaloWaveformLinks ) + + static const SG::AuxElement::Accessor< CalorimeterHit_v1::WaveformHitLinks_t > caloHitAcc( "caloWaveformLinks" ); + + const WaveformHit* CalorimeterHit_v1::caloHit( size_t i ) const { + return ( *caloHitAcc( *this )[ i ] ); + } + + size_t CalorimeterHit_v1::nCaloHits() const { + return caloHitAcc( *this ).size(); + } + + void CalorimeterHit_v1::addCaloHit( const xAOD::WaveformHitContainer* pWaveformHitContainer, + const xAOD::WaveformHit* pWaveformHit) { + ElementLink< xAOD::WaveformHitContainer > linkToWaveformHit; + linkToWaveformHit.toContainedElement(*pWaveformHitContainer, pWaveformHit); + + caloHitAcc( *this ).push_back( linkToWaveformHit ); + + return; + } + + void CalorimeterHit_v1::clearCaloWaveformLinks() { + caloHitAcc( *this ).clear(); + return; + } + +} // namespace xAOD + +namespace xAOD { + + std::ostream& operator<<(std::ostream& s, const xAOD::CalorimeterHit_v1& hit) { + s << "xAODCalorimeterHit:" + << " local time=" << hit.localtime() + << " raw_energy=" << hit.raw_energy() + << std::endl; + + return s; + } + +} // namespace xAOD diff --git a/xAOD/xAODFaserCalorimeter/Root/dict/ContainerProxies.cxx b/xAOD/xAODFaserCalorimeter/Root/dict/ContainerProxies.cxx new file mode 100644 index 0000000000000000000000000000000000000000..8d2cc883ca49d230cc66fdfcab9dedf0112e30eb --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/Root/dict/ContainerProxies.cxx @@ -0,0 +1,8 @@ +// EDM include(s): +#include "xAODCore/AddDVProxy.h" + +// Local include(s): +#include "xAODFaserCalorimeter/CalorimeterHitContainer.h" + +// Set up the collection proxies: +ADD_NS_DV_PROXY( xAOD, CalorimeterHitContainer ); diff --git a/xAOD/xAODFaserCalorimeter/Root/xAODFaserCalorimeterCLIDs.cxx b/xAOD/xAODFaserCalorimeter/Root/xAODFaserCalorimeterCLIDs.cxx new file mode 100644 index 0000000000000000000000000000000000000000..b98755185832080df8e8e60165c5f98c1e68bcf6 --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/Root/xAODFaserCalorimeterCLIDs.cxx @@ -0,0 +1,8 @@ +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +//simple includes to force the CLASS_DEF etc to be encountered during compile + +#include "xAODFaserCalorimeter/CalorimeterHitContainer.h" +#include "xAODFaserCalorimeter/CalorimeterHitAuxContainer.h" diff --git a/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/CalorimeterHit.h b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/CalorimeterHit.h new file mode 100644 index 0000000000000000000000000000000000000000..2a0fc9bac8f81a9e439a5426da3f28bf607d351a --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/CalorimeterHit.h @@ -0,0 +1,22 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +#ifndef XAODFASERCALORIMETER_CALORIMETERHIT_H +#define XAODFASERCALORIMETER_CALORIMETERHIT_H + +// Local include(s): +#include "xAODFaserCalorimeter/versions/CalorimeterHit_v1.h" + +namespace xAOD { + /// Declare the latest version of the class + typedef CalorimeterHit_v1 CalorimeterHit; +} + +// Set up a CLID for the container: +#include "xAODCore/CLASS_DEF.h" +CLASS_DEF( xAOD::CalorimeterHit, 195445226, 1 ) + +#endif // XAODFASERCALORIMETER_CALORIMETERHIT_H diff --git a/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/CalorimeterHitAuxContainer.h b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/CalorimeterHitAuxContainer.h new file mode 100644 index 0000000000000000000000000000000000000000..d7c60f9fe782c7f3f817c8f285be1d0616b3e12b --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/CalorimeterHitAuxContainer.h @@ -0,0 +1,22 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +#ifndef XAODFASERCALORIMETER_CALORIMETERHITAUXCONTAINER_H +#define XAODFASERCALORIMETER_CALORIMETERHITAUXCONTAINER_H + +// Local include(s): +#include "xAODFaserCalorimeter/versions/CalorimeterHitAuxContainer_v1.h" + +namespace xAOD { + /// Declare the latest version of the class + typedef CalorimeterHitAuxContainer_v1 CalorimeterHitAuxContainer; +} + +// Set up a CLID for the container: +#include "xAODCore/CLASS_DEF.h" +CLASS_DEF( xAOD::CalorimeterHitAuxContainer, 1074912337, 1 ) + +#endif // XAODFASERCALORIMETER_CALORIMETERHITAUXCONTAINER_H diff --git a/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/CalorimeterHitContainer.h b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/CalorimeterHitContainer.h new file mode 100644 index 0000000000000000000000000000000000000000..21f338983f67681cba5d3d505ca37ba5324b1f0c --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/CalorimeterHitContainer.h @@ -0,0 +1,22 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +#ifndef XAODFASERCALORIMETER_CALORIMETERHITCONTAINER_H +#define XAODFASERCALORIMETER_CALORIMETERHITCONTAINER_H + +// Local include(s): +#include "xAODFaserCalorimeter/versions/CalorimeterHitContainer_v1.h" + +namespace xAOD { + /// Declare the latest version of the class + typedef CalorimeterHitContainer_v1 CalorimeterHitContainer; +} + +// Set up a CLID for the container: +#include "xAODCore/CLASS_DEF.h" +CLASS_DEF( xAOD::CalorimeterHitContainer, 1147607550, 1 ) + +#endif // XAODFASERCALORIMETER_CALORIMETERHITCONTAINER_H diff --git a/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/selection.xml b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/selection.xml new file mode 100644 index 0000000000000000000000000000000000000000..a07951d20534a62a96b9452c008b06bb23814eb8 --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/selection.xml @@ -0,0 +1,16 @@ +<!-- Copyright (C) 2020 CERN for the benefit of the FASER collaboration --> +<lcgdict> + + <class name="xAOD::CalorimeterHit_v1" /> + <typedef name="xAOD::CalorimeterHit" /> + + <class name="xAOD::CalorimeterHitContainer_v1" + id="1172f311-f09a-4e3b-a946-68991c2c0646" /> + <typedef name="xAOD::CalorimeterHitContainer" /> + + <class name="xAOD::CalorimeterHitAuxContainer_v1" + id="755f71cf-2148-4736-b26e-3c007d627861" /> + <typedef name="xAOD::CalorimeterHitAuxContainer" /> + + +</lcgdict> diff --git a/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/versions/CalorimeterHitAuxContainer_v1.h b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/versions/CalorimeterHitAuxContainer_v1.h new file mode 100644 index 0000000000000000000000000000000000000000..7e61261eb4bd10f106d03b2a85f9918b82ce7944 --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/versions/CalorimeterHitAuxContainer_v1.h @@ -0,0 +1,50 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +#ifndef XAODFASERCALORIMETER_VERSIONS_CALORIMETERHITAUXCONTAINER_V1_H +#define XAODFASERCALORIMETER_VERSIONS_CALORIMETERHITAUXCONTAINER_V1_H + +// STL include(s): +#include <vector> + +// EDM include(s): +#include "xAODCore/AuxContainerBase.h" +#include "xAODFaserWaveform/WaveformHitContainer.h" + +namespace xAOD { + + /// Auxiliary container for CalorimeterHit containers + + class CalorimeterHitAuxContainer_v1 : public AuxContainerBase { + + public: + /// Default constructor + CalorimeterHitAuxContainer_v1(); + /// Destructor + ~CalorimeterHitAuxContainer_v1() {} + + private: + /// @name Basic variables + ///@ { + std::vector<float> localtime; + std::vector<float> bcid_time; + std::vector<float> raw_energy; + + typedef std::vector< ElementLink< WaveformHitContainer > > WaveformHitLink_t; + std::vector< WaveformHitLink_t > caloLinks; + std::vector< WaveformHitLink_t > preshowerLinks; + + ///@} + + }; // class CalorimeterHitAuxContainer_v1 + +} // namespace xAOD + +// Set up a CLID and StoreGate inheritance for the class: +#include "xAODCore/BaseInfo.h" +SG_BASE( xAOD::CalorimeterHitAuxContainer_v1, xAOD::AuxContainerBase ); + +#endif // XAODFASERCALORIMETER_VERSIONS_CALORIMETERHITAUXCONTAINER_V1_H diff --git a/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/versions/CalorimeterHitContainer_v1.h b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/versions/CalorimeterHitContainer_v1.h new file mode 100644 index 0000000000000000000000000000000000000000..84201189dcd86d08dd7bfa0083fe6bfb1c970b01 --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/versions/CalorimeterHitContainer_v1.h @@ -0,0 +1,26 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +#ifndef XAODFASERCALORIMETER_VERSIONS_CALORIMETERHITCONTAINER_V1_H +#define XAODFASERCALORIMETER_VERSIONS_CALORIMETERHITCONTAINER_V1_H + +// System include(s): +extern "C" { +# include "stdint.h" +} + +// EDM include(s): +#include "AthContainers/DataVector.h" + +// Local includes: +#include "xAODFaserCalorimeter/versions/CalorimeterHit_v1.h" + +namespace xAOD { + // Define the container as a simple DataVector + typedef DataVector<CalorimeterHit_v1> CalorimeterHitContainer_v1; +} + +#endif // XAODFASERCALORIMETER_VERSIONS_CALORIMETERHITCONTAINER_V1_H diff --git a/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/versions/CalorimeterHit_v1.h b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/versions/CalorimeterHit_v1.h new file mode 100644 index 0000000000000000000000000000000000000000..d9bb35047e6a75d6dac12dc0ba0eb47e3bceb684 --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/versions/CalorimeterHit_v1.h @@ -0,0 +1,86 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +#ifndef XAODFASERCALORIMETER_VERSIONS_CALORIMETERHIT_V1_H +#define XAODFASERCALORIMETER_VERSIONS_CALORIMETERHIT_V1_H + +// System include(s): +extern "C" { +# include "stdint.h" +} + +#include <vector> + +// Core EDM include(s): +#include "AthLinks/ElementLink.h" +#include "AthContainers/AuxElement.h" + +// xAOD include(s): +#include "xAODFaserWaveform/WaveformHit.h" +#include "xAODFaserWaveform/WaveformHitContainer.h" + +namespace xAOD { + + // Cllss describing pulses in the calorimeter digitizer + class CalorimeterHit_v1 : public SG::AuxElement { + + public: + /// Defaullt constructor + CalorimeterHit_v1(); + + /// @name Access CalorimeterHit elements + /// @{ + + /// Best results + float localtime() const; + void set_localtime(float value); + + float bcidtime() const; + void set_bcidtime(float value); + + float raw_energy() const; + void set_raw_energy(float value); + + // Waveform Hits + typedef std::vector< ElementLink< xAOD::WaveformHitContainer > > WaveformHitLinks_t; + + // Contributing Calorimeter Waveform Hits + const WaveformHitLinks_t& caloWaveformLinks() const; + void setCaloWaveformLinks( const WaveformHitLinks_t& caloWaveforms ); + // Remove all waveform hits + void clearCaloWaveformLinks(); + // Get the pointer to a given waveform hit + const WaveformHit* caloHit( size_t i ) const; + // Get the number of waveform hits + size_t nCaloHits() const; + // Add a waveform hit + void addCaloHit( const xAOD::WaveformHitContainer*, const xAOD::WaveformHit*); + + // // Contributing Preshower Waveform Hits + // const WaveformHitLinks_t& preshowerWaveformLinks() const; + // void setPreshowerWaveformLinks( const WaveformHitLinks_t& preshowerWaveforms ); + // // Remove all waveform hits + // void clearPreshowerWaveformLinks(); + // // Get the pointer to a given waveform hit + // const WaveformHit* preshowerHit( size_t i ) const; + // // Get the number of waveform hits + // size_t nPreshowerHits() const; + // // Add a waveform hit + // void addPreshowerHit( const xAOD::WaveformHitContainer*, const xAOD::WaveformHit*); + + /// @} + + }; // class CalorimeterHit_v1 + + std::ostream& operator<<(std::ostream& s, const xAOD::CalorimeterHit_v1& hit); +} + +// Declare the inheritance of the type: +#include "xAODCore/BaseInfo.h" +SG_BASE( xAOD::CalorimeterHit_v1, SG::AuxElement ); + + +#endif // XAODFASERCALORIMETER_VERSIONS_CALORIMETERHIT_V1_H diff --git a/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/xAODFaserCalorimeterDict.h b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/xAODFaserCalorimeterDict.h new file mode 100644 index 0000000000000000000000000000000000000000..387eacb5e0c4e510a875a1ddfa4f8a5f0213ebdb --- /dev/null +++ b/xAOD/xAODFaserCalorimeter/xAODFaserCalorimeter/xAODFaserCalorimeterDict.h @@ -0,0 +1,26 @@ +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +#ifndef XAODFASERCALORIMETER_XAODFASERCALORIMETERDICT_H +#define XAODFASERCALORIMETER_XAODFASERCALORIMETERDICT_H + +// Local includes +#include "xAODFaserCalorimeter/CalorimeterHit.h" +#include "xAODFaserCalorimeter/CalorimeterHitContainer.h" +#include "xAODFaserCalorimeter/CalorimeterHitAuxContainer.h" + +#include "xAODFaserCalorimeter/versions/CalorimeterHit_v1.h" +#include "xAODFaserCalorimeter/versions/CalorimeterHitContainer_v1.h" +#include "xAODFaserCalorimeter/versions/CalorimeterHitAuxContainer_v1.h" + +// EDM include(s). +#include "xAODCore/tools/DictHelpers.h" + +namespace { + struct GCCXML_DUMMY_INSTANTIATION_XAODFASERCALORIMETER { + XAOD_INSTANTIATE_NS_CONTAINER_TYPES( xAOD, CalorimeterHitContainer_v1 ); + }; +} + +#endif // XAODFASERCALORIMETER_XAODFASERCALORIMETERDICT_H diff --git a/xAOD/xAODFaserCalorimeterAthenaPool/CMakeLists.txt b/xAOD/xAODFaserCalorimeterAthenaPool/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..14c855eeff41534ed5a09a38b912a11dd1395a23 --- /dev/null +++ b/xAOD/xAODFaserCalorimeterAthenaPool/CMakeLists.txt @@ -0,0 +1,14 @@ +# Copyright (C) 2020 CERN for the benefit of the FASER collaboration + +# Declare the package name. +atlas_subdir( xAODFaserCalorimeterAthenaPool ) + +# Component(s) in the package: +atlas_add_poolcnv_library( xAODFaserCalorimeterAthenaPoolPoolCnv + src/*.h src/*.cxx + FILES xAODFaserCalorimeter/CalorimeterHitContainer.h xAODFaserCalorimeter/CalorimeterHitAuxContainer.h + TYPES_WITH_NAMESPACE xAOD::CalorimeterHitContainer xAOD::CalorimeterHitAuxContainer + CNV_PFX xAOD + LINK_LIBRARIES AthenaPoolCnvSvcLib AthenaPoolUtilities xAODFaserCalorimeter xAODFaserWaveform ) + + diff --git a/xAOD/xAODFaserCalorimeterAthenaPool/src/xAODCalorimeterHitAuxContainerCnv.cxx b/xAOD/xAODFaserCalorimeterAthenaPool/src/xAODCalorimeterHitAuxContainerCnv.cxx new file mode 100644 index 0000000000000000000000000000000000000000..783826faef6ddb70bf5806e935a364c7a9177d46 --- /dev/null +++ b/xAOD/xAODFaserCalorimeterAthenaPool/src/xAODCalorimeterHitAuxContainerCnv.cxx @@ -0,0 +1,6 @@ +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +// Dummy source file so that cmake will know this is a custom converter. +// xAODCalorimeterHitAuxContainerCnv.cxx diff --git a/xAOD/xAODFaserCalorimeterAthenaPool/src/xAODCalorimeterHitAuxContainerCnv.h b/xAOD/xAODFaserCalorimeterAthenaPool/src/xAODCalorimeterHitAuxContainerCnv.h new file mode 100644 index 0000000000000000000000000000000000000000..49acdb4f27d547ef553dfc82b2d9528978c1991c --- /dev/null +++ b/xAOD/xAODFaserCalorimeterAthenaPool/src/xAODCalorimeterHitAuxContainerCnv.h @@ -0,0 +1,15 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +#ifndef XAODFASERCALORIMETERATHENAPOOL_XAODCALORIMETERHITAUXCONTAINERCNV_H +#define XAODFASERCALORIMETERATHENAPOOL_XAODCALORIMETERHITAUXCONTAINERCNV_H + +#include "xAODFaserCalorimeter/CalorimeterHitAuxContainer.h" +#include "AthenaPoolCnvSvc/T_AthenaPoolAuxContainerCnv.h" + +typedef T_AthenaPoolAuxContainerCnv<xAOD::CalorimeterHitAuxContainer> xAODCalorimeterHitAuxContainerCnv; + +#endif // XAODFASERCALORIMETERATHENAPOOL_XAODFASERCALORIMETERHITAUXCONTAINERCNV_H diff --git a/xAOD/xAODFaserCalorimeterAthenaPool/src/xAODCalorimeterHitContainerCnv.cxx b/xAOD/xAODFaserCalorimeterAthenaPool/src/xAODCalorimeterHitContainerCnv.cxx new file mode 100644 index 0000000000000000000000000000000000000000..03aa7c9bedf108b7bf7cf9dec5bd010f4b6ecdc9 --- /dev/null +++ b/xAOD/xAODFaserCalorimeterAthenaPool/src/xAODCalorimeterHitContainerCnv.cxx @@ -0,0 +1,6 @@ +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +// Dummy source file so that cmake will know this is a custom converter. +// xAODCalorimeterHitContainerCnv.cxx diff --git a/xAOD/xAODFaserCalorimeterAthenaPool/src/xAODCalorimeterHitContainerCnv.h b/xAOD/xAODFaserCalorimeterAthenaPool/src/xAODCalorimeterHitContainerCnv.h new file mode 100644 index 0000000000000000000000000000000000000000..360e61266868e159e1e5d7f7b0929957ac052147 --- /dev/null +++ b/xAOD/xAODFaserCalorimeterAthenaPool/src/xAODCalorimeterHitContainerCnv.h @@ -0,0 +1,15 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2020 CERN for the benefit of the FASER collaboration +*/ + +#ifndef XAODFASERCALORIMETERATHENAPOOL_XAODCALORIMETERHITCONTAINERCNV_H +#define XAODFASERCALORIMETERATHENAPOOL_XAODCALORIMETERHITCONTAINERCNV_H + +#include "xAODFaserCalorimeter/CalorimeterHitContainer.h" +#include "AthenaPoolCnvSvc/T_AthenaPoolxAODCnv.h" + +typedef T_AthenaPoolxAODCnv<xAOD::CalorimeterHitContainer> xAODCalorimeterHitContainerCnv; + +#endif // XAODFASERCALORIMETERATHENAPOOL_XAODCALORIMETERHITCONTAINERCNV_H diff --git a/xAOD/xAODFaserWaveform/Root/WaveformHit_v1.cxx b/xAOD/xAODFaserWaveform/Root/WaveformHit_v1.cxx index 8b26eebffaa1018193523608e0494ef5fcc29d44..df91c67cf77ef79b749934687ee910146ee3e309 100644 --- a/xAOD/xAODFaserWaveform/Root/WaveformHit_v1.cxx +++ b/xAOD/xAODFaserWaveform/Root/WaveformHit_v1.cxx @@ -55,6 +55,8 @@ namespace xAOD { s << "xAODWaveformHit: channel=" << hit.channel() << " local time=" << hit.localtime() << " peak=" << hit.peak() + << " start time=" << hit.time_vector().front() + << " end time=" << hit.time_vector().back() << std::endl; return s;