Skip to content

Commit

Permalink
Merge pull request #38886 from forthommel/nt2_unpacking-12_5_X
Browse files Browse the repository at this point in the history
TOTEM nT2 unpacker
  • Loading branch information
cmsbuild committed Aug 7, 2022
2 parents 2373b50 + e06897d commit 848a3db
Show file tree
Hide file tree
Showing 21 changed files with 617 additions and 20 deletions.
122 changes: 121 additions & 1 deletion CalibPPS/ESProducers/plugins/TotemDAQMappingESSourceXML.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "DataFormats/CTPPSDetId/interface/TotemRPDetId.h"
#include "DataFormats/CTPPSDetId/interface/CTPPSDiamondDetId.h"
#include "DataFormats/CTPPSDetId/interface/TotemTimingDetId.h"
#include "DataFormats/CTPPSDetId/interface/TotemT2DetId.h"

#include "CondFormats/DataRecord/interface/TotemReadoutRcd.h"
#include "CondFormats/PPSObjects/interface/TotemDAQMapping.h"
Expand Down Expand Up @@ -77,6 +78,10 @@ class TotemDAQMappingESSourceXML : public edm::ESProducer, public edm::EventSetu
static const std::string tagTotemTimingCh;
static const std::string tagTotemTimingPlane;

/// TOTEM nT2 specific tags
static const std::string tagTotemT2Plane;
static const std::string tagTotemT2Tile;

TotemDAQMappingESSourceXML(const edm::ParameterSet &);
~TotemDAQMappingESSourceXML() override;

Expand Down Expand Up @@ -129,7 +134,9 @@ class TotemDAQMappingESSourceXML : public edm::ESProducer, public edm::EventSetu
nSampicBoard,
nSampicChannel,
nTotemTimingPlane,
nTotemTimingCh
nTotemTimingCh,
nTotemT2Plane,
nTotemT2Tile
};

/// whether to parse a mapping of a mask XML
Expand Down Expand Up @@ -165,6 +172,14 @@ class TotemDAQMappingESSourceXML : public edm::ESProducer, public edm::EventSetu
const std::unique_ptr<TotemDAQMapping> &,
const std::unique_ptr<TotemAnalysisMask> &);

/// recursive method to extract nT2-related information from the DOM tree
void ParseTreeTotemT2(ParseType,
xercesc::DOMNode *,
NodeType,
unsigned int parentID,
const std::unique_ptr<TotemDAQMapping> &,
const std::unique_ptr<TotemAnalysisMask> &);

private:
/// adds the path prefix, if needed
string CompleteFileName(const string &fn);
Expand Down Expand Up @@ -202,6 +217,8 @@ class TotemDAQMappingESSourceXML : public edm::ESProducer, public edm::EventSetu
(type == nSampicChannel) || (type == nTotemTimingPlane) || (type == nTotemTimingCh));
}

bool TotemT2Node(NodeType type) { return type == nArm || type == nTotemT2Plane || type == nTotemT2Tile; }

bool CommonNode(NodeType type) { return ((type == nChip) || (type == nArm)); }

protected:
Expand Down Expand Up @@ -243,6 +260,10 @@ const string TotemDAQMappingESSourceXML::tagSampicCh = "rp_sampic_channel";
const string TotemDAQMappingESSourceXML::tagTotemTimingCh = "timing_channel";
const string TotemDAQMappingESSourceXML::tagTotemTimingPlane = "timing_plane";

// specific tags for TOTEM nT2
const string TotemDAQMappingESSourceXML::tagTotemT2Plane = "nt2_plane";
const string TotemDAQMappingESSourceXML::tagTotemT2Tile = "nt2_tile";

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

TotemDAQMappingESSourceXML::TotemDAQMappingESSourceXML(const edm::ParameterSet &conf)
Expand Down Expand Up @@ -369,6 +390,8 @@ void TotemDAQMappingESSourceXML::ParseXML(ParseType pType,
ParseTreeDiamond(pType, elementRoot, nTop, 0, mapping, mask);

ParseTreeTotemTiming(pType, elementRoot, nTop, 0, mapping, mask);

ParseTreeTotemT2(pType, elementRoot, nTop, 0, mapping, mask);
}

//-----------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -782,6 +805,97 @@ void TotemDAQMappingESSourceXML::ParseTreeTotemTiming(ParseType pType,

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

