23 |
|
//Fill object PlotTool with Chains constructed from files from given source |
24 |
|
int PlotTool::init(string fileName, string dirPath, string treeName) |
25 |
|
{ |
26 |
+ |
this->New( this->GetEntries() ); |
27 |
+ |
int currChain = this->GetEntries() - 1; |
28 |
+ |
|
29 |
+ |
if(currChain < 0 ) return currChain; |
30 |
+ |
|
31 |
|
//make file for tree friends (adding additional, computed branches) |
32 |
|
string friendFileName("/scratch/hh/lustre/cms/user/thomsen/temp/"); |
33 |
|
friendFileName += fileName; |
34 |
|
friendFileName += ".root"; |
35 |
|
TFile *f = new TFile(friendFileName.c_str(),"recreate"); |
36 |
< |
TTree *friendTree = new TTree("friendTree","friendTree"); |
36 |
> |
string friendTreeName("friendTree"); |
37 |
> |
//char number = currChain; |
38 |
> |
//friendTreeName += number; |
39 |
> |
//TTree *friendTree = new TTree("friendTree","friendTree"); |
40 |
> |
TTree *friendTree = new TTree(friendTreeName.c_str(),friendTreeName.c_str()); |
41 |
|
|
42 |
+ |
fileNames.clear(); |
43 |
|
|
44 |
|
|
35 |
– |
this->New( this->GetEntries() ); |
36 |
– |
int currChain = this->GetEntries() - 1; |
37 |
– |
|
38 |
– |
if(currChain < 0 ) return currChain; |
39 |
– |
|
45 |
|
|
46 |
|
((TChain*) this->At(currChain))->SetName(fileName.c_str()); |
47 |
|
TSystemDirectory dir("sourceDir",dirPath.c_str()); |
89 |
|
TrackJetKT = new float [100]; |
90 |
|
fwlite::ChainEvent ev(fileNames); |
91 |
|
|
92 |
< |
TBranch *BnJetsKT = friendTree->Branch("nJetsKT", &nJetsKT, "nJetsKT/I"); |
93 |
< |
TBranch *BTrackJetKT = friendTree->Branch("TrackJetKT", TrackJetKT, "TrackJetKT[nJetsKT]/F"); |
89 |
< |
//TBranch *BnJetsKT = ((TChain*) this->At(currChain))->Branch("nJetsKT", &nJetsKT, "nJetsKT/I"); |
90 |
< |
//TBranch *BTrackJetKT = ((TChain*) this->At(currChain))->Branch("TrackJetKT", TrackJetKT, "TrackJetKT[nJetsKT]/F"); |
91 |
< |
|
92 |
> |
friendTree->Branch("nJetsKT", &nJetsKT, "nJetsKT/I"); |
93 |
> |
friendTree->Branch("TrackJetKT", TrackJetKT, "TrackJetKT[nJetsKT]/F"); |
94 |
|
|
95 |
|
cout<<"calculating additional variables..."<<endl; |
96 |
|
for( ev.toBegin();! ev.atEnd();++ev) { |
115 |
|
TrackJetKT[nJetsKT] = trackSum; |
116 |
|
nJetsKT++; |
117 |
|
} |
118 |
< |
//((TChain*) this->At(currChain))->FindBranch("nJetsKT")->Fill(); |
117 |
< |
//((TChain*) this->At(currChain))->FindBranch("TrackJetKT")->Fill(); |
118 |
< |
BnJetsKT->Fill(); |
119 |
< |
BTrackJetKT->Fill(); |
118 |
> |
friendTree->Fill(); |
119 |
|
} |
120 |
|
f->cd(); |
121 |
|
friendTree->Write(); |
122 |
< |
((TChain*) this->At(currChain))->AddFriend("friendTree",f); |
123 |
< |
|
122 |
> |
f->Close(); |
123 |
> |
((TChain*) this->At(currChain))->AddFriend(friendTreeName.c_str(),friendFileName.c_str()); |
124 |
> |
|
125 |
|
return this->GetEntries(); |
126 |
|
|
127 |
|
} |