CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes

EcalSelectiveReadoutProducer Class Reference

#include <EcalSelectiveReadoutProducer.h>

Inheritance diagram for EcalSelectiveReadoutProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 EcalSelectiveReadoutProducer (const edm::ParameterSet &params)
virtual void produce (edm::Event &event, const edm::EventSetup &eventSetup)
virtual ~EcalSelectiveReadoutProducer ()

Static Public Member Functions

static void printSrFlags (std::ostream &os, const EBSrFlagCollection &ebSrFlags, const EESrFlagCollection &eeSrFlags, int iEvent=-1, bool withHeader=true)

Private Member Functions

void checkWeights (const edm::Event &evt, const edm::ProductID &noZSDigiId) const
bool getBinOfMax (const edm::Event &evt, const edm::ProductID &noZsDigiId, int &binOfMax) const
const EBDigiCollectiongetEBDigis (edm::Event &event) const
const EEDigiCollectiongetEEDigis (edm::Event &event) const
const EcalTrigPrimDigiCollectiongetTrigPrims (edm::Event &event) const
void printTTFlags (const EcalTrigPrimDigiCollection &tp, std::ostream &os) const
void checkGeometry (const edm::EventSetup &eventSetup)
void checkTriggerMap (const edm::EventSetup &eventSetup)
void checkElecMap (const edm::EventSetup &eventSetup)

Static Private Member Functions

static void checkValidity (const EcalSRSettings &settings)

Private Attributes

std::string digiProducer_
int dumpFlags_
std::string ebdigiCollection_
std::string ebSrFlagCollection_
std::string ebSRPdigiCollection_
std::string eedigiCollection_
std::string eeSrFlagCollection_
std::string eeSRPdigiCollection_
edm::ParameterSet params_
bool produceDigis_
const EcalSRSettingssettings_
std::auto_ptr< EcalSRSettingssettingsFromFile_
std::auto_ptr
< EcalSelectiveReadoutSuppressor
suppressor_
const EcalElectronicsMappingtheElecMap
const CaloGeometrytheGeometry
const
EcalTrigTowerConstituentsMap
theTriggerTowerMap
bool trigPrimBypass_
int trigPrimBypassMode_
std::string trigPrimCollection_
std::string trigPrimProducer_
bool useCondDb_
bool writeSrFlags_

Detailed Description

Definition at line 17 of file EcalSelectiveReadoutProducer.h.


Constructor & Destructor Documentation

EcalSelectiveReadoutProducer::EcalSelectiveReadoutProducer ( const edm::ParameterSet params) [explicit]

Constructor

Parameters:
paramsseletive readout parameters

Definition at line 19 of file EcalSelectiveReadoutProducer.cc.

References digiProducer_, dumpFlags_, ebdigiCollection_, ebSrFlagCollection_, ebSRPdigiCollection_, eedigiCollection_, eeSrFlagCollection_, eeSRPdigiCollection_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), EcalSRCondTools::importParameterSet(), produceDigis_, settings_, settingsFromFile_, theElecMap, theGeometry, theTriggerTowerMap, trigPrimBypass_, trigPrimBypassMode_, trigPrimCollection_, trigPrimProducer_, useCondDb_, and writeSrFlags_.

  : params_(params)
{
  //settings:
  //  settings which are only in python config files:
  digiProducer_ = params.getParameter<string>("digiProducer");
  ebdigiCollection_ = params.getParameter<std::string>("EBdigiCollection");
  eedigiCollection_ = params.getParameter<std::string>("EEdigiCollection");
  ebSRPdigiCollection_ = params.getParameter<std::string>("EBSRPdigiCollection");
  eeSRPdigiCollection_ = params.getParameter<std::string>("EESRPdigiCollection");
  ebSrFlagCollection_ = params.getParameter<std::string>("EBSrFlagCollection");
  eeSrFlagCollection_ = params.getParameter<std::string>("EESrFlagCollection");
  trigPrimProducer_ = params.getParameter<string>("trigPrimProducer");
  trigPrimCollection_ = params.getParameter<string>("trigPrimCollection");
  trigPrimBypass_ = params.getParameter<bool>("trigPrimBypass");
  trigPrimBypassMode_ = params.getParameter<int>("trigPrimBypassMode");
  dumpFlags_ = params.getUntrackedParameter<int>("dumpFlags", 0);
  writeSrFlags_ = params.getUntrackedParameter<bool>("writeSrFlags", false);
  produceDigis_ = params.getUntrackedParameter<bool>("produceDigis", true);
  //   settings which can come from either condition database or python configuration file:
  useCondDb_ = false;
  try{
    if(params.getParameter<bool>("configFromCondDB")){
      useCondDb_ = true;
    }
  } catch(cms::Exception){
    /* pameter not found */
    edm::LogWarning("EcalSelectiveReadout") << "Parameter configFromCondDB of EcalSelectiveReadout module not found. "
      "Selective readout configuration will be read from python file.";
  }
  if(!useCondDb_){
    settingsFromFile_ = auto_ptr<EcalSRSettings>(new EcalSRSettings());
    EcalSRCondTools::importParameterSet(*settingsFromFile_, params);
    settings_ = settingsFromFile_.get();
  }

  //declares the products made by this producer:
  if(produceDigis_){
    produces<EBDigiCollection>(ebSRPdigiCollection_);
    produces<EEDigiCollection>(eeSRPdigiCollection_);
  }

  if (writeSrFlags_) {
    produces<EBSrFlagCollection>(ebSrFlagCollection_);
    produces<EESrFlagCollection>(eeSrFlagCollection_);
  }

  theGeometry = 0;
  theTriggerTowerMap = 0;
  theElecMap = 0;
}
EcalSelectiveReadoutProducer::~EcalSelectiveReadoutProducer ( ) [virtual]