void TotemDAQMappingESSourceXML::ParseTreeTotemT2(ParseType pType,
xercesc::DOMNode *parent,
NodeType parentType,
unsigned int parentID,
const std::unique_ptr<TotemDAQMapping> &mapping,
const std::unique_ptr<TotemAnalysisMask> &mask) {
DOMNodeList *children = parent->getChildNodes();

for (unsigned int i = 0; i < children->getLength(); i++) {
DOMNode *child = children->item(i);
if (child->getNodeType() != DOMNode::ELEMENT_NODE)
continue;

NodeType type = GetNodeType(child);

// structure control
if (!TotemT2Node(type))
continue;

NodeType expectedParentType;
switch (type) {
case nArm:
expectedParentType = nTop;
break;
case nTotemT2Plane:
expectedParentType = nArm;
break;
case nTotemT2Tile:
expectedParentType = nTotemT2Plane;
break;
default:
expectedParentType = nUnknown;
break;
}

if (expectedParentType != parentType) {
throw cms::Exception("TotemDAQMappingESSourceXML")
<< "Node " << cms::xerces::toString(child->getNodeName()) << " not allowed within "
<< cms::xerces::toString(parent->getNodeName()) << " block.\n";
}

unsigned int id = 0;
bool id_set = false;
DOMNamedNodeMap *attr = child->getAttributes();

for (unsigned int j = 0; j < attr->getLength(); j++) {
DOMNode *a = attr->item(j);
if (!strcmp(cms::xerces::toString(a->getNodeName()).c_str(), "id")) {
sscanf(cms::xerces::toString(a->getNodeValue()).c_str(), "%u", &id);
id_set = true;
}
}
if (pType == pMapping && type == nTotemT2Tile) {
// parse tag attributes
unsigned int hw_id = 0;
bool hw_id_set = false;
DOMNamedNodeMap *attr = child->getAttributes();

for (unsigned int j = 0; j < attr->getLength(); j++) {
DOMNode *a = attr->item(j);
if (!strcmp(cms::xerces::toString(a->getNodeName()).c_str(), "hwId")) {
sscanf(cms::xerces::toString(a->getNodeValue()).c_str(), "%u", &hw_id);
hw_id_set = true;
}
}

// content control
if (!id_set)
throw cms::Exception("TotemDAQMappingESSourceXML::ParseTreeTotemT2")
<< "id not given for element `" << cms::xerces::toString(child->getNodeName()) << "'";
if (!hw_id_set)
throw cms::Exception("TotemDAQMappingESSourceXML::ParseTreeTotemT2")
<< "hwId not given for element `" << cms::xerces::toString(child->getNodeName()) << "'";

// store mapping data
const TotemFramePosition &framepos = ChipFramePosition(child);
TotemVFATInfo vfatInfo;
unsigned int arm = parentID / 10, plane = parentID % 10;
vfatInfo.symbolicID.symbolicID = TotemT2DetId(arm, plane, id);

mapping->insert(framepos, vfatInfo);

continue;
}
// follow tree recursively
ParseTreeTotemT2(pType, child, type, parentID * 10 + id, mapping, mask);
}
}

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

