CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

TreeSplitter Class Reference

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

Inheritance diagram for TreeSplitter:
edm::EDAnalyzer

List of all members.

Public Member Functions

 TreeSplitter (const edm::ParameterSet &)
 ~TreeSplitter ()

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_

Detailed Description

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

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

Definition at line 29 of file TreeSplitter.h.


Constructor & Destructor Documentation

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

Definition at line 6 of file TreeSplitter.cc.

                                                         :
  treeFileName_( iConfig.getParameter<std::string>("InputFileName") ),
  outputFileName_( iConfig.getParameter<std::string>("OutputFileName") ),
  maxEvents_( iConfig.getParameter<int32_t>("MaxEvents") ),
  subSampleFirstEvent_( iConfig.getParameter<uint32_t>("SubSampleFirstEvent") ),
  subSampleMaxEvents_( iConfig.getParameter<uint32_t>("SubSampleMaxEvents") )
{
}
TreeSplitter::~TreeSplitter ( )

Definition at line 15 of file TreeSplitter.cc.

{
}

Member Function Documentation

virtual void TreeSplitter::analyze ( const edm::Event ,
const edm::EventSetup  
) [inline, private, virtual]

Implements edm::EDAnalyzer.

Definition at line 36 of file TreeSplitter.h.

{};
void TreeSplitter::endJob ( void  ) [private, virtual]

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

{
  std::cout << "Reading muon pairs from Root Tree in " << treeFileName_ << std::endl;
  RootTreeHandler rootTreeHandler;

  typedef std::vector<std::pair<lorentzVector,lorentzVector> > MuonPairVector;
  // MuonPairVector savedPair;
  std::vector<MuonPair> savedPair;
  rootTreeHandler.readTree(maxEvents_, treeFileName_, &savedPair, 0);
  // rootTreeHandler.readTree(maxEvents, inputRootTreeFileName_, &savedPair, &(MuScleFitUtils::genPair));

  // Loop on all the pairs
  std::vector<MuonPair> newSavedPair;
  // MuonPairVector newSavedPair;
  unsigned int i = 0;
  // MuonPairVector::iterator it = savedPair.begin();
  std::vector<MuonPair>::iterator it = savedPair.begin();
  std::cout << "Starting loop on " << savedPair.size() << " muons" << std::endl;
  uint32_t lastEvent = subSampleFirstEvent_ + subSampleMaxEvents_;
  for( ; it != savedPair.end(); ++it, ++i ) {
    // Save only events in the selected range
    if( i >= subSampleFirstEvent_ && i < lastEvent ) {
      newSavedPair.push_back(*it);
    }
  }
  rootTreeHandler.writeTree(outputFileName_, &newSavedPair, 0);
}

Member Data Documentation

int32_t TreeSplitter::maxEvents_ [private]

Definition at line 41 of file TreeSplitter.h.

Referenced by endJob().

TString TreeSplitter::outputFileName_ [private]

Definition at line 40 of file TreeSplitter.h.

Referenced by endJob().

Definition at line 42 of file TreeSplitter.h.

Referenced by endJob().

Definition at line 43 of file TreeSplitter.h.

Referenced by endJob().

TString TreeSplitter::treeFileName_ [private]

Definition at line 39 of file TreeSplitter.h.

Referenced by endJob().