Destructor

Definition at line 73 of file EcalSelectiveReadoutProducer.cc.

{ }

Member Function Documentation

void EcalSelectiveReadoutProducer::checkElecMap ( const edm::EventSetup eventSetup) [private]

Definition at line 241 of file EcalSelectiveReadoutProducer.cc.

References edm::EventSetup::get(), suppressor_, and theElecMap.

Referenced by produce().

{

   edm::ESHandle<EcalElectronicsMapping> eElecmap;
   eventSetup.get<EcalMappingRcd>().get(eElecmap);

   const EcalElectronicsMapping * pMap = &*eElecmap;

  // see if we need to update
  if(pMap!= theElecMap) {
    theElecMap = pMap;
    suppressor_->setElecMap(theElecMap);
  }
}
void EcalSelectiveReadoutProducer::checkGeometry ( const edm::EventSetup eventSetup) [private]

call these once an event, to make sure everything is up-to-date

Definition at line 210 of file EcalSelectiveReadoutProducer.cc.

References edm::EventSetup::get(), suppressor_, and theGeometry.

Referenced by produce().

{
  edm::ESHandle<CaloGeometry> hGeometry;
  eventSetup.get<CaloGeometryRecord>().get(hGeometry);

  const CaloGeometry * pGeometry = &*hGeometry;

  // see if we need to update
  if(pGeometry != theGeometry) {
    theGeometry = pGeometry;
    suppressor_->setGeometry(theGeometry);
  }
}
void EcalSelectiveReadoutProducer::checkTriggerMap ( const edm::EventSetup eventSetup) [private]

Definition at line 225 of file EcalSelectiveReadoutProducer.cc.

References edm::EventSetup::get(), suppressor_, and theTriggerTowerMap.

Referenced by produce().

{

   edm::ESHandle<EcalTrigTowerConstituentsMap> eTTmap;
   eventSetup.get<IdealGeometryRecord>().get(eTTmap);

   const EcalTrigTowerConstituentsMap * pMap = &*eTTmap;

  // see if we need to update
  if(pMap!= theTriggerTowerMap) {
    theTriggerTowerMap = pMap;
    suppressor_->setTriggerMap(theTriggerTowerMap);
  }
}
void EcalSelectiveReadoutProducer::checkValidity ( const EcalSRSettings settings) [static, private]

Checks validity of selective setting object is valid to be used for MC, especially checks the number of elements in the vectors

Parameters:
forEmulatorif true check the restriction that applies for EcalSelectiveReadoutProducer
Exceptions:
cms::Exceptionif the setting is not valid.

Definition at line 494 of file EcalSelectiveReadoutProducer.cc.

References EcalSRSettings::dccNormalizedWeights_, EcalSRSettings::ecalDccZs1stSample_, and Exception.

