CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

HcalTBObjectUnpacker Class Reference

#include <HcalTBObjectUnpacker.h>

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

List of all members.

Public Member Functions

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

Private Member Functions

void parseCalib ()

Private Attributes

std::string calibFile_
std::vector< std::vector
< std::string > > 
calibLines_
bool doBeamADC_
bool doEventPosition_
bool doRunData_
bool doSourcePos_
bool doTiming_
bool doTriggerData_
int qadcFed_
hcaltb::HcalTBQADCUnpacker qadcUnpacker_
int sdFed_
hcaltb::HcalTBSlowDataUnpacker sdUnpacker_
int spdFed_
hcaltb::HcalTBSourcePositionDataUnpacker spdUnpacker_
int tdcFed_
hcaltb::HcalTBTDCUnpacker tdcUnpacker_
hcaltb::HcalTBTriggerDataUnpacker tdUnpacker_
int triggerFed_

Detailed Description

HcalTBObjectUnpacker is the EDProducer subclass which runs the Hcal Test Beam Object Unpack algorithm.

Author:
Phil Dudero
Version:
1st Version June 10, 2005

Definition at line 30 of file HcalTBObjectUnpacker.h.


Constructor & Destructor Documentation

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

Definition at line 17 of file HcalTBObjectUnpacker.cc.

References calibFile_, calibLines_, gather_cfg::cout, doBeamADC_, doEventPosition_, doRunData_, doSourcePos_, doTiming_, doTriggerData_, Exception, parseCalib(), qadcFed_, qadcUnpacker_, sdFed_, hcaltb::HcalTBTDCUnpacker::setCalib(), hcaltb::HcalTBQADCUnpacker::setCalib(), spdFed_, tdcFed_, tdcUnpacker_, and triggerFed_.

                                                                       :
    triggerFed_(conf.getUntrackedParameter<int>("HcalTriggerFED",-1)),
    sdFed_(conf.getUntrackedParameter<int>("HcalSlowDataFED",-1)),
    spdFed_(conf.getUntrackedParameter<int>("HcalSourcePositionFED",-1)),
    tdcFed_(conf.getUntrackedParameter<int>("HcalTDCFED",-1)),
    qadcFed_(conf.getUntrackedParameter<int>("HcalQADCFED",-1)),
    calibFile_(conf.getUntrackedParameter<string>("ConfigurationFile","")),
    tdcUnpacker_(conf.getUntrackedParameter<bool>("IncludeUnmatchedHits",false)),
    doRunData_(false),doTriggerData_(false),doEventPosition_(false),doTiming_(false),doSourcePos_(false),doBeamADC_(false)
  {

    if (triggerFed_ >=0) {
      std::cout << "HcalTBObjectUnpacker will unpack Trigger FED ";
      std::cout << triggerFed_ << endl;
      doTriggerData_=true;
    }

    if (sdFed_ >=0) {
      std::cout << "HcalTBObjectUnpacker will unpack SlowData FED ";
      std::cout << sdFed_ << endl;
      doRunData_=true;
      doEventPosition_=true; // at least the table
    }

    if (tdcFed_ >=0) {
      std::cout << "HcalTBObjectUnpacker will unpack TDC FED ";
      std::cout << tdcFed_ << endl;
      doTiming_=true;
      doEventPosition_=true; // at least the WC
    }

    if (qadcFed_ >=0) {
      std::cout << "HcalTBObjectUnpacker will unpack QADC FED ";
      std::cout << qadcFed_ << endl;
      doBeamADC_=true;
    }

    if (spdFed_ >=0) {
      std::cout << "HcalTBObjectUnpacker will unpack Source Position Data FED ";
      std::cout << spdFed_ << endl;
      doSourcePos_=true;
    }


    if (tdcFed_ >= 0 || qadcFed_ >=0 ) {
      calibLines_.clear();
      if(calibFile_.size()>0){
        
        parseCalib();
        //  printf("I got %d lines!\n",calibLines_.size());
        if(calibLines_.size()==0)
          throw cms::Exception("Incomplete configuration") << 
            "HcalTBObjectUnpacker: TDC/QADC/WC configuration file not found or is empty: "<<calibFile_<<endl;
      }
      else{
        throw cms::Exception("Incomplete configuration") << 
          "HcalTBObjectUnpacker: TDC/QADC/WC configuration file not found: "<<calibFile_<<endl;
      }
    }


    if (doTriggerData_) produces<HcalTBTriggerData>();
    if (doRunData_) produces<HcalTBRunData>();
    if (doEventPosition_) produces<HcalTBEventPosition>();
    if (doTiming_) produces<HcalTBTiming>();
//    if (doBeamADC_) produces<HcalTBBeamCounters>();
    if (doBeamADC_) {produces<HcalTBBeamCounters>();qadcUnpacker_.setCalib(calibLines_);}
//    if (doSourcePos_) produces<HcalSourcePositionData>();
    if(doTiming_||doEventPosition_)tdcUnpacker_.setCalib(calibLines_);
  }
