Skip to content

Commit

Permalink
Merge 94ddf55 into 069d41c
Browse files Browse the repository at this point in the history
  • Loading branch information
igv4321 committed Jun 14, 2016
2 parents 069d41c + 94ddf55 commit 1726448
Show file tree
Hide file tree
Showing 24 changed files with 1,182 additions and 37 deletions.
47 changes: 47 additions & 0 deletions CondFormats/HcalObjects/interface/AbsHFPhase1AlgoData.h
@@ -0,0 +1,47 @@
#ifndef CondFormats_HcalObjects_AbsHFPhase1AlgoData_h_
#define CondFormats_HcalObjects_AbsHFPhase1AlgoData_h_

#include <typeinfo>

#include "boost/serialization/base_object.hpp"
#include "boost/serialization/export.hpp"

// Archive headers are needed here for the serialization registration to work.
// <cassert> is needed for the archive headers to work.
#if !defined(__GCCXML__)
#include <cassert>
#include "CondFormats/Serialization/interface/eos/portable_iarchive.hpp"
#include "CondFormats/Serialization/interface/eos/portable_oarchive.hpp"
#endif /* #if !defined(__GCCXML__) */

//
// Classes inheriting from this one are supposed to configure algorithms
// that inherit from AbsHFPhase1Algo (in package RecoLocalCalo/HcalRecAlgos)
//
class AbsHFPhase1AlgoData
{
public:
inline virtual ~AbsHFPhase1AlgoData() {}

// Comparison operators. Note that they are not virtual and should
// not be overriden by derived classes. These operators are very
// useful for I/O testing.
inline bool operator==(const AbsHFPhase1AlgoData& r) const
{return (typeid(*this) == typeid(r)) && this->isEqual(r);}
inline bool operator!=(const AbsHFPhase1AlgoData& r) const
{return !(*this == r);}

protected:
// Method needed to compare objects for equality.
// Must be implemented by derived classes.
virtual bool isEqual(const AbsHFPhase1AlgoData&) const = 0;

private:
friend class boost::serialization::access;
template <typename Ar>
inline void serialize(Ar& ar, unsigned /* version */) {}
};

BOOST_CLASS_EXPORT_KEY(AbsHFPhase1AlgoData)

#endif // CondFormats_HcalObjects_AbsHFPhase1AlgoData_h_
2 changes: 2 additions & 0 deletions DataFormats/HcalDetId/interface/HcalDetId.h
Expand Up @@ -70,6 +70,8 @@ class HcalDetId : public DetId {
/// base detId for HF dual channels
bool sameBaseDetId(const DetId&) const;
HcalDetId baseDetId() const;
/// second PMT anode detId for HF dual channels
HcalDetId secondAnodeId() const;

/// get the smallest crystal_ieta of the crystal in front of this tower (HB and HE tower 17 only)
int crystal_ieta_low() const { return ((ieta()-zside())*5)+zside(); }
Expand Down
15 changes: 15 additions & 0 deletions DataFormats/HcalDetId/src/HcalDetId.cc
Expand Up @@ -183,6 +183,21 @@ HcalDetId HcalDetId::baseDetId() const {
}
}

HcalDetId HcalDetId::secondAnodeId() const {
if (subdet() != HcalForward || depth() > 2) {
return HcalDetId(id_);
} else {
int zsid, eta, phi, dep;
unpackId(id_, zsid, eta, phi, dep);
dep += 2;
uint32_t rawid = id_&kHcalIdMask;
rawid |= (kHcalIdFormat2) | ((dep&kHcalDepthMask2)<<kHcalDepthOffset2) |
((zsid>0)?(kHcalZsideMask2|(eta<<kHcalEtaOffset2)):((eta)<<kHcalEtaOffset2)) |
(phi&kHcalPhiMask2);
return HcalDetId(rawid);
}
}

