CMS 3D CMS Logo

AlignmentParametersIORoot.cc
Go to the documentation of this file.
1 // this class's header
3 
7 
9 
10 #include "TTree.h"
11 
12 // ----------------------------------------------------------------------------
13 // constructor
15  treename = "AlignmentParameters";
16  treetxt = "Alignment Parameters";
17 }
18 
19 // ----------------------------------------------------------------------------
21  tree->Branch("parSize", &theCovRang, "CovRang/I");
22  tree->Branch("Id", &theId, "Id/i");
23  tree->Branch("paramType", &theParamType, "paramType/I");
24  tree->Branch("Par", &thePar, "Par[CovRang]/D");
25  tree->Branch("covarSize", &theCovarRang, "CovarRang/I");
26  tree->Branch("Cov", &theCov, "Cov[CovarRang]/D");
27  tree->Branch("ObjId", &theObjId, "ObjId/I");
28  tree->Branch("HieraLevel", &theHieraLevel, "HieraLevel/I");
29 }
30 
31 // ----------------------------------------------------------------------------
33  tree->SetBranchAddress("parSize", &theCovRang);
34  tree->SetBranchAddress("covarSize", &theCovarRang);
35  tree->SetBranchAddress("Id", &theId);
36  tree->SetBranchAddress("Par", &thePar);
37  tree->SetBranchAddress("paramType", &theParamType);
38  tree->SetBranchAddress("Cov", &theCov);
39  tree->SetBranchAddress("ObjId", &theObjId);
40  tree->SetBranchAddress("HieraLevel", &theHieraLevel);
41 }
42 
43 // ----------------------------------------------------------------------------
45  const AlignmentParameters* ap = ali->alignmentParameters();
46  const AlgebraicVector& params = ap->parameters();
47  const AlgebraicSymMatrix& cov = ap->covariance();
48 
49  theCovRang = params.num_row();
50  theCovarRang = theCovRang * (theCovRang + 1) / 2;
51  int count = 0;
52  for (int row = 0; row < theCovRang; row++) {
53  thePar[row] = params[row];
54  for (int col = 0; col < theCovRang; col++) {
55  if (row - 1 < col) {
56  theCov[count] = cov[row][col];
57  count++;
58  }
59  }
60  }
61 
62  theId = ali->id();
63  theParamType = ap->type();
64  theObjId = ali->alignableObjectId();
66 
67  tree->Fill();
68  return 0;
69 }
70 
71 // ----------------------------------------------------------------------------
73  if (tree->GetEntryWithIndex(ali->id(), ali->alignableObjectId()) > 0) {
74  int covsize = theCovRang;
75  int count = 0;
76  AlgebraicVector par(covsize, 0);
77  AlgebraicSymMatrix cov(covsize, 0);
78  for (int row = 0; row < covsize; row++) {
79  par[row] = thePar[row];
80  for (int col = 0; col < covsize; col++) {
81  if (row - 1 < col) {
82  cov[row][col] = theCov[count];
83  count++;
84  }
85  }
86  }
87 
88  using namespace AlignmentParametersFactory;
90  AlignmentParameters* alipar1;
91  if (ali->alignmentParameters()) {
92  const std::vector<bool>& sel = ali->alignmentParameters()->selector();
93  alipar1 = createParameters(ali, parType, sel);
94  } else {
95  const std::vector<bool> sel(theCovRang, true);
96  alipar1 = createParameters(ali, parType, sel);
97  }
98  AlignmentParameters* alipar = alipar1->clone(par, cov);
99  alipar->setValid(true);
100  ierr = 0;
101  delete alipar1;
102  return alipar;
103  }
104 
105  ierr = -1;
106  return (nullptr);
107 }
108 
110  if (bWrite) {
111  int nIndices = tree->BuildIndex("Id", "ObjId");
112  edm::LogInfo("Alignment") << "@SUB=AlignmentParametersIORoot::setBranchAddresses"
113  << "number of indexed entries: " << nIndices;
114  }
115 
116  return closeRoot();
117 }
AlignmentIORootBase::closeRoot
int closeRoot(void)
close IO
Definition: AlignmentIORootBase.cc:92
AlignmentParametersFactory::createParameters
AlignmentParameters * createParameters(Alignable *ali, ParametersType parType, const std::vector< bool > &sel)
Definition: AlignmentParametersFactory.cc:83
AlignmentParametersIORoot::readOne
AlignmentParameters * readOne(Alignable *ali, int &ierr) override
Read AlignmentParameters of one Alignable.
Definition: AlignmentParametersIORoot.cc:72
AlignmentParametersFactory.h
AlignmentParametersIORoot::close
int close(void) override
Close IO.
Definition: AlignmentParametersIORoot.cc:109
MessageLogger.h
AlignmentParametersIORoot::AlignmentParametersIORoot
AlignmentParametersIORoot()
Constructor.
Definition: AlignmentParametersIORoot.cc:14
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
AlignmentParametersFactory::ParametersType
ParametersType
enums for all available AlignmentParameters
Definition: AlignmentParametersFactory.h:21
tree
Definition: tree.py:1
Alignable
Definition: Alignable.h:27
cuy.col
col
Definition: cuy.py:1009
AlignmentParametersFactory
AlignmentParametersIORoot::theId
align::ID theId
Definition: AlignmentParametersIORoot.h:51
AlignmentIORootBase::treename
TString treename
Definition: AlignmentIORootBase.h:39
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
AlignmentParameters
Definition: AlignmentParameters.h:35
AlignmentIORootBase::treetxt
TString treetxt
Definition: AlignmentIORootBase.h:40
AlignmentParameters.h
AlignmentParameters::type
virtual int type() const =0
tell type (AlignmentParametersFactory::ParametersType - but no circular dependency)
AlgebraicVector
CLHEP::HepVector AlgebraicVector
Definition: AlgebraicObjects.h:13
Alignable::alignableObjectId
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
AlignmentParametersIORoot::theHieraLevel
int theHieraLevel
Definition: AlignmentParametersIORoot.h:50
AlignmentParametersIORoot::theCovarRang
int theCovarRang
Definition: AlignmentParametersIORoot.h:50
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
AlignmentIORootBase::bWrite
bool bWrite
Definition: AlignmentIORootBase.h:41
AlignmentParametersIORoot::setBranchAddresses
void setBranchAddresses(void) override
Set branch adresses.
Definition: AlignmentParametersIORoot.cc:32
AlignmentParametersIORoot::theCovRang
int theCovRang
Definition: AlignmentParametersIORoot.h:50
AlignmentParametersIORoot::writeOne
int writeOne(Alignable *ali) override
Write AlignmentParameters of one Alignable.
Definition: AlignmentParametersIORoot.cc:44
AlignmentParametersIORoot::thePar
double thePar[nParMax]
Definition: AlignmentParametersIORoot.h:54
Alignable::id
align::ID id() const
Return the ID of Alignable, i.e. DetId of 'first' component GeomDet(Unit).
Definition: Alignable.h:180
AlignmentParametersIORoot.h
AlignmentParameters::clone
virtual AlignmentParameters * clone(const AlgebraicVector &par, const AlgebraicSymMatrix &cov) const =0
Enforce clone methods in derived classes.
AlgebraicSymMatrix
CLHEP::HepSymMatrix AlgebraicSymMatrix
Definition: AlgebraicObjects.h:15
AlignmentParameters::covariance
const AlgebraicSymMatrix & covariance(void) const
Get parameter covariance matrix.
Definition: AlignmentParameters.cc:67
AlignmentParameters::setValid
void setValid(bool v)
Set validity flag.
Definition: AlignmentParameters.cc:137
Alignable.h
AlignmentParameters::selector
const std::vector< bool > & selector(void) const
Get alignment parameter selector vector.
Definition: AlignmentParameters.cc:48
EgammaValidation_Wenu_cff.sel
sel
Definition: EgammaValidation_Wenu_cff.py:33
AlignmentParametersIORoot::theCov
double theCov[nParMax *(nParMax+1)/2]
Definition: AlignmentParametersIORoot.h:54
AlignmentParameters::parameters
const AlgebraicVector & parameters(void) const
Get alignment parameters.
Definition: AlignmentParameters.cc:64
AlignmentParametersIORoot::theParamType
int theParamType
Definition: AlignmentParametersIORoot.h:50
AlignmentParametersIORoot::theObjId
align::StructureType theObjId
Definition: AlignmentParametersIORoot.h:52
Alignable::alignmentParameters
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:58
AlignmentParametersFactory::parametersType
ParametersType parametersType(const std::string &typeString)
convert string to ParametersType - exception if not known
Definition: AlignmentParametersFactory.cc:22
AlignmentParametersIORoot::createBranches
void createBranches(void) override
Create all branches and give names.
Definition: AlignmentParametersIORoot.cc:20
AlignmentParameters::hierarchyLevel
virtual unsigned int hierarchyLevel() const
Definition: AlignmentParameters.cc:107