HcalTBObjectUnpacker::~HcalTBObjectUnpacker ( ) [virtual]

Definition at line 89 of file HcalTBObjectUnpacker.cc.

{ }  

Member Function Documentation

void HcalTBObjectUnpacker::parseCalib ( ) [private]

Definition at line 160 of file HcalTBObjectUnpacker.cc.

References calibFile_, calibLines_, relativeConstraints::empty, edm::FileInPath::fullPath(), i, and EdgesToViz::infile.

Referenced by HcalTBObjectUnpacker().

                                     {
  
  if(calibFile_.size()==0){
    printf("HcalTBObjectUnpacker cowardly refuses to parse a NULL file...\n"); 
    return;
  }

  edm::FileInPath fip(calibFile_);
  
 
  ifstream infile(fip.fullPath().c_str());

  char buffer [1024];
  string tmpStr;
  
  while (infile.getline(buffer, 1024)) {
    if (buffer [0] == '#') continue; //ignore comment
    if (buffer [0] == '/' && buffer [1] == '/') continue; //ignore comment
    tmpStr = string(buffer);
    vector<string> lineVect;
    
    int start = 0; bool empty = true;
    for (unsigned i=0; i<=tmpStr.size(); i++) {
      if (tmpStr[i] == ' ' || i==tmpStr.size()) {
        if (!empty) {
          std::string item(tmpStr, start, i-start);
          lineVect.push_back(item);
          empty = true;
//        printf("Got: %s\n",item.c_str());
        }
        start = i+1;
      }
      else {
        if (empty) empty = false;       
      }
    }  
    
    if(lineVect.size()>0) calibLines_.push_back(lineVect);    
  }

  infile.close();
  return;
}
void HcalTBObjectUnpacker::produce ( edm::Event e,
const edm::EventSetup c 
) [virtual]

Implements edm::EDProducer.

Definition at line 92 of file HcalTBObjectUnpacker.cc.

