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.9 by tschum, Thu Dec 3 11:24:14 2009 UTC vs.
Revision 1.11 by tschum, Mon Dec 7 14:02:01 2009 UTC

# Line 14 | Line 14 | PlotTool::PlotTool() {
14  
15          showLegend = false;
16          logY = true;
17 <        addTrackJets = true;
17 >        addTrackJets = false;
18          verbose = true;
19  
20   }
# Line 41 | Line 41 | int PlotTool::init(string fileName, stri
41                  fileLabel=fileName;
42          }
43          ((TChain*) this->At(currChain))->SetName(fileLabel.c_str());
44 +
45 +        TList *files = new TList();
46 +        TSystemFile* sysFile = 0;
47 +        if(fileName.find(".") != string::npos) {
48 +          ifstream f(fileName.c_str());
49 +          if( ! f.is_open() ) return -1;
50 +          string line;
51 +
52 +          while (!f.eof()) {
53 +            getline(f,line);
54 +            sysFile = new TSystemFile(line.c_str(),dirPath.c_str());
55 +            files->Add(sysFile);
56 +          }
57 +
58 +
59 +        } else {
60          TSystemDirectory dir("sourceDir", dirPath.c_str());
61 <        TList *files = dir.GetListOfFiles();
62 <        if (files) {
61 >        files = dir.GetListOfFiles();
62 >        }
63 >        if (files->GetEntries()>0) {
64                  TIter next(files);
65                  TSystemFile *file;
66                  TString fname;
67                  string filePath;
68  
69 <                if(verbose)     cout<<"Open"<<dirPath.c_str()<<" Search for .root files that contain: "
69 >                if(verbose && fileName.find(".") == string::npos )      cout<<"Open"<<dirPath.c_str()<<" Search for .root files that contain: "
70 >                                <<fileName.c_str()<<endl;
71 >                if(verbose && fileName.find(".") != string::npos )      cout<<"Open"<<dirPath.c_str()<<" Search lines with .root in: "
72                                  <<fileName.c_str()<<endl;
73  
74 +
75                  while ((file=(TSystemFile*)next())) {
76                          fname = file->GetName();
77                          if (!fname.EndsWith(".root"))
78                                  continue;
79 <                        if (!fname.Contains(fileName.c_str()))
79 >                        if (!fname.Contains(fileName.c_str()) && fileName.find(".") == string::npos )
80                                  continue;
81  
82                          filePath = dirPath;
# Line 197 | Line 217 | int PlotTool::plot(int chainIndex, strin
217                  return -1;
218  
219          TStopwatch timer;
220 <        timer.Start();
220 >        if(verbose) {
221 >          cout<<"Plot: "<<histName<<" "<<cutName<<" from chain "<<this->At(chainIndex)->GetName()<<endl;
222 >          timer.Start();
223 >        }
224  
225          int currN = nEntries;
226          if (nEntries < 0)
# Line 285 | Line 308 | int PlotTool::plot(int chainIndex, strin
308                          setCanvas( pads_[currPadName.str()] );
309          }
310  
311 <        timer.Stop();
311 >
312          if(verbose) {
313 <          cout<<"Done: "<<currN<<" events in "<<histName<<" "<<cutName<<" from chain "<<this->At(chainIndex)->GetName()<<endl;
313 >          timer.Stop();
314 >          cout<<"Done: "<<currN<<" events."<<endl;
315            timer.Print();
316          }
317          return draw_err;
# Line 695 | Line 719 | int PlotTool::saveCanvases(string name,
719  
720   }
721   //------------------------------------------------------------------
722 < void PlotTool::showChainInfo()
722 >
723 > int PlotTool::clearCanvases()
724   {
725  
726 +  while(gROOT->GetListOfCanvases()->GetEntries()) ((TCanvas*) gROOT->GetListOfCanvases()->At(0))->Close();
727 +  pads_.clear();
728 +  autoVars.clear();
729 +  return pads_.size() + gROOT->GetListOfCanvases()->GetEntries();
730 +
731 + }
732 + //------------------------------------------------------------------
733 + int PlotTool::setVariables(string label)
734 + {
735  
736    cout<<endl;
737    cout<<"****** Show Chain Information:"<<endl;
# Line 708 | Line 742 | void PlotTool::showChainInfo()
742    cout<<endl;
743    cout<<"We have "<<this->GetEntries()<<" TChains with following aliases set:"<<endl;
744          for (int i=0; i< this->GetEntries(); ++i) {
745 <          cout<<endl;
745 >          cout<<"--------------------------------"<<endl;
746            cout<<((TChain*) this->At(i))->GetName()<<endl;
747 <          ((TChain*) this->At(i))->GetListOfAliases()->ls();
747 >          cout<<"------------"<<endl;
748  
749 <        }
749 >          TList* leaves = (TList*) ((TChain*) this->At(i))->GetListOfLeaves();
750 >          for (int j=0; j< leaves->GetEntries(); ++j) {
751 >            TString leafName ( leaves->At(j)->GetName() );
752 >            if(! leafName.EndsWith(".") ) continue;
753 >            if(! leafName.Contains(label.c_str() ) ) continue;
754 >
755 >            TClass cl( ( (TLeafElement*) leaves->At(j) )->GetTypeName() );
756 >            cout<<"++++++"<<endl;
757 >            cout<< leafName.Data() <<endl;
758 >            for(int k=0;k<cl.GetListOfAllPublicMethods()->GetEntries();++k) {
759 >              string typeName ( ((TMethod*) cl.GetListOfAllPublicMethods()->At(k))->GetReturnTypeName() );
760 >              string methName ( cl.GetListOfAllPublicMethods()->At(k)->GetName() );
761 >              if( methName != "product") continue;
762 >                cout<< typeName <<endl;
763 >                string _type;
764 >                TString testString( typeName.c_str() );
765 >                if( testString.BeginsWith("vector<") ) {
766 >                  _type = typeName.substr(typeName.find("<")+1,typeName.find(">")-typeName.find("<")-1);
767 >                  string _varSize = leafName.Data();
768 >                  _varSize += "obj@.size()";
769 >                  autoVars.push_back( _varSize );
770 >                  }
771 >                else _type = typeName.substr(0,typeName.find("*"));
772 >                  TClass _cl( _type.c_str() );
773 >                  for(int l=0;l<_cl.GetListOfAllPublicMethods()->GetEntries();++l) {
774 >                    string _typeName ( ((TMethod*) _cl.GetListOfAllPublicMethods()->At(l))->GetReturnTypeName() );
775 >                    string _methName ( _cl.GetListOfAllPublicMethods()->At(l)->GetName() );
776 >                    //              if(_typeName.find("void") != string::npos ) continue;
777 >                    //              cout<<"   "<<_typeName<<"  "<<_methName<<endl;
778 >
779 >                    cout<<" "<<_typeName<<"  "<<_methName<<endl;
780 >                    if(_methName.find("operator")==string::npos&&(_typeName=="float"||_typeName=="double"||_typeName=="int"||_typeName=="unsigned int"||_typeName=="bool"||_typeName=="unsigned short"||_typeName=="unsigned long"||_typeName=="unsigned long long")) {
781 >
782 >                      cout<<"-->   "<<_typeName<<"  "<<_methName<<endl;
783 >
784 >                      string  _varName = leafName.Data();
785 >                      _varName += "obj.";
786 >                      _varName += _methName;
787 >                      _varName += "()";
788 >                      autoVars.push_back( _varName );
789 >                    }
790 >                  }
791 >                  
792 >              
793 >            }
794  
795 +          }
796 +
797 +        }
798  
799 +        return autoVars.size();
800  
801   }
802   //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines