CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
Tracker_OldtoNewConverter Class Reference

#include <Alignment/OfflineValidation/plugins/Tracker_OldtoNewConverter.cc>

Inheritance diagram for Tracker_OldtoNewConverter:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 Tracker_OldtoNewConverter (const edm::ParameterSet &)
 
 ~Tracker_OldtoNewConverter () override=default
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

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::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 38 of file Tracker_OldtoNewConverter.cc.

Constructor & Destructor Documentation

◆ Tracker_OldtoNewConverter()

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

Definition at line 85 of file Tracker_OldtoNewConverter.cc.

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

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

◆ ~Tracker_OldtoNewConverter()

Tracker_OldtoNewConverter::~Tracker_OldtoNewConverter ( )
overridedefault

Member Function Documentation

◆ addBranches()

void Tracker_OldtoNewConverter::addBranches ( )
private

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

199  {
200  m_inputTree->SetBranchAddress("rawid", &rawid_i);
201  m_inputTree->SetBranchAddress("x", &x_i);
202  m_inputTree->SetBranchAddress("y", &y_i);
203  m_inputTree->SetBranchAddress("z", &z_i);
204  m_inputTree->SetBranchAddress("alpha", &a_i);
205  m_inputTree->SetBranchAddress("beta", &b_i);
206  m_inputTree->SetBranchAddress("gamma", &c_i);
207 
208  m_outputTree->Branch("rawid", &rawid_f, "rawid/I");
209  m_outputTree->Branch("x", &x_f, "x/D");
210  m_outputTree->Branch("y", &y_f, "y/D");
211  m_outputTree->Branch("z", &z_f, "z/D");
212  m_outputTree->Branch("alpha", &a_f, "alpha/D");
213  m_outputTree->Branch("beta", &b_f, "beta/D");
214  m_outputTree->Branch("gamma", &c_f, "gamma/D");
215 }

◆ analyze()

void Tracker_OldtoNewConverter::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 127 of file Tracker_OldtoNewConverter.cc.

127 {}

◆ beginJob()

void Tracker_OldtoNewConverter::beginJob ( )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

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

130  {
131  m_inputTFile = new TFile(m_inputFile.c_str());
132  m_outputTFile = new TFile(m_outputFile.c_str(), "RECREATE");
133 
134  m_inputTree = (TTree*)m_inputTFile->Get(m_treeName.c_str());
135  m_outputTree = new TTree(m_treeName.c_str(), m_treeName.c_str());
136 
137  createMap();
138  addBranches();
139 
140  uint32_t nEntries = m_inputTree->GetEntries();
141  uint32_t iter = 0;
142  for (uint32_t i = 0; i < nEntries; ++i) {
143  m_inputTree->GetEntry(i);
144  std::map<uint32_t, uint32_t>::const_iterator it = theMap.find(rawid_i);
145 
146  if (it == theMap.end()) {
147  edm::LogInfo("ERROR") << "Error: couldn't find rawId: " << rawid_i;
148  iter++;
149  } else {
150  rawid_f = (it)->second;
151  x_f = x_i;
152  y_f = y_i;
153  z_f = z_i;
154  a_f = a_i;
155  b_f = b_i;
156  c_f = c_i;
157  m_outputTree->Fill();
158  }
159  }
160  edm::LogInfo("errors") << "Couldn't find: " << iter;
161  m_outputTFile->cd();
162  m_outputTree->Write();
163  m_outputTFile->Close();
164 }
U second(std::pair< T, U > const &p)
std::map< uint32_t, uint32_t > theMap
Log< level::Info, false > LogInfo

◆ createMap()

void Tracker_OldtoNewConverter::createMap ( )
private

Definition at line 166 of file Tracker_OldtoNewConverter.cc.

References dqmiodatasetharvest::ctr, m_conversionType, m_textFile, and theMap.

Referenced by beginJob().

166  {
167  std::ifstream myfile(m_textFile.c_str());
168  if (!myfile.is_open())
169  throw cms::Exception("FileAccess") << "Unable to open input text file";
170 
171  uint32_t oldid;
172  uint32_t newid;
173 
174  uint32_t ctr = 0;
175  while (!myfile.eof() && myfile.good()) {
176  myfile >> oldid >> newid;
177 
178  //depends on conversion type: OldtoNew or NewtoOld
179  std::pair<uint32_t, uint32_t> pairType;
180  if (m_conversionType == "OldtoNew") {
181  pairType.first = oldid;
182  pairType.second = newid;
183  }
184  if (m_conversionType == "NewtoOld") {
185  pairType.first = newid;
186  pairType.second = oldid;
187  }
188 
189  theMap.insert(pairType);
190 
191  if (myfile.fail())
192  break;
193 
194  ctr++;
195  }
196  edm::LogInfo("Check") << ctr << " alignables read.";
197 }
std::map< uint32_t, uint32_t > theMap
Log< level::Info, false > LogInfo

◆ endJob()

void Tracker_OldtoNewConverter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 218 of file Tracker_OldtoNewConverter.cc.

Referenced by o2olib.O2ORunMgr::executeJob().

218 {}

◆ fillDescriptions()

void Tracker_OldtoNewConverter::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 115 of file Tracker_OldtoNewConverter.cc.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

115  {
117  desc.setComment("Converts tracker geometry comparison trees");
118  desc.addUntracked<std::string>("conversionType", {});
119  desc.addUntracked<std::string>("inputFile", {});
120  desc.addUntracked<std::string>("outputFile", {});
121  desc.addUntracked<std::string>("textFile", {});
122  desc.addUntracked<std::string>("treeName", {});
123  descriptions.addWithDefaultLabel(desc);
124 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ a_f

double Tracker_OldtoNewConverter::a_f
private

Definition at line 71 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

◆ a_i

double Tracker_OldtoNewConverter::a_i
private

Definition at line 70 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

◆ b_f

double Tracker_OldtoNewConverter::b_f
private

Definition at line 71 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

◆ b_i

double Tracker_OldtoNewConverter::b_i
private

Definition at line 70 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

◆ c_f

double Tracker_OldtoNewConverter::c_f
private

Definition at line 71 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

◆ c_i

double Tracker_OldtoNewConverter::c_i
private

Definition at line 70 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

◆ m_conversionType

std::string Tracker_OldtoNewConverter::m_conversionType
private

Definition at line 55 of file Tracker_OldtoNewConverter.cc.

Referenced by createMap(), and Tracker_OldtoNewConverter().

◆ m_inputFile

std::string Tracker_OldtoNewConverter::m_inputFile
private

Definition at line 57 of file Tracker_OldtoNewConverter.cc.

Referenced by beginJob(), and Tracker_OldtoNewConverter().

◆ m_inputTFile

TFile* Tracker_OldtoNewConverter::m_inputTFile
private

Definition at line 63 of file Tracker_OldtoNewConverter.cc.

Referenced by beginJob().

◆ m_inputTree

TTree* Tracker_OldtoNewConverter::m_inputTree
private

Definition at line 65 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

◆ m_outputFile

std::string Tracker_OldtoNewConverter::m_outputFile
private

Definition at line 58 of file Tracker_OldtoNewConverter.cc.

Referenced by beginJob(), and Tracker_OldtoNewConverter().

◆ m_outputTFile

TFile* Tracker_OldtoNewConverter::m_outputTFile
private

Definition at line 64 of file Tracker_OldtoNewConverter.cc.

Referenced by beginJob().

◆ m_outputTree

TTree* Tracker_OldtoNewConverter::m_outputTree
private

Definition at line 66 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

◆ m_textFile

std::string Tracker_OldtoNewConverter::m_textFile
private

Definition at line 56 of file Tracker_OldtoNewConverter.cc.

Referenced by createMap(), and Tracker_OldtoNewConverter().

◆ m_treeName

std::string Tracker_OldtoNewConverter::m_treeName
private

Definition at line 59 of file Tracker_OldtoNewConverter.cc.

Referenced by beginJob(), and Tracker_OldtoNewConverter().

◆ rawid_f

uint32_t Tracker_OldtoNewConverter::rawid_f
private

Definition at line 68 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

◆ rawid_i

uint32_t Tracker_OldtoNewConverter::rawid_i
private

Definition at line 68 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

◆ theMap

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

Definition at line 61 of file Tracker_OldtoNewConverter.cc.

Referenced by beginJob(), and createMap().

◆ x_f

double Tracker_OldtoNewConverter::x_f
private

Definition at line 71 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

◆ x_i

double Tracker_OldtoNewConverter::x_i
private

Definition at line 70 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

◆ y_f

double Tracker_OldtoNewConverter::y_f
private

Definition at line 71 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

◆ y_i

double Tracker_OldtoNewConverter::y_i
private

Definition at line 70 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

◆ z_f

double Tracker_OldtoNewConverter::z_f
private

Definition at line 71 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

◆ z_i

double Tracker_OldtoNewConverter::z_i
private

Definition at line 70 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().