コード例 #1
0
ファイル: GoodRuns.cpp プロジェクト: hengne/d0wmass
    bool GoodRuns::processEvent(cafe::Event& event)
    {
	if (_useRuns)
	    return _goodRuns.find(event.getGlobal(_vars)->runno()) != _goodRuns.end();
	else
	    return _goodRuns.find(event.getGlobal(_vars)->runno()) == _goodRuns.end();
    }
コード例 #2
0
ファイル: VtxSelector.cpp プロジェクト: hengne/d0wmass
//
// put pointers into event class 
//
void VtxSelector::putPointers(cafe::Event& event) {
  event.put("Primary vertexX", _event_vertex[0]);
  event.put("Primary vertexY", _event_vertex[1]);
  event.put("Primary vertexZ", _event_vertex[2]);
  event.put("New primary vertexX", _track_vertex[0]);
  event.put("New primary vertexY", _track_vertex[1]);
  event.put("New primary vertexZ", _track_vertex[2]);
}
コード例 #3
0
ファイル: TriggerSelection.cpp プロジェクト: hengne/d0wmass
  bool TriggerEpoch::isEpoch(const cafe::Event& event) const {

    if (_trigVerMin <= 0) return event.isEpoch(_name) ;
    
    float trigVer = _runnum_to_triggerversion.TriggerVersion(event.getGlobal()->runno());
    
    if ( trigVer >= _trigVerMin && trigVer <= _trigVerMax) return true ;

    return false ;
  }
コード例 #4
0
ファイル: BadLBNs.cpp プロジェクト: hengne/d0wmass
    bool BadLBNs::processEvent(cafe::Event& event)
    {
	if(_MC) {
	    // Monte Carlo
	    return _badLBNs.find(event.getMCEventInfo(_vars)->overlaylumblk()) == _badLBNs.end();	    
	} else {
	    // Data
	    return _badLBNs.find(event.getGlobal(_vars)->lumblk()) == _badLBNs.end();
	}
    }
コード例 #5
0
ファイル: L2RecoMatchTest.cpp プロジェクト: hengne/d0wmass
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;
};
コード例 #6
0
ファイル: RemoveObjects.cpp プロジェクト: hengne/d0wmass
    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;
    }
コード例 #7
0
ファイル: FakeAnalysis.cpp プロジェクト: hengne/d0wmass
// 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;
}
コード例 #8
0
    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;
    }
