Skip to content

Commit

Permalink
Merge pull request cms-sw#16616 from CTPPS/ctpps_diamond_raw_to_digi
Browse files Browse the repository at this point in the history
CTPPS: raw-to-digi for diamond detectors
  • Loading branch information
davidlange6 authored Nov 30, 2016
2 parents 381d6ae + c0c2a48 commit 03fb439
Show file tree
Hide file tree
Showing 45 changed files with 1,101 additions and 899 deletions.
1 change: 1 addition & 0 deletions CondFormats/CTPPSReadoutObjects/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<use name="FWCore/Framework"/>
<use name="DataFormats/CTPPSDetId"/>

<export>
<lib name="1"/>
Expand Down
3 changes: 0 additions & 3 deletions CondFormats/CTPPSReadoutObjects/interface/TotemDAQMapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
class TotemVFATInfo
{
public:
/// is data of coincidence-chip VFAT
enum {data, CC} type;

/// the symbolic id
TotemSymbID symbolicID;

Expand Down
78 changes: 39 additions & 39 deletions CondFormats/CTPPSReadoutObjects/interface/TotemFramePosition.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,25 @@
*
* The internal representation has the following structure:
* \verbatim
* | 32 bits raw position |
* | 12 bits | 2 bits | 3 bits | 5 bits | 2 bits | 4 bits | 4 bits |
* | empty | empty | SubSystem | TOTFED ID | OptoRx ID | GOH ID | index within fiber |
* | | (this part is encoded in OptoRx header) | |
* | 32 bits raw position |
* | 12 bits | 2 bits | 10 bits | 4 bits | 4 bits |
* | empty | empty | FED ID | GOH ID | index within fiber |
* \endverbatim
* According to the convention SubSystemId goes from 1 to 6, TOTFEDId from 1 to 21 and OptoRx from 1 to 3.
*
* In the old (TOTEM only) scheme, the FED ID was further split
* \verbatim
* | 3 bits | 5 bits | 2 bits |
* | SubSystem | TOTFED ID | OptoRx ID |
* \endverbatim
* IMPORTANT: This splitting is only supported for backward compatibility and should not be used anymore.
**/
class TotemFramePosition
{
public:
/// the official enumeration of DAQ subsystems
enum SubSystemType {ssNone=0, ssT1=1, ssT2=2, ssRP=3, ssTrigger=4, ssTTC=5, ssFEC=6};

static const unsigned int offsetIdxInFiber = 0, maskIdxInFiber = 0xF;
static const unsigned int offsetGOHId = 4, maskGOHId = 0xF;
static const unsigned int offsetFEDId = 8, maskFEDId = 0x3FF;

static const unsigned int offsetOptoRxId = 8, maskOptoRxId = 0x3;
static const unsigned int offsetTOTFEDId = 10, maskTOTFEDId = 0x1F;
static const unsigned int offsetSubSystemId = 15, maskSubSystemId = 0x7;
Expand All @@ -51,40 +55,50 @@ class TotemFramePosition
{
}

unsigned short getSubSystemId() const { return (rawPosition >> offsetSubSystemId) & maskSubSystemId; }
unsigned short getTOTFEDId() const { return (rawPosition >> offsetTOTFEDId) & maskTOTFEDId;}
unsigned short getOptoRxId() const { return (rawPosition >> offsetOptoRxId) & maskOptoRxId; }
/// 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 getGOHId() const { return (rawPosition >> offsetGOHId) & maskGOHId; }

void setGOHId(unsigned short v)
{ v &= maskGOHId; rawPosition &= 0xFFFFFFFF - (maskGOHId << offsetGOHId); rawPosition |= (v << offsetGOHId); }

unsigned short getIdxInFiber() const { return (rawPosition >> offsetIdxInFiber) & maskIdxInFiber; }

void setIdxInFiber(unsigned short v)
{ v &= maskIdxInFiber; rawPosition &= 0xFFFFFFFF - (maskIdxInFiber << offsetIdxInFiber); rawPosition |= (v << offsetIdxInFiber); }


/// the getters and setters below are deprecated

unsigned short getSubSystemId() const { return (rawPosition >> offsetSubSystemId) & maskSubSystemId; }

void setSubSystemId(unsigned short v)
{ v &= maskSubSystemId; rawPosition &= 0xFFFFFFFF - (maskSubSystemId << offsetSubSystemId); rawPosition |= (v << offsetSubSystemId); }

unsigned short getTOTFEDId() const { return (rawPosition >> offsetTOTFEDId) & maskTOTFEDId;}

void setTOTFEDId(unsigned short v)
{ v &= maskTOTFEDId; rawPosition &= 0xFFFFFFFF - (maskTOTFEDId << offsetTOTFEDId); rawPosition |= (v << offsetTOTFEDId); }

unsigned short getOptoRxId() const { return (rawPosition >> offsetOptoRxId) & maskOptoRxId; }

void setOptoRxId(unsigned short v)
{ v &= maskOptoRxId; rawPosition &= 0xFFFFFFFF - (maskOptoRxId << offsetOptoRxId); rawPosition |= (v << offsetOptoRxId); }

void setGOHId(unsigned short v)
{ v &= maskGOHId; rawPosition &= 0xFFFFFFFF - (maskGOHId << offsetGOHId); rawPosition |= (v << offsetGOHId); }

void setIdxInFiber(unsigned short v)
{ v &= maskIdxInFiber; rawPosition &= 0xFFFFFFFF - (maskIdxInFiber << offsetIdxInFiber); rawPosition |= (v << offsetIdxInFiber); }

void setAllIDs(unsigned short SubSystemId, unsigned short TOTFEDId, unsigned short OptoRxId, unsigned short GOHId, unsigned short IdxInFiber)
{
rawPosition = (IdxInFiber<<offsetIdxInFiber | GOHId<<offsetGOHId | OptoRxId<<offsetOptoRxId
| TOTFEDId<<offsetTOTFEDId | SubSystemId<<offsetSubSystemId);
}

/// don't use this method unless you have a good reason
unsigned int getRawPosition() const
{
return rawPosition;
}

public:
bool operator < (const TotemFramePosition &pos) const
{
return (rawPosition < pos.rawPosition);
Expand All @@ -100,15 +114,6 @@ class TotemFramePosition
/// GOH ID, index within fiber in this order
friend std::ostream& operator << (std::ostream& s, const TotemFramePosition &fp);

/// XML sub-system tags
static const std::string tagSSNone;
static const std::string tagSSTrigger;
static const std::string tagSST1;
static const std::string tagSST2;
static const std::string tagSSRP;
static const std::string tagSSTTC;
static const std::string tagSSFEC;

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

Expand All @@ -120,12 +125,7 @@ class TotemFramePosition
/// returns true if all attributes have been set
static bool checkXMLAttributeFlag(unsigned char flag)
{
return ((flag == 0x1f) | (flag == 0x20) | (flag == 0x40));
}

unsigned short getFullOptoRxId() const
{
return (rawPosition >> 8) & 0xFFF;
return (flag == 0x1f);
}

protected:
Expand Down
10 changes: 2 additions & 8 deletions CondFormats/CTPPSReadoutObjects/interface/TotemSymbId.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,17 @@
class TotemSymbID
{
public:
// TODO: remove ??
/// identifies the TOTEM subsystem
enum {RP, T1, T2} subSystem;

/// chip ID, raw integer representation of DetId class
unsigned int symbolicID;

bool operator < (const TotemSymbID &sid) const
{
if (subSystem == sid.subSystem)
return (symbolicID < sid.symbolicID);
return (subSystem < sid.subSystem);
return (symbolicID < sid.symbolicID);
}

bool operator == (const TotemSymbID &sid) const
{
return ((subSystem==sid.subSystem) && (symbolicID==sid.symbolicID));
return (symbolicID == sid.symbolicID);
}

friend std::ostream& operator << (std::ostream& s, const TotemSymbID &sid);
Expand Down
21 changes: 13 additions & 8 deletions CondFormats/CTPPSReadoutObjects/plugins/PrintTotemDAQMapping.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
//----------------------------------------------------------------------------------------------------

/**
*\brief Prints the DAQ mapping loaded by DAQMappingSourceXML.
*\brief Prints the DAQ mapping loaded by TotemDAQMappingESSourceXML.
**/
class PrintTotemDAQMapping : public edm::one::EDAnalyzer<>
{
Expand All @@ -29,17 +29,15 @@ class PrintTotemDAQMapping : public edm::one::EDAnalyzer<>
~PrintTotemDAQMapping() {}

private:
virtual void beginRun(edm::Run const&, edm::EventSetup const&);
virtual void analyze(const edm::Event &e, const edm::EventSetup &es) {}
virtual void endJob() {}
virtual void analyze(const edm::Event &e, const edm::EventSetup &es) override;
};

using namespace std;
using namespace edm;

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

void PrintTotemDAQMapping::beginRun(edm::Run const&, edm::EventSetup const& es)
void PrintTotemDAQMapping::analyze(const edm::Event&, edm::EventSetup const& es)
{
// get mapping
ESHandle<TotemDAQMapping> mapping;
Expand All @@ -49,10 +47,17 @@ void PrintTotemDAQMapping::beginRun(edm::Run const&, edm::EventSetup const& es)
ESHandle<TotemAnalysisMask> analysisMask;
es.get<TotemReadoutRcd>().get(analysisMask);

// print mapping
printf("* DAQ mapping\n");
for (const auto &p : mapping->VFATMapping)
{
cout << p.first << " -> " << p.second << endl;
}
cout << " " << p.first << " -> " << p.second << endl;

// print mapping
printf("* mask\n");
for (const auto &p : analysisMask->analysisMask)
cout << " " << p.first
<< ": fullMask=" << p.second.fullMask
<< ", number of masked channels " << p.second.maskedChannels.size() << endl;
}

//----------------------------------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 03fb439

Please sign in to comment.