Referenced by produce().

                                                                              {
  if(settings.dccNormalizedWeights_.size() != 1){
    throw cms::Exception("Configuration") << "Selective readout emulator, EcalSelectiveReadout, supports only single set of ZS weights. "
      "while the configuration contains " << settings.dccNormalizedWeights_.size() << " set(s)\n";
  }
  
//   if(settings.dccNormalizedWeights_.size() != 1
//      && settings.dccNormalizedWeights_.size() != 2
//      && settings.dccNormalizedWeights_.size() != 54
//      && settings.dccNormalizedWeights_.size() != 75848){
//     throw cms::Exception("Configuration") << "Invalid number of DCC weight set (" << settings.dccNormalizedWeights_.size()
//                                        << ") in condition object EcalSRSetting::dccNormalizedWeights_. "
//                                        << "Valid counts are: 1 (single set), 2 (EB and EE), 54 (one per DCC) and 75848 "
//       "(one per crystal)\n";
//   }
  
  if(settings.dccNormalizedWeights_.size() != settings.ecalDccZs1stSample_.size()){
    throw cms::Exception("Configuration") << "Inconsistency between number of weigth sets ("
                                          << settings.dccNormalizedWeights_.size() << ") and "
                                          << "number of ecalDccZs1Sample values ("
                                          << settings.ecalDccZs1stSample_.size() << ").";
  }  
}
void EcalSelectiveReadoutProducer::checkWeights ( const edm::Event evt,
const edm::ProductID noZSDigiId 
) const [private]

Sanity check on the DCC FIR filter weights. Log warning or error message if an unexpected weight set is found. In principle it is checked that the maximum weight is applied to the expected maximum sample.

Definition at line 293 of file EcalSelectiveReadoutProducer.cc.

References EcalSRSettings::dccNormalizedWeights_, EcalSRSettings::ecalDccZs1stSample_, getBinOfMax(), EcalSelectiveReadoutSuppressor::getFIRTapCount(), i, settings_, and create_public_pileup_plots::weights.

Referenced by getEBDigis(), and getEEDigis().

                                                                                     {
  const vector<float> & weights = settings_->dccNormalizedWeights_[0]; //params_.getParameter<vector<double> >("dccNormalizedWeights");
  int nFIRTaps = EcalSelectiveReadoutSuppressor::getFIRTapCount();
  static bool warnWeightCnt = true;
  if((int)weights.size() > nFIRTaps && warnWeightCnt){
      edm::LogWarning("Configuration") << "The list of DCC zero suppression FIR "
        "weights given in parameter dccNormalizedWeights is longer "
        "than the expected depth of the FIR filter :(" << nFIRTaps << "). "
        "The last weights will be discarded.";
      warnWeightCnt = false; //it's not needed to repeat the warning.
  }

  if(weights.size()>0){
    int iMaxWeight = 0;
    double maxWeight = weights[iMaxWeight];
    //looks for index of maximum weight
    for(unsigned i=0; i<weights.size(); ++i){
      if(weights[i]>maxWeight){
        iMaxWeight = i;
        maxWeight = weights[iMaxWeight];
      }
    }

    //position of time sample whose maximum weight is applied:
    int maxWeightBin = settings_->ecalDccZs1stSample_[0] //params_.getParameter<int>("ecalDccZs1stSample")
      + iMaxWeight;
    
    //gets the bin of maximum (in case of raw data it will not exist)
    int binOfMax = 0;
    bool rc = getBinOfMax(evt, noZsDigiId, binOfMax);

    if(rc && maxWeightBin!=binOfMax){
      edm::LogWarning("Configuration")
        << "The maximum weight of DCC zero suppression FIR filter is not "
        "applied to the expected maximum sample(" << binOfMax
        << (binOfMax==1?"st":(binOfMax==2?"nd":(binOfMax==3?"rd":"th")))
        << " time sample). This may indicate faulty 'dccNormalizedWeights' "
        "or 'ecalDccZs1sSample' parameters.";
    }
  }
}
bool EcalSelectiveReadoutProducer::getBinOfMax ( const edm::Event evt,
const edm::ProductID noZsDigiId,
int &  binOfMax 
) const [private]

Gets the value of the digitizer binOfMaximum parameter.

Parameters:
noZsDigiIdproduct ID of the non-suppressed digis
binOfMax[out] set the parameter value if found
Returns:
true on success, false otherwise

Definition at line 337 of file EcalSelectiveReadoutProducer.cc.

