Пример #1
0
void printJet(Jet *jet)
{

  GenParticle *particle;
  Muon *muon;

  Track *track;
  Tower *tower;

  TObject *object;
  TLorentzVector momentum;
      momentum.SetPxPyPzE(0.0, 0.0, 0.0, 0.0);
      //TRefArray constituentarray(jet->Constituents);
      TRefArray particlearray(jet->Particles);
      cout<<"Looping over jet constituents. Jet pt: "<<jet->PT<<", eta: "<<jet->Eta<<", phi: "<<jet->Phi<<endl;      

      // Loop over all jet's constituents
      for(Int_t j = 0; j < jet->Constituents.GetEntriesFast(); ++j)
      {
        object = jet->Constituents.At(j);
        // Check if the constituent is accessible
        if(object == 0) continue;

        if(object->IsA() == GenParticle::Class())
        {
          particle = (GenParticle*) object;
          cout << "    GenPart pt: " << particle->PT << ", eta: " << particle->Eta << ", phi: " << particle->Phi << endl;
          momentum += particle->P4();
        }
        else if(object->IsA() == Track::Class())
        {
          track = (Track*) object;
          cout << "    Track pt: " << track->PT << ", eta: " << track->Eta << ", phi: " << track->Phi << endl;
          momentum += track->P4();
        }
        else if(object->IsA() == Tower::Class())
        {
          tower = (Tower*) object;
          cout << "    Tower pt: " << tower->ET << ", eta: " << tower->Eta << ", phi: " << tower->Phi << endl;
          momentum += tower->P4();
        }
        else if(object->IsA() == Muon::Class())
        {
          muon = (Muon*) object;
          cout << "    Muon pt: " << muon->PT << ", eta: " << muon->Eta << ", phi: " << muon->Phi << endl;
          momentum += muon->P4();
        }
      }
      cout << " constituent sum pt:  " << momentum.Pt() <<" eta "<< momentum.Eta()  <<"  phi " << momentum.Phi() << std::endl;


      for (Int_t j =0; j<jet->Particles.GetEntries();  j++){
     		GenParticle *p_tmp = (GenParticle*) particlearray.At(j);
		printGenParticle(p_tmp);
	}
}
Пример #2
0
Muon::Muon( const Muon& copy){
  maptotree = copy.IndexInTree();
  p4 = copy.P4();
  id = copy.IDMap();

  charge = copy.Charge();
  pdgID = copy.PdgID();
  iso = copy.Iso();
  dz = copy.Dz();
}
Пример #3
0
int main(int argc, const char *argv[])
try
{
    GOOGLE_PROTOBUF_VERIFY_VERSION;

    if (2 > argc)
    {
        cerr << "Usage: " << argv[0] << " [events] output.pb" << endl;

        google::protobuf::ShutdownProtobufLibrary();

        return 1;
    }

    {
        int events = 100;
        boost::shared_ptr<Writer> writer;

        if (3 == argc)
        {
            events = boost::lexical_cast<uint32_t>(argv[1]);
            writer.reset(new Writer(argv[2], 10000));
        }
        else
            writer.reset(new Writer(argv[1]));

        writer->open();
        if (writer->isOpen())
        {
            writer->input()->set_type(Input::DATA);

            boost::shared_ptr<Event> event(new Event());
            boost::shared_ptr<TRandom> randomizer(new TRandom3());
            randomizer->SetSeed(time(0));

            cout << "Generate: " << events << " events" << endl;

            for(int i = 0; events > i; ++i)
            {
                for(int pv = 0, pvs = randomizer->Poisson(2); pvs > pv; ++pv)
                {
                    PrimaryVertex *pv = event->add_primary_vertices();

                    Vector *vertex = pv->mutable_vertex();

                    vertex->set_x(randomizer->Gaus(0, .3));
                    vertex->set_y(randomizer->Gaus(0, .5));
                    vertex->set_z(randomizer->Gaus(0, .7));
                }

                for(int j = 0, jets = randomizer->Poisson(5); jets > j; ++j)
                {
                    Jet *jet = event->add_jets();
                    LorentzVector *p4 = jet->mutable_physics_object()->mutable_p4();

                    p4->set_e(randomizer->Gaus(172, 10));
                    p4->set_px(randomizer->Gaus(100, 15));
                    p4->set_py(randomizer->Gaus(100, 20));
                    p4->set_pz(randomizer->Gaus(100, 25));

                    Vector *vertex = jet->mutable_physics_object()->mutable_vertex();

                    vertex->set_x(randomizer->Gaus(0, 5));
                    vertex->set_y(randomizer->Gaus(0, 4));
                    vertex->set_z(randomizer->Gaus(0, 3));
                }

                for(int m = 0, muons = randomizer->Poisson(10); muons > m; ++m)
                {
                    Muon *muon = event->add_pf_muons();
                    LorentzVector *p4 = muon->mutable_physics_object()->mutable_p4();

                    p4->set_e(randomizer->Gaus(.105, 0.005));
                    p4->set_px(randomizer->Gaus(10, 3));
                    p4->set_py(randomizer->Gaus(10, 2));
                    p4->set_pz(randomizer->Gaus(10, 1));

                    Vector *vertex = muon->mutable_physics_object()->mutable_vertex();

                    vertex->set_x(randomizer->Gaus(1, 2));
                    vertex->set_y(randomizer->Gaus(1, 3));
                    vertex->set_z(randomizer->Gaus(1, 4));
                }

                writer->write(event);

                event->Clear();
            }
        }
    }

    google::protobuf::ShutdownProtobufLibrary();

    return 0;
}
catch(...)
{
    cerr << "Unknown error" << endl;

    google::protobuf::ShutdownProtobufLibrary();
}
Пример #4
0
//void LeptonEnergy(const char *inputFile = "sourceFiles/LO/ttbar_LO_total.root")
void LeptonEnergy(const TString & file)
{

  //const char *inputFile = Form("/home/tjkim/work/pheno/topmass/sourceFiles/LO/fromSayaka/ttbar_%s.root",file.Data());
  //gSystem->Load("/export/apps/delphes//libDelphes");
  const char *inputFile = Form("/data/users/seohyun/analysis/ttbar_%s.root",file.Data());
  gSystem->Load("/home/seohyun/delphes/libDelphes.so");
/*
  TFile *f2 = TFile::Open("weightfunc2.root");
  TFile *f3 = TFile::Open("weightfunc3.root");
  TFile *f5 = TFile::Open("weightfunc5.root");
  TFile *f15 = TFile::Open("weightfunc15.root");

  const int nmass = 151;
  float mymass[ nmass ];
  float integral2[ nmass ];
  float integral3[ nmass ];
  float integral5[ nmass ];
  float integral15[ nmass ];
  for(int i=0; i < nmass ; i++){
    integral2[i] = 0.0;
    integral3[i] = 0.0;
    integral5[i] = 0.0;
    integral15[i] = 0.0;
  }

  TGraph * g2[nmass];
  TGraph * g3[nmass];
  TGraph * g5[nmass];
  TGraph * g15[nmass];

  TIter next(f2->GetListOfKeys());
  TKey *key;
  int i = 0;
  while( (key = (TKey*) next())) {
    TClass *cl = gROOT->GetClass( key->GetClassName());
    if( !cl->InheritsFrom("TGraph")) continue;
    g2[i] = (TGraph*) key->ReadObj();
    string mass = g2[i]->GetName(); 
    float temp = atof(mass.c_str()); 
    mymass[i] = temp;
    i++;
  }

  TIter next(f3->GetListOfKeys());
  i = 0;
  while( (key = (TKey*) next())) {
    TClass *cl = gROOT->GetClass( key->GetClassName());
    if( !cl->InheritsFrom("TGraph")) continue;
    g3[i] = (TGraph*) key->ReadObj();
    i++;
  }

  TIter next(f5->GetListOfKeys());
  i = 0;
  while( (key = (TKey*) next())) {
    TClass *cl = gROOT->GetClass( key->GetClassName());
    if( !cl->InheritsFrom("TGraph")) continue;
    g5[i] = (TGraph*) key->ReadObj();
    i++;
  }

  TIter next(f15->GetListOfKeys());
  i = 0;
  while( (key = (TKey*) next())) {
    TClass *cl = gROOT->GetClass( key->GetClassName());
    if( !cl->InheritsFrom("TGraph")) continue;
    g15[i] = (TGraph*) key->ReadObj();
    i++;
  } 

  TFile * res = TFile::Open("hist_LO_res_v3.root");
  TH1F * h_acc = (TH1F*) res->Get("h_totalacc_lepton"); 
*/

  //TFile* f = TFile::Open("hist_LO_res_60.root", "recreate");
  TFile* f = TFile::Open(Form("170717/hist_%s.root",file.Data()), "recreate");

  // Create chain of root trees
  TChain chain("Delphes");
  chain.Add(inputFile);
 
  // Create object of class ExRootTreeReader
  ExRootTreeReader *treeReader = new ExRootTreeReader(&chain);
  Long64_t numberOfEntries = treeReader->GetEntries();

  // Get pointers to branches used in this analysis
  TClonesArray *branchParticle = treeReader->UseBranch("Particle");
  TClonesArray *branchMuon = treeReader->UseBranch("Muon");
  TClonesArray *branchElectron = treeReader->UseBranch("Electron");
  TClonesArray *branchJet = treeReader->UseBranch("Jet");

  TClonesArray *branchEvent = treeReader->UseBranch("Event");
 
  GenParticle *particle;
  GenParticle *daughter1;
  GenParticle *daughter2;
  GenParticle *granddaughter1_1;
  GenParticle *granddaughter1_2;
  GenParticle *granddaughter2_1;
  GenParticle *granddaughter2_2;

  GenParticle *genelectron;
  GenParticle *genmuon;

  LHEFEvent * event;

  // Create TTree
  //Float_t Muon_E;
  //Float_t Electron_E;
  //Float_t Lepton_E;
  //Float_t Lepton_E_reco;
  //TTree * tree = new TTree("tree","lepton energy");
  //tree->Branch("Lepton_E",&Lepton_E,"Lepton_E/F"); 
  //tree->Branch("Lepton_E_reco",&Lepton_E_reco,"Lepton_E_reco/F"); 
  //tree->Branch("Muon_E",&Muon_E,"Muon_E/F"); 
  //tree->Branch("Electron_E",&Electron_E,"Electron_E/F"); 

  // Book histograms
  TH1 * channel = new TH1F("channel", "ttbar event categorization", 7, 0.0, 7.0);

  TH1 * h_muon_energy = new TH1F("h_muon_energy", "muon energy distribution", 5000, 0, 500);
  TH1 * h_electron_energy = new TH1F("h_electron_energy", "electron energy distribution", 5000, 0, 500);
  TH1 * h_lepton_energy = new TH1F("h_lepton_energy", "lepton energy distribution", 5000, 0, 500);

  //TH1 * h_muon_energy_acc = new TH1F("h_muon_energy_acc", "muon energy distribution", 5000, 0, 500);
  //TH1 * h_electron_energy_acc = new TH1F("h_electron_energy_acc", "electron energy distribution", 5000, 0, 500);
  TH1 * h_lepton_energy_acc = new TH1F("h_lepton_energy_acc", "lepton energy distribution", 5000, 0, 500);

  //TH1 * h_muon_energy_reco = new TH1F("h_muon_energy_reco", "muon energy distribution at RECO", 5000, 0, 500);
  //TH1 * h_electron_energy_reco = new TH1F("h_electron_energy_reco", "electron energy distribution at RECO", 5000, 0, 500);
  TH1 * h_lepton_energy_reco = new TH1F("h_lepton_energy_reco", "lepton energy distribution at RECO", 5000, 0, 500);
  TH2 * h2_lepton_energy_response = new TH2F("h2_lepton_energy_response", "lepton energy response", 5000, 0, 500,5000,0,500);

  //TH1 * h_muon_energy_reco_S2 = new TH1F("h_muon_energy_reco_S2", "muon energy distribution at RECO", 5000, 0, 500);
  //TH1 * h_electron_energy_reco_S2 = new TH1F("h_electron_energy_reco_S2", "electron energy distribution at RECO", 5000, 0, 500);
  //TH1 * h_lepton_energy_reco_S2 = new TH1F("h_lepton_energy_reco_S2", "lepton energy distribution at RECO", 5000, 0, 500);
  //TH1 * h_lepton_nbjets_reco_S2 = new TH1F("h_lepton_nbjets_reco_S2","number of b jets",5,0,5);

  //TH1 * h_muon_energy_reco_final = new TH1F("h_muon_energy_reco_final", "muon energy distribution at RECO", 5000, 0, 500);
  //TH1 * h_electron_energy_reco_final = new TH1F("h_electron_energy_reco_final", "electron energy distribution at RECO", 5000, 0, 500);
  TH1 * h_lepton_energy_reco_final = new TH1F("h_lepton_energy_reco_final", "lepton energy distribution at RECO", 5000, 0, 500);
  TH2 * h2_lepton_energy_final_response = new TH2F("h2_lepton_energy_final_response", "lepton energy response", 5000, 0, 500,5000,0,500);

  //std::vector<float> lepton_E;
  //std::vector<float> lepton_E_final;

  int ndileptonic = 0; //ee, mm, tautau
  int ndileptonic2 = 0; //ee, mm, tau->ee, mm
  int ndileptonic3 = 0; //ee, mm
  int nsemileptonic = 0;
  int nsemileptonic2 = 0;
  int nsemileptonic3 = 0;
  int nhadronic = 0;

  // Loop over all events
  for(Int_t entry = 0; entry < numberOfEntries; ++entry)
  {
    //if( entry == 100000) break;
    if( entry%1000 == 0) cout << "starting with " << entry << endl;
    // Load selected branches with data from specified event
    treeReader->ReadEntry(entry);
 
    int nmuons = 0;
    int nelectrons= 0;
    int ntaumuons = 0;
    int ntauelectrons= 0;
    int ntaus = 0 ;
    int nhadrons = 0 ;
    // If event contains at least 1 particle
    int ntop = 0;

    double genweight = 1.0;
    if(branchEvent->GetEntries() > 0)
    {

      event = (LHEFEvent * ) branchEvent->At(0);
      genweight = event->Weight;
      //cout << "event number = " << event->Number << endl;
      //cout << "event weight = " << event->Weight << endl;

    }

    //Lepton_E = -1.0;
    
    if(branchParticle->GetEntries() > 0)
    {
      
      for(int i = 0; i < branchParticle->GetEntriesFast() ; i++){
        if(ntop == 2) break;

        particle = (GenParticle *) branchParticle->At(i);
    
        int status = particle->Status; 

        bool LO = true;
        //if( LO ) cout << "THIS IS LO..." << endl;
        if( status != 3) continue;

        int id = particle->PID; 

        double gen_pt = particle->PT;
        double gen_eta = particle->Eta;
        //Leading order
        if( LO) {
          if( abs(id) == 11 ){
            genelectron = particle;
            double energy = genelectron->E;
            h_electron_energy->Fill( energy, genweight );
            h_lepton_energy->Fill( energy, genweight );
            //Lepton_E = energy;
            //for(int i=0; i < nmass; i++){
            //  float w = g2[i]->Eval( energy );
            //  integral2[i] = integral2[i] + w ;
            //}
            //lepton_E.push_back( energy );
            if( energy > 20 && fabs(gen_eta) < 2.4) {
              //h_electron_energy_acc->Fill( energy, genweight );
              h_lepton_energy_acc->Fill( energy, genweight );
              nmuons++;
            }
            //daughter1 = (GenParticle*) branchParticle->At( particle->D1);
            //daughter2 = (GenParticle*) branchParticle->At( particle->D2);
            //int d1_id = abs(daughter1->PID);
            //int d2_id = abs(daughter2->PID);
            //cout << "electron daughter  " << d1_id  << " , " << d2_id << endl;     
          }else if( abs(id) == 13 ){
            genmuon = particle;
            double energy = genmuon->E;
            h_muon_energy->Fill( energy, genweight );
            h_lepton_energy->Fill( energy, genweight );
            //Lepton_E = energy;
            //for(int i=0; i < nmass; i++){
            //  float w = g2[i]->Eval( energy );
            //  integral2[i] = integral2[i] + w ;
            //}
            //lepton_E.push_back( energy );
            if( energy > 20 && fabs(gen_eta) < 2.4) {
              //h_muon_energy_acc->Fill( energy, genweight );
              h_lepton_energy_acc->Fill( energy, genweight );
              nelectrons++;
            }
            //int d1_id = -1;
            //int d2_id = -1;
            //if( particle->D1 >= branchParticle->GetEntries()){
            //  daughter1 = (GenParticle*) branchParticle->At( particle->D1);
            //  int d1_id = abs(daughter1->PID);
            //}
            //if( particle->D1 >= branchParticle->GetEntries()){
            //  daughter1 = (GenParticle*) branchParticle->At( particle->D1);
            //  int d1_id = abs(daughter1->PID);
            //}
            //cout << "muon daughter  " << d1_id  << " , " << d2_id << endl;            
          }
        //NLO
        }else if( abs(id) == 6 ) {
          ntop++;
          particle = (GenParticle*) branchParticle->At( i ) ;
          if( particle->D1 >= branchParticle->GetEntries() ) continue;
          bool lasttop  =  false ;
          while( !lasttop ){
            if( particle->D1 >= branchParticle->GetEntries() ) break;
            GenParticle * d = (GenParticle *) branchParticle->At( particle->D1 );
            if( abs(d->PID) != 6 ) { 
              lasttop = true;
            }
            else { particle = d ; }
          } 

          if( particle->D1 >= branchParticle->GetEntries() || particle->D2 >= branchParticle->GetEntries() ){
           continue;
          }

          daughter1 = (GenParticle*) branchParticle->At( particle->D1) ;
          daughter2 = (GenParticle*) branchParticle->At( particle->D2) ;
  
 
          bool lastW = false;
          int d1_id = abs(daughter1->PID);
          int d2_id = abs(daughter2->PID);

          //cout << "top daughter  " << d1_id  << " , " << d2_id << endl;

          while( !lastW) {
            if( daughter1->D1 >= branchParticle->GetEntries() ) break;
            GenParticle * d = (GenParticle *) branchParticle->At( daughter1->D1 );
            if( abs(d->PID) != 24 ) { lastW = true; }
            else {
              daughter1 = d ;
            } 
          } 

          if( daughter1->D1 >= branchParticle->GetEntries() || daughter1->D2 >= branchParticle->GetEntries() ){
           continue;
          }

          granddaughter1_1 = (GenParticle*) branchParticle->At( daughter1->D1) ;
          granddaughter1_2 = (GenParticle*) branchParticle->At( daughter1->D2) ;
          granddaughter2_1 = (GenParticle*) branchParticle->At( daughter2->D1) ;
          granddaughter2_2 = (GenParticle*) branchParticle->At( daughter2->D2) ;    
 
          int gd1_1_id = abs(granddaughter1_1->PID);
          int gd1_2_id = abs(granddaughter1_2->PID);
          int gd2_1_id = abs(granddaughter2_1->PID);
          int gd2_2_id = abs(granddaughter2_2->PID);

          //cout << "W daughters = " << gd1_1_id << " , " << gd1_2_id << " , " << gd2_1_id << " , " << gd2_2_id << endl;
          int W_dau_status = granddaughter1_1->Status ;

          //if( gd1_1_id > gd1_2_id ) cout << "Something is WRONG ! " << endl;

          GenParticle * le = (GenParticle * ) branchParticle->At( granddaughter1_1->D1 );
          //GenParticle * leda = (GenParticle * ) branchParticle->At( le->D1);
          if( gd1_1_id == 11 || gd1_1_id == 13 ){
            cout << le->D1 << " , " << le->D2 << endl;
          //  cout << " original id and status = " << gd1_1_id << " , " <<  W_dau_status  << " le id and status = " << le->PID << " , " << le->Status <<  " leda id and status = " << leda->PID << " , " << leda->Status << endl;
          }

          if( gd1_1_id == 11 ) { 
            nelectrons++;
            //genelectron = granddaughter1_2;
            genelectron = le;
          }
          else if( gd1_1_id == 13 ) { 
            nmuons++;
            //genmuon = granddaughter1_2;
            genmuon = le;
          }
          else if( gd1_1_id == 15 ) {
            ntaus++;

            /*
            if( granddaughter1_2->D1 >= branchParticle->GetEntries() || granddaughter1_2->D2 >= branchParticle->GetEntries() ){
              continue;
            }

            GenParticle * taudaughter1 = (GenParticle*) branchParticle->At( granddaughter1_2->D1) ;
            GenParticle * taudaughter2 = (GenParticle*) branchParticle->At( granddaughter1_2->D2) ;
            int taud1_id = abs(taudaughter1->PID);
            int taud2_id = abs(taudaughter2->PID);

            //cout << "tau daughter = " << taud1_id << " " << taud2_id << endl;

            if( taud1_id == 11 || taud1_id == 12 ) ntauelectrons++;
            else if( taud1_id == 13 || taud1_id == 14 ) ntaumuons++;
            else if( taud1_id == 15 || taud1_id == 16 ) {
              if( taudaughter1->D1 >= branchParticle->GetEntries() || taudaughter1->D2 >= branchParticle->GetEntries() ){
              continue;
            }

              GenParticle * taugranddaughter1 = (GenParticle*) branchParticle->At( taudaughter1->D1) ;
              GenParticle * taugranddaughter2 = (GenParticle*) branchParticle->At( taudaughter1->D2) ;
              int taugd1_id = abs(taugranddaughter1->PID);
              int taugd2_id = abs(taugranddaughter2->PID);
              //cout << "tau grand daughter = " << taugd1_id << " " << taugd2_id << endl;
              if( taugd1_id == 11 || taugd1_id == 12 ) ntauelectrons++;
              else if( taugd1_id == 13 || taugd1_id == 14 ) ntaumuons++;
            ㅜㅜ  else { continue; }
          
            } else { continue; }
            */
          }else{
            nhadrons++;
          }
          //cout << "nelectrons = " << nelectrons << " nmuons = " << nmuons << " ntaus = " << ntaus << " nhadrons = " << nhadrons << endl;
        }
      }
    }
  
    if( LO ){


    }else{
      int remaining = 0 ;
      int nleptons = nelectrons + nmuons + ntaus;
      if( nleptons == 2 && nhadrons == 0){
         //cout << "dilepton" << endl;
         ndileptonic++;
         if( ntaus ==0 || ( ntaus == 1 && (ntauelectrons+ntaumuons) == 1) || (ntaus == 2 && (ntauelectrons+ntaumuons) == 2)  ) { 
           ndileptonic2++; 
         }  
         if( ntaus == 0) ndileptonic3++;
      }else if( nleptons == 1 && nhadrons == 1){
         //cout << "lepton+jets" << endl;
         nsemileptonic++;
         if( ntaus ==0 || ( ntaus == 1 && (ntauelectrons+ntaumuons) == 1) ) nsemileptonic2++;
         if( ntaus == 0 ) {
           nsemileptonic3++;
           if( nmuons ) {
             h_muon_energy->Fill(genmuon->E, genweight);
             h_lepton_energy->Fill(genmuon->E, genweight);
           }
           if( nelectrons ) {
             h_electron_energy->Fill(genelectron->E, genweight);
             h_lepton_energy->Fill(genelectron->E, genweight);
           }
         }
      }else if ( nleptons == 0 && nhadrons == 2 ){
         //cout << "hadronic" << endl;
         nhadronic++;
      }else{
         //cout << "remaining" << endl;
         remaining++;
      }
    }

    Muon * mymuon;
    Electron * myelectron; 
    bool passmuon = false; 
    bool passelectron = false; 

    if(branchMuon->GetEntries() > 0)
    {
      bool mymuonpass = false;
      for(int i = 0; i < branchMuon->GetEntriesFast() ; i++){ 
        Muon * muon =  (Muon *) branchMuon->At(i);
        if( muon->P4().E() > 20 && fabs( muon->P4().Eta() < 2.4) ){
          mymuon = muon;
          mymuonpass = true;
        }
        break;
      }
     
      if( mymuonpass && ( nmuons > 0 || nelectrons > 0 ) ){ 
        //h_muon_energy_reco->Fill(mymuon->P4().E(), genweight);
        h_lepton_energy_reco->Fill(mymuon->P4().E(), genweight);
        h2_lepton_energy_response->Fill(mymuon->P4().E(), genmuon->E, genweight);
        passmuon = true;
      }

    }

    
    if(branchElectron->GetEntries() > 0)
    {
      bool myelectronpass = false;
      for(int i = 0; i < branchElectron->GetEntriesFast() ; i++){
        Electron * electron =  (Electron *) branchElectron->At(i);
        if( electron->P4().E() > 20 && fabs( electron->P4().Eta() < 2.4) ){
          myelectron = electron;
          myelectronpass = true;
        }
        break;
      }
      if( myelectronpass && ( nmuons > 0 || nelectrons > 0 ) ){
        //h_electron_energy_reco->Fill(myelectron->P4().E(), genweight);
        h_lepton_energy_reco->Fill(myelectron->P4().E(), genweight);
        h2_lepton_energy_response->Fill(myelectron->P4().E(), genelectron->E, genweight);
        passelectron = true;
      }
    }

    if(branchJet->GetEntries() > 0 )
    {
      int njets = 0;
      int nbjets = 0;
      for(int i = 0; i < branchJet->GetEntriesFast() ; i++){
        Jet * jet =  (Jet *) branchJet->At(i);
        if( jet->P4().Pt() > 30 && fabs( jet->P4().Eta() < 2.5) ){
          njets++;
          if( jet->BTag ) nbjets++;
        }
      }
    }

    //Muon_E = -9.0;
    //Electron_E = -9.0;
    //Lepton_E_reco = -1.0;
    float Energy = 9.0;
    if( passelectron && !passmuon && njets >= 4){
      float myele_energy = myelectron->P4().E();
      //h_electron_energy_reco_S2->Fill(myele_energy, genweight);
      //h_lepton_energy_reco_S2->Fill(myele_energy, genweight);
      //h_lepton_nbjets_reco_S2->Fill(nbjets);
      if( nbjets >= 2 ){
        //h_electron_energy_reco_final->Fill(myele_energy, genweight);
        h_lepton_energy_reco_final->Fill(myele_energy, genweight);
        h2_lepton_energy_final_response->Fill(myele_energy, genelectron->E, genweight);
      }
      //lepton_E_final.push_back( myelectron->P4().E() );
      //for(int i=0; i < nmass; i++){
      //  float corr = 1.0/ h_acc->Interpolate( myelectron->P4().E() );
      //  float w = g2[i]->Eval( myelectron->P4().E() );
        //integral2[i] = integral2[i] + w*corr ;
      //}
      //Electron_E = myele_energy;
      //Lepton_E_reco = myele_energy;
    }

    if( passmuon && !passelectron && njets >= 4){
      float mymuon_energy = mymuon->P4().E();
      //h_muon_energy_reco_S2->Fill(mymuon_energy, genweight);
      //h_lepton_energy_reco_S2->Fill(mymuon_energy, genweight);
      //h_lepton_nbjets_reco_S2->Fill(nbjets);
      if( nbjets >= 2  ){
      //  h_muon_energy_reco_final->Fill(mymuon_energy, genweight);
        h_lepton_energy_reco_final->Fill(mymuon_energy, genweight);
        h2_lepton_energy_final_response->Fill(mymuon_energy, genmuon->E, genweight);
      }
      //lepton_E_final.push_back( mymuon->P4().E() );
      //for(int i=0; i < nmass; i++){
      //  float corr = 1.0/ h_acc->Interpolate( mymuon->P4().E() );
      //  float w = g2[i]->Eval( mymuon->P4().E() );
        //integral2[i] = integral2[i] + w*corr ;
      //}
      //Muon_E = mymuon_energy;
      //Lepton_E_reco = mymuon_energy;
    }

/*
    for(int i=0; i < nmass; i++){
    //for(int i=0; i < 0; i++){
      float lenergy = -9;
      if( Muon_E > 0 && Electron_E < 0 ) lenergy = Muon_E;
      if( Muon_E < 0 && Electron_E > 0 ) lenergy = Electron_E;
      float acc = h_acc->Interpolate( lenergy );
      integral2[i] = integral2[i] +  g2[i]->Eval( lenergy ) /acc ;
      integral3[i] = integral3[i] +  g3[i]->Eval( lenergy ) /acc ;
      integral5[i] = integral5[i] +  g5[i]->Eval( lenergy ) /acc ;
      integral15[i] = integral15[i] +  g15[i]->Eval( lenergy ) /acc ;
    }
*/
    //if( passmuon && passelectron) cout << "Lepton E = " << Lepton_E << endl;
    //tree->Fill();
  }

  //tree->Print();
//  for(int m=0; m < nmass; m++){
//    for(int i=0; i < 400;i++){
//      float bincenter = h_lepton_energy->GetBinCenter(i+1);
//      float binconten = h_lepton_energy->GetBinContent(i+1);
//      float weight_value = g2[m]->Eval( bincenter );
//      integral2[m] = integral2[m] + weight_value*binconten;
//    }
//  }

/*
  for(int m=0; m < nmass; m++){
    for(int i=0; i < lepton_E_final.size() ;i++){
      float energy = lepton_E_final[i];
      float corr = 1.0/ h_acc->Interpolate( energy );
      float weight_value2 = g2[m]->Eval( bincenter );
      float weight_value3 = g3[m]->Eval( bincenter );
      float weight_value5 = g5[m]->Eval( bincenter );
      float weight_value15 = g15[m]->Eval( bincenter );
      integral2[m] = integral2[m] + weight_value2*corr;
      integral3[m] = integral3[m] + weight_value3*corr;
      integral5[m] = integral5[m] + weight_value5*corr;
      integral15[m] = integral15[m] + weight_value15*corr;
    }
  }

  TGraph * final2 = new TGraph();
  TGraph * final3 = new TGraph();
  TGraph * final5 = new TGraph();
  TGraph * final15 = new TGraph();
  for (Int_t i=0;i<nmass;i++) {
    final2->SetPoint(i, mymass[i], integral2[i]);
    final3->SetPoint(i, mymass[i], integral3[i]);
    final5->SetPoint(i, mymass[i], integral5[i]);
    final15->SetPoint(i, mymass[i], integral15[i]);
  }
  final2->SetName("n2");
  final3->SetName("n3");
  final5->SetName("n5");
  final15->SetName("n15");
  final2->Write();
  final3->Write();
  final5->Write();
  final15->Write();
*/

  if( remaining != 0 ) cout << "Someting is wrong" << endl;
  //TCanvas * c = new TCanvas("c","c",1000,600);
  channel->SetBinContent(1,ndileptonic);
  channel->SetBinContent(2,ndileptonic2);
  channel->SetBinContent(3,ndileptonic3);
  channel->SetBinContent(4,nsemileptonic);
  channel->SetBinContent(5,nsemileptonic2);
  channel->SetBinContent(6,nsemileptonic3);
  channel->SetBinContent(7,nhadronic);

  channel->GetXaxis()->SetBinLabel(1,"Dileptonic");
  channel->GetXaxis()->SetBinLabel(2,"DileptonicTau");
  channel->GetXaxis()->SetBinLabel(3,"DileptonicNoTau");
  channel->GetXaxis()->SetBinLabel(4,"Semileptonic");
  channel->GetXaxis()->SetBinLabel(5,"SemileptonicTau");
  channel->GetXaxis()->SetBinLabel(6,"SemileptonicNoTau");
  channel->GetXaxis()->SetBinLabel(7,"Hadronic");

  //int nBins = 400;
  //h_lepton_energy->AddBinContent(nBins, h_lepton_energy->GetBinContent(nBins+1));
  //h_lepton_energy_reco_final->AddBinContent(nBins, h_lepton_energy_reco_final->GetBinContent(nBins+1));
  
  // Show resulting histograms
  channel->SetStats(0000);
  double scale = 1.0/numberOfEntries;
  channel->Scale( scale );  
  //channel->Draw("HText0");
/*  
  channel->Write();
  h_muon_energy->Write();
  h_electron_energy->Write();
  h_lepton_energy->Write();

  h_muon_energy_acc->Write();
  h_electron_energy_acc->Write();
  h_lepton_energy_acc->Write();

  h_muon_energy_reco->Write();
  h_electron_energy_reco->Write();
  h_lepton_energy_reco->Write();
 
  h_muon_energy_reco_final->Write();
  h_electron_energy_reco_final->Write();
  h_lepton_energy_reco_final->Write();
*/  
  f->Write();
  f->Close();
}
Пример #5
0
  T MuonDefinition<T>::getVisibleEnergy(const Muon<T>& muon) const{

    return getVisibleEnergy(muon.getDetectorCharge());

  }