コード例 #9
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;
}
コード例 #10
0
ファイル: VtxSelector.cpp プロジェクト: hengne/d0wmass
//
// extract event vertex and track vertex 
//
void VtxSelector::extract(cafe::Event& event, const vector<CAFEMObj*>& emobjs, int& nvtx) {  
 
  // Primary Vertex
  Collection<TMBPrimaryVertex> vertices = event.getPrimaryVertices(_PV_vars);

  // event vertex from the first primary vertex
  nvtx = vertices.size();

  if(nvtx>0) {
    _event_vertex[0] = vertices[0].vx();
    _event_vertex[1] = vertices[0].vy();
    _event_vertex[2] = vertices[0].vz();
  } else {
    _event_vertex[0] = 0.;
    _event_vertex[1] = 0.;
    _event_vertex[2] = 0.;
  }

  if(_debugLevel>=10) cout<<"Old primary vertex="<<_event_vertex[0]<<" "
                          <<_event_vertex[1]<<" "<<_event_vertex[2]<<endl;

  //
  // get beam spot position for this run 
  // and then correct for the beam spot position
  // comment out by J. Zhu on Sep 17, 2006
  // I do not really believe that we need to do this beam spot corrections
  //
  // int runno = event.getGlobal(_global_vars)->runno();
  //   float xoffset=0., yoffset=0., xslope=0., yslope=0.;
  
  //   BeamSpotManager *beamspot_manager = BeamSpotManager::get_instance();
  //   if(beamspot_manager){
  //     const map<int, BEAMSPOT_STRUCT>& beamspot_map = beamspot_manager->BeamSpotMap();
  
  //     map<int, BEAMSPOT_STRUCT>::const_iterator iter = beamspot_map.find(runno);
  //     if(iter != beamspot_map.end()){
  //       xoffset = (*iter).second.xoffset;
  //       yoffset = (*iter).second.yoffset;
  //       xslope = (*iter).second.xslope;
  //       yslope = (*iter).second.yslope;
  //     }
  //   }
  
  // if no tracks found, Z of the track vertex will be the same as that of event vertex
  float vtx_new_z = _event_vertex[2];

  // if two EM clusters have track match, using the average track Z postion
  // if only one EM cluster has track match, just use the track Z position
  // if the track Z position and the D0reco primary vertex are far away from each, 
  // will modify met later in ObjSelector

  if(emobjs.size() >= 1) { // at least one good EM cluster
    bool has_trk1 = emobjs[0]->has_good_spatial_track_match();
    
    if(emobjs.size() >= 2) { // at least two good EM clusters
      bool has_trk2 = emobjs[1]->has_good_spatial_track_match();
      
      if(has_trk1 && has_trk2) {
	vtx_new_z = ( (emobjs[0]->getPtrSpatialChp())->z() + (emobjs[1]->getPtrSpatialChp())->z())/2.;      
      } else if(has_trk1 || has_trk2) {
	if(has_trk1) vtx_new_z = (emobjs[0]->getPtrSpatialChp())->z();
	else vtx_new_z = (emobjs[1]->getPtrSpatialChp())->z();
      }    
    } else if (emobjs.size() == 1) // only one good EM cluster
      if(has_trk1) vtx_new_z = (emobjs[0]->getPtrSpatialChp())->z();
  }

  // find corrected primary vertex 
  //  _track_vertex[0] = xoffset + xslope * vtx_new_z;
  //  _track_vertex[1] = yoffset + yslope * vtx_new_z;
  _track_vertex[0] = _event_vertex[0];
  _track_vertex[1] = _event_vertex[1];
  _track_vertex[2] = vtx_new_z;
  
  if(_debugLevel>=10) cout<<"New primary vertex="<<_track_vertex[0]<<" "
                          <<_track_vertex[1]<<" "<<_track_vertex[2]<<endl;
  
}
コード例 #11
0
void cafTriggerEfficiency::change_request( cafe::Event &event ){

  cafe::Config config(name());
  
  
  
  if (!MCREQID) throw runtime_error("ERROR:  processor MCReqID is not initialized.") ;
  
  // verify if request id is stay the same. In that case do nothing.
  
  if ( MCREQID->reqid() == _reqid ) return ;
  _reqid = MCREQID->reqid() ;
  
    // verify data epochs associated to this MC
  const vector<string>* epochs =  MCREQID->current_data_epochs();




  //------------------------------------
  // Get the list of trigger versions
  //
  // Config should have trigger versions listed for each data epoch, like:
  // caftrig.triglist_RunIIa: 	08,09a,09b,10,11,12,13a,13b,13c,14
  // caftrig.triglist_RunIIb1: 	15a,15b
  // caftrig.triglist_RunIIb2: 	15c,16a,16b,16c
  // caftrig.triglist_RunIIb3: 	16d,16e
  //
  // And if more than one data epoch is used the lists will be concatinated here.
  //------------------------------------
  vector<string> triggerList;
  if(debug()>0) cout<<"Get trigger versions."<<endl;
  for (vector<string>::const_iterator eit=epochs->begin(); eit!=epochs->end(); eit++){
    vector<string> tmp_versions = config.getVString(("triglist_"+ *eit),",");
    triggerList.insert(triggerList.end(),tmp_versions.begin(),tmp_versions.end());
    if(debug()>0) cout<<"Added "<<tmp_versions.size()<<" trigger versions for "<<*eit<<endl;
  }
  
  vector<float> lumi, lumi1, lumi2;
  if (!_dqLumi) {
    out() << "Luminosity for each trigger is read from  the config file. " << endl ;  
    for (vector<string>::const_iterator eit=epochs->begin(); eit!=epochs->end(); eit++){

      vector<float> tmp_lumi;
      tmp_lumi = config.getVFloat(("lumi_"+ *eit),",");
      lumi.insert(lumi.end(),tmp_lumi.begin(),tmp_lumi.end());

      tmp_lumi.clear();
      tmp_lumi = config.getVFloat(("lumi1_"+ *eit),",");
      lumi1.insert(lumi1.end(),tmp_lumi.begin(),tmp_lumi.end());

      tmp_lumi.clear();
      tmp_lumi = config.getVFloat(("lumi2_"+ *eit),",");
      lumi2.insert(lumi2.end(),tmp_lumi.begin(),tmp_lumi.end());
    }
    
  } else {    
    CafeDataQualityLuminosity* dq_lumi = CafeDataQualityLuminosityInstance() ;
    if (!dq_lumi) 
      throw runtime_error("cafTriggerEfficiency ["+name()+"]: need DQ processor instantiated with lumicache file. No DQLuminosity object was found!") ;
    
    // read file caf_trigger/parameters/trignames.txt with correspondence between
    // trigger names and trigger versions
    ifstream fnames("caf_trigger/parameters/trignames.txt") ;
    if (!fnames)  
      throw runtime_error("Could not read file caf_trigger/parameters/trignames.txt") ;
    
    map<string,pair<float, float> > trig_names ;
    float t1=0, t2=0 ;
    string in_string, tname ;
    while ( getline(fnames,in_string) ) {
      istringstream s(in_string) ;
      s >> tname >> t1  >> t2 ;
      if (!tname.empty()) trig_names[tname] = pair<float,float>(t1,t2) ;
    }
    fnames.close() ;
    
    for (vector<string>::const_iterator it = triggerList.begin(); it != triggerList.end(); it++) {
      pair<float,float> trs = trig_names[*it] ;
      lumi.push_back(dq_lumi->integrateRecordedDqLuminosityByTriggerVersion(trs.first, trs.second));
    }
  }
  
  if ( lumi.size() != triggerList.size() ) {
    out() << "cafTriggerEfficiency::cafTriggerEfficiency" << endl ;
    out() << "- Error: The triggerlist and luminosity vectors must be equal in number" << endl;
    out() << endl;
    out() << "Lumi vector:" << endl;
    for(int i = 0; i < lumi.size(); ++i) {
      out() << "Lumi[" << i << "] = " << lumi[i] << endl;
    }
    
    out() << "TriggerList vector:" << endl;
    for(int i = 0; i < triggerList.size(); ++i) {
      out() << "TriggerList[" << i << "] = " << triggerList[i] << endl;
    }
    
    exit(1);
  }
  
  if ( lumi1.size() == 0 ) lumi1=lumi;
  if ( lumi2.size() == 0 ) lumi2=lumi;
  
  if ( lumi.size() != lumi1.size() || lumi.size() != lumi2.size() ) {
    err()   << "cafTriggerEfficiency::cafTriggerEfficiency" << endl
	   << "- Error: The luminosity vectors must be equal in number" << endl;
    err() << endl;
    err() << "Lumi vector" << endl;
    for(int i = 0; i < lumi.size(); ++i) {
      err() << "Lumi[" << i << "] = " << lumi[i] << endl;
    }
    for(int i = 0; i < lumi1.size(); ++i) {
      err() << "Lumi1[" << i << "] = " << lumi1[i] << endl;
    }
    for(int i = 0; i < lumi2.size(); ++i) {
      err() << "Lumi2[" << i << "] = " << lumi2[i] << endl;
    }
    
    exit(1);
  }
  
  //We place this information into a mapping for (triggerList, lumi)
  for(int i = 0; i < lumi.size(); ++i) {
    _mapVersionLumi[triggerList[i]] = lumi[i];
    _mapVersionLumi1[triggerList[i]] = lumi1[i];
    _mapVersionLumi2[triggerList[i]] = lumi2[i];
  }
 
  
  out() << endl << "////////////////////////////////////" << endl ;
  out() << "TriggerEfficiency Calculations: Lumi information:" << endl ;
  if (_dqLumi) 
    out() << "Read luminosity for each run range from lumicache file." << endl ;
  else 
    out() << "Read luminosity from the configuration file" << endl ;

  _lumi_tot = 0.0 ;
  for(map<string, float>::iterator it = _mapVersionLumi.begin(); it != _mapVersionLumi.end(); ++it) {
      out()   << "Trigger version: " << (*it).first
	     << " with lumi: " << (*it).second << endl;
      _lumi_tot += (*it).second  ;
    }
  out() << "Lumi total: " << _lumi_tot << " pb" << endl ;

  /// What is this for? -Joe
  //The sigma calculations
  string sigma = config.get("sigma", "false");
  if(sigma != "false") {
    out() << "with Sigma +1, -1 calculations" << endl;
  }
  out()    << "////////////////////////////////////" << endl;


  // replace maps in event
  event.put("passedVersionLumi", _mapVersionLumi);
  event.put("passedVersionLumi1", _mapVersionLumi1);
  event.put("passedVersionLumi2", _mapVersionLumi2);
  
}