Skip to content

Commit

Permalink
Merge pull request #7950 from UMN-CMS/amc13_onto_from-CMSSW_7_5_X_201…
Browse files Browse the repository at this point in the history
…5-02-25-0200_extra

Update HCAL Packing/Unpacking
  • Loading branch information
davidlange6 committed Mar 10, 2015
2 parents 3b62f13 + a0144a6 commit ece0210
Show file tree
Hide file tree
Showing 22 changed files with 426 additions and 46 deletions.
33 changes: 29 additions & 4 deletions CalibFormats/HcalObjects/src/HcalText2DetIdConverter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,17 @@ bool HcalText2DetIdConverter::init (DetId fId) {
}
else {
flavorName = "HT";
setField (1, triggerId.ieta());
setField (2, triggerId.iphi());
setField (3, 1);
if (triggerId.version() == 0) {
setField (1, triggerId.ieta());
setField (2, triggerId.iphi());
setField (3, 1);
} else if (triggerId.version() == 1) {
setField (1, triggerId.ieta());
setField (2, triggerId.iphi());
setField (3, 10); // We use the tens digit to indicate version
} else {
// Unknown version
}
}
}
else if (genId.isHcalZDCDetId ()) {
Expand Down Expand Up @@ -158,7 +166,24 @@ bool HcalText2DetIdConverter::init (const std::string& fFlavor, const std::strin
mId = HcalDetId (sub, getField (1), getField (2), getField (3));
}
else if (flavorName == "HT") {
mId = HcalTrigTowerDetId (getField (1), getField (2));
// We use the depth to signal the "version" being used (RCT or 1x1 HF). RCT
// has a 0 in the 10s digit, whereas 1x1 has a 1. The ones digit is still
// used to indicate depth, although in the 1x1 case this must be 0, so we
// set it as such.
const int depth_field = getField(3);
const int ones = depth_field % 10;
const int tens = (depth_field - ones) / 10;
if (tens == 0) {
const int depth = ones;
const int version = 0;
mId = HcalTrigTowerDetId (getField (1), getField (2), depth, version);
} else if (tens == 1) {
const int depth = 0;
const int version = 1;
mId = HcalTrigTowerDetId(getField(1), getField(2), depth, version);
} else {
// Undefined version!
}
}
else if (flavorName.find ("ZDC_") == 0) {
HcalZDCDetId::Section section = flavorName == "ZDC_EM" ? HcalZDCDetId::EM :
Expand Down
1 change: 1 addition & 0 deletions DQM/HcalMonitorTasks/src/HcalDigiMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ void HcalDigiMonitor::analyze(edm::Event const&e, edm::EventSetup const&s)
dccHeader->getSpigotData(spigot, htr, fed.size());

int NTS = htr.getNDD(); //number time slices, in precision channels
if (NTS==0) continue; // no DAQ data in this HTR (fully zero-suppressed)
int dccid=dccHeader->getSourceId();

if(dccid==720 && (spigot==12 || spigot==13)) continue; // calibration HTR
Expand Down
9 changes: 8 additions & 1 deletion DataFormats/HcalDetId/interface/HcalTrigTowerDetId.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@ class HcalTrigTowerDetId : public DetId {
/** \brief Constructor from signed ieta, iphi, depth
*/
HcalTrigTowerDetId(int ieta, int iphi, int depth);
/** \brief Constructor from signed ieta, iphi, depth, version
*/
HcalTrigTowerDetId(int ieta, int iphi, int depth, int version);

/** Constructor from a generic cell id */
HcalTrigTowerDetId(const DetId& id);
/** Assignment from a generic cell id */
HcalTrigTowerDetId& operator=(const DetId& id);

void setVersion(int version);

/// get the subdetector
HcalSubdetector subdet() const { return (HcalSubdetector)(subdetId()); }
/// get the z-side of the tower (1/-1)
Expand All @@ -39,8 +44,10 @@ class HcalTrigTowerDetId : public DetId {
int ieta() const { return zside()*ietaAbs(); }
/// get the tower iphi
int iphi() const { return id_&0x7F; }
/// get the depth (zero for LHC, may be nonzero for SuperCMS)
/// get the depth (zero for LHC Run 1, may be nonzero for later runs)
int depth() const { return (id_>>14)&0x7; }
/// get the version code for the trigger tower
int version() const { return (id_>>17)&0x7; }

static const HcalTrigTowerDetId Undefined;

Expand Down
13 changes: 12 additions & 1 deletion DataFormats/HcalDetId/src/HcalTrigTowerDetId.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,24 @@ HcalTrigTowerDetId::HcalTrigTowerDetId(int ieta, int iphi, int depth) : DetId(Hc
(iphi&0x7F);
}

HcalTrigTowerDetId::HcalTrigTowerDetId(int ieta, int iphi, int depth, int version) : DetId(Hcal,HcalTriggerTower) {
id_|=((depth&0x7)<<14) |
((ieta>0)?(0x2000|(ieta<<7)):((-ieta)<<7)) |
(iphi&0x7F);
id_|=((version&0x7)<<17);
}

HcalTrigTowerDetId::HcalTrigTowerDetId(const DetId& gen) {
if (!gen.null() && (gen.det()!=Hcal || gen.subdetId()!=HcalTriggerTower)) {
throw cms::Exception("Invalid DetId") << "Cannot initialize HcalTrigTowerDetId from " << std::hex << gen.rawId() << std::dec;
}
id_=gen.rawId();
}

void HcalTrigTowerDetId::setVersion(int version) {
id_|=((version&0x7)<<17);
}

HcalTrigTowerDetId& HcalTrigTowerDetId::operator=(const DetId& gen) {
if (!gen.null() && (gen.det()!=Hcal || gen.subdetId()!=HcalTriggerTower)) {
throw cms::Exception("Invalid DetId") << "Cannot assign HcalTrigTowerDetId from " << std::hex << gen.rawId() << std::dec;
Expand All @@ -37,7 +48,7 @@ HcalTrigTowerDetId& HcalTrigTowerDetId::operator=(const DetId& gen) {
}

std::ostream& operator<<(std::ostream& s,const HcalTrigTowerDetId& id) {
s << "(HcalTrigTower " << id.ieta() << ',' << id.iphi();
s << "(HcalTrigTower v" << id.version() << ": " << id.ieta() << ',' << id.iphi();
if (id.depth()>0) s << ',' << id.depth();

return s << ')';
Expand Down
22 changes: 22 additions & 0 deletions DataFormats/HcalDigi/interface/HcalDigiCollections.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#include "DataFormats/HcalDigi/interface/HOTriggerPrimitiveDigi.h"
#include "DataFormats/HcalDigi/interface/HcalTTPDigi.h"

#include "DataFormats/HcalDigi/interface/QIE10DataFrame.h"
#include "DataFormats/HcalDigi/interface/QIE11DataFrame.h"

typedef edm::SortedCollection<HBHEDataFrame> HBHEDigiCollection;
typedef edm::SortedCollection<HODataFrame> HODigiCollection;
typedef edm::SortedCollection<HFDataFrame> HFDigiCollection;
Expand All @@ -29,4 +32,23 @@ typedef edm::SortedCollection<CastorTriggerPrimitiveDigi> CastorTrigPrimDigiColl
typedef edm::SortedCollection<HOTriggerPrimitiveDigi> HOTrigPrimDigiCollection;
typedef edm::SortedCollection<HcalTTPDigi> HcalTTPDigiCollection;

#include "DataFormats/Common/interface/DataFrameContainer.h"

template <class Digi>
class HcalDataFrameContainer : protected edm::DataFrameContainer {
public:
HcalDataFrameContainer() { }
HcalDataFrameContainer(int nsamples_per_digi) : edm::DataFrameContainer(nsamples_per_digi*Digi::WORDS_PER_SAMPLE+Digi::HEADER_WORDS) { }

int size() const { return int(edm::DataFrameContainer::size()); }
Digi operator[](size_type i) const { return Digi(edm::DataFrameContainer::operator[](i));}
void addDataFrame(DetId detid, const uint16_t* data) { push_back(detid.rawId(),data); }
int samples() const { return int((stride()-Digi::HEADER_WORDS)/Digi::WORDS_PER_SAMPLE); }
void sort() { edm::DataFrameContainer::sort(); }
};

typedef HcalDataFrameContainer<QIE10DataFrame> QIE10DigiCollection;
typedef HcalDataFrameContainer<QIE11DataFrame> QIE11DigiCollection;


#endif
55 changes: 55 additions & 0 deletions DataFormats/HcalDigi/interface/QIE10DataFrame.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#ifndef DATAFORMATS_HCALDIGI_QIE10DATAFRAME_H
#define DATAFORMATS_HCALDIGI_QIE10DATAFRAME_H

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

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

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

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

class Sample {
public:
Sample(const edm::DataFrame& frame, edm::DataFrame::size_type i) : frame_(frame),i_(i) { }
int adc() const { return frame_[i_]&0xFF; }
int le_tdc() const { return frame_[i_+1]&0x3F; }
int te_tdc() const { return (frame_[i_]>>6)&0x1F; }
bool ok() const { return frame_[i_]&0x1000; }
bool soi() const { return frame_[i_]&0x2000; }
int capid() const { return (frame_[i_+1]>>12)&0x3; }
private:
const edm::DataFrame& frame_;
edm::DataFrame::size_type i_;
};

/// Get the detector id
DetId detid() const { return DetId(id()); }
/// total number of samples in the digi
int samples() const { return (size()-1)/2; }
/// get the flavor of the frame
int flavor() const { return ((edm::DataFrame::operator[](0)>>12)&0x7); }
/// was there a link error?
bool linkError() const { return edm::DataFrame::operator[](0)&0x800; }
/// was this a mark-and-pass ZS event?
bool wasMarkAndPass() const {return edm::DataFrame::operator[](0)&0x100; }
/// get the sample
inline Sample operator[](edm::DataFrame::size_type i) const { return Sample(*this,i*2+1); }
/// 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);

};

std::ostream& operator<<(std::ostream&, const QIE10DataFrame&);


#endif // DATAFORMATS_HCALDIGI_QIE10DATAFRAME_H
56 changes: 56 additions & 0 deletions DataFormats/HcalDigi/interface/QIE11DataFrame.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#ifndef DATAFORMATS_HCALDIGI_QIE11DATAFRAME_H
#define DATAFORMATS_HCALDIGI_QIE11DATAFRAME_H

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

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

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

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

class Sample {
public:
Sample(const edm::DataFrame& frame, edm::DataFrame::size_type i) : frame_(frame),i_(i) { }
int adc() const { return frame_[i_]&0xFF; }
int tdc() const { return (frame_[i_]>>8)&0x3F; }
bool soi() const { return frame_[i_]&0x4000; }
int capid() const { return ((((frame_[0]>>8)&0x3)+i_)%4); }
private:
const edm::DataFrame& frame_;
edm::DataFrame::size_type i_;
};

/// Get the detector id
DetId detid() const { return DetId(id()); }
/// total number of samples in the digi
int samples() const { return (size()-1)/2; }
/// get the flavor of the frame
int flavor() const { return ((edm::DataFrame::operator[](0)>>12)&0x7); }
/// was there a link error?
bool linkError() const { return edm::DataFrame::operator[](0)&0x800; }
/// was there a capid rotation error?
bool capidError() const { return edm::DataFrame::operator[](0)&0x400; }
/// was this a mark-and-pass ZS event?
bool wasMarkAndPass() const {return (flavor()==1); }
/// get the sample
inline Sample operator[](edm::DataFrame::size_type i) const { return Sample(*this,i+1); }
void setCapid0(int cap0);
/// set the sample contents
void setSample(edm::DataFrame::size_type isample, int adc, int tdc, bool soi=false);

};

std::ostream& operator<<(std::ostream&, const QIE11DataFrame&);


#endif // DATAFORMATS_HCALDIGI_QIE11DATAFRAME_H
27 changes: 27 additions & 0 deletions DataFormats/HcalDigi/src/QIE10DataFrame.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#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) {
if (isample>=size()) return;
edm::DataFrame::operator[](isample*2+1)=(adc&0xFF)|(soi?(0x2000):(0))|(ok?(0x1000):(0));
edm::DataFrame::operator[](isample*2+2)=(le_tdc&0x3F)|((fe_tdc&0x1F)<<6)|((capid&0x3)<<12)|0x4000;
}

std::ostream& operator<<(std::ostream& s, const QIE10DataFrame& digi) {
if (digi.detid().det()==DetId::Hcal) {
s << HcalGenericDetId(digi.detid());
} else {
s << "DetId(" << digi.detid().rawId() << ")";
}
s << " " << digi.samples() << " samples";
if (digi.linkError()) s << " LinkError ";
if (digi.wasMarkAndPass()) 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 ";
s << std::endl;
}
return s;
}
31 changes: 31 additions & 0 deletions DataFormats/HcalDigi/src/QIE11DataFrame.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "DataFormats/HcalDigi/interface/QIE11DataFrame.h"
#include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"

void QIE11DataFrame::setCapid0(int cap0) {
edm::DataFrame::operator[](0)&=0xFCFF;
edm::DataFrame::operator[](0)|=((cap0&0x3)<<8);
}

void QIE11DataFrame::setSample(edm::DataFrame::size_type isample, int adc, int tdc, bool soi) {
if (isample>=size()) return;
edm::DataFrame::operator[](isample+1)=(adc&0xFF)|(soi?(0x4000):(0))|((tdc&0x3F)<<8);
}

std::ostream& operator<<(std::ostream& s, const QIE11DataFrame& digi) {
if (digi.detid().det()==DetId::Hcal) {
s << HcalGenericDetId(digi.detid());
} else {
s << "DetId(" << digi.detid().rawId() << ")";
}
s << " " << digi.samples() << " samples";
if (digi.linkError()) s << " LinkError ";
if (digi.capidError()) s << " CapIdError ";
if (digi.wasMarkAndPass()) 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 ";
s << std::endl;
}
return s;
}
4 changes: 4 additions & 0 deletions DataFormats/HcalDigi/src/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ namespace DataFormats_HcalDigi {
CastorTrigPrimDigiCollection theCastorTP_;
HOTrigPrimDigiCollection theHOTP_;
HcalTTPDigiCollection theTTP_;
QIE10DigiCollection theqie10_;
QIE11DigiCollection theqie11_;

edm::Wrapper<edm::SortedCollection<HBHEDataFrame> > anotherHBHE_;
edm::Wrapper<edm::SortedCollection<HODataFrame> > anotherHO_;
Expand All @@ -66,6 +68,8 @@ namespace DataFormats_HcalDigi {
edm::Wrapper<HcalTTPDigiCollection> theTTPw_;
edm::Wrapper<HBHEUpgradeDigiCollection> theUHBHEw_;
edm::Wrapper<HFUpgradeDigiCollection> theUHFw_;
edm::Wrapper<QIE10DigiCollection> theQIE10w_;
edm::Wrapper<QIE11DigiCollection> theQIE11w_;
};
}

4 changes: 4 additions & 0 deletions DataFormats/HcalDigi/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
<class name="edm::SortedCollection<CastorTriggerPrimitiveDigi,edm::StrictWeakOrdering<CastorTriggerPrimitiveDigi> >"/>
<class name="edm::SortedCollection<HcalTTPDigi,edm::StrictWeakOrdering<HcalTTPDigi> >"/>
<class name="edm::SortedCollection<HcalUpgradeDataFrame,edm::StrictWeakOrdering<HcalUpgradeDataFrame> >"/>
<class name="HcalDataFrameContainer<QIE10DataFrame>"/>
<class name="HcalDataFrameContainer<QIE11DataFrame>"/>

<class name="edm::StrictWeakOrdering<HBHEDataFrame>"/>
<class name="edm::StrictWeakOrdering<HODataFrame>"/>
Expand All @@ -99,6 +101,8 @@
<class name="edm::Wrapper<edm::SortedCollection<CastorTriggerPrimitiveDigi,edm::StrictWeakOrdering<CastorTriggerPrimitiveDigi> > >" splitLevel="0" />
<class name="edm::Wrapper<edm::SortedCollection<HcalTTPDigi,edm::StrictWeakOrdering<HcalTTPDigi> > >" splitLevel="0" />
<class name="edm::Wrapper<edm::SortedCollection<HcalUpgradeDataFrame,edm::StrictWeakOrdering<HcalUpgradeDataFrame> > >" splitLevel="0" />
<class name="edm::Wrapper<HcalDataFrameContainer<QIE10DataFrame> >" splitLevel="0"/>
<class name="edm::Wrapper<HcalDataFrameContainer<QIE11DataFrame> >" splitLevel="0"/>
<class name="edm::Wrapper<HcalUnpackerReport>"/>
<class name="HcalLaserDigi" ClassVersion="10">
<version ClassVersion="10" checksum="2447500554"/>
Expand Down
Loading

0 comments on commit ece0210

Please sign in to comment.