00001 #ifndef COMMONSF_H
00002 #define COMMONSF_H
00003
00004 #include <string>
00005 #include <vector>
00006 #include <map>
00007 #include <assert.h>
00008 #include <iostream>
00009 #include <typeinfo>
00010
00011 #include "TROOT.h"
00012 #include "TClass.h"
00013 #include "TFile.h"
00014 #include "TGraph.h"
00015 #include "TH1F.h"
00016 #include "TH1D.h"
00017 #include "TObject.h"
00018 #include "TLorentzVector.h"
00019 #include "TKey.h"
00020 #include "TParameter.h"
00021
00022 namespace TauCorrUncert {
00023
00024 class CommonSF : public TObject
00025 {
00026
00027 public:
00028
00029 CommonSF(const std::string& sharepath,
00030 const std::string& sSFFileName,
00031 bool debug=false);
00032
00033 ~CommonSF();
00034
00035 protected:
00036
00037 std::string ConvertProngToString(int prongness);
00038 virtual std::string ConvertEtaToString(const float& fEta) = 0;
00039 typedef std::map<std::string, TH1F*> SFMAP;
00040 SFMAP* m_mSF;
00041 bool m_debug;
00042
00043 template<class T>
00044 void ReadInputs(TFile* f, std::map<std::string, T>* map)
00045 {
00046 if(!f || !f->IsOpen())
00047 {
00048 Fatal("ReadInputs", "Could not open %s", f->GetName());
00049 return;
00050 }
00051 assert(f->IsOpen());
00052 TKey *key;
00053 TIter next(f->GetListOfKeys());
00054 while ((key = (TKey*)next()))
00055 {
00056 TClass *cl = gROOT->GetClass(key->GetClassName());
00057 if (!cl->InheritsFrom("TH1"))
00058 continue;
00059 T obj = (T)key->ReadObj();
00060 obj->SetDirectory(0);
00061 (*map)[std::string(obj->GetName())] = obj;
00062 }
00063 Info("ReadInputs", "data loaded from %s", f->GetName());
00064 }
00065
00066 private:
00067 ClassDef(CommonSF, 1)
00068
00069 };
00070 }
00071
00072 #endif // COMMONSF_H