ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/CMSSW/Alignment/CommonAlignmentAlgorithm/src/AlignableDataIORoot.cc
Revision: 1.4
Committed: Mon Mar 12 21:39:04 2007 UTC (18 years, 1 month ago) by cklae
Content type: text/plain
Branch: MAIN
CVS Tags: CMSSW_1_6_12, CMSSW_1_6_12_pre2, CMSSW_1_6_12_pre1, CMSSW_1_6_11, CMSSW_1_7_7, CMSSW_1_6_11_pre1, CMSSW_1_7_6, CMSSW_1_6_10, CMSSW_1_6_10_pre2, CMSSW_1_6_10_pre1, CMSSW_1_6_9, CMSSW_1_6_9_pre2, CMSSW_1_6_9_pre1, CMSSW_1_7_5, CMSSW_1_7_4, CMSSW_1_7_3, CMSSW_1_6_8, CMSSW_1_6_8_pre2, CMSSW_1_7_2, CMSSW_1_6_8_pre1, CMSSW_1_7_1, CMSSW_1_7_0, CMSSW_1_7_0_pre13, CMSSW_1_4_10, CMSSW_1_7_0_pre12, CMSSW_1_7_0_pre11, CMSSW_1_7_0_pre10, CMSSW_1_7_0_pre9, CMSSW_1_7_0_pre8, CMSSW_1_7_0_pre7, CMSSW_1_4_9, CMSSW_1_4_8, CMSSW_1_6_7, CMSSW_1_7_0_pre6, CMSSW_1_6_6, CMSSW_1_6_5, CMSSW_1_6_5_pre1, CMSSW_1_6_4, CMSSW_1_7_0_pre5, CMSSW_1_6_3, CMSSW_1_6_1, CMSSW_1_7_0_pre4, V01-04-00-08, CMSSW_1_7_0_pre3, CMSSW_1_7_0_pre2, CMSSW_1_6_0, CMSSW_1_6_0_pre14, CMSSW_1_7_0_pre1, CMSSW_1_6_0_DAQ3, CMSSW_1_6_0_pre13, CMSSW_1_6_0_pre12, CMSSW_1_6_0_pre11, CMSSW_1_6_0_pre10, CMSSW_1_4_7, CMSSW_1_6_0_pre9, CMSSW_1_6_0_pre8, CMSSW_1_5_4, CMSSW_1_6_0_pre7, CMSSW_1_5_3, CMSSW_1_6_0_pre6, CMSSW_1_4_6, CMSSW_1_6_0_DAQ1, CMSSW_1_6_0_pre5, V01-04-00-07, V01-09-00, V01-04-00-06, CMSSW_1_6_0_pre4, CMSSW_1_5_2, CMSSW_1_6_0_pre3, CMSSW_1_6_0_pre2, CMSSW_1_6_0_pre1, CMSSW_1_5_1, CMSSW_1_4_5, CMSSW_1_5_0, V01-08-01, V01-04-00-05, CMSSW_1_4_3g483, CMSSW_1_4_4, CMSSW_1_5_0_pre6, CMSSW_1_4_3, V01-04-00-03, V01-08-00, CMSSW_1_5_0_pre5, CMSSW_1_4_2, CMSSW_1_4_1, CMSSW_1_5_0_pre4, V01-07-04, CMSSW_1_5_0_pre3, V01-07-03, V01-07-02, CMSSW_1_4_0_DAQ1, V01-06-01, V01-07-01, V01-04-00-02, CMSSW_1_4_0, CMSSW_1_5_0_pre2, CMSSW_1_4_0_pre7, CMSSW_1_4_0_pre6, CMSSW_1_4_0_pre5, V01-07-00, V01-04-00-01, CMSSW_1_5_0_pre1, CMSSW_1_4_0_pre4, V01-06-00, V01-05-00, V01-04-01, CMSSW_1_4_0_pre3, V01-04-00, V01-03-01, V01-03-00, cklae_20070314
Branch point for: V01-04-00-04
Changes since 1.3: +0 -1 lines
Log Message:
Remove AlignmentTransformations and use align namespace.

File Contents

