![Logo](../../ATLAS-Logo-Square-Blue-RGB.png) |
ATLAS Offline Software
|
Go to the documentation of this file.
9 #include "CoralBase/AttributeListSpecification.h"
10 #include "CoralBase/Attribute.h"
19 #include "GaudiKernel/NTuple.h"
20 #include "GaudiKernel/INTupleSvc.h"
21 #include "GaudiKernel/SmartDataPtr.h"
23 #include "GaudiKernel/RndmGenerators.h"
24 #include "GaudiKernel/IRndmGenSvc.h"
61 const std::string&
name,
const IInterface*
parent)
67 m_attrListCollection(nullptr),
69 m_par_scttwoside(false),
71 m_par_condstream(
"AthenaOutputStreamTool/AthenaOutputStreamTool", this),
72 m_par_dbroot(
"/Indet/Align" ),
73 m_par_dbkey(
"/Indet/Align" ),
74 m_par_oldTextFile(false),
76 m_forceUserDBConfig(false)
78 declareInterface<IInDetAlignDBTool>(
this);
104 return StatusCode::FAILURE;
139 ATH_MSG_FATAL(
"Pixel and SCT Managers have different alignfolder type registered --> Check ");
140 return StatusCode::FAILURE;
148 return StatusCode::FAILURE;
153 return StatusCode::FAILURE;
166 int TransfLevel_low = 0;
170 std::string man_name;
174 if (element!=
nullptr) {
178 std::string
level[3];
179 for (
int i=TransfLevel_low;
i<3;++
i) {
182 std::vector<std::string>::const_iterator ix=
191 ATH_MSG_ERROR(
"Si detector element type " << idet <<
" has no detset conversion" );
198 ATH_MSG_INFO(
"Geometry initialisation sees " << ndet[0] <<
199 " pixel and " << ndet[1] <<
" SCT modules giving " <<
m_alignobjs.size()
200 <<
" alignment keys" );
205 " pixel and " << ndet[1] <<
" SCT modules giving " <<
m_alignobjs.size()
206 <<
" alignment keys" );
213 ATH_MSG_DEBUG(
"Assuming new COOL alignment DB model based on AlignableTransformContainer");
216 ATH_MSG_DEBUG(
"Assuming old (Lisbon) alignment DB model based on separate AlignableTransforms");
223 coral::AttributeListSpecification*
spec =
new coral::AttributeListSpecification();
224 spec->extend(
"stave",
"int");
225 spec->extend(
"eta",
"int");
226 spec->extend(
"mag",
"float");
227 spec->extend(
"base",
"float");
228 spec->extend(
"free",
"float");
230 const int ibl_stave_max = 14;
232 for (
int this_stave=0; this_stave<ibl_stave_max; this_stave++){
236 atrlist[
"stave" ].data<
int>()=this_stave;
237 atrlist[
"eta" ].data<
int>()=0;
238 atrlist[
"mag" ].data<
float>()=0;
239 atrlist[
"base" ].data<
float>()=0;
240 atrlist[
"free" ].data<
float>()=0;
244 return StatusCode::SUCCESS;
250 return StatusCode::SUCCESS;
259 ATH_MSG_FATAL(
"Cannot create new database when geometry is faked");
270 ATH_MSG_ERROR(
"createDB: AlignableTransformContainer already exists");
274 ATH_MSG_DEBUG(
"Setup database structures in AlignableTransformContainer");
278 ATH_MSG_DEBUG(
"Setup separate AlignableTransform for each layer");
283 else ATH_MSG_DEBUG(
"Treat both sides of SCT module as single entity" );
308 ATH_MSG_ERROR(
"Could not record AlignableTransformContainer");
313 std::vector<std::string> level2;
320 if (element!=
nullptr) {
332 std::vector<std::string>::const_iterator ix =
find(level2.begin(),level2.end(),
key);
333 if (ix==level2.end()) {
334 level2.push_back(
key);
362 globshift.setIdentity();
384 ATH_MSG_DEBUG(
"Dumping size of created AlignableTransform objects");
390 int&
layer,
int& ring,
int& sector,
int&
side)
const {
417 const int level)
const {
431 std::ostringstream
result;
449 int layer,
const int level,
const int sector)
const {
452 std::ostringstream
result;
454 result <<
"/Indet/AlignL";
480 const int level,
const int sector)
const {
483 std::ostringstream
result;
497 const int layer,
const int ring,
const int sector,
498 const float rphidisp,
const float rdisp,
const float zdisp,
499 const int syst,
const int level,
const int skip)
const {
504 IRndmGenSvc* randsvc;
505 if (StatusCode::SUCCESS!=service(
"RndmGenSvc",randsvc,
true))
507 Rndm::Numbers
gauss(randsvc,Rndm::Gauss(0.,1.));
513 float rpd=0,rd=0,zd=0;
515 rpd=rphidisp*
gauss();
520 std::vector<Identifier> lvl12id;
523 for (
int idet=1;idet<3;++idet) {
525 if (element!=
nullptr) {
527 int mdet,mbec,mlayer,mring,msector,mside;
530 if ((dettype==-1 || mdet==dettype) && (
bec==-1 || std::abs(2*mbec)==
bec) &&
531 (
layer==-1 || mlayer==
layer) && (ring==-1 || mring==ring) &&
532 (sector== -1 || msector==sector) && mside==0) {
539 if (dettype!=2 || mside!=1) {
540 if (syst==2 || syst==4 || (syst==6 && mring==-6)) {
541 rpd=rphidisp*
gauss();
545 mlayer <<
" " << mring <<
" z " << zd );
554 if (syst<=2 || syst==6) {
557 float dx=modcent.x();
558 float dy=modcent.y();
576 }
else if (
level==2) {
586 std::vector<Identifier>::const_iterator ix=
587 find(lvl12id.begin(),lvl12id.end(),ident2);
588 if (ix==lvl12id.end()) {
589 lvl12id.push_back(ident2);
601 std::vector<Identifier>::const_iterator ix=
602 find(lvl12id.begin(),lvl12id.end(),ident2);
603 if (ix==lvl12id.end()) {
604 lvl12id.push_back(ident2);
615 <<
"," << mlayer <<
"," << mring <<
"," << msector <<
" to xyz" <<
616 xd <<
"," << yd <<
"," << zd );
626 ATH_MSG_DEBUG(
"Added displacement to " << nmod <<
" modules " << dettype <<
","
627 <<
bec <<
"," <<
layer <<
" [" << rphidisp <<
"," << rdisp
628 <<
"," << zdisp <<
"]"
629 <<
" type " << syst );
634 std::ofstream*
outfile=
nullptr;
636 if (StatusCode::SUCCESS!=service(
"NTupleSvc",ntsvc,
true))
638 const std::string
path=
file+
"/9002";
642 ATH_MSG_DEBUG(
"writeFile: Write AlignableTransforms on ntuple 9002, path: " <<
file );
648 nt=ntsvc->book(
file,ntid,CLID_ColumnWiseTuple,
"AlignDB");
669 "Error booking ntuple 9002 contents" );
676 for (std::vector<std::string>::const_iterator iobj=
m_alignobjs.begin();
681 if (!ntuple) *
outfile << *iobj << std::endl;
683 cit!=
pat->end();++cit) {
719 std::string r3=iobj->substr(iobj->size()-3,3);
721 if (r3==
"SCT" || r3==
"PIX")
nt_level=2;
732 if (StatusCode::SUCCESS!=
nt->write())
ATH_MSG_ERROR(
"Problem filling ntuple 9002" );
735 " " << ring <<
" " <<
side <<
" " <<
dx <<
" " <<
dy <<
" "
749 ATH_MSG_DEBUG(
"Written " << nobj <<
" AlignableTransform objects" <<
" with " << ntrans <<
" transforms to text file" );
755 std::ofstream*
outfile=
nullptr;
759 *
outfile <<
"/Indet/IBLDist" << std::endl;
762 if (StatusCode::SUCCESS==
detStore()->
retrieve(atrlistcol,
"/Indet/IBLDist")) {
767 *
outfile << citr->first <<
" " << atrlist[
"stave"].data<
int>()
768 <<
" " << atrlist[
"eta"].data<int>()
769 <<
" " << atrlist[
"mag"].data<
float>()
770 <<
" " << atrlist[
"base"].data<float>() << std::endl;
775 msg(MSG::INFO) <<
"Cannot find IBLDist Container - cannot write IBLDist DB in text file " <<
endmsg;
787 std::ofstream*
outfile=
nullptr;
792 std::vector<std::string> folder_list = {
"/Indet/AlignL1/ID",
"/Indet/AlignL2/PIX",
"/Indet/AlignL2/SCT"};
804 *
outfile << atrlist[
"subsystem"].data<
int>()
805 <<
" " << atrlist[
"det"].data<int>()
806 <<
" " << atrlist[
"bec"].data<
int>()
807 <<
" " << atrlist[
"layer"].data<int>()
808 <<
" " << atrlist[
"ring"].data<
int>()
809 <<
" " << atrlist[
"sector"].data<int>()
810 <<
" " << atrlist[
"side"].data<
int>()
811 <<
" " << atrlist[
"Tx"].data<float>()
812 <<
" " << atrlist[
"Ty"].data<
float>()
813 <<
" " << atrlist[
"Tz"].data<float>()
814 <<
" " << atrlist[
"Rx"].data<
float>()
815 <<
" " << atrlist[
"Ry"].data<float>()
816 <<
" " << atrlist[
"Rz"].data<
float>() << std::endl;
821 msg(MSG::INFO) <<
"Cannot find " << *
it <<
" Container - cannot write DB in text file " <<
endmsg;
828 ATH_MSG_DEBUG(
"writeFile: No dynamic Run2 DB structure is present --> skipping writing file " <<
file );
837 ATH_MSG_DEBUG(
"readTextFile - set alignment constants from text file: " <<
file );
849 std::string channelName;
854 std::getline(
infile, tmpline);
858 if ((tmpline.substr(0,2) ==
"//") || (tmpline.substr(0,1) ==
"#"))
continue;
860 std::istringstream instring(tmpline);
865 if (tmpstr.empty())
continue;
867 if (tmpstr[0] ==
'/') {
869 channelName = tmpstr;
870 ATH_MSG_DEBUG(
"Read in AlignableTransform data, key " << channelName );
874 ATH_MSG_ERROR(
"Cannot find AlignableTransform object for key"
888 std::istringstream datastream(tmpline);
895 if (datastream.fail()) {
906 }
else if (dettype==2) {
912 if (!
ident.is_valid()) {
915 phiModule <<
"," << etaModule <<
"," <<
side <<
"] key " << channelName <<
916 " shift [" <<
dx <<
"," <<
dy <<
"," << dz <<
"]" );
923 Amg::Transform3D newtrans = newtranslation * Amg::RotationMatrix3D::Identity();
935 while ((itr->identify()!=
ident) && (itr!=pat2->
mend())) ++itr;
936 if (itr!=pat2->
mend()) {
945 " shift [" <<
dx <<
"," <<
dy <<
"," << dz <<
"]" );
953 ATH_MSG_DEBUG(
"Read " << nobj <<
" objects from file with " << ntrans <<
" transforms" );
958 ATH_MSG_DEBUG(
"readNtuple - set alignment constants from ntuple path: " <<
file );
960 if (StatusCode::SUCCESS!=service(
"NTupleSvc",ntsvc,
true))
962 const std::string
path=
file+
"/9002";
981 "Error booking ntuple 9002 contents" );
983 while (
nt->read().isSuccess()) {
995 Amg::Transform3D newtrans = newtranslation * Amg::RotationMatrix3D::Identity();
1003 ATH_MSG_DEBUG(
"Read " << ntrans <<
" transforms from ntuple");
1029 if (pat2!=
nullptr) {
1034 ATH_MSG_ERROR(
"setTrans: cannot retrieve AlignableTransform for key" <<
key );
1046 Amg::Transform3D newtrans = newtranslation * Amg::RotationMatrix3D::Identity();
1073 if (pat2!=
nullptr) {
1082 "tweakTrans: cannot retrieve AlignableTransform for key" <<
key );
1094 Amg::Transform3D newtrans = newtranslation * Amg::RotationMatrix3D::Identity();
1142 ATH_MSG_ERROR(
"getTransL123(): Module not found in PIX or SCT!" );
1148 ATH_MSG_FATAL(
"Code needs to corrected otherwise you will get nonsensical results-- IndetAlignDBTool:2060");
1151 result = trfL1 * trfL2 * trfL3 ;
1159 const int level)
const {
1178 return StatusCode::FAILURE;
1210 ATH_MSG_DEBUG(
"starting to register typeKey for IBLDist" );
1213 typekeys_IBLDist[0] = pair;
1216 if (StatusCode::SUCCESS!=
m_par_condstream->streamObjects(typekeys_IBLDist)) {
1218 return StatusCode::FAILURE;
1230 return StatusCode::SUCCESS;
1234 const unsigned int run1,
const unsigned int event1,
1235 const unsigned int run2,
const unsigned int event2)
const {
1243 if (StatusCode::SUCCESS!=
1244 service(
"IOVRegistrationSvc",regsvc)) {
1260 for (std::vector<std::string>::const_iterator iobj=
m_alignobjs.begin();
1262 if (StatusCode::SUCCESS==regsvc->
registerIOV(
"AlignableTransform",
1264 ATH_MSG_DEBUG(
"Stored AlignableTransform object " << *iobj );
1267 ATH_MSG_ERROR(
"Failed (registerIOV) to store object " << *iobj );
1271 ATH_MSG_DEBUG(
" Written " << nobj <<
" AlignableTransform objects to conditions database" );
1278 for (std::vector<std::string>::const_iterator iobj=
m_alignobjs.begin();
1285 cit!=
pat->end();++cit) {
1296 "," << ring <<
"," << sector <<
"," <<
side <<
"] Trans:(" <<
1297 shift.x() <<
"," << shift.y() <<
"," << shift.z() <<
") Rot:{"
1298 << alpha <<
"," <<
beta <<
"," <<
gamma <<
"}");
1305 ATH_MSG_DEBUG(
"Object contains " << nobj <<
" transforms" );
1307 ATH_MSG_ERROR(
"AlignableTransform " << *iobj <<
" not found" );
1323 dva!=patc->
end();++dva) {
1324 if ((*dva)->tag()==
key) {
1346 dva!=patc->
end();++dva) {
1347 if ((*dva)->tag()==
key) {
1360 const int nbsct,
const int necsct) {
1372 if (nbpix!=0 || necpix!=0) {
1379 for (
int i=0;
i<necpix;++
i) {
1384 for (
int i=0;
i<nbpix;++
i) {
1389 for (
int i=0;
i<necpix;++
i) {
1394 if (nbsct!=0 || necsct!=0) {
1400 for (
int i=0;
i<necsct;++
i) {
1405 for (
int i=0;
i<nbsct;++
i) {
1410 for (
int i=0;
i<necsct;++
i) {
1428 double& alpha,
double&
beta,
double &
gamma)
const
1430 double siny = trans(0,2);
1438 if ((trans(1,2) == 0) && (trans(2,2) == 0)) {
1442 alpha = atan2(trans(1,1),trans(2,1));
1444 alpha = atan2(-trans(1,2),trans(2,2));
1445 gamma = atan2(-trans(0,1),trans(0,0));
1446 if (alpha == 0) alpha = 0;
1458 if (StatusCode::SUCCESS==
detStore()->
retrieve(atrlistcol1,
"/Indet/IBLDist")) {
1461 if (atrlistcol2!=
nullptr){
1467 if(atrlist2[
"stave"].data<int>()!=stave)
continue;
1469 msg(
MSG::DEBUG) <<
"IBLDist DB -- channel before update: " << citr->first
1470 <<
" ,stave: " << atrlist2[
"stave"].data<
int>()
1471 <<
" ,mag: " << atrlist2[
"mag"].data<float>()
1472 <<
" ,base: " << atrlist2[
"base"].data<
float>() <<
endmsg;
1474 atrlist2[
"mag"].data<
float>() += bowx;
1476 msg(
MSG::DEBUG) <<
"IBLDist DB -- channel after update: " << citr->first
1477 <<
" ,stave: " << atrlist2[
"stave"].data<
int>()
1478 <<
" ,mag: " << atrlist2[
"mag"].data<float>()
1479 <<
" ,base: " << atrlist2[
"base"].data<
float>() <<
endmsg;
1485 ATH_MSG_ERROR(
"tweakIBLDist: cast fails for stave " << stave );
1490 ATH_MSG_ERROR(
"tweakIBLDist: cannot retrieve CondAttrListCollection for key /Indet/IBLDist" );
1509 const unsigned int DBident=
det*10000+2*
bec*1000+
layer*100+ring*10+sector;
1516 if (atrlistcol2!=
nullptr){
1522 if(citr->first!=DBident)
continue;
1524 msg(
MSG::DEBUG) <<
"Tweak Old global DB -- channel: " << citr->first
1525 <<
" ,det: " << atrlist2[
"det"].data<
int>()
1526 <<
" ,bec: " << atrlist2[
"bec"].data<int>()
1527 <<
" ,layer: " << atrlist2[
"layer"].data<
int>()
1528 <<
" ,ring: " << atrlist2[
"ring"].data<int>()
1529 <<
" ,sector: " << atrlist2[
"sector"].data<
int>()
1530 <<
" ,Tx: " << atrlist2[
"Tx"].data<float>()
1531 <<
" ,Ty: " << atrlist2[
"Ty"].data<
float>()
1532 <<
" ,Tz: " << atrlist2[
"Tz"].data<float>()
1533 <<
" ,Rx: " << atrlist2[
"Rx"].data<
float>()
1534 <<
" ,Ry: " << atrlist2[
"Ry"].data<float>()
1535 <<
" ,Rz: " << atrlist2[
"Rz"].data<
float>() <<
endmsg;
1539 Amg::Translation3D oldtranslation(atrlist2[
"Tx"].data<float>(),atrlist2[
"Ty"].data<float>(),atrlist2[
"Tz"].data<float>());
1540 Amg::Transform3D oldtrans = oldtranslation * Amg::RotationMatrix3D::Identity();
1553 atrlist2[
"Tx"].data<
float>() = shift.x();
1554 atrlist2[
"Ty"].data<
float>() = shift.y();
1555 atrlist2[
"Tz"].data<
float>() = shift.z();
1556 atrlist2[
"Rx"].data<
float>() = alpha/
CLHEP::mrad ;
1561 msg(
MSG::DEBUG) <<
"Tweak New global DB -- channel: " << citr->first
1562 <<
" ,det: " << atrlist2[
"det"].data<
int>()
1563 <<
" ,bec: " << atrlist2[
"bec"].data<int>()
1564 <<
" ,layer: " << atrlist2[
"layer"].data<
int>()
1565 <<
" ,ring: " << atrlist2[
"ring"].data<int>()
1566 <<
" ,sector: " << atrlist2[
"sector"].data<
int>()
1567 <<
" ,Tx: " << atrlist2[
"Tx"].data<float>()
1568 <<
" ,Ty: " << atrlist2[
"Ty"].data<
float>()
1569 <<
" ,Tz: " << atrlist2[
"Tz"].data<float>()
1570 <<
" ,Rx: " << atrlist2[
"Rx"].data<
float>()
1571 <<
" ,Ry: " << atrlist2[
"Ry"].data<float>()
1572 <<
" ,Rz: " << atrlist2[
"Rz"].data<
float>() <<
endmsg;
1578 ATH_MSG_ERROR(
"tweakGlobalFolder: cast fails for DBident " << DBident );
1583 ATH_MSG_ERROR(
"tweakGlobalFolder: cannot retrieve CondAttrListCollection for key " <<
key );
def retrieve(aClass, aKey=None)
JetConstituentVector::iterator iterator
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
bool is_pixel(Identifier id) const
const_iterator end() const
Const iterator class for DataVector/DataList.
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
path
python interpreter configuration --------------------------------------—
Scalar phi() const
phi method
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
std::string find(const std::string &s)
return a remapped string
bool is_sct(Identifier id) const
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
A CondMultChanCollection is a template class which can hold a collection of T* objects which are inte...
Scalar theta() const
theta method
bool msgLvl(const MSG::Level lvl) const
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
This is an interface to a tool used to register conditions objects in the Interval of Validity (IOV) ...
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
int phi_module(const Identifier &id) const
#define ATH_MSG_VERBOSE(x)
This class is a collection of AttributeLists where each one is associated with a channel number....
virtual SiDetectorElement * getDetectorElement(const Identifier &id) const override
access to individual elements via Identifier
virtual StatusCode registerIOV(const std::string &typeName) const =0
Register IOV DB for an object given its typeName - run/LB numbers interval or times interval and tag ...
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual const SiDetectorElementCollection * getDetectorElementCollection() const override
access to whole collectiom
virtual const SiDetectorElementCollection * getDetectorElementCollection() const override
access to whole collection via Iterators
(Non-const) Iterator class for DataVector/DataList.
::StatusCode StatusCode
StatusCode definition for legacy code.
Eigen::Affine3d Transform3D
This is an interface to a service used to register conditions objects in the Interval of Validity (IO...
void add(ChanNum chanNum)
Adding in channel numbers.
int layer_disk(const Identifier &id) const
int eta_module(const Identifier &id) const
int layer_disk(const Identifier &id) const
value_type push_back(value_type pElem)
Add an element to the end of the collection.
Eigen::Matrix< double, 3, 1 > Vector3D
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
#define ATH_MSG_WARNING(x)
ChanAttrListMap::const_iterator const_iterator
Amg::Transform3D CLHEPTransformToEigen(const HepGeom::Transform3D &CLHEPtransf)
Converts a CLHEP-based HepGeom::Transform3D into an Eigen Amg::Transform3D.
Eigen::Matrix< double, 3, 3 > RotationMatrix3D
int eta_module(const Identifier &id) const
Eigen::Translation< double, 3 > Translation3D
HepGeom::Transform3D EigenTransformToCLHEP(const Amg::Transform3D &eigenTransf)
Converts an Eigen-based Amg::Transform3D into a CLHEP-based HepGeom::Transform3D.
AlignFolderType m_alignfoldertype
int side(const Identifier &id) const
Eigen::AngleAxisd AngleAxis3D
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module, int side) const
For a single side of module.
int phi_module(const Identifier &id) const
bool add(ChanNum chanNum, const AttributeList &attributeList)
Adding in chan/attrList pairs.
size_type size() const noexcept
Returns the number of elements in the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
virtual SiDetectorElement * getDetectorElement(const Identifier &id) const override
access to individual elements : via Identifier