ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/CMSSW/Alignment/CommonAlignmentAlgorithm/src/AlignableDataIORoot.cc
Revision: 1.2
Committed: Tue Nov 7 17:48:25 2006 UTC (18 years, 5 months ago) by flucke
Content type: text/plain
Branch: MAIN
CVS Tags: V00-07-01, V00-07-00
Changes since 1.1: +2 -2 lines
Log Message:
reduce severity level of many messages

File Contents

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