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::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 TreeSplitter (const edm::ParameterSet &)
 
 ~TreeSplitter () 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
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 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::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 wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

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

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

Definition at line 28 of file TreeSplitter.h.

Constructor & Destructor Documentation

◆ TreeSplitter()

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

Definition at line 6 of file TreeSplitter.cc.

7  : treeFileName_(iConfig.getParameter<std::string>("InputFileName")),
8  outputFileName_(iConfig.getParameter<std::string>("OutputFileName")),
9  maxEvents_(iConfig.getParameter<int32_t>("MaxEvents")),
10  subSampleFirstEvent_(iConfig.getParameter<uint32_t>("SubSampleFirstEvent")),
11  subSampleMaxEvents_(iConfig.getParameter<uint32_t>("SubSampleMaxEvents")) {}

◆ ~TreeSplitter()

TreeSplitter::~TreeSplitter ( )
override

Definition at line 13 of file TreeSplitter.cc.

13 {}

Member Function Documentation

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 34 of file TreeSplitter.h.

34 {};

◆ endJob()

void TreeSplitter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 15 of file TreeSplitter.cc.

15  {
16  std::cout << "Reading muon pairs from Root Tree in " << treeFileName_ << std::endl;
17  RootTreeHandler rootTreeHandler;
18 
19  typedef std::vector<std::pair<lorentzVector, lorentzVector> > MuonPairVector;
20  // MuonPairVector savedPair;
21  std::vector<MuonPair> savedPair;
22  rootTreeHandler.readTree(maxEvents_, treeFileName_, &savedPair, 0);
23  // rootTreeHandler.readTree(maxEvents, inputRootTreeFileName_, &savedPair, &(MuScleFitUtils::genPair));
24 
25  // Loop on all the pairs
26  std::vector<MuonPair> newSavedPair;
27  // MuonPairVector newSavedPair;
28  unsigned int i = 0;
29  // MuonPairVector::iterator it = savedPair.begin();
30  std::vector<MuonPair>::iterator it = savedPair.begin();
31  std::cout << "Starting loop on " << savedPair.size() << " muons" << std::endl;
33  for (; it != savedPair.end(); ++it, ++i) {
34  // Save only events in the selected range
35  if (i >= subSampleFirstEvent_ && i < lastEvent) {
36  newSavedPair.push_back(*it);
37  }
38  }
39  rootTreeHandler.writeTree(outputFileName_, &newSavedPair, 0);
40 }

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

Member Data Documentation

◆ maxEvents_

int32_t TreeSplitter::maxEvents_
private

Definition at line 39 of file TreeSplitter.h.

Referenced by endJob().

◆ outputFileName_

TString TreeSplitter::outputFileName_
private

Definition at line 38 of file TreeSplitter.h.

Referenced by endJob().

◆ subSampleFirstEvent_

uint32_t TreeSplitter::subSampleFirstEvent_
private

Definition at line 40 of file TreeSplitter.h.

Referenced by endJob().

◆ subSampleMaxEvents_

uint32_t TreeSplitter::subSampleMaxEvents_
private

Definition at line 41 of file TreeSplitter.h.

Referenced by endJob().

◆ treeFileName_

TString TreeSplitter::treeFileName_
private

Definition at line 37 of file TreeSplitter.h.

Referenced by endJob().

TreeSplitter::maxEvents_
int32_t maxEvents_
Definition: TreeSplitter.h:39
mps_fire.i
i
Definition: mps_fire.py:428
RootTreeHandler
Definition: RootTreeHandler.h:24
gather_cfg.cout
cout
Definition: gather_cfg.py:144
MuonPairVector
std::vector< std::pair< lorentzVector, lorentzVector > > MuonPairVector
Definition: RootTreeHandler.h:13
RootTreeHandler::writeTree
void writeTree(const TString &fileName, const std::vector< MuonPair > *savedPair, const int muonType=0, const std::vector< GenMuonPair > *genPair=nullptr, const bool saveAll=false)
Definition: RootTreeHandler.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
callgrindSwitch_cfi.lastEvent
lastEvent
Definition: callgrindSwitch_cfi.py:5
TreeSplitter::subSampleMaxEvents_
uint32_t subSampleMaxEvents_
Definition: TreeSplitter.h:41
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
RootTreeHandler::readTree
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)
Definition: RootTreeHandler.h:86
TreeSplitter::subSampleFirstEvent_
uint32_t subSampleFirstEvent_
Definition: TreeSplitter.h:40
TreeSplitter::outputFileName_
TString outputFileName_
Definition: TreeSplitter.h:38
TreeSplitter::treeFileName_
TString treeFileName_
Definition: TreeSplitter.h:37