CMS 3D CMS Logo

Public Member Functions | Private Attributes

CastorRawToDigi Class Reference

#include <CastorRawToDigi.h>

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

List of all members.

Public Member Functions

virtual void beginRun (edm::Run &, edm::EventSetup const &)
 CastorRawToDigi (const edm::ParameterSet &ps)
virtual void produce (edm::Event &e, const edm::EventSetup &c)
virtual ~CastorRawToDigi ()

Private Attributes

bool complainEmptyData_
CastorCtdcUnpacker ctdcunpacker_
edm::InputTag dataTag_
int expectedOrbitMessageTime_
std::vector< int > fedUnpackList_
CastorDataFrameFilter filter_
int firstFED_
bool silent_
CastorUnpacker unpacker_
bool unpackTTP_
bool usenominalOrbitMessageTime_
bool usingctdc_

Detailed Description

CastorRawToDigi is the EDProducer subclass which runs the Hcal Unpack algorithm.

Author:
Alan Campbell
Version:
1st Version April 18, 2008

Definition at line 28 of file CastorRawToDigi.h.


Constructor & Destructor Documentation

CastorRawToDigi::CastorRawToDigi ( const edm::ParameterSet ps) [explicit]

Definition at line 15 of file CastorRawToDigi.cc.

References expectedOrbitMessageTime_, fedUnpackList_, i, FEDNumbering::MAXCASTORFEDID, FEDNumbering::MINCASTORFEDID, CastorUnpacker::setExpectedOrbitMessageTime(), unpacker_, and unpackTTP_.

                                                           :
  dataTag_(conf.getParameter<edm::InputTag>("InputLabel")),
  unpacker_(conf.getUntrackedParameter<int>("CastorFirstFED",FEDNumbering::MINCASTORFEDID),conf.getParameter<int>("firstSample"),conf.getParameter<int>("lastSample")),
  ctdcunpacker_(conf.getUntrackedParameter<int>("CastorFirstFED",FEDNumbering::MINCASTORFEDID),conf.getParameter<int>("firstSample"),conf.getParameter<int>("lastSample")),
  filter_(conf.getParameter<bool>("FilterDataQuality"),conf.getParameter<bool>("FilterDataQuality"),
          false,
          0, 0, 
          -1),
  fedUnpackList_(conf.getUntrackedParameter<std::vector<int> >("FEDs", std::vector<int>())),
  firstFED_(conf.getUntrackedParameter<int>("CastorFirstFED",FEDNumbering::MINCASTORFEDID)),
//  unpackCalib_(conf.getUntrackedParameter<bool>("UnpackCalib",false)),
  complainEmptyData_(conf.getUntrackedParameter<bool>("ComplainEmptyData",false)),
  usingctdc_(conf.getUntrackedParameter<bool>("CastorCtdc",false)),
  unpackTTP_(conf.getUntrackedParameter<bool>("UnpackTTP",false)),
  silent_(conf.getUntrackedParameter<bool>("silent",true)),
  usenominalOrbitMessageTime_(conf.getUntrackedParameter<bool>("UseNominalOrbitMessageTime",true)),
  expectedOrbitMessageTime_(conf.getUntrackedParameter<int>("ExpectedOrbitMessageTime",-1))

{
  if (fedUnpackList_.empty()) {
    for (int i=FEDNumbering::MINCASTORFEDID; i<=FEDNumbering::MAXCASTORFEDID; i++)
     fedUnpackList_.push_back(i);
  } 

  unpacker_.setExpectedOrbitMessageTime(expectedOrbitMessageTime_);  
  std::ostringstream ss;
  for (unsigned int i=0; i<fedUnpackList_.size(); i++) 
    ss << fedUnpackList_[i] << " ";
  edm::LogInfo("CASTOR") << "CastorRawToDigi will unpack FEDs ( " << ss.str() << ")";
    
  // products produced...
  produces<CastorDigiCollection>();
  produces<CastorTrigPrimDigiCollection>();
  produces<HcalUnpackerReport>();
  if (unpackTTP_)
    produces<HcalTTPDigiCollection>();

//  if (unpackCalib_)
//    produces<HcalCalibDigiCollection>();

}
CastorRawToDigi::~CastorRawToDigi ( ) [virtual]

Definition at line 58 of file CastorRawToDigi.cc.

{ }  

Member Function Documentation

void CastorRawToDigi::beginRun ( edm::Run irun,
edm::EventSetup const &  es 
) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 151 of file CastorRawToDigi.cc.

References expectedOrbitMessageTime_, edm::RunBase::run(), CastorUnpacker::setExpectedOrbitMessageTime(), unpacker_, and usenominalOrbitMessageTime_.

                                                                   {
        if ( usenominalOrbitMessageTime_ ) {
                if ( irun.run() > 132640 ) { 
                        expectedOrbitMessageTime_ = 3560;
                } else if ( irun.run() > 132174 ) {
                        expectedOrbitMessageTime_ = 3559;
                } else if ( irun.run() > 124371 ) {
                        expectedOrbitMessageTime_ = 3557;
                } else if ( irun.run() > 123984 ) {
                        expectedOrbitMessageTime_ = 3559;
                } else if ( irun.run() > 123584 ) {
                        expectedOrbitMessageTime_ = 2;
                } else {
                        expectedOrbitMessageTime_ = 3562;
                }
                unpacker_.setExpectedOrbitMessageTime(expectedOrbitMessageTime_);
        }
}
void CastorRawToDigi::produce ( edm::Event e,
const edm::EventSetup c 
) [virtual]