References doBeamADC_, doEventPosition_, doRunData_, doSourcePos_, doTiming_, doTriggerData_, edm::Event::getByType(), edm::Event::put(), qadcFed_, qadcUnpacker_, sdFed_, sdUnpacker_, spdFed_, spdUnpacker_, tdcFed_, tdcUnpacker_, tdUnpacker_, triggerFed_, hcaltb::HcalTBTDCUnpacker::unpack(), hcaltb::HcalTBTriggerDataUnpacker::unpack(), hcaltb::HcalTBSourcePositionDataUnpacker::unpack(), hcaltb::HcalTBQADCUnpacker::unpack(), and hcaltb::HcalTBSlowDataUnpacker::unpack().

  {
    // Step A: Get Inputs 
    edm::Handle<FEDRawDataCollection> rawraw;  
    //    edm::ProcessNameSelector s("PROD"); // HACK!
    e.getByType(rawraw);           

    // Step B: Create empty output    
    std::auto_ptr<HcalTBTriggerData>
      trigd(new HcalTBTriggerData);

    std::auto_ptr<HcalTBRunData>
      rund(new HcalTBRunData);

    std::auto_ptr<HcalTBEventPosition>
      epd(new HcalTBEventPosition);

    std::auto_ptr<HcalTBTiming>
      tmgd(new HcalTBTiming);

    std::auto_ptr<HcalTBBeamCounters>
      bcntd(new HcalTBBeamCounters);

    std::auto_ptr<HcalSourcePositionData>
      spd(new HcalSourcePositionData);
    
    if (triggerFed_ >=0) {
      // Step C: unpack all requested FEDs
      const FEDRawData& fed = rawraw->FEDData(triggerFed_);
      tdUnpacker_.unpack(fed,*trigd);
    }

    if (sdFed_ >=0) {
      // Step C: unpack all requested FEDs
      const FEDRawData& fed = rawraw->FEDData(sdFed_);
      sdUnpacker_.unpack(fed, *rund, *epd);
    }

    if (tdcFed_ >=0) {
      // Step C: unpack all requested FEDs
      const FEDRawData& fed = rawraw->FEDData(tdcFed_);
      tdcUnpacker_.unpack(fed, *epd, *tmgd);
    }

    if (qadcFed_ >=0) {
      // Step C: unpack all requested FEDs
      const FEDRawData& fed = rawraw->FEDData(qadcFed_);
      bool is04 = true;
      if(qadcFed_==8) is04=false;
      qadcUnpacker_.unpack(fed, *bcntd,is04);
    }

    if (spdFed_ >=0) {      
      // Step C: unpack all requested FEDs
      const FEDRawData& fed = rawraw->FEDData(spdFed_);
      spdUnpacker_.unpack(fed, *spd);
    }

    // Step D: Put outputs into event
    if (doTriggerData_) e.put(trigd);
    if (doRunData_) e.put(rund);
    if (doEventPosition_) e.put(epd);
    if (doTiming_) e.put(tmgd);
    if (doBeamADC_) e.put(bcntd);
    if (doSourcePos_) e.put(spd);
  }

Member Data Documentation

std::string HcalTBObjectUnpacker::calibFile_ [private]

Definition at line 42 of file HcalTBObjectUnpacker.h.

Referenced by HcalTBObjectUnpacker(), and parseCalib().

std::vector<std::vector<std::string> > HcalTBObjectUnpacker::calibLines_ [private]

Definition at line 50 of file HcalTBObjectUnpacker.h.

Referenced by HcalTBObjectUnpacker(), and parseCalib().

Definition at line 48 of file HcalTBObjectUnpacker.h.

Referenced by HcalTBObjectUnpacker(), and produce().

Definition at line 48 of file HcalTBObjectUnpacker.h.

Referenced by HcalTBObjectUnpacker(), and produce().

Definition at line 48 of file HcalTBObjectUnpacker.h.

Referenced by HcalTBObjectUnpacker(), and produce().

Definition at line 48 of file HcalTBObjectUnpacker.h.

Referenced by HcalTBObjectUnpacker(), and produce().

Definition at line 48 of file HcalTBObjectUnpacker.h.

Referenced by HcalTBObjectUnpacker(), and produce().

Definition at line 48 of file HcalTBObjectUnpacker.h.

Referenced by HcalTBObjectUnpacker(), and produce().

Definition at line 41 of file HcalTBObjectUnpacker.h.

Referenced by HcalTBObjectUnpacker(), and produce().

Definition at line 46 of file HcalTBObjectUnpacker.h.

Referenced by HcalTBObjectUnpacker(), and produce().

Definition at line 38 of file HcalTBObjectUnpacker.h.

Referenced by HcalTBObjectUnpacker(), and produce().

Definition at line 44 of file HcalTBObjectUnpacker.h.

Referenced by produce().

Definition at line 39 of file HcalTBObjectUnpacker.h.

Referenced by HcalTBObjectUnpacker(), and produce().

Definition at line 47 of file HcalTBObjectUnpacker.h.

Referenced by produce().

Definition at line 40 of file HcalTBObjectUnpacker.h.

Referenced by HcalTBObjectUnpacker(), and produce().

Definition at line 45 of file HcalTBObjectUnpacker.h.

Referenced by HcalTBObjectUnpacker(), and produce().

Definition at line 43 of file HcalTBObjectUnpacker.h.

Referenced by produce().

Definition at line 37 of file HcalTBObjectUnpacker.h.

Referenced by HcalTBObjectUnpacker(), and produce().