Exemplo n.º 1
0
bool L2RecoMatchTest::processEvent(cafe::Event &event)
{
  // The vector of "Matches" and iterators of it are used with the _old_ interface
  std::vector<Match< TMBL2Base, TMBLorentzVector> > test;
  std::vector<Match< TMBL2Base, TMBLorentzVector> >::iterator match_it;
  //The new interface uses a multimap and iterators thereof.
  std::multimap<Collection<TMBL2Base>::iterator, Collection<TMBLorentzVector>::iterator> L2Reco;
  std::multimap<Collection<TMBL2Base>::iterator, Collection<TMBLorentzVector>::iterator>::iterator L2Reco_it;
  Collection<TMBL2Base>::iterator l2_it;
  Collection<TMBLorentzVector>::iterator reco_it;

  //Uncomment the following section to print a list of all triggers of the event
/*
  Collection<TMBTrigger> triggers = event.getTriggers();
  Collection<TMBTrigger>::iterator trigger_it=triggers.begin();
  for(; trigger_it!=triggers.end(); trigger_it++) {
    std::cout << (*trigger_it).getTrgName() << std::endl;
  };
*/
  //Example to access the matchings, old interface!
  if(event.get(_matchname, test)) {
    match_it=test.begin();
    std::cout << "Found " << test.size() << " match(es) in the event." << std::endl; 
    for(; match_it!=test.end(); match_it++) {
	std::cout << "dr = " << (*match_it).getdR() << std::endl;
	std::cout << "Et = " << (*match_it).getObj1It()->Et() << std::endl;
    };
  }
  
  //Example code to access the matchings, new interface!
  if(event.get(_matchname+"MAP", L2Reco)) {
    std::cout << "Matches in the event: " << L2Reco.size() << std::endl;
    L2Reco_it = L2Reco.begin();

    int i=0;
    for(; L2Reco_it!=L2Reco.end(); L2Reco_it++) {
	l2_it = (*L2Reco_it).first;
	reco_it = (*L2Reco_it).second;
	
	float dphi = kinem::delta_phi((*l2_it).Phi(), (*reco_it).Phi());
	float deta = (*l2_it).Eta() - (*reco_it).Eta();
	float dR   = sqrt(dphi * dphi + deta * deta);
	
	std::cout << "Distance of match: " << dR << std::endl;
	std::cout << "Et of L2 object: " << (*l2_it).Et() << "; and pT of reco object: " << (*reco_it).Pt() << std::endl;
    };
  };
  
  std::cout << "--------------------------------------------------------------------------" << std::endl;
  return true;
};
Exemplo n.º 2
0
    bool RemoveObjects::processEvent(cafe::Event& event)
    {
	using namespace cafe;
	using namespace std;

	vector<TObjArray*> vars;

	for(vector<string>::const_iterator it = _list.begin();
	    it != _list.end();
	    ++it) {
	    TObjArray *ptr = 0;
	    if(event.get(*it, ptr) && ptr != 0) {
		vars.push_back(ptr);
	    } else {
		err() << "RemoveObjects[" << name() << "]: No such list:" << *it << endl;
	    }
	}

	if(TClonesArray *objects = const_cast<TClonesArray*>(event.getClonesArray(_branch))) {

	    unsigned int initial = objects->GetLast() + 1;
	    unsigned int count = 0;

	    // need non-const object since we modify it...
	    TIter iter(objects);
	    while(TObject *obj = iter.Next()) {
		bool remove = true;

		for(vector<TObjArray*>::const_iterator it = vars.begin();
		    it != vars.end();
		    ++it) {
		    if((*it)->FindObject(obj) != 0) {
			remove = false;
			break;
		    }
		}

		if(remove) {
		    count++;
		    objects->Remove(obj);
		}
	    }

	    objects->Compress();

	} else {
	    err() << "RemoveObjects[" << name() << "]: No such branch: " << _branch << endl;
	}

	return true;
    }