# User Rev Content
1 fronga 1.1 #include "FWCore/MessageLogger/interface/MessageLogger.h"
2    
3     #include "Alignment/TrackerAlignment/interface/TrackerAlignableId.h"
4    
5     #include "Alignment/CommonAlignmentAlgorithm/interface/AlignableDataIORoot.h"
6    
7     // ----------------------------------------------------------------------------
8     // constructor
9     AlignableDataIORoot::AlignableDataIORoot(PosType p) :
10     AlignableDataIO(p)
11     {
12     if (thePosType == Abs) {
13     treename = "AlignablesAbsPos";
14     treetxt = "Alignables abs.Pos";
15     }
16     else if (thePosType == Org) {
17     treename = "AlignablesOrgPos";
18     treetxt = "Alignables org.Pos";
19     }
20     else if (thePosType == Rel) {
21     treename = "AlignablesRelPos";
22     treetxt = "Alignables rel.Pos";
23     }
24     }
25    
26     // ----------------------------------------------------------------------------
27     // create root tree branches (for writing)
28    
29     void AlignableDataIORoot::createBranches(void)
30     {
31     tree->Branch("Id", &Id, "Id/I");
32     tree->Branch("ObjId", &ObjId, "ObjId/I");
33     tree->Branch("Pos", &Pos, "Pos[3]/D");
34     tree->Branch("Rot", &Rot, "Rot[9]/D");
35     }
36    
37     // ----------------------------------------------------------------------------
38     // set root tree branch addresses (for reading)
39    
40     void AlignableDataIORoot::setBranchAddresses(void)
41     {
42     tree->SetBranchAddress("Id", &Id);
43     tree->SetBranchAddress("ObjId", &ObjId);
44     tree->SetBranchAddress("Pos", &Pos);
45     tree->SetBranchAddress("Rot", &Rot);
46     }
47    
48     // ----------------------------------------------------------------------------
49     // find root tree entry based on IDs
50    
51     int AlignableDataIORoot::findEntry(unsigned int detId,int comp)
52     {
53     if (newopen) { // we're here first time
54 flucke 1.2 edm::LogInfo("Alignment") << "@SUB=AlignableDataIORoot::findEntry"
55     << "Filling map ...";
56 fronga 1.1 treemap.erase(treemap.begin(),treemap.end());
57     for (int ev = 0;ev<tree->GetEntries();ev++) {
58     tree->GetEntry(ev);
59     treemap[ std::make_pair(Id,ObjId) ] = ev;
60     }
61     newopen=false;
62     }
63    
64     // now we have filled the map
65     treemaptype::iterator imap = treemap.find( std::make_pair(detId,comp) );
66     int result=-1;
67     if (imap != treemap.end()) result=(*imap).second;
68     return result;
69    
70     }
71    
72     // ----------------------------------------------------------------------------
73 flucke 1.3 int AlignableDataIORoot::writeAbsRaw(const AlignableAbsData &ad)
74 fronga 1.1 {
75     GlobalPoint pos = ad.pos();
76     Surface::RotationType rot = ad.rot();
77     Id = ad.id();
78     ObjId = ad.objId();
79     Pos[0]=pos.x(); Pos[1]=pos.y(); Pos[2]=pos.z();
80     Rot[0]=rot.xx(); Rot[1]=rot.xy(); Rot[2]=rot.xz();
81     Rot[3]=rot.yx(); Rot[4]=rot.yy(); Rot[5]=rot.yz();
82     Rot[6]=rot.zx(); Rot[7]=rot.zy(); Rot[8]=rot.zz();
83     tree->Fill();
84     return 0;
85     }
86    
87     // ----------------------------------------------------------------------------
88 flucke 1.3 int AlignableDataIORoot::writeRelRaw(const AlignableRelData &ad)
89 fronga 1.1 {
90     GlobalVector pos = ad.pos();
91     Surface::RotationType rot = ad.rot();
92     Id = ad.id();
93     ObjId = ad.objId();
94     Pos[0]=pos.x(); Pos[1]=pos.y(); Pos[2]=pos.z();
95     Rot[0]=rot.xx(); Rot[1]=rot.xy(); Rot[2]=rot.xz();
96     Rot[3]=rot.yx(); Rot[4]=rot.yy(); Rot[5]=rot.yz();
97     Rot[6]=rot.zx(); Rot[7]=rot.zy(); Rot[8]=rot.zz();
98     tree->Fill();
99     return 0;
100     }
101    
102     // ----------------------------------------------------------------------------
103     AlignableAbsData AlignableDataIORoot::readAbsRaw(Alignable* ali,int& ierr)
104     {
105     Global3DPoint pos;
106     Surface::RotationType rot;
107    
108     TrackerAlignableId converter;
109     int typeId = converter.alignableTypeId(ali);
110     unsigned int id = converter.alignableId(ali);
111     int entry = findEntry(id,typeId);
112     if(entry!=-1) {
113     tree->GetEntry(entry);
114     Global3DPoint pos2(Pos[0],Pos[1],Pos[2]);
115     Surface::RotationType rot2(Rot[0],Rot[1],Rot[2],
116     Rot[3],Rot[4],Rot[5],
117     Rot[6],Rot[7],Rot[8]);
118     pos=pos2;
119     rot=rot2;
120     ierr=0;
121     }
122     else ierr=-1;
123    
124     return AlignableAbsData(pos,rot,id,typeId);
125     }
126    
127     // ----------------------------------------------------------------------------
128    
129     AlignableRelData AlignableDataIORoot::readRelRaw(Alignable* ali,int& ierr)
130     {
131     Global3DVector pos;
132     Surface::RotationType rot;
133    
134     TrackerAlignableId converter;
135     int typeId = converter.alignableTypeId(ali);
136     unsigned int id = converter.alignableId(ali);
137     int entry = findEntry(id,typeId);
138     if(entry!=-1) {
139     tree->GetEntry(entry);
140     Global3DVector pos2(Pos[0],Pos[1],Pos[2]);
141     Surface::RotationType rot2(Rot[0],Rot[1],Rot[2],
142     Rot[3],Rot[4],Rot[5],
143     Rot[6],Rot[7],Rot[8]);
144     pos=pos2;
145     rot=rot2;
146     ierr=0;
147     }
148     else ierr=-1;
149    
150     return AlignableRelData(pos,rot,id,typeId);
151     }