Skip to content

Commit

Permalink
#3 initial skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
jhgoh committed Dec 26, 2013
1 parent dc5057e commit 75fd75f
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
35 changes: 35 additions & 0 deletions FlatTree/interface/KFlatTreeAnalyzer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef KFlatTreeAnalyzer_h
#define KFlatTreeAnalyzer_h

#include <iostream>

#include "TFile.h"
#include "TH1F.h"
#include "TTree.h"
#include "TDirectory.h"
#include "TMath.h"

#include "KrAFT/FlatTree/interface/FlatEvent.h"

#include "Math/GenVector/LorentzVector.h"
#include "Math/GenVector/VectorUtil.h"

using namespace ROOT::Math::VectorUtil;
typedef ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > LorentzVector;

void printEntryFraction(int i, int n);

class KFlatTreeAnalyzer
{
public:
KFlatTreeAnalyzer(const std::string inputFileName, const std::string outputFileName);
~KFlatTreeAnalyzer();
void analyze();

private:
TFile* inputFile_, * outputFile_;
TTree* tree_;
FlatEvent* event_;
};

#endif
35 changes: 35 additions & 0 deletions FlatTree/src/KFlatTreeAnalyzer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "KrAFT/FlatTree/interface/KFlatTreeAnalyzer.h"
#include "TString.h"

using namespace std;

void printEntryFraction(int i, int n)
{
static int digit = 1;
if ( i%max(1, digit/10) == 0 )
{
cout << Form(TString("% ")+Form("%d", int(log10(n))+2)+"d/%d processed\r", i, n);
cout.flush();
}
if ( i%digit == 0 ) digit *= 10;

if ( i==(n-1) )
{
cout << Form(TString("% ")+Form("%d", int(log10(n))+2)+"d/%d processed", i, n) << endl;
digit = 1;
}
}

KFlatTreeAnalyzer::KFlatTreeAnalyzer(const string inputFileName, const string outputFileName)
{
inputFile_ = TFile::Open(inputFileName.c_str());
outputFile_ = TFile::Open(outputFileName.c_str(), "RECREATE");
}

KFlatTreeAnalyzer::~KFlatTreeAnalyzer()
{
inputFile_->Close();
outputFile_->Write();
outputFile_->Close();
}

0 comments on commit 75fd75f

Please sign in to comment.