NtupleReader/src/MyDatasetInfo.cxx

00001 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00002 // 09/2007, AUTHOR: Mandfred Groh, Steffen Kaiser
00003 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00004 
00005 // standard C++ //
00006 #include <iostream>
00007 #include <fstream>
00008 
00009 // STL //
00010 #include <string>
00011 
00012 // ROOT //
00013 #include "TObjString.h"
00014 
00015 // NtupleReader reader //
00016 #include "NtupleReader/MyDatasetInfo.h"
00017 
00018 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
00019 //:: IMPLEMENTATION OF METHODS DEFINED IN THE CLASS MyDatasetInfo ::
00020 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
00021 
00022 //::::::::::::::::::::::::
00023 //:: NAMESPACE SETTINGS ::
00024 //::::::::::::::::::::::::
00025 
00026 using namespace std;
00027 
00028 //*****************************************************************************
00029 
00030 //::::::::::::::::::::::::::::::::
00031 //:: METHOD set/get_AtlFastFlag ::
00032 //::::::::::::::::::::::::::::::::
00033 
00034 void MyDatasetInfo::set_AtlFastFlag(const bool & flag){
00035     
00036     m_atlfastflag = flag;
00037 }
00038 
00039 bool MyDatasetInfo::get_AtlFastFlag(void) const {
00040     
00041     return m_atlfastflag;
00042 }
00043 
00044 //*****************************************************************************
00045 
00046 //::::::::::::::::::::::::::::::::::
00047 //:: METHOD set/get_trackjet_flag ::
00048 //::::::::::::::::::::::::::::::::::
00049 
00050 void MyDatasetInfo::set_trackjet_flag(const bool & flag){
00051     
00052     m_trackjetflag = flag;
00053 }
00054 
00055 bool MyDatasetInfo::get_trackjet_flag(void) const {
00056     
00057     return m_trackjetflag;
00058 }
00059 
00060 //*****************************************************************************
00061 
00062 //::::::::::::::::::::::::::::::::
00063 //:: METHOD set/get_vertex_flag ::
00064 //::::::::::::::::::::::::::::::::
00065 
00066 void MyDatasetInfo::set_vertex_flag(const bool & flag){
00067     
00068     m_vertexflag = flag;
00069 }
00070 
00071 bool MyDatasetInfo::get_vertex_flag(void) const {
00072     
00073     return m_vertexflag;
00074 }
00075 
00076 //*****************************************************************************
00077 
00078 //::::::::::::::::::::::::::::
00079 //:: METHOD set/get_release ::
00080 //::::::::::::::::::::::::::::
00081 
00082 void MyDatasetInfo::set_release(const int & release){
00083     
00084     m_release = release;
00085 }
00086 
00087 int MyDatasetInfo::get_release(void) const {
00088     
00089     return m_release;
00090 }
00091 
00092 //*****************************************************************************
00093 
00094 //:::::::::::::::::::::::::::::::
00095 //:: METHOD set/get_svnversion ::
00096 //:::::::::::::::::::::::::::::::
00097 
00098 void MyDatasetInfo::set_svnversion(const int & svnversion){
00099     
00100     m_svnversion = svnversion;
00101 }
00102 
00103 int MyDatasetInfo::get_svnversion(void) const {
00104     
00105     return m_svnversion;
00106 }
00107 
00108 //*****************************************************************************
00109 
00110 //::::::::::::::::::::::::::
00111 //:: METHOD set/get_scale ::
00112 //::::::::::::::::::::::::::
00113 
00114 void MyDatasetInfo::set_scale(const double & scale){
00115     
00116     m_scale = scale;
00117 }
00118 
00119 double MyDatasetInfo::get_scale(void) const {
00120     
00121     return m_scale;
00122 }
00123 
00124 //*****************************************************************************
00125 
00126 //::::::::::::::::::::::
00127 //:: METHOD set_TFile ::
00128 //::::::::::::::::::::::
00129 
00130 void MyDatasetInfo::set_TFile(TFile* aan_file) {
00131         
00132     m_aan_file = aan_file;
00133     return;
00134 
00135 }
00136 
00137 //*****************************************************************************
00138 
00139 //:::::::::::::::::::::::::
00140 //:: METHOD get_aan_file ::
00141 //:::::::::::::::::::::::::
00142 
00143 TFile* 
00144 MyDatasetInfo::get_aan_file(void) const {
00145 
00146     if (m_aan_file==NULL){
00147         cout << "Error In DatasetInfo: TFile not found!"<<endl;
00148     }
00149     return m_aan_file;
00150 
00151 }
00152 
00153 //*****************************************************************************
00154 
00155 //:::::::::::::::::::::
00156 //:: METHOD get_tree ::
00157 //:::::::::::::::::::::
00158 
00159 TTree* 
00160 MyDatasetInfo::get_tree(string tree_name){
00161    
00162     if (m_aan_file==NULL){
00163         cout << "In DatasetInfo: TFile not found!"<<endl;
00164         return NULL;
00165     }
00166 
00167     TTree* tmp_tree = NULL;
00168     tmp_tree = (TTree*)m_aan_file->Get(tree_name.c_str());
00169     if (tmp_tree==NULL){
00170         cout<<"In DatasetInfo: TTree with name "<<endl
00171             <<tree_name<<" not found!"<<endl;
00172         //exit(1);
00173     }
00174     
00175     return tmp_tree;
00176 
00177   }
00178 
00179 //*****************************************************************************
00180 
00181 //::::::::::::::::::::::::::
00182 //:: METHOD get_generator ::
00183 //::::::::::::::::::::::::::
00184 
00185 string 
00186 MyDatasetInfo::get_generator(){
00187 
00188     TString path       = "unknown";
00189     TString aod_file   = "unknown";
00190     TString tmp_gen    = "unknown";
00191     //TTree* tmp_tree    = (TTree*)m_aan_file->Get("aod_file_collection");
00192     TTree* tmp_tree    = get_tree("aod_file_collection");
00193     Int_t n_generators = 0;
00194 
00195     // if AOD filename tree is not in the aan file
00196     if (tmp_tree==NULL){
00197         cerr<<"In DatasetInfo: TTree \"aod_file_collection\" not found!"<<endl
00198             <<"=> Can not determine generator!"<<endl;
00199     }
00200     // get the AOD filename
00201     else{
00202         char ch_array_helper[250];
00203         tmp_tree->SetBranchAddress("aod_files",&ch_array_helper);
00204         tmp_tree->GetEntry(0);
00205         path = ch_array_helper;
00206     }
00207     //cout << "path:" << path <<  endl;
00208 
00209     TObjArray*  TOarray  = path.Tokenize("/");
00210     TObjString* TOstring = (TObjString*)TOarray->Last();
00211     aod_file = TOstring->GetString();
00212     aod_file = path;
00213     aod_file.ToLower();
00214     delete TOarray; 
00215     // cout << "aod_file:" << aod_file << endl;
00216         
00217     // look for a known generator name in the filename
00218     if (aod_file.Contains("herwig")){
00219         tmp_gen += "Herwig";
00220         n_generators++;
00221     }
00222     if (aod_file.Contains("alpgen")){
00223         tmp_gen += "Alpgen";
00224         n_generators++;
00225     }
00226     if (aod_file.Contains("mcatnlo")){
00227         tmp_gen += "McAtNlo";
00228         n_generators++;
00229     }
00230     if (aod_file.Contains("pythia")){
00231         tmp_gen += "Pythia";
00232         n_generators++;
00233     }
00234     if (aod_file.Contains("sherpa")){
00235         tmp_gen += "Sherpa";
00236         n_generators++;
00237     }
00238     if (aod_file.Contains("jimmy_susy")){
00239         tmp_gen += "jimmy_susy";
00240         n_generators++;
00241     }
00242     if (aod_file.Contains("A10")||aod_file.Contains("a3")){
00243         cout <<"ASD1"<<endl;
00244         tmp_gen += "Pythia";
00245         n_generators++;
00246     }
00247 
00248     //if generator was found remove "unknown"
00249     if(!tmp_gen.EndsWith("unknown")){
00250         tmp_gen.ReplaceAll("unknown","");
00251     }
00252     
00253     if(n_generators>1){
00254         cout << endl
00255              << "Warning In DatasetInfo: More then one generator found in" << endl
00256              << "\tfile:      " << aod_file << endl
00257              << "\tgenerator: " << tmp_gen  << endl
00258              << endl;
00259     }
00260 
00261     return string(tmp_gen);
00262 
00263 }

Generated on Tue Oct 21 11:50:45 2008 for NtupleAnalysis by  doxygen 1.5.1