예제 #1
0
//
// 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]);
}
예제 #2
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);
  
}