Skip to content

Commit

Permalink
TO BE REVERTED: test environment to be able to debug and run COCOA
Browse files Browse the repository at this point in the history
  • Loading branch information
ghugo83 committed Jun 22, 2020
1 parent 0456dd2 commit e1c64b5
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 10 deletions.
24 changes: 18 additions & 6 deletions Alignment/CocoaApplication/src/CocoaAnalyzer.cc
Expand Up @@ -9,6 +9,7 @@
#include "CondFormats/DataRecord/interface/OpticalAlignmentsRcd.h"
#include "DetectorDescription/Core/interface/DDFilteredView.h"
#include "DetectorDescription/Core/interface/DDCompactView.h"
#include "DD4hep/DetFactoryHelper.h"
#include "Geometry/Records/interface/IdealGeometryRecord.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
Expand Down Expand Up @@ -130,13 +131,17 @@ void CocoaAnalyzer::ReadXMLFile( const edm::EventSetup& evts )
// At each node we get specpars as variables and use them in
// constructing COCOA objects.
// It stores these objects in a private data member, opt
std::string attribute = "COCOA";
std::string value = "COCOA";
//std::string attribute = "COCOA";
//std::string value = "COCOA";
std::string attribute = "ReadOutName";
//std::string value = "MuonCSCHits";
std::string value = "TrackerHitsPixelBarrel";

// get all parts labelled with COCOA using a SpecPar
DDSpecificsMatchesValueFilter filter{DDValue(attribute, value, 0.0)};
DDFilteredView fv(*cpv, filter);
bool doCOCOA = fv.firstChild();
std::cout << "doCOCOA = " << doCOCOA << std::endl;

// Loop on parts
int nObjects=0;
Expand Down Expand Up @@ -172,20 +177,26 @@ void CocoaAnalyzer::ReadXMLFile( const edm::EventSetup& evts )
if(ALIUtils::debug >= 5) {
std::cout << " @@ Name built= " << oaInfo.name_ << " short_name= " << name << " parent= " << oaInfo.parentName_ << std::endl;
}

//----- Read centre and angles
oaInfo.x_.quality_ = int (myFetchDbl(params, "centre_X_quality", 0));
DDTranslation transl = (fv.translation());
DDRotationMatrix rot = (fv.rotation());
std::cout << "child transl = " << transl << std::endl;
std::cout << "child rot = " << rot << std::endl;

DDExpandedNode parent = fv.geoHistory()[ fv.geoHistory().size()-2 ];
const DDTranslation& parentTransl = parent.absTranslation();
const DDRotationMatrix& parentRot = parent.absRotation();
std::cout << "parent transl = " << parentTransl << std::endl;
std::cout << "parent rot = " << parentRot << std::endl;

transl = parentRot.Inverse()*(transl - parentTransl );
rot = parentRot.Inverse()*rot;
rot = rot.Inverse(); //DDL uses opposite convention than COCOA
/* if(ALIUtils::debug >= 4) {
ALIUtils::dumprm( rot, "local rotation ");
ALIUtils::dump3v( transl, "local translation");
} */
std::cout << "transl = " << transl << std::endl;
std::cout << "rot = " << rot << std::endl;


oaInfo.x_.name_ = "X";
oaInfo.x_.dim_type_ = "centre";
Expand All @@ -211,6 +222,7 @@ void CocoaAnalyzer::ReadXMLFile( const edm::EventSetup& evts )
rot.GetComponents (xx, xy, xz,
yx, yy, yz,
zx, zy, zz);
std::cout << "xx,xy,xz,yx,yy,yz,zx,zy,zz = " << xx << xy << xz << yx << yy << yz << zx << zy << zz << std::endl;
CLHEP::Hep3Vector colX(xx,xy,xz);
CLHEP::Hep3Vector colY(yx,yy,yz);
CLHEP::Hep3Vector colZ(zx,zy,zz);
Expand Down
69 changes: 69 additions & 0 deletions Alignment/CocoaApplication/test/test_CocoaAnalyzer_cfg.py
@@ -0,0 +1,69 @@
import FWCore.ParameterSet.Config as cms

process = cms.Process("Demo")

process.load("FWCore.MessageService.MessageLogger_cfi")

# Ideal geometry
#process.load('Geometry.CMSCommonData.cmsIdealGeometry2015XML_cfi')
process.load("Geometry.CMSCommonData.cmsExtendedGeometry2026D51XML_cfi")

process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) )

#process.source = cms.Source("PoolSource",
#fileNames = cms.untracked.vstring(
#'file:/afs/cern.ch/cms/Tutorials/TWIKI_DATA/TTJets_8TeV_53X.root'
#'file:/eos/cms/store/relval/CMSSW_10_6_1_patch1/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_106X_mcRun3_2021_realistic_v3-v1/10000/43AFE2E2-5D53-3440-9937-1E7EECBF7029.root'
#'file:/home/ghugo/CMSSW/CMSSW_11_2_0_pre1/src/Alignment/CocoaApplication/test/cocoaDaqTest.root'
#'file:/eos/cms/store/relval/CMSSW_11_2_0_pre1/RelValNuGun/GEN-SIM/110X_mcRun4_realistic_v3_2026D49noPU-v1/10000/F3227D3F-965E-9B42-9D7B-D80CB5B01FBE.root'
#)
#)
process.source = cms.Source("EmptySource")


