CMS 3D CMS Logo

TreeSplitter.cc
Go to the documentation of this file.
1 #ifndef TREESPLITTER_CC
2 #define TREESPLITTER_CC
3 
4 #include "TreeSplitter.h"
5 
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 
14 
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 }
41 
42 //define this as a plug-in
44 
45 #endif
TreeSplitter::maxEvents_
int32_t maxEvents_
Definition: TreeSplitter.h:39
mps_fire.i
i
Definition: mps_fire.py:428
RootTreeHandler
Definition: RootTreeHandler.h:24
TreeSplitter::TreeSplitter
TreeSplitter(const edm::ParameterSet &)
Definition: TreeSplitter.cc:6
gather_cfg.cout
cout
Definition: gather_cfg.py:144
TreeSplitter::endJob
void endJob() override
Definition: TreeSplitter.cc:15
MuonPairVector
std::vector< std::pair< lorentzVector, lorentzVector > > MuonPairVector
Definition: RootTreeHandler.h:13
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
TreeSplitter
Definition: TreeSplitter.h:28
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
TreeSplitter.h
edm::ParameterSet
Definition: ParameterSet.h:47
callgrindSwitch_cfi.lastEvent
lastEvent
Definition: callgrindSwitch_cfi.py:5
TreeSplitter::subSampleMaxEvents_
uint32_t subSampleMaxEvents_
Definition: TreeSplitter.h:41
std
Definition: JetResolutionObject.h:76
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::~TreeSplitter
~TreeSplitter() override
Definition: TreeSplitter.cc:13
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