Пример #1
0
int main(int argc, char** argv){
    std::vector<std::pair<std::string,double> > myFileWeights;
    std::vector<bool> IsTtBar;
    std::string anaName;
    std::pair<std::string,double> inputNameWeight;
    inputNameWeight.first = "";
    inputNameWeight.second = 0.;
    double Luminosity = 0;
    double intialBeforePresel = 0;
    double XSec = 0;
    bool isTtBar = false;
    double doJES = 1.;

    MassAndResolution myMassResolution;
    myMassResolution.topMass = -1;
    myMassResolution.topRes = -1;
    myMassResolution.wMass = -1;
    myMassResolution.wRes = -1;

    double b1 = 1000.;
    double b2 = 100.;
    double b3 = 10.;

    double extFdata = -1.;
    
    for (int f = 1; f < argc; f++) {
        std::string arg_fth(*(argv + f));
//        cout<<"-------- "<< arg_fth<<endl;
        if (arg_fth == "out") {
          f++;
          std::string out(*(argv + f));
          anaName = string(out);
        }else if (arg_fth == "JES") {
          f++;
          std::string out(*(argv + f));
          doJES = atof(out.c_str());
        }else if (arg_fth == "WMass") {
          f++;
          std::string out(*(argv + f));
          myMassResolution.wMass = atof(out.c_str());
        }else if (arg_fth == "WRes") {
          f++;
          std::string out(*(argv + f));
          myMassResolution.wRes = atof(out.c_str());
        }else if (arg_fth == "TopMass") {
          f++;
          std::string out(*(argv + f));
          myMassResolution.topMass = atof(out.c_str());
        }else if (arg_fth == "TopRes") {
          f++;
          std::string out(*(argv + f));
          myMassResolution.topRes = atof(out.c_str());
        }else if (arg_fth == "b1") {
          f++;
          std::string out(*(argv + f));
          b1 = atof(out.c_str());
        }else if (arg_fth == "b2") {
          f++;
          std::string out(*(argv + f));
          b2 = atof(out.c_str());
        }else if (arg_fth == "b3") {
          f++;
          std::string out(*(argv + f));
          b3 = atof(out.c_str());
        }else if (arg_fth == "Fdata") {
          f++;
          std::string out(*(argv + f));
          extFdata = atof(out.c_str());
        }else if (arg_fth == "input") {
          f++;
          std::string in(*(argv + f));
          if(in == "Signal.root" || in == "OtherTtBar.root" || in == "0.9/FS_Signal_0.9.root" ||
             in == "1.1/FS_Signal_1.1.root" ||in == "0.9/FS_OtherTt_0.9.root" ||in == "1.1/FS_OtherTt_1.1.root")
              isTtBar = true;
          IsTtBar.push_back(isTtBar);
//          in ="/home/ajafari/rootfiles/TopTrees/7TeV/July10/SystematicSamples/FullSelection/JES"+in;
          in ="/home/ajafari/rootfiles/TopTrees/7TeV/July10/Skimmed/FullSelection/FS_ECalDriven_"+in;
          inputNameWeight.first = in;
//          cout<<inputNameWeight.first<<endl;
        }else if(arg_fth == "XSec"){
          f++;
          std::string Xsec(*(argv + f));
          XSec = atof(Xsec.c_str());
        }else if(arg_fth == "Lumi"){
          f++;
          std::string Lumi(*(argv + f));
          Luminosity = atof(Lumi.c_str());
        }else if(arg_fth == "Initial"){
          f++;
          std::string intialBeforePresel_(*(argv + f));
          intialBeforePresel = atof(intialBeforePresel_.c_str());
        }else if(arg_fth == "nextinput"){
          f++;
          inputNameWeight.second = (double)(XSec*Luminosity)/(double)intialBeforePresel;
          myFileWeights.push_back(inputNameWeight);
          intialBeforePresel = 0;
          XSec = 0;
          isTtBar = false;
          std::string in(*(argv + f));
          if(in == "Signal.root" || in == "OtherTtBar.root" || in == "0.9/FS_Signal_0.9.root" ||
             in == "1.1/FS_Signal_1.1.root" ||in == "0.9/FS_OtherTt_0.9.root" ||in == "1.1/FS_OtherTt_1.1.root")
              isTtBar = true;
          IsTtBar.push_back(isTtBar);
          in ="/home/ajafari/rootfiles/TopTrees/7TeV/July10/Skimmed/FullSelection/FS_ECalDriven_"+in;
//          in ="/home/ajafari/rootfiles/TopTrees/7TeV/July10/SystematicSamples/FullSelection/JES"+in;
          inputNameWeight.first = in;
//          cout<<inputNameWeight.first<<endl;
          inputNameWeight.second = 0.;
        }else if(arg_fth == "lastinput"){
          f++;
          inputNameWeight.second = (double)(XSec*Luminosity)/(double)intialBeforePresel;
          myFileWeights.push_back(inputNameWeight);
          break;
        }
    }
    ElectronCuts myElecCuts;
    myElecCuts.Pt = 30;
    myElecCuts.eta = 2.4; myElecCuts.ExLow = 1.442; myElecCuts.ExHigh = 1.56;
    myElecCuts.Id = "VBTF70"; myElecCuts.IdSecond = "VBTF95";
    myElecCuts.IsoType = "";
    myElecCuts.D0 = 0.02;
    myElecCuts.IsoCut = 0.1;

    JetCuts myJetCuts;
    myJetCuts.bTagAlgo = "TCHE"; myJetCuts.Pt = 30.; myJetCuts.eta = 2.4;
    myJetCuts.nCaloTower = 5;
    myJetCuts.EmfUp = 0.9; myJetCuts.EmfLow = 0.05;
    myJetCuts.fhpd = 1000.; myJetCuts.N90 = -1;
    myJetCuts.bTagCut = 4.;
//
//    MassAndResolution myMassResolution;
//    myMassResolution.topMass = 180.6;
//    myMassResolution.topRes = 3.462;
//    myMassResolution.wMass = 88.76;
//    myMassResolution.wRes = 10.73;
    if(myMassResolution.topMass == -1 ||myMassResolution.wRes == -1 ||myMassResolution.wMass == -1 ||myMassResolution.topRes == -1 )
        return -1;
    cout<<myMassResolution.topMass <<"\t"<<myMassResolution.topRes<<"\t"<<myMassResolution.wMass<<"\t"<<myMassResolution.wRes<<endl;
    bool ExtJets = true;
//
//
    PtWeightEffHandler * WeightHandler_1 = new PtWeightEffHandler("expo_1",1);
    WeightHandler_1->Condition = FunctionBtag_MC;
    WeightHandler_1->ResetConditionForAllProps();
    WeightHandler_1->set2Ds();
//////
    PtWeightEffHandler * WeightHandler_2 = new PtWeightEffHandler("expo_2",2);
    WeightHandler_2->Condition = FunctionBtag_MC;
    WeightHandler_2->ResetConditionForAllProps();
    WeightHandler_2->set2Ds();
////
    PtWeightEffHandler * WeightHandler_5 = new PtWeightEffHandler("landau_5",5);
    WeightHandler_5->Condition = FunctionBtag_MC;
    WeightHandler_5->ResetConditionForAllProps();
    WeightHandler_5->set2Ds();
////
    PtWeightEffHandler * WeightHandler_4 = new PtWeightEffHandler("landau_4",4);
    WeightHandler_4->Condition = FunctionBtag_MC;
    WeightHandler_4->ResetConditionForAllProps();
    WeightHandler_4->set2Ds();

        
//    MCAnalysis * myMCAnalysis = new MCAnalysis("FmcMC_Chi2Cut10000",50., 160.,160.,280.,/*chi2Cut*/10000.,/*topPtcut*/0.,
//    /*ExtJets*/ExtJets);
    DataAnalysis * myDataAnalysis = new DataAnalysis(("FdataData_"+anaName), b1, b2,b2,b3,/*chi2cut*/100000.,/*topPtcut*/0.,
    /*doAntiTag*/false,/*AntiTagCut*/1000.);
    MCAnalysis * myMCAnalysis = new MCAnalysis(string("FmcMC_"+anaName), b1, b2,b2,b3,/*chi2cut*/100000.,/*topPtcut*/0.);
    AnalysisHandler Fullanalysis("",/*dobTag*/false,/*doBtagDataLike*/false,/*ExtJets*/true,/*Lumi*/100.,
    myMassResolution,myElecCuts,myJetCuts,"minChi2");

    

    myDataAnalysis->AddWeighedHandlersToRightRegion(WeightHandler_1);
    myDataAnalysis->AddWeighedHandlersToRightRegion(WeightHandler_2);
    myDataAnalysis->AddWeighedHandlersToRightRegion(WeightHandler_4);
    myDataAnalysis->AddWeighedHandlersToRightRegion(WeightHandler_5);

//    myMCAnalysis->AddWeighedHandlersToRightRegion(WeightHandler_30);
//    myMCAnalysis->AddWeighedHandlersToRightRegion(WeightHandler_31);
//    myMCAnalysis->AddWeighedHandlersToRightRegion(WeightHandler_4);
//    myMCAnalysis->AddWeighedHandlersToRightRegion(WeightHandler_5);

    
    Fullanalysis.AddAnalysis(myDataAnalysis);
    Fullanalysis.AddAnalysis(myMCAnalysis);
    Fullanalysis.setVerbosity(0);

    for(uint nf = 0; nf < myFileWeights.size(); nf++){
        std::string fname = myFileWeights.at(nf).first;
        cout<<fname<<endl;
        double weight = myFileWeights.at(nf).second;
        cout<<weight<<endl;
        TFile * F = new TFile(myFileWeights.at(nf).first.c_str(),"read");
        if(F == NULL)
            cout<<"Bad file pointer"<<endl;
        TTree* runTree = (TTree*) F->Get("runTree");
        TTree* eventTree = (TTree*) F->Get("eventTree");
        PracticalEvent * pracEvt = NULL;
        if(IsTtBar.at(nf))
            pracEvt = new PracticalEvent(eventTree,runTree,true);
        else
            pracEvt = new PracticalEvent(eventTree,runTree);
        int i = 0;

        while (pracEvt->Next()){
            i++;
////            cout<<"event number : "<<i<<endl;
            Fullanalysis.Analyze(pracEvt,weight,doJES);
//            if(i == 100)
//                break;
        }
    }
    double Fmc = myMCAnalysis->getF();
    double Fdata = myDataAnalysis->getF();
    if(extFdata != -1.){
        Fullanalysis.setAnalysisNonTrivialF(1,extFdata);
        Fdata = extFdata;
    }
    Fullanalysis.End();
    cout<<"\t\t--------------------------------"<<endl;
    cout<<"\t\tFmc = "<<Fmc<<endl;
    cout<<"\t\tFdata = "<<Fdata<<endl;
//    cout<<"\t\tFdata_RW = "<<Fullanalysis.f.at(0)<<endl;
    cout<<"\t\t--------------------------------"<<endl;

    return 0;
};
Пример #2
0
int main(){
    TFile * F = new TFile("/home/ajafari/rootfiles/TopTrees/7TeV/July10/Skimmed/FullSelection/FS_ECalDriven_Signal.root","read");
//    TFile * F = new TFile("/tmp/ajafari/FullSelection/FS_ECalDriven_Signal.root","read");
//    TFile * F = new TFile("/tmp/ajafari/FS_ECalDriven_Signal.root","read");
    TTree* runTree = (TTree*) F->Get("runTree");
    TTree* eventTree = (TTree*) F->Get("eventTree");
    PracticalEvent pracEvt(eventTree,runTree,true);
    
    ElectronCuts myElecCuts;
    myElecCuts.Pt = 30;
    myElecCuts.eta = 2.4; myElecCuts.ExLow = 1.442; myElecCuts.ExHigh = 1.56;
    myElecCuts.Id = "VBTF70"; myElecCuts.IdSecond = "VBTF95";
    myElecCuts.IsoType = "";
    myElecCuts.D0 = 0.02;
    myElecCuts.IsoCut = 0.1;

    JetCuts myJetCuts;
    myJetCuts.bTagAlgo = "TCHE"; myJetCuts.Pt = 30.; myJetCuts.eta = 2.4;
    myJetCuts.nCaloTower = 5;
    myJetCuts.EmfUp = 0.9; myJetCuts.EmfLow = 0.05;
    myJetCuts.fhpd = 1000.; myJetCuts.N90 = -1;
    myJetCuts.bTagCut = 4.;

    MassAndResolution myMassResolution;
    myMassResolution.topMass = 180.6;
    myMassResolution.topRes = 3.462;
    myMassResolution.wMass = 88.76;
    myMassResolution.wRes = 10.73;
    
//    MCAnalysis * myMCAnalysis = new MCAnalysis("FmcMC",50., 160.,160.,280.);
    MCAnalysis * myMCAnalysis = new MCAnalysis("FmcMC",60., 160.,160.,280.);
//    MCAnalysis * myMCAnalysis_Fdata = new MCAnalysis("FdataMC",50., 160.,160.,280.);
    MCAnalysis * myMCAnalysis_Fdata = new MCAnalysis("FdataMC",60., 160.,160.,280.);
//    DataAnalysis * myDataAnalysis = new DataAnalysis("FdataDATA",50., 160.,160.,280.);
    DataAnalysis * myDataAnalysis = new DataAnalysis("FdataDATA",60., 160.,160.,280.);

    AnalysisHandler Signalanalysis("SignalStudy_60-160-280",/*dobtag*/false,/*doBtagDataLike*/false,/*extJetOk_*/true,/*Lumi*/100.,
    myMassResolution,myElecCuts,myJetCuts,/*whichMethod*/"minChi2");
    Signalanalysis.AddAnalysis(myMCAnalysis);
    Signalanalysis.AddAnalysis(myMCAnalysis_Fdata);
    Signalanalysis.AddAnalysis(myDataAnalysis);
    Signalanalysis.setOnly4MatchedJets();
    Signalanalysis.setVerbosity(0);
    
    int i = 1;

    while (pracEvt.Next()){
//        cout<<"-----------------------------------------------------------------------------------event number : "<<i<<endl;
        Signalanalysis.Analyze(&pracEvt,1.);
        i++;
//        if(i == 200)
//            break;
    }
    double Fmc = myMCAnalysis->getF();
    double Fdata = myDataAnalysis->getF();
    Signalanalysis.setAnalysisNonTrivialF(2,2.83644);// no reweighing
//    Signalanalysis.setAnalysisNonTrivialF(2,Fdata);
    Signalanalysis.End();
    cout<<"\t\t--------------------------------"<<endl;
    cout<<"\t\tFmc = "<<Fmc<<endl;
    cout<<"\t\tFdata = "<<Fdata<<endl;
    cout<<"\t\t--------------------------------"<<endl;

    return 0;
};