CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

Tracker_OldtoNewConverter Class Reference

Inheritance diagram for Tracker_OldtoNewConverter:
edm::EDAnalyzer

List of all members.

Public Member Functions

 Tracker_OldtoNewConverter (const edm::ParameterSet &)
 ~Tracker_OldtoNewConverter ()

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

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.

                                                                                   :
  m_inputTFile(0), m_outputTFile(0), m_inputTree(0), m_outputTree(0),
  rawid_i(0), rawid_f(0),
  x_i(0.), y_i(0.), z_i(0.), a_i(0.), b_i(0.), c_i(0.),
  x_f(0.), y_f(0.), z_f(0.), a_f(0.), b_f(0.), c_f(0.)
{
        m_conversionType = iConfig.getUntrackedParameter< std::string > ("conversionType");
        m_inputFile = iConfig.getUntrackedParameter< std::string > ("inputFile");
        m_outputFile = iConfig.getUntrackedParameter< std::string > ("outputFile");
        m_textFile = iConfig.getUntrackedParameter< std::string > ("textFile");
        m_treeName = iConfig.getUntrackedParameter< std::string > ("treeName");
}
Tracker_OldtoNewConverter::~Tracker_OldtoNewConverter ( )

Definition at line 103 of file Tracker_OldtoNewConverter.cc.

{}

Member Function Documentation

void Tracker_OldtoNewConverter::addBranches ( ) [private]

Definition at line 188 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 beginJob().

                                           {

        m_inputTree->SetBranchAddress("rawid", &rawid_i);
        m_inputTree->SetBranchAddress("x", &x_i);
        m_inputTree->SetBranchAddress("y", &y_i);
        m_inputTree->SetBranchAddress("z", &z_i);
        m_inputTree->SetBranchAddress("alpha", &a_i);
        m_inputTree->SetBranchAddress("beta", &b_i);
        m_inputTree->SetBranchAddress("gamma", &c_i);

        m_outputTree->Branch("rawid", &rawid_f, "rawid/I");
        m_outputTree->Branch("x", &x_f, "x/D");
        m_outputTree->Branch("y", &y_f, "y/D");
        m_outputTree->Branch("z", &z_f, "z/D");
        m_outputTree->Branch("alpha", &a_f, "alpha/D");
        m_outputTree->Branch("beta", &b_f, "beta/D");
        m_outputTree->Branch("gamma", &c_f, "gamma/D");

}
void Tracker_OldtoNewConverter::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDAnalyzer.

Definition at line 112 of file Tracker_OldtoNewConverter.cc.

{}
void Tracker_OldtoNewConverter::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 117 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.

{
        
        m_inputTFile = new TFile(m_inputFile.c_str());
        m_outputTFile = new TFile(m_outputFile.c_str(),"RECREATE");

        m_inputTree = (TTree*) m_inputTFile->Get(m_treeName.c_str());
        m_outputTree = new TTree(m_treeName.c_str(), m_treeName.c_str());
        
        createMap();
        addBranches();

        uint32_t nEntries = m_inputTree->GetEntries();
        uint32_t iter = 0;
        for (uint32_t i = 0; i < nEntries; ++i){
                m_inputTree->GetEntry(i);
                std::map< uint32_t, uint32_t >::const_iterator it = theMap.find(rawid_i);
                
                if (it == theMap.end()){
                        edm::LogInfo("ERROR") << "Error: couldn't find rawId: " << rawid_i;
                        iter++;
                }
                else{
                        rawid_f = (it)->second;
                        x_f = x_i;
                        y_f = y_i;
                        z_f = z_i;
                        a_f = a_i;
                        b_f = b_i;
                        c_f = c_i;
                        m_outputTree->Fill();
                }

        }
        edm::LogInfo("errors") << "Couldn't find: " << iter;
        m_outputTFile->cd();
        m_outputTree->Write();
        m_outputTFile->Close();
}
void Tracker_OldtoNewConverter::createMap ( ) [private]

Definition at line 159 of file Tracker_OldtoNewConverter.cc.

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

Referenced by beginJob().

                                          {

        std::ifstream myfile( m_textFile.c_str() );
        if (!myfile.is_open())
                throw cms::Exception("FileAccess") << "Unable to open input text file";

        uint32_t oldid;
        uint32_t newid;

        uint32_t ctr = 0;
        while( !myfile.eof() && myfile.good() ){

                myfile >> oldid >> newid;

                //depends on conversion type: OldtoNew or NewtoOld
                std::pair< uint32_t, uint32_t > pairType;
                if (m_conversionType == "OldtoNew") {pairType.first = oldid; pairType.second = newid;}
                if (m_conversionType == "NewtoOld") {pairType.first = newid; pairType.second = oldid;}


                theMap.insert( pairType );

                if (myfile.fail()) break;

                ctr++;
        }
        edm::LogInfo("Check") << ctr << " alignables read.";
}
void Tracker_OldtoNewConverter::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 210 of file Tracker_OldtoNewConverter.cc.

                                       {
}

Member Data Documentation

Definition at line 73 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

Definition at line 72 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

Definition at line 73 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

Definition at line 72 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

Definition at line 73 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

Definition at line 72 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

Definition at line 56 of file Tracker_OldtoNewConverter.cc.

Referenced by createMap(), and Tracker_OldtoNewConverter().

Definition at line 58 of file Tracker_OldtoNewConverter.cc.

Referenced by beginJob(), and Tracker_OldtoNewConverter().

Definition at line 64 of file Tracker_OldtoNewConverter.cc.

Referenced by beginJob().

Definition at line 66 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

Definition at line 59 of file Tracker_OldtoNewConverter.cc.

Referenced by beginJob(), and Tracker_OldtoNewConverter().

Definition at line 65 of file Tracker_OldtoNewConverter.cc.

Referenced by beginJob().

Definition at line 67 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

Definition at line 57 of file Tracker_OldtoNewConverter.cc.

Referenced by createMap(), and Tracker_OldtoNewConverter().

Definition at line 60 of file Tracker_OldtoNewConverter.cc.

Referenced by beginJob(), and Tracker_OldtoNewConverter().

Definition at line 70 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

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().

Definition at line 73 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

Definition at line 72 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

Definition at line 73 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

Definition at line 72 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

Definition at line 73 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

Definition at line 72 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().