References spr::find(), edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNames(), edm::getParameterSet(), edm::Event::getProvenance(), AlCaHLTBitMon_ParallelJobs::p, edm::Provenance::psetID(), and query::result.

Referenced by checkWeights().

                                                              {
  bool rc;
  const edm::Provenance p=evt.getProvenance(noZsDigiId);
  edm::ParameterSet result = getParameterSet(p.psetID());
  vector<string> ebDigiParamList = result.getParameterNames();
  string bofm("binOfMaximum");
  if(find(ebDigiParamList.begin(), ebDigiParamList.end(), bofm)
     != ebDigiParamList.end()){//bofm found
    binOfMax=result.getParameter<int>("binOfMaximum");
    rc = true;
  } else{
    rc = false;
  }
  return rc;
}
const EBDigiCollection * EcalSelectiveReadoutProducer::getEBDigis ( edm::Event event) const [private]

Definition at line 170 of file EcalSelectiveReadoutProducer.cc.

References checkWeights(), digiProducer_, ebdigiCollection_, edm::HandleBase::id(), edm::Handle< T >::product(), and query::result.

Referenced by produce().

{
  edm::Handle<EBDigiCollection> hEBDigis;
  event.getByLabel(digiProducer_, ebdigiCollection_, hEBDigis);
  //product() method is called before id() in order to get an exception
  //if the handle is not available (check not done by id() method).
  const EBDigiCollection* result = hEBDigis.product();
  static bool firstCall= true;
  if(firstCall){
    checkWeights(event, hEBDigis.id());
    firstCall = false;
  }
  return result;
}
const EEDigiCollection * EcalSelectiveReadoutProducer::getEEDigis ( edm::Event event) const [private]

Definition at line 186 of file EcalSelectiveReadoutProducer.cc.

References checkWeights(), digiProducer_, eedigiCollection_, edm::HandleBase::id(), edm::Handle< T >::product(), and query::result.

Referenced by produce().

{
  edm::Handle<EEDigiCollection> hEEDigis;
  event.getByLabel(digiProducer_, eedigiCollection_, hEEDigis);
  //product() method is called before id() in order to get an exception
  //if the handle is not available (check not done by id() method).
  const EEDigiCollection* result = hEEDigis.product();
  static bool firstCall = true;
  if(firstCall){
    checkWeights(event, hEEDigis.id());
    firstCall = false;
  }
  return result;
}
const EcalTrigPrimDigiCollection * EcalSelectiveReadoutProducer::getTrigPrims ( edm::Event event) const [private]

Definition at line 202 of file EcalSelectiveReadoutProducer.cc.

References edm::Handle< T >::product(), trigPrimCollection_, and trigPrimProducer_.

Referenced by produce().

{
  edm::Handle<EcalTrigPrimDigiCollection> hTPDigis;
  event.getByLabel(trigPrimProducer_, trigPrimCollection_, hTPDigis);
  return hTPDigis.product();
}
void EcalSelectiveReadoutProducer::printSrFlags ( std::ostream &  os,
const EBSrFlagCollection ebSrFlags,
const EESrFlagCollection eeSrFlags,
int  iEvent = -1,
bool  withHeader = true 
) [static]

Help function to print SR flags.

Parameters:
ebSrFlagsthe action flags of EB
eeSrFlagthe action flags of EE
iEventevent number. Ignored if <0.
withHeader,iftrue an output description is written out as header.

Definition at line 356 of file EcalSelectiveReadoutProducer.cc.

References edm::SortedCollection< T, SORT >::begin(), edm::SortedCollection< T, SORT >::end(), i, EESrFlag::id(), EBSrFlag::id(), EcalTrigTowerDetId::ieta(), EcalTrigTowerDetId::iphi(), EcalScDetId::ix(), EcalScDetId::iy(), nEndcaps, srpFlagMarker, lumiQTWidget::t, cond::rpcobgas::time, EcalSrFlag::value(), and EcalScDetId::zside().

