CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
Tracker_OldtoNewConverter Class Reference
Inheritance diagram for Tracker_OldtoNewConverter:
edm::EDAnalyzer

Public Member Functions

 Tracker_OldtoNewConverter (const edm::ParameterSet &)
 
 ~Tracker_OldtoNewConverter ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Member Functions

void addBranches ()
 
virtual void analyze (const edm::Event &iEvent, const edm::EventSetup &iSetup)
 
virtual void beginJob ()
 
void createMap ()
 
virtual void endJob ()
 

Private Attributes

double a_f
 
double a_i
 
double b_f
 
double b_i
 
double c_f
 
double c_i
 
std::string m_conversionType
 
std::string m_inputFile
 
TFile * m_inputTFile
 
TTree * m_inputTree
 
std::string m_outputFile
 
TFile * m_outputTFile
 
TTree * m_outputTree
 
std::string m_textFile
 
std::string m_treeName
 
uint32_t rawid_f
 
uint32_t rawid_i
 
std::map< uint32_t, uint32_t > theMap
 
double x_f
 
double x_i
 
double y_f
 
double y_i
 
double z_f
 
double z_i
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 40 of file Tracker_OldtoNewConverter.cc.

Constructor & Destructor Documentation

Tracker_OldtoNewConverter::Tracker_OldtoNewConverter ( const edm::ParameterSet iConfig)
explicit

Definition at line 89 of file Tracker_OldtoNewConverter.cc.

References edm::ParameterSet::getUntrackedParameter(), m_conversionType, m_inputFile, m_outputFile, m_textFile, and m_treeName.

90 {
91  m_conversionType = iConfig.getUntrackedParameter< std::string > ("conversionType");
92  m_inputFile = iConfig.getUntrackedParameter< std::string > ("inputFile");
93  m_outputFile = iConfig.getUntrackedParameter< std::string > ("outputFile");
94  m_textFile = iConfig.getUntrackedParameter< std::string > ("textFile");
95  m_treeName = iConfig.getUntrackedParameter< std::string > ("treeName");
96 }
T getUntrackedParameter(std::string const &, T const &) const
Tracker_OldtoNewConverter::~Tracker_OldtoNewConverter ( )

Definition at line 99 of file Tracker_OldtoNewConverter.cc.

100 {}

Member Function Documentation

void Tracker_OldtoNewConverter::addBranches ( )
private

Definition at line 184 of file Tracker_OldtoNewConverter.cc.

References a_f, a_i, b_f, b_i, c_f, c_i, m_inputTree, m_outputTree, rawid_f, rawid_i, x_f, x_i, y_f, y_i, z_f, and z_i.

Referenced by python.Vispa.Plugins.EdmBrowser.EventContentDataAccessor.EventContentDataAccessor::addContentFile(), and beginJob().

184  {
185 
186  m_inputTree->SetBranchAddress("rawid", &rawid_i);
187  m_inputTree->SetBranchAddress("x", &x_i);
188  m_inputTree->SetBranchAddress("y", &y_i);
189  m_inputTree->SetBranchAddress("z", &z_i);
190  m_inputTree->SetBranchAddress("alpha", &a_i);
191  m_inputTree->SetBranchAddress("beta", &b_i);
192  m_inputTree->SetBranchAddress("gamma", &c_i);
193 
194  m_outputTree->Branch("rawid", &rawid_f, "rawid/I");
195  m_outputTree->Branch("x", &x_f, "x/D");
196  m_outputTree->Branch("y", &y_f, "y/D");
197  m_outputTree->Branch("z", &z_f, "z/D");
198  m_outputTree->Branch("alpha", &a_f, "alpha/D");
199  m_outputTree->Branch("beta", &b_f, "beta/D");
200  m_outputTree->Branch("gamma", &c_f, "gamma/D");
201 
202 }
void Tracker_OldtoNewConverter::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDAnalyzer.

Definition at line 108 of file Tracker_OldtoNewConverter.cc.

109 {}
void Tracker_OldtoNewConverter::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 113 of file Tracker_OldtoNewConverter.cc.

References a_f, a_i, addBranches(), b_f, b_i, c_f, c_i, createMap(), i, m_inputFile, m_inputTFile, m_inputTree, m_outputFile, m_outputTFile, m_outputTree, m_treeName, rawid_f, rawid_i, edm::second(), theMap, x_f, x_i, y_f, y_i, z_f, and z_i.

