CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
Tracker_OldtoNewConverter Class Reference
Inheritance diagram for Tracker_OldtoNewConverter:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 Tracker_OldtoNewConverter (const edm::ParameterSet &)
 
 ~Tracker_OldtoNewConverter () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

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

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
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ESProduct , Transition Tr = Transition::Event>
auto esConsumes (eventsetup::EventSetupRecordKey const &, ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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, m_treeName, and AlCaHLTBitMon_QueryRunRegistry::string.

89  :
90  m_inputTFile(nullptr), m_outputTFile(nullptr), m_inputTree(nullptr), m_outputTree(nullptr),
91  rawid_i(0), rawid_f(0),
92  x_i(0.), y_i(0.), z_i(0.), a_i(0.), b_i(0.), c_i(0.),
93  x_f(0.), y_f(0.), z_f(0.), a_f(0.), b_f(0.), c_f(0.)
94 {
95  m_conversionType = iConfig.getUntrackedParameter< std::string > ("conversionType");
96  m_inputFile = iConfig.getUntrackedParameter< std::string > ("inputFile");
97  m_outputFile = iConfig.getUntrackedParameter< std::string > ("outputFile");
98  m_textFile = iConfig.getUntrackedParameter< std::string > ("textFile");
99  m_treeName = iConfig.getUntrackedParameter< std::string > ("treeName");
100 }
T getUntrackedParameter(std::string const &, T const &) const
Tracker_OldtoNewConverter::~Tracker_OldtoNewConverter ( )
override

Definition at line 103 of file Tracker_OldtoNewConverter.cc.

104 {}

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 Vispa.Plugins.EdmBrowser.EventContentDataAccessor.EventContentDataAccessor::addContentFile(), and beginJob().

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

Definition at line 112 of file Tracker_OldtoNewConverter.cc.

113 {}
void Tracker_OldtoNewConverter::beginJob ( void  )
overrideprivatevirtual

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(), mps_fire::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.

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

Definition at line 159 of file Tracker_OldtoNewConverter.cc.

References m_conversionType, m_textFile, and theMap.

Referenced by beginJob().

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

Reimplemented from edm::EDAnalyzer.

Definition at line 210 of file Tracker_OldtoNewConverter.cc.

References DEFINE_FWK_MODULE.

Referenced by o2olib.O2ORunMgr::executeJob().

210  {
211 }

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