TotemFramePosition TotemDAQMappingESSourceXML::ChipFramePosition(xercesc::DOMNode *chipnode) {
TotemFramePosition fp;
unsigned char attributeFlag = 0;
Expand Down Expand Up @@ -840,6 +954,12 @@ TotemDAQMappingESSourceXML::NodeType TotemDAQMappingESSourceXML::GetNodeType(xer
if (Test(n, tagTotemTimingPlane))
return nTotemTimingPlane;

// TOTEM nT2 specifics
if (Test(n, tagTotemT2Plane))
return nTotemT2Plane;
if (Test(n, tagTotemT2Tile))
return nTotemT2Tile;

// for backward compatibility
if (Test(n, "trigger_vfat"))
return nSkip;
Expand Down
15 changes: 15 additions & 0 deletions CalibPPS/ESProducers/python/totemT2DAQMapping_cff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import FWCore.ParameterSet.Config as cms

from CalibPPS.ESProducers.totemDAQMappingESSourceXML_cfi import totemDAQMappingESSourceXML as _xml

totemDAQMappingESSourceXML = _xml.clone(
subSystem = "TotemT2",
configuration = cms.VPSet(
cms.PSet(
validityRange = cms.EventRange("1:min - 999999999:max"),
mappingFileNames = cms.vstring("CondFormats/PPSObjects/xml/mapping_totem_nt2_2021.xml"),
maskFileNames = cms.vstring()
)
),
sampicSubDetId = cms.uint32(6),
)
105 changes: 105 additions & 0 deletions CondFormats/PPSObjects/xml/mapping_totem_nt2_2021.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<!-- This mapping is a dummy 1-to-1 association to PPS diamond readout
channels as used during run 2 operations (2017-2018). Please edit
accordingly once the final T2 tiles mapping has been clearly defined
and implemented. -->
<top>
<arm id="0"> <!-- sector 45, CMS negative z -->
<nt2_plane id="0">
<nt2_tile id="0" hwId="0x206" FEDId="583" GOHId="3" IdxInFiber="6"/>
<nt2_tile id="1" hwId="0x201" FEDId="583" GOHId="3" IdxInFiber="1"/>
<nt2_tile id="2" hwId="0x205" FEDId="583" GOHId="3" IdxInFiber="5"/>
<nt2_tile id="3" hwId="0x20D" FEDId="583" GOHId="3" IdxInFiber="13"/>
</nt2_plane>
<nt2_plane id="1">
<nt2_tile id="0" hwId="0x20A" FEDId="583" GOHId="3" IdxInFiber="10"/>
<nt2_tile id="1" hwId="0x202" FEDId="583" GOHId="3" IdxInFiber="2"/>
<nt2_tile id="2" hwId="0x204" FEDId="583" GOHId="3" IdxInFiber="4"/>
<nt2_tile id="3" hwId="0x20C" FEDId="583" GOHId="3" IdxInFiber="12"/>
</nt2_plane>
<nt2_plane id="2">
<nt2_tile id="0" hwId="0x20B" FEDId="583" GOHId="3" IdxInFiber="11"/>
<nt2_tile id="1" hwId="0x203" FEDId="583" GOHId="3" IdxInFiber="3"/>
<nt2_tile id="2" hwId="0x209" FEDId="583" GOHId="3" IdxInFiber="9"/>
<nt2_tile id="3" hwId="0x20E" FEDId="583" GOHId="3" IdxInFiber="14"/>
</nt2_plane>
<nt2_plane id="3">
<nt2_tile id="0" hwId="0x216" FEDId="583" GOHId="4" IdxInFiber="6"/>
<nt2_tile id="1" hwId="0x211" FEDId="583" GOHId="4" IdxInFiber="1"/>
<nt2_tile id="2" hwId="0x215" FEDId="583" GOHId="4" IdxInFiber="5"/>
<nt2_tile id="3" hwId="0x21D" FEDId="583" GOHId="4" IdxInFiber="13"/>
</nt2_plane>
<nt2_plane id="4">
<nt2_tile id="0" hwId="0x21A" FEDId="583" GOHId="4" IdxInFiber="10"/>
<nt2_tile id="1" hwId="0x212" FEDId="583" GOHId="4" IdxInFiber="2"/>
<nt2_tile id="2" hwId="0x214" FEDId="583" GOHId="4" IdxInFiber="4"/>
<nt2_tile id="3" hwId="0x21C" FEDId="583" GOHId="4" IdxInFiber="12"/>
</nt2_plane>
<nt2_plane id="5">
<nt2_tile id="0" hwId="0x21B" FEDId="583" GOHId="4" IdxInFiber="11"/>
<nt2_tile id="1" hwId="0x213" FEDId="583" GOHId="4" IdxInFiber="3"/>
<nt2_tile id="2" hwId="0x219" FEDId="583" GOHId="4" IdxInFiber="9"/>
<nt2_tile id="3" hwId="0x21E" FEDId="583" GOHId="4" IdxInFiber="14"/>
</nt2_plane>
<nt2_plane id="6">
<nt2_tile id="0" hwId="0x106" FEDId="583" GOHId="1" IdxInFiber="6"/>
<nt2_tile id="1" hwId="0x101" FEDId="583" GOHId="1" IdxInFiber="1"/>
<nt2_tile id="2" hwId="0x105" FEDId="583" GOHId="1" IdxInFiber="5"/>
<nt2_tile id="3" hwId="0x10D" FEDId="583" GOHId="1" IdxInFiber="13"/>
</nt2_plane>
<nt2_plane id="7">
<nt2_tile id="0" hwId="0x10A" FEDId="583" GOHId="1" IdxInFiber="10"/>
<nt2_tile id="1" hwId="0x102" FEDId="583" GOHId="1" IdxInFiber="2"/>
<nt2_tile id="2" hwId="0x104" FEDId="583" GOHId="1" IdxInFiber="4"/>
<nt2_tile id="3" hwId="0x10C" FEDId="583" GOHId="1" IdxInFiber="12"/>
</nt2_plane>
</arm>
<arm id="1"> <!-- sector 56, CMS positive z -->
<nt2_plane id="0">
<nt2_tile id="0" hwId="0x306" FEDId="582" GOHId="7" IdxInFiber="6"/>
<nt2_tile id="1" hwId="0x301" FEDId="582" GOHId="7" IdxInFiber="1"/>
<nt2_tile id="2" hwId="0x305" FEDId="582" GOHId="7" IdxInFiber="5"/>
<nt2_tile id="3" hwId="0x30D" FEDId="582" GOHId="7" IdxInFiber="13"/>
</nt2_plane>
<nt2_plane id="1">
<nt2_tile id="0" hwId="0x30A" FEDId="582" GOHId="7" IdxInFiber="10"/>
<nt2_tile id="1" hwId="0x302" FEDId="582" GOHId="7" IdxInFiber="2"/>
<nt2_tile id="2" hwId="0x304" FEDId="582" GOHId="7" IdxInFiber="4"/>
<nt2_tile id="3" hwId="0x30C" FEDId="582" GOHId="7" IdxInFiber="12"/>
</nt2_plane>
<nt2_plane id="2">
<nt2_tile id="0" hwId="0x30B" FEDId="582" GOHId="7" IdxInFiber="11"/>
<nt2_tile id="1" hwId="0x303" FEDId="582" GOHId="7" IdxInFiber="3"/>
<nt2_tile id="2" hwId="0x309" FEDId="582" GOHId="7" IdxInFiber="9"/>
<nt2_tile id="3" hwId="0x30E" FEDId="582" GOHId="7" IdxInFiber="14"/>
</nt2_plane>
<nt2_plane id="3">
<nt2_tile id="0" hwId="0x316" FEDId="582" GOHId="8" IdxInFiber="6"/>
<nt2_tile id="1" hwId="0x311" FEDId="582" GOHId="8" IdxInFiber="1"/>
<nt2_tile id="2" hwId="0x315" FEDId="582" GOHId="8" IdxInFiber="5"/>
<nt2_tile id="3" hwId="0x31D" FEDId="582" GOHId="8" IdxInFiber="13"/>
</nt2_plane>
<nt2_plane id="4">
<nt2_tile id="0" hwId="0x31A" FEDId="582" GOHId="8" IdxInFiber="10"/>
<nt2_tile id="1" hwId="0x312" FEDId="582" GOHId="8" IdxInFiber="2"/>
<nt2_tile id="2" hwId="0x314" FEDId="582" GOHId="8" IdxInFiber="4"/>
<nt2_tile id="3" hwId="0x31C" FEDId="582" GOHId="8" IdxInFiber="12"/>
</nt2_plane>
<nt2_plane id="5">
<nt2_tile id="0" hwId="0x31B" FEDId="582" GOHId="8" IdxInFiber="11"/>
<nt2_tile id="1" hwId="0x313" FEDId="582" GOHId="8" IdxInFiber="3"/>
<nt2_tile id="2" hwId="0x319" FEDId="582" GOHId="8" IdxInFiber="9"/>
<nt2_tile id="3" hwId="0x31E" FEDId="582" GOHId="8" IdxInFiber="14"/>
</nt2_plane>
<nt2_plane id="6">
<nt2_tile id="0" hwId="0x406" FEDId="582" GOHId="3" IdxInFiber="6"/>
<nt2_tile id="1" hwId="0x401" FEDId="582" GOHId="3" IdxInFiber="1"/>
<nt2_tile id="2" hwId="0x405" FEDId="582" GOHId="3" IdxInFiber="5"/>
<nt2_tile id="3" hwId="0x40D" FEDId="582" GOHId="3" IdxInFiber="13"/>
</nt2_plane>
<nt2_plane id="7">
<nt2_tile id="0" hwId="0x40A" FEDId="582" GOHId="3" IdxInFiber="10"/>
<nt2_tile id="1" hwId="0x402" FEDId="582" GOHId="3" IdxInFiber="2"/>
<nt2_tile id="2" hwId="0x404" FEDId="582" GOHId="3" IdxInFiber="4"/>
<nt2_tile id="3" hwId="0x40C" FEDId="582" GOHId="3" IdxInFiber="12"/>
</nt2_plane>
</arm>
8 changes: 7 additions & 1 deletion DataFormats/CTPPSDetId/interface/CTPPSDetId.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@
class CTPPSDetId : public DetId {
public:
/// CTPPS sub-detectors
enum SubDetector { sdTrackingStrip = 3, sdTrackingPixel = 4, sdTimingDiamond = 5, sdTimingFastSilicon = 6 };
enum SubDetector {
sdTrackingStrip = 3,
sdTrackingPixel = 4,
sdTimingDiamond = 5,
sdTimingFastSilicon = 6,
sdTotemT2 = 7
};

/// Construct from a raw id.
explicit CTPPSDetId(uint32_t id);
Expand Down
Loading

0 comments on commit 848a3db

Please sign in to comment.