test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

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

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
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- 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 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

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

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

Definition at line 28 of file TreeSplitter.h.

Constructor & Destructor Documentation

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

Definition at line 6 of file TreeSplitter.cc.

6  :
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") )
12 {
13 }
uint32_t subSampleFirstEvent_
Definition: TreeSplitter.h:41
T getParameter(std::string const &) const
TString treeFileName_
Definition: TreeSplitter.h:38
TString outputFileName_
Definition: TreeSplitter.h:39
uint32_t subSampleMaxEvents_
Definition: TreeSplitter.h:42
int32_t maxEvents_
Definition: TreeSplitter.h:40
TreeSplitter::~TreeSplitter ( )

Definition at line 15 of file TreeSplitter.cc.

16 {
17 }

Member Function Documentation

virtual void TreeSplitter::analyze ( const edm::Event ,
const edm::EventSetup  
)
inlineprivatevirtual

Implements edm::EDAnalyzer.

Definition at line 35 of file TreeSplitter.h.

35 {};
void TreeSplitter::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 19 of file TreeSplitter.cc.

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

20 {
21  std::cout << "Reading muon pairs from Root Tree in " << treeFileName_ << std::endl;
22  RootTreeHandler rootTreeHandler;
23 
24  typedef std::vector<std::pair<lorentzVector,lorentzVector> > MuonPairVector;
25  // MuonPairVector savedPair;
26  std::vector<MuonPair> savedPair;
27  rootTreeHandler.readTree(maxEvents_, treeFileName_, &savedPair, 0);
28  // rootTreeHandler.readTree(maxEvents, inputRootTreeFileName_, &savedPair, &(MuScleFitUtils::genPair));
29 
30  // Loop on all the pairs
31  std::vector<MuonPair> newSavedPair;
32  // MuonPairVector newSavedPair;
33  unsigned int i = 0;
34  // MuonPairVector::iterator it = savedPair.begin();
35  std::vector<MuonPair>::iterator it = savedPair.begin();
36  std::cout << "Starting loop on " << savedPair.size() << " muons" << std::endl;
37  uint32_t lastEvent = subSampleFirstEvent_ + subSampleMaxEvents_;
38  for( ; it != savedPair.end(); ++it, ++i ) {
39  // Save only events in the selected range
40  if( i >= subSampleFirstEvent_ && i < lastEvent ) {
41  newSavedPair.push_back(*it);
42  }
43  }
44  rootTreeHandler.writeTree(outputFileName_, &newSavedPair, 0);
45 }
uint32_t subSampleFirstEvent_
Definition: TreeSplitter.h:41
void readTree(const int maxEvents, const TString &fileName, MuonPairVector *savedPair, const int muonType, std::vector< std::pair< int, int > > *evtRun, MuonPairVector *genPair=0)
int i
Definition: DBlmapReader.cc:9
TString treeFileName_
Definition: TreeSplitter.h:38
TString outputFileName_
Definition: TreeSplitter.h:39
std::vector< std::pair< lorentzVector, lorentzVector > > MuonPairVector
void writeTree(const TString &fileName, const std::vector< MuonPair > *savedPair, const int muonType=0, const std::vector< GenMuonPair > *genPair=0, const bool saveAll=false)
uint32_t subSampleMaxEvents_
Definition: TreeSplitter.h:42
tuple cout
Definition: gather_cfg.py:121
int32_t maxEvents_
Definition: TreeSplitter.h:40

Member Data Documentation

int32_t TreeSplitter::maxEvents_
private

Definition at line 40 of file TreeSplitter.h.

Referenced by endJob().

TString TreeSplitter::outputFileName_
private

Definition at line 39 of file TreeSplitter.h.

Referenced by endJob().

uint32_t TreeSplitter::subSampleFirstEvent_
private

Definition at line 41 of file TreeSplitter.h.

Referenced by endJob().

uint32_t TreeSplitter::subSampleMaxEvents_
private

Definition at line 42 of file TreeSplitter.h.

Referenced by endJob().

TString TreeSplitter::treeFileName_
private

Definition at line 38 of file TreeSplitter.h.

Referenced by endJob().