CMS 3D CMS Logo

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

#include <MuonAnalysis/MomentumScaleCalibration/plugins/TreeSplitter.cc>

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

Public Member Functions

 TreeSplitter (const edm::ParameterSet &)
 
 ~TreeSplitter () 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
 
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)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void endJob () override
 

Private Attributes

int32_t maxEvents_
 
TString outputFileName_
 
uint32_t subSampleFirstEvent_
 
uint32_t subSampleMaxEvents_
 
TString treeFileName_
 

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 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 25 of file TreeSplitter.cc.

Constructor & Destructor Documentation

◆ TreeSplitter()

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

Definition at line 41 of file TreeSplitter.cc.

42  : treeFileName_(iConfig.getParameter<std::string>("InputFileName")),
43  outputFileName_(iConfig.getParameter<std::string>("OutputFileName")),
44  maxEvents_(iConfig.getParameter<int32_t>("MaxEvents")),
45  subSampleFirstEvent_(iConfig.getParameter<uint32_t>("SubSampleFirstEvent")),
46  subSampleMaxEvents_(iConfig.getParameter<uint32_t>("SubSampleMaxEvents")) {}
uint32_t subSampleFirstEvent_
Definition: TreeSplitter.cc:37
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TString treeFileName_
Definition: TreeSplitter.cc:34
TString outputFileName_
Definition: TreeSplitter.cc:35
uint32_t subSampleMaxEvents_
Definition: TreeSplitter.cc:38
int32_t maxEvents_
Definition: TreeSplitter.cc:36

◆ ~TreeSplitter()

TreeSplitter::~TreeSplitter ( )
override

Definition at line 48 of file TreeSplitter.cc.

48 {}

Member Function Documentation

◆ analyze()

void TreeSplitter::analyze ( const edm::Event ,
const edm::EventSetup  
)
inlineoverrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 31 of file TreeSplitter.cc.

31 {};

◆ endJob()

void TreeSplitter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 50 of file TreeSplitter.cc.

References gather_cfg::cout, mps_fire::i, callgrindSwitch_cfi::lastEvent, maxEvents_, outputFileName_, RootTreeHandler::readTree(), subSampleFirstEvent_, subSampleMaxEvents_, treeFileName_, and RootTreeHandler::writeTree().

50  {
51  std::cout << "Reading muon pairs from Root Tree in " << treeFileName_ << std::endl;
52  RootTreeHandler rootTreeHandler;
53 
54  typedef std::vector<std::pair<lorentzVector, lorentzVector> > MuonPairVector;
55  // MuonPairVector savedPair;
56  std::vector<MuonPair> savedPair;
57  rootTreeHandler.readTree(maxEvents_, treeFileName_, &savedPair, 0);
58  // rootTreeHandler.readTree(maxEvents, inputRootTreeFileName_, &savedPair, &(MuScleFitUtils::genPair));
59 
60  // Loop on all the pairs
61  std::vector<MuonPair> newSavedPair;
62  // MuonPairVector newSavedPair;
63  unsigned int i = 0;
64  // MuonPairVector::iterator it = savedPair.begin();
65  std::vector<MuonPair>::iterator it = savedPair.begin();
66  std::cout << "Starting loop on " << savedPair.size() << " muons" << std::endl;
68  for (; it != savedPair.end(); ++it, ++i) {
69  // Save only events in the selected range
70  if (i >= subSampleFirstEvent_ && i < lastEvent) {
71  newSavedPair.push_back(*it);
72  }
73  }
74  rootTreeHandler.writeTree(outputFileName_, &newSavedPair, 0);
75 }
uint32_t subSampleFirstEvent_
Definition: TreeSplitter.cc:37
void readTree(const int maxEvents, const TString &fileName, MuonPairVector *savedPair, const int muonType, std::vector< std::pair< unsigned int, unsigned long long > > *evtRun, MuonPairVector *genPair=nullptr)
void writeTree(const TString &fileName, const std::vector< MuonPair > *savedPair, const int muonType=0, const std::vector< GenMuonPair > *genPair=nullptr, const bool saveAll=false)
TString treeFileName_
Definition: TreeSplitter.cc:34
TString outputFileName_
Definition: TreeSplitter.cc:35
uint32_t subSampleMaxEvents_
Definition: TreeSplitter.cc:38
std::vector< std::pair< lorentzVector, lorentzVector > > MuonPairVector
int32_t maxEvents_
Definition: TreeSplitter.cc:36

Member Data Documentation

◆ maxEvents_

int32_t TreeSplitter::maxEvents_
private

Definition at line 36 of file TreeSplitter.cc.

Referenced by endJob().

◆ outputFileName_

TString TreeSplitter::outputFileName_
private

Definition at line 35 of file TreeSplitter.cc.

Referenced by endJob().

◆ subSampleFirstEvent_

uint32_t TreeSplitter::subSampleFirstEvent_
private

Definition at line 37 of file TreeSplitter.cc.

Referenced by endJob().

◆ subSampleMaxEvents_

uint32_t TreeSplitter::subSampleMaxEvents_
private

Definition at line 38 of file TreeSplitter.cc.

Referenced by endJob().

◆ treeFileName_

TString TreeSplitter::treeFileName_
private

Definition at line 34 of file TreeSplitter.cc.

Referenced by endJob().