Exemplo n.º 3
0
// process
bool FakeAnalysis::processEvent(cafe::Event& event) {

  vector<CAFEMObj*> emobjs;
  CAFMet met_corr;
  int triglist_flag = -1;
  vector<const TMBL1CalTower*> l1cal_vec;
  vector<const TMBL1Cal2bEM*> l1cal2b_vec;
  vector<const TMBL2GblEM*> l2cal_vec;
  vector<const TMBL3Ele*> l3cal_vec;
  float event_vertex;

  int solpol = -999;  
  double instlumi = 0.;

  if(event.get("Good EMObjs", emobjs) && event.get("EMCorr Met", met_corr) &&
     event.get("L1CalTowers", l1cal_vec) &&  event.get("L1Cal2bTowers", l1cal2b_vec) &&   
     event.get("L2GblEMs", l2cal_vec) && 
     event.get("L3Eles", l3cal_vec) && event.get("triglist flag", triglist_flag) && 
     event.get("InstLumi", instlumi) && event.get("solenoid polarity", solpol) && 
     event.get("Primary vertexZ", event_vertex)) {

  
	if(instlumi > _InstLumi_lowcut && instlumi < _InstLumi_highcut){

    	double met = met_corr.met(); 

    	// require exactly one electron and this electron must pass trigger requirement
    	bool pass_trigger = false;

    	if(emobjs.size() == 1) 
    	  pass_trigger = emobjs[0]->PassTrigCMB(triglist_flag, 0.4, l1cal_vec, l1cal2b_vec,  l2cal_vec, l3cal_vec);
    	// only look at the electron that passes trigger requirement
    	if(pass_trigger) {

    		// get primary vertex
    		double v_z = event_vertex;
    		char bins_Vtx[10];
    		int bin_Vtx_number;
    		bin_Vtx_number=int((v_z+60.)/20.);
    		sprintf(bins_Vtx, "%d", bin_Vtx_number);


    		// identify Zee candidates
    		// ************* code from WAnalysis *********************
    		// ************* for estimating zee bkgd *****************
			// require no high pT isolated track back-to-back with the electron
			bool EM_Track_backtoback = false;

    		// change solpol from 0/1 to -1/1
    		int polarity = 2*solpol -1;

			// get all isolated tracks
			vector<CAFTrack *> isolatedTrks;
			if(event.get("Good Tracks", isolatedTrks)) {
			  for(int itrk=0; itrk<isolatedTrks.size(); itrk++) {
	    		double em_trk_phidiff = kinem::delta_phi(emobjs[0]->Phi(), isolatedTrks[itrk]->Phi());
	    		if(em_trk_phidiff > 2.5 && // back to back with the EM cluster
	    		   fabs(isolatedTrks[itrk]->TrackDetEta(polarity, false /*_MCStudy*/))>1.1 &&  // track in ICR 
	    		   fabs(isolatedTrks[itrk]->TrackDetEta(polarity, false /*_MCStudy*/))<1.5 &&
	    		   fabs(isolatedTrks[itrk]->z()-v_z)<1. &&  // vertex close to each other 
	    		   (isolatedTrks[itrk]->charge())*(emobjs[0]->charge())<0.) { // opposite charge

	    		  TLorentzVector vect_trk(isolatedTrks[itrk]->Px(),isolatedTrks[itrk]->Py(),isolatedTrks[itrk]->Pz(),isolatedTrks[itrk]->E());
	    		  TLorentzVector vect_emobj(emobjs[0]->Px(),emobjs[0]->Py(),emobjs[0]->Pz(),emobjs[0]->E());
	    		  TLorentzVector vect_Z=vect_trk+vect_emobj;

	    		  // invariant mass
	    		  if(vect_Z.M()>70. && vect_Z.M()<110.)   EM_Track_backtoback = true;
	    		}
			  }
			}
			// end of identify Zee candidates

		    if(EM_Track_backtoback==false) {

    			//get jets from the event
    			cafe::Collection<TMBJet> jets = event.getJCCB(_jccb_vars);

    			for(Collection<TMBJet>::iterator iter = jets.begin(); iter!= jets.end(); ++iter) {

				if(GoodJet(*iter)) {
        		  float dphi_jet_em = kinem::delta_phi(emobjs[0]->Phi(), (*iter).Phi());
				  //get rid of the jet if they are close to each other
				  //since EM cluster may also be reconstructed as a jet
	    			if(fabs(dphi_jet_em) > _DPhi_Jet_EM_Cut) {

            			  // determine whether electron in CC or EC region
            			  int cal_region = -1; 
            			  if(emobjs[0]->IsCC(_DetEtaCC)) cal_region = 0;
            			  if(emobjs[0]->IsEC(_DetEtaEC1, _DetEtaEC2)) cal_region = 1;

            			  char region[10];  sprintf(region, "%d", cal_region);

	    				  float elec_deteta = emobjs[0]->CalDetectorEta();
	    				  float elec_eta = emobjs[0]->Eta();
	    				  float elec_pT = emobjs[0]->Pt();

            				  _histos.Fill1D("Fake_Electron_DetEta", elec_deteta);
	    				  _histos.Fill1D("Fake_Electron_Eta", elec_eta);
	    				  _histos.Fill1D("Fake_Electron_Pt", elec_pT);
	    				  _histos.Fill1D("Fake_Met", met);

	    				  // fill distributions for CC or EC region
	    				  _histos.Fill1D(string("Fake_Electron_DetEta_")+region, elec_deteta);
	    				  _histos.Fill1D(string("Fake_Electron_Eta_")+region, elec_eta);
	    				  _histos.Fill1D(string("Fake_Electron_Pt_")+region, elec_pT);
	    				  _histos.Fill1D(string("Fake_Met_")+region, met);


	    				  if(met< 15. && cal_region==0){
						      _histos.Fill1D(string("Fake_Electron_DetEta_CCVtxBin_")+bins_Vtx, emobjs[0]->CalDetectorEta());
	    				  }

	    				  // spatial+E/P
	    				  if(emobjs[0]->has_track_match()) {
							_histos.Fill1D("Fake_Electron_DetEta_Match", elec_deteta);
							_histos.Fill1D("Fake_Electron_Eta_Match", elec_eta);
							_histos.Fill1D("Fake_Electron_Pt_Match", elec_pT);
							_histos.Fill1D("Fake_Met_Match", met);

                					// fill distributions for CC or EC region
	        					_histos.Fill1D(string("Fake_Electron_DetEta_Match_")+region, elec_deteta);
	        					_histos.Fill1D(string("Fake_Electron_Eta_Match_")+region, elec_eta);
	        					_histos.Fill1D(string("Fake_Electron_Pt_Match_")+region, elec_pT);
                					_histos.Fill1D(string("Fake_Met_Match_")+region, met);
	    				  }

	    			  // spatial only
	    			  if(emobjs[0]->has_good_spatial_track_match()) {
						_histos.Fill1D("Fake_Electron_DetEta_Spatial_Match", elec_deteta);
						_histos.Fill1D("Fake_Electron_Eta_Spatial_Match", elec_eta);
						_histos.Fill1D("Fake_Electron_Pt_Spatial_Match", elec_pT);
						_histos.Fill1D("Fake_Met_Spatial_Match", met);

                				// fill distributions for CC or EC region
	        				_histos.Fill1D(string("Fake_Electron_DetEta_Spatial_Match_")+region, elec_deteta);
	        				_histos.Fill1D(string("Fake_Electron_Eta_Spatial_Match_")+region, elec_eta);
	        				_histos.Fill1D(string("Fake_Electron_Pt_Spatial_Match_")+region, elec_pT);
                				_histos.Fill1D(string("Fake_Met_Spatial_Match_")+region, met);

						if(met< 15. && cal_region==0){
						  _histos.Fill1D(string("Fake_Electron_DetEta_CCVtxBin_Spatial_Match_")+bins_Vtx, emobjs[0]->CalDetectorEta());
						}
	    			  }

	    			  // spatial only+SMT,CFT
	    			  if(emobjs[0]->has_spatial_track_match(-0.5)) {
						  // check chi2 vs met
						  _histos.Fill2D("Fake_Electron_Chi2_V_Met_Spatial_Match", met, emobjs[0]->track_match_spatialchi2prob());
						  _histos.Fill2D(string("Fake_Electron_Chi2_V_Met_Spatial_Match_")+region, met, emobjs[0]->track_match_spatialchi2prob());
                	    		  _histos.Fill1D("Fake_Electron_Chi2", emobjs[0]->track_match_spatialchi2prob());
                	    		  _histos.Fill1D(string("Fake_Electron_Chi2_")+region, emobjs[0]->track_match_spatialchi2prob());

						  double ElecPt = emobjs[0]->Pt();
						  double TrkPt = emobjs[0]->getPtrSpatialChp()->Pt();
						  double EOverP = 0.;
						  if(TrkPt>0.) EOverP = ElecPt/TrkPt;

						  if(emobjs[0]->getPtrSpatialChp()->nsmt()>=1 && emobjs[0]->getPtrSpatialChp()->ncft()>=4) {

							  // check chi2 vs met
							  _histos.Fill2D("Fake_Electron_Chi2_V_Met_Spatial_Match_Tight", met, emobjs[0]->track_match_spatialchi2prob());
							  _histos.Fill2D(string("Fake_Electron_Chi2_V_Met_Spatial_Match_Tight_")+region, met, emobjs[0]->track_match_spatialchi2prob());
                					  _histos.Fill1D("Fake_Electron_Chi2_Tight", emobjs[0]->track_match_spatialchi2prob());
                					  _histos.Fill1D(string("Fake_Electron_Chi2_Tight_")+region, emobjs[0]->track_match_spatialchi2prob());

							  _histos.Fill1D("Fake_Electron_DetEta_Spatial_Match_Tight", elec_deteta);
							  _histos.Fill1D("Fake_Electron_Eta_Spatial_Match_Tight", elec_eta);
							  _histos.Fill1D("Fake_Electron_Pt_Spatial_Match_Tight", elec_pT);
							  _histos.Fill1D("Fake_Met_Spatial_Match_Tight", met);

							  // fill distributions for CC or EC region
							  _histos.Fill1D(string("Fake_Electron_DetEta_Spatial_Match_Tight_")+region, elec_deteta);
							  _histos.Fill1D(string("Fake_Electron_Eta_Spatial_Match_Tight_")+region, elec_eta);
							  _histos.Fill1D(string("Fake_Electron_Pt_Spatial_Match_Tight_")+region, elec_pT);
							  _histos.Fill1D(string("Fake_Met_Spatial_Match_Tight_")+region, met);
				    	  }
	    			  }

	    			  //#######################################################
	    			  // same histograms for met<_MetCut_FakeRate
	    			  //#######################################################
	    			  if( met < _MetCut_FakeRate ) {
						_histos.Fill1D("Fake_Electron_DetEta_MetCut", elec_deteta);
						_histos.Fill1D("Fake_Electron_Eta_MetCut", elec_eta);
						_histos.Fill1D("Fake_Electron_Pt_MetCut", elec_pT);

						// fill distributions for CC or EC region
						_histos.Fill1D(string("Fake_Electron_DetEta_MetCut_")+region, elec_deteta);
						_histos.Fill1D(string("Fake_Electron_Eta_MetCut_")+region, elec_eta);
						_histos.Fill1D(string("Fake_Electron_Pt_MetCut_")+region, elec_pT);

						// spatial+E/P
						if(emobjs[0]->has_track_match()) {
						  _histos.Fill1D("Fake_Electron_DetEta_Match_MetCut", elec_deteta);
						  _histos.Fill1D("Fake_Electron_Eta_Match_MetCut", elec_eta);
						  _histos.Fill1D("Fake_Electron_Pt_Match_MetCut", elec_pT);

						  // fill distributions for CC or EC region
						  _histos.Fill1D(string("Fake_Electron_DetEta_Match_MetCut_")+region, elec_deteta);
						  _histos.Fill1D(string("Fake_Electron_Eta_Match_MetCut_")+region, elec_eta);
						  _histos.Fill1D(string("Fake_Electron_Pt_Match_MetCut_")+region, elec_pT);
						}

						// good spatial only
						if(emobjs[0]->has_good_spatial_track_match()) {
						  _histos.Fill1D("Fake_Electron_DetEta_Spatial_Match_MetCut", elec_deteta);
						  _histos.Fill1D("Fake_Electron_Eta_Spatial_Match_MetCut", elec_eta);
						  _histos.Fill1D("Fake_Electron_Pt_Spatial_Match_MetCut", elec_pT);

						  // fill distributions for CC or EC region
						  _histos.Fill1D(string("Fake_Electron_DetEta_Spatial_Match_MetCut_")+region, elec_deteta);
						  _histos.Fill1D(string("Fake_Electron_Eta_Spatial_Match_MetCut_")+region, elec_eta);
						  _histos.Fill1D(string("Fake_Electron_Pt_Spatial_Match_MetCut_")+region, elec_pT);
						}

						// spatial only+SMT,CFT+E/p
						if(emobjs[0]->has_spatial_track_match(-0.5)) {
						  double ElecPt = emobjs[0]->Pt();
						  double TrkPt = emobjs[0]->getPtrSpatialChp()->Pt();
						  double EOverP = 0.;
						  if(TrkPt>0.) EOverP = ElecPt/TrkPt;

						  if(emobjs[0]->getPtrSpatialChp()->nsmt()>=1 && emobjs[0]->getPtrSpatialChp()->ncft()>=4) {
		    				_histos.Fill1D("Fake_Electron_DetEta_Spatial_Match_Tight_MetCut", elec_deteta);
		    				_histos.Fill1D("Fake_Electron_Eta_Spatial_Match_Tight_MetCut", elec_eta);
		    				_histos.Fill1D("Fake_Electron_Pt_Spatial_Match_Tight_MetCut", elec_pT);

		    				// fill distributions for CC or EC region
		    				_histos.Fill1D(string("Fake_Electron_DetEta_Spatial_Match_Tight_MetCut_")+region, elec_deteta);
		    				_histos.Fill1D(string("Fake_Electron_Eta_Spatial_Match_Tight_MetCut_")+region, elec_eta);
		    				_histos.Fill1D(string("Fake_Electron_Pt_Spatial_Match_Tight_MetCut_")+region, elec_pT);
						  }
						}

	    			  } // missing Et cut

	    			} // EM and Jet are back-to-back
				}
    		    } // loop over jets

		   }//if(EM_Track_backtoback==false) i.e. this is not zee event 

    	}// exactly one good EM object and pass trigger

	}//lumi cut
  }
  return true;
}
    bool TopMuonPairSelector::processEvent(cafe::Event &event)
    {
    //get pointer to statistics collector
        StatPointer stat ;
        event.get("StatPointer", stat) ;

        Collection<TMBEMCluster> em_from(event.getCollection<TMBEMCluster>(_electronBranch.c_str()));
        Collection<TMBMuon> mu_from(event.getCollection<TMBMuon>(_muonBranch.c_str()));

        Collection<TMBMuon> all_muons( event.getMuons() );

        if (em_from.size() == 0 && mu_from.size() == 0 && debug ) {
            out() << "PAIR SELECTOR WARNING! Electron/Muon branch " 
                    << _electronBranch << "/" << _muonBranch << " is empty or is not existing! "
                    << endl ;
            return true ;
        }

        if (em_from.size() >=2 && debug) {
            out() << "PAIR SELECTOR ERROR! 2 electrons found in branch \""
                    << _electronBranch << "\". Considering only leading electron outside of a jet!"
                    << endl ;
//     return false ;
        }

        l_mom.SetPxPyPzE( 0 , 0 , 0 , 0 );
        lepton_charge = 0;

        jet_array = event.getCollection<TMBJet>(_jet_branch.c_str());
        if( em_from.size() == 0 )
        {
            for( int i = 0 ; i < mu_from.size() ; i++ )
            {
                bool is_in_jet = false;
                if( dR_cut > 0 )
                {
                    for( int j = 0 ; j < jet_array.size() ; j++ )
                    {
                        if( do_dr_mujet_lead_muon && mu_from[i].DeltaR( jet_array[j] ) < dR_cut )
                            is_in_jet = true;
                    }
                }
                if( use_only_leading_lepton && i > 0 )
                    is_in_jet = true;
                if( mu_from[i].Pt() > l_mom.Pt() && mu_from[i].charge() != 0 && !is_in_jet )
                {
                    l_mom = mu_from[i];
                    l_track = const_cast<TMBTrack*>(mu_from[i].GetChargedTrack());
                    lepton_charge = mu_from[i].charge();
                }
            }
        }
        else
        {
            for( int i = 0 ; i < em_from.size() ; i++ )
            {
                if( em_from[i].Pt() > l_mom.Pt() && em_from[i].charge() != 0 )
                {
                    bool common_track = false;
                    for( int j = 0 ; j < all_muons.size() ; j++ )
                    {
                        if( remove_common_track && ( all_muons[j].GetChargedTrack() && all_muons[j].isLoose() == 1 )
                              && ( em_from[i].getPtrChp()->DeltaR( *all_muons[j].GetChargedTrack() ) < 1e-4 ) )
                            common_track = true;
                    }
                    if( use_only_leading_lepton && i > 0 )
                        common_track = true;
                    if( !common_track )
                    {
                        l_mom = em_from[i];
                        l_track = const_cast<TMBTrack*>(em_from[i].getPtrChp());
                        lepton_charge = em_from[i].charge();
                    }
                }
            }
        }

        if (_selectSameSign) 
        {
            stat.EventSelected("Same charge selection") ;     
        }
        else
        {
            stat.EventSelected("Opposite charge selection") ;
        }
  
        SelectUserObjects<TMBMuon>::processEvent(event);
  
        return true;
    }