Referenced by produce().

                                                           {
  const char srpFlagMarker[] = {'.', 'z', 'Z', 'F', '4','5','6','7'};
  if(withHeader){
    time_t t;
    time(&t);
    const char* date = ctime(&t);
    os << "#SRP flag map\n#\n"
      "# Generatied on: " << date << "\n#\n"
      "# +-->Phi/Y " << srpFlagMarker[0] << ": suppressed\n"
      "# |         " << srpFlagMarker[1] << ": ZS 1\n"
      "# |         " << srpFlagMarker[2] << ": ZS 2\n"
      "# V Eta/X   " << srpFlagMarker[3] << ": full readout\n"
      "#\n";
  }

  //EE-,EB,EE+ map wil be written onto file in following format:
  //
  //      72
  // <-------------->
  //  20
  // <--->
  //  EEE                A             +-----> Y
  // EEEEE               |             |
  // EE EE               | 20   EE-    |
  // EEEEE               |             |
  //  EEE                V             V X
  // BBBBBBBBBBBBBBBBB   A
  // BBBBBBBBBBBBBBBBB   |             +-----> Phi
  // BBBBBBBBBBBBBBBBB   |             |
  // BBBBBBBBBBBBBBBBB   | 34  EB      |
  // BBBBBBBBBBBBBBBBB   |             |
  // BBBBBBBBBBBBBBBBB   |             V Eta
  // BBBBBBBBBBBBBBBBB   |
  // BBBBBBBBBBBBBBBBB   |
  // BBBBBBBBBBBBBBBBB   V
  //  EEE                A             +-----> Y
  // EEEEE               |             |
  // EE EE               | 20 EE+      |
  // EEEEE               |             |
  //  EEE                V             V X
  //
  //
  //
  //
  //event header:
  if(iEvent>=0){
    os << "# Event " << iEvent << "\n";
  }

  //retrieve flags:
  const int nEndcaps = 2;
  const int nScX = 20;
  const int nScY = 20;
  int eeSrf[nEndcaps][nScX][nScY];
  for(size_t i=0; i < sizeof(eeSrf)/sizeof(int); ((int*)eeSrf)[i++] = -1){};
  for(EESrFlagCollection::const_iterator it = eeSrFlags.begin();
      it != eeSrFlags.end(); ++it){
    const EESrFlag& flag = *it;
    int iZ0 = flag.id().zside()>0?1:0;
    int iX0 = flag.id().ix()-1;
    int iY0 = flag.id().iy()-1;
    assert(iZ0>=0 && iZ0<nEndcaps);
    assert(iX0>=0 && iX0<nScX);
    assert(iY0>=0 && iY0<nScY);
    eeSrf[iZ0][iX0][iY0] = flag.value();
  }
  const int nEbTtEta = 34;
  const int nEeTtEta = 11;
  const int nTtEta = nEeTtEta*2+nEbTtEta;
  const int nTtPhi = 72;
  int ebSrf[nEbTtEta][nTtPhi];
  for(size_t i=0; i<sizeof(ebSrf)/sizeof(int); ((int*)ebSrf)[i++] = -1){};
  for(EBSrFlagCollection::const_iterator it = ebSrFlags.begin();
      it != ebSrFlags.end(); ++it){

    const EBSrFlag& flag = *it;
    int iEta = flag.id().ieta();
    int iEta0 = iEta + nTtEta/2 - (iEta>=0?1:0); //0->55 from eta=-3 to eta=3
    int iEbEta0 = iEta0 - nEeTtEta;//0->33 from eta=-1.48 to eta=1.48
    int iPhi0 = flag.id().iphi() - 1;
    assert(iEbEta0>=0 && iEbEta0<nEbTtEta);
    assert(iPhi0>=0 && iPhi0<nTtPhi);

//     cout << __FILE__ << ":" << __LINE__ << ": "
//       <<  iEta << "\t" << flag.id().iphi() << " -> "
//       << iEbEta0 << "\t" << iPhi0
//       << "... Flag: " << flag.value() << "\n";


    ebSrf[iEbEta0][iPhi0] = flag.value();
  }


  //print flags:

  //EE-
  for(int iX0=0; iX0<nScX; ++iX0){
    for(int iY0=0; iY0<nScY; ++iY0){
      int srFlag = eeSrf[0][iX0][iY0];
      assert(srFlag>=-1
             && srFlag<(int)(sizeof(srpFlagMarker)/sizeof(srpFlagMarker[0])));
      os << (srFlag==-1?' ':srpFlagMarker[srFlag]);
    }
    os << "\n"; //one Y supercystal column per line
  } //next supercrystal X-index

  //EB
  for(int iEta0 = 0;
      iEta0 < nEbTtEta;
      ++iEta0){
    for(int iPhi0 = 0; iPhi0 < nTtPhi; ++iPhi0){
      int srFlag = ebSrf[iEta0][iPhi0];
      assert(srFlag>=-1
             && srFlag<(int)(sizeof(srpFlagMarker)/sizeof(srpFlagMarker[0])));
      os << (srFlag==-1?'?':srpFlagMarker[srFlag]);
    }
    os << "\n"; //one phi per line
  }

  //EE+
  for(int iX0=0; iX0<nScX; ++iX0){
    for(int iY0=0; iY0<nScY; ++iY0){
      int srFlag = eeSrf[1][iX0][iY0];
      assert(srFlag>=-1
             && srFlag<(int)(sizeof(srpFlagMarker)/sizeof(srpFlagMarker[0])));
      os << (srFlag==-1?' ':srpFlagMarker[srFlag]);
    }
    os << "\n"; //one Y supercystal column per line
  } //next supercrystal X-index

  //event trailer:
  os << "\n";
}
void EcalSelectiveReadoutProducer::printTTFlags ( const EcalTrigPrimDigiCollection tp,
std::ostream &  os 
) const [private]