114 {
115 
116  m_inputTFile = new TFile(m_inputFile.c_str());
117  m_outputTFile = new TFile(m_outputFile.c_str(),"RECREATE");
118 
119  m_inputTree = (TTree*) m_inputTFile->Get(m_treeName.c_str());
120  m_outputTree = new TTree(m_treeName.c_str(), m_treeName.c_str());
121 
122  createMap();
123  addBranches();
124 
125  uint32_t nEntries = m_inputTree->GetEntries();
126  uint32_t iter = 0;
127  for (uint32_t i = 0; i < nEntries; ++i){
128  m_inputTree->GetEntry(i);
129  std::map< uint32_t, uint32_t >::const_iterator it = theMap.find(rawid_i);
130 
131  if (it == theMap.end()){
132  edm::LogInfo("ERROR") << "Error: couldn't find rawId: " << rawid_i;
133  iter++;
134  }
135  else{
136  rawid_f = (it)->second;
137  x_f = x_i;
138  y_f = y_i;
139  z_f = z_i;
140  a_f = a_i;
141  b_f = b_i;
142  c_f = c_i;
143  m_outputTree->Fill();
144  }
145 
146  }
147  edm::LogInfo("errors") << "Couldn't find: " << iter;
148  m_outputTFile->cd();
149  m_outputTree->Write();
150  m_outputTFile->Close();
151 }
int i
Definition: DBlmapReader.cc:9
U second(std::pair< T, U > const &p)
std::map< uint32_t, uint32_t > theMap
void Tracker_OldtoNewConverter::createMap ( )
private

Definition at line 155 of file Tracker_OldtoNewConverter.cc.

References m_conversionType, m_textFile, python.tagInventory::newid, and theMap.

Referenced by beginJob().

155  {
156 
157  std::ifstream myfile( m_textFile.c_str() );
158  if (!myfile.is_open())
159  throw cms::Exception("FileAccess") << "Unable to open input text file";
160 
161  uint32_t oldid;
162  uint32_t newid;
163 
164  uint32_t ctr = 0;
165  while( !myfile.eof() && myfile.good() ){
166 
167  myfile >> oldid >> newid;
168 
169  //depends on conversion type: OldtoNew or NewtoOld
170  std::pair< uint32_t, uint32_t > pairType;
171  if (m_conversionType == "OldtoNew") {pairType.first = oldid; pairType.second = newid;}
172  if (m_conversionType == "NewtoOld") {pairType.first = newid; pairType.second = oldid;}
173 
174 
175  theMap.insert( pairType );
176 
177  if (myfile.fail()) break;
178 
179  ctr++;
180  }
181  edm::LogInfo("Check") << ctr << " alignables read.";
182 }
std::map< uint32_t, uint32_t > theMap
void Tracker_OldtoNewConverter::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 206 of file Tracker_OldtoNewConverter.cc.

206  {
207 }

Member Data Documentation

double Tracker_OldtoNewConverter::a_f
private

Definition at line 73 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

double Tracker_OldtoNewConverter::a_i
private

Definition at line 72 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

double Tracker_OldtoNewConverter::b_f
private

Definition at line 73 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

double Tracker_OldtoNewConverter::b_i
private

Definition at line 72 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

double Tracker_OldtoNewConverter::c_f
private

Definition at line 73 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

double Tracker_OldtoNewConverter::c_i
private

Definition at line 72 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

std::string Tracker_OldtoNewConverter::m_conversionType
private

Definition at line 56 of file Tracker_OldtoNewConverter.cc.

Referenced by createMap(), and Tracker_OldtoNewConverter().

std::string Tracker_OldtoNewConverter::m_inputFile
private

Definition at line 58 of file Tracker_OldtoNewConverter.cc.

Referenced by beginJob(), and Tracker_OldtoNewConverter().

TFile* Tracker_OldtoNewConverter::m_inputTFile
private

Definition at line 64 of file Tracker_OldtoNewConverter.cc.

Referenced by beginJob().

TTree* Tracker_OldtoNewConverter::m_inputTree
private

Definition at line 66 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

std::string Tracker_OldtoNewConverter::m_outputFile
private

Definition at line 59 of file Tracker_OldtoNewConverter.cc.

Referenced by beginJob(), and Tracker_OldtoNewConverter().

TFile* Tracker_OldtoNewConverter::m_outputTFile
private

Definition at line 65 of file Tracker_OldtoNewConverter.cc.

Referenced by beginJob().

TTree* Tracker_OldtoNewConverter::m_outputTree
private

Definition at line 67 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

std::string Tracker_OldtoNewConverter::m_textFile
private

Definition at line 57 of file Tracker_OldtoNewConverter.cc.

Referenced by createMap(), and Tracker_OldtoNewConverter().

std::string Tracker_OldtoNewConverter::m_treeName
private

Definition at line 60 of file Tracker_OldtoNewConverter.cc.

Referenced by beginJob(), and Tracker_OldtoNewConverter().

uint32_t Tracker_OldtoNewConverter::rawid_f
private

Definition at line 70 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

uint32_t Tracker_OldtoNewConverter::rawid_i
private

Definition at line 70 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

std::map< uint32_t, uint32_t > Tracker_OldtoNewConverter::theMap
private

Definition at line 62 of file Tracker_OldtoNewConverter.cc.

Referenced by beginJob(), and createMap().

double Tracker_OldtoNewConverter::x_f
private

Definition at line 73 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

double Tracker_OldtoNewConverter::x_i
private

Definition at line 72 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

double Tracker_OldtoNewConverter::y_f
private

Definition at line 73 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

double Tracker_OldtoNewConverter::y_i
private

Definition at line 72 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

double Tracker_OldtoNewConverter::z_f
private

Definition at line 73 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

double Tracker_OldtoNewConverter::z_i
private

Definition at line 72 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().