Skip to content

Commit

Permalink
Merge pull request #18103 from CTPPS/ctpps_pixel_unpacker
Browse files Browse the repository at this point in the history
Ctpps pixel unpacker
  • Loading branch information
davidlange6 committed Apr 13, 2017
2 parents ed781a4 + 94f4e85 commit 1f04ccd
Show file tree
Hide file tree
Showing 43 changed files with 2,607 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CondFormats/CTPPSReadoutObjects/BuildFile.xml
@@ -1,6 +1,9 @@
<use name="FWCore/Framework"/>
<use name="FWCore/Concurrency"/>
<use name="DataFormats/CTPPSDetId"/>

<use name="CondFormats/Serialization"/>
<use name="boost_serialization"/>
<export>
<lib name="1"/>
</export>
48 changes: 48 additions & 0 deletions CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelAnalysisMask.h
@@ -0,0 +1,48 @@
/****************************************************************************
*
* Author: F.Ferro ferro@ge.infn.it
*
****************************************************************************/

#ifndef CondFormats_CTPPSReadoutObjects_CTPPSPixelAnalysisMask
#define CondFormats_CTPPSReadoutObjects_CTPPSPixelAnalysisMask

#include <set>
#include <map>

#include "CondFormats/Serialization/interface/Serializable.h"
#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelIndices.h"

/**
*\brief Contains data on masked channels of a ROC
*/
class CTPPSPixelROCAnalysisMask
{
public:
CTPPSPixelROCAnalysisMask() : fullMask(false) {}

/// whether all channels of the ROC shall be masked
bool fullMask;

/// list of channels to be masked
std::set<std::pair<unsigned char, unsigned char> > maskedPixels;

COND_SERIALIZABLE;

};

/**
*\brief Channel-mask mapping.
**/
class CTPPSPixelAnalysisMask
{
public:
std::map<uint32_t, CTPPSPixelROCAnalysisMask> analysisMask;

void insert(const uint32_t &sid, const CTPPSPixelROCAnalysisMask &am);

COND_SERIALIZABLE;

};

#endif
55 changes: 55 additions & 0 deletions CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelDAQMapping.h
@@ -0,0 +1,55 @@
/****************************************************************************
*
*
* Authors:
* F.Ferro ferro@ge.infn.it
*
****************************************************************************/

#ifndef CondFormats_CTPPSReadoutObjects_CTPPSPixelDAQMapping
#define CondFormats_CTPPSReadoutObjects_CTPPSPixelDAQMapping

#include "CondFormats/Serialization/interface/Serializable.h"
#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelFramePosition.h"
#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelIndices.h"

#include <map>
#include <set>

//----------------------------------------------------------------------------------------------------

/**
*\brief Contains mappind data related to a ROC.
*/
class CTPPSPixelROCInfo
{
public:
/// the symbolic id
uint32_t iD;

unsigned int roc;

friend std::ostream& operator << (std::ostream& s, const CTPPSPixelROCInfo &fp);

COND_SERIALIZABLE;
};

//----------------------------------------------------------------------------------------------------

/**
*\brief The mapping between FramePosition and ROCInfo.
*/
class CTPPSPixelDAQMapping
{
public:
std::map<CTPPSPixelFramePosition, CTPPSPixelROCInfo> ROCMapping;

void insert(const CTPPSPixelFramePosition &fp, const CTPPSPixelROCInfo &vi);

std::set<unsigned int> fedIds() const;

COND_SERIALIZABLE;

};

#endif
118 changes: 118 additions & 0 deletions CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelFramePosition.h
@@ -0,0 +1,118 @@
/****************************************************************************
*
*
* Authors:
* F.Ferro ferro@ge.infn.it
*
****************************************************************************/

#ifndef CondFormats_CTPPSReadoutObjects_CTPPSPixelFramePosition
#define CondFormats_CTPPSReadoutObjects_CTPPSPixelFramePosition

#include <iostream>
#include <string>

#include "CondFormats/Serialization/interface/Serializable.h"

/**
* Uniquely identifies the DAQ channel through which a ROC frame has been received.
*
* The internal representation has the following structure:
* \verbatim
* | 32 bits raw position |
* | 11 bits | 12 bits | 1 bit | 6 bits | 2bits |
* | empty | FED ID | FMC 0-1 | fiber index 0-12 | ROC 0-2 |
* \endverbatim
*
**/
class CTPPSPixelFramePosition
{
public:
static const unsigned int offsetROC = 0, maskROC = 0x3;
static const unsigned int offsetChannelIdx = 2, maskChannelIdx = 0x3F;
static const unsigned int offsetFMCId = 8, maskFMCId = 0x1;
static const unsigned int offsetFEDId = 9, maskFEDId = 0xFFF;


/// the preferred constructor
CTPPSPixelFramePosition( unsigned short FEDId, unsigned short FMCId, unsigned short ChannelIdx, unsigned short ROC) :
rawPosition(ROC<<offsetROC | ChannelIdx<<offsetChannelIdx | FMCId<<FMCId | FEDId<<offsetFEDId )
{
}

/// don't use this constructor unless you have a good reason
CTPPSPixelFramePosition(unsigned int pos = 0) : rawPosition(pos)
{
}

~CTPPSPixelFramePosition()
{
}

/// recomended getters and setters

unsigned short getFEDId() const
{
return (rawPosition >> offsetFEDId) & maskFEDId;
}

void setFEDId(unsigned short v)
{ v &= maskFEDId; rawPosition &= 0xFFFFFFFF - (maskFEDId << offsetFEDId); rawPosition |= (v << offsetFEDId); }

unsigned short getChannelIdx() const { return (rawPosition >> offsetChannelIdx) & maskChannelIdx; }

void setChannelIdx(unsigned short v)
{ v &= maskChannelIdx; rawPosition &= 0xFFFFFFFF - (maskChannelIdx << offsetChannelIdx); rawPosition |= (v << offsetChannelIdx); }

unsigned short getROC() const { return (rawPosition >> offsetROC) & maskROC; }

void setROC(unsigned short v)
{ v &= maskROC; rawPosition &= 0xFFFFFFFF - (maskROC << offsetROC); rawPosition |= (v << offsetROC); }

unsigned short getFMCId() const { return (rawPosition >> offsetFMCId) & maskFMCId; }

void setFMCId(unsigned short v)
{ v &= maskFMCId; rawPosition &= 0xFFFFFFFF - (maskFMCId << offsetFMCId); rawPosition |= (v << offsetFMCId); }


unsigned int getRawPosition() const
{
return rawPosition;
}

bool operator < (const CTPPSPixelFramePosition &pos) const
{
return (rawPosition < pos.rawPosition);
}

bool operator == (const CTPPSPixelFramePosition &pos) const
{
return (rawPosition == pos.rawPosition);
}

/// Condensed representation of the DAQ channel.
/// prints 5-digit hex number,
friend std::ostream& operator << (std::ostream& s, const CTPPSPixelFramePosition &fp);

/// prints XML formatted DAQ channel to stdout
void printXML();

/// Sets attribute with XML name 'attribute' and value 'value'.
/// Also turns on attribute presents bit in the flag parameter
/// returns 0 if the attribute is known, non-zero value else
unsigned char setXMLAttribute(const std::string &attribute, const std::string &value, unsigned char &flag);

/// returns true if all attributes have been set
static bool checkXMLAttributeFlag(unsigned char flag)
{
return (flag == 0xF);
}

protected:
unsigned int rawPosition;

COND_SERIALIZABLE;

};

#endif

0 comments on commit 1f04ccd

Please sign in to comment.