Пример #6
0
  bool MuonDefinition<T>::tag(const Muon<T>& muon) const{

    return muon.getVetoCharge() > IVChargeThreshold && (muon.template Event<T>::getVisibleEnergy() > energyThreshold || muon.getDetectorCharge() > IDChargeThreshold);

  }
Пример #7
0
void MuonPlots(TString HLTname = "IsoMu20")
{
	TTimeStamp ts_start;
	cout << "[Start Time(local time): " << ts_start.AsString("l") << "]" << endl;

	TStopwatch totaltime;
	totaltime.Start();

	TString HLT;
	Double_t LeadPtCut = 9999;
	Double_t SubPtCut = 9999;
	Double_t LeadEtaCut = 9999;
	Double_t SubEtaCut = 9999;
	AssignAccThreshold(HLTname, &HLT, &LeadPtCut, &SubPtCut, &LeadEtaCut, &SubEtaCut);
	cout << "===========================================================" << endl;
	cout << "Trigger: " << HLT << endl;
	cout << "leading lepton pT Cut: " << LeadPtCut << endl;
	cout << "Sub-leading lepton pT Cut: " << SubPtCut << endl;
	cout << "leading lepton Eta Cut: " << LeadEtaCut << endl;
	cout << "sub-leading lepton Eta Cut: " << SubEtaCut << endl;
	cout << "===========================================================" << endl;

	Double_t Factor = 569.0171*2008.4*3/4.5275/10;

	//TFile *f = new TFile("ROOTFile_Histogram_InvMass_"+HLTname+"_Data.root", "RECREATE");
	//TFile *f = new TFile("ROOTFile_Histogram_InvMass_60to120_Data.root", "RECREATE");
	TFile *fcut = new TFile("MuonCut.root", "RECREATE");
	//TFile *fisPF = new TFile("MuonCutIsPF.root", "RECREATE");
	//TFile *fisChi2dof = new TFile("MuonCutChi2dof.root", "RECREATE");
	//TFile *f = new TFile("MuonCutMuonHits.root", "RECREATE");
	//TFile *f = new TFile("MuonCutNMatches.root", "RECREATE");
	//TFile *f = new TFile("MuonCutDxyVTX.root", "RECREATE");
	//TFile *f = new TFile("MuonCutDzVTX.root", "RECREATE");
	//TFile *f = new TFile("MuonCutPixelHits.root", "RECREATE");
	//TFile *f = new TFile("MuonCutTrackerLayers.root", "RECREATE");

	TString BaseLocation = "/data4/Users/kplee/DYntuple";
	//Each ntuple directory & corresponding Tags
	vector< TString > ntupleDirectory; vector< TString > Tag;
	//MC
	// ntupleDirectory.push_back( "Spring15DR/25ns/DYLL_M10to50_v2_AddTauInfo" ); Tag.push_back( "DYMuMu_M20to50" );
	ntupleDirectory.push_back( "Spring15DR/25ns/DYLL_M50_v1" ); Tag.push_back( "DYMuMu" );
	// ntupleDirectory.push_back( "Spring15DR/25ns/DYLL_M10to50_v2_AddTauInfo" ); Tag.push_back( "DYTauTau_M20to50" );
	// ntupleDirectory.push_back( "Spring15DR/25ns/DYLL_M50_v1" ); Tag.push_back( "DYTauTau" );
	// ntupleDirectory.push_back( "Spring15DR/25ns/ttbar_v1" );  Tag.push_back( "ttbar" );
	// ntupleDirectory.push_back( "Spring15DR/25ns/WJets_v1" );  Tag.push_back( "WJets" );
	// ntupleDirectory.push_back( "Spring15DR/25ns/WW_v1" );  Tag.push_back( "WW" );
	// ntupleDirectory.push_back( "Spring15DR/25ns/WZ_v1" );  Tag.push_back( "WZ" );
	// ntupleDirectory.push_back( "Spring15DR/25ns/ZZ_v1" );  Tag.push_back( "ZZ" );

	//Data
	ntupleDirectory.push_back( "Run2015C/GoldenJSON/SingleMuon_v3_Run246908to256869" ); Tag.push_back( "Data" ); // -- Run2015C -- //


	//Loop for all samples
	const Int_t Ntup = ntupleDirectory.size();
	for(Int_t i_tup = 0; i_tup<Ntup; i_tup++)
	{
		TStopwatch looptime;
		looptime.Start();

		cout << "\t<" << Tag[i_tup] << ">" << endl;

		ControlPlots *Plots = new ControlPlots( Tag[i_tup] );
		//Histograms for cuts
		TH1D *h_isGLB_Pt = new TH1D("h_isGLB_Pt"+Tag[i_tup], "", 250, 0, 500);
		TH1D *h_isGLB_eta = new TH1D("h_isGLB_eta"+Tag[i_tup], "", 60, -3, 3);
		TH1D *h_isGLB_phi = new TH1D("h_isGLB_phi"+Tag[i_tup], "", 80, -4, 4);
		TH1D *h_isPF_Pt = new TH1D("h_isGLB_Pt"+Tag[i_tup], "", 250, 0, 500);
		TH1D *h_isPF_eta = new TH1D("h_isGLB_eta"+Tag[i_tup], "", 60, -3, 3);
		TH1D *h_isPF_phi = new TH1D("h_isGLB_phi"+Tag[i_tup], "", 80, -4, 4);
		TH1D *h_chi2dof_Pt = new TH1D("h_isGLB_Pt"+Tag[i_tup], "", 250, 0, 500);
		TH1D *h_chi2dof_eta = new TH1D("h_isGLB_eta"+Tag[i_tup], "", 60, -3, 3);
		TH1D *h_chi2dof_phi = new TH1D("h_isGLB_phi"+Tag[i_tup], "", 80, -4, 4);
		TH1D *h_muonHits_Pt = new TH1D("h_isGLB_Pt"+Tag[i_tup], "", 250, 0, 500);
		TH1D *h_muonHits_eta = new TH1D("h_isGLB_eta"+Tag[i_tup], "", 60, -3, 3);
		TH1D *h_muonHits_phi = new TH1D("h_isGLB_phi"+Tag[i_tup], "", 80, -4, 4);
		TH1D *h_nMatches_Pt = new TH1D("h_isGLB_Pt"+Tag[i_tup], "", 250, 0, 500);
		TH1D *h_nMatches_eta = new TH1D("h_isGLB_eta"+Tag[i_tup], "", 60, -3, 3);
		TH1D *h_nMatches_phi = new TH1D("h_isGLB_phi"+Tag[i_tup], "", 80, -4, 4);
		TH1D *h_dxyVTX_Pt = new TH1D("h_isGLB_Pt"+Tag[i_tup], "", 250, 0, 500);
		TH1D *h_dxyVTX_eta = new TH1D("h_isGLB_eta"+Tag[i_tup], "", 60, -3, 3);
		TH1D *h_dxyVTX_phi = new TH1D("h_isGLB_phi"+Tag[i_tup], "", 80, -4, 4);
		TH1D *h_dzVTX_Pt = new TH1D("h_isGLB_Pt"+Tag[i_tup], "", 250, 0, 500);
		TH1D *h_dzVTX_eta = new TH1D("h_isGLB_eta"+Tag[i_tup], "", 60, -3, 3);
		TH1D *h_dzVTX_phi = new TH1D("h_isGLB_phi"+Tag[i_tup], "", 80, -4, 4);
		TH1D *h_pixelHits_Pt = new TH1D("h_isGLB_Pt"+Tag[i_tup], "", 250, 0, 500);
		TH1D *h_pixelHits_eta = new TH1D("h_isGLB_eta"+Tag[i_tup], "", 60, -3, 3);
		TH1D *h_pixelHits_phi = new TH1D("h_isGLB_phi"+Tag[i_tup], "", 80, -4, 4);
		TH1D *h_trackerLayers_Pt = new TH1D("h_isGLB_Pt"+Tag[i_tup], "", 250, 0, 500);
		TH1D *h_trackerLayers_eta = new TH1D("h_isGLB_eta"+Tag[i_tup], "", 60, -3, 3);
		TH1D *h_trackerLayers_phi = new TH1D("h_isGLB_phi"+Tag[i_tup], "", 80, -4, 4);

		TChain *chain = new TChain("recoTree/DYTree");
		chain->Add(BaseLocation+"/"+ntupleDirectory[i_tup]+"/ntuple_*.root");
		if( Tag[i_tup] == "Data" )
		{
			// -- Run2015D -- // 
			chain->Add("/data4/Users/kplee/DYntuple/Run2015D/GoldenJSON/v20151016_v3JSON_Run2015D_SingleMuon_Run246908to256869/*.root");
			chain->Add("/data4/Users/kplee/DYntuple/Run2015D/GoldenJSON/v20151010_v2JSON_SingleMuon_Run256870to257599/*.root");
			chain->Add("/data4/Users/kplee/DYntuple/Run2015D/GoldenJSON/v20151009_SingleMuon_Run257600toRun258159/*.root");
		}
		
		NtupleHandle *ntuple = new NtupleHandle( chain );

		Bool_t isNLO = 0;
		if( Tag[i_tup] == "DYMuMu" || Tag[i_tup] == "DYTauTau" || Tag[i_tup] == "WJets" || Tag[i_tup] == "DYMuMu_M20to50" || Tag[i_tup] == "DYTauTau_M20to50" )
		{
			isNLO = 1;
			cout << "\t" << Tag[i_tup] << ": generated with NLO mode - Weights are applied" << endl;
		}

		Int_t count_Zpeak = 0;
		Double_t SumWeight = 0;
		Double_t SumWeight_DYMuMu_M20to50 = 0;
		Double_t SumWeight_DYTauTau_M20to50 = 0;

		Int_t NEvents = chain->GetEntries();
		cout << "\t[Total Events: " << NEvents << "]" << endl;
		for(Int_t i=0; i<NEvents; i++)
		{
			loadBar(i+1, NEvents, 100, 100);
			
			ntuple->GetEvent(i);

			//Bring weights for NLO MC events
			Double_t GenWeight;
			if( isNLO == 1 )
				GenWeight = ntuple->GENEvt_weight;
			else
				GenWeight = 1;
			// cout << "Weight of " << i << "th Event: " << GenWeight << endl;
			SumWeight += GenWeight;

			Int_t GenMassFlag = -1;
			//Take the events within 20<M<50 in gen-level
/*
 *            if( Tag[i_tup] == "DYMuMu_M20to50" )
 *            {
 *                GenMassFlag = 0;
 *                vector<GenLepton> GenLeptonCollection;
 *                Int_t NGenLeptons = ntuple->gnpair;
 *                for(Int_t i_gen=0; i_gen<NGenLeptons; i_gen++)
 *                {
 *                    GenLepton genlep;
 *                    genlep.FillFromNtuple(ntuple, i_gen);
 *                    if( genlep.isMuon() && genlep.fromHardProcessFinalState )
 *                        GenLeptonCollection.push_back( genlep );
 *                }
 *
 *                if( GenLeptonCollection.size() == 2 )
 *                {
 *                    GenLepton genlep1 = GenLeptonCollection[0];
 *                    GenLepton genlep2 = GenLeptonCollection[1];
 *
 *                    TLorentzVector gen_v1 = genlep1.Momentum;
 *                    TLorentzVector gen_v2 = genlep2.Momentum;
 *                    TLorentzVector gen_vtot = gen_v1 + gen_v2;
 *                    Double_t gen_M = gen_vtot.M();
 *
 *                    if( gen_M > 20 && gen_M < 50 ) //Take the events within 20<M<50 in gen-level
 *                    {
 *                        GenMassFlag = 1;
 *                        SumWeight_DYMuMu_M20to50 += GenWeight;
 *                    }		
 *                }
 *            }
 *            else if( Tag[i_tup] == "DYTauTau_M20to50" )
 *            {
 *                GenMassFlag = 0;
 *                vector<GenLepton> GenLeptonCollection;
 *                Int_t NGenLeptons = ntuple->gnpair;
 *                for(Int_t i_gen=0; i_gen<NGenLeptons; i_gen++)
 *                {
 *                    GenLepton genlep;
 *                    genlep.FillFromNtuple(ntuple, i_gen);
 *                    if( abs(genlep.ID) == 15 && genlep.fromHardProcessDecayed )
 *                        GenLeptonCollection.push_back( genlep );
 *                }
 *
 *                if( GenLeptonCollection.size() == 2 )
 *                {
 *                    GenLepton genlep1 = GenLeptonCollection[0];
 *                    GenLepton genlep2 = GenLeptonCollection[1];
 *
 *                    TLorentzVector gen_v1 = genlep1.Momentum;
 *                    TLorentzVector gen_v2 = genlep2.Momentum;
 *                    TLorentzVector gen_vtot = gen_v1 + gen_v2;
 *                    Double_t gen_M = gen_vtot.M();
 *
 *                    if( gen_M > 20 && gen_M < 50 ) //Take the events within 20<M<50 in gen-level
 *                    {
 *                        GenMassFlag = 1;
 *                        SumWeight_DYTauTau_M20to50 += GenWeight;
 *                    }	
 *                }
 *            }
 *            else
 */
				GenMassFlag = 1; // -- other cases: pass


			
			if( ntuple->isTriggered( HLT ) && GenMassFlag)
			{
				//Collect Reconstruction level information
				vector< Muon > MuonCollection;
				Int_t NLeptons = ntuple->nMuon;
				for(Int_t i_reco=0; i_reco<NLeptons; i_reco++)
				{
					Muon mu;
					mu.FillFromNtuple(ntuple, i_reco);
						MuonCollection.push_back( mu );
				}

				//Select muons directly from Z/gamma by matching with gen-level final state muons from hard process
				if( Tag[i_tup] == "DYMuMu" )
					GenMatching(HLTname, "fromHardProcess", ntuple, &MuonCollection);
/*
 *                //Select muons directly from tau by matching with gen-level final state muons from prompt tau
 *                else if( Tag[i_tup] == "DYTauTau" )
 *                    GenMatching(HLTname, "fromTau", ntuple, &MuonCollection);
 *
 */

				//Collect qualified muons among muons
				vector< Muon > QMuonCollection;
				for(Int_t j=0; j<(int)MuonCollection.size(); j++)
				{
					if( MuonCollection[j]->isGLB == 1)
					{
						h_isGLB_Pt->Fill( MuonCollection[j].Pt, GenWeight );
						h_isGLB_eta->Fill( MuonCollection[j].eta, GenWeight);
						h_isGLB_phi->Fill( MuonCollection[j].phi, GenWeight);
					}
					if( MuonCollection[j]->isPF == 1)
					{
						h_isPF_Pt->Fill( MuonCollection[j].Pt, GenWeight );
						h_isPF_eta->Fill( MuonCollection[j].eta, GenWeight);
						h_isPF_phi->Fill( MuonCollection[j].phi, GenWeight);
					}
					if( MuonCollection[j]->chi2dof < 10)
					{
						h_ischi2dof_Pt->Fill( MuonCollection[j].Pt, GenWeight );
						h_ischi2dof_eta->Fill( MuonCollection[j].eta, GenWeight);
						h_ischi2dof_phi->Fill( MuonCollection[j].phi, GenWeight);
					}
					if( MuonCollection[j]->muonHits > 0)
					{
						h_is_muonHits_Pt->Fill( MuonCollection[j].Pt, GenWeight );
						h_is_muonHits_eta->Fill( MuonCollection[j].eta, GenWeight);
						h_is_muonHits_phi->Fill( MuonCollection[j].phi, GenWeight);
					}
					if( MuonCollection[j]->nMatches > 1)
					{
						h_nMatches_Pt->Fill( MuonCollection[j].Pt, GenWeight );
						h_nMatches_eta->Fill( MuonCollection[j].eta, GenWeight);
						h_nMatches_phi->Fill( MuonCollection[j].phi, GenWeight);
					}
					if( fabs(MuonCollection[j]->dxyVTX) < 0.2)
					{
						h_dxyVTX_Pt->Fill( MuonCollection[j].Pt, GenWeight );
						h_dxyVTX_eta->Fill( MuonCollection[j].eta, GenWeight);
						h_dxyVTX_phi->Fill( MuonCollection[j].phi, GenWeight);
					}
					if( fabs(MuonCollection[j]->dzVTX) < 0.5 )
					{
						h_dzVTX_Pt->Fill( MuonCollection[j].Pt, GenWeight );
						h_dzVTX_eta->Fill( MuonCollection[j].eta, GenWeight);
						h_dzVTX_phi->Fill( MuonCollection[j].phi, GenWeight);
					}
					if( MuonCollection[j]->pixelHits > 0 )
					{
						h_pixelHits_Pt->Fill( MuonCollection[j].Pt, GenWeight );
						h_pixelHits_eta->Fill( MuonCollection[j].eta, GenWeight);
						h_pixelHits_phi->Fill( MuonCollection[j].phi, GenWeight);
					}
					if( MuonCollection[j]->trackerLayers > 5)
					{
						h_trackerLayers_Pt->Fill( MuonCollection[j].Pt, GenWeight );
						h_trackerLayers_eta->Fill( MuonCollection[j].eta, GenWeight);
						h_trackerLayers_phi->Fill( MuonCollection[j].phi, GenWeight);
					}

					//if( MuonCollection[j].isTightMuon() && MuonCollection[j].trkiso < 0.10)
						//QMuonCollection.push_back( MuonCollection[j] );
				}

/*
 *                //Give Acceptance cuts
 *                if( QMuonCollection.size() >= 2)
 *                {
 *                    Muon leadMu, subMu;
 *                    CompareMuon(&QMuonCollection[0], &QMuonCollection[1], &leadMu, &subMu);
 *                    if( !(leadMu.Pt > LeadPtCut && subMu.Pt > SubPtCut && abs(leadMu.eta) < LeadEtaCut && abs(subMu.eta) < SubEtaCut) )
 *                        QMuonCollection.clear();
 *                }
 *
 *                if( QMuonCollection.size() == 2)
 *                {
 *                    Muon recolep1 = QMuonCollection[0];
 *                    Muon recolep2 = QMuonCollection[1];
 *                    TLorentzVector reco_v1 = recolep1.Momentum;
 *                    TLorentzVector reco_v2 = recolep2.Momentum;
 *                    Double_t reco_M = (reco_v1 + reco_v2).M();
 *
 *                    if( reco_M > 60 && reco_M < 120 && isPassDimuonVertexCut(ntuple, recolep1.cktpT, recolep2.cktpT) )
 *                    {
 *                        Plots->FillHistograms(ntuple, HLT, recolep1, recolep2, GenWeight);
 *
 *                        //Count # events in the Z-peak region for each sample
 *                        //if( reco_M > 60 && reco_M < 120 )
 *                            count_Zpeak++;
 *                    }
 *                }
 *
 */
			} //End of if( isTriggered )

		} //End of event iteration

		/*
		 *cout << "\tcount_Zpeak(" << Tag[i_tup] << "): " << count_Zpeak << endl;
		 */

		// if( Tag[i_tup] == "DYTauTau_M20to50" )
		// {
		// 	for(Int_t i_hist=0; i_hist < (Int_t)Plots->Histo.size(); i_hist++)
		// 		Plots->Histo[i_hist]->Scale( 2.49997e+10 / 4.48119e+11 );
		// }




		//Plots->WriteHistograms( fisGLB );
		fisGLB->cd();
		h_isGLB_Pt->Write();
		h_isGLB_eta->Write();
		h_isGLB_phi->Write();
		h_isPF_Pt->Write();
		h_isPF_eta->Write();
		h_isPF_phi->Write();
		h_chi2dof_Pt->Write();
		h_chi2dof_eta->Write();
		h_chi2dof_phi->Write();
		h_muonHits_Pt->Write();
		h_muonHits_eta->Write();
		h_muonHits_phi->Write();
		h_nMatches_Pt->Write();
		h_nMatches_eta->Write();
		h_nMatches_phi->Write();
		h_dxyVTX_Pt->Write();
		h_dxyVTX_eta->Write();
		h_dxyVTX_phi->Write();
		h_dzVTX_Pt->Write();
		h_dzVTX_eta->Write();
		h_dzVTX_phi->Write();
		h_pixelHits_Pt->Write();
		h_pixelHits_eta->Write();
		h_pixelHits_phi->Write();
		h_trackerLayers_Pt->Write();
		h_trackerLayers_eta->Write();
		h_trackerLayers_phi->Write();
		



		if(isNLO == 1)
			cout << "\tTotal sum of weights: " << SumWeight << endl;

		if( Tag[i_tup] == "DYMuMu_M20to50" )
			cout << "\tSum of weights in 20<M<50 for DYMuMu events: " << SumWeight_DYMuMu_M20to50 << endl;

		if( Tag[i_tup] == "DYTauTau_M20to50" )
			cout << "\tSum of weights in 20<M<50 for DYTauTau events: " << SumWeight_DYTauTau_M20to50 << endl;

		Double_t LoopRunTime = looptime.CpuTime();
		cout << "\tLoop RunTime(" << Tag[i_tup] << "): " << LoopRunTime << " seconds\n" << endl;
	} //end of i_tup iteration

	Double_t TotalRunTime = totaltime.CpuTime();
	cout << "Total RunTime: " << TotalRunTime << " seconds" << endl;

	TTimeStamp ts_end;
	cout << "[End Time(local time): " << ts_end.AsString("l") << "]" << endl;
}
Пример #8
0
void LHCOWriter::AnalyseMuons()
{
  Muon *element;
  Track *track;
  Tower *tower;
  Jet *jet;
  Int_t muonCounter, tauCounter, jetCounter, minIndex;
  Float_t sumPT, sumET, ratET, jetDR, minDR;

  muonCounter = 0;
  fItMuon->Reset();
  while((element = static_cast<Muon*>(fItMuon->Next())))
  {
    Reset();

    sumPT = 0.0;
    fItTrack->Reset();
    while((track = static_cast<Track*>(fItTrack->Next())))
    {
      if(element->P4().DeltaR(track->P4()) < 0.5) sumPT += track->PT;
    }

    sumET = 0.0;
    fItTower->Reset();
    while((tower = static_cast<Tower*>(fItTower->Next())))
    {
      if(element->P4().DeltaR(tower->P4()) < 0.5) sumET += tower->ET;
    }

    tauCounter = 0;
    jetCounter = 0;
    minIndex = -1;
    minDR = 1.0E9;
    fItJet->Reset();
    while((jet = static_cast<Jet*>(fItJet->Next())))
    {
      if(jet->TauTag != 0)
      {
        ++tauCounter;
        continue;
      }

      jetDR = element->P4().DeltaR(jet->P4());
      if(jetDR < minDR)
      {
        minIndex = jetCounter;
        minDR = jetDR;
      }
      ++jetCounter;
    }

    fIntParam[1] = 2;

    fDblParam[0] = element->Eta;
    fDblParam[1] = element->Phi;
    fDblParam[2] = element->PT;

    fDblParam[3] = 0.11;

    fDblParam[4] = element->Charge;

    if(minIndex >= 0)
    {
      fDblParam[5] = fIntParam[0] + fBranchMuon->GetEntriesFast() - muonCounter + tauCounter + minIndex;
    }

    ratET = sumET/element->PT;
    fDblParam[6] = Float_t(TMath::Nint(sumPT)) + (ratET < 1.0 ? ratET : 0.99);

    Write();
    ++muonCounter;
  }
}