calib

Implements edm::EDProducer.

Definition at line 61 of file CastorRawToDigi.cc.

References CastorDataFrameFilter::active(), CastorRawCollections::castorCont, complainEmptyData_, ctdcunpacker_, dataTag_, fedUnpackList_, CastorDataFrameFilter::filter(), filter_, edm::EventSetup::get(), edm::Event::getByLabel(), i, parseEventContent::prod, edm::Event::put(), zeeHLT_cff::report, FEDRawData::size(), edm::SortedCollection< T, SORT >::swap(), CastorRawCollections::tpCont, CastorRawCollections::ttp, CastorUnpacker::unpack(), CastorCtdcUnpacker::unpack(), unpacker_, unpackTTP_, usingctdc_, and cms::Exception::what().

{
  // Step A: Get Inputs 
  edm::Handle<FEDRawDataCollection> rawraw;  
  e.getByLabel(dataTag_,rawraw);
  // get the mapping
  edm::ESHandle<CastorDbService> pSetup;
  es.get<CastorDbRecord>().get( pSetup );
  const CastorElectronicsMap* readoutMap=pSetup->getCastorMapping();
  
  // Step B: Create empty output  : three vectors for three classes...
  std::vector<CastorDataFrame> castor;
  std::vector<HcalTTPDigi> ttp;
  std::vector<CastorTriggerPrimitiveDigi> htp;

  std::auto_ptr<HcalUnpackerReport> report(new HcalUnpackerReport);

  CastorRawCollections colls;
  colls.castorCont=&castor;
  if (unpackTTP_) colls.ttp=&ttp;
  colls.tpCont=&htp;
  //colls.calibCont=&hc;
 
  // Step C: unpack all requested FEDs
  for (std::vector<int>::const_iterator i=fedUnpackList_.begin(); i!=fedUnpackList_.end(); i++) {
    const FEDRawData& fed = rawraw->FEDData(*i);
    if (fed.size()==0) {
      if (complainEmptyData_) {
        edm::LogWarning("EmptyData") << "No data for FED " << *i;
        report->addError(*i);
      }
    } else if (fed.size()<8*3) {
      edm::LogWarning("EmptyData") << "Tiny data " << fed.size() << " for FED " << *i;
      report->addError(*i);
    } else {
      try {
                  if ( usingctdc_ ) { 
                          ctdcunpacker_.unpack(fed,*readoutMap,colls, *report);
                  } else {
                          unpacker_.unpack(fed,*readoutMap,colls, *report);
              }
              report->addUnpacked(*i);
      } catch (cms::Exception& e) {
        edm::LogWarning("Unpacking error") << e.what();
        report->addError(*i);
      } catch (...) {
        edm::LogWarning("Unpacking exception");
        report->addError(*i);
      }
    }
  }

  // Step B: encapsulate vectors in actual collections
  std::auto_ptr<CastorDigiCollection> castor_prod(new CastorDigiCollection()); 
  std::auto_ptr<CastorTrigPrimDigiCollection> htp_prod(new CastorTrigPrimDigiCollection());  

  castor_prod->swap_contents(castor);
  htp_prod->swap_contents(htp);

  // Step C2: filter FEDs, if required
  if (filter_.active()) {
    CastorDigiCollection filtered_castor=filter_.filter(*castor_prod,*report);
    
    castor_prod->swap(filtered_castor);
  }

  // Step D: Put outputs into event
  // just until the sorting is proven
  castor_prod->sort();
  htp_prod->sort();

  e.put(castor_prod);
  e.put(htp_prod);

//  if (unpackCalib_) {
//    std::auto_ptr<CastorCalibDigiCollection> hc_prod(new CastorCalibDigiCollection());
//    hc_prod->swap_contents(hc);
//    hc_prod->sort();
//    e.put(hc_prod);
//  }
  if (unpackTTP_) {
    std::auto_ptr<HcalTTPDigiCollection> prod(new HcalTTPDigiCollection());
    prod->swap_contents(ttp);
    
    prod->sort();
    e.put(prod);
  }
  e.put(report);
}

Member Data Documentation

Definition at line 44 of file CastorRawToDigi.h.

Referenced by produce().

Definition at line 39 of file CastorRawToDigi.h.

Referenced by produce().

Definition at line 37 of file CastorRawToDigi.h.

Referenced by produce().

Definition at line 49 of file CastorRawToDigi.h.

Referenced by beginRun(), and CastorRawToDigi().

std::vector<int> CastorRawToDigi::fedUnpackList_ [private]

Definition at line 41 of file CastorRawToDigi.h.

Referenced by CastorRawToDigi(), and produce().

Definition at line 40 of file CastorRawToDigi.h.

Referenced by produce().

Definition at line 42 of file CastorRawToDigi.h.

bool CastorRawToDigi::silent_ [private]

Definition at line 47 of file CastorRawToDigi.h.

Definition at line 38 of file CastorRawToDigi.h.

Referenced by beginRun(), CastorRawToDigi(), and produce().

Definition at line 46 of file CastorRawToDigi.h.

Referenced by CastorRawToDigi(), and produce().

Definition at line 48 of file CastorRawToDigi.h.

Referenced by beginRun().

Definition at line 45 of file CastorRawToDigi.h.

Referenced by produce().