CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SurveyInputTrackerFromDB.cc
Go to the documentation of this file.
8 
9 // Database
16 
17 
19 
21 textFileName( cfg.getParameter<std::string>("textFileName") )
22 {
23 }
24 
26 {
27  if (theFirstEvent) {
28 
29  // std::cout << "***************ENTERING INITIALIZATION******************" << std::endl;
30 
31  //Get map from textreader
32  SurveyInputTextReader dataReader;
33  dataReader.readFile( textFileName );
34  uIdMap = dataReader.UniqueIdMap();
35 
37  setup.get<IdealGeometryRecord>().get(geom);
39 
40  addComponent( new AlignableTracker( tracker ) );
42 
43  //write out to a DB ...
44  Alignments* myAlignments = detector()->alignments();
45  AlignmentErrors* myAlignmentErrors = detector()->alignmentErrors();
46 
47  // 2. Store alignment[Error]s to DB
49  // Call service
50 
51  if( !poolDbService.isAvailable() ) // Die if not available
52  throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
53 
54  poolDbService->writeOne<Alignments>( myAlignments, poolDbService->beginOfTime(), "TrackerAlignmentRcd" );
55  poolDbService->writeOne<AlignmentErrors>( myAlignmentErrors, poolDbService->beginOfTime(), "TrackerAlignmentErrorRcd" );
56 
57  theFirstEvent = false;
58  }
59 }
60 
62 {
63  const align::Alignables& comp = ali->components();
64  unsigned int nComp = comp.size();
65 
66  for (unsigned int i = 0; i < nComp; ++i) addSurveyInfo(comp[i]);
67 
69 
70  SurveyInputTextReader::MapType::const_iterator it
71  = uIdMap.find(std::make_pair(ali->id(), ali->alignableObjectId()));
72 
73  if (it != uIdMap.end()){
74 
75  const align::Scalars& parameters = (it)->second;
76 
77  //move the surface
78  //displacement
79  align::LocalVector lvector (parameters[0], parameters[1], parameters[2]);
80  align::GlobalVector gvector = ali->surface().toGlobal(lvector);
81  ali->move(gvector);
82  //rotation
83  Basic3DVector<align::Scalar> rot_aa(parameters[3], parameters[4], parameters[5]);
84  align::RotationType rotation(rot_aa, rot_aa.mag());
86 
87  //sets the errors for the hierarchy level
88  double* errorData = error.Array();
89  for (unsigned int i = 0; i < 21; ++i){errorData[i] = parameters[i+6];}
90 
91  ali->setSurvey( new SurveyDet(ali->surface(), error*(1e-6)) );
92  }
93  else {
94  error = ROOT::Math::SMatrixIdentity();
95  ali->setSurvey( new SurveyDet(ali->surface(), error * 1e-6) );
96  }
97 
98 }
99 // Plug in to framework
100 
102 
103 
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:180
int i
Definition: DBlmapReader.cc:9
dictionary parameters
Definition: Parameters.py:2
virtual void rotateInLocalFrame(const RotationType &rotation)
Rotation intepreted in the local reference frame.
Definition: Alignable.cc:91
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
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
static void addComponent(Alignable *)
virtual Alignables components() const =0
Return vector of all direct components.
SurveyInputTrackerFromDB(const edm::ParameterSet &)
U second(std::pair< T, U > const &p)
std::vector< Scalar > Scalars
Definition: Utilities.h:22
bool isAvailable() const
Definition: Service.h:47
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
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:126
void addSurveyInfo(Alignable *)
Add survey info to an alignable.
const MapType & UniqueIdMap() const
void setSurvey(const SurveyDet *)
Set survey info.
Definition: Alignable.cc:268
const T & get() const
Definition: EventSetup.h:55
TrackerGeometry * build(const GeometricDet *gd)
std::vector< Alignable * > Alignables
Definition: Utilities.h:28
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
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
virtual Alignments * alignments() const =0
Return vector of alignment data.
virtual AlignmentErrors * alignmentErrors() const =0
Return vector of alignment errors.