Definition at line 600 of file EcalSelectiveReadoutSuppressor.cc.

References EcalSelectiveReadoutSuppressor::nTriggerTowersInEta, EcalSelectiveReadoutSuppressor::nTriggerTowersInPhi, tccFlagMarker, and EcalSelectiveReadoutSuppressor::ttFlags.

                                                                        {
  const char tccFlagMarker[] = { '?', '.', 'S', '?', 'C', 'E', 'E', 'E', 'E'};
  const int nEta = EcalSelectiveReadout::nTriggerTowersInEta;
  const int nPhi = EcalSelectiveReadout::nTriggerTowersInPhi;
  
  if(withHeader){
    os << "# TCC flag map\n#\n"
      "# +-->Phi            " << tccFlagMarker[1+0] << ": 000 (low interest)\n"
      "# |                  " << tccFlagMarker[1+1] << ": 001 (mid interest)\n"
      "# |                  " << tccFlagMarker[1+2] << ": 010 (not valid)\n"
      "# V Eta              " << tccFlagMarker[1+3] << ": 011 (high interest)\n"
      "#                    " << tccFlagMarker[1+4] << ": 1xx forced readout (Hw error)\n";
  }

  if(iEvent>=0){
    os << "#\n#Event " << iEvent << "\n";
  }
  
  for(int iEta=0; iEta<nEta; ++iEta){
    for(int iPhi=0; iPhi<nPhi; ++iPhi){
      os << tccFlagMarker[ttFlags[iEta][iPhi]+1];
    }
    os << "\n";
  }
}
void EcalSelectiveReadoutProducer::produce ( edm::Event event,
const edm::EventSetup eventSetup 
) [virtual]

Produces the EDM products

Parameters:
CMSevent
eventSetupevent conditions

Implements edm::EDProducer.

Definition at line 78 of file EcalSelectiveReadoutProducer.cc.

References checkElecMap(), checkGeometry(), checkTriggerMap(), checkValidity(), dumpFlags_, ebSrFlagCollection_, ebSRPdigiCollection_, eeSrFlagCollection_, eeSRPdigiCollection_, edm::EventSetup::get(), getEBDigis(), getEEDigis(), getTrigPrims(), iEvent, params_, printSrFlags(), produceDigis_, edm::ESHandle< T >::product(), settings_, suppressor_, trigPrimBypass_, trigPrimBypassMode_, estimatePileup_makeJSON::trunc, useCondDb_, and writeSrFlags_.

