CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SurveyInputTrackerFromDB.cc
Go to the documentation of this file.
12 
13 // Database
20 
22 
25  geomDetToken_(esConsumes()),
26  ptpToken_(esConsumes()),
27  ptitpToken_(esConsumes()),
28  textFileName(cfg.getParameter<std::string>("textFileName")) {}
29 
31  if (theFirstEvent) {
32  // std::cout << "***************ENTERING INITIALIZATION******************" << std::endl;
33 
34  //Retrieve tracker topology from geometry
35  const TrackerTopology* const tTopo = &setup.getData(tTopoToken_);
36 
37  //Get map from textreader
38  SurveyInputTextReader dataReader;
39  dataReader.readFile(textFileName);
40  uIdMap = dataReader.UniqueIdMap();
41 
42  const GeometricDet* geom = &setup.getData(geomDetToken_);
43  const PTrackerParameters& ptp = setup.getData(ptpToken_);
45  TrackerGeometry* tracker = TrackerGeomBuilderFromGeometricDet().build(geom, ptitp, ptp, tTopo);
46 
47  addComponent(new AlignableTracker(tracker, tTopo));
49 
50  //write out to a DB ...
51  Alignments* myAlignments = detector()->alignments();
52  AlignmentErrorsExtended* myAlignmentErrorsExtended = detector()->alignmentErrors();
53 
54  // 2. Store alignment[Error]s to DB
56  // Call service
57 
58  if (!poolDbService.isAvailable()) // Die if not available
59  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
60 
61  poolDbService->writeOneIOV<Alignments>(*myAlignments, poolDbService->beginOfTime(), "TrackerAlignmentRcd");
62  poolDbService->writeOneIOV<AlignmentErrorsExtended>(
63  *myAlignmentErrorsExtended, poolDbService->beginOfTime(), "TrackerAlignmentErrorExtendedRcd");
64 
65  theFirstEvent = false;
66  }
67 }
68 
70  const align::Alignables& comp = ali->components();
71  unsigned int nComp = comp.size();
72 
73  for (unsigned int i = 0; i < nComp; ++i)
74  addSurveyInfo(comp[i]);
75 
77 
78  SurveyInputTextReader::MapType::const_iterator it = uIdMap.find(std::make_pair(ali->id(), ali->alignableObjectId()));
79 
80  if (it != uIdMap.end()) {
81  const align::Scalars& parameters = (it)->second;
82 
83  //move the surface
84  //displacement
85  align::LocalVector lvector(parameters[0], parameters[1], parameters[2]);
86  align::GlobalVector gvector = ali->surface().toGlobal(lvector);
87  ali->move(gvector);
88  //rotation
89  Basic3DVector<align::Scalar> rot_aa(parameters[3], parameters[4], parameters[5]);
90  align::RotationType rotation(rot_aa, rot_aa.mag());
92 
93  //sets the errors for the hierarchy level
94  double* errorData = error.Array();
95  for (unsigned int i = 0; i < 21; ++i) {
96  errorData[i] = parameters[i + 6];
97  }
98 
99  ali->setSurvey(new SurveyDet(ali->surface(), error * (1e-6)));
100  } else {
101  error = ROOT::Math::SMatrixIdentity();
102  ali->setSurvey(new SurveyDet(ali->surface(), error * 1e-6));
103  }
104 }
105 // Plug in to framework
106 
108 
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:180
const edm::ESGetToken< PTrackerAdditionalParametersPerDet, PTrackerAdditionalParametersPerDetRcd > ptitpToken_
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.
tuple cfg
Definition: looper.py:296
virtual AlignmentErrorsExtended * alignmentErrors() const =0
Return vector of alignment errors.
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
TrackerGeometry * build(const GeometricDet *gd, const PTrackerAdditionalParametersPerDet *ptitp, 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 &)
bool getData(T &iHolder) const
Definition: EventSetup.h:128
U second(std::pair< T, U > const &p)
std::vector< Scalar > Scalars
Definition: Utilities.h:26
bool isAvailable() const
Definition: Service.h:40
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)
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.
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:132
void addSurveyInfo(Alignable *)
Add survey info to an alignable.
const MapType & UniqueIdMap() const
void setSurvey(const SurveyDet *)
Set survey info.
Definition: Alignable.cc:266
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
SurveyInputTextReader::MapType uIdMap
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
math::Error< 6 >::type ErrorMatrix
Definition: Definitions.h:37
void analyze(const edm::Event &, const edm::EventSetup &) override
Read ideal tracker geometry from DB.
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
tTopoToken_
virtual Alignments * alignments() const =0
Return vector of alignment data.