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.11 by tschum, Mon Dec 7 14:02:01 2009 UTC vs.
Revision 1.12 by tschum, Tue Dec 8 10:04:35 2009 UTC

# Line 17 | Line 17 | PlotTool::PlotTool() {
17          addTrackJets = false;
18          verbose = true;
19  
20 +        globalCuts="";
21 +
22   }
23  
24   //------------------------------------------------------------------
# Line 281 | Line 283 | int PlotTool::plot(int chainIndex, strin
283  
284  
285          //Draw histogram:
286 <        int draw_err = ((TChain*) this->At(chainIndex))->Draw(histName.c_str(), cutName.c_str(),
286 >        string cutNameWithGlobal = cutName;
287 >        if(cutName!="" && globalCuts!="")    cutNameWithGlobal += "&&";
288 >        if(globalCuts!="")                   cutNameWithGlobal += globalCuts;
289 >
290 >        int draw_err = ((TChain*) this->At(chainIndex))->Draw(histName.c_str(), cutNameWithGlobal.c_str(),
291                          currOpt.c_str(), currN);
292          if (draw_err < 0)
293                  return draw_err;
# Line 309 | Line 315 | int PlotTool::plot(int chainIndex, strin
315          }
316  
317  
318 <        if(verbose) {
318 >        if(verbose && draw_err > 0) {
319            timer.Stop();
320 <          cout<<"Done: "<<currN<<" events."<<endl;
320 >          cout<<"Done: Selected "<<draw_err<<" of total "<< currN <<" events."<<endl;
321            timer.Print();
322          }
323          return draw_err;
# Line 544 | Line 550 | void PlotTool::setMathLabels(TH1* thisHi
550          string x = thisHist->GetXaxis()->GetTitle();
551          string y = thisHist->GetYaxis()->GetTitle();
552  
553 <        if (t.find(".phi()") != string::npos)
554 <                t.replace(t.find(".phi()"), 6, " #phi");
553 > //      if (x.find("__") != string::npos)
554 > //        x = x.substr(0,x.find("__"));
555 > //      if (y.find("__") != string::npos)
556 > //        y = y.substr(0,y.find("__"));
557 >
558          if (x.find(".phi()") != string::npos)
559                  x.replace(x.find(".phi()"), 6, " #phi");
560          if (y.find(".phi()") != string::npos)
561                  y.replace(y.find(".phi()"), 6, " #phi");
562  
554        if (t.find(".eta()") != string::npos)
555                t.replace(t.find(".eta()"), 6, " #eta");
563          if (x.find(".eta()") != string::npos)
564                  x.replace(x.find(".eta()"), 6, " #eta");
565          if (y.find(".eta()") != string::npos)
566                  y.replace(y.find(".eta()"), 6, " #eta");
567  
568 <        if (t.find(".pt()") != string::npos)
569 <                t.replace(t.find(".pt()"), 5, " p_{T}");
568 >        if (x.find(".theta()") != string::npos)
569 >                x.replace(x.find(".theta()"), 6, " #theta");
570 >        if (y.find(".theta()") != string::npos)
571 >                y.replace(y.find(".theta()"), 6, " #theta");
572 >
573 >        if (x.find(".chi2()") != string::npos)
574 >                x.replace(x.find(".chi2()"), 7, " #chi^{2}");
575 >        if (y.find(".chi2()") != string::npos)
576 >                y.replace(y.find(".chi2()"), 7, " #chi^{2}");
577 >
578          if (x.find(".pt()") != string::npos)
579 <                x.replace(x.find(".pt()"), 5, " p_{T}");
579 >                x.replace(x.find(".pt()"), 5, " p_{T} [GeV]");
580          if (y.find(".pt()") != string::npos)
581 <                y.replace(y.find(".pt()"), 5, " p_{T}");
581 >                y.replace(y.find(".pt()"), 5, " p_{T} [GeV]");
582 >
583 >        if (x.find(".et()") != string::npos)
584 >                x.replace(x.find(".et()"), 5, " E_{T} [GeV]");
585 >        if (y.find(".et()") != string::npos)
586 >                y.replace(y.find(".et()"), 5, " E_{T} [GeV]");
587 >
588 >        //splitlines for many cuts
589 >        string test1= "{" + globalCuts + "}";
590 >        string test2= "&&" + globalCuts;
591 >
592 >        if(t.find(test1) != string::npos) t.replace(t.find(test1),test1.length(),"");
593 >        if(t.find(test2) != string::npos) t.replace(t.find(test2),test2.length(),"");
594 >
595 >        if (t.find("{") != string::npos && t.find("#splitline") == string::npos) {
596 >          t.replace(t.find_last_of("{"), 1, "}{");
597 >          string t_old = t;
598 >          t = "#splitline{";
599 >          t +=  t_old;
600 >        }
601  
602          thisHist ->SetTitle(t.c_str());
603          thisHist->GetXaxis()->SetTitle(x.c_str());
# Line 698 | Line 732 | int PlotTool::saveCanvases(string name,
732  
733          int savedCanvs =0;
734  
701        TPostScript ps(namePs.c_str(),112);
702        TFile rt(nameRt.c_str(),"recreate");
735  
736          TIter next(gROOT->GetListOfCanvases());
737          TCanvas* canv;
738          while ((canv=(TCanvas*)next())) {
739 +          string modName = (*canv).GetName();
740 +          if(modName.find("{") != string::npos) modName = modName.substr(0,modName.find("{"));
741 +          (*canv).SetTitle( modName.c_str() );
742 +
743 +        }
744 +
745 +
746 +        TPostScript ps(namePs.c_str(),112);
747 +        TFile rt(nameRt.c_str(),"recreate");
748 +
749 +        next.Reset();
750 +        while ((canv=(TCanvas*)next())) {
751            ps.NewPage();
752 +
753 +
754 +          (*canv).Write();
755            (*canv).Draw();
756            (*canv).Update();
757 <          (*canv).Write();
757 >
758 >
759            ++savedCanvs;
760  
761          }
# Line 715 | Line 763 | int PlotTool::saveCanvases(string name,
763          ps.Close();
764          rt.Close();
765  
766 +
767 +        if(verbose && savedCanvs) {
768 +          cout<<"Saved file "<<rt.GetName()<<" with "<<savedCanvs<<" canvases."<<endl;
769 +          cout<<"Saved file "<<ps.GetName()<<" with "<<savedCanvs<<" pages."<<endl;
770 + }
771          return savedCanvs;
772  
773   }
# Line 733 | Line 786 | int PlotTool::clearCanvases()
786   int PlotTool::setVariables(string label)
787   {
788  
736  cout<<endl;
737  cout<<"****** Show Chain Information:"<<endl;
738
739
740  this->ls();
741
742  cout<<endl;
743  cout<<"We have "<<this->GetEntries()<<" TChains with following aliases set:"<<endl;
789          for (int i=0; i< this->GetEntries(); ++i) {
790            cout<<"--------------------------------"<<endl;
791            cout<<((TChain*) this->At(i))->GetName()<<endl;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines