-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextractHistsFromTree.C
More file actions
63 lines (43 loc) · 2.3 KB
/
Copy pathextractHistsFromTree.C
File metadata and controls
63 lines (43 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <iostream>
#include <string>
#include "TLorentzVector.h"
using namespace std;
void doThings(std::string inFileName,std::string outFileName, std::string treeName)
{
const char *_inFilename = inFileName.c_str();
std::cout << "Reading file: " << _inFilename << std::endl;
TFile *f = new TFile(_inFilename);
double superJet_mass[100];
const char *_outFilename = outFileName.c_str();
TFile outFile(_outFilename,"RECREATE");
TTree *t1 = (TTree*)f->Get(treeName.c_str()); // TO do
const Int_t nentries = t1->GetEntries();
t1->SetBranchAddress("superJet_mass", superJet_mass);
TH1F* h_SJ_mass_JEC = new TH1F("h_SJ_mass_JEC","superjet mass (JEC nom);Mass [GeV]; Events / 100 GeV",40,0.,4000);
std::cout << nentries << std::endl;
for (Int_t i=0;i<nentries;i++)
{
t1->GetEntry(i);
h_SJ_mass_JEC->Fill(superJet_mass[0]);
h_SJ_mass_JEC->Fill(superJet_mass[1]);
}
outFile.Write();
}
void extractHistsFromTree()
{
std::vector<std::string> inFileNames = {
"/home/ethan/Documents/rootFiles/ClusteringAlgorithmBR_JECup_output.root",
"/home/ethan/Documents/rootFiles/ClusteringAlgorithmBR_data_output.root",
"/home/ethan/Documents/rootFiles/ClusteringAlgorithmBR_JECdown_output.root"};//,
std::vector<std::string> outFileNames = {
"/home/ethan/Documents/rootFiles/processedRootFiles/ClusteringAlgorithmBR_JECup_output_processed.root",
"/home/ethan/Documents/rootFiles/processedRootFiles/ClusteringAlgorithmBR_data_output_processed.root",
"/home/ethan/Documents/rootFiles/processedRootFiles/ClusteringAlgorithmBR_JECdown_output_processed.root"};//,
std::vector<std::string> treeName = {"clusteringAnalyzerAll/tree_JEC_up","clusteringAnalyzerAll/tree_","clusteringAnalyzerAll/tree_JEC_down"};
for(unsigned int iii = 0; iii<inFileNames.size(); iii++)
{
doThings(inFileNames[iii],outFileNames[iii], treeName[iii]);
}
std::cout << "Finished with "<< inFileNames.size() << " files." << std::endl;
}
//look at nBtag plots ...