ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/tschum/FWlite_Analysis/PlotTool.cc
(Generate patch)

Comparing UserCode/tschum/FWlite_Analysis/PlotTool.cc (file contents):
Revision 1.4 by thomsen, Wed Nov 18 14:53:42 2009 UTC vs.
Revision 1.5 by thomsen, Fri Nov 20 10:52:48 2009 UTC

# Line 23 | Line 23 | PlotTool::PlotTool()
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());
# Line 84 | Line 89 | int PlotTool::init(string fileName, stri
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) {
# Line 113 | Line 115 | int PlotTool::init(string fileName, stri
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   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines