CMS 3D CMS Logo

SurveyInputTrackerFromDB.cc
Go to the documentation of this file.
12 
13 // Database
20 
22 
24  : tTopoToken_(esConsumes()),
25  geomDetToken_(esConsumes()),
26  ptpToken_(esConsumes()),
27  textFileName(cfg.getParameter<std::string>("textFileName")) {}
28 
30  if (theFirstEvent) {
31  // std::cout << "***************ENTERING INITIALIZATION******************" << std::endl;
32 
33  //Retrieve tracker topology from geometry
34  const TrackerTopology* const tTopo = &setup.getData(tTopoToken_);
35 
36  //Get map from textreader
37  SurveyInputTextReader dataReader;
38  dataReader.readFile(textFileName);
39  uIdMap = dataReader.UniqueIdMap();
40 
41  const GeometricDet* geom = &setup.getData(geomDetToken_);
42  const PTrackerParameters& ptp = setup.getData(ptpToken_);
44 
47 
48  //write out to a DB ...
49  Alignments* myAlignments = detector()->alignments();
50  AlignmentErrorsExtended* myAlignmentErrorsExtended = detector()->alignmentErrors();
51 
52  // 2. Store alignment[Error]s to DB
54  // Call service
55 
56  if (!poolDbService.isAvailable()) // Die if not available
57  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
58 
59  poolDbService->writeOneIOV<Alignments>(*myAlignments, poolDbService->beginOfTime(), "TrackerAlignmentRcd");
60  poolDbService->writeOneIOV<AlignmentErrorsExtended>(
61  *myAlignmentErrorsExtended, poolDbService->beginOfTime(), "TrackerAlignmentErrorExtendedRcd");
62 
63  theFirstEvent = false;
64  }
65 }
66 
68  const align::Alignables& comp = ali->components();
69  unsigned int nComp = comp.size();
70 
71  for (unsigned int i = 0; i < nComp; ++i)
73 
75 
76  SurveyInputTextReader::MapType::const_iterator it = uIdMap.find(std::make_pair(ali->id(), ali->alignableObjectId()));
77 
78  if (it != uIdMap.end()) {
79  const align::Scalars& parameters = (it)->second;
80 
81  //move the surface
82  //displacement
84  align::GlobalVector gvector = ali->surface().toGlobal(lvector);
85  ali->move(gvector);
86  //rotation
88  align::RotationType rotation(rot_aa, rot_aa.mag());
90 
91  //sets the errors for the hierarchy level
92  double* errorData = error.Array();
93  for (unsigned int i = 0; i < 21; ++i) {
94  errorData[i] = parameters[i + 6];
95  }
96 
97  ali->setSurvey(new SurveyDet(ali->surface(), error * (1e-6)));
98  } else {
99  error = ROOT::Math::SMatrixIdentity();
100  ali->setSurvey(new SurveyDet(ali->surface(), error * 1e-6));
101  }
102 }
103 // Plug in to framework
104 
106 
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
virtual void rotateInLocalFrame(const RotationType &rotation)
Rotation intepreted in the local reference frame.
Definition: Alignable.cc:129
void readFile(const std::string &textFileName)
Read given text file.
virtual AlignmentErrorsExtended * alignmentErrors() const =0
Return vector of alignment errors.
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:132
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
TrackerGeometry * build(const GeometricDet *gd, const PTrackerParameters &ptp, const TrackerTopology *tTopo)
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
static void addComponent(Alignable *)
SurveyInputTrackerFromDB(const edm::ParameterSet &)
U second(std::pair< T, U > const &p)
std::vector< Scalar > Scalars
Definition: Utilities.h:26
const edm::ESGetToken< GeometricDet, IdealGeometryRecord > geomDetToken_
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const edm::ESGetToken< PTrackerParameters, PTrackerParametersRcd > ptpToken_
static Alignable * detector()
Get alignable detector as read from input.
virtual const Alignables & components() const =0
Return vector of all direct components.
void addSurveyInfo(Alignable *)
Add survey info to an alignable.
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:180
void setSurvey(const SurveyDet *)
Set survey info.
Definition: Alignable.cc:266
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
SurveyInputTextReader::MapType uIdMap
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
bool isAvailable() const
Definition: Service.h:40
math::Error< 6 >::type ErrorMatrix
Definition: Definitions.h:37
void analyze(const edm::Event &, const edm::EventSetup &) override
Read ideal tracker geometry from DB.
const MapType & UniqueIdMap() const
virtual Alignments * alignments() const =0
Return vector of alignment data.