Skip to content

Commit

Permalink
DataFormat and unpacker changes for HF QIE10 (part A)
Browse files Browse the repository at this point in the history
  • Loading branch information
kpedro88 committed Feb 17, 2016
1 parent 309a066 commit b9926f7
Show file tree
Hide file tree
Showing 9 changed files with 207 additions and 51 deletions.
40 changes: 29 additions & 11 deletions DataFormats/HcalDigi/interface/QIE10DataFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@

#include "DataFormats/HcalDetId/interface/HcalDetId.h"
#include "DataFormats/Common/interface/DataFrame.h"
#include "DataFormats/Common/interface/DataFrameContainer.h"
#include <ostream>

/** Precision readout digi from QIE10 including TDC information
*/
class QIE10DataFrame : protected edm::DataFrame {
class QIE10DataFrame {
public:

static const int WORDS_PER_SAMPLE = 2;
static const int HEADER_WORDS = 1;
static const int FLAG_WORDS = 1;

QIE10DataFrame() { }
QIE10DataFrame(const edm::DataFrameContainer& c, edm::DataFrame::size_type i) : edm::DataFrame(c,i) { }
QIE10DataFrame(edm::DataFrame df) : edm::DataFrame(df) { }
QIE10DataFrame(edm::DataFrame const & df) : m_data(df) { }

class Sample {
public:
Expand All @@ -42,29 +40,49 @@ class QIE10DataFrame : protected edm::DataFrame {
edm::DataFrame::size_type i_;
};

void copyContent(const QIE10DataFrame& src);

/// Get the detector id
DetId detid() const { return DetId(id()); }
DetId detid() const { return DetId(m_data.id()); }
edm::DataFrame::id_type id() const { return m_data.id(); }
/// more accessors
edm::DataFrame::size_type size() const { return m_data.size(); }
/// iterators
edm::DataFrame::iterator begin() { return m_data.begin(); }
edm::DataFrame::iterator end() { return m_data.end(); }
edm::DataFrame::const_iterator begin() const { return m_data.begin(); }
edm::DataFrame::const_iterator end() const { return m_data.end(); }
/// total number of samples in the digi
int samples() const { return (size()-HEADER_WORDS-FLAG_WORDS)/WORDS_PER_SAMPLE; }
/// for backward compatibility
int presamples() const;
/// get the flavor of the frame
static const int OFFSET_FLAVOR = 12;
static const int MASK_FLAVOR = 0x7;
int flavor() const { return ((edm::DataFrame::operator[](0)>>OFFSET_FLAVOR)&MASK_FLAVOR); }
int flavor() const { return ((m_data[0]>>OFFSET_FLAVOR)&MASK_FLAVOR); }
/// was there a link error?
static const int MASK_LINKERROR = 0x800;
bool linkError() const { return edm::DataFrame::operator[](0)&MASK_LINKERROR; }
bool linkError() const { return m_data[0]&MASK_LINKERROR; }
/// was this a mark-and-pass ZS event?
static const int MASK_MARKPASS = 0x100;
bool wasMarkAndPass() const {return edm::DataFrame::operator[](0)&MASK_MARKPASS; }
bool zsMarkAndPass() const {return m_data[0]&MASK_MARKPASS; }
/// other ZS functions (TODO: real implementation)
bool zsUnsuppressed() const { return false; }
uint32_t zsCrossingMask() const { return 0; }
/// set ZS params
void setZSInfo(bool unsuppressed, bool markAndPass, uint32_t crossingMask=0);
/// get the sample
inline Sample operator[](edm::DataFrame::size_type i) const { return Sample(*this,i*WORDS_PER_SAMPLE+HEADER_WORDS); }
inline Sample operator[](edm::DataFrame::size_type i) const { return Sample(m_data,i*WORDS_PER_SAMPLE+HEADER_WORDS); }
/// set the sample contents
void setSample(edm::DataFrame::size_type isample, int adc, int le_tdc, int fe_tdc, int capid, bool soi=false, bool ok=true);
void setSample(edm::DataFrame::size_type isample, int adc, int le_tdc, int te_tdc, int capid, bool soi=false, bool ok=true);
/// get the flag word
uint16_t flags() const { return edm::DataFrame::operator[](size()-1); }
uint16_t flags() const { return m_data[size()-1]; }
/// set the flag word
void setFlags(uint16_t v);

private:
edm::DataFrame m_data;

};

std::ostream& operator<<(std::ostream&, const QIE10DataFrame&);
Expand Down
38 changes: 27 additions & 11 deletions DataFormats/HcalDigi/interface/QIE11DataFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@

#include "DataFormats/HcalDetId/interface/HcalDetId.h"
#include "DataFormats/Common/interface/DataFrame.h"
#include "DataFormats/Common/interface/DataFrameContainer.h"
#include <ostream>

/** Precision readout digi from QIE11 including TDC information
*/
class QIE11DataFrame : protected edm::DataFrame {
class QIE11DataFrame {
public:

static const int WORDS_PER_SAMPLE = 1;
static const int HEADER_WORDS = 1;
static const int FLAG_WORDS = 1;

QIE11DataFrame() { }
QIE11DataFrame(const edm::DataFrameContainer& c, edm::DataFrame::size_type i) : edm::DataFrame(c,i) { }
QIE11DataFrame(edm::DataFrame df) : edm::DataFrame(df) { }
QIE11DataFrame(edm::DataFrame const & df) : m_data(df) { }

class Sample {
public:
Expand All @@ -38,32 +36,50 @@ class QIE11DataFrame : protected edm::DataFrame {
edm::DataFrame::size_type i_;
};

void copyContent(const QIE11DataFrame&);

/// Get the detector id
DetId detid() const { return DetId(id()); }
DetId detid() const { return DetId(m_data.id()); }
edm::DataFrame::id_type id() const { return m_data.id(); }
/// more accessors
edm::DataFrame::size_type size() const { return m_data.size(); }
/// iterators
edm::DataFrame::iterator begin() { return m_data.begin(); }
edm::DataFrame::iterator end() { return m_data.end(); }
edm::DataFrame::const_iterator begin() const { return m_data.begin(); }
edm::DataFrame::const_iterator end() const { return m_data.end(); }
/// total number of samples in the digi
int samples() const { return (size()-HEADER_WORDS-FLAG_WORDS)/WORDS_PER_SAMPLE; }
/// for backward compatibility
int presamples() const;
/// get the flavor of the frame
static const int OFFSET_FLAVOR = 12;
static const int MASK_FLAVOR = 0x7;
int flavor() const { return ((edm::DataFrame::operator[](0)>>OFFSET_FLAVOR)&MASK_FLAVOR); }
int flavor() const { return ((m_data[0]>>OFFSET_FLAVOR)&MASK_FLAVOR); }
/// was there a link error?
static const int MASK_LINKERROR = 0x800;
bool linkError() const { return edm::DataFrame::operator[](0)&MASK_LINKERROR; }
bool linkError() const { return m_data[0]&MASK_LINKERROR; }
/// was there a capid rotation error?
static const int MASK_CAPIDERROR = 0x400;
bool capidError() const { return edm::DataFrame::operator[](0)&MASK_CAPIDERROR; }
bool capidError() const { return m_data[0]&MASK_CAPIDERROR; }
/// was this a mark-and-pass ZS event?
bool wasMarkAndPass() const {return (flavor()==1); }
bool zsMarkAndPass() const {return (flavor()==1); }
/// other ZS functions (TODO: real implementation)
bool zsUnsuppressed() const { return false; }
uint32_t zsCrossingMask() const { return 0; }
/// get the sample
inline Sample operator[](edm::DataFrame::size_type i) const { return Sample(*this,i+HEADER_WORDS); }
inline Sample operator[](edm::DataFrame::size_type i) const { return Sample(m_data,i+HEADER_WORDS); }
void setCapid0(int cap0);
/// set the sample contents
void setSample(edm::DataFrame::size_type isample, int adc, int tdc, bool soi=false);
/// get the flag word
uint16_t flags() const { return edm::DataFrame::operator[](size()-1); }
uint16_t flags() const { return m_data[size()-1]; }
/// set the flag word
void setFlags(uint16_t v);

private:
edm::DataFrame m_data;

};

std::ostream& operator<<(std::ostream&, const QIE11DataFrame&);
Expand Down
34 changes: 26 additions & 8 deletions DataFormats/HcalDigi/src/QIE10DataFrame.cc
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
#include "DataFormats/HcalDigi/interface/QIE10DataFrame.h"
#include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"

void QIE10DataFrame::setSample(edm::DataFrame::size_type isample, int adc, int le_tdc, int fe_tdc, int capid, bool soi, bool ok) {
void QIE10DataFrame::setSample(edm::DataFrame::size_type isample, int adc, int le_tdc, int te_tdc, int capid, bool soi, bool ok) {
if (isample>=size()) return;
edm::DataFrame::operator[](isample*WORDS_PER_SAMPLE+HEADER_WORDS)=(adc&Sample::MASK_ADC)|(soi?(Sample::MASK_SOI):(0))|(ok?(Sample::MASK_OK):(0));
edm::DataFrame::operator[](isample*WORDS_PER_SAMPLE+HEADER_WORDS+1)=(le_tdc&Sample::MASK_LE_TDC)|((fe_tdc&Sample::MASK_TE_TDC)<<Sample::OFFSET_TE_TDC)|((capid&Sample::MASK_CAPID)<<Sample::OFFSET_CAPID)|0x4000; // 0x4000 marks this as second word of a pair
m_data[isample*WORDS_PER_SAMPLE+HEADER_WORDS]=(adc&Sample::MASK_ADC)|(soi?(Sample::MASK_SOI):(0))|(ok?(Sample::MASK_OK):(0));
m_data[isample*WORDS_PER_SAMPLE+HEADER_WORDS+1]=(le_tdc&Sample::MASK_LE_TDC)|((te_tdc&Sample::MASK_TE_TDC)<<Sample::OFFSET_TE_TDC)|((capid&Sample::MASK_CAPID)<<Sample::OFFSET_CAPID)|0x4000; // 0x4000 marks this as second word of a pair
}

void QIE10DataFrame::setFlags(uint16_t v) {
edm::DataFrame::operator[](size()-1)=v;
m_data[size()-1]=v;
}

void QIE10DataFrame::copyContent(const QIE10DataFrame& digi) {
for (edm::DataFrame::size_type i=0; i<size() && i<digi.size();i++){
Sample sam = digi[i];
setSample(i, sam.adc(), sam.le_tdc(), sam.te_tdc(), sam.capid(), sam.soi(), sam.ok());
}
}

int QIE10DataFrame::presamples() const {
for (int i=0; i<samples(); i++) {
if ((*this)[i].soi()) return i;
}
return -1;
}

void QIE10DataFrame::setZSInfo(bool unsuppressed, bool markAndPass, uint32_t crossingMask){
if(markAndPass) m_data[0] |= MASK_MARKPASS;
}

std::ostream& operator<<(std::ostream& s, const QIE10DataFrame& digi) {
if (digi.detid().det()==DetId::Hcal) {
Expand All @@ -20,12 +37,13 @@ std::ostream& operator<<(std::ostream& s, const QIE10DataFrame& digi) {
}
s << " " << digi.samples() << " samples";
if (digi.linkError()) s << " LinkError ";
if (digi.wasMarkAndPass()) s << " MaP ";
if (digi.zsMarkAndPass()) s << " MaP ";
s << std::endl;
for (int i=0; i<digi.samples(); i++) {
s << " ADC=" << digi[i].adc() << " TDC(LE)=" << digi[i].le_tdc() << " TDC(TE)=" << digi[i].te_tdc() << " CAPID=" << digi[i].capid();
if (digi[i].soi()) s << " SOI ";
if (!digi[i].ok()) s << " !OK ";
QIE10DataFrame::Sample sam = digi[i];
s << " ADC=" << sam.adc() << " TDC(LE)=" << sam.le_tdc() << " TDC(TE)=" << sam.te_tdc() << " CAPID=" << sam.capid();
if (sam.soi()) s << " SOI ";
if (!sam.ok()) s << " !OK ";
s << std::endl;
}
return s;
Expand Down
29 changes: 22 additions & 7 deletions DataFormats/HcalDigi/src/QIE11DataFrame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,31 @@
#include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"

void QIE11DataFrame::setCapid0(int cap0) {
edm::DataFrame::operator[](0)&=0xFCFF; // inversion of the capid0 mask
edm::DataFrame::operator[](0)|=((cap0&Sample::MASK_CAPID)<<Sample::OFFSET_CAPID);
m_data[0]&=0xFCFF; // inversion of the capid0 mask
m_data[0]|=((cap0&Sample::MASK_CAPID)<<Sample::OFFSET_CAPID);
}

void QIE11DataFrame::setFlags(uint16_t v) {
edm::DataFrame::operator[](size()-1)=v;
m_data[size()-1]=v;
}

void QIE11DataFrame::copyContent(const QIE11DataFrame& digi) {
for (edm::DataFrame::size_type i=0; i<size() && i<digi.size();i++){
Sample sam = digi[i];
setSample(i,sam.adc(),sam.tdc(),sam.soi());
}
}

int QIE11DataFrame::presamples() const {
for (int i=0; i<samples(); i++) {
if ((*this)[i].soi()) return i;
}
return -1;
}

void QIE11DataFrame::setSample(edm::DataFrame::size_type isample, int adc, int tdc, bool soi) {
if (isample>=size()) return;
edm::DataFrame::operator[](isample+1)=(adc&Sample::MASK_ADC)|(soi?(Sample::MASK_SOI):(0))|((tdc&Sample::MASK_TDC)<<Sample::OFFSET_TDC);
m_data[isample+1]=(adc&Sample::MASK_ADC)|(soi?(Sample::MASK_SOI):(0))|((tdc&Sample::MASK_TDC)<<Sample::OFFSET_TDC);
}

std::ostream& operator<<(std::ostream& s, const QIE11DataFrame& digi) {
Expand All @@ -24,11 +38,12 @@ std::ostream& operator<<(std::ostream& s, const QIE11DataFrame& digi) {
s << " " << digi.samples() << " samples";
if (digi.linkError()) s << " LinkError ";
if (digi.capidError()) s << " CapIdError ";
if (digi.wasMarkAndPass()) s << " M&P ";
if (digi.zsMarkAndPass()) s << " M&P ";
s << std::endl;
for (int i=0; i<digi.samples(); i++) {
s << " ADC=" << digi[i].adc() << " TDC=" << digi[i].tdc() << " CAPID=" << digi[i].capid();
if (digi[i].soi()) s << " SOI ";
QIE11DataFrame::Sample sam = digi[i];
s << " ADC=" << sam.adc() << " TDC=" << sam.tdc() << " CAPID=" << sam.capid();
if (sam.soi()) s << " SOI ";
s << std::endl;
}
return s;
Expand Down
8 changes: 4 additions & 4 deletions DataFormats/HcalDigi/test/HcalDigiDump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ void HcalDigiDump::analyze(edm::Event const& e, edm::EventSetup const& c) {
for (i=qie10s.begin(); i!=qie10s.end(); i++) {
const QIE10DigiCollection& c=*(*i);

for (int j=0; j < c.size(); j++)
cout << c[j] << std::endl;
for (unsigned j=0; j < c.size(); j++)
cout << QIE10DataFrame(c[j]) << std::endl;
}
} catch (...) {
}
Expand All @@ -242,8 +242,8 @@ void HcalDigiDump::analyze(edm::Event const& e, edm::EventSetup const& c) {
for (i=qie11s.begin(); i!=qie11s.end(); i++) {
const QIE11DigiCollection& c=*(*i);

for (int j=0; j < c.size(); j++)
cout << c[j] << std::endl;
for (unsigned j=0; j < c.size(); j++)
cout << QIE11DataFrame(c[j]) << std::endl;
}
} catch (...) {
}
Expand Down
2 changes: 2 additions & 0 deletions EventFilter/HcalRawToDigi/interface/HcalUnpacker.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class HcalUnpacker {
std::vector<HOTriggerPrimitiveDigi>* tphoCont;
std::vector<HcalTTPDigi>* ttp;
QIE10DigiCollection* qie10;
QIE11DigiCollection* qie11;

};

/// for normal data
Expand Down
9 changes: 8 additions & 1 deletion EventFilter/HcalRawToDigi/plugins/HcalRawToDigi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ HcalRawToDigi::HcalRawToDigi(edm::ParameterSet const& conf):
if (unpackTTP_)
produces<HcalTTPDigiCollection>();
produces<QIE10DigiCollection>();

produces<QIE11DigiCollection>();

memset(&stats_,0,sizeof(stats_));

}
Expand Down Expand Up @@ -194,6 +195,10 @@ void HcalRawToDigi::produce(edm::Event& e, const edm::EventSetup& es)
colls.qie10 = new QIE10DigiCollection();
}
std::auto_ptr<QIE10DigiCollection> qie10_prod(colls.qie10);
if (colls.qie11 == 0) {
colls.qie11 = new QIE11DigiCollection();
}
std::auto_ptr<QIE11DigiCollection> qie11_prod(colls.qie11);

hbhe_prod->swap_contents(hbhe);
if( !cntHFdup ) hf_prod->swap_contents(hf);
Expand Down Expand Up @@ -221,13 +226,15 @@ void HcalRawToDigi::produce(edm::Event& e, const edm::EventSetup& es)
htp_prod->sort();
hotp_prod->sort();
qie10_prod->sort();
qie11_prod->sort();

e.put(hbhe_prod);
e.put(ho_prod);
e.put(hf_prod);
e.put(htp_prod);
e.put(hotp_prod);
e.put(qie10_prod);
e.put(qie11_prod);

/// calib
if (unpackCalib_) {
Expand Down
2 changes: 1 addition & 1 deletion EventFilter/HcalRawToDigi/src/HcalUHTRData.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

static const int HEADER_LENGTH_16BIT=2*sizeof(uint64_t)/sizeof(uint16_t);

HcalUHTRData::const_iterator::const_iterator(const uint16_t* ptr, const uint16_t* limit) : m_ptr(ptr), m_limit(limit) {
HcalUHTRData::const_iterator::const_iterator(const uint16_t* ptr, const uint16_t* limit) : m_ptr(ptr), m_limit(limit), m_stepclass(0) {
if (isHeader()) determineMode();
}

Expand Down
Loading

0 comments on commit b9926f7

Please sign in to comment.