int HcalDetId::crystal_iphi_low() const {
int simple_iphi=((iphi()-1)*5)+1;
simple_iphi+=10;
Expand Down
28 changes: 19 additions & 9 deletions DataFormats/HcalDigi/interface/QIE10DataFrame.h
Expand Up @@ -20,7 +20,12 @@ class QIE10DataFrame {

class Sample {
public:
Sample(const edm::DataFrame& frame, edm::DataFrame::size_type i) : frame_(frame),i_(i) { }
typedef uint32_t wide_type;

Sample(const edm::DataFrame& frame, edm::DataFrame::size_type i) : word1_(frame[i]), word2_(frame[i+1]) { }
Sample(const edm::DataFrame::data_type& word1, const edm::DataFrame::data_type& word2) : word1_(word1), word2_(word2) {}
explicit Sample(wide_type wide);

static const int MASK_ADC = 0xFF;
static const int MASK_LE_TDC = 0x3F;
static const int MASK_TE_TDC = 0x1F;
Expand All @@ -29,15 +34,20 @@ class QIE10DataFrame {
static const int MASK_OK = 0x1000;
static const int MASK_CAPID = 0x3;
static const int OFFSET_CAPID = 12;
int adc() const { return frame_[i_]&MASK_ADC; }
int le_tdc() const { return frame_[i_+1]&MASK_LE_TDC; }
int te_tdc() const { return (frame_[i_+1]>>OFFSET_TE_TDC)&MASK_TE_TDC; }
bool ok() const { return frame_[i_]&MASK_OK; }
bool soi() const { return frame_[i_]&MASK_SOI; }
int capid() const { return (frame_[i_+1]>>OFFSET_CAPID)&MASK_CAPID; }

inline int adc() const { return word1_&MASK_ADC; }
inline int le_tdc() const { return word2_&MASK_LE_TDC; }
inline int te_tdc() const { return (word2_>>OFFSET_TE_TDC)&MASK_TE_TDC; }
inline bool ok() const { return word1_&MASK_OK; }
inline bool soi() const { return word1_&MASK_SOI; }
inline int capid() const { return (word2_>>OFFSET_CAPID)&MASK_CAPID; }
inline edm::DataFrame::data_type raw(edm::DataFrame::size_type i) const
{ return (i > WORDS_PER_SAMPLE) ? 0 : ( (i==1) ? word2_ : word1_ ); }
wide_type wideRaw() const;

private:
const edm::DataFrame& frame_;
edm::DataFrame::size_type i_;
edm::DataFrame::data_type word1_;
edm::DataFrame::data_type word2_;
};

void copyContent(const QIE10DataFrame& src);
Expand Down
24 changes: 23 additions & 1 deletion DataFormats/HcalDigi/src/QIE10DataFrame.cc
@@ -1,3 +1,5 @@
#include <type_traits>

#include "DataFormats/HcalDigi/interface/QIE10DataFrame.h"
#include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"

Expand Down Expand Up @@ -25,10 +27,30 @@ int QIE10DataFrame::presamples() const {
return -1;
}

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

QIE10DataFrame::Sample::Sample(const wide_type wide) {
static_assert(sizeof(wide) == 2*sizeof(word1_),
"The wide input type must be able to contain two words");
const edm::DataFrame::data_type* ptr =
reinterpret_cast<const edm::DataFrame::data_type*>(&wide);
word1_ = ptr[0];
word2_ = ptr[1];
}

QIE10DataFrame::Sample::wide_type QIE10DataFrame::Sample::wideRaw() const {
static_assert(sizeof(QIE10DataFrame::Sample::wide_type) == 2*sizeof(word1_),
"The wide result type must be able to contain two words");
wide_type result;
edm::DataFrame::data_type* ptr =
reinterpret_cast<edm::DataFrame::data_type*>(&result);
ptr[0] = word1_;
ptr[1] = word2_;
return result;
}

std::ostream& operator<<(std::ostream& s, const QIE10DataFrame& digi) {
if (digi.detid().det()==DetId::Hcal) {
s << HcalGenericDetId(digi.detid());
Expand Down
23 changes: 19 additions & 4 deletions DataFormats/HcalRecHit/interface/HFQIE10Info.h
@@ -1,7 +1,10 @@
#ifndef DATAFORMATS_HCALRECHIT_HFQIE10INFO_H
#define DATAFORMATS_HCALRECHIT_HFQIE10INFO_H

#include <limits>

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

/** \class HFQIE10Info
*
Expand All @@ -13,28 +16,40 @@ class HFQIE10Info
{
public:
typedef HcalDetId key_type;
typedef QIE10DataFrame::Sample::wide_type raw_type;

static const unsigned N_RAW_MAX = 5;
static const raw_type INVALID_RAW = std::numeric_limits<raw_type>::max();

HFQIE10Info();

HFQIE10Info(const HcalDetId& id, int adc, float charge,
float energy, float timeRising, float timeFalling);
// Argument "soi" provides the index of the sample of interest
// in the "rawData" array
HFQIE10Info(const HcalDetId& id, float charge, float energy,
float timeRising, float timeFalling,
const raw_type* rawData, unsigned nData, unsigned soi);

inline HcalDetId id() const {return id_;}

inline int adc() const {return adc_;}
inline float charge() const {return charge_;}
inline float energy() const {return energy_;}
inline float timeRising() const {return timeRising_;}
inline float timeFalling() const {return timeFalling_;}
inline unsigned nRaw() const {return nRaw_;}
inline unsigned soi() const {return soi_;}
inline raw_type getRaw(const unsigned which) const
{return which >= nRaw_ ? INVALID_RAW : raw_[which];}

private:
HcalDetId id_;

int32_t adc_;
float charge_;
float energy_;
float timeRising_;
float timeFalling_;
raw_type raw_[N_RAW_MAX];
uint8_t nRaw_;
uint8_t soi_;
};

#endif // DATAFORMATS_HCALRECHIT_HFQIE10INFO_H
5 changes: 4 additions & 1 deletion DataFormats/HcalRecHit/interface/HFRecHit.h
Expand Up @@ -22,10 +22,13 @@ class HFRecHit : public CaloRecHit {
float timeFalling() const { return timeFalling_; }
HcalDetId id() const { return HcalDetId(detid()); }

inline void setAuxHF(const uint32_t u) {auxHF_ = u;}
inline uint32_t getAuxHF() const {return auxHF_;}

private:

float timeFalling_;

uint32_t auxHF_;
};

std::ostream& operator<<(std::ostream& s, const HFRecHit& hit);
Expand Down
52 changes: 45 additions & 7 deletions DataFormats/HcalRecHit/src/HFQIE10Info.cc
@@ -1,22 +1,60 @@
#include <algorithm>
#include "DataFormats/HcalRecHit/interface/HFQIE10Info.h"

HFQIE10Info::HFQIE10Info()
: adc_(0),
charge_(0.f),
: charge_(0.f),
energy_(0.f),
timeRising_(0.f),
timeFalling_(-1.f)
timeFalling_(-1.f),
raw_{INVALID_RAW, INVALID_RAW, INVALID_RAW, INVALID_RAW, INVALID_RAW},
nRaw_(0),
soi_(0)
{
}

HFQIE10Info::HFQIE10Info(const HcalDetId& id, const int i_adc,
HFQIE10Info::HFQIE10Info(const HcalDetId& id,
const float i_charge, const float i_energy,
const float i_timeRising, const float i_timeFalling)
const float i_timeRising, const float i_timeFalling,
const raw_type* rawData, const unsigned nData,
const unsigned i_soi)
: id_(id),
adc_(i_adc),
charge_(i_charge),
energy_(i_energy),
timeRising_(i_timeRising),
timeFalling_(i_timeFalling)
timeFalling_(i_timeFalling),
raw_{INVALID_RAW, INVALID_RAW, INVALID_RAW, INVALID_RAW, INVALID_RAW},
nRaw_(std::min(nData, N_RAW_MAX)),
soi_(0)
{
if (nData)
{
unsigned tbegin = 0;
if (i_soi >= nData)
{
// No SOI in the data. This situation is not normal
// but can not be addressed in this code.
if (nData > nRaw_)
tbegin = nData - nRaw_;
soi_ = nRaw_;
}
else
{
if (nData > nRaw_)
{
// Want to keep at least 2 presamples
if (i_soi > 2U)
{
tbegin = i_soi - 2U;
if (tbegin + nRaw_ > nData)
tbegin = nData - nRaw_;
}
}
soi_ = i_soi - tbegin;
}

raw_type* to = &raw_[0];
const raw_type* from = rawData + tbegin;
for (unsigned i=0; i<nRaw_; ++i)
*to++ = *from++;
}
}
9 changes: 7 additions & 2 deletions DataFormats/HcalRecHit/src/HFRecHit.cc
@@ -1,12 +1,17 @@
#include "DataFormats/HcalRecHit/interface/HFRecHit.h"


HFRecHit::HFRecHit() : CaloRecHit() {
HFRecHit::HFRecHit() :
CaloRecHit(),
timeFalling_(0.f),
auxHF_(0)
{
}

HFRecHit::HFRecHit(const HcalDetId& id, float energy, float timeRising, float timeFalling) :
CaloRecHit(id,energy,timeRising),
timeFalling_(timeFalling)
timeFalling_(timeFalling),
auxHF_(0)
{
}

Expand Down
6 changes: 4 additions & 2 deletions DataFormats/HcalRecHit/src/classes_def.xml
Expand Up @@ -11,13 +11,15 @@
<version ClassVersion="11" checksum="1379911758"/>
<version ClassVersion="10" checksum="1697427050"/>
</class>
<class name="HFQIE10Info" ClassVersion="3">
<class name="HFQIE10Info" ClassVersion="4">
<version ClassVersion="4" checksum="3261445918"/>
<version ClassVersion="3" checksum="1025085409"/>
</class>
<class name="HFPreRecHit" ClassVersion="3">
<version ClassVersion="3" checksum="224636588"/>
</class>
<class name="HFRecHit" ClassVersion="13">
<class name="HFRecHit" ClassVersion="14">
<version ClassVersion="14" checksum="3957655113"/>
<version ClassVersion="13" checksum="1446699820"/>
<version ClassVersion="12" checksum="1242817974"/>
<version ClassVersion="10" checksum="1310006561"/>
Expand Down
Expand Up @@ -8,6 +8,7 @@
RecoLocalCaloFEVT = cms.PSet(
outputCommands = cms.untracked.vstring('keep *_hbhereco_*_*',
'keep *_hbheprereco_*_*',
'keep *_hfprereco_*_*',
'keep *_hfreco_*_*',
'keep *_horeco_*_*',
'keep HBHERecHitsSorted_hbherecoMB_*_*',
Expand All @@ -22,6 +23,7 @@
#RECO content
RecoLocalCaloRECO = cms.PSet(
outputCommands = cms.untracked.vstring('keep *_hbhereco_*_*',
'keep *_hfprereco_*_*',
'keep *_hfreco_*_*',
'keep *_horeco_*_*',
'keep HBHERecHitsSorted_hbherecoMB_*_*',
Expand Down
Expand Up @@ -8,6 +8,7 @@
RecoLocalCaloFEVT = cms.PSet(
outputCommands = cms.untracked.vstring('keep *_hbhereco_*_*',
'keep *_hbheprereco_*_*',
'keep *_hfprereco_*_*',
'keep *_hfreco_*_*',
'keep *_horeco_*_*',
'keep HBHERecHitsSorted_hbherecoMB_*_*',
Expand All @@ -24,7 +25,8 @@
#RECO content
RecoLocalCaloRECO = cms.PSet(
outputCommands = cms.untracked.vstring('keep *_hbhereco_*_*',
'keep *_hbheprereco_*_*',
'keep *_hbheprereco_*_*',
'keep *_hfprereco_*_*',
'keep *_hfreco_*_*',
'keep *_horeco_*_*',
'keep HBHERecHitsSorted_hbherecoMB_*_*',
Expand Down

0 comments on commit 1726448

Please sign in to comment.