ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/RateMonShiftTool_dev/dumpToPDF.C
(Generate patch)

Comparing UserCode/RateMonShiftTool_dev/dumpToPDF.C (file contents):
Revision 1.2 by fantasia, Mon May 7 14:27:47 2012 UTC vs.
Revision 1.4 by abrinke1, Fri Oct 26 12:06:54 2012 UTC

# Line 1 | Line 1
1   //This script will take all the rate comparison plots from a
2   //root file and print them into a single pdf for easy viewing
3 < //Usage: root -b -l -q 'dumpToPDF.C("infile.root")'  
3 > //Usage: root -b -l -q 'dumpToPDF.C+("infile.root", "fitName")'  
4 >
5 > #include <iostream>
6 > #include "TFile.h"
7 > #include "TCanvas.h"
8 > #include "TKey.h"
9  
10   void
11   dumpToPDF(string inName, string fitName){
12    TFile *fin = TFile::Open(inName.c_str(), "read"); assert(fin);
13  
9
14    string outName = inName;
15    outName.replace(outName.find(".root"), 5, ".pdf");
16  
# Line 20 | Line 24 | dumpToPDF(string inName, string fitName)
24    int nplots = fin->GetNkeys();
25    int nfits = fFit->GetNkeys();
26    printf("nplots: %i, nfits: %i\n", nplots, nfits);
27 <  assert(nplots == nfits);
27 >  if(nplots != nfits){
28 >    cout<<" PDF output will be wrong since different number of triggers in fit and current run"<<endl;
29 >    if (nplots > nfits) {
30 >      cout<<"Quitting"<<endl;
31 >      abort();
32 >    }
33 >  }
34    TList* plots = fin->GetListOfKeys();  
35    TList* fits  = fFit->GetListOfKeys();
36 +  int offset = 0; //Assumes nfits >= nplots
37 +  std::string inPlotName = "";
38 +  std::string inFitName = "";
39    for(int i=0; i<nplots; ++i){
40 +
41      TKey* plot = (TKey*) plots->At(i);
42 <    TKey* fit = (TKey*) fits->At(i);//assume they're in the same order for now
42 >    TKey* fit = (TKey*) fits->At(i+offset);//assume they're in the same order for now
43  
44      if(!fin->GetKey(plot->GetName())){
45        cout<<"Didn't find "<<plot<<". Removing."<<endl;
# Line 35 | Line 49 | dumpToPDF(string inName, string fitName)
49        cout<<"Didn't find "<<fit<<". Removing."<<endl;
50        abort();
51      }
52 +    inPlotName = plot->GetName();
53 +    inFitName = fit->GetName();
54 +    inFitName.erase(inFitName.length()-17,inFitName.length());//Removes "rate_vs_delivered" from string
55 +
56 +    //std::cout << inPlotName << "  " << inFitName << std::endl;
57 +    while ((std::string::npos != inPlotName.find(inFitName)) == 0) { //While plot and fit names don't match
58 +      offset += 1;
59 +      fit = (TKey*) fits->At(i+offset);
60 +      if(!fFit->GetKey(fit->GetName())){
61 +        cout<<"Didn't find "<<fit<<". Removing."<<endl;
62 +        abort();
63 +      }
64 +      inFitName = fit->GetName();
65 +      inFitName.erase(inFitName.length()-17,inFitName.length());
66 +      //std::cout << inFitName << std::endl;
67 +    }
68 +      
69      TCanvas* c = new TCanvas();
70      c->Divide(1,2);
71  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines