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.
7 
10 
13 
16 
18 
20  textFileName( cfg.getParameter<std::string>("textFileName") )
21 {}
22 
24 {
25  if (theFirstEvent) {
26  //Retrieve tracker topology from geometry
28  setup.get<TrackerTopologyRcd>().get(tTopoHandle);
29  const TrackerTopology* const tTopo = tTopoHandle.product();
30 
32  setup.get<IdealGeometryRecord>().get(geom);
33 
35  setup.get<PTrackerParametersRcd>().get( ptp );
37 
38  addComponent(new AlignableTracker( tracker, tTopo ));
39 
40  edm::LogInfo("SurveyMisalignmentInput") << "Starting!";
41  // Retrieve alignment[Error]s from DBase
42  setup.get<TrackerAlignmentRcd>().get( alignments );
43 
44  //Get map from textreader
45  SurveyInputTextReader dataReader;
46  dataReader.readFile( textFileName );
47  uIdMap = dataReader.UniqueIdMap();
48 
50 
51  theFirstEvent = false;
52  }
53 }
54 
55 
57 {
58 
59  const align::Alignables& comp = ali->components();
60  unsigned int nComp = comp.size();
61  for (unsigned int i = 0; i < nComp; ++i) addSurveyInfo(comp[i]);
62 
63  SurveyInputTextReader::MapType::const_iterator it
64  = uIdMap.find(std::make_pair(ali->id(), ali->alignableObjectId()));
65 
67 
68  if (it != uIdMap.end()){
69  //survey error values
70  const align::Scalars& parameters = (it)->second;
71  //sets the errors for the hierarchy level
72  double* errorData = error.Array();
73  for (unsigned int i = 0; i < 21; ++i){errorData[i] = parameters[i+6];}
74 
75  //because record only needs global value of modules
77  // fill survey values
78  ali->setSurvey( new SurveyDet(getAlignableSurface(ali->id()), error) );
79  }
80  else{
81  ali->setSurvey( new SurveyDet(ali->surface(), error) );
82  }
83  }
84  else{
85  //fill
86  error = ROOT::Math::SMatrixIdentity();
87  ali->setSurvey( new SurveyDet(ali->surface(), error*(1e-6)) );
88  }
89  //std::cout << "UniqueId: " << id.first << ", " << id.second << std::endl;
90  //std::cout << error << std::endl;
91 
92 }
93 
95 {
96  std::vector<AlignTransform>::const_iterator it;
97 
98  for (it = alignments->m_align.begin(); it != alignments->m_align.end(); ++it)
99  {
100  if (id == (*it).rawId())
101  {
102  align::PositionType position( (*it).translation().x(), (*it).translation().y(), (*it).translation().z() );
103  CLHEP::HepRotation rot( (*it).rotation() );
104  align::RotationType rotation( rot.xx(), rot.xy(), rot.xz(),
105  rot.yx(), rot.yy(), rot.yz(),
106  rot.zx(), rot.zy(), rot.zz() );
108  }
109  }
110 
111  return AlignableSurface();
112 }
113 
114 // Plug in to framework
115 
117 
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:185
int i
Definition: DBlmapReader.cc:9
dictionary parameters
Definition: Parameters.py:2
void readFile(const std::string &textFileName)
Read given text file.
tuple cfg
Definition: looper.py:293
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.
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:131
const MapType & UniqueIdMap() const
void setSurvey(const SurveyDet *)
Set survey info.
Definition: Alignable.cc:306
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
std::vector< Alignable * > Alignables
Definition: Utilities.h:28
TrackerGeometry * build(const GeometricDet *gd, const PTrackerParameters &ptp)
AlignableSurface getAlignableSurface(align::ID)
Get alignable surface from misalignments.db.
static int position[264][3]
Definition: ReadPGInfo.cc:509
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="")