CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SurveyMisalignmentInput.cc
Go to the documentation of this file.
4 
7 
10 
13 
15 
17  textFileName( cfg.getParameter<std::string>("textFileName") )
18 {
19 }
20 
22 {
23  if (theFirstEvent) {
25  setup.get<IdealGeometryRecord>().get(geom);
27  addComponent(new AlignableTracker( tracker ) );
28 
29  edm::LogInfo("SurveyMisalignmentInput") << "Starting!";
30  // Retrieve alignment[Error]s from DBase
31  setup.get<TrackerAlignmentRcd>().get( alignments );
32 
33  //Get map from textreader
34  SurveyInputTextReader dataReader;
35  dataReader.readFile( textFileName );
36  uIdMap = dataReader.UniqueIdMap();
37 
39 
40  theFirstEvent = false;
41  }
42 }
43 
44 
46 {
47 
48  const align::Alignables& comp = ali->components();
49  unsigned int nComp = comp.size();
50  for (unsigned int i = 0; i < nComp; ++i) addSurveyInfo(comp[i]);
51 
52  SurveyInputTextReader::MapType::const_iterator it
53  = uIdMap.find(std::make_pair(ali->id(), ali->alignableObjectId()));
54 
56 
57  if (it != uIdMap.end()){
58  //survey error values
59  const align::Scalars& parameters = (it)->second;
60  //sets the errors for the hierarchy level
61  double* errorData = error.Array();
62  for (unsigned int i = 0; i < 21; ++i){errorData[i] = parameters[i+6];}
63 
64  //because record only needs global value of modules
66  // fill survey values
67  ali->setSurvey( new SurveyDet(getAlignableSurface(ali->id()), error) );
68  }
69  else{
70  ali->setSurvey( new SurveyDet(ali->surface(), error) );
71  }
72  }
73  else{
74  //fill
75  error = ROOT::Math::SMatrixIdentity();
76  ali->setSurvey( new SurveyDet(ali->surface(), error*(1e-6)) );
77  }
78  //std::cout << "UniqueId: " << id.first << ", " << id.second << std::endl;
79  //std::cout << error << std::endl;
80 
81 }
82 
84 {
85  std::vector<AlignTransform>::const_iterator it;
86 
87  for (it = alignments->m_align.begin(); it != alignments->m_align.end(); ++it)
88  {
89  if (id == (*it).rawId())
90  {
91  align::PositionType position( (*it).translation().x(), (*it).translation().y(), (*it).translation().z() );
92  CLHEP::HepRotation rot( (*it).rotation() );
93  align::RotationType rotation( rot.xx(), rot.xy(), rot.xz(),
94  rot.yx(), rot.yy(), rot.yz(),
95  rot.zx(), rot.zy(), rot.zz() );
97  }
98  }
99 
100  return AlignableSurface();
101 }
102 
103 // Plug in to framework
104 
106 
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
void readFile(const std::string &textFileName)
Read given text file.
SurveyMisalignmentInput(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
uint32_t ID
Definition: Definitions.h:26
SurveyInputTextReader::MapType uIdMap
static void addComponent(Alignable *)
virtual Alignables components() const =0
Return vector of all direct components.
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
void addSurveyInfo(Alignable *)
Add survey info to an alignable.
U second(std::pair< T, U > const &p)
edm::ESHandle< Alignments > alignments
std::vector< Scalar > Scalars
Definition: Utilities.h:22
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
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
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
AlignableSurface getAlignableSurface(align::ID)
Get alignable surface from misalignments.db.
math::Error< 6 >::type ErrorMatrix
Definition: Definitions.h:39
virtual void analyze(const edm::Event &, const edm::EventSetup &)
Read ideal tracker geometry from DB.
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")