#process.load("CondCore.DBCommon.CondDBSetup_cfi")
#process.PoolDBESSourceGeometry = cms.ESSource("PoolDBESSource",
#process.CondDBSetup,
#timetype = cms.string('runnumber'),
#toGet = cms.VPSet(
#cms.PSet(record = cms.string('IdealGeometryRecord'),tag = cms.string('TKRECO_Geometry_TagXX')),
#),
#connect = cms.string('sqlite_file:OpticalAlignments.db')
#)

#process.load("CondCore.CondDB.CondDB_cfi")
#process.CondDB.connect = 'sqlite_file:/home/ghugo/CMSSW/CMSSW_11_2_0_pre1/src/Alignment/CocoaApplication/test/OpticalAlignments.db'
#process.PoolDBESSource = cms.ESSource("PoolDBESSource",
# process.CondDB,
# DumpStat=cms.untracked.bool(True),
# toGet = cms.VPSet(cms.PSet(
# record = cms.string('IdealGeometryRecord'),
# tag = cms.string("hey")
# )),
#)


# Reading from DB
#process.load("CondCore.DBCommon.CondDBSetup_cfi")

#process.PoolDBESSource = cms.ESSource("PoolDBESSource",
# process.CondDBSetup,
# toGet = cms.VPSet(
# cms.PSet(
# record = cms.string('OpticalAlignmentsRcd'),
# tag = cms.string('caca')
# )),
# connect = cms.string('sqlite_file:/home/ghugo/CMSSW/CMSSW_11_2_0_pre1/src/Alignment/CocoaApplication/test/OpticalAlignments.db')
#)





process.demo = cms.EDAnalyzer('CocoaAnalyzer',
maxEvents = cms.int32(1),
cocoaDaqRootFile = cms.string("cocoaDaqTest.root")
)

process.p = cms.Path(process.demo)

3 changes: 2 additions & 1 deletion Alignment/CocoaUtilities/src/ALIUtils.cc
Expand Up @@ -12,7 +12,8 @@
#include <cstdlib>
#include <iomanip>

ALIint ALIUtils::debug = -1;
//ALIint ALIUtils::debug = -1;
ALIint ALIUtils::debug = 6;
ALIint ALIUtils::report = 1;
ALIdouble ALIUtils::_LengthValueDimensionFactor = 1.;
ALIdouble ALIUtils::_LengthSigmaDimensionFactor = 1.;
Expand Down
4 changes: 2 additions & 2 deletions Alignment/CocoaUtilities/src/GlobalOptionMgr.cc
Expand Up @@ -79,9 +79,9 @@ void GlobalOptionMgr::setDefaultGlobalOptions() {

theGlobalOptions[ALIstring("stopAfter1stIteration")] = 0;
theGlobalOptions[ALIstring("calParamInyfMatrix")] = 0;
theGlobalOptions[ALIstring("writeXML")] = 0;
theGlobalOptions[ALIstring("writeXML")] = 1;
theGlobalOptions[ALIstring("dumpInAllFrames")] = 0;
theGlobalOptions[ALIstring("rootResults")] = 0;
theGlobalOptions[ALIstring("rootResults")] = 1;
theGlobalOptions[ALIstring("writeDBAlign")] = 0;
theGlobalOptions[ALIstring("writeDBOptAlign")] = 0;
}
Expand Down
Expand Up @@ -43,7 +43,7 @@
)

process.DDDetectorESProducer = cms.ESSource("DDDetectorESProducer",
confGeomXMLFiles = cms.FileInPath('DetectorDescription/DDCMS/data/cms-tracker-2021.xml'),
confGeomXMLFiles = cms.FileInPath('Geometry/TrackerCommonData/data/dd4hep/cms-tracker-geometry-2021.xml'),
appendToDataLabel = cms.string('CMS')
)

Expand Down
Expand Up @@ -2767,6 +2767,7 @@ note: see OT616_IT615_2019_11_28.cfg for full config files
</CompositeMaterial>
</MaterialSection>
<RotationSection label="pixel.xml">
<Rotation name="TEST" thetaX="90*deg" phiX="90*deg" thetaY="90*deg" phiY="180*deg" thetaZ="0*deg" phiZ="0*deg"/>
<Rotation name="INNERTRACKERRODTOFLIPPEDMODULE" thetaX="90*deg" phiX="90*deg" thetaY="180*deg" phiY="0*deg" thetaZ="90*deg" phiZ="180*deg"/>
<Rotation name="INNERTRACKERRODTOMODULE" thetaX="90*deg" phiX="270*deg" thetaY="180*deg" phiY="0*deg" thetaZ="90*deg" phiZ="0*deg"/>
<Rotation name="Y180" thetaX="90*deg" phiX="180*deg" thetaY="90*deg" phiY="90*deg" thetaZ="180*deg" phiZ="0*deg"/>
Expand Down Expand Up @@ -7466,6 +7467,8 @@ note: see OT616_IT615_2019_11_28.cfg for full config files
<PosPart copyNumber="1">
<rParent name="pixel:BModule1Layer1InnerPixelwafer"/>
<rChild name="pixel:BModule1Layer1InnerPixelActive"/>
<rRotation name="pixel:TEST"/>
<Translation x="1*mm" y="2*mm" z="3*mm"/>
</PosPart>
<PosPart copyNumber="1">
<rParent name="pixel:BModule1Layer1"/>
Expand Down

0 comments on commit e1c64b5

Please sign in to comment.