CMS 3D CMS Logo

SurveyInputTrackerFromDB.cc
Go to the documentation of this file.
11 
12 // Database
19 
20 
22 
24  : textFileName( cfg.getParameter<std::string>("textFileName") )
25 {}
26 
28 {
29 
30  if (theFirstEvent) {
31 
32  // std::cout << "***************ENTERING INITIALIZATION******************" << std::endl;
33 
34  //Retrieve tracker topology from geometry
36  setup.get<TrackerTopologyRcd>().get(tTopoHandle);
37  const TrackerTopology* const tTopo = tTopoHandle.product();
38 
39  //Get map from textreader
40  SurveyInputTextReader dataReader;
41  dataReader.readFile( textFileName );
42  uIdMap = dataReader.UniqueIdMap();
43 
45  setup.get<IdealGeometryRecord>().get(geom);
47  setup.get<PTrackerParametersRcd>().get( ptp );
49 
50  addComponent( new AlignableTracker( tracker, tTopo ) );
52 
53  //write out to a DB ...
54  Alignments* myAlignments = detector()->alignments();
55  AlignmentErrorsExtended* myAlignmentErrorsExtended = detector()->alignmentErrors();
56 
57  // 2. Store alignment[Error]s to DB
59  // Call service
60 
61  if( !poolDbService.isAvailable() ) // Die if not available
62  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
63 
64  poolDbService->writeOne<Alignments>( myAlignments, poolDbService->beginOfTime(), "TrackerAlignmentRcd" );
65  poolDbService->writeOne<AlignmentErrorsExtended>( myAlignmentErrorsExtended, poolDbService->beginOfTime(), "TrackerAlignmentErrorExtendedRcd" );
66 
67  theFirstEvent = false;
68  }
69 }
70 
72 {
73  const align::Alignables& comp = ali->components();
74  unsigned int nComp = comp.size();
75 
76  for (unsigned int i = 0; i < nComp; ++i) addSurveyInfo(comp[i]);
77 
79 
80  SurveyInputTextReader::MapType::const_iterator it
81  = uIdMap.find(std::make_pair(ali->id(), ali->alignableObjectId()));
82 
83  if (it != uIdMap.end()){
84 
85  const align::Scalars& parameters = (it)->second;
86 
87  //move the surface
88  //displacement
89  align::LocalVector lvector (parameters[0], parameters[1], parameters[2]);
90  align::GlobalVector gvector = ali->surface().toGlobal(lvector);
91  ali->move(gvector);
92  //rotation
93  Basic3DVector<align::Scalar> rot_aa(parameters[3], parameters[4], parameters[5]);
94  align::RotationType rotation(rot_aa, rot_aa.mag());
96 
97  //sets the errors for the hierarchy level
98  double* errorData = error.Array();
99  for (unsigned int i = 0; i < 21; ++i){errorData[i] = parameters[i+6];}
100 
101  ali->setSurvey( new SurveyDet(ali->surface(), error*(1e-6)) );
102  }
103  else {
104  error = ROOT::Math::SMatrixIdentity();
105  ali->setSurvey( new SurveyDet(ali->surface(), error * 1e-6) );
106  }
107 
108 }
109 // Plug in to framework
110 
112 
113 
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:189
virtual void rotateInLocalFrame(const RotationType &rotation)
Rotation intepreted in the local reference frame.
Definition: Alignable.cc:139
void readFile(const std::string &textFileName)
Read given text file.
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
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)
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
virtual Alignables components() const =0
Return vector of all direct components.
std::vector< Scalar > Scalars
Definition: Utilities.h:26
bool isAvailable() const
Definition: Service.h:46
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
static Alignable * detector()
Get alignable detector as read from input.
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:135
void addSurveyInfo(Alignable *)
Add survey info to an alignable.
const MapType & UniqueIdMap() const
void setSurvey(const SurveyDet *)
Set survey info.
Definition: Alignable.cc:356
const T & get() const
Definition: EventSetup.h:56
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
virtual Alignments * alignments() const =0
Return vector of alignment data.
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
SurveyInputTextReader::MapType uIdMap
virtual void analyze(const edm::Event &, const edm::EventSetup &)
Read ideal tracker geometry from DB.
math::Error< 6 >::type ErrorMatrix
Definition: Definitions.h:39
T const * product() const
Definition: ESHandle.h:86
virtual AlignmentErrorsExtended * alignmentErrors() const =0
Return vector of alignment errors.