{
  if(useCondDb_){
    //getting selective readout configuration:
    edm::ESHandle<EcalSRSettings> hSr;
    eventSetup.get<EcalSRSettingsRcd>().get(hSr);
    settings_ = hSr.product();
  }
  
  //gets the trigger primitives:
  EcalTrigPrimDigiCollection emptyTPColl;
  const EcalTrigPrimDigiCollection* trigPrims =
    (trigPrimBypass_ && trigPrimBypassMode_==0)?&emptyTPColl:getTrigPrims(event);


  //gets the digis from the events:
  EBDigiCollection dummyEbDigiColl;
  EEDigiCollection dummyEeDigiColl;

  const EBDigiCollection* ebDigis = produceDigis_?getEBDigis(event)
    :&dummyEbDigiColl;
  const EEDigiCollection* eeDigis = produceDigis_?getEEDigis(event)
    :&dummyEeDigiColl;

  //runs the selective readout algorithm:
  auto_ptr<EBDigiCollection> selectedEBDigis;
  auto_ptr<EEDigiCollection> selectedEEDigis;
  auto_ptr<EBSrFlagCollection> ebSrFlags;
  auto_ptr<EESrFlagCollection> eeSrFlags;

  if(produceDigis_){
    selectedEBDigis = auto_ptr<EBDigiCollection>(new EBDigiCollection);
    selectedEEDigis = auto_ptr<EEDigiCollection>(new EEDigiCollection);
  }

  if(writeSrFlags_){
    ebSrFlags = auto_ptr<EBSrFlagCollection>(new EBSrFlagCollection);
    eeSrFlags = auto_ptr<EESrFlagCollection>(new EESrFlagCollection);
  }

  if(suppressor_.get() == 0){
    //Check the validity of EcalSRSettings
    checkValidity(*settings_);
    
    //instantiates the selective readout algorithm:
    suppressor_ = auto_ptr<EcalSelectiveReadoutSuppressor>(new EcalSelectiveReadoutSuppressor(params_, settings_));

    // check that everything is up-to-date
    checkGeometry(eventSetup);
    checkTriggerMap(eventSetup);
    checkElecMap(eventSetup);
  }
  
  suppressor_->run(eventSetup, *trigPrims, *ebDigis, *eeDigis,
                   selectedEBDigis.get(), selectedEEDigis.get(),
                   ebSrFlags.get(), eeSrFlags.get());

  static int iEvent = 1;
  if(dumpFlags_>=iEvent){
    ofstream ttfFile("TTF.txt", (iEvent==1?ios::trunc:ios::app));
    suppressor_->printTTFlags(ttfFile, iEvent,
                              iEvent==1?true:false);

    ofstream srfFile("SRF.txt", (iEvent==1?ios::trunc:ios::app));
    if(iEvent==1){
      suppressor_->getEcalSelectiveReadout()->printHeader(srfFile);
    }
    srfFile << "# Event " << iEvent << "\n";
    suppressor_->getEcalSelectiveReadout()->print(srfFile);
    srfFile << "\n";

    ofstream afFile("AF.txt", (iEvent==1?ios::trunc:ios::app));
    printSrFlags(afFile, *ebSrFlags, *eeSrFlags, iEvent,
                 iEvent==1?true:false);
  }

  ++iEvent; //event counter

  if(produceDigis_){
    //puts the selected digis into the event:
    event.put(selectedEBDigis, ebSRPdigiCollection_);
    event.put(selectedEEDigis, eeSRPdigiCollection_);
  }

  //puts the SR flags into the event:
  if(writeSrFlags_) {
    event.put(ebSrFlags, ebSrFlagCollection_);
    event.put(eeSrFlags, eeSrFlagCollection_);
  }
}

Member Data Documentation

Number of event whose TT and SR flags must be dumped into a file.

Definition at line 127 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

Definition at line 106 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and getEBDigis().

Definition at line 110 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

Definition at line 108 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

Definition at line 107 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and getEEDigis().

Definition at line 111 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

Definition at line 109 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

Definition at line 119 of file EcalSelectiveReadoutProducer.h.

Referenced by produce().

Switch for suppressed digi production If false SR flags are produced but selective readout is not applied on the crystal channel digis.

Definition at line 136 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

SR settings

Definition at line 140 of file EcalSelectiveReadoutProducer.h.

Referenced by checkWeights(), EcalSelectiveReadoutProducer(), and produce().

Used when settings_ is imported from configuration file. Just used for memory management. Used settings_ to access to the object

Definition at line 150 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer().

Definition at line 118 of file EcalSelectiveReadoutProducer.h.

Referenced by checkElecMap(), and EcalSelectiveReadoutProducer().

Definition at line 116 of file EcalSelectiveReadoutProducer.h.

Referenced by checkGeometry(), and EcalSelectiveReadoutProducer().

Definition at line 121 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

Definition at line 123 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

Definition at line 113 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and getTrigPrims().

Definition at line 112 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and getTrigPrims().

Switch for retrieving SR settings from condition database instead of CMSSW python configuration file.

Definition at line 145 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

switch to write out the SrFlags collections in the event

Definition at line 131 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().