Exemplo n.º 5
0
// process
bool FakeAnalysis_with_ej_tree::processEvent(cafe::Event& event) {
cout <<"in Fakeanalysis code"<<endl;
  const TMBCellContainer *cells = event.get<TMBCellContainer>("CaloCells");

  vector<CAFEMObj*> emobjs;
  CAFMet met_corr;
  CAFMet met_corricd;
  CAFMet rawmet;
  

  int triglist_flag = -1;
  vector<const TMBL1CalTower*> l1cal_vec;
  vector<const TMBL1Cal2bEM*> l1cal2b_vec;
  vector<const TMBL2GblEM*> l2cal_vec;
  vector<const TMBL3Ele*> l3cal_vec;
  float event_vertex;
  float v_x,v_y,v_z;

  int solpol = -999;  
  double instlumi = 0.;


   cout<<"Good EMObjs, emobjs " <<event.get("Good EMObjs", emobjs) << endl; 
   cout<<"EMCorr Met, met_cor " <<event.get("EMCorr Met", met_corr) << endl; 
   cout<<"Raw Met, rawmet) << " <<event.get("Raw Met", rawmet) << endl;
   cout<<"EMCorr MetICD, met_ " <<event.get("EMCorr MetICD", met_corricd) << endl;
  cout<<"L1CalTowers, l1cal_ " <<event.get("L1CalTowers", l1cal_vec) << endl;  
  cout<<"L1Cal2bTowers, l1ca " <<event.get("L1Cal2bTowers", l1cal2b_vec) << endl;	
  cout<<"L2GblEMs, l2cal_vec " <<event.get("L2GblEMs", l2cal_vec) << endl; 
  cout<<"L3Eles, l3cal_vec)  " <<event.get("L3Eles", l3cal_vec) << endl; 
  cout<<"triglist flag, trig " <<event.get("triglist flag", triglist_flag) << endl; 
  cout<<"InstLumi, instlumi) " <<event.get("InstLumi", instlumi) << endl; 
  cout<<"solenoid polarity,  " <<event.get("solenoid polarity", solpol) << endl; 
  cout<<"Best primary vertexZ " <<event.get("Best primary vertexZ", v_z) << endl;
  cout<<"Best primary vertexX " <<event.get("Best primary vertexX", v_x) << endl;
  cout<<"Best primary vertexY " <<event.get("Best primary vertexY", v_y) << endl;
  cout<<" just before event.get loop"<<endl;
  if(event.get("Good EMObjs", emobjs) && 
     event.get("EMCorr Met", met_corr) && 
     event.get("Raw Met", rawmet) &&
     //event.get("EMCorr MetICD", met_corricd) &&
     event.get("L1CalTowers", l1cal_vec) &&  event.get("L1Cal2bTowers", l1cal2b_vec) &&   
     event.get("L2GblEMs", l2cal_vec) && 
     event.get("L3Eles", l3cal_vec) && event.get("triglist flag", triglist_flag) && 
     event.get("InstLumi", instlumi) && event.get("solenoid polarity", solpol) && 
     event.get("Best primary vertexZ", v_z) &&
     event.get("Best primary vertexX", v_x) &&
     event.get("Best primary vertexY", v_y)
     ) {
    cout<<" just before inst lumi"<<endl;
    if(instlumi > _InstLumi_lowcut && instlumi < _InstLumi_highcut){
	 
    	double met = met_corr.met(); 
        double set = met_corr.scalarEt();

    	double meticd = met_corricd.met(); 
        double seticd = met_corricd.scalarEt();


    	// require exactly one electron and this electron must pass trigger requirement
    	bool pass_trigger = false;

    	if(emobjs.size() == 1) 
    	  pass_trigger = emobjs[0]->PassTrigCMB(triglist_flag, 0.4, l1cal_vec, l1cal2b_vec,  l2cal_vec, l3cal_vec);
    	// only look at the electron that passes trigger requirement
    	if(pass_trigger) {

    		// get primary vertex
    		//double v_z = event_vertex;
    		char bins_Vtx[10];
    		int bin_Vtx_number;
    		bin_Vtx_number=int((v_z+60.)/20.);
    		sprintf(bins_Vtx, "%d", bin_Vtx_number);


    		// identify Zee candidates
    		// ************* code from WAnalysis *********************
    		// ************* for estimating zee bkgd *****************
			// require no high pT isolated track back-to-back with the electron
			bool EM_Track_backtoback = false;

    		// change solpol from 0/1 to -1/1
    		int polarity = 2*solpol -1;


			// get all isolated tracks
			vector<CAFTrack *> isolatedTrks;
			if(event.get("Good Tracks", isolatedTrks)) {
			  for(int itrk=0; itrk<isolatedTrks.size(); itrk++) {
	    		double em_trk_phidiff = kinem::delta_phi(emobjs[0]->Phi(), isolatedTrks[itrk]->Phi());
	    		if(em_trk_phidiff > 2.5 && // back to back with the EM cluster
	    		   fabs(isolatedTrks[itrk]->TrackDetEta(polarity, false /*_MCStudy*/))>1.1 &&  // track in ICR 
	    		   fabs(isolatedTrks[itrk]->TrackDetEta(polarity, false /*_MCStudy*/))<1.5 &&
	    		   fabs(isolatedTrks[itrk]->z()-v_z)<1. &&  // vertex close to each other 
	    		   (isolatedTrks[itrk]->charge())*(emobjs[0]->charge())<0.) { // opposite charge

	    		  TLorentzVector vect_trk(isolatedTrks[itrk]->Px(),isolatedTrks[itrk]->Py(),isolatedTrks[itrk]->Pz(),isolatedTrks[itrk]->E());
	    		  TLorentzVector vect_emobj(emobjs[0]->Px(),emobjs[0]->Py(),emobjs[0]->Pz(),emobjs[0]->E());
	    		  TLorentzVector vect_Z=vect_trk+vect_emobj;

	    		  // invariant mass
	    		  if(vect_Z.M()>70. && vect_Z.M()<110.)   EM_Track_backtoback = true;
	    		}
			  }
			}
			// end of identify Zee candidates

            if(EM_Track_backtoback==false) {

    			// construct W candidate
    			// primary vertex
    			float vtx[3]={v_x, v_y, v_z};

    			CAFWCand wcand;
    			CAFEMObj *emobj = 0;
    			double wScalarET = 0.;
    			if (emobjs.size()>=1) {
    			  emobj = emobjs[0];
    			  if(_dorawCellsRecoil) {
				if (_useConsistentMET) {
				  wcand = CAFWCand(emobj, &rawmet, vtx, true);
				} else {
				  wcand = CAFWCand(emobj, &met_corr, vtx);
				}
    			  } else {
				wcand = CAFWCand(emobj, &met_corr);
    			  }
    			  if (_useConsistentMET) {
				TVector2 consistMET=wcand.GetConsistentMET();
				double dummySET=met_corr.scalarEt();
        			wScalarET = dummySET;
				met_corr.SetMet(consistMET.X(),consistMET.Y(),consistMET.Mod(),dummySET);
    			  }
    			}

				// ejt tree code
				//entry = -555;
				run = -555;
				evt = -555;
				lumi = -555;
				vtxz = -555;
				evtmet = -555;
				evtset = -555;
				evtmeticd = -555;
				evtseticd = -555;

				wcandut = -555;
				wcandmt = -555;

				e_n = -555;
				e_pt = -555;
				e_e = -555;
				e_eta = -555;
				e_deta = -555;
				e_phi = -555;
				e_charge = -555;
				e_spmtch = -555;
				e_goodspmtch = -555;
				e_id = -555;

				j_n = -555;
				j_pt = -555;
				j_e = -555;
				j_eta = -555;
				j_deta = -555;
				j_phi = -555;
				j_trks = -555;
				j_n90 = -555;

				j_emf = -555;
				j_chf = -555;
				j_hcr = -555;
	
				ej_deltaphi = -555;
				ej_m = -555;
				ej_angle = -555;
				

    			bool found_JET=false;

				entry++;
				run=event.getGlobal()->runno();
				evt=event.getGlobal()->evtno();
				lumi=instlumi*36.0;
				vtxz=v_z;
				evtmet =  met;
				evtset =  set;
				evtmeticd =  meticd;
				evtseticd =  seticd;

    			wcandut = wcand.MagRecoil();
    			wcandmt = wcand.Mt();	

				if(emobjs[0]->has_spatial_track_match(-0.5)) e_spmtch=1;
				if(emobjs[0]->has_good_spatial_track_match()) e_goodspmtch=1;

    			e_id=emobjs[0]->id();
				e_pt=emobjs[0]->Pt();
				e_e=emobjs[0]->E();
				e_eta=emobjs[0]->Eta();
				e_deta=emobjs[0]->CalDetectorEta();
				e_phi=emobjs[0]->Phi();
				e_charge=emobjs[0]->charge();
				e_n=emobjs.size();

	            //loop over jets
				cafe::Collection<TMBJet> jets_ejttree = event.getJCCB();
    			j_n = 0;
				if(jets_ejttree.size() > 0) {
    			  for(Collection<TMBJet>::iterator iter = jets_ejttree.begin(); iter != jets_ejttree.end(); ++iter) { 
        			  j_n++;
                	  ej_deltaphi=kinem::delta_phi(e_phi, (*iter).Phi());
					  j_n90  = (*iter).n90(); 
					  j_pt   = (*iter).Pt();	 
					  j_emf  = (*iter).emf();
					  j_chf  = (*iter).chf();
					  j_hcr  = (*iter).hotcellratio();
					  j_trks = (*iter).Ntr(); 
					  j_eta  = (*iter).Eta();
					  j_phi  = (*iter).Phi();
					  j_deta = 0.1*((*iter).deta());
 					  j_e = (*iter).E();
	    			  TLorentzVector vect_jet((*iter).Px(), (*iter).Py(),(*iter).Pz(),(*iter).E());
	    			  TLorentzVector vect_emobj(emobjs[0]->Px(),emobjs[0]->Py(),emobjs[0]->Pz(),emobjs[0]->E());
	    			  TLorentzVector vect_Z=vect_jet+vect_emobj;
        			  ej_m=vect_Z.M();
					  TVector3 em_vect3 = emobjs[0]->vect3();
					  TVector3 jet_vect3( (*iter).Px(), (*iter).Py(), (*iter).Pz() );  
					  ej_angle = em_vect3.Angle(jet_vect3);
        			  found_JET = true;
                	  ej->Fill();
    			  }// for(Collection<TMBJet>
				}//if(jets_ejttree.size() > 0)
                // end of ejt tree code


    			//get jets from the event
    			cafe::Collection<TMBJet> jets = event.getJCCB(_jccb_vars);

    			for(Collection<TMBJet>::iterator iter = jets.begin(); iter!= jets.end(); ++iter) {

				if(GoodJet(*iter)) {
        		  float dphi_jet_em = kinem::delta_phi(emobjs[0]->Phi(), (*iter).Phi());
				  //get rid of the jet if they are close to each other
				  //since EM cluster may also be reconstructed as a jet
	    			if(fabs(dphi_jet_em) > _DPhi_Jet_EM_Cut) {

            			  // determine whether electron in CC or EC region
            			  int cal_region = -1; 
            			  if(emobjs[0]->IsCC(_DetEtaCC)) cal_region = 0;
            			  if(emobjs[0]->IsEC(_DetEtaEC1, _DetEtaEC2)) cal_region = 1;

            			  char region[10];  sprintf(region, "%d", cal_region);

	    				  float elec_deteta = emobjs[0]->CalDetectorEta();
	    				  float elec_eta = emobjs[0]->Eta();
	    				  float elec_pT = emobjs[0]->Pt();
					  cout<<"Fake_Electron_DetEta "<<elec_deteta<<endl;
            				  _histos.Fill1D("Fake_Electron_DetEta", elec_deteta);
	    				  _histos.Fill1D("Fake_Electron_Eta", elec_eta);
	    				  _histos.Fill1D("Fake_Electron_Pt", elec_pT);
	    				  _histos.Fill1D("Fake_Met", met);

	    				  // fill distributions for CC or EC region
	    				  _histos.Fill1D(string("Fake_Electron_DetEta_")+region, elec_deteta);
	    				  _histos.Fill1D(string("Fake_Electron_Eta_")+region, elec_eta);
	    				  _histos.Fill1D(string("Fake_Electron_Pt_")+region, elec_pT);
	    				  _histos.Fill1D(string("Fake_Met_")+region, met);


	    				  if(met< 15. && cal_region==0){
						      _histos.Fill1D(string("Fake_Electron_DetEta_CCVtxBin_")+bins_Vtx, emobjs[0]->CalDetectorEta());
	    				  }

	    				  // spatial+E/P
	    				  if(emobjs[0]->has_track_match()) {
							_histos.Fill1D("Fake_Electron_DetEta_Match", elec_deteta);
							_histos.Fill1D("Fake_Electron_Eta_Match", elec_eta);
							_histos.Fill1D("Fake_Electron_Pt_Match", elec_pT);
							_histos.Fill1D("Fake_Met_Match", met);

                					// fill distributions for CC or EC region
	        					_histos.Fill1D(string("Fake_Electron_DetEta_Match_")+region, elec_deteta);
	        					_histos.Fill1D(string("Fake_Electron_Eta_Match_")+region, elec_eta);
	        					_histos.Fill1D(string("Fake_Electron_Pt_Match_")+region, elec_pT);
                					_histos.Fill1D(string("Fake_Met_Match_")+region, met);
	    				  }

	    			  // spatial only
	    			  if(emobjs[0]->has_good_spatial_track_match()) {
						_histos.Fill1D("Fake_Electron_DetEta_Spatial_Match", elec_deteta);
						_histos.Fill1D("Fake_Electron_Eta_Spatial_Match", elec_eta);
						_histos.Fill1D("Fake_Electron_Pt_Spatial_Match", elec_pT);
						_histos.Fill1D("Fake_Met_Spatial_Match", met);

                				// fill distributions for CC or EC region
	        				_histos.Fill1D(string("Fake_Electron_DetEta_Spatial_Match_")+region, elec_deteta);
	        				_histos.Fill1D(string("Fake_Electron_Eta_Spatial_Match_")+region, elec_eta);
	        				_histos.Fill1D(string("Fake_Electron_Pt_Spatial_Match_")+region, elec_pT);
                				_histos.Fill1D(string("Fake_Met_Spatial_Match_")+region, met);

						if(met< 15. && cal_region==0){
						  _histos.Fill1D(string("Fake_Electron_DetEta_CCVtxBin_Spatial_Match_")+bins_Vtx, emobjs[0]->CalDetectorEta());
						}
	    			  }

	    			  // spatial only+SMT,CFT
	    			  if(emobjs[0]->has_spatial_track_match(-0.5)) {
						  // check chi2 vs met
						  _histos.Fill2D("Fake_Electron_Chi2_V_Met_Spatial_Match", met, emobjs[0]->track_match_spatialchi2prob());
						  _histos.Fill2D(string("Fake_Electron_Chi2_V_Met_Spatial_Match_")+region, met, emobjs[0]->track_match_spatialchi2prob());
                	    		  _histos.Fill1D("Fake_Electron_Chi2", emobjs[0]->track_match_spatialchi2prob());
                	    		  _histos.Fill1D(string("Fake_Electron_Chi2_")+region, emobjs[0]->track_match_spatialchi2prob());

						  double ElecPt = emobjs[0]->Pt();
						  double TrkPt = emobjs[0]->getPtrSpatialChp()->Pt();
						  double EOverP = 0.;
						  if(TrkPt>0.) EOverP = ElecPt/TrkPt;

						  if(emobjs[0]->getPtrSpatialChp()->nsmt()>=1 && emobjs[0]->getPtrSpatialChp()->ncft()>=4) {

							  // check chi2 vs met
							  _histos.Fill2D("Fake_Electron_Chi2_V_Met_Spatial_Match_Tight", met, emobjs[0]->track_match_spatialchi2prob());
							  _histos.Fill2D(string("Fake_Electron_Chi2_V_Met_Spatial_Match_Tight_")+region, met, emobjs[0]->track_match_spatialchi2prob());
                					  _histos.Fill1D("Fake_Electron_Chi2_Tight", emobjs[0]->track_match_spatialchi2prob());
                					  _histos.Fill1D(string("Fake_Electron_Chi2_Tight_")+region, emobjs[0]->track_match_spatialchi2prob());

							  _histos.Fill1D("Fake_Electron_DetEta_Spatial_Match_Tight", elec_deteta);
							  _histos.Fill1D("Fake_Electron_Eta_Spatial_Match_Tight", elec_eta);
							  _histos.Fill1D("Fake_Electron_Pt_Spatial_Match_Tight", elec_pT);
							  _histos.Fill1D("Fake_Met_Spatial_Match_Tight", met);

							  // fill distributions for CC or EC region
							  _histos.Fill1D(string("Fake_Electron_DetEta_Spatial_Match_Tight_")+region, elec_deteta);
							  _histos.Fill1D(string("Fake_Electron_Eta_Spatial_Match_Tight_")+region, elec_eta);
							  _histos.Fill1D(string("Fake_Electron_Pt_Spatial_Match_Tight_")+region, elec_pT);
							  _histos.Fill1D(string("Fake_Met_Spatial_Match_Tight_")+region, met);
				    	  }
	    			  }

	    			  //#######################################################
	    			  // same histograms for met<_MetCut_FakeRate
	    			  //#######################################################
	    			  if( met < _MetCut_FakeRate ) {
						_histos.Fill1D("Fake_Electron_DetEta_MetCut", elec_deteta);
						_histos.Fill1D("Fake_Electron_Eta_MetCut", elec_eta);
						_histos.Fill1D("Fake_Electron_Pt_MetCut", elec_pT);

						// fill distributions for CC or EC region
						_histos.Fill1D(string("Fake_Electron_DetEta_MetCut_")+region, elec_deteta);
						_histos.Fill1D(string("Fake_Electron_Eta_MetCut_")+region, elec_eta);
						_histos.Fill1D(string("Fake_Electron_Pt_MetCut_")+region, elec_pT);

						// spatial+E/P
						if(emobjs[0]->has_track_match()) {
						  _histos.Fill1D("Fake_Electron_DetEta_Match_MetCut", elec_deteta);
						  _histos.Fill1D("Fake_Electron_Eta_Match_MetCut", elec_eta);
						  _histos.Fill1D("Fake_Electron_Pt_Match_MetCut", elec_pT);

						  // fill distributions for CC or EC region
						  _histos.Fill1D(string("Fake_Electron_DetEta_Match_MetCut_")+region, elec_deteta);
						  _histos.Fill1D(string("Fake_Electron_Eta_Match_MetCut_")+region, elec_eta);
						  _histos.Fill1D(string("Fake_Electron_Pt_Match_MetCut_")+region, elec_pT);
						}

						// good spatial only
						if(emobjs[0]->has_good_spatial_track_match()) {
						  _histos.Fill1D("Fake_Electron_DetEta_Spatial_Match_MetCut", elec_deteta);
						  _histos.Fill1D("Fake_Electron_Eta_Spatial_Match_MetCut", elec_eta);
						  _histos.Fill1D("Fake_Electron_Pt_Spatial_Match_MetCut", elec_pT);

						  // fill distributions for CC or EC region
						  _histos.Fill1D(string("Fake_Electron_DetEta_Spatial_Match_MetCut_")+region, elec_deteta);
						  _histos.Fill1D(string("Fake_Electron_Eta_Spatial_Match_MetCut_")+region, elec_eta);
						  _histos.Fill1D(string("Fake_Electron_Pt_Spatial_Match_MetCut_")+region, elec_pT);
						}

						// spatial only+SMT,CFT+E/p
						if(emobjs[0]->has_spatial_track_match(-0.5)) {
						  double ElecPt = emobjs[0]->Pt();
						  double TrkPt = emobjs[0]->getPtrSpatialChp()->Pt();
						  double EOverP = 0.;
						  if(TrkPt>0.) EOverP = ElecPt/TrkPt;

						  if(emobjs[0]->getPtrSpatialChp()->nsmt()>=1 && emobjs[0]->getPtrSpatialChp()->ncft()>=4) {
		    				_histos.Fill1D("Fake_Electron_DetEta_Spatial_Match_Tight_MetCut", elec_deteta);
		    				_histos.Fill1D("Fake_Electron_Eta_Spatial_Match_Tight_MetCut", elec_eta);
		    				_histos.Fill1D("Fake_Electron_Pt_Spatial_Match_Tight_MetCut", elec_pT);

		    				// fill distributions for CC or EC region
		    				_histos.Fill1D(string("Fake_Electron_DetEta_Spatial_Match_Tight_MetCut_")+region, elec_deteta);
		    				_histos.Fill1D(string("Fake_Electron_Eta_Spatial_Match_Tight_MetCut_")+region, elec_eta);
		    				_histos.Fill1D(string("Fake_Electron_Pt_Spatial_Match_Tight_MetCut_")+region, elec_pT);
						  }
						}

	    			  } // missing Et cut

	    			} // EM and Jet are back-to-back
				}
    		    } // loop over jets

	    }//if(EM_Track_backtoback==false) i.e. this is not zee event 

    	}// exactly one good EM object and pass trigger

    }//lumi cut
  }// if event.get loop
  cout<<" end of process event" <<endl;
  return true;
}