CMS 3D CMS Logo

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

Public Member Functions

 Tracker_OldtoNewConverter (const edm::ParameterSet &)
 
 ~Tracker_OldtoNewConverter () override
 
- 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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices const &)
 
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::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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 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<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

Definition at line 38 of file Tracker_OldtoNewConverter.cc.

Constructor & Destructor Documentation

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

Definition at line 83 of file Tracker_OldtoNewConverter.cc.

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

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

Definition at line 109 of file Tracker_OldtoNewConverter.cc.

109 {}

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

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

Implements edm::one::EDAnalyzerBase.

Definition at line 116 of file Tracker_OldtoNewConverter.cc.

116 {}
void Tracker_OldtoNewConverter::beginJob ( )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

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

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  } else {
139  rawid_f = (it)->second;
140  x_f = x_i;
141  y_f = y_i;
142  z_f = z_i;
143  a_f = a_i;
144  b_f = b_i;
145  c_f = c_i;
146  m_outputTree->Fill();
147  }
148  }
149  edm::LogInfo("errors") << "Couldn't find: " << iter;
150  m_outputTFile->cd();
151  m_outputTree->Write();
152  m_outputTFile->Close();
153 }
U second(std::pair< T, U > const &p)
std::map< uint32_t, uint32_t > theMap
Log< level::Info, false > LogInfo
void Tracker_OldtoNewConverter::createMap ( )
private

Definition at line 155 of file Tracker_OldtoNewConverter.cc.

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

Referenced by beginJob().

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

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 207 of file Tracker_OldtoNewConverter.cc.

Referenced by o2olib.O2ORunMgr::executeJob().

207 {}

Member Data Documentation

double Tracker_OldtoNewConverter::a_f
private

Definition at line 69 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

double Tracker_OldtoNewConverter::a_i
private

Definition at line 68 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

double Tracker_OldtoNewConverter::b_f
private

Definition at line 69 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

double Tracker_OldtoNewConverter::b_i
private

Definition at line 68 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

double Tracker_OldtoNewConverter::c_f
private

Definition at line 69 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

double Tracker_OldtoNewConverter::c_i
private

Definition at line 68 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

std::string Tracker_OldtoNewConverter::m_conversionType
private

Definition at line 53 of file Tracker_OldtoNewConverter.cc.

Referenced by createMap(), and Tracker_OldtoNewConverter().

std::string Tracker_OldtoNewConverter::m_inputFile
private

Definition at line 55 of file Tracker_OldtoNewConverter.cc.

Referenced by beginJob(), and Tracker_OldtoNewConverter().

TFile* Tracker_OldtoNewConverter::m_inputTFile
private

Definition at line 61 of file Tracker_OldtoNewConverter.cc.

Referenced by beginJob().

TTree* Tracker_OldtoNewConverter::m_inputTree
private

Definition at line 63 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

std::string Tracker_OldtoNewConverter::m_outputFile
private

Definition at line 56 of file Tracker_OldtoNewConverter.cc.

Referenced by beginJob(), and Tracker_OldtoNewConverter().

TFile* Tracker_OldtoNewConverter::m_outputTFile
private

Definition at line 62 of file Tracker_OldtoNewConverter.cc.

Referenced by beginJob().

TTree* Tracker_OldtoNewConverter::m_outputTree
private

Definition at line 64 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

std::string Tracker_OldtoNewConverter::m_textFile
private

Definition at line 54 of file Tracker_OldtoNewConverter.cc.

Referenced by createMap(), and Tracker_OldtoNewConverter().

std::string Tracker_OldtoNewConverter::m_treeName
private

Definition at line 57 of file Tracker_OldtoNewConverter.cc.

Referenced by beginJob(), and Tracker_OldtoNewConverter().

uint32_t Tracker_OldtoNewConverter::rawid_f
private

Definition at line 66 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

uint32_t Tracker_OldtoNewConverter::rawid_i
private

Definition at line 66 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

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

Definition at line 59 of file Tracker_OldtoNewConverter.cc.

Referenced by beginJob(), and createMap().

double Tracker_OldtoNewConverter::x_f
private

Definition at line 69 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

double Tracker_OldtoNewConverter::x_i
private

Definition at line 68 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

double Tracker_OldtoNewConverter::y_f
private

Definition at line 69 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

double Tracker_OldtoNewConverter::y_i
private

Definition at line 68 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

double Tracker_OldtoNewConverter::z_f
private

Definition at line 69 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().

double Tracker_OldtoNewConverter::z_i
private

Definition at line 68 of file Tracker_OldtoNewConverter.cc.

Referenced by addBranches(), and beginJob().