diff --git a/CondFormats/TotemReadoutObjects/BuildFile.xml b/CondFormats/TotemReadoutObjects/BuildFile.xml deleted file mode 100644 index 193dfc68b50..00000000000 --- a/CondFormats/TotemReadoutObjects/BuildFile.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/CondFormats/TotemReadoutObjects/interface/TotemAnalysisMask.h b/CondFormats/TotemReadoutObjects/interface/TotemAnalysisMask.h deleted file mode 100644 index 3c1b4f7884c..00000000000 --- a/CondFormats/TotemReadoutObjects/interface/TotemAnalysisMask.h +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Maciej Wróbel (wroblisko@gmail.com) -* Jan Kašpar (jan.kaspar@cern.ch) -* -****************************************************************************/ - -#ifndef CondFormats_TotemReadoutObjects_TotemAnalysisMask -#define CondFormats_TotemReadoutObjects_TotemAnalysisMask - -#include "CondFormats/TotemReadoutObjects/interface/TotemSymbId.h" - -#include -#include - -//---------------------------------------------------------------------------------------------------- - -/** - *\brief Contains data on masked channels of a VFAT. - */ -class TotemVFATAnalysisMask -{ - public: - TotemVFATAnalysisMask() : fullMask(false) {} - - /// whether all channels of the VFAT shall be masked - bool fullMask; - - /// list of channels to be masked - std::set maskedChannels; -}; - -//---------------------------------------------------------------------------------------------------- - -/** - *\brief Channel-mask mapping. - **/ -class TotemAnalysisMask -{ - public: - std::map analysisMask; - - void insert(const TotemSymbID &sid, const TotemVFATAnalysisMask &vam); -}; - -#endif diff --git a/CondFormats/TotemReadoutObjects/interface/TotemDAQMapping.h b/CondFormats/TotemReadoutObjects/interface/TotemDAQMapping.h deleted file mode 100644 index 6d0df627064..00000000000 --- a/CondFormats/TotemReadoutObjects/interface/TotemDAQMapping.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Maciej Wróbel (wroblisko@gmail.com) -* Jan Kašpar (jan.kaspar@cern.ch) -* -****************************************************************************/ - -#ifndef CondFormats_TotemReadoutObjects_TotemDAQMapping -#define CondFormats_TotemReadoutObjects_TotemDAQMapping - -#include "CondFormats/TotemReadoutObjects/interface/TotemFramePosition.h" - -#include "CondFormats/TotemReadoutObjects/interface/TotemSymbId.h" - -#include - -//---------------------------------------------------------------------------------------------------- - -/** - *\brief Contains mappind data related to a VFAT. - */ -class TotemVFATInfo -{ - public: - /// is data of coincidence-chip VFAT - enum {data, CC} type; - - /// the symbolic id - TotemSymbID symbolicID; - - /// the hardware ID (16 bit) - unsigned int hwID; - - friend std::ostream& operator << (std::ostream& s, const TotemVFATInfo &fp); -}; - -//---------------------------------------------------------------------------------------------------- - -/** - *\brief The mapping between FramePosition and VFATInfo. - */ -class TotemDAQMapping -{ - public: - std::map VFATMapping; - - void insert(const TotemFramePosition &fp, const TotemVFATInfo &vi); -}; - -#endif diff --git a/CondFormats/TotemReadoutObjects/interface/TotemFramePosition.h b/CondFormats/TotemReadoutObjects/interface/TotemFramePosition.h deleted file mode 100644 index 6c752b119bf..00000000000 --- a/CondFormats/TotemReadoutObjects/interface/TotemFramePosition.h +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -* -* This is a part of the TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#ifndef CondFormats_TotemReadoutObjects_TotemFramePosition -#define CondFormats_TotemReadoutObjects_TotemFramePosition - -#include -#include - -/** - * Uniquely identifies the DAQ channel through which a VFAT frame has been received. - * - * The internal representation has the following structure: - * \verbatim - * | 32 bits raw position | - * | 12 bits | 2 bits | 10 bits | 4 bits | 4 bits | - * | empty | empty | FED ID | GOH ID | index within fiber | - * \endverbatim - * - * In a 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: - 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; - - /// the preferred constructor - TotemFramePosition(unsigned short SubSystemId, unsigned short TOTFEDId, unsigned short OptoRxId, unsigned short GOHId, unsigned short IdxInFiber) : - rawPosition(IdxInFiber<> 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); } - - /// don't use this method unless you have a good reason - unsigned int getRawPosition() const - { - return rawPosition; - } - - bool operator < (const TotemFramePosition &pos) const - { - return (rawPosition < pos.rawPosition); - } - - bool operator == (const TotemFramePosition &pos) const - { - return (rawPosition == pos.rawPosition); - } - - /// Condensed representation of the DAQ channel. - /// prints 5-digit hex number, the digits correspond to SubSystem, TOTFED ID, OptoRx ID, - /// GOH ID, index within fiber in this order - friend std::ostream& operator << (std::ostream& s, const TotemFramePosition &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 == 0x1f); - } - - protected: - unsigned int rawPosition; -}; - -#endif diff --git a/CondFormats/TotemReadoutObjects/interface/TotemSymbId.h b/CondFormats/TotemReadoutObjects/interface/TotemSymbId.h deleted file mode 100644 index 99fc5005862..00000000000 --- a/CondFormats/TotemReadoutObjects/interface/TotemSymbId.h +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@cern.ch) -* -****************************************************************************/ - -#ifndef CondFormats_TotemReadoutObjects_TotemSymbId -#define CondFormats_TotemReadoutObjects_TotemSymbId - -#include - -/** - *\brief Symbolic ID describing an entity of a TOTEM subdetector. - **/ -class TotemSymbID -{ - public: - /// identifies the TOTEM subsystem - enum {RP, T1, T2} subSystem; - - /// integer-encoded symbolic ID - unsigned int symbolicID; - - bool operator < (const TotemSymbID &sid) const - { - if (subSystem == sid.subSystem) - return (symbolicID < sid.symbolicID); - return (subSystem < sid.subSystem); - } - - bool operator == (const TotemSymbID &sid) const - { - return ((subSystem==sid.subSystem) && (symbolicID==sid.symbolicID)); - } - - friend std::ostream& operator << (std::ostream& s, const TotemSymbID &sid); -}; - -#endif diff --git a/CondFormats/TotemReadoutObjects/plugins/BuildFile.xml b/CondFormats/TotemReadoutObjects/plugins/BuildFile.xml deleted file mode 100644 index 653b699f384..00000000000 --- a/CondFormats/TotemReadoutObjects/plugins/BuildFile.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/CondFormats/TotemReadoutObjects/plugins/PrintTotemDAQMapping.cc b/CondFormats/TotemReadoutObjects/plugins/PrintTotemDAQMapping.cc deleted file mode 100644 index c8519aa65c1..00000000000 --- a/CondFormats/TotemReadoutObjects/plugins/PrintTotemDAQMapping.cc +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#include "FWCore/Framework/interface/one/EDAnalyzer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Framework/interface/ESHandle.h" - -#include "CondFormats/DataRecord/interface/TotemReadoutRcd.h" -#include "CondFormats/TotemReadoutObjects/interface/TotemDAQMapping.h" -#include "CondFormats/TotemReadoutObjects/interface/TotemAnalysisMask.h" - -//---------------------------------------------------------------------------------------------------- - -/** - *\brief Prints the DAQ mapping loaded by DAQMappingSourceXML. - **/ -class PrintTotemDAQMapping : public edm::one::EDAnalyzer<> -{ - public: - PrintTotemDAQMapping(const edm::ParameterSet &ps) {} - ~PrintTotemDAQMapping() {} - - private: - virtual void analyze(const edm::Event &e, const edm::EventSetup &es) override; -}; - -using namespace std; -using namespace edm; - -//---------------------------------------------------------------------------------------------------- - -void PrintTotemDAQMapping::analyze(const edm::Event &e, const edm::EventSetup &es) -{ - // get mapping - ESHandle mapping; - es.get().get(mapping); - - // get analysis mask to mask channels - ESHandle analysisMask; - es.get().get(analysisMask); - - for (const auto &p : mapping->VFATMapping) - { - cout << p.first << " -> " << p.second << endl; - } -} - -//---------------------------------------------------------------------------------------------------- - -DEFINE_FWK_MODULE(PrintTotemDAQMapping); diff --git a/CondFormats/TotemReadoutObjects/plugins/TotemDAQMappingESSourceXML.cc b/CondFormats/TotemReadoutObjects/plugins/TotemDAQMappingESSourceXML.cc deleted file mode 100644 index 6ba668e8c94..00000000000 --- a/CondFormats/TotemReadoutObjects/plugins/TotemDAQMappingESSourceXML.cc +++ /dev/null @@ -1,1050 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Maciej Wróbel (wroblisko@gmail.com) -* Jan Kašpar (jan.kaspar@cern.ch) -* Marcin Borratynski (mborratynski@gmail.com) -* -****************************************************************************/ - -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Framework/interface/SourceFactory.h" -#include "FWCore/Framework/interface/ModuleFactory.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Framework/interface/ESProducer.h" -#include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h" -#include "FWCore/Framework/interface/ESProducts.h" -#include "FWCore/Framework/interface/SourceFactory.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -#include "CondFormats/DataRecord/interface/TotemReadoutRcd.h" -#include "CondFormats/TotemReadoutObjects/interface/TotemDAQMapping.h" -#include "CondFormats/TotemReadoutObjects/interface/TotemAnalysisMask.h" -#include "CondFormats/TotemReadoutObjects/interface/TotemFramePosition.h" - -#include -#include -#include -#include -#include - -#include -#include - -//#define DEBUG 1 - -//---------------------------------------------------------------------------------------------------- - -using namespace std; - -/** - * \brief Loads TotemDAQMapping and TotemAnalysisMask from two XML files. - **/ -class TotemDAQMappingESSourceXML: public edm::ESProducer, public edm::EventSetupRecordIntervalFinder -{ -public: - static const std::string tagVFAT; - static const std::string tagChannel; - static const std::string tagAnalysisMask; - - /// Common position tags - static const std::string tagArm; - - /// RP XML tags - static const std::string tagRPStation; - static const std::string tagRPPot; - static const std::string tagRPPlane; - - /// T2 XML tags - static const std::string tagT2; - static const std::string tagT2Half; - static const std::string tagT2detector; - - /// T1 XML tags - static const std::string tagT1; - static const std::string tagT1Arm; - static const std::string tagT1Plane; - static const std::string tagT1CSC; - static const std::string tagT1ChannelType; - - /// COMMON Chip XML tags - static const std::string tagChip1; - static const std::string tagChip2; - static const std::string tagTriggerVFAT1; - - TotemDAQMappingESSourceXML(const edm::ParameterSet &); - ~TotemDAQMappingESSourceXML(); - - edm::ESProducts< boost::shared_ptr, boost::shared_ptr > produce( const TotemReadoutRcd & ); - -private: - unsigned int verbosity; - - /// the mapping files - std::vector mappingFileNames; - - /// the mask files - std::vector maskFileNames; - - /// enumeration of XML node types - enum NodeType { nUnknown, nTop, nArm, nRPStation, nRPPot, nRPPlane, nChip, nTriggerVFAT, - nT2, nT2Half, nT2Det, nT1, nT1Arm, nT1Plane, nT1CSC, nT1ChannelType, nChannel }; - - /// whether to parse a mapping of a mask XML - enum ParseType { pMapping, pMask }; - - /// parses XML file - void ParseXML(ParseType, const string &file, const boost::shared_ptr&, const boost::shared_ptr&); - - /// recursive method to extract RP-related information from the DOM tree - void ParseTreeRP(ParseType, xercesc::DOMNode *, NodeType, unsigned int parentID, - const boost::shared_ptr&, const boost::shared_ptr&); - - /// recursive method to extract RP-related information from the DOM tree - void ParseTreeT1(ParseType, xercesc::DOMNode *, NodeType, unsigned int parentID, - const boost::shared_ptr&, const boost::shared_ptr&, - unsigned int T1Arm, unsigned int T1Plane, unsigned int T1CSC); - - /// recursive method to extract RP-related information from the DOM tree - void ParseTreeT2(ParseType, xercesc::DOMNode *, NodeType, unsigned int parentID, - const boost::shared_ptr&, const boost::shared_ptr&); - -private: - /// adds the path prefix, if needed - string CompleteFileName(const string &fn); - - /// returns the top element from an XML file - xercesc::DOMDocument* GetDOMDocument(string file); - - /// returns true iff the node is of the given name - bool Test(xercesc::DOMNode *node, const std::string &name) - { - return !(name.compare(xercesc::XMLString::transcode(node->getNodeName()))); - } - - /// determines node type - NodeType GetNodeType(xercesc::DOMNode *); - - /// returns the content of the node - string GetNodeContent(xercesc::DOMNode *parent) - { - return string(xercesc::XMLString::transcode(parent->getTextContent())); - } - - /// returns the value of the node - string GetNodeValue(xercesc::DOMNode *node) - { - return string(xercesc::XMLString::transcode(node->getNodeValue())); - } - - /// extracts VFAT's DAQ channel from XML attributes - TotemFramePosition ChipFramePosition(xercesc::DOMNode *chipnode); - - void GetChannels(xercesc::DOMNode *n, std::set &channels); - - bool RPNode(NodeType type) - { - return ((type == nArm)||(type == nRPStation)||(type == nRPPot)||(type == nRPPlane)||(type == nChip)||(type == nTriggerVFAT)); - } - - bool T2Node(NodeType type) - { - return ((type==nT2)||(type==nT2Det)|| (type==nT2Half)); - } - - bool T1Node(NodeType type) - { - return ((type==nT1)||(type==nT1Arm)|| (type==nT1Plane) || (type==nT1CSC) || (type==nT1ChannelType)); - } - - bool CommonNode(NodeType type) - { - return ((type==nChip)||(type==nArm)); - } - -protected: - /// sets infinite validity of this data - virtual void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&, const edm::IOVSyncValue&, edm::ValidityInterval&); -}; - -//---------------------------------------------------------------------------------------------------- - -using namespace std; -using namespace edm; -using namespace xercesc; - -const string TotemDAQMappingESSourceXML::tagVFAT="vfat"; -const string TotemDAQMappingESSourceXML::tagChannel="channel"; -const string TotemDAQMappingESSourceXML::tagAnalysisMask="analysisMask"; - -// common XML position tags -const string TotemDAQMappingESSourceXML::tagArm = "arm"; - -// common XML Chip tags -const string TotemDAQMappingESSourceXML::tagChip1 = "vfat"; -const string TotemDAQMappingESSourceXML::tagChip2 = "test_vfat"; -const string TotemDAQMappingESSourceXML::tagTriggerVFAT1 = "trigger_vfat"; - -// specific RP XML tags -const string TotemDAQMappingESSourceXML::tagRPStation = "station"; -const string TotemDAQMappingESSourceXML::tagRPPot = "rp_detector_set"; -const string TotemDAQMappingESSourceXML::tagRPPlane = "rp_plane"; - -// specific T2 XML tags -const string TotemDAQMappingESSourceXML::tagT2="t2_detector_set"; -const string TotemDAQMappingESSourceXML::tagT2detector="t2_detector"; -const string TotemDAQMappingESSourceXML::tagT2Half="t2_half"; - -// specific T1 XML tags -const string TotemDAQMappingESSourceXML::tagT1="t1_detector_set"; -const string TotemDAQMappingESSourceXML::tagT1Arm="t1_arm"; -const string TotemDAQMappingESSourceXML::tagT1Plane="t1_plane"; -const string TotemDAQMappingESSourceXML::tagT1CSC="t1_csc"; -const string TotemDAQMappingESSourceXML::tagT1ChannelType="t1_channel_type"; - -//---------------------------------------------------------------------------------------------------- - -TotemDAQMappingESSourceXML::TotemDAQMappingESSourceXML(const edm::ParameterSet& conf) : - verbosity(conf.getUntrackedParameter("verbosity", 0)), - mappingFileNames(conf.getUntrackedParameter< vector >("mappingFileNames")), - maskFileNames(conf.getUntrackedParameter< vector >("maskFileNames")) -{ - setWhatProduced(this); - findingRecord(); -} - -//---------------------------------------------------------------------------------------------------- - -string TotemDAQMappingESSourceXML::CompleteFileName(const string &fn) -{ - FileInPath fip(fn); - return fip.fullPath(); -} - -//---------------------------------------------------------------------------------------------------- - -void TotemDAQMappingESSourceXML::setIntervalFor(const edm::eventsetup::EventSetupRecordKey&, - const edm::IOVSyncValue& iosv, edm::ValidityInterval& oValidity) -{ - ValidityInterval infinity(iosv.beginOfTime(), iosv.endOfTime()); - oValidity = infinity; -} - -//---------------------------------------------------------------------------------------------------- - -DOMDocument* TotemDAQMappingESSourceXML::GetDOMDocument(string file) -{ - XercesDOMParser* parser = new XercesDOMParser(); - parser->parse(file.c_str()); - - DOMDocument* xmlDoc = parser->getDocument(); - - if (!xmlDoc) - throw cms::Exception("TotemDAQMappingESSourceXML::GetDOMDocument") << "Cannot parse file `" << file - << "' (xmlDoc = NULL)." << endl; - - return xmlDoc; -} - -//---------------------------------------------------------------------------------------------------- - -TotemDAQMappingESSourceXML::~TotemDAQMappingESSourceXML() -{ -} - -//---------------------------------------------------------------------------------------------------- - -edm::ESProducts< boost::shared_ptr, boost::shared_ptr > - TotemDAQMappingESSourceXML::produce( const TotemReadoutRcd & ) -{ - boost::shared_ptr mapping(new TotemDAQMapping()); - boost::shared_ptr mask(new TotemAnalysisMask()); - - // initialize Xerces - try - { - XMLPlatformUtils::Initialize(); - } - catch (const XMLException& toCatch) - { - char* message = XMLString::transcode(toCatch.getMessage()); - throw cms::Exception("TotemDAQMappingESSourceXML") << "An XMLException caught with message: " << message << ".\n"; - XMLString::release(&message); - } - - // load mapping files - for (unsigned int i = 0; i < mappingFileNames.size(); ++i) - ParseXML(pMapping, CompleteFileName(mappingFileNames[i]), mapping, mask); - - // load mask files - for (unsigned int i = 0; i < maskFileNames.size(); ++i) - ParseXML(pMask, CompleteFileName(maskFileNames[i]), mapping, mask); - - // release Xerces - XMLPlatformUtils::Terminate(); - - // commit the products - return edm::es::products(mapping, mask); -} - -//---------------------------------------------------------------------------------------------------- - -void TotemDAQMappingESSourceXML::ParseXML(ParseType pType, const string &file, - const boost::shared_ptr &mapping, const boost::shared_ptr &mask) -{ - DOMDocument* domDoc = GetDOMDocument(file); - DOMElement* elementRoot = domDoc->getDocumentElement(); - - if (!elementRoot) - throw cms::Exception("TotemDAQMappingESSourceXML::ParseMappingXML") << "File `" << - file << "' is empty." << endl; - - ParseTreeRP(pType, elementRoot, nTop, 0, mapping, mask); - ParseTreeT2(pType, elementRoot, nTop, 0, mapping, mask); - ParseTreeT1(pType, elementRoot, nTop, 0, mapping, mask, 0,0,0); -} - -//----------------------------------------------------------------------------------------------------------- - -void TotemDAQMappingESSourceXML::ParseTreeRP(ParseType pType, xercesc::DOMNode * parent, NodeType parentType, - unsigned int parentID, const boost::shared_ptr& mapping, - const boost::shared_ptr& mask) -{ -#ifdef DEBUG - printf(">> TotemDAQMappingESSourceXML::ParseTreeRP(%s, %u, %u)\n", XMLString::transcode(parent->getNodeName()), - parentType, parentID); -#endif - - DOMNodeList *children = parent->getChildNodes(); - - for (unsigned int i = 0; i < children->getLength(); i++) - { - DOMNode *n = children->item(i); - if (n->getNodeType() != DOMNode::ELEMENT_NODE) - continue; - - NodeType type = GetNodeType(n); - -#ifdef DEBUG - printf("\tname = %s, type = %u\n", XMLString::transcode(n->getNodeName()), type); -#endif - - // structure control - if (!RPNode(type)) - continue; - - if ((type != parentType + 1)&&(parentType != nRPPot || type != nTriggerVFAT)) - { - if (parentType == nTop && type == nRPPot) - { - LogPrint("TotemDAQMappingESSourceXML") << ">> TotemDAQMappingESSourceXML::ParseTreeRP > Warning: tag `" << tagRPPot - << "' found in global scope, assuming station ID = 12."; - parentID = 12; - } else { - throw cms::Exception("TotemDAQMappingESSourceXML") << "Node " << XMLString::transcode(n->getNodeName()) - << " not allowed within " << XMLString::transcode(parent->getNodeName()) << " block.\n"; - } - } - - // parse tag attributes - unsigned int id = 0, hw_id = 0; - bool id_set = false, hw_id_set = false; - bool fullMask = false; - DOMNamedNodeMap* attr = n->getAttributes(); - - for (unsigned int j = 0; j < attr->getLength(); j++) - { - DOMNode *a = attr->item(j); - - if (!strcmp(XMLString::transcode(a->getNodeName()), "id")) - { - sscanf(XMLString::transcode(a->getNodeValue()), "%u", &id); - id_set = true; - } - - if (!strcmp(XMLString::transcode(a->getNodeName()), "hw_id")) - { - sscanf(XMLString::transcode(a->getNodeValue()), "%x", &hw_id); - hw_id_set = true; - } - - if (!strcmp(XMLString::transcode(a->getNodeName()), "full_mask")) - fullMask = (strcmp(XMLString::transcode(a->getNodeValue()), "no") != 0); - } - - // content control - if (!id_set && type != nTriggerVFAT) - throw cms::Exception("TotemDAQMappingESSourceXML::ParseTreeRP") << "id not given for element `" - << XMLString::transcode(n->getNodeName()) << "'" << endl; - - if (!hw_id_set && type == nChip && pType == pMapping) - throw cms::Exception("TotemDAQMappingESSourceXML::ParseTreeRP") << "hw_id not given for element `" - << XMLString::transcode(n->getNodeName()) << "'" << endl; - - if (type == nRPPlane && id > 9) - throw cms::Exception("TotemDAQMappingESSourceXML::ParseTreeRP") << - "Plane IDs range from 0 to 9. id = " << id << " is invalid." << endl; - -#ifdef DEBUG - printf("\tID found: 0x%x\n", id); -#endif - - // store mapping data - if (pType == pMapping && (type == nChip || type == nTriggerVFAT)) - { - const TotemFramePosition &framepos = ChipFramePosition(n); - TotemVFATInfo vfatInfo; - vfatInfo.hwID = hw_id; - vfatInfo.symbolicID.subSystem = TotemSymbID::RP; - - if (type == nChip) - { - vfatInfo.symbolicID.symbolicID = parentID * 10 + id; - vfatInfo.type = TotemVFATInfo::data; - } - - if (type == nTriggerVFAT) - { - vfatInfo.symbolicID.symbolicID = parentID; - vfatInfo.type = TotemVFATInfo::CC; - } - - mapping->insert(framepos, vfatInfo); - - continue; - } - - // store mask data - if (pType == pMask && type == nChip) - { - TotemSymbID symbId; - symbId.subSystem = TotemSymbID::RP; - symbId.symbolicID = parentID * 10 + id; - - TotemVFATAnalysisMask am; - am.fullMask = fullMask; - GetChannels(n, am.maskedChannels); - - mask->insert(symbId, am); - - continue; - } - - // recursion (deeper in the tree) - ParseTreeRP(pType, n, type, parentID * 10 + id, mapping, mask); - } -} - -//---------------------------------------------------------------------------------------------------- - -void TotemDAQMappingESSourceXML::ParseTreeT2(ParseType pType, xercesc::DOMNode * parent, NodeType parentType, - unsigned int parentID, const boost::shared_ptr& data, - const boost::shared_ptr& mask) -{ - DOMNodeList *children = parent->getChildNodes(); - -#ifdef DEBUG - printf(">> ParseTreeT2(parent,parentType,parentID)=(%p, %i, %u)\n", parent, parentType, parentID); - printf("\tchildren: Numero children: %li\n", children->getLength()); -#endif - - for (unsigned int i = 0; i < children->getLength(); i++) - { - DOMNode *n = children->item(i); - - if (n->getNodeType() != DOMNode::ELEMENT_NODE) - continue; - - // get node type for RP or T2 - NodeType type = GetNodeType(n); - -#ifdef DEBUG - printf("\t\tchildren #%i: is a %s, (of type %i) \n", i, XMLString::transcode(n->getNodeName()), type); -#endif - - if ((type == nUnknown)) { -#ifdef DEBUG - printf("Found Unknown tag during T2 reading.. EXIT "); -#endif - continue; - } - - if ((T2Node(type)==false)&&(CommonNode(type)==false)) { -#ifdef DEBUG - printf("Found Non-T2 tag during T2 reading.. EXIT "); - printf("\t The tag is: %s \n", XMLString::transcode(n->getNodeName())); -#endif - continue; - } - - // get ID_t2 and position - - // id for T2 plane goes from 0..9; for chip is the 16 bit ID - // position_t2 was the S-link for chip and for the plane should be a number compatible with arm,ht,pl,pls or HS position - int ID_t2 = 0; - - unsigned int position_t2 = 0; - - unsigned int arm=0,ht=0,pl=0,pls=0; - - bool idSet_t2 = false; - //position_t2Set = false; - int attribcounter_t2planedescript=0; - unsigned int toaddForParentID=0; - - unsigned hw_id = 0; - bool hw_id_set = false; - - DOMNamedNodeMap* attr = n->getAttributes(); - - // Begin loop for save T2 element attriute - for (unsigned int j = 0; j < attr->getLength(); j++) { - DOMNode *a = attr->item(j); - if (!strcmp(XMLString::transcode(a->getNodeName()), "id")) { - sscanf(XMLString::transcode(a->getNodeValue()), "%i", &ID_t2); - idSet_t2 = true; - } - - if (!strcmp(XMLString::transcode(a->getNodeName()), "hw_id")) { - sscanf(XMLString::transcode(a->getNodeValue()), "%x", &hw_id); - hw_id_set = true; - } - - if (!strcmp(XMLString::transcode(a->getNodeName()), "position")) { - position_t2 = atoi(XMLString::transcode(a->getNodeValue())); - if (pType == pMask) - toaddForParentID = position_t2; -// position_t2Set = true; - } - - if (type == nArm) { - // arm is the top node and should be reset to 0. - if (!strcmp(XMLString::transcode(a->getNodeName()), "id")) { - parentID=0; - unsigned int id_arm = atoi(XMLString::transcode(a->getNodeValue())); - toaddForParentID=20*id_arm; - } - } - - if (type == nT2Half) { - if (!strcmp(XMLString::transcode(a->getNodeName()), "id")) { - unsigned int id_half = atoi(XMLString::transcode(a->getNodeValue())); - toaddForParentID=10*id_half; - } - } - - // This is needed in principle only for the old formats - if(type == nT2Det) { - if (!strcmp(XMLString::transcode(a->getNodeName()), "arm")) { - sscanf(XMLString::transcode(a->getNodeValue()), "%u", &arm); - attribcounter_t2planedescript++; - } - - if (!strcmp(XMLString::transcode(a->getNodeName()), "ht")) { - sscanf(XMLString::transcode(a->getNodeValue()), "%u", &ht); - attribcounter_t2planedescript++; - } - - if (!strcmp(XMLString::transcode(a->getNodeName()), "pl")) { - sscanf(XMLString::transcode(a->getNodeValue()), "%u", &pl); - attribcounter_t2planedescript++; - } - - if (!strcmp(XMLString::transcode(a->getNodeName()), "pls")) { - sscanf(XMLString::transcode(a->getNodeValue()), "%u", &pls); - attribcounter_t2planedescript++; - } - - // remember id in monitor goes from 0 -- 39 - if (!strcmp(XMLString::transcode(a->getNodeName()), "id")) { - // Id saved another time ... just to increment attribcounter - sscanf(XMLString::transcode(a->getNodeValue()), "%i", &ID_t2); - attribcounter_t2planedescript++; - } - - if (!strcmp(XMLString::transcode(a->getNodeName()), "position")) { - sscanf(XMLString::transcode(a->getNodeValue()), "%u", &position_t2); - attribcounter_t2planedescript++; - // Just another indication for further checking. This attribute was not compulsory in monitor. - attribcounter_t2planedescript=attribcounter_t2planedescript+20; - // 20 is just a "big number" - } - } - } - - // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // When a plane tag is found, calculate Parent-Id and allows different xml formats: - // Provide compatibility with old monitor formats. - - // Note: - // plane position and id foreseen in final ip5 mapping. - // plane position NOT foreseen in Monitor. - - if (pType == pMapping) { - if (type == nT2Det) { - // Calculate the parent-id from attributes or xml STRUCTURE -// position_t2Set = true; - if (attribcounter_t2planedescript>=(21)) { - // there is already in xml plane the "position" attribute + other attributes. It is assumed to utilize the parent info - -#ifdef DEBUG - printf("TotemDAQMappingESSourceXML: attribcounter_t2planedescript: %i \n",attribcounter_t2planedescript); -#endif - - if (attribcounter_t2planedescript>=25) { - edm::LogVerbatim("TotemDAQMappingESSourceXML") << "T2-Plane attribute utilezed for parentID: position+info from parent "; - //Plane Seems fully specified - //all T2 plane attribute read correctly. Check if it is consitent - unsigned int test_position_t2=arm*20+ht*10+pl*2+pls; - unsigned int testHS=pl*2+pls; - if(testHS!=position_t2) { - edm::LogPrint("TotemDAQMappingESSourceXML") <<"T2 Xml inconsistence in pl-pls attributes and position. Only 'position attribute' taken "; - } - - // For plane, ID_t2 should go from 0..39 position_t2 from 0..9 - ID_t2=parentID+position_t2; - cout << "attribcounter_t2planedescript>=(25), ID_t2: " << ID_t2 << endl; - toaddForParentID=position_t2; - if (ID_t2!=(int)test_position_t2) - edm::LogPrint("TotemDAQMappingESSourceXML") <<"T2 Xml inconsistence in plane attributes and xml parents structure. Plane attributes ignored"; - - } else { - // Case where arm-ht-pl-pls are NOT specified - edm::LogVerbatim("TotemDAQMappingESSourceXML")<<"T2 Plane have parentID: "<=(21), ID_t2: " << ID_t2 << endl; - toaddForParentID=position_t2; - idSet_t2=true; - } - } - } else { - // Construct plane position from other attributes cause "position" is not inserted; - // Ex- monitor: - - if (attribcounter_t2planedescript>=1) { - // Remember, Z attribute is not counted - - if(attribcounter_t2planedescript>=5) { - int test_position_t2=arm*20+ht*10+pl*2+pls; - - // case for xml from monitor - ID_t2=test_position_t2; - cout << "ID_t2=test_position_t2: " << ID_t2 << endl; - toaddForParentID=test_position_t2; - - if ((int)parentID!=ID_t2) { - edm::LogPrint("TotemDAQMappingESSourceXML") <<"T2 Inconsistence between plane 'id' and position from attributes. Id ignored"; - edm::LogPrint("TotemDAQMappingESSourceXML") <<" T2-Parent = "<getNodeName()) << "'" << endl; - edm::LogProblem ("TotemDAQMappingESSourceXML") <<"ID_t2 not given for element `"<getNodeName()) << "'"; - } - - if (type == nChip && !hw_id_set) - throw cms::Exception("TotemDAQMappingESSourceXML::ParseTree") << "hw_id not given for VFAT id `" << - ID_t2 << "'" << endl; - - if (type == nT2Det && position_t2 > 39) { - throw cms::Exception("TotemDAQMappingESSourceXML::ParseTree") << "Plane position_t2 range from 0 to 39. position_t2 = " << position_t2 << " is invalid." << endl; - edm::LogProblem ("TotemDAQMappingESSourceXML") <<"Plane position_t2 range from 0 to 39. position_t2 = "<getParentNode()->getNodeName())))) - symId = parentID * 100 + ID_t2; // same conv = symbplaneNumber*100 +iid used in DQM - else { - // It is a special VFAT and the special number is set directly in the XML file - symId = ID_t2; //17,18,19,20 -#ifdef DEBUG - printf("TotemDAQMappingESSourceXML Found T2 special Vfat ChId-SLink-Symb 0x%x - %i - %i \n", - ID_t2,position_t2,symId ); -#endif - } - - TotemFramePosition framepos = ChipFramePosition(n); - TotemVFATInfo vfatInfo; - vfatInfo.symbolicID.symbolicID = symId; - vfatInfo.hwID = hw_id; - vfatInfo.symbolicID.subSystem = TotemSymbID::T2; - vfatInfo.type = TotemVFATInfo::data; - data->insert(framepos, vfatInfo); - } - - // save mask data - if (pType == pMask) { - TotemVFATAnalysisMask vfatMask; - TotemSymbID symbId; - symbId.subSystem = TotemSymbID::T2; - symbId.symbolicID = 100*parentID+ID_t2; - - DOMNode *fullMaskNode = attr->getNamedItem(XMLString::transcode("full_mask")); - if (fullMaskNode && !GetNodeValue(fullMaskNode).compare("yes")) - vfatMask.fullMask = true; - else - GetChannels(n, vfatMask.maskedChannels); - - mask->insert(symbId, vfatMask); - //cout << "saved mask, ID = " << symbId.symbolicID << ", full mask: " << vfatMask.fullMask << endl; - } - } else { - // Look for the children of n (recursion) - // 3° argument=parentId is needed for calculate VFAT-id startintg from the parent plane - ParseTreeT2(pType, n, type, parentID+toaddForParentID, data, mask); - } - } // Go to the next children -} - -//---------------------------------------------------------------------------------------------------- - -void TotemDAQMappingESSourceXML::ParseTreeT1(ParseType pType, xercesc::DOMNode * parent, NodeType parentType, - unsigned int parentID, const boost::shared_ptr& mapping, - const boost::shared_ptr& mask, unsigned int T1Arm, unsigned int T1Plane, unsigned int T1CSC) -{ - const int ArmMask = 0x0200; - const int PlaneMask = 0x01c0; - const int CSCMask = 0x0038; - const int GenderMask = 0x0004; - const int VFnMask = 0x0003; - - int ArmMask_ = 0; - int PlaneMask_ = 0; - int CSCMask_ = 0; - int GenderMask_ = 0; - int VFnMask_ = 0; - - unsigned int T1ChannelType = 0; - - DOMNodeList *children = parent->getChildNodes(); - -#ifdef DEBUG - printf(">> ParseTreeT1(parent,parentType,parentID)=(%p, %i, %u)\n", parent, parentType, parentID); - printf("\tchildren: Numero children: %li\n", children->getLength()); -#endif - - for (unsigned int i = 0; i < children->getLength(); i++) { - DOMNode *n = children->item(i); - - if (n->getNodeType() != DOMNode::ELEMENT_NODE) - continue; - - // get node type for RP or T2 or T1 - NodeType type = GetNodeType(n); - -#ifdef DEBUG - printf("\t\tchildren #%i: is a %s, (of type %i) \n", i, XMLString::transcode(n->getNodeName()), type); -#endif - - if ((type == nUnknown)) { -#ifdef DEBUG - printf("Found Unknown tag during T1 reading.. EXIT "); -#endif - continue; - } - - if ((T1Node(type)==false)&&(CommonNode(type)==false)) { -#ifdef DEBUG - printf("Found Non-T1 tag during T1 reading.. EXIT "); - printf("\t The tag is: %s \n", XMLString::transcode(n->getNodeName())); -#endif - continue; - } - - // id for T2 plane goes from 0..9; for chip is the 16 bit ID - // for VFATs: (0 or 1 for anodes A0 and A1; 0, 1 or 2 for Cathodes C0,C1,C2) - unsigned int ID_t1 = 0; -#ifdef DEBUG - unsigned int VFPOS = 0; -#endif - unsigned int Gender =0; - - // hardware of an id - unsigned int hw_id = 0; - bool hw_id_set = false; - - bool idSet_t1 = false;//bool position_t2Set = false; - - DOMNamedNodeMap* attr = n->getAttributes(); - - bool fullMask = false; - - // Begin loop for save T1 element attriute ------------------------------------------------------------------ - for (unsigned int j = 0; j < attr->getLength(); j++) { - - DOMNode *a = attr->item(j); - if (!strcmp(XMLString::transcode(a->getNodeName()), "id")) { - sscanf(XMLString::transcode(a->getNodeValue()), "%u", &ID_t1); - idSet_t1 = true; - } - - if (type == nT1Arm) { - if (!strcmp(XMLString::transcode(a->getNodeName()), "id")) { - // arm is the top node and parent ID should be reset to 0. - parentID=0; - unsigned int id_arm = atoi(XMLString::transcode(a->getNodeValue())); - T1Arm = id_arm; - if (id_arm != 0 && id_arm != 1) { - throw cms::Exception("TotemDAQMappingESSourceXML::ParseTree") << "T1 id_arm neither 0 nor 1. Problem parsing XML file." << XMLString::transcode(n->getNodeName()) << endl; - edm::LogProblem ("TotemDAQMappingESSourceXML") <<"T1 id_arm neither 0 nor 1. Problem parsing XML file."<getNodeName()) ; - } - - id_arm = id_arm << 9; - ArmMask_ = ~ArmMask; - parentID &= ArmMask_; - parentID |= id_arm; - } - } - - if (type == nT1Plane) { - if (!strcmp(XMLString::transcode(a->getNodeName()), "id")) { - unsigned int id_plane = atoi(XMLString::transcode(a->getNodeValue())); - T1Plane = id_plane; - id_plane = id_plane << 6; - PlaneMask_ = ~PlaneMask; - parentID &= PlaneMask_; - parentID |= id_plane; - } - } - - if (type == nT1CSC) { - if (!strcmp(XMLString::transcode(a->getNodeName()), "id")) { - unsigned int id_csc = atoi(XMLString::transcode(a->getNodeValue())); - T1CSC = id_csc; - id_csc = id_csc << 3; - CSCMask_ = ~CSCMask; - parentID &= CSCMask_; - parentID |= id_csc; - } - } - - if (type == nT1ChannelType) { - if (!strcmp(XMLString::transcode(a->getNodeName()), "id")) { - T1ChannelType = atoi(XMLString::transcode(a->getNodeValue())); - } - if (!strcmp(XMLString::transcode(a->getNodeName()), "full_mask")) { - fullMask = (strcmp(XMLString::transcode(a->getNodeValue()), "no") != 0); - } - } - - if(type == nChip) { -#ifdef DEBUG - if (!strcmp(XMLString::transcode(a->getNodeName()), "position")){ - VFPOS = atoi(XMLString::transcode(a->getNodeValue())); - } -#endif - if (!strcmp(XMLString::transcode(a->getNodeName()), "polarity")) { - if (!strcmp(XMLString::transcode(a->getNodeValue()),"a")) { - Gender = 0; - } else - if (!strcmp(XMLString::transcode(a->getNodeValue()),"c")) { - Gender = 1; - } else { - throw cms::Exception("TotemDAQMappingESSourceXML::ParseTree") << "T1: Neither anode nor cathode vfat : " << XMLString::transcode(n->getNodeName()) << endl; - edm::LogProblem ("TotemDAQMappingESSourceXML") <<"T1: Neither anode nor cathode vfat : "<getNodeName()); - } - } - - if (!strcmp(XMLString::transcode(a->getNodeName()), "hw_id")) - sscanf(XMLString::transcode(a->getNodeValue()), "%x", &hw_id); - hw_id_set = true; - } - } - - // content control - // Note: each element has an id!! However if the element is a plane, it could be enough to use position 0..9 - - if (idSet_t1==false){ - throw cms::Exception("TotemDAQMappingESSourceXML::ParseTree") << "ID_t1 not given for element `" << XMLString::transcode(n->getNodeName()) << "'" << endl; - edm::LogProblem ("TotemDAQMappingESSourceXML") <<"ID_t1 not given for element `"<getNodeName()) << "'"; - } - - if (type == nChip && !hw_id_set) - throw cms::Exception("TotemDAQMappingESSourceXML::ParseTreeT1") << - "hw_id not set for T1 VFAT id " << ID_t1 << "." << endl; - - - - // save mask data - if (type == nT1ChannelType && pType == pMask) { - TotemSymbID symbId; - symbId.subSystem = TotemSymbID::T1; - symbId.symbolicID = T1ChannelType + 10 * T1CSC + 100 * T1Plane + 1000 * T1Arm; - //cout << "mask: " << T1Arm << " " << T1Plane << " " << T1CSC << " " <insert(symbId, am); - //cout << "saved mask, ID = " << symbId.symbolicID << ", full mask: " << am.fullMask << endl; - } - - // save data - if (type == nChip) { -#ifdef DEBUG - printf("T1 Vfat in detector (parentID): %x || Position %i \n", parentID, VFPOS); - printf("\t\t\tID_t1 = 0x%x\n", ID_t1); -#endif - - unsigned int symId=0; - - // Check if it is a special chip - if (!tagT1CSC.compare(XMLString::transcode((n->getParentNode()->getNodeName())))) { - symId = parentID; - Gender = Gender << 2; - GenderMask_ = ~GenderMask; - - symId &= GenderMask_; - symId |= Gender; - - VFnMask_ = ~VFnMask; - symId &= VFnMask_; - symId |= ID_t1; - } else { - // It is a special VFAT ... - throw cms::Exception("TotemDAQMappingESSourceXML::ParseTree") << "T1 has no special vfat `" << XMLString::transcode(n->getNodeName()) << "'" << endl; - edm::LogProblem ("TotemDAQMappingESSourceXML") <<"T1 has no special vfat `"<getNodeName()) << "'"; - } - - // Assign a contanaier for the register of that VFAT with ChipId (Hex) - TotemFramePosition framepos = ChipFramePosition(n); - TotemVFATInfo vfatInfo; - vfatInfo.symbolicID.symbolicID = symId; - vfatInfo.hwID = hw_id; - vfatInfo.symbolicID.subSystem = TotemSymbID::T1; - vfatInfo.type = TotemVFATInfo::data; - mapping->insert(framepos, vfatInfo); - } else { - // Look for the children of n (recursion) - // 3° argument=parentId is needed for calculate VFAT-id startintg from the parent plane - ParseTreeT1(pType, n, type, parentID, mapping, mask, T1Arm, T1Plane, T1CSC); - } - } // Go to the next children -} - -//---------------------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------------------- - -TotemFramePosition TotemDAQMappingESSourceXML::ChipFramePosition(xercesc::DOMNode *chipnode) -{ - TotemFramePosition fp; - unsigned char attributeFlag = 0; - - DOMNamedNodeMap* attr = chipnode->getAttributes(); - for (unsigned int j = 0; j < attr->getLength(); j++) - { - DOMNode *a = attr->item(j); - if (fp.setXMLAttribute(XMLString::transcode(a->getNodeName()), XMLString::transcode(a->getNodeValue()), attributeFlag) > 1) - { - throw cms::Exception("TotemDAQMappingESSourceXML") << - "Unrecognized tag `" << XMLString::transcode(a->getNodeName()) << - "' or incompatible value `" << XMLString::transcode(a->getNodeValue()) << - "'." << endl; - } - } - - if (!fp.checkXMLAttributeFlag(attributeFlag)) - { - throw cms::Exception("TotemDAQMappingESSourceXML") << - "Wrong/incomplete DAQ channel specification (attributeFlag = " << (unsigned int) attributeFlag << ")." << endl; - } - - return fp; -} - -//---------------------------------------------------------------------------------------------------- - -TotemDAQMappingESSourceXML::NodeType TotemDAQMappingESSourceXML::GetNodeType(xercesc::DOMNode *n) -{ - // common node types - if (Test(n, tagArm)) return nArm; - if (Test(n, tagChip1)) return nChip; - if (Test(n, tagChip2)) return nChip; - if (Test(n, tagTriggerVFAT1)) return nTriggerVFAT; - - // RP node types - if (Test(n, tagRPStation)) return nRPStation; - if (Test(n, tagRPPot)) return nRPPot; - if (Test(n, tagRPPlane)) return nRPPlane; - - // T2 node types - if (Test(n, tagT2)) return nT2; - if (Test(n, tagT2detector)) return nT2Det; - if (Test(n, tagT2Half)) return nT2Half; - - // T1 node types - if (Test(n, tagT1)) return nT1; - if (Test(n, tagT1Arm)) return nT1Arm; - if (Test(n, tagT1Plane)) return nT1Plane; - if (Test(n, tagT1CSC)) return nT1CSC; - if (Test(n, tagT1ChannelType)) return nT1ChannelType; - if (Test(n, tagChannel)) return nChannel; - - throw cms::Exception("TotemDAQMappingESSourceXML::GetNodeType") << "Unknown tag `" - << XMLString::transcode(n->getNodeName()) << "'.\n"; -} - -//---------------------------------------------------------------------------------------------------- - -void TotemDAQMappingESSourceXML::GetChannels(xercesc::DOMNode *n, set &channels) -{ - DOMNodeList *children = n->getChildNodes(); - for (unsigned int i = 0; i < children->getLength(); i++) - { - DOMNode *n = children->item(i); - if (n->getNodeType() != DOMNode::ELEMENT_NODE || !Test(n, "channel")) - continue; - - DOMNamedNodeMap* attr = n->getAttributes(); - bool idSet = false; - for (unsigned int j = 0; j < attr->getLength(); j++) - { - DOMNode *a = attr->item(j); - - if (!strcmp(XMLString::transcode(a->getNodeName()), "id")) - { - unsigned int id = 0; - sscanf(XMLString::transcode(a->getNodeValue()), "%u", &id); - channels.insert(id); - idSet = true; - break; - } - } - - if (!idSet) - { - throw cms::Exception("TotemDAQMappingESSourceXML::GetChannels") << - "Channel tags must have an `id' attribute."; - } - } -} - -//---------------------------------------------------------------------------------------------------- - -DEFINE_FWK_EVENTSETUP_SOURCE(TotemDAQMappingESSourceXML); diff --git a/CondFormats/TotemReadoutObjects/python/TotemDAQMappingESSourceXML_cfi.py b/CondFormats/TotemReadoutObjects/python/TotemDAQMappingESSourceXML_cfi.py deleted file mode 100644 index 72eb628b317..00000000000 --- a/CondFormats/TotemReadoutObjects/python/TotemDAQMappingESSourceXML_cfi.py +++ /dev/null @@ -1,8 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -TotemDAQMappingESSourceXML = cms.ESSource("TotemDAQMappingESSourceXML", - verbosity = cms.untracked.uint32(0), - - mappingFileNames = cms.untracked.vstring(), - maskFileNames = cms.untracked.vstring() -) diff --git a/CondFormats/TotemReadoutObjects/src/TotemAnalysisMask.cc b/CondFormats/TotemReadoutObjects/src/TotemAnalysisMask.cc deleted file mode 100644 index cf8eb46f1d8..00000000000 --- a/CondFormats/TotemReadoutObjects/src/TotemAnalysisMask.cc +++ /dev/null @@ -1,23 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Maciej Wróbel (wroblisko@gmail.com) -* Jan Kašpar (jan.kaspar@cern.ch) -* -****************************************************************************/ - -#include "FWCore/Utilities/interface/typelookup.h" - -#include "CondFormats/TotemReadoutObjects/interface/TotemAnalysisMask.h" - -//---------------------------------------------------------------------------------------------------- - -void TotemAnalysisMask::insert(const TotemSymbID &sid, const TotemVFATAnalysisMask &vam) -{ - analysisMask[sid] = vam; -} - -//---------------------------------------------------------------------------------------------------- - -TYPELOOKUP_DATA_REG(TotemAnalysisMask); diff --git a/CondFormats/TotemReadoutObjects/src/TotemDAQMapping.cc b/CondFormats/TotemReadoutObjects/src/TotemDAQMapping.cc deleted file mode 100644 index 729fff9dbc3..00000000000 --- a/CondFormats/TotemReadoutObjects/src/TotemDAQMapping.cc +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Maciej Wróbel (wroblisko@gmail.com) -* -****************************************************************************/ - -#include "FWCore/Utilities/interface/typelookup.h" - -#include "CondFormats/TotemReadoutObjects/interface/TotemDAQMapping.h" - -using namespace std; - -//---------------------------------------------------------------------------------------------------- - -std::ostream& operator << (std::ostream& s, const TotemVFATInfo &vi) -{ - if (vi.type == TotemVFATInfo::data) - s << "type=data, "; - else - s << "type= CC, "; - - s << vi.symbolicID << ", hw id=0x" << hex << vi.hwID << dec; - - return s; -} - -//---------------------------------------------------------------------------------------------------- - -void TotemDAQMapping::insert(const TotemFramePosition &fp, const TotemVFATInfo &vi) -{ - auto it = VFATMapping.find(fp); - if (it != VFATMapping.end()) - { - cerr << "WARNING in DAQMapping::Insert > Overwriting entry at " << fp << ". Previous: " << endl - << " " << VFATMapping[fp] << "," << endl << " new: " << endl << " " << vi << ". " << endl; - } - - VFATMapping[fp] = vi; -} - -//---------------------------------------------------------------------------------------------------- - -TYPELOOKUP_DATA_REG(TotemDAQMapping); diff --git a/CondFormats/TotemReadoutObjects/src/TotemFramePosition.cc b/CondFormats/TotemReadoutObjects/src/TotemFramePosition.cc deleted file mode 100644 index bfed0d49740..00000000000 --- a/CondFormats/TotemReadoutObjects/src/TotemFramePosition.cc +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -* -* This is a part of the TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#include "CondFormats/TotemReadoutObjects/interface/TotemFramePosition.h" - -#include -#include - -using namespace std; - -//---------------------------------------------------------------------------------------------------- - -std::ostream& operator << (std::ostream& s, const TotemFramePosition &fp) -{ - return s - << fp.getFEDId() << ":" - << fp.getGOHId() << ":" - << fp.getIdxInFiber(); -} - -//---------------------------------------------------------------------------------------------------- - -void TotemFramePosition::printXML() -{ - cout << "\" FEDId=\"" << getFEDId() - << "\" GOHId=\"" << getGOHId() - << "\" IdxInFiber=\"" << getIdxInFiber() - << "\""; -} - -//---------------------------------------------------------------------------------------------------- - -unsigned char TotemFramePosition::setXMLAttribute(const std::string &attribute, const std::string &value, - unsigned char &flag) -{ - unsigned int v = atoi(value.c_str()); - - if (attribute == "FEDId") - { - setFEDId(v); - flag |= 0x1C; // SubSystem + TOTFED + OptoRx - return 0; - } - - if (attribute == "SubSystemId") - { - setSubSystemId(v); - flag |= 0x10; - return 0; - } - - if (attribute == "TOTFEDId") - { - setTOTFEDId(v); - flag |= 0x8; - return 0; - } - - if (attribute == "OptoRxId") - { - setOptoRxId(v); - flag |= 0x4; - return 0; - } - - if (attribute == "GOHId") - { - setGOHId(v); - flag |= 0x2; - return 0; - } - - if (attribute == "IdxInFiber") - { - setIdxInFiber(v); - flag |= 0x1; - return 0; - } - - return 1; -} diff --git a/CondFormats/TotemReadoutObjects/src/TotemSymbId.cc b/CondFormats/TotemReadoutObjects/src/TotemSymbId.cc deleted file mode 100644 index eb4b54bea5a..00000000000 --- a/CondFormats/TotemReadoutObjects/src/TotemSymbId.cc +++ /dev/null @@ -1,29 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@cern.ch) -* -****************************************************************************/ - -#include "CondFormats/TotemReadoutObjects/interface/TotemSymbId.h" - -std::ostream& operator << (std::ostream& s, const TotemSymbID &sid) -{ - switch (sid.subSystem) { - case TotemSymbID::RP: - s << "sub-system=RP, "; - break; - case TotemSymbID::T1: - s << "sub-system=T1, "; - break; - case TotemSymbID::T2: - s << "sub-system=T2, "; - break; - } - - s << "symb. id=" << sid.symbolicID; - - return s; -} - diff --git a/CondFormats/TotemReadoutObjects/test/test_cfg.py b/CondFormats/TotemReadoutObjects/test/test_cfg.py deleted file mode 100644 index 43546147964..00000000000 --- a/CondFormats/TotemReadoutObjects/test/test_cfg.py +++ /dev/null @@ -1,32 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -process = cms.Process('test') - -# minimum of logs -process.MessageLogger = cms.Service("MessageLogger", - statistics = cms.untracked.vstring(), - destinations = cms.untracked.vstring('cerr'), - cerr = cms.untracked.PSet( - threshold = cms.untracked.string('WARNING') - ) -) - -# raw data source -process.source = cms.Source("EmptySource", -) - -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(1) -) - -# load a mapping -process.load("CondFormats.TotemReadoutObjects.TotemDAQMappingESSourceXML_cfi") -process.TotemDAQMappingESSourceXML.mappingFileNames.append("CondFormats/TotemReadoutObjects/xml/ctpps_210_mapping.xml") - -# print the mapping -process.printTotemDAQMapping = cms.EDAnalyzer("PrintTotemDAQMapping" -) - -process.path = cms.Path( - process.printTotemDAQMapping -) diff --git a/CondFormats/TotemReadoutObjects/xml/ctpps_210_mapping.xml b/CondFormats/TotemReadoutObjects/xml/ctpps_210_mapping.xml deleted file mode 100644 index 88bf4f3c2c1..00000000000 --- a/CondFormats/TotemReadoutObjects/xml/ctpps_210_mapping.xml +++ /dev/null @@ -1,789 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/CondFormats/TotemReadoutObjects/xml/totem_rp_210_mapping.xml b/CondFormats/TotemReadoutObjects/xml/totem_rp_2016_210_mapping.xml similarity index 96% rename from CondFormats/TotemReadoutObjects/xml/totem_rp_210_mapping.xml rename to CondFormats/TotemReadoutObjects/xml/totem_rp_2016_210_mapping.xml index 9cb8f54e377..ebe80863a0e 100644 --- a/CondFormats/TotemReadoutObjects/xml/totem_rp_210_mapping.xml +++ b/CondFormats/TotemReadoutObjects/xml/totem_rp_2016_210_mapping.xml @@ -1,789 +1,790 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CondFormats/TotemReadoutObjects/xml/totem_rp_210far_220_mapping.xml b/CondFormats/TotemReadoutObjects/xml/totem_rp_210far_220_mapping.xml deleted file mode 100644 index 68b13e85f68..00000000000 --- a/CondFormats/TotemReadoutObjects/xml/totem_rp_210far_220_mapping.xml +++ /dev/null @@ -1,1576 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/CondFormats/TotemReadoutObjects/xml/totem_rp_220_mapping.xml b/CondFormats/TotemReadoutObjects/xml/totem_rp_220_mapping.xml deleted file mode 100644 index e1ecf47c670..00000000000 --- a/CondFormats/TotemReadoutObjects/xml/totem_rp_220_mapping.xml +++ /dev/null @@ -1,790 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/CondFormats/TotemReadoutObjects/xml/totem_rp_mask_example.xml b/CondFormats/TotemReadoutObjects/xml/totem_rp_mask_example.xml deleted file mode 100644 index 9f9b08fb541..00000000000 --- a/CondFormats/TotemReadoutObjects/xml/totem_rp_mask_example.xml +++ /dev/null @@ -1,533 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/DQM/CTPPS/.gitignore b/DQM/CTPPS/.gitignore deleted file mode 100644 index 57da11fe8f2..00000000000 --- a/DQM/CTPPS/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.root -*.swp diff --git a/DQM/CTPPS/BuildFile.xml b/DQM/CTPPS/BuildFile.xml deleted file mode 100644 index 2280831045c..00000000000 --- a/DQM/CTPPS/BuildFile.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/DQM/CTPPS/plugins/BuildFile.xml b/DQM/CTPPS/plugins/BuildFile.xml deleted file mode 100644 index b5e7d0184d6..00000000000 --- a/DQM/CTPPS/plugins/BuildFile.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/DQM/CTPPS/plugins/TotemDAQTriggerDQMSource.cc b/DQM/CTPPS/plugins/TotemDAQTriggerDQMSource.cc deleted file mode 100644 index f50ea5d02e1..00000000000 --- a/DQM/CTPPS/plugins/TotemDAQTriggerDQMSource.cc +++ /dev/null @@ -1,207 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@gmail.com) -* Rafał Leszko (rafal.leszko@gmail.com) -* -****************************************************************************/ - -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Utilities/interface/InputTag.h" - -#include "DQMServices/Core/interface/DQMEDAnalyzer.h" -#include "DQMServices/Core/interface/DQMStore.h" -#include "DQMServices/Core/interface/MonitorElement.h" - -#include "DataFormats/TotemDigi/interface/TotemFEDInfo.h" -#include "DataFormats/TotemDigi/interface/TotemTriggerCounters.h" - -#include - -//---------------------------------------------------------------------------------------------------- - -class TotemDAQTriggerDQMSource: public DQMEDAnalyzer -{ - public: - TotemDAQTriggerDQMSource(const edm::ParameterSet& ps); - virtual ~TotemDAQTriggerDQMSource(); - - protected: - void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override; - void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override; - void analyze(edm::Event const& e, edm::EventSetup const& eSetup); - void beginLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& eSetup); - void endLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& eSetup); - void endRun(edm::Run const& run, edm::EventSetup const& eSetup); - - private: - unsigned int verbosity; - - edm::EDGetTokenT> tokenFEDInfo; - edm::EDGetTokenT tokenTriggerCounters; - - MonitorElement *daq_bx_diff; - MonitorElement *daq_event_bx_diff; - MonitorElement *daq_event_bx_diff_vs_fed; - MonitorElement *daq_trigger_bx_diff; - - MonitorElement *trigger_type; - MonitorElement *trigger_event_num; - MonitorElement *trigger_bunch_num; - MonitorElement *trigger_src_id; - MonitorElement *trigger_orbit_num; - MonitorElement *trigger_revision_num; - MonitorElement *trigger_run_num; - MonitorElement *trigger_trigger_num; - MonitorElement *trigger_inhibited_triggers_num; - MonitorElement *trigger_input_status_bits; -}; - -//---------------------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------------------- - -using namespace std; -using namespace edm; - -//---------------------------------------------------------------------------------------------------- - -TotemDAQTriggerDQMSource::TotemDAQTriggerDQMSource(const edm::ParameterSet& ps) : - verbosity(ps.getUntrackedParameter("verbosity", 0)) -{ - tokenFEDInfo = consumes>(ps.getParameter("tagFEDInfo")); - tokenTriggerCounters = consumes(ps.getParameter("tagTriggerCounters")); -} - -//---------------------------------------------------------------------------------------------------- - -TotemDAQTriggerDQMSource::~TotemDAQTriggerDQMSource() -{ -} - -//---------------------------------------------------------------------------------------------------- - -void TotemDAQTriggerDQMSource::dqmBeginRun(edm::Run const &, edm::EventSetup const &) -{ -} - -//---------------------------------------------------------------------------------------------------- - -void TotemDAQTriggerDQMSource::bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &, edm::EventSetup const &) -{ - ibooker.cd(); - - ibooker.setCurrentFolder("CTPPS/DAQ/"); - - daq_bx_diff = ibooker.book1D("bx_diff", ";OptoRx_{i}.BX - OptoRx_{j}.BX", 100, 0., 0.); - daq_event_bx_diff = ibooker.book1D("daq_event_bx_diff", ";OptoRx_{i}.BX - Event.BX", 100, 0., 0.); - daq_event_bx_diff_vs_fed = ibooker.book2D("daq_event_bx_diff_vs_fed", ";OptoRx.ID;OptoRx.BX - Event.BX", 10, 0., 0., 10., 0., 0.); - - daq_trigger_bx_diff = ibooker.book1D("trigger_bx_diff", ";OptoRx_{i}.BX - LoneG.BX", 100, 0., 0.); - - ibooker.setCurrentFolder("CTPPS/Trigger/"); - - trigger_type = ibooker.book1D("type", ";type", 100, 0., 0.); - trigger_event_num = ibooker.book1D("event_num", ";event_num", 100, 0., 0.); - trigger_bunch_num = ibooker.book1D("bunch_num", ";bunch_num", 100, 0., 0.); - trigger_src_id = ibooker.book1D("src_id", ";src_id", 100, 0., 0.); - trigger_orbit_num = ibooker.book1D("orbit_num", ";orbit_num", 100, 0., 0.); - trigger_revision_num = ibooker.book1D("revision_num", ";revision_num", 100, 0., 0.); - trigger_run_num = ibooker.book1D("run_num", ";run_num", 100, 0., 0.); - trigger_trigger_num = ibooker.book1D("trigger_num", ";trigger_num", 100, 0., 0.); - trigger_inhibited_triggers_num = ibooker.book1D("inhibited_triggers_num", ";inhibited_triggers_num", 100, 0., 0.); - trigger_input_status_bits = ibooker.book1D("input_status_bits", ";input_status_bits", 100, 0., 0.); -} - -//---------------------------------------------------------------------------------------------------- - -void TotemDAQTriggerDQMSource::beginLuminosityBlock(edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& context) -{ -} - -//---------------------------------------------------------------------------------------------------- - -void TotemDAQTriggerDQMSource::analyze(edm::Event const& event, edm::EventSetup const& eventSetup) -{ - // get input - Handle> fedInfo; - event.getByToken(tokenFEDInfo, fedInfo); - - Handle triggerCounters; - event.getByToken(tokenTriggerCounters, triggerCounters); - - // check validity - bool daqValid = fedInfo.isValid(); - bool triggerValid = triggerCounters.isValid(); - - if (!daqValid || !triggerValid) - { - if (verbosity) - { - LogPrint("TotemDAQTriggerDQMSource") << - "WARNING in TotemDAQTriggerDQMSource::analyze > some of the inputs are not valid.\n" - << " fedInfo.isValid = " << fedInfo.isValid() << "\n" - << " triggerCounters.isValid = " << triggerCounters.isValid(); - } - } - - // DAQ plots - if (daqValid) - { - for (auto &it1 : *fedInfo) - { - daq_event_bx_diff->Fill(it1.getBX() - event.bunchCrossing()); - daq_event_bx_diff_vs_fed->Fill(it1.getFEDId(), it1.getBX() - event.bunchCrossing()); - - for (auto &it2 : *fedInfo) - { - if (it2.getFEDId() <= it1.getFEDId()) - continue; - - daq_bx_diff->Fill(it2.getBX() - it1.getBX()); - } - } - } - - // trigger plots - if (triggerValid) - { - trigger_type->Fill(triggerCounters->type); - trigger_event_num->Fill(triggerCounters->event_num); - trigger_bunch_num->Fill(triggerCounters->bunch_num); - trigger_src_id->Fill(triggerCounters->src_id); - trigger_orbit_num->Fill(triggerCounters->orbit_num); - trigger_revision_num->Fill(triggerCounters->revision_num); - trigger_run_num->Fill(triggerCounters->run_num); - trigger_trigger_num->Fill(triggerCounters->trigger_num); - trigger_inhibited_triggers_num->Fill(triggerCounters->inhibited_triggers_num); - trigger_input_status_bits->Fill(triggerCounters->input_status_bits); - } - - // combined DAQ + trigger plots - if (daqValid && triggerValid) - { - for (auto &it : *fedInfo) - daq_trigger_bx_diff->Fill(it.getBX() - triggerCounters->orbit_num); - } -} - -//---------------------------------------------------------------------------------------------------- - -void TotemDAQTriggerDQMSource::endLuminosityBlock(edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& eSetup) -{ -} - -//---------------------------------------------------------------------------------------------------- - -void TotemDAQTriggerDQMSource::endRun(edm::Run const& run, edm::EventSetup const& eSetup) -{ -} - -//---------------------------------------------------------------------------------------------------- - -DEFINE_FWK_MODULE(TotemDAQTriggerDQMSource); diff --git a/DQM/CTPPS/plugins/TotemRPDQMHarvester.cc b/DQM/CTPPS/plugins/TotemRPDQMHarvester.cc deleted file mode 100644 index 0dd1dc0578c..00000000000 --- a/DQM/CTPPS/plugins/TotemRPDQMHarvester.cc +++ /dev/null @@ -1,210 +0,0 @@ -/**************************************************************************** -* -* This is a part of TotemDQM and TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "DQMServices/Core/interface/DQMEDHarvester.h" -#include "DQMServices/Core/interface/DQMStore.h" -#include "DQMServices/Core/interface/MonitorElement.h" - -#include "DataFormats/TotemRPDetId/interface/TotemRPDetId.h" - -//---------------------------------------------------------------------------------------------------- - -class TotemRPDQMHarvester: public DQMEDHarvester -{ - public: - TotemRPDQMHarvester(const edm::ParameterSet& ps); - virtual ~TotemRPDQMHarvester(); - - protected: - void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override {} - - void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, const edm::LuminosityBlock &, const edm::EventSetup &) override; - - private: - void MakeHitNumberRatios(unsigned int id, DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter); - - void MakePlaneEfficiencyHistograms(unsigned int id, DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter, bool &rpPlotInitialized); -}; - -//---------------------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------------------- - -using namespace std; -using namespace edm; - -//---------------------------------------------------------------------------------------------------- - -TotemRPDQMHarvester::TotemRPDQMHarvester(const edm::ParameterSet& ps) -{ -} - -//---------------------------------------------------------------------------------------------------- - -TotemRPDQMHarvester::~TotemRPDQMHarvester() -{ -} - -//---------------------------------------------------------------------------------------------------- - -void TotemRPDQMHarvester::MakeHitNumberRatios(unsigned int id, DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) -{ - // get source histogram - string path = TotemRPDetId::rpName(id, TotemRPDetId::nPath); - path.replace(0, 2, "CTPPS/TrackingStrip"); - - MonitorElement *activity = igetter.get(path + "/activity in planes (2D)"); - - if (!activity) - return; - - // book new histogram, if not yet done - const string hit_ratio_name = "hit ratio in hot spot"; - MonitorElement *hit_ratio = igetter.get(path + "/" + hit_ratio_name); - - if (hit_ratio == NULL) - { - ibooker.setCurrentFolder(path); - string title = TotemRPDetId::rpName(id, TotemRPDetId::nFull); - hit_ratio = ibooker.book1D(hit_ratio_name, title+";plane;N_hits(320getTH1F()->Reset(); - } - - // calculate ratios - TAxis *y_axis = activity->getTH2F()->GetYaxis(); - for (int bix = 1; bix <= activity->getNbinsX(); ++bix) - { - double S_full = 0., S_sel = 0.; - for (int biy = 1; biy <= activity->getNbinsY(); ++biy) - { - double c = activity->getBinContent(bix, biy); - double s = y_axis->GetBinCenter(biy); - - S_full += c; - - if (s > 320. && s < 440.) - S_sel += c; - } - - double r = (S_full > 0.) ? S_sel / S_full : 0.; - - hit_ratio->setBinContent(bix, r); - } -} - -//---------------------------------------------------------------------------------------------------- - -void TotemRPDQMHarvester::MakePlaneEfficiencyHistograms(unsigned int id, DQMStore::IBooker& ibooker, - DQMStore::IGetter& igetter, bool &rpPlotInitialized) -{ - // get source histograms - string path = TotemRPDetId::planeName(id, TotemRPDetId::nPath); - path.replace(0, 2, "CTPPS/TrackingStrip"); - - MonitorElement *efficiency_num = igetter.get(path + "/efficiency num"); - MonitorElement *efficiency_den = igetter.get(path + "/efficiency den"); - - if (!efficiency_num || !efficiency_den) - return; - - // book new plane histogram, if not yet done - const string efficiency_name = "efficiency"; - MonitorElement *efficiency = igetter.get(path + "/" + efficiency_name); - - if (efficiency == NULL) - { - string title = TotemRPDetId::planeName(id, TotemRPDetId::nFull); - TAxis *axis = efficiency_den->getTH1()->GetXaxis(); - ibooker.setCurrentFolder(path); - efficiency = ibooker.book1D(efficiency_name, title+";track position (mm)", axis->GetNbins(), axis->GetXmin(), axis->GetXmax()); - } else { - efficiency->getTH1F()->Reset(); - } - - // book new RP histogram, if not yet done - path = TotemRPDetId::rpName(id/10, TotemRPDetId::nPath); - path.replace(0, 2, "CTPPS/TrackingStrip"); - const string rp_efficiency_name = "plane efficiency"; - MonitorElement *rp_efficiency = igetter.get(path + "/" + rp_efficiency_name); - - if (rp_efficiency == NULL) - { - string title = TotemRPDetId::rpName(id/10, TotemRPDetId::nFull); - TAxis *axis = efficiency_den->getTH1()->GetXaxis(); - ibooker.setCurrentFolder(path); - rp_efficiency = ibooker.book2D(rp_efficiency_name, title+";plane;track position (mm)", - 10, -0.5, 9.5, axis->GetNbins(), axis->GetXmin(), axis->GetXmax()); - rpPlotInitialized = true; - } else { - if (!rpPlotInitialized) - rp_efficiency->getTH2F()->Reset(); - rpPlotInitialized = true; - } - - // calculate and fill efficiencies - for (signed int bi = 1; bi <= efficiency->getNbinsX(); bi++) - { - double num = efficiency_num->getBinContent(bi); - double den = efficiency_den->getBinContent(bi); - - if (den > 0) - { - double p = num / den; - double p_unc = sqrt(p * (1. - p) / den); - efficiency->setBinContent(bi, p); - efficiency->setBinError(bi, p_unc); - - int pl_bi = (id%10) + 1; - rp_efficiency->setBinContent(pl_bi, bi, p); - } else { - efficiency->setBinContent(bi, 0.); - } - } -} - -//---------------------------------------------------------------------------------------------------- - -void TotemRPDQMHarvester::dqmEndLuminosityBlock(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, - const edm::LuminosityBlock &, const edm::EventSetup &) -{ - // loop over arms - for (unsigned int arm = 0; arm < 2; arm++) - { - // loop over stations - for (unsigned int st = 0; st < 3; st += 2) - { - unsigned int stId = 10*arm + st; - - // loop over RPs - for (unsigned int rp = 0; rp < 6; ++rp) - { - unsigned int rpId = 10*stId + rp; - - MakeHitNumberRatios(rpId, ibooker, igetter); - - bool rpPlotInitialized = false; - - // loop over planes - for (unsigned int pl = 0; pl < 10; ++pl) - { - unsigned int plId = 10*rpId + pl; - - MakePlaneEfficiencyHistograms(plId, ibooker, igetter, rpPlotInitialized); - } - } - } - } -} - -//---------------------------------------------------------------------------------------------------- - -DEFINE_FWK_MODULE(TotemRPDQMHarvester); diff --git a/DQM/CTPPS/plugins/TotemRPDQMSource.cc b/DQM/CTPPS/plugins/TotemRPDQMSource.cc deleted file mode 100644 index 8937e0aa736..00000000000 --- a/DQM/CTPPS/plugins/TotemRPDQMSource.cc +++ /dev/null @@ -1,973 +0,0 @@ -/**************************************************************************** -* -* This is a part of TotemDQM and TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@gmail.com) -* Rafał Leszko (rafal.leszko@gmail.com) -* -****************************************************************************/ - -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Utilities/interface/InputTag.h" - -#include "DQMServices/Core/interface/DQMEDAnalyzer.h" -#include "DQMServices/Core/interface/DQMStore.h" -#include "DQMServices/Core/interface/MonitorElement.h" - -#include "DataFormats/Common/interface/DetSetVector.h" -#include "DataFormats/TotemRPDetId/interface/TotemRPDetId.h" -#include "DataFormats/TotemDigi/interface/TotemRPDigi.h" -#include "DataFormats/TotemDigi/interface/TotemVFATStatus.h" -#include "DataFormats/CTPPSReco/interface/TotemRPCluster.h" -#include "DataFormats/CTPPSReco/interface/TotemRPRecHit.h" -#include "DataFormats/CTPPSReco/interface/TotemRPUVPattern.h" -#include "DataFormats/CTPPSReco/interface/TotemRPLocalTrack.h" -//#include "RecoTotemRP/RPRecoDataFormats/interface/RPMulFittedTrackCollection.h" - -#include "Geometry/Records/interface/VeryForwardRealGeometryRecord.h" -#include "Geometry/VeryForwardGeometryBuilder/interface/TotemRPGeometry.h" -#include "Geometry/VeryForwardRPTopology/interface/RPTopology.h" - -#include - -//---------------------------------------------------------------------------------------------------- - -class TotemRPDQMSource: public DQMEDAnalyzer -{ - public: - TotemRPDQMSource(const edm::ParameterSet& ps); - virtual ~TotemRPDQMSource(); - - protected: - void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override; - void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override; - void analyze(edm::Event const& e, edm::EventSetup const& eSetup); - void beginLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& eSetup); - void endLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& eSetup); - void endRun(edm::Run const& run, edm::EventSetup const& eSetup); - - private: - unsigned int verbosity; - - edm::EDGetTokenT< edm::DetSetVector > tokenStatus; - edm::EDGetTokenT< edm::DetSetVector > tokenDigi; - edm::EDGetTokenT< edm::DetSetVector > tokenCluster; - edm::EDGetTokenT< edm::DetSetVector > tokenRecHit; - edm::EDGetTokenT< edm::DetSetVector > tokenUVPattern; - edm::EDGetTokenT< edm::DetSetVector > tokenLocalTrack; - //edm::EDGetTokenT< RPMulFittedTrackCollection > tokenMultiTrackColl; - - /// plots related to the whole system - struct GlobalPlots - { - MonitorElement *events_per_bx = NULL, *events_per_bx_short = NULL; - MonitorElement *h_trackCorr_hor = NULL; - - void Init(DQMStore::IBooker &ibooker); - }; - - GlobalPlots globalPlots; - - /// plots related to one (anti)diagonal - struct DiagonalPlots - { - int id; - - MonitorElement *h_lrc_x_d=NULL, *h_lrc_x_n=NULL, *h_lrc_x_f=NULL; - MonitorElement *h_lrc_y_d=NULL, *h_lrc_y_n=NULL, *h_lrc_y_f=NULL; - - DiagonalPlots() {} - - DiagonalPlots(DQMStore::IBooker &ibooker, int _id); - }; - - std::map diagonalPlots; - - /// plots related to one arm - struct ArmPlots - { - int id; - - MonitorElement *h_numRPWithTrack_top=NULL, *h_numRPWithTrack_hor=NULL, *h_numRPWithTrack_bot=NULL; - MonitorElement *h_trackCorr=NULL, *h_trackCorr_overlap=NULL; - - ArmPlots(){} - - ArmPlots(DQMStore::IBooker &ibooker, int _id); - }; - - std::map armPlots; - - /// plots related to one station - struct StationPlots - { - StationPlots() {} - StationPlots(DQMStore::IBooker &ibooker, int _id); - }; - - std::map stationPlots; - - /// plots related to one RP - struct PotPlots - { - MonitorElement *vfat_problem=NULL, *vfat_missing=NULL, *vfat_ec_bc_error=NULL, *vfat_corruption=NULL; - - MonitorElement *activity=NULL, *activity_u=NULL, *activity_v=NULL; - MonitorElement *activity_per_bx=NULL, *activity_per_bx_short=NULL; - MonitorElement *hit_plane_hist=NULL; - MonitorElement *patterns_u=NULL, *patterns_v=NULL; - MonitorElement *h_planes_fit_u=NULL, *h_planes_fit_v=NULL; - MonitorElement *event_category=NULL; - MonitorElement *trackHitsCumulativeHist=NULL; - MonitorElement *track_u_profile=NULL, *track_v_profile=NULL; - - PotPlots() {} - PotPlots(DQMStore::IBooker &ibooker, unsigned int id); - }; - - std::map potPlots; - - /// plots related to one RP plane - struct PlanePlots - { - MonitorElement *digi_profile_cumulative = NULL; - MonitorElement *cluster_profile_cumulative = NULL; - MonitorElement *hit_multiplicity = NULL; - MonitorElement *cluster_size = NULL; - MonitorElement *efficiency_num = NULL, *efficiency_den = NULL; - - PlanePlots() {} - PlanePlots(DQMStore::IBooker &ibooker, unsigned int id); - }; - - std::map planePlots; -}; - -//---------------------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------------------- - -using namespace std; -using namespace edm; - -//---------------------------------------------------------------------------------------------------- - -void TotemRPDQMSource::GlobalPlots::Init(DQMStore::IBooker &ibooker) -{ - events_per_bx = ibooker.book1D("events per BX", "rp;Event.BX", 4002, -1.5, 4000. + 0.5); - events_per_bx_short = ibooker.book1D("events per BX (short)", "rp;Event.BX", 102, -1.5, 100. + 0.5); - - h_trackCorr_hor = ibooker.book2D("track correlation RP-210-hor", "rp, 210, hor", 4, -0.5, 3.5, 4, -0.5, 3.5); - TH2F *hist = h_trackCorr_hor->getTH2F(); - TAxis *xa = hist->GetXaxis(), *ya = hist->GetYaxis(); - xa->SetBinLabel(1, "45, 210, near"); ya->SetBinLabel(1, "45, 210, near"); - xa->SetBinLabel(2, "45, 210, far"); ya->SetBinLabel(2, "45, 210, far"); - xa->SetBinLabel(3, "56, 210, near"); ya->SetBinLabel(3, "56, 210, near"); - xa->SetBinLabel(4, "56, 210, far"); ya->SetBinLabel(4, "56, 210, far"); -} - -//---------------------------------------------------------------------------------------------------- - -TotemRPDQMSource::DiagonalPlots::DiagonalPlots(DQMStore::IBooker &ibooker, int _id) : id(_id) -{ - bool top45 = id & 2; - bool top56 = id & 1; - bool diag = (top45 != top56); - - char name[50]; - sprintf(name, "%s 45%s - 56%s", - (diag) ? "diagonal" : "antidiagonal", - (top45) ? "top" : "bot", - (top56) ? "top" : "bot" - ); - - ibooker.setCurrentFolder(string("CTPPS/TrackingStrip/") + name); - - h_lrc_x_d = ibooker.book2D("dx left vs right", string(name) + " : dx left vs. right, histogram;#Delta x_{45};#Delta x_{56}", 50, 0., 0., 50, 0., 0.); - h_lrc_x_n = ibooker.book2D("xn left vs right", string(name) + " : xn left vs. right, histogram;x^{N}_{45};x^{N}_{56}", 50, 0., 0., 50, 0., 0.); - h_lrc_x_f = ibooker.book2D("xf left vs right", string(name) + " : xf left vs. right, histogram;x^{F}_{45};x^{F}_{56}", 50, 0., 0., 50, 0., 0.); - - h_lrc_y_d = ibooker.book2D("dy left vs right", string(name) + " : dy left vs. right, histogram;#Delta y_{45};#Delta y_{56}", 50, 0., 0., 50, 0., 0.); - h_lrc_y_n = ibooker.book2D("yn left vs right", string(name) + " : yn left vs. right, histogram;y^{N}_{45};y^{N}_{56}", 50, 0., 0., 50, 0., 0.); - h_lrc_y_f = ibooker.book2D("yf left vs right", string(name) + " : yf left vs. right, histogram;y^{F}_{45};y^{F}_{56}", 50, 0., 0., 50, 0., 0.); -} - -//---------------------------------------------------------------------------------------------------- - -TotemRPDQMSource::ArmPlots::ArmPlots(DQMStore::IBooker &ibooker, int _id) : id(_id) -{ - string path = TotemRPDetId::armName(id, TotemRPDetId::nPath); - path.replace(0, 2, "TrackingStrip"); - ibooker.setCurrentFolder(string("CTPPS/") + path); - - string title = TotemRPDetId::armName(id, TotemRPDetId::nFull); - - h_numRPWithTrack_top = ibooker.book1D("number of top RPs with tracks", title+";number of top RPs with tracks", 5, -0.5, 4.5); - h_numRPWithTrack_hor = ibooker.book1D("number of hor RPs with tracks", title+";number of hor RPs with tracks", 5, -0.5, 4.5); - h_numRPWithTrack_bot = ibooker.book1D("number of bot RPs with tracks", title+";number of bot RPs with tracks", 5, -0.5, 4.5); - - h_trackCorr = ibooker.book2D("track RP correlation", title, 13, -0.5, 12.5, 13, -0.5, 12.5); - TH2F *h_trackCorr_h = h_trackCorr->getTH2F(); - TAxis *xa = h_trackCorr_h->GetXaxis(), *ya = h_trackCorr_h->GetYaxis(); - xa->SetBinLabel(1, "210, near, top"); ya->SetBinLabel(1, "210, near, top"); - xa->SetBinLabel(2, "bot"); ya->SetBinLabel(2, "bot"); - xa->SetBinLabel(3, "hor"); ya->SetBinLabel(3, "hor"); - xa->SetBinLabel(4, "far, hor"); ya->SetBinLabel(4, "far, hor"); - xa->SetBinLabel(5, "top"); ya->SetBinLabel(5, "top"); - xa->SetBinLabel(6, "bot"); ya->SetBinLabel(6, "bot"); - xa->SetBinLabel(8, "220, near, top"); ya->SetBinLabel(8, "220, near, top"); - xa->SetBinLabel(9, "bot"); ya->SetBinLabel(9, "bot"); - xa->SetBinLabel(10, "hor"); ya->SetBinLabel(10, "hor"); - xa->SetBinLabel(11, "far, hor"); ya->SetBinLabel(11, "far, hor"); - xa->SetBinLabel(12, "top"); ya->SetBinLabel(12, "top"); - xa->SetBinLabel(13, "bot"); ya->SetBinLabel(13, "bot"); - - h_trackCorr_overlap = ibooker.book2D("track RP correlation hor-vert overlaps", title, 13, -0.5, 12.5, 13, -0.5, 12.5); - h_trackCorr_h = h_trackCorr_overlap->getTH2F(); - xa = h_trackCorr_h->GetXaxis(); ya = h_trackCorr_h->GetYaxis(); - xa->SetBinLabel(1, "210, near, top"); ya->SetBinLabel(1, "210, near, top"); - xa->SetBinLabel(2, "bot"); ya->SetBinLabel(2, "bot"); - xa->SetBinLabel(3, "hor"); ya->SetBinLabel(3, "hor"); - xa->SetBinLabel(4, "far, hor"); ya->SetBinLabel(4, "far, hor"); - xa->SetBinLabel(5, "top"); ya->SetBinLabel(5, "top"); - xa->SetBinLabel(6, "bot"); ya->SetBinLabel(6, "bot"); - xa->SetBinLabel(8, "220, near, top"); ya->SetBinLabel(8, "220, near, top"); - xa->SetBinLabel(9, "bot"); ya->SetBinLabel(9, "bot"); - xa->SetBinLabel(10, "hor"); ya->SetBinLabel(10, "hor"); - xa->SetBinLabel(11, "far, hor"); ya->SetBinLabel(11, "far, hor"); - xa->SetBinLabel(12, "top"); ya->SetBinLabel(12, "top"); - xa->SetBinLabel(13, "bot"); ya->SetBinLabel(13, "bot"); -} - -//---------------------------------------------------------------------------------------------------- - -TotemRPDQMSource::StationPlots::StationPlots(DQMStore::IBooker &ibooker, int id) -{ - string path = TotemRPDetId::stationName(id, TotemRPDetId::nPath); - path.replace(0, 2, "TrackingStrip"); - ibooker.setCurrentFolder(string("CTPPS/") + path); -} - -//---------------------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------------------- - -TotemRPDQMSource::PotPlots::PotPlots(DQMStore::IBooker &ibooker, unsigned int id) -{ - string path = TotemRPDetId::rpName(id, TotemRPDetId::nPath); - path.replace(0, 2, "TrackingStrip"); - ibooker.setCurrentFolder(string("CTPPS/") + path); - - string title = TotemRPDetId::rpName(id, TotemRPDetId::nFull); - - vfat_problem = ibooker.book2D("vfats with any problem", title+";plane;vfat index", 10, -0.5, 9.5, 4, -0.5, 3.5); - vfat_missing = ibooker.book2D("vfats missing", title+";plane;vfat index", 10, -0.5, 9.5, 4, -0.5, 3.5); - vfat_ec_bc_error = ibooker.book2D("vfats with EC or BC error", title+";plane;vfat index", 10, -0.5, 9.5, 4, -0.5, 3.5); - vfat_corruption = ibooker.book2D("vfats with data corruption", title+";plane;vfat index", 10, -0.5, 9.5, 4, -0.5, 3.5); - - activity = ibooker.book1D("active planes", title+";number of active planes", 11, -0.5, 10.5); - activity_u = ibooker.book1D("active planes U", title+";number of active U planes", 11, -0.5, 10.5); - activity_v = ibooker.book1D("active planes V", title+";number of active V planes", 11, -0.5, 10.5); - - activity_per_bx = ibooker.book1D("activity per BX", title+";Event.BX", 4002, -1.5, 4000. + 0.5); - activity_per_bx_short = ibooker.book1D("activity per BX (short)", title+";Event.BX", 102, -1.5, 100. + 0.5); - - hit_plane_hist = ibooker.book2D("activity in planes (2D)", title+";plane number;strip number", 10, -0.5, 9.5, 32, -0.5, 511.5); - - patterns_u = ibooker.book1D("recognized patterns U", title+";number of recognized U patterns", 11, -0.5, 10.5); - patterns_v = ibooker.book1D("recognized patterns V", title+";number of recognized V patterns", 11, -0.5, 10.5); - - h_planes_fit_u = ibooker.book1D("planes contributing to fit U", title+";number of planes contributing to U fit", 6, -0.5, 5.5); - h_planes_fit_v = ibooker.book1D("planes contributing to fit V", title+";number of planes contributing to V fit", 6, -0.5, 5.5); - - event_category = ibooker.book1D("event category", title+";event category", 5, -0.5, 4.5); - TH1F *event_category_h = event_category->getTH1F(); - event_category_h->GetXaxis()->SetBinLabel(1, "empty"); - event_category_h->GetXaxis()->SetBinLabel(2, "insufficient"); - event_category_h->GetXaxis()->SetBinLabel(3, "single-track"); - event_category_h->GetXaxis()->SetBinLabel(4, "multi-track"); - event_category_h->GetXaxis()->SetBinLabel(5, "shower"); - - trackHitsCumulativeHist = ibooker.book2D("track XY profile", title+";x (mm);y (mm)", 100, -18., +18., 100, -18., +18.); - - track_u_profile = ibooker.book1D("track profile U", title+"; U (mm)", 512, -256*66E-3, +256*66E-3); - track_v_profile = ibooker.book1D("track profile V", title+"; V (mm)", 512, -256*66E-3, +256*66E-3); -} - -//---------------------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------------------- - -TotemRPDQMSource::PlanePlots::PlanePlots(DQMStore::IBooker &ibooker, unsigned int id) -{ - string path = TotemRPDetId::planeName(id, TotemRPDetId::nPath); - path.replace(0, 2, "TrackingStrip"); - ibooker.setCurrentFolder(string("CTPPS/") + path); - - string title = TotemRPDetId::planeName(id, TotemRPDetId::nFull); - - digi_profile_cumulative = ibooker.book1D("digi profile", title+";strip number", 512, -0.5, 511.5); - cluster_profile_cumulative = ibooker.book1D("cluster profile", title+";cluster center", 1024, -0.25, 511.75); - hit_multiplicity = ibooker.book1D("hit multiplicity", title+";hits/detector/event", 6, -0.5, 5.5); - cluster_size = ibooker.book1D("cluster size", title+";hits per cluster", 5, 0.5, 5.5); - - efficiency_num = ibooker.book1D("efficiency num", title+";track position (mm)", 30, -15., 0.); - efficiency_den = ibooker.book1D("efficiency den", title+";track position (mm)", 30, -15., 0.); -} - -//---------------------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------------------- - -TotemRPDQMSource::TotemRPDQMSource(const edm::ParameterSet& ps) : - verbosity(ps.getUntrackedParameter("verbosity", 0)) -{ - tokenStatus = consumes>(ps.getParameter("tagStatus")); - - tokenDigi = consumes< DetSetVector >(ps.getParameter("tagDigi")); - tokenCluster = consumes< edm::DetSetVector >(ps.getParameter("tagCluster")); - tokenRecHit = consumes< edm::DetSetVector >(ps.getParameter("tagRecHit")); - tokenUVPattern = consumes< DetSetVector >(ps.getParameter("tagUVPattern")); - tokenLocalTrack = consumes< DetSetVector >(ps.getParameter("tagLocalTrack")); - //tokenMultiTrackColl = consumes< RPMulFittedTrackCollection >(ps.getParameter("tagMultiTrackColl")); -} - -//---------------------------------------------------------------------------------------------------- - -TotemRPDQMSource::~TotemRPDQMSource() -{ -} - -//---------------------------------------------------------------------------------------------------- - -void TotemRPDQMSource::dqmBeginRun(edm::Run const &, edm::EventSetup const &) -{ -} - -//---------------------------------------------------------------------------------------------------- - -void TotemRPDQMSource::bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &, edm::EventSetup const &) -{ - ibooker.cd(); - ibooker.setCurrentFolder("CTPPS"); - - // global plots - globalPlots.Init(ibooker); - - // temporarily disabled - /* - // initialize diagonals - diagonalPlots[1] = DiagonalPlots(ibooker, 1); // 45 bot - 56 top - diagonalPlots[2] = DiagonalPlots(ibooker, 2); // 45 top - 45 bot - - // initialize anti-diagonals - diagonalPlots[0] = DiagonalPlots(ibooker, 0); // 45 bot - 56 bot - diagonalPlots[3] = DiagonalPlots(ibooker, 3); // 45 top - 56 top - */ - - // loop over arms - for (unsigned int arm = 0; arm < 2; arm++) - { - armPlots[arm] = ArmPlots(ibooker, arm); - - // loop over stations - for (unsigned int st = 0; st < 3; st += 2) - { - unsigned int stId = 10*arm + st; - - stationPlots[stId] = StationPlots(ibooker, stId); - - // loop over RPs - for (unsigned int rp = 0; rp < 6; ++rp) - { - unsigned int rpId = 10*stId + rp; - - potPlots[rpId] = PotPlots(ibooker, rpId); - - // loop over planes - for (unsigned int pl = 0; pl < 10; ++pl) - { - unsigned int plId = 10*rpId + pl; - planePlots[plId] = PlanePlots(ibooker, plId); - } - } - } - } -} - -//---------------------------------------------------------------------------------------------------- - -void TotemRPDQMSource::beginLuminosityBlock(edm::LuminosityBlock const& lumiSeg, - edm::EventSetup const& context) -{ -} - -//---------------------------------------------------------------------------------------------------- - -void TotemRPDQMSource::analyze(edm::Event const& event, edm::EventSetup const& eventSetup) -{ - // get event setup data - ESHandle geometry; - eventSetup.get().get(geometry); - - // get event data - Handle< DetSetVector > status; - event.getByToken(tokenStatus, status); - - Handle< DetSetVector > digi; - event.getByToken(tokenDigi, digi); - - Handle< DetSetVector > digCluster; - event.getByToken(tokenCluster, digCluster); - - Handle< DetSetVector > hits; - event.getByToken(tokenRecHit, hits); - - Handle> patterns; - event.getByToken(tokenUVPattern, patterns); - - Handle< DetSetVector > tracks; - event.getByToken(tokenLocalTrack, tracks); - - //Handle< RPMulFittedTrackCollection > multiTracks; - //event.getByToken(tokenMultiTrackColl, multiTracks); - - // check validity - bool valid = true; - valid &= status.isValid(); - valid &= digi.isValid(); - valid &= digCluster.isValid(); - valid &= hits.isValid(); - valid &= patterns.isValid(); - valid &= tracks.isValid(); - //valid &= multiTracks.isValid(); - - if (!valid) - { - if (verbosity) - { - LogProblem("TotemRPDQMSource") << - "ERROR in TotemDQMModuleRP::analyze > some of the required inputs are not valid. Skipping this event.\n" - << " status.isValid = " << status.isValid() << "\n" - << " digi.isValid = " << digi.isValid() << "\n" - << " digCluster.isValid = " << digCluster.isValid() << "\n" - << " hits.isValid = " << hits.isValid() << "\n" - << " patterns.isValid = " << patterns.isValid() << "\n" - << " tracks.isValid = " << tracks.isValid(); - //<< " multiTracks.isValid = %i\n", multiTracks.isValid() - } - - return; - } - - //------------------------------ - // Global Plots - - globalPlots.events_per_bx->Fill(event.bunchCrossing()); - globalPlots.events_per_bx_short->Fill(event.bunchCrossing()); - - for (auto &ds1 : *tracks) - { - for (auto &tr1 : ds1) - { - if (! tr1.isValid()) - continue; - - unsigned int rpId1 = ds1.detId(); - unsigned int arm1 = rpId1 / 100; - unsigned int stNum1 = (rpId1 / 10) % 10; - unsigned int rpNum1 = rpId1 % 10; - if (stNum1 != 0 || (rpNum1 != 2 && rpNum1 != 3)) - continue; - unsigned int idx1 = arm1*2 + rpNum1-2; - - for (auto &ds2 : *tracks) - { - for (auto &tr2 : ds2) - { - if (! tr2.isValid()) - continue; - - unsigned int rpId2 = ds2.detId(); - unsigned int arm2 = rpId2 / 100; - unsigned int stNum2 = (rpId2 / 10) % 10; - unsigned int rpNum2 = rpId2 % 10; - if (stNum2 != 0 || (rpNum2 != 2 && rpNum2 != 3)) - continue; - unsigned int idx2 = arm2*2 + rpNum2-2; - - globalPlots.h_trackCorr_hor->Fill(idx1, idx2); - } - } - } - } - - //------------------------------ - // Status Plots - - for (auto &ds : *status) - { - unsigned int decId = TotemRPDetId::rawToDecId(ds.detId()); - unsigned int rpId = decId / 10; - unsigned int plNum = decId % 10; - - auto &plots = potPlots[rpId]; - - for (auto &s : ds) - { - if (s.isMissing()) - { - plots.vfat_problem->Fill(plNum, s.getChipPosition()); - plots.vfat_missing->Fill(plNum, s.getChipPosition()); - } - - if (s.isECProgressError() || s.isBCProgressError()) - { - plots.vfat_problem->Fill(plNum, s.getChipPosition()); - plots.vfat_ec_bc_error->Fill(plNum, s.getChipPosition()); - } - - if (s.isIDMismatch() || s.isFootprintError() || s.isCRCError()) - { - plots.vfat_problem->Fill(plNum, s.getChipPosition()); - plots.vfat_corruption->Fill(plNum, s.getChipPosition()); - } - } - } - - //------------------------------ - // Plane Plots - - // digi profile cumulative - for (DetSetVector::const_iterator it = digi->begin(); it != digi->end(); ++it) - { - unsigned int DetId = TotemRPDetId::rawToDecId(it->detId()); - for (DetSet::const_iterator dit = it->begin(); dit != it->end(); ++dit) - { - planePlots[DetId].digi_profile_cumulative->Fill(dit->getStripNumber()); - } - } - - // cluster profile cumulative - for (DetSetVector::const_iterator it = digCluster->begin(); it != digCluster->end(); it++) - { - unsigned int DetId = TotemRPDetId::rawToDecId(it->detId()); - for (DetSet::const_iterator dit = it->begin(); dit != it->end(); ++dit) - { - planePlots[DetId].cluster_profile_cumulative->Fill(dit->getCenterStripPosition()); - } - } - - // hit multiplicity - for (DetSetVector::const_iterator it = digCluster->begin(); it != digCluster->end(); it++) - { - unsigned int DetId = TotemRPDetId::rawToDecId(it->detId()); - planePlots[DetId].hit_multiplicity->Fill(it->size()); - } - - // cluster size - for (DetSetVector::const_iterator it = digCluster->begin(); it != digCluster->end(); it++) - { - unsigned int DetId = TotemRPDetId::rawToDecId(it->detId()); - for (DetSet::const_iterator dit = it->begin(); dit != it->end(); ++dit) - planePlots[DetId].cluster_size->Fill(dit->getNumberOfStrips()); - } - - // plane efficiency plots - for (auto &ds : *tracks) - { - unsigned int rpId = ds.detId(); - - for (auto &ft : ds) - { - if (!ft.isValid()) - continue; - - double rp_z = geometry->GetRPGlobalTranslation(rpId).z(); - - for (unsigned int plNum = 0; plNum < 10; ++plNum) - { - unsigned int plDecId = rpId*10 + plNum; - unsigned int plRawId = TotemRPDetId::decToRawId(plDecId); - - double ft_z = ft.getZ0(); - double ft_x = ft.getX0() + ft.getTx() * (ft_z - rp_z); - double ft_y = ft.getY0() + ft.getTy() * (ft_z - rp_z); - - double ft_v = geometry->GlobalToLocal(plRawId, CLHEP::Hep3Vector(ft_x, ft_y, ft_z)).y(); - - bool hasMatchingHit = false; - const auto &hit_ds_it = hits->find(plRawId); - if (hit_ds_it != hits->end()) - { - for (const auto &h : *hit_ds_it) - { - bool match = (fabs(ft_v - h.getPosition()) < 2.*0.066); - if (match) - { - hasMatchingHit = true; - break; - } - } - } - - auto &pp = planePlots[plDecId]; - - pp.efficiency_den->Fill(ft_v); - if (hasMatchingHit) - pp.efficiency_num->Fill(ft_v); - } - } - } - - - //------------------------------ - // Roman Pots Plots - - // determine active planes (from RecHits and VFATStatus) - map > planes; - map > planes_u; - map > planes_v; - for (const auto &ds : *hits) - { - if (ds.empty()) - continue; - - unsigned int DetId = TotemRPDetId::rawToDecId(ds.detId()); - unsigned int RPId = TotemRPDetId::rpOfDet(DetId); - unsigned int planeNum = DetId % 10; - planes[RPId].insert(planeNum); - if (TotemRPDetId::isStripsCoordinateUDirection(DetId)) - planes_u[RPId].insert(planeNum); - else - planes_v[RPId].insert(planeNum); - } - - for (const auto &ds : *status) - { - bool activity = false; - for (const auto &s : ds) - { - if (s.isNumberOfClustersSpecified() && s.getNumberOfClusters() > 0) - { - activity = true; - break; - } - } - - if (!activity) - continue; - - unsigned int DetId = TotemRPDetId::rawToDecId(ds.detId()); - unsigned int RPId = TotemRPDetId::rpOfDet(DetId); - unsigned int planeNum = DetId % 10; - planes[RPId].insert(planeNum); - if (TotemRPDetId::isStripsCoordinateUDirection(DetId)) - planes_u[RPId].insert(planeNum); - else - planes_v[RPId].insert(planeNum); - } - - // plane activity histogram - for (std::map::iterator it = potPlots.begin(); it != potPlots.end(); it++) - { - it->second.activity->Fill(planes[it->first].size()); - it->second.activity_u->Fill(planes_u[it->first].size()); - it->second.activity_v->Fill(planes_v[it->first].size()); - - if (planes[it->first].size() >= 6) - { - it->second.activity_per_bx->Fill(event.bunchCrossing()); - it->second.activity_per_bx_short->Fill(event.bunchCrossing()); - } - } - - for (DetSetVector::const_iterator it = digCluster->begin(); it != digCluster->end(); it++) - { - unsigned int DetId = TotemRPDetId::rawToDecId(it->detId()); - unsigned int RPId = TotemRPDetId::rpOfDet(DetId); - unsigned int planeNum = DetId % 10; - PotPlots &pp = potPlots[RPId]; - for (DetSet::const_iterator dit = it->begin(); dit != it->end(); ++dit) - pp.hit_plane_hist->Fill(planeNum, dit->getCenterStripPosition()); - } - - // recognized pattern histograms - for (auto &ds : *patterns) - { - unsigned int rpId = ds.detId(); - PotPlots &pp = potPlots[rpId]; - - // count U and V patterns - unsigned int u = 0, v = 0; - for (auto &p : ds) - { - if (! p.getFittable()) - continue; - - if (p.getProjection() == TotemRPUVPattern::projU) - u++; - - if (p.getProjection() == TotemRPUVPattern::projV) - v++; - } - - pp.patterns_u->Fill(u); - pp.patterns_v->Fill(v); - } - - // event-category histogram - for (auto &it : potPlots) - { - const unsigned int &id = it.first; - auto &pp = it.second; - - // process hit data for this plot - unsigned int pl_u = planes_u[id].size(); - unsigned int pl_v = planes_v[id].size(); - - // process pattern data for this pot - const auto &rp_pat_it = patterns->find(id); - - unsigned int pat_u = 0, pat_v = 0; - if (rp_pat_it != patterns->end()) - { - for (auto &p : *rp_pat_it) - { - if (! p.getFittable()) - continue; - - if (p.getProjection() == TotemRPUVPattern::projU) - pat_u++; - - if (p.getProjection() == TotemRPUVPattern::projV) - pat_v++; - } - } - - // determine category - signed int category = -1; - - if (pl_u == 0 && pl_v == 0) category = 0; // empty - - if (category == -1 && pat_u + pat_v <= 1) - { - if (pl_u + pl_v < 6) - category = 1; // insuff - else - category = 4; // shower - } - - if (pat_u == 1 && pat_v == 1) category = 2; // 1-track - - if (category == -1) category = 3; // multi-track - - pp.event_category->Fill(category); - } - - // RP track-fit plots - for (auto &ds : *tracks) - { - unsigned int RPId = ds.detId(); - PotPlots &pp = potPlots[RPId]; - - for (auto &ft : ds) - { - if (!ft.isValid()) - continue; - - // number of planes contributing to (valid) fits - unsigned int n_pl_in_fit_u = 0, n_pl_in_fit_v = 0; - for (auto &hds : ft.getHits()) - { - unsigned int rawId = hds.detId(); - unsigned int decId = TotemRPDetId::rawToDecId(rawId); - bool uProj =TotemRPDetId::isStripsCoordinateUDirection(decId); - - for (auto &h : hds) - { - h.getPosition(); // just to keep compiler silent - if (uProj) - n_pl_in_fit_u++; - else - n_pl_in_fit_v++; - } - } - - pp.h_planes_fit_u->Fill(n_pl_in_fit_u); - pp.h_planes_fit_v->Fill(n_pl_in_fit_v); - - // mean position of U and V planes - double rp_x = ( geometry->GetDetector(TotemRPDetId::decToRawId(RPId*10 + 0))->translation().x() + - geometry->GetDetector(TotemRPDetId::decToRawId(RPId*10 + 1))->translation().x() ) / 2.; - double rp_y = ( geometry->GetDetector(TotemRPDetId::decToRawId(RPId*10 + 0))->translation().y() + - geometry->GetDetector(TotemRPDetId::decToRawId(RPId*10 + 1))->translation().y() ) / 2.; - - // mean read-out direction of U and V planes - CLHEP::Hep3Vector rod_U = geometry->LocalToGlobalDirection(TotemRPDetId::decToRawId(RPId*10 + 1), CLHEP::Hep3Vector(0., 1., 0.)); - CLHEP::Hep3Vector rod_V = geometry->LocalToGlobalDirection(TotemRPDetId::decToRawId(RPId*10 + 0), CLHEP::Hep3Vector(0., 1., 0.)); - - double x = ft.getX0() - rp_x; - double y = ft.getY0() - rp_y; - - pp.trackHitsCumulativeHist->Fill(x, y); - - double U = x * rod_U.x() + y * rod_U.y(); - double V = x * rod_V.x() + y * rod_V.y(); - - pp.track_u_profile->Fill(U); - pp.track_v_profile->Fill(V); - } - } - - //------------------------------ - // Station Plots - - - //------------------------------ - // Arm Plots - { - map mTop, mHor, mBot; - - for (auto p : armPlots) - { - mTop[p.first] = 0; - mHor[p.first] = 0; - mBot[p.first] = 0; - } - - for (auto &ds : *tracks) - { - unsigned int rpId = ds.detId(); - unsigned int armNum = rpId / 100; - unsigned int rpNum = rpId % 10; - - for (auto &tr : ds) - { - if (! tr.isValid()) - continue; - - if (rpNum == 0 || rpNum == 4) - mTop[armNum]++; - if (rpNum == 2 || rpNum == 3) - mHor[armNum]++; - if (rpNum == 1 || rpNum == 5) - mBot[armNum]++; - } - } - - for (auto &p : armPlots) - { - p.second.h_numRPWithTrack_top->Fill(mTop[p.first]); - p.second.h_numRPWithTrack_hor->Fill(mHor[p.first]); - p.second.h_numRPWithTrack_bot->Fill(mBot[p.first]); - } - - // track RP correlation - for (auto &ds1 : *tracks) - { - for (auto &tr1 : ds1) - { - if (! tr1.isValid()) - continue; - - unsigned int rpId1 = ds1.detId(); - unsigned int arm1 = rpId1 / 100; - unsigned int stNum1 = (rpId1 / 10) % 10; - unsigned int rpNum1 = rpId1 % 10; - unsigned int idx1 = stNum1/2 * 7 + rpNum1; - bool hor1 = (rpNum1 == 2 || rpNum1 == 3); - - ArmPlots &ap = armPlots[arm1]; - - for (auto &ds2 : *tracks) - { - for (auto &tr2 : ds2) - { - if (! tr2.isValid()) - continue; - - unsigned int rpId2 = ds2.detId(); - unsigned int arm2 = rpId2 / 100; - unsigned int stNum2 = (rpId2 / 10) % 10; - unsigned int rpNum2 = rpId2 % 10; - unsigned int idx2 = stNum2/2 * 7 + rpNum2; - bool hor2 = (rpNum2 == 2 || rpNum2 == 3); - - if (arm1 != arm2) - continue; - - ap.h_trackCorr->Fill(idx1, idx2); - - if (hor1 != hor2) - ap.h_trackCorr_overlap->Fill(idx1, idx2); - } - } - } - } - } - - //------------------------------ - // RP-system plots - // TODO: this code needs - // * generalization for more than two RPs per arm - // * updating for tracks as DetSetVector - /* - for (auto &dp : diagonalPlots) - { - unsigned int id = dp.first; - bool top45 = id & 2; - bool top56 = id & 1; - - unsigned int id_45_n = (top45) ? 20 : 21; - unsigned int id_45_f = (top45) ? 24 : 25; - unsigned int id_56_n = (top56) ? 120 : 121; - unsigned int id_56_f = (top56) ? 124 : 125; - - bool h_45_n = (tracks->find(id_45_n) != tracks->end() && tracks->find(id_45_n)->second.IsValid()); - bool h_45_f = (tracks->find(id_45_f) != tracks->end() && tracks->find(id_45_f)->second.IsValid()); - bool h_56_n = (tracks->find(id_56_n) != tracks->end() && tracks->find(id_56_n)->second.IsValid()); - bool h_56_f = (tracks->find(id_56_f) != tracks->end() && tracks->find(id_56_f)->second.IsValid()); - - if (! (h_45_n && h_45_f && h_56_n && h_56_f) ) - continue; - - double x_45_n = tracks->find(id_45_n)->second.X0(), y_45_n = tracks->find(id_45_n)->second.Y0(); - double x_45_f = tracks->find(id_45_f)->second.X0(), y_45_f = tracks->find(id_45_f)->second.Y0(); - double x_56_n = tracks->find(id_56_n)->second.X0(), y_56_n = tracks->find(id_56_n)->second.Y0(); - double x_56_f = tracks->find(id_56_f)->second.X0(), y_56_f = tracks->find(id_56_f)->second.Y0(); - - double dx_45 = x_45_f - x_45_n; - double dy_45 = y_45_f - y_45_n; - double dx_56 = x_56_f - x_56_n; - double dy_56 = y_56_f - y_56_n; - - DiagonalPlots &pl = dp.second; - - pl.h_lrc_x_d->Fill(dx_45, dx_56); - pl.h_lrc_y_d->Fill(dy_45, dy_56); - - pl.h_lrc_x_n->Fill(x_45_n, x_56_n); - pl.h_lrc_y_n->Fill(y_45_n, y_56_n); - - pl.h_lrc_x_f->Fill(x_45_f, x_56_f); - pl.h_lrc_y_f->Fill(y_45_f, y_56_f); - } - */ -} - -//---------------------------------------------------------------------------------------------------- - -void TotemRPDQMSource::endLuminosityBlock(edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& eSetup) -{ -} - -//---------------------------------------------------------------------------------------------------- - -void TotemRPDQMSource::endRun(edm::Run const& run, edm::EventSetup const& eSetup) -{ -} - -//---------------------------------------------------------------------------------------------------- - -DEFINE_FWK_MODULE(TotemRPDQMSource); diff --git a/DQM/CTPPS/python/totemDAQTriggerDQMSource_cfi.py b/DQM/CTPPS/python/totemDAQTriggerDQMSource_cfi.py deleted file mode 100644 index d2686abd209..00000000000 --- a/DQM/CTPPS/python/totemDAQTriggerDQMSource_cfi.py +++ /dev/null @@ -1,8 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -totemDAQTriggerDQMSource = cms.EDAnalyzer("TotemDAQTriggerDQMSource", - tagFEDInfo = cms.InputTag("totemRPRawToDigi", "RP"), - tagTriggerCounters = cms.InputTag("totemTriggerRawToDigi"), - - verbosity = cms.untracked.uint32(0) -) diff --git a/DQM/CTPPS/python/totemDQM_cff.py b/DQM/CTPPS/python/totemDQM_cff.py deleted file mode 100644 index 94b718ce78b..00000000000 --- a/DQM/CTPPS/python/totemDQM_cff.py +++ /dev/null @@ -1,13 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -from DQM.CTPPS.totemDAQTriggerDQMSource_cfi import * - -from DQM.CTPPS.totemRPDQMSource_cfi import * - -from DQM.CTPPS.totemRPDQMHarvester_cfi import * - -totemDQM = cms.Sequence( - totemDAQTriggerDQMSource * - totemRPDQMSource * - totemRPDQMHarvester -) diff --git a/DQM/CTPPS/python/totemRPDQMHarvester_cfi.py b/DQM/CTPPS/python/totemRPDQMHarvester_cfi.py deleted file mode 100644 index 02e88f1441b..00000000000 --- a/DQM/CTPPS/python/totemRPDQMHarvester_cfi.py +++ /dev/null @@ -1,4 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -totemRPDQMHarvester = cms.EDAnalyzer("TotemRPDQMHarvester", -) diff --git a/DQM/CTPPS/python/totemRPDQMSource_cfi.py b/DQM/CTPPS/python/totemRPDQMSource_cfi.py deleted file mode 100644 index b8738b4c6a8..00000000000 --- a/DQM/CTPPS/python/totemRPDQMSource_cfi.py +++ /dev/null @@ -1,12 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -totemRPDQMSource = cms.EDAnalyzer("TotemRPDQMSource", - tagStatus = cms.InputTag("totemRPRawToDigi", "RP"), - tagDigi = cms.InputTag("totemRPRawToDigi", "RP"), - tagCluster = cms.InputTag("totemRPClusterProducer"), - tagRecHit = cms.InputTag("totemRPRecHitProducer"), - tagUVPattern = cms.InputTag("totemRPUVPatternFinder"), - tagLocalTrack = cms.InputTag("totemRPLocalTrackFitter"), - - verbosity = cms.untracked.uint32(0), -) diff --git a/DQM/CTPPS/test/dqm_test_cfg.py b/DQM/CTPPS/test/dqm_test_cfg.py deleted file mode 100644 index 849d73d6766..00000000000 --- a/DQM/CTPPS/test/dqm_test_cfg.py +++ /dev/null @@ -1,56 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -process = cms.Process('RECODQM') - -# minimum of logs -process.MessageLogger = cms.Service("MessageLogger", - statistics = cms.untracked.vstring(), - destinations = cms.untracked.vstring('cerr'), - cerr = cms.untracked.PSet( - threshold = cms.untracked.string('WARNING') - ) -) - -# load DQM framework -process.load("DQM.Integration.config.environment_cfi") -process.dqmEnv.subSystemFolder = "CTPPS" -process.dqmEnv.eventInfoFolder = "EventInfo" -process.dqmSaver.path = "" -process.dqmSaver.tag = "CTPPS" - -# raw data source -process.source = cms.Source("PoolSource", - fileNames = cms.untracked.vstring('file:/afs/cern.ch/user/j/jkaspar/public/run273062_ls0001-2_stream.root') -) - -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(-1) -) - -# raw-to-digi conversion -process.load("EventFilter.TotemRawToDigi.totemRawToDigi_cff") - -# local RP reconstruction chain with standard settings -process.load("RecoCTPPS.Configuration.recoCTPPS_cff") - -# CTPPS DQM modules -process.load("DQM.CTPPS.totemDQM_cff") - -process.path = cms.Path( - process.totemTriggerRawToDigi * - process.totemRPRawToDigi * - - process.recoCTPPS * - - process.totemDQM -) - -process.end_path = cms.EndPath( - process.dqmEnv + - process.dqmSaver -) - -process.schedule = cms.Schedule( - process.path, - process.end_path -) diff --git a/DataFormats/CTPPSReco/BuildFile.xml b/DataFormats/CTPPSReco/BuildFile.xml deleted file mode 100644 index ec277b10dff..00000000000 --- a/DataFormats/CTPPSReco/BuildFile.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/DataFormats/CTPPSReco/interface/TotemRPCluster.h b/DataFormats/CTPPSReco/interface/TotemRPCluster.h deleted file mode 100644 index fa918045986..00000000000 --- a/DataFormats/CTPPSReco/interface/TotemRPCluster.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Hubert Niewiadomski -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#ifndef DataFormats_CTPPSReco_TotemRPCluster -#define DataFormats_CTPPSReco_TotemRPCluster - -/** - *\brief Cluster of TOTEM RP strip hits. - **/ -class TotemRPCluster -{ - public: - TotemRPCluster(unsigned short str_beg=0, unsigned short str_end=0) : str_beg_(str_beg), str_end_(str_end) - { - } - - inline uint16_t getStripBegin() const { return str_beg_; } - inline void setStripBegin(unsigned short str_beg) { str_beg_ = str_beg; } - - inline uint16_t getStripEnd() const { return str_end_; } - inline void setStripEnd(unsigned short str_end) { str_end_ = str_end; } - - inline int getNumberOfStrips() const { return str_end_ - str_beg_ + 1; } - - inline double getCenterStripPosition() const { return (str_beg_ + str_end_)/2.; } - - private: - uint16_t str_beg_; - uint16_t str_end_; -}; - -//---------------------------------------------------------------------------------------------------- - -inline bool operator<( const TotemRPCluster& l, const TotemRPCluster& r) -{ - if (l.getStripBegin() < r.getStripBegin()) - return true; - if (l.getStripBegin() > r.getStripBegin()) - return false; - - if (l.getStripEnd() < r.getStripEnd()) - return true; - - return false; -} - -#endif diff --git a/DataFormats/CTPPSReco/interface/TotemRPLocalTrack.h b/DataFormats/CTPPSReco/interface/TotemRPLocalTrack.h deleted file mode 100644 index d960e2960c7..00000000000 --- a/DataFormats/CTPPSReco/interface/TotemRPLocalTrack.h +++ /dev/null @@ -1,169 +0,0 @@ -/**************************************************************************** - * - * This is a part of TOTEM offline software. - * Authors: - * Hubert Niewiadomski - * Jan Kašpar (jan.kaspar@gmail.com) - * - ****************************************************************************/ - -#ifndef DataFormats_CTPPSReco_TotemRPLocalTrack -#define DataFormats_CTPPSReco_TotemRPLocalTrack - -#include "DataFormats/Common/interface/DetSetVector.h" -#include "DataFormats/CTPPSReco/interface/TotemRPRecHit.h" - -#include "TVector3.h" -#include "TMatrixD.h" -#include "TVectorD.h" - -//---------------------------------------------------------------------------------------------------- - -/** - *\brief A track fit through a single RP. - * - * x = x0+tx*(z-z0) y = ... - * - * z0 is defined below - * x any y refer to the global (x, y) system with the beam at (x = 0, y = 0). - * Only VALID tracks (IsValid()==true) can be later used for physics reconstruction! - **/ -class TotemRPLocalTrack -{ - public: - class FittedRecHit: public TotemRPRecHit - { - public: - FittedRecHit(const TotemRPRecHit &hit, const TVector3 &space_point_on_det, double residual, double pull) : - TotemRPRecHit(hit), space_point_on_det_(space_point_on_det), residual_(residual), pull_(pull) {} - - FittedRecHit() : TotemRPRecHit(), residual_(0), pull_(0) {} - - virtual ~FittedRecHit() {} - - inline const TVector3 & getGlobalCoordinates() const { return space_point_on_det_; } - inline void setGlobalCoordinates(const TVector3 & space_point_on_det) { space_point_on_det_ = space_point_on_det; } - - inline double getResidual() const { return residual_; } - inline void setResidual(double residual) { residual_ = residual; } - - inline double getPull() const { return pull_; } - inline void setPull(double pull) { pull_ = pull; } - - inline double getPullNormalization() const { return residual_ / pull_; } - - private: - TVector3 space_point_on_det_; ///< mm - double residual_; ///< mm - double pull_; ///< normalised residual - }; - - public: - ///< parameter vector size - static const int dimension = 4; - - ///< covariance matrix size - static const int covarianceSize = dimension * dimension; - - TotemRPLocalTrack() : z0_(0), chiSquared_(0), valid_(false) - { - } - - TotemRPLocalTrack(double z0, const TVectorD &track_params_vector, - const TMatrixD &par_covariance_matrix, double chiSquared); - - virtual ~TotemRPLocalTrack() {} - - inline const edm::DetSetVector& getHits() const { return track_hits_vector_; } - inline void addHit(unsigned int detId, const FittedRecHit &hit) - { - track_hits_vector_.find_or_insert(detId).push_back(hit); - } - - inline double getX0() const { return track_params_vector_[0]; } - inline double getX0Sigma() const { return sqrt(CovarianceMatrixElement(0, 0)); } - inline double getX0Variance() const { return CovarianceMatrixElement(0, 0); } - - inline double getY0() const { return track_params_vector_[1]; } - inline double getY0Sigma() const { return sqrt(CovarianceMatrixElement(1, 1)); } - inline double getY0Variance() const { return CovarianceMatrixElement(1, 1); } - - inline double getZ0() const { return z0_; } - inline void setZ0(double z0) { z0_ = z0; } - - inline double getTx() const { return track_params_vector_[2]; } - inline double getTxSigma() const { return sqrt(CovarianceMatrixElement(2, 2)); } - - inline double getTy() const { return track_params_vector_[3]; } - inline double getTySigma() const { return sqrt(CovarianceMatrixElement(3, 3)); } - - inline TVector3 getDirectionVector() const - { - TVector3 vect(getTx(), getTy(), 1); - vect.SetMag(1.0); - return vect; - } - - TVectorD getParameterVector() const; - void setParameterVector(const TVectorD & track_params_vector); - - TMatrixD getCovarianceMatrix() const; - void setCovarianceMatrix(const TMatrixD &par_covariance_matrix); - - inline double getChiSquared() const { return chiSquared_; } - inline void setChiSquared(double & chiSquared) { chiSquared_ = chiSquared; } - - inline double getChiSquaredOverNDF() const { return chiSquared_ / (track_hits_vector_.size() - 4); } - - /// returns (x, y) vector - inline TVector2 getTrackPoint(double z) const - { - double delta_z = z - z0_; - return TVector2( - track_params_vector_[0] + track_params_vector_[2] * delta_z, - track_params_vector_[1] + track_params_vector_[3] * delta_z); - } - - inline TVector3 getTrackCentrePoint() - { - return TVector3(track_params_vector_[0], track_params_vector_[1], z0_); - } - - TMatrixD trackPointInterpolationCovariance(double z) const; - - inline bool isValid() const { return valid_; } - - inline void setValid(bool valid) { valid_ = valid; } - - friend bool operator< (const TotemRPLocalTrack &l, const TotemRPLocalTrack &r); - - private: - inline const double& CovarianceMatrixElement(int i, int j) const - { - return par_covariance_matrix_[i * dimension + j]; - } - - inline double& CovarianceMatrixElement(int i, int j) - { - return par_covariance_matrix_[i * dimension + j]; - } - - edm::DetSetVector track_hits_vector_; - - /// track parameters: (x0, y0, tx, ty); x = x0 + tx*(z-z0) ... - double track_params_vector_[dimension]; - - /// z where x0 and y0 are evaluated. - /// filled from TotemRPGeometry::GetRPGlobalTranslation - double z0_; - - double par_covariance_matrix_[covarianceSize]; - - /// fit chi^2 - double chiSquared_; - - /// fit valid? - bool valid_; -}; - -#endif diff --git a/DataFormats/CTPPSReco/interface/TotemRPRecHit.h b/DataFormats/CTPPSReco/interface/TotemRPRecHit.h deleted file mode 100644 index 5e0b66f6962..00000000000 --- a/DataFormats/CTPPSReco/interface/TotemRPRecHit.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Hubert Niewiadomski -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#ifndef DataFormats_CTPPSReco_TotemRPRecHit -#define DataFormats_CTPPSReco_TotemRPRecHit - -/** - *\brief Reconstructed hit in TOTEM RP. - * - * Basically a cluster (TotemRPCluster), the position of which has been converted into actual geometry (in mm). - **/ -class TotemRPRecHit -{ - public: - TotemRPRecHit(double position=0, double sigma=0) : position_(position), sigma_(sigma) - { - } - - inline double getPosition() const { return position_; } - inline void setPosition(double position) { position_=position; } - - inline double getSigma() const { return sigma_; } - inline void setSigma(double sigma) { sigma_=sigma; } - - private: - /// position of the hit in mm, wrt detector center (see RPTopology::GetHitPositionInReadoutDirection) - double position_; - - /// position uncertainty, in mm - double sigma_; -}; - -//---------------------------------------------------------------------------------------------------- - -inline bool operator< (const TotemRPRecHit &l, const TotemRPRecHit &r) -{ - if (l.getPosition() < r.getPosition()) - return true; - if (l.getPosition() > r.getPosition()) - return false; - - if (l.getSigma() < r.getSigma()) - return true; - - return false; -} - -#endif diff --git a/DataFormats/CTPPSReco/interface/TotemRPUVPattern.h b/DataFormats/CTPPSReco/interface/TotemRPUVPattern.h deleted file mode 100644 index 5d8207264da..00000000000 --- a/DataFormats/CTPPSReco/interface/TotemRPUVPattern.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#ifndef DataFormats_CTPPSReco_TotemRPUVPattern -#define DataFormats_CTPPSReco_TotemRPUVPattern - -#include "DataFormats/Common/interface/DetSet.h" -#include "DataFormats/Common/interface/DetSetVector.h" -#include "DataFormats/CTPPSReco/interface/TotemRPRecHit.h" - -/** - *\brief A linear pattern in U or V projection. - * The intercept b is taken at the middle of a RP: - * (geometry->GetRPDevice(RPId)->translation().z()) - * The global coordinate system is used (wrt. the beam). This is the same convention - * as for the 1-RP track fits. - **/ -class TotemRPUVPattern -{ - public: - enum ProjectionType { projInvalid, projU, projV }; - - TotemRPUVPattern() : projection(projInvalid), a(0.), b(0.), w(0.), fittable(false) - { - } - - ProjectionType getProjection() const { return projection; } - void setProjection(ProjectionType p_) { projection = p_; } - - double getA() const { return a; } - void setA(double a_) { a = a_; } - - double getB() const { return b; } - void setB(double b_) { b = b_; } - - double getW() const { return w; } - void setW(double w_) { w = w_; } - - bool getFittable() const { return fittable; } - void setFittable(bool f_) { fittable = f_; } - - void addHit(edm::det_id_type detId, const TotemRPRecHit &hit) - { - hits.find_or_insert(detId).push_back(hit); - } - - const edm::DetSetVector& getHits() const { return hits; } - - friend bool operator< (const TotemRPUVPattern &l, const TotemRPUVPattern &r); - - private: - ProjectionType projection; ///< projection - double a; ///< slope in rad - double b; ///< intercept in mm - double w; ///< weight - bool fittable; ///< whether this pattern is worth including in track fits - - edm::DetSetVector hits; ///< hits associated with the pattern -}; - -//---------------------------------------------------------------------------------------------------- - -extern bool operator< (const TotemRPUVPattern &l, const TotemRPUVPattern &r); - -#endif diff --git a/DataFormats/CTPPSReco/src/TotemRPLocalTrack.cc b/DataFormats/CTPPSReco/src/TotemRPLocalTrack.cc deleted file mode 100644 index 34d4041bace..00000000000 --- a/DataFormats/CTPPSReco/src/TotemRPLocalTrack.cc +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** - * - * This is a part of TOTEM offline software. - * Authors: - * Hubert Niewiadomski - * Jan Kašpar (jan.kaspar@gmail.com) - * - ****************************************************************************/ - -#include "DataFormats/CTPPSReco/interface/TotemRPLocalTrack.h" - -//---------------------------------------------------------------------------------------------------- - -TMatrixD TotemRPLocalTrack::trackPointInterpolationCovariance(double z) const -{ - TMatrixD h(2,4); - h(0,0)=1; - h(1,1)=1; - h(0,2)=z-z0_; - h(1,3)=z-z0_; - - TMatrixD cov_matr(dimension,dimension); - for(int i=0; i r.z0_) - return true; - - for (int i = 0; i < TotemRPLocalTrack::dimension; ++i) - { - if (l.track_params_vector_[i] < r.track_params_vector_[i]) - return true; - if (l.track_params_vector_[i] > r.track_params_vector_[i]) - return true; - } - - return false; -} diff --git a/DataFormats/CTPPSReco/src/TotemRPUVPattern.cc b/DataFormats/CTPPSReco/src/TotemRPUVPattern.cc deleted file mode 100644 index 10714d238b8..00000000000 --- a/DataFormats/CTPPSReco/src/TotemRPUVPattern.cc +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#include "DataFormats/CTPPSReco/interface/TotemRPUVPattern.h" - -//---------------------------------------------------------------------------------------------------- - -bool operator< (const TotemRPUVPattern &l, const TotemRPUVPattern &r) -{ - if (l.projection < r.projection) - return true; - if (l.projection > r.projection) - return false; - - if (l.a < r.a) - return true; - if (l.a > r.a) - return false; - - if (l.b < r.b) - return true; - if (l.b > r.b) - return false; - - if (l.w < r.w) - return true; - if (l.w > r.w) - return false; - - if (l.fittable < r.fittable) - return true; - if (l.fittable > r.fittable) - return false; - - return false; -} diff --git a/DataFormats/CTPPSReco/src/classes.h b/DataFormats/CTPPSReco/src/classes.h deleted file mode 100644 index ec09b18caa8..00000000000 --- a/DataFormats/CTPPSReco/src/classes.h +++ /dev/null @@ -1,39 +0,0 @@ -#include "DataFormats/Common/interface/Wrapper.h" -#include "DataFormats/Common/interface/DetSet.h" -#include "DataFormats/Common/interface/DetSetVector.h" - -#include "DataFormats/CTPPSReco/interface/TotemRPCluster.h" -#include "DataFormats/CTPPSReco/interface/TotemRPRecHit.h" -#include "DataFormats/CTPPSReco/interface/TotemRPUVPattern.h" -#include "DataFormats/CTPPSReco/interface/TotemRPLocalTrack.h" - -#include - -namespace { - namespace { - TotemRPRecHit rp_reco_hit; - edm::DetSet ds_rp_reco_hit; - edm::DetSetVector dsv_rp_reco_hit; - std::vector > sv_dsw_rp_reco_hit; - edm::Wrapper > w_dsv_rp_reco_hit; - std::vector sv_rp_reco_hit; - std::vector sv_cp_rp_reco_hit; - - TotemRPCluster dc; - edm::DetSet dsdc; - std::vector svdc; - std::vector > svdsdc; - edm::DetSetVector dsvdc; - edm::Wrapper > wdsvdc; - - TotemRPUVPattern pat; - edm::DetSetVector dsv_pat; - edm::Wrapper> w_dsv_pat; - - TotemRPLocalTrack ft; - edm::DetSetVector dsv_ft; - edm::Wrapper> w_dsv_ft; - edm::DetSetVector dsv_ft_frh; - edm::Wrapper> w_dsv_ft_frh; - } -} diff --git a/DataFormats/CTPPSReco/src/classes_def.xml b/DataFormats/CTPPSReco/src/classes_def.xml deleted file mode 100644 index 2bbac820c36..00000000000 --- a/DataFormats/CTPPSReco/src/classes_def.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/DataFormats/TotemDigi/BuildFile.xml b/DataFormats/TotemDigi/BuildFile.xml deleted file mode 100644 index 193dfc68b50..00000000000 --- a/DataFormats/TotemDigi/BuildFile.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/DataFormats/TotemDigi/interface/TotemFEDInfo.h b/DataFormats/TotemDigi/interface/TotemFEDInfo.h deleted file mode 100644 index cdd9213afe1..00000000000 --- a/DataFormats/TotemDigi/interface/TotemFEDInfo.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#ifndef DataFormats_TotemDigi_TotemFEDInfo -#define DataFormats_TotemDigi_TotemFEDInfo - -/** - * \brief OptoRx headers and footers. - **/ -class TotemFEDInfo -{ - public: - TotemFEDInfo(int _id=0) : fedId(_id), header(0), orbitCounter(0), footer(0) - { - } - - void setFEDId(int _f) { fedId = _f; } - int getFEDId() const { return fedId; } - - void setHeader(uint64_t _h) { header = _h; } - uint8_t getBOE() const { return (header >> 60) & 0xF; } - uint32_t getLV1() const { return (header >> 32) & 0xFFFFFF; } - uint16_t getBX() const { return (header >> 20) & 0xFFF; } - uint16_t getOptoRxId() const { return (header >> 8) & 0xFFF; } - uint8_t getFOV() const { return (header >> 4) & 0xF; } - uint8_t getH0() const { return (header >> 0) & 0xF; } - - void setOrbitCounter(uint32_t _oc) { orbitCounter = _oc; } - uint32_t getOrbitCounter() const { return orbitCounter; } - - void setFooter(uint64_t _f) { footer = _f; } - uint8_t getEOE() const { return (footer >> 60) & 0xF; } - uint16_t getFSize() const { return (footer >> 32) & 0x3FF; } - uint8_t getF0() const { return (footer >> 0) & 0xF; } - - private: - /// Id from FEDRawDataCollection. - int fedId; - - /// Data from OptoRx headers and footer. - uint64_t header; - uint32_t orbitCounter; - uint64_t footer; -}; - -#endif diff --git a/DataFormats/TotemDigi/interface/TotemRPDigi.h b/DataFormats/TotemDigi/interface/TotemRPDigi.h deleted file mode 100644 index bebb5ff2f9d..00000000000 --- a/DataFormats/TotemDigi/interface/TotemRPDigi.h +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Hubert Niewiadomski -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#ifndef DataFormats_TotemDigi_TotemRPDigi -#define DataFormats_TotemDigi_TotemRPDigi - -/** - * Digi structure for TOTEM RP silicon strip sensors. -**/ -class TotemRPDigi -{ - public: - TotemRPDigi(unsigned short strip_no=0) : strip_no_(strip_no) - { - }; - - unsigned short getStripNumber() const - { - return strip_no_; - } - - private: - /// index of the activated strip - unsigned short strip_no_; -}; - - -inline bool operator< (const TotemRPDigi& one, const TotemRPDigi& other) -{ - return one.getStripNumber() < other.getStripNumber(); -} - -#endif diff --git a/DataFormats/TotemDigi/interface/TotemTriggerCounters.h b/DataFormats/TotemDigi/interface/TotemTriggerCounters.h deleted file mode 100644 index 49edf9560cf..00000000000 --- a/DataFormats/TotemDigi/interface/TotemTriggerCounters.h +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************** -* -* This is a part of the TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#ifndef DataFormats_TotemDigi_TotemTriggerCounters -#define DataFormats_TotemDigi_TotemTriggerCounters - -/** - * Trigger counters from LoneG. -**/ -struct TotemTriggerCounters -{ - unsigned char type; - unsigned int event_num, bunch_num, src_id; - unsigned int orbit_num; - unsigned char revision_num; - unsigned int run_num, trigger_num, inhibited_triggers_num, input_status_bits; - - TotemTriggerCounters() : - type(0), - event_num(0), bunch_num(0), src_id(0), - orbit_num(0), - revision_num(0), - run_num(0), trigger_num(0), inhibited_triggers_num(0), input_status_bits(0) - { - } -}; - -#endif diff --git a/DataFormats/TotemDigi/interface/TotemVFATStatus.h b/DataFormats/TotemDigi/interface/TotemVFATStatus.h deleted file mode 100644 index 7dff9877cc4..00000000000 --- a/DataFormats/TotemDigi/interface/TotemVFATStatus.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Maciej Wróbel (wroblisko@gmail.com) -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#ifndef DataFormats_TotemDigi_TotemVFATStatus -#define DataFormats_TotemDigi_TotemVFATStatus - -#include -#include - -//---------------------------------------------------------------------------------------------------- - -/** - * Class which contains information about conversion from RAW to DIGI for a single read-out chip (VFAT). - */ -class TotemVFATStatus -{ - public: - TotemVFATStatus(uint8_t _cp = 0) : chipPosition(_cp), status(0), numberOfClustersSpecified(false), numberOfClusters(0) - { - } - - /// Chip position - inline uint8_t getChipPosition() const { return chipPosition; } - inline void setChipPosition(uint8_t _cp) { chipPosition = _cp; } - - /// VFAT is present in mapping but no data is present int raw event - inline bool isMissing() const { return status[0]; } - inline void setMissing(bool val = true) { status[0] = val; } - - /// 12-bit hw id from the header of the vfat frame is diffrent from the 16-bit one from hw mapping - inline bool isIDMismatch() const { return status[1]; } - inline void setIDMismatch(bool val = true) { status[1] = val; } - - /// Footprint error - inline bool isFootprintError() const { return status[2]; } - inline void setFootprintError(bool val = true) { status[2] = val; } - - /// CRC error - inline bool isCRCError() const { return status[3]; } - inline void setCRCError(bool val = true) { status[3] = val; } - - /// VFATFrame event number doesn't follow the number derived from DAQ - inline bool isECProgressError() const { return status[4]; } - inline void setECProgressError(bool val = true) { status[4] = val; } - - /// BC number is incorrect - inline bool isBCProgressError() const { return status[5]; } - inline void setBCProgressError(bool val = true) { status[5] = val; } - - /// All channels from that VFAT are not taken into account - inline bool isFullyMaskedOut() const { return status[6]; } - inline void setFullyMaskedOut() { status[6]=true; } - - /// Some channels from VFAT ale masked out, but not all - inline bool isPartiallyMaskedOut() const { return status[7]; } - inline void setPartiallyMaskedOut() { status[7]=true; } - - /// No channels are masked out - inline bool isNotMasked() const { return !(status[6] || status[7]); } - inline void setNotMasked() { status[6]=status[7]=false; } - - bool isOK() const - { - return !(status[0] || status[1] || status[2] || status[3] || status[4] || status[5]); - } - - /// number of clusters - inline bool isNumberOfClustersSpecified() const { return numberOfClustersSpecified; } - inline void setNumberOfClustersSpecified(bool v) { numberOfClustersSpecified = v; } - - inline uint8_t getNumberOfClusters() const { return numberOfClusters; } - inline void setNumberOfClusters(uint8_t v) { numberOfClusters = v; } - - bool operator < (const TotemVFATStatus &cmp) const - { - return (status.to_ulong() < cmp.status.to_ulong()); - } - - friend std::ostream& operator << (std::ostream& s, const TotemVFATStatus &st); - - private: - /// describes placement of the VFAT within the detector - uint8_t chipPosition; - - /// the status bits - std::bitset<8> status; - - /// the number of hit clusters before DAQ trimming - bool numberOfClustersSpecified; - uint8_t numberOfClusters; -}; - -#endif diff --git a/DataFormats/TotemDigi/src/TotemVFATStatus.cc b/DataFormats/TotemDigi/src/TotemVFATStatus.cc deleted file mode 100644 index 45279e653d1..00000000000 --- a/DataFormats/TotemDigi/src/TotemVFATStatus.cc +++ /dev/null @@ -1,25 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Maciej Wróbel (wroblisko@gmail.com) -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#include "DataFormats/TotemDigi/interface/TotemVFATStatus.h" - -#include - -std::ostream& operator << (std::ostream& s, const TotemVFATStatus &st) -{ - return s - << "miss=" << st.status[0] - << ",ID=" << st.status[1] - << ",foot=" << st.status[2] - << ",CRC=" << st.status[3] - << ",EC=" << st.status[4] - << ",BC=" << st.status[5] - << ",fm=" << st.status[6] - << ",pm=" << st.status[7]; -} diff --git a/DataFormats/TotemDigi/src/classes.h b/DataFormats/TotemDigi/src/classes.h deleted file mode 100644 index 3d4c0f35c4f..00000000000 --- a/DataFormats/TotemDigi/src/classes.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -* -* This is a part of the TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#include "DataFormats/Common/interface/Wrapper.h" -#include "DataFormats/Common/interface/DetSet.h" -#include "DataFormats/Common/interface/DetSetVector.h" - -#include "DataFormats/TotemDigi/interface/TotemRPDigi.h" -#include "DataFormats/TotemDigi/interface/TotemTriggerCounters.h" -#include "DataFormats/TotemDigi/interface/TotemVFATStatus.h" -#include "DataFormats/TotemDigi/interface/TotemFEDInfo.h" - -#include - -namespace { - namespace { - TotemRPDigi rp_str_dig; - edm::DetSet ds_rp_str_dig; - std::vector vec_rp_str_dig; - edm::DetSetVector dsv_rp_str_dig; - std::vector > vec_ds_rp_str_dig; - edm::Wrapper > wds_rp_str_dig; - edm::Wrapper > wdsv_rp_str_dig; - - TotemTriggerCounters dummy10; - edm::Wrapper dummy11; - - std::map dummy27; - - TotemVFATStatus dummy30; - edm::Wrapper< TotemVFATStatus > dummy31; - edm::DetSetVector dummy32; - edm::Wrapper< edm::DetSetVector > dummy33; - - std::bitset<8> dummy50; - edm::Wrapper< std::bitset<8> > dummy51; - - TotemFEDInfo fi; - std::vector v_fi; - edm::Wrapper> w_v_fi; - } -} diff --git a/DataFormats/TotemDigi/src/classes_def.xml b/DataFormats/TotemDigi/src/classes_def.xml deleted file mode 100644 index 10b5cb6a4ad..00000000000 --- a/DataFormats/TotemDigi/src/classes_def.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/DataFormats/TotemRPDetId/BuildFile.xml b/DataFormats/TotemRPDetId/BuildFile.xml deleted file mode 100644 index 83a0e6456c3..00000000000 --- a/DataFormats/TotemRPDetId/BuildFile.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/DataFormats/TotemRPDetId/interface/TotemRPDetId.h b/DataFormats/TotemRPDetId/interface/TotemRPDetId.h deleted file mode 100644 index e97a5723d86..00000000000 --- a/DataFormats/TotemRPDetId/interface/TotemRPDetId.h +++ /dev/null @@ -1,203 +0,0 @@ -/**************************************************************************** - * - * This is a part of TOTEM offline software. - * Authors: - * Hubert Niewiadomski - * Jan Kašpar (jan.kaspar@gmail.com) - * - ****************************************************************************/ - -#ifndef DataFormats_TotemRPDetId_TotemRPDetId -#define DataFormats_TotemRPDetId_TotemRPDetId - -#include "DataFormats/DetId/interface/DetId.h" - -#include "FWCore/Utilities/interface/Exception.h" - -#include -#include -#include - -/** - *\brief Roman Pot detector ID. - * - * There are 3 types of IDs used in CMSSW in the context of RP. - * \li "class ID" - this class TotemRPDetId, a daughter of DetId - * \li "raw ID" - unsigned int, the result of rawId() method - * \li "decimal or symbolic ID" - 4 decimal digit unsigned int, |arm|station|RP|det| - * - * The structure of the raw ID is the following (based on the concept of the DetId) - * Bit 24 = Arm: 1=z>0 0=z<0 - * Bits [22:23] Station - * Bits [19:21] Roman Pot number - * Bits [15:18] Si det. number - * - * The advantage of the symbolic ID is that it is easily readable and that it can address most of the elements int the RP subdetector system: - * chip ID = |arm|station|RP|det|VFAT|, ie. 5-digit decimal number (possibly with leading zeros)\n - * detector ID = |arm|station|RP|det|\n - * Roman Pot ID = |arm|station|RP|\n - * station ID = |arm|station|\n - * arm ID = |arm|\n - * where - * \li arm = 0 (left, i.e. z < 0), 1 (right) - * \li station = 0 (210m), 2 (220m) - * \li RP = 0 - 5; 0+1 vertical pots (lower |z|), 2+3 horizontal pots, 4+5 vertical pots (higher |z|) - * \li det = 0 - 9 (0th det has the lowest |z|) - * \li VFAT = 0 - 4 - * - * Moreover there is an official naming scheme (EDMS 906715). It is supported by the ...Name() methods. -**/ - -class TotemRPDetId : public DetId -{ - public: - TotemRPDetId(); - - /// Construct from a raw id. It is required that the Detector part of - /// id is Totem and the SubDet part is RP, otherwise an exception is thrown. - explicit TotemRPDetId(uint32_t id); - - /// Construct from fully qualified identifier. - TotemRPDetId(unsigned int Arm, unsigned int Station, unsigned int RomanPot, unsigned int Detector); - - static const unsigned int totem_rp_subdet_id = 3; - - static const unsigned int startArmBit = 24, maskArm = 0x1, maxArm = 1; - static const unsigned int startStationBit = 22, maskStation = 0x3, maxStation = 2; - static const unsigned int startRPBit = 19, maskRP = 0x7, maxRP = 5; - static const unsigned int startDetBit = 15, maskDet = 0xF, maxDet = 9; - - inline int arm() const - { - return int ((id_>>startArmBit) & maskArm); - } - - inline int station() const - { - return int ((id_>>startStationBit) & maskStation); - } - - inline int romanPot() const - { - return int ((id_>>startRPBit) & maskRP); - } - - inline int detector() const - { - return int ((id_>>startDetBit) & maskDet); - } - - int rpCopyNumber() const - { - return romanPot() + 10*station() + 100*arm(); - } - - bool isStripsCoordinateUDirection() const - { - return detector()%2; - } - - bool isStripsCoordinateVDirection() const - { - return !isStripsCoordinateUDirection(); - } - - inline unsigned int detectorDecId() const - { - return detector() + romanPot()*10 + station()*100 + arm()*1000; - } - - //-------------------------------- static members --------------------------------------- - - /// returs true it the raw ID is a TOTEM RP one - static bool check(unsigned int raw) - { - return ((raw >> DetId::kDetOffset) & 0xF) == DetId::VeryForward && - ((raw >> DetId::kSubdetOffset) & 0x7) == totem_rp_subdet_id; - } - - /// fast conversion Raw to Decimal ID - static unsigned int rawToDecId(unsigned int raw) - { - return ((raw >> startArmBit) & maskArm) * 1000 - + ((raw >> startStationBit) & maskStation) * 100 - + ((raw >> startRPBit) & maskRP) * 10 - + ((raw >> startDetBit) & maskDet); - } - - /// fast conversion Decimal to Raw ID - static unsigned int decToRawId(unsigned int dec) - { - unsigned int i = (DetId::VeryForward << DetId::kDetOffset) | (totem_rp_subdet_id << DetId::kSubdetOffset); - i &= 0xFE000000; - i |= ((dec % 10) & maskDet) << startDetBit; dec /= 10; - i |= ((dec % 10) & maskRP) << startRPBit; dec /= 10; - i |= ((dec % 10) & maskStation) << startStationBit; dec /= 10; - i |= ((dec % 10) & maskArm) << startArmBit; - return i; - } - - /// returns ID of RP for given detector ID ''i'' - static unsigned int rpOfDet(unsigned int i) { return i / 10; } - - /// returns ID of station for given detector ID ''i'' - static unsigned int stOfDet(unsigned int i) { return i / 100; } - - /// returns ID of arm for given detector ID ''i'' - static unsigned int armOfDet(unsigned int i) { return i / 1000; } - - /// returns ID of station for given RP ID ''i'' - static unsigned int stOfRP(unsigned int i) { return i / 10; } - - /// returns ID of arm for given RP ID ''i'' - static unsigned int armOfRP(unsigned int i) { return i / 100; } - - /// returns ID of arm for given station ID ''i'' - static unsigned int armOfSt(unsigned int i) { return i / 10; } - - - /// is Detector u-detector? - /// expect symbolic/decimal ID - static bool isStripsCoordinateUDirection(int Detector) - { - return Detector%2; - } - - - /// type of name returned by *Name functions - enum NameFlag {nShort, nFull, nPath}; - - /// level identifier in the RP hierarchy - enum ElementLevel {lSystem, lArm, lStation, lRP, lPlane, lChip, lStrip}; - - /// returns the name of the RP system - static std::string systemName(NameFlag flag = nFull); - - /// returns official name of an arm characterized by ''id''; if ''full'' is true, prefix rp_ added - static std::string armName(unsigned int id, NameFlag flag = nFull); - - /// returns official name of a station characterized by ''id''; if ''full'' is true, name of arm is prefixed - static std::string stationName(unsigned int id, NameFlag flag = nFull); - - /// returns official name of a RP characterized by ''id''; if ''full'' is true, name of station is prefixed - static std::string rpName(unsigned int id, NameFlag flag = nFull); - - /// returns official name of a plane characterized by ''id''; if ''full'' is true, name of RP is prefixed - static std::string planeName(unsigned int id, NameFlag flag = nFull); - - /// returns official name of a chip characterized by ''id''; if ''full'' is true, name of plane is prefixed - static std::string chipName(unsigned int id, NameFlag flag = nFull); - - /// returns official name of a strip characterized by ''id'' (of chip) and strip number; if ''full'' is true, name of chip is prefixed - static std::string stripName(unsigned int id, unsigned char strip, NameFlag flag = nFull); - - /// shortcut to use any of the *Name methods, given the ElementLevel - static std::string officialName(ElementLevel level, unsigned int id, NameFlag flag = nFull, unsigned char strip = 0); - - private: - inline void init(unsigned int Arm, unsigned int Station, unsigned int RomanPot, unsigned int Detector); -}; - -std::ostream& operator<<(std::ostream& os, const TotemRPDetId& id); - -#endif diff --git a/DataFormats/TotemRPDetId/src/TotemRPDetId.cc b/DataFormats/TotemRPDetId/src/TotemRPDetId.cc deleted file mode 100644 index ea4e4b0e645..00000000000 --- a/DataFormats/TotemRPDetId/src/TotemRPDetId.cc +++ /dev/null @@ -1,192 +0,0 @@ -/**************************************************************************** - * - * This is a part of TOTEM offline software. - * Authors: - * Hubert Niewiadomski - * Jan Kašpar (jan.kaspar@gmail.com) - * - ****************************************************************************/ - - -#include "DataFormats/TotemRPDetId/interface/TotemRPDetId.h" -#include "FWCore/Utilities/interface/Exception.h" - -using namespace std; - -//---------------------------------------------------------------------------------------------------- - -TotemRPDetId::TotemRPDetId() : DetId(DetId::VeryForward, totem_rp_subdet_id) -{ -} - -//---------------------------------------------------------------------------------------------------- - -TotemRPDetId::TotemRPDetId(uint32_t id) : DetId(id) -{ - if (! check(id)) - { - throw cms::Exception("InvalidDetId") << "TotemRPDetId ctor:" - << " det: " << det() - << " subdet: " << subdetId() - << " is not a valid Totem RP id"; - } -} - -//---------------------------------------------------------------------------------------------------- - -void TotemRPDetId::init(unsigned int Arm, unsigned int Station, unsigned int RomanPot, unsigned int Detector) -{ - if (Arm > maxArm || Station > maxStation || RomanPot > maxRP || Detector > maxDet) - { - throw cms::Exception("InvalidDetId") << "TotemRPDetId ctor:" - << " Invalid parameters: " - << " Arm "<init(Arm, Station, RomanPot, Detector); -} - -//---------------------------------------------------------------------------------------------------- - -std::ostream& operator<<( std::ostream& os, const TotemRPDetId& id ) -{ - os << " Arm "< - - - - diff --git a/EventFilter/TotemRawToDigi/BuildFile.xml b/EventFilter/TotemRawToDigi/BuildFile.xml deleted file mode 100644 index 6de7cbdc886..00000000000 --- a/EventFilter/TotemRawToDigi/BuildFile.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/EventFilter/TotemRawToDigi/interface/CounterChecker.h b/EventFilter/TotemRawToDigi/interface/CounterChecker.h deleted file mode 100644 index 65a17b3cabc..00000000000 --- a/EventFilter/TotemRawToDigi/interface/CounterChecker.h +++ /dev/null @@ -1,146 +0,0 @@ -/**************************************************************************** - * - * This is a part of the TOTEM offline software. - * Authors: - * Maciej Wróbel (wroblisko@gmail.com) - * Jan Kašpar (jan.kaspar@gmail.com) - * - ****************************************************************************/ - -#ifndef EventFilter_TotemRawToDigi_CounterChecker -#define EventFilter_TotemRawToDigi_CounterChecker - -#include -#include -#include -#include - -#include "CondFormats/TotemReadoutObjects/interface/TotemFramePosition.h" - -#include "DataFormats/TotemDigi/interface/TotemVFATStatus.h" - -//---------------------------------------------------------------------------------------------------- - -/** - *\brief Class for finding the most popular both EC and BC counter, and filling the conversion - * status 'wrong EC/BC number' for frames with different value. - */ -class CounterChecker -{ - public: - typedef unsigned short word; - - typedef std::map > CounterMap; - - enum CheckerType {BCChecker, ECChecker}; - - /** - * \param t: CounterChecker::ECCounter or CounterChecker::BCCounter. On that, depends whether - * checker will fill wrong EC or BC rogress error. - * \param name: name - * \param min: minimal required number of frames to search for the most frequent one - */ - CounterChecker(CheckerType _type = CounterChecker::BCChecker, const std::string &_name="", - unsigned int _min=0, double _fraction=0., unsigned int _verbosity=0) : type(_type), - name(_name), min(_min), fraction(_fraction), verbosity(_verbosity) {} - - /// add new value to map, counter takes value of EC or BC number - void Fill(word counter, TotemFramePosition fr); - - /// summarizes and fill the status (wrong EC and BC progress error for some frames) - template - void Analyze(T &status, bool error, std::ostream &es); - - private: - class Comparer - { - public: - typedef unsigned short word; - bool operator()(const std::pair > &a, const std::pair > &b) - { - return a.second.size() < b.second.size(); - } - }; - - /// counter value -> list of frames with this value - CounterMap relationMap; - - /// EC or BC counter checker - CheckerType type; - - /// the name of this check, used in error messages - std::string name; - - /// minimal required number of frames to search for the most frequent one - unsigned int min; - - /// the most frequent value is accepted only provided its sub-sample size is greater than the - /// specified fraction of the full sample - double fraction; - - /// level of verbosity - unsigned int verbosity; -}; - -//------------------------------------------------------------------------------------------------- - -template -void CounterChecker::Analyze(T &status, bool error, std::ostream &es) -{ - word mostFrequentCounter = 0; - word mostFrequentSize = 0; - unsigned int totalFrames = 0; - - // finding the most frequent counter - for (CounterMap::iterator iter = relationMap.begin(); iter != relationMap.end(); iter++) - { - unsigned int iterSize = iter->second.size(); - totalFrames += iterSize; - - if (iterSize > mostFrequentSize) - { - mostFrequentCounter = iter->first; - mostFrequentSize = iter->second.size(); - } - } - - if (totalFrames < min) - { - if (verbosity > 0) - es << "Too few frames to determine the most frequent " << name << " value."; - - return; - } - - // if there are too few frames with the most frequent value - if ((float)mostFrequentSize/(float)totalFrames < fraction) - { - if (verbosity > 0) - es << " The most frequent " << name << " value is doubtful - variance is too high."; - - return; - } - - for (CounterMap::iterator iter = relationMap.begin(); iter != relationMap.end(); iter++) - { - if (iter->first != mostFrequentCounter) - { - for (std::vector::iterator fr = iter->second.begin(); fr != iter->second.end(); fr++) - { - if (error) - { - if (type == ECChecker) - status[*fr].status.setECProgressError(); - if (type == BCChecker) - status[*fr].status.setBCProgressError(); - } - - if (verbosity > 0) - es << " Frame at " << *fr << ": " << name << " number " << iter->first - << " is different from the most frequent one " << mostFrequentCounter << std::endl; - } - } - } -} - -#endif diff --git a/EventFilter/TotemRawToDigi/interface/RawDataUnpacker.h b/EventFilter/TotemRawToDigi/interface/RawDataUnpacker.h deleted file mode 100644 index 0ec0a443a0f..00000000000 --- a/EventFilter/TotemRawToDigi/interface/RawDataUnpacker.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -* -* This is a part of the TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#ifndef EventFilter_TotemRawToDigi_RawDataUnpacker -#define EventFilter_TotemRawToDigi_RawDataUnpacker - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "DataFormats/FEDRawData/interface/FEDRawData.h" -#include "DataFormats/TotemDigi/interface/TotemFEDInfo.h" - -#include "EventFilter/TotemRawToDigi/interface/VFATFrameCollection.h" -#include "EventFilter/TotemRawToDigi/interface/SimpleVFATFrameCollection.h" - -//---------------------------------------------------------------------------------------------------- - -/// \brief Collection of code for unpacking of TOTEM raw-data. -class RawDataUnpacker -{ - public: - typedef uint64_t word; - - /// VFAT transmission modes - enum { vmCluster = 0x80, vmRaw = 0x90 }; - - RawDataUnpacker() {} - - RawDataUnpacker(const edm::ParameterSet &conf); - - /// Unpack data from FED with fedId into `coll' collection. - int Run(int fedId, const FEDRawData &data, std::vector &fedInfoColl, SimpleVFATFrameCollection &coll) const; - - /// Process one Opto-Rx (or LoneG) frame. - int ProcessOptoRxFrame(const word *buf, unsigned int frameSize, TotemFEDInfo &fedInfo, SimpleVFATFrameCollection *fc) const; - - /// Process one Opto-Rx frame in serial (old) format - int ProcessOptoRxFrameSerial(const word *buffer, unsigned int frameSize, SimpleVFATFrameCollection *fc) const; - - /// Process one Opto-Rx frame in parallel (new) format - int ProcessOptoRxFrameParallel(const word *buffer, unsigned int frameSize, TotemFEDInfo &fedInfo, SimpleVFATFrameCollection *fc) const; - - /// Process data from one VFAT in parallel (new) format - int ProcessVFATDataParallel(const uint16_t *buf, unsigned int OptoRxId, SimpleVFATFrameCollection *fc) const; -}; - -#endif diff --git a/EventFilter/TotemRawToDigi/interface/RawToDigiConverter.h b/EventFilter/TotemRawToDigi/interface/RawToDigiConverter.h deleted file mode 100644 index ec886b8754f..00000000000 --- a/EventFilter/TotemRawToDigi/interface/RawToDigiConverter.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -* -* This is a part of the TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#ifndef EventFilter_TotemRawToDigi_RawToDigiConverter -#define EventFilter_TotemRawToDigi_RawToDigiConverter - -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "DataFormats/Common/interface/DetSetVector.h" - -#include "EventFilter/TotemRawToDigi/interface/VFATFrameCollection.h" - -#include "CondFormats/TotemReadoutObjects/interface/TotemDAQMapping.h" -#include "CondFormats/TotemReadoutObjects/interface/TotemAnalysisMask.h" - -#include "DataFormats/TotemDigi/interface/TotemRPDigi.h" -#include "DataFormats/TotemDigi/interface/TotemVFATStatus.h" - -//---------------------------------------------------------------------------------------------------- - -/// \brief Collection of code to convert TOTEM raw data into digi. -class RawToDigiConverter -{ - public: - RawToDigiConverter(const edm::ParameterSet &conf); - - /// Creates RP digi. - void Run(const VFATFrameCollection &coll, const TotemDAQMapping &mapping, const TotemAnalysisMask &mask, - edm::DetSetVector &digi, edm::DetSetVector &status); - - /// Print error summaries. - void PrintSummaries(); - - private: - struct Record - { - const TotemVFATInfo *info; - const VFATFrame *frame; - TotemVFATStatus status; - }; - - unsigned char verbosity; - - unsigned int printErrorSummary; - unsigned int printUnknownFrameSummary; - - enum TestFlag { tfNoTest, tfWarn, tfErr }; - - /// flags for which tests to run - unsigned int testFootprint; - unsigned int testCRC; - unsigned int testID; - unsigned int testECRaw; - unsigned int testECDAQ; - unsigned int testECMostFrequent; - unsigned int testBCMostFrequent; - - /// the minimal required number of frames to determine the most frequent counter value - unsigned int EC_min, BC_min; - - /// the minimal required (relative) occupancy of the most frequent counter value to be accepted - double EC_fraction, BC_fraction; - - /// error summaries - std::map > errorSummary; - std::map unknownSummary; - - /// Common processing for all VFAT based sub-systems. - void RunCommon(const VFATFrameCollection &input, const TotemDAQMapping &mapping, - std::map &records); -}; - -#endif diff --git a/EventFilter/TotemRawToDigi/interface/SimpleVFATFrameCollection.h b/EventFilter/TotemRawToDigi/interface/SimpleVFATFrameCollection.h deleted file mode 100644 index 9c9ed7301e1..00000000000 --- a/EventFilter/TotemRawToDigi/interface/SimpleVFATFrameCollection.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -* -* This is a part of the TOTEM offline software. -* Authors: -* Mate Csanad (mate.csanad@cern.ch) -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - - -#ifndef EventFilter_TotemRawToDigi_SimpleVFATFrameCollection -#define EventFilter_TotemRawToDigi_SimpleVFATFrameCollection - -#include "EventFilter/TotemRawToDigi/interface/VFATFrameCollection.h" - -#include - -/** - * A basic implementation of VFAT frame collection, as map: TotemFramePosition --> VFATFrame. -**/ -class SimpleVFATFrameCollection : public VFATFrameCollection -{ - protected: - typedef std::map MapType; - - MapType data; - - virtual value_type BeginIterator() const; - virtual value_type NextIterator(const value_type&) const; - virtual bool IsEndIterator(const value_type&) const; - - public: - SimpleVFATFrameCollection(); - ~SimpleVFATFrameCollection(); - - const VFATFrame* GetFrameByID(unsigned int ID) const; - const VFATFrame* GetFrameByIndex(TotemFramePosition index) const; - - virtual unsigned int Size() const - { - return data.size(); - } - - virtual bool Empty() const - { - return (data.size() == 0); - } - - void Insert(const TotemFramePosition &index, const VFATFrame &frame) - { - data.insert({index, frame}); - } - - /// inserts an empty (default) frame to the given position and returns pointer to the frame - VFATFrame* InsertEmptyFrame(TotemFramePosition index) - { - return &data.insert({index, VFATFrame()}).first->second; - } - - /// cleans completely the collection - void Clear() - { - data.clear(); - } -}; - -#endif diff --git a/EventFilter/TotemRawToDigi/interface/VFATFrame.h b/EventFilter/TotemRawToDigi/interface/VFATFrame.h deleted file mode 100644 index 60d0e70faaa..00000000000 --- a/EventFilter/TotemRawToDigi/interface/VFATFrame.h +++ /dev/null @@ -1,187 +0,0 @@ -/********************************************************** -* -* This is a part of the TOTEM offline software. -* Authors: -* Jan Kaspar (jan.kaspar@gmail.com) -* -**********************************************************/ - -#ifndef EventFilter_TotemRawToDigi_VFATFrame -#define EventFilter_TotemRawToDigi_VFATFrame - -#include -#include -#include - -/** - * Representation of VFAT frame plus extra info added by DAQ. -**/ -class VFATFrame -{ - public: - typedef uint16_t word; - - public: - VFATFrame(const word* _data = NULL); - - VFATFrame(const VFATFrame& copy) - { - setData(copy.data); - presenceFlags = copy.presenceFlags; - daqErrorFlags = copy.daqErrorFlags; - numberOfClusters = copy.numberOfClusters; - } - - virtual ~VFATFrame() {} - - /// Copies a memory block to data buffer. - void setData(const word *_data); - - VFATFrame::word* getData() - { - return data; - } - - /// Returns Bunch Crossing number (BC<11:0>). - VFATFrame::word getBC() const - { - return data[11] & 0x0FFF; - } - - /// Returns Event Counter (EV<7:0>). - VFATFrame::word getEC() const - { - return (data[10] & 0x0FF0) >> 4; - } - - /// Returns flags. - VFATFrame::word getFlags() const - { - return data[10] & 0x000F; - } - - /// Returns ChipID (ChipID<11:0>). - VFATFrame::word getChipID() const - { - return data[9] & 0x0FFF; - } - - /// Returns the CRC. - VFATFrame::word getCRC() const - { - return data[0]; - } - - /// Sets presence flags. - void setPresenceFlags(uint8_t v) - { - presenceFlags = v; - } - - /// Returns true if the BC word is present in the frame. - bool isBCPresent() const - { - return presenceFlags & 0x1; - } - - /// Returns true if the EC word is present in the frame. - bool isECPresent() const - { - return presenceFlags & 0x2; - } - - /// Returns true if the ID word is present in the frame. - bool isIDPresent() const - { - return presenceFlags & 0x4; - } - - /// Returns true if the CRC word is present in the frame. - bool isCRCPresent() const - { - return presenceFlags & 0x8; - } - - /// Returns true if the CRC word is present in the frame. - bool isNumberOfClustersPresent() const - { - return presenceFlags & 0x10; - } - - /// Sets DAQ error flags. - void setDAQErrorFlags(uint8_t v) - { - daqErrorFlags = v; - } - - void setNumberOfClusters(uint8_t v) - { - numberOfClusters = v; - } - - /// Returns the number of clusters as given by the "0xD0 frame". - /// Returns 0, if not available. - uint8_t getNumberOfClusters() const - { - return numberOfClusters; - } - - /// Checks the fixed bits in the frame. - /// Returns false if any of the groups (in BC, EC and ID words) is present but wrong. - bool checkFootprint() const; - - /// Checks the validity of frame (CRC and daqErrorFlags). - /// Returns false if daqErrorFlags is non-zero. - /// Returns false if the CRC is present and invalid. - virtual bool checkCRC() const; - - /// Checks if channel number 'channel' was active. - /// Returns positive number if it was active, 0 otherwise. - virtual bool channelActive(unsigned char channel) const - { - return ( data[1 + (channel / 16)] & (1 << (channel % 16)) ) ? 1 : 0; - } - - /// Returns list of active channels. - /// It's more efficient than the channelActive(char) for events with low channel occupancy. - virtual std::vector getActiveChannels() const; - - /// Prints the frame. - /// If binary is true, binary format is used. - void Print(bool binary = false) const; - - private: - /** Raw data frame as sent by electronics. - * The container is organized as follows (reversed Figure 8 at page 23 of VFAT2 manual): - * \verbatim - * buffer index content size - * --------------------------------------------------------------- - * 0 CRC 16 bits - * 1->8 Channel data 128 bits, channel 0 first - * 9 ChipID 4 constant bits (1110) + 12 bits - * 10 EC, Flags 4 constant bits (1100) + 8, 4 bits - * 11 BC 4 constant bits (1010) + 12 bits - * \endverbatim - **/ - word data[12]; - - /// Flag indicating the presence of various components. - /// bit 1: "BC word" (buffer index 11) - /// bit 2: "EC word" (buffer index 10) - /// bit 3: "ID word" (buffer index 9) - /// bit 4: "CRC word" (buffer index 0) - /// bit 5: "number of clusters word" (prefix 0xD0) - uint8_t presenceFlags; - - /// Error flag as given by certain versions of DAQ. - uint8_t daqErrorFlags; - - /// Number of clusters. - /// Only available in cluster mode and if the number of clusters exceeds a limit (10). - uint8_t numberOfClusters; - - /// internaly used to check CRC - static word calculateCRC(word crc_in, word dato); -}; - -#endif diff --git a/EventFilter/TotemRawToDigi/interface/VFATFrameCollection.h b/EventFilter/TotemRawToDigi/interface/VFATFrameCollection.h deleted file mode 100644 index 7fa3284fc09..00000000000 --- a/EventFilter/TotemRawToDigi/interface/VFATFrameCollection.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -* -* This is a part of the TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - - -#ifndef EventFilter_TotemRawToDigi_VFATFrameCollection -#define EventFilter_TotemRawToDigi_VFATFrameCollection - -#include "CondFormats/TotemReadoutObjects/interface/TotemFramePosition.h" - -#include "EventFilter/TotemRawToDigi/interface/VFATFrame.h" - -#include - -/** - * Interface class for VFAT-frame collections. -**/ -class VFATFrameCollection -{ - public: - VFATFrameCollection() {} - virtual ~VFATFrameCollection() {} - - /// returns pointer to frame with ID, performs NO duplicity check (if there is precisely one frame with this 12bit ID) - virtual const VFATFrame* GetFrameByID(unsigned int ID) const = 0; - - /// returns frame at given position in Slink frame - virtual const VFATFrame* GetFrameByIndex(TotemFramePosition index) const = 0; - - /// returns frame at given position in Slink frame and checks 12bit ID - virtual const VFATFrame* GetFrameByIndexID(TotemFramePosition index, unsigned int ID); - - /// return the number of VFAT frames in the collection - virtual unsigned int Size() const = 0; - - /// returns whether the collection is empty - virtual bool Empty() const = 0; - - /// pair: frame DAQ position, frame data - typedef std::pair value_type; - - /// the VFATFrameCollection interator - class Iterator { - protected: - /// interator value - value_type value; - - /// the pointer to the collection - const VFATFrameCollection* collection; - - public: - /// constructor, automatically sets the iterator to the beginning - Iterator(const VFATFrameCollection* c = NULL) : collection(c) - { if (collection) value = collection->BeginIterator(); } - - /// returns the DAQ position of the current element - TotemFramePosition Position() - { return value.first; } - - /// returns the frame data of the current element - const VFATFrame* Data() - { return value.second; } - - /// shifts the iterator - void Next() - { value = collection->NextIterator(value); } - - /// returns whether the iterator points over the end of the collection - bool IsEnd() - { return collection->IsEndIterator(value); } - }; - - protected: - /// returns the beginning of the collection - virtual value_type BeginIterator() const = 0; - - /// shifts the iterator - virtual value_type NextIterator(const value_type&) const = 0; - - /// checks whether the iterator points over the end of the collection - virtual bool IsEndIterator(const value_type&) const = 0; -}; - -#endif diff --git a/EventFilter/TotemRawToDigi/plugins/BuildFile.xml b/EventFilter/TotemRawToDigi/plugins/BuildFile.xml deleted file mode 100644 index 27b7f2b5f40..00000000000 --- a/EventFilter/TotemRawToDigi/plugins/BuildFile.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/EventFilter/TotemRawToDigi/plugins/TotemTriggerRawToDigi.cc b/EventFilter/TotemRawToDigi/plugins/TotemTriggerRawToDigi.cc deleted file mode 100644 index ab930e92267..00000000000 --- a/EventFilter/TotemRawToDigi/plugins/TotemTriggerRawToDigi.cc +++ /dev/null @@ -1,144 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#include "FWCore/Framework/interface/stream/EDProducer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Utilities/interface/InputTag.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/EventSetup.h" - -#include "DataFormats/FEDRawData/interface/FEDRawData.h" -#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" -#include "DataFormats/FEDRawData/interface/FEDNumbering.h" - -#include "DataFormats/TotemDigi/interface/TotemTriggerCounters.h" - -#include -#include - -//---------------------------------------------------------------------------------------------------- - -class TotemTriggerRawToDigi : public edm::stream::EDProducer<> -{ - public: - explicit TotemTriggerRawToDigi(const edm::ParameterSet&); - ~TotemTriggerRawToDigi(); - - virtual void produce(edm::Event&, const edm::EventSetup&) override; - - private: - unsigned int fedId; - - edm::EDGetTokenT fedDataToken; - - /// Process one LoneG frame. - int ProcessLoneGFrame(uint64_t *oBuf, unsigned long size, TotemTriggerCounters &data); -}; - -//---------------------------------------------------------------------------------------------------- - -using namespace edm; -using namespace std; - -//---------------------------------------------------------------------------------------------------- - -TotemTriggerRawToDigi::TotemTriggerRawToDigi(const edm::ParameterSet &conf): - fedId(conf.getParameter("fedId")) -{ - fedDataToken = consumes(conf.getParameter("rawDataTag")); - - if (fedId == 0) - fedId = FEDNumbering::MINTotemTriggerFEDID; - - produces(); -} - -//---------------------------------------------------------------------------------------------------- - -TotemTriggerRawToDigi::~TotemTriggerRawToDigi() -{ -} - -//---------------------------------------------------------------------------------------------------- - -void TotemTriggerRawToDigi::produce(edm::Event& event, const edm::EventSetup &es) -{ - // raw data handle - edm::Handle rawData; - event.getByToken(fedDataToken, rawData); - - // book output products - TotemTriggerCounters totemTriggerCounters; - - // unpack trigger data - const FEDRawData &data = rawData->FEDData(fedId); - uint64_t *buf = (uint64_t *) data.data(); - unsigned int sizeInWords = data.size() / 8; // bytes -> words - if (data.size() > 0) - ProcessLoneGFrame(buf + 2, sizeInWords - 4, totemTriggerCounters); - - // commit products to event - event.put(make_unique(totemTriggerCounters)); -} - -//---------------------------------------------------------------------------------------------------- - -int TotemTriggerRawToDigi::ProcessLoneGFrame(uint64_t *oBuf, unsigned long size, TotemTriggerCounters &td) -{ - if (size != 20) - { - LogProblem("Totem") << "Error in TotemTriggerRawToDigi::ProcessLoneGFrame > " << - "Wrong LoneG frame size: " << size << " (shall be 20)." << endl; - return 1; - } - - // buffer mapping: OptoRx buffer --> LoneG buffer - uint64_t buf[5]; - for (unsigned int i = 0; i < 5; i++) - buf[i] = 0; - - for (unsigned int i = 0; i < 20; i++) - { - int row = i / 4; - int col = i % 4; - buf[row] |= (oBuf[i] & 0xFFFF) << (col * 16); - } - - td.type = (buf[0] >> 56) & 0xF; - td.event_num = (buf[0] >> 32) & 0xFFFFFF; - td.bunch_num = (buf[0] >> 20) & 0xFFF; - td.src_id = (buf[0] >> 8) & 0xFFF; - - td.orbit_num = (buf[1] >> 32) & 0xFFFFFFFF; - td.revision_num = (buf[1] >> 24) & 0xFF; - - td.run_num = (buf[2] >> 32) & 0xFFFFFFFF; - td.trigger_num = (buf[2] >> 0) & 0xFFFFFFFF; - - td.inhibited_triggers_num = (buf[3] >> 32) & 0xFFFFFFFF; - td.input_status_bits = (buf[3] >> 0) & 0xFFFFFFFF; - -#ifdef DEBUG - printf(">> RawDataUnpacker::ProcessLoneGFrame > size = %li\n", size); - printf("\ttype = %x, event number = %x, bunch number = %x, id = %x\n", - td.type, td.event_num, td.bunch_num, td.src_id); - printf("\torbit number = %x, revision = %x\n", - td.orbit_num, td.revision_num); - printf("\trun number = %x, trigger number = %x\n", - td.run_num, td.trigger_num); - printf("\tinhibited triggers = %x, input status bits = %x\n", - td.inhibited_triggers_num, td.input_status_bits); -#endif - - return 0; -} - -//---------------------------------------------------------------------------------------------------- - -DEFINE_FWK_MODULE(TotemTriggerRawToDigi); diff --git a/EventFilter/TotemRawToDigi/plugins/TotemVFATRawToDigi.cc b/EventFilter/TotemRawToDigi/plugins/TotemVFATRawToDigi.cc deleted file mode 100644 index fbd0150812b..00000000000 --- a/EventFilter/TotemRawToDigi/plugins/TotemVFATRawToDigi.cc +++ /dev/null @@ -1,156 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#include "FWCore/Framework/interface/stream/EDProducer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Utilities/interface/InputTag.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/EventSetup.h" - -#include "DataFormats/FEDRawData/interface/FEDRawData.h" -#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" -#include "DataFormats/FEDRawData/interface/FEDNumbering.h" - -#include "DataFormats/Common/interface/DetSetVector.h" - -#include "DataFormats/TotemDigi/interface/TotemRPDigi.h" -#include "DataFormats/TotemDigi/interface/TotemVFATStatus.h" -#include "DataFormats/TotemDigi/interface/TotemFEDInfo.h" - -#include "CondFormats/DataRecord/interface/TotemReadoutRcd.h" -#include "CondFormats/TotemReadoutObjects/interface/TotemDAQMapping.h" -#include "CondFormats/TotemReadoutObjects/interface/TotemAnalysisMask.h" - -#include "EventFilter/TotemRawToDigi/interface/SimpleVFATFrameCollection.h" -#include "EventFilter/TotemRawToDigi/interface/RawDataUnpacker.h" -#include "EventFilter/TotemRawToDigi/interface/RawToDigiConverter.h" - -#include - -//---------------------------------------------------------------------------------------------------- - -class TotemVFATRawToDigi : public edm::stream::EDProducer<> -{ - public: - explicit TotemVFATRawToDigi(const edm::ParameterSet&); - ~TotemVFATRawToDigi(); - - virtual void produce(edm::Event&, const edm::EventSetup&) override; - - private: - std::string subSystem; - - std::vector fedIds; - - edm::EDGetTokenT fedDataToken; - - RawDataUnpacker rawDataUnpacker; - RawToDigiConverter rawToDigiConverter; - - template - void run(edm::Event&, const edm::EventSetup&); -}; - -//---------------------------------------------------------------------------------------------------- - -using namespace edm; -using namespace std; - -//---------------------------------------------------------------------------------------------------- - -TotemVFATRawToDigi::TotemVFATRawToDigi(const edm::ParameterSet &conf): - subSystem(conf.getParameter("subSystem")), - fedIds(conf.getParameter< vector >("fedIds")), - rawDataUnpacker(conf.getParameterSet("RawUnpacking")), - rawToDigiConverter(conf.getParameterSet("RawToDigi")) -{ - fedDataToken = consumes(conf.getParameter("rawDataTag")); - - // validate chosen subSystem - if (subSystem != "RP") - throw cms::Exception("TotemVFATRawToDigi::TotemVFATRawToDigi") << "Unknown sub-system string " << subSystem << "." << endl; - - // FED (OptoRx) headers and footers - produces< vector >(subSystem); - - // digi - if (subSystem == "RP") - produces< DetSetVector >(subSystem); - - // set default IDs - if (fedIds.empty()) - { - if (subSystem == "RP") - { - for (int id = FEDNumbering::MINTotemRPFEDID; id <= FEDNumbering::MAXTotemRPFEDID; ++id) - fedIds.push_back(id); - } - } - - // conversion status - produces< DetSetVector >(subSystem); -} - -//---------------------------------------------------------------------------------------------------- - -TotemVFATRawToDigi::~TotemVFATRawToDigi() -{ -} - -//---------------------------------------------------------------------------------------------------- - -void TotemVFATRawToDigi::produce(edm::Event& event, const edm::EventSetup &es) -{ - if (subSystem == "RP") - run< DetSetVector >(event, es); -} - -//---------------------------------------------------------------------------------------------------- - -template -void TotemVFATRawToDigi::run(edm::Event& event, const edm::EventSetup &es) -{ - // get DAQ mapping - ESHandle mapping; - es.get().get(mapping); - - // get analysis mask to mask channels - ESHandle analysisMask; - es.get().get(analysisMask); - - // raw data handle - edm::Handle rawData; - event.getByToken(fedDataToken, rawData); - - // book output products - vector fedInfo; - DigiType digi; - DetSetVector conversionStatus; - - // raw-data unpacking - SimpleVFATFrameCollection vfatCollection; - for (const auto &fedId : fedIds) - { - const FEDRawData &data = rawData->FEDData(fedId); - if (data.size() > 0) - rawDataUnpacker.Run(fedId, data, fedInfo, vfatCollection); - } - - // raw-to-digi conversion - rawToDigiConverter.Run(vfatCollection, *mapping, *analysisMask, digi, conversionStatus); - - // commit products to event - event.put(make_unique>(fedInfo), subSystem); - event.put(make_unique(digi), subSystem); - event.put(make_unique>(conversionStatus), subSystem); -} - -//---------------------------------------------------------------------------------------------------- - -DEFINE_FWK_MODULE(TotemVFATRawToDigi); diff --git a/EventFilter/TotemRawToDigi/python/totemRPRawToDigi_cfi.py b/EventFilter/TotemRawToDigi/python/totemRPRawToDigi_cfi.py deleted file mode 100644 index 356b7eaee4f..00000000000 --- a/EventFilter/TotemRawToDigi/python/totemRPRawToDigi_cfi.py +++ /dev/null @@ -1,6 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -from EventFilter.TotemRawToDigi.totemVFATRawToDigi_cfi import totemVFATRawToDigi - -totemRPRawToDigi = totemVFATRawToDigi.copy() -totemRPRawToDigi.subSystem = "RP" diff --git a/EventFilter/TotemRawToDigi/python/totemRawToDigi_cff.py b/EventFilter/TotemRawToDigi/python/totemRawToDigi_cff.py deleted file mode 100644 index 13ae924e025..00000000000 --- a/EventFilter/TotemRawToDigi/python/totemRawToDigi_cff.py +++ /dev/null @@ -1,10 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -from CondFormats.TotemReadoutObjects.TotemDAQMappingESSourceXML_cfi import * -TotemDAQMappingESSourceXML.mappingFileNames.append("CondFormats/TotemReadoutObjects/xml/ctpps_210_mapping.xml") - -from EventFilter.TotemRawToDigi.totemTriggerRawToDigi_cfi import * -totemTriggerRawToDigi.rawDataTag = cms.InputTag("rawDataCollector") - -from EventFilter.TotemRawToDigi.totemRPRawToDigi_cfi import * -totemRPRawToDigi.rawDataTag = cms.InputTag("rawDataCollector") diff --git a/EventFilter/TotemRawToDigi/python/totemTriggerRawToDigi_cfi.py b/EventFilter/TotemRawToDigi/python/totemTriggerRawToDigi_cfi.py deleted file mode 100644 index 893588f74e9..00000000000 --- a/EventFilter/TotemRawToDigi/python/totemTriggerRawToDigi_cfi.py +++ /dev/null @@ -1,9 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -totemTriggerRawToDigi = cms.EDProducer("TotemTriggerRawToDigi", - rawDataTag = cms.InputTag(""), - - # IMPORTANT: leave 0 to load the default configuration from - # DataFormats/FEDRawData/interface/FEDNumbering.h - fedId = cms.uint32(0) -) diff --git a/EventFilter/TotemRawToDigi/python/totemVFATRawToDigi_cfi.py b/EventFilter/TotemRawToDigi/python/totemVFATRawToDigi_cfi.py deleted file mode 100644 index de353609ac3..00000000000 --- a/EventFilter/TotemRawToDigi/python/totemVFATRawToDigi_cfi.py +++ /dev/null @@ -1,47 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -totemVFATRawToDigi = cms.EDProducer("TotemVFATRawToDigi", - rawDataTag = cms.InputTag(""), - - # options: "RP" - subSystem = cms.string(""), - - # IMPORTANT: leave empty to load the default configuration from - # DataFormats/FEDRawData/interface/FEDNumbering.h - fedIds = cms.vuint32(), - - RawUnpacking = cms.PSet( - ), - - RawToDigi = cms.PSet( - # 0: no error output - # 1: one-line message for every event with at least one corrupted VFAT frame - # 2: lists all corrupted VFATs in all events - # 3: lists all corruptions for all corrupted VFATs in all events - verbosity = cms.untracked.uint32(0), - - # flags for available consistency tests - # 0: do not perform the test at all - # 1: print an error message, but keep the frame - # 2: print an error message and do not process the frame - testFootprint = cms.uint32(2), - testCRC = cms.uint32(2), - testID = cms.uint32(2), # compare the ID from data and mapping - testECMostFrequent = cms.uint32(2), # compare frame's EC with the most frequent value in the event - testBCMostFrequent = cms.uint32(2), # compare frame's BC with the most frequent value in the event - - # the minimal number of frames to search for the most frequent counter value - EC_min = cms.untracked.uint32(10), - BC_min = cms.untracked.uint32(10), - - # the most frequent counter value is accepted provided its relative occupancy is higher than this fraction - EC_fraction = cms.untracked.double(0.6), - BC_fraction = cms.untracked.double(0.6), - - # if non-zero, prints a per-VFAT error summary at the end of the job - printErrorSummary = cms.untracked.uint32(1), - - # if non-zero, prints a summary of frames found in data, but not in the mapping - printUnknownFrameSummary = cms.untracked.uint32(0), - ) -) diff --git a/EventFilter/TotemRawToDigi/src/CounterChecker.cc b/EventFilter/TotemRawToDigi/src/CounterChecker.cc deleted file mode 100644 index 3a4844e9af2..00000000000 --- a/EventFilter/TotemRawToDigi/src/CounterChecker.cc +++ /dev/null @@ -1,27 +0,0 @@ -/**************************************************************************** - * - * This is a part of TOTEM offline software. - * Authors: - * Maciej Wróbel (wroblisko@gmail.com) - * Jan Kašpar (jan.kaspar@gmail.com) - * - ****************************************************************************/ - -#include "EventFilter/TotemRawToDigi/interface/CounterChecker.h" - -//------------------------------------------------------------------------------------------------- - -using namespace std; - -//------------------------------------------------------------------------------------------------- - -void CounterChecker::Fill(word counter, TotemFramePosition fr) -{ - pair ret; - - vector list; - list.push_back(fr); - ret = relationMap.insert(pair >(counter, list)); - if (ret.second == false) - relationMap[counter].push_back(fr); -} diff --git a/EventFilter/TotemRawToDigi/src/RawDataUnpacker.cc b/EventFilter/TotemRawToDigi/src/RawDataUnpacker.cc deleted file mode 100644 index abd7410f9f1..00000000000 --- a/EventFilter/TotemRawToDigi/src/RawDataUnpacker.cc +++ /dev/null @@ -1,374 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#include "EventFilter/TotemRawToDigi/interface/RawDataUnpacker.h" - -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -//---------------------------------------------------------------------------------------------------- - -using namespace std; -using namespace edm; - -//---------------------------------------------------------------------------------------------------- - -RawDataUnpacker::RawDataUnpacker(const edm::ParameterSet &conf) -{ -} - -//---------------------------------------------------------------------------------------------------- - -int RawDataUnpacker::Run(int fedId, const FEDRawData &data, vector &fedInfoColl, SimpleVFATFrameCollection &coll) const -{ - unsigned int size_in_words = data.size() / 8; // bytes -> words - if (size_in_words < 2) - { - LogProblem("Totem") << "Error in RawDataUnpacker::Run > " << - "Data in FED " << fedId << " too short (size = " << size_in_words << " words)."; - return 1; - } - - fedInfoColl.push_back(TotemFEDInfo(fedId)); - - return ProcessOptoRxFrame((const word *) data.data(), size_in_words, fedInfoColl.back(), &coll); -} - -//---------------------------------------------------------------------------------------------------- - -int RawDataUnpacker::ProcessOptoRxFrame(const word *buf, unsigned int frameSize, TotemFEDInfo &fedInfo, SimpleVFATFrameCollection *fc) const -{ - // get OptoRx metadata - unsigned long long head = buf[0]; - unsigned long long foot = buf[frameSize-1]; - - fedInfo.setHeader(head); - fedInfo.setFooter(foot); - - unsigned int BOE = (head >> 60) & 0xF; - unsigned int H0 = (head >> 0) & 0xF; - - //unsigned long LV1 = (head >> 32) & 0xFFFFFF; - //unsigned long BX = (head >> 20) & 0xFFF; - unsigned int OptoRxId = (head >> 8) & 0xFFF; - unsigned int FOV = (head >> 4) & 0xF; - - unsigned int EOE = (foot >> 60) & 0xF; - unsigned int F0 = (foot >> 0) & 0xF; - unsigned int FSize = (foot >> 32) & 0x3FF; - - // check header and footer structure - if (BOE != 5 || H0 != 0 || EOE != 10 || F0 != 0 || FSize != frameSize) - { - LogProblem("Totem") << "Error in RawDataUnpacker::ProcessOptoRxFrame > " << "Wrong structure of OptoRx header/footer: " - << "BOE=" << BOE << ", H0=" << H0 << ", EOE=" << EOE << ", F0=" << F0 - << ", size (OptoRx)=" << FSize << ", size (DATE)=" << frameSize - << ". OptoRxID=" << OptoRxId << ". Skipping frame." << endl; - return 0; - } - - #ifdef DEBUG - printf(">> RawDataUnpacker::ProcessOptoRxFrame > OptoRxId = %u, BX = %lu, LV1 = %lu, frameSize = %u, subFrames = %u)\n", - OptoRxId, BX, LV1, frameSize, subFrames); - #endif - - // parallel or serial transmission? - if (FOV == 1) - return ProcessOptoRxFrameSerial(buf, frameSize, fc); - - if (FOV == 2) - return ProcessOptoRxFrameParallel(buf, frameSize, fedInfo, fc); - - LogProblem("Totem") << "Error in RawDataUnpacker::ProcessOptoRxFrame > " << "Unknown FOV = " << FOV << endl; - - return 0; -} - -//---------------------------------------------------------------------------------------------------- - -int RawDataUnpacker::ProcessOptoRxFrameSerial(const word *buf, unsigned int frameSize, SimpleVFATFrameCollection *fc) const -{ - // get OptoRx metadata - unsigned int OptoRxId = (buf[0] >> 8) & 0xFFF; - - // get number of subframes - unsigned int subFrames = (frameSize - 2) / 194; - - // process all sub-frames - unsigned int errorCounter = 0; - for (unsigned int r = 0; r < subFrames; ++r) - { - for (unsigned int c = 0; c < 4; ++c) - { - unsigned int head = (buf[1 + 194 * r] >> (16 * c)) & 0xFFFF; - unsigned int foot = (buf[194 + 194 * r] >> (16 * c)) & 0xFFFF; - - #ifdef DEBUG - printf(">>>> r = %i, c = %i: S = %i, BOF = %i, EOF = %i, ID = %i, ID' = %i\n", r, c, head & 0x1, head >> 12, foot >> 12, (head >> 8) & 0xF, (foot >> 8) & 0xF); - #endif - - // stop if this GOH is NOT active - if ((head & 0x1) == 0) - continue; - - #ifdef DEBUG - printf("\tHeader active (%04x -> %x).\n", head, head & 0x1); - #endif - - // check structure - if (head >> 12 != 0x4 || foot >> 12 != 0xB || ((head >> 8) & 0xF) != ((foot >> 8) & 0xF)) - { - char ss[500]; - if (head >> 12 != 0x4) - sprintf(ss, "\n\tHeader is not 0x4 as expected (%x).", head); - if (foot >> 12 != 0xB) - sprintf(ss, "\n\tFooter is not 0xB as expected (%x).", foot); - if (((head >> 8) & 0xF) != ((foot >> 8) & 0xF)) - sprintf(ss, "\n\tIncompatible GOH IDs in header (%x) and footer (%x).", ((head >> 8) & 0xF), - ((foot >> 8) & 0xF)); - - LogProblem("Totem") << "Error in RawDataUnpacker::ProcessOptoRxFrame > " << "Wrong payload structure (in GOH block row " << r << - " and column " << c << ") in OptoRx frame ID " << OptoRxId << ". GOH block omitted." << ss << endl; - - errorCounter++; - continue; - } - - // allocate memory for VFAT frames - unsigned int goh = (head >> 8) & 0xF; - vector dataPtrs; - for (unsigned int fi = 0; fi < 16; fi++) - { - TotemFramePosition fp(0, 0, OptoRxId, goh, fi); - dataPtrs.push_back( fc->InsertEmptyFrame(fp)->getData() ); - } - - #ifdef DEBUG - printf(">>>> transposing GOH block at prefix: %i, dataPtrs = %p\n", OptoRxId*192 + goh*16, dataPtrs); - #endif - - // deserialization - for (int i = 0; i < 192; i++) - { - int iword = 11 - i / 16; // number of current word (11...0) - int ibit = 15 - i % 16; // number of current bit (15...0) - unsigned int w = (buf[i + 2 + 194 * r] >> (16 * c)) & 0xFFFF; - - // Fill the current bit of the current word of all VFAT frames - for (int idx = 0; idx < 16; idx++) - { - if (w & (1 << idx)) - dataPtrs[idx][iword] |= (1 << ibit); - } - } - } - } - - return errorCounter; -} - -//---------------------------------------------------------------------------------------------------- - -int RawDataUnpacker::ProcessOptoRxFrameParallel(const word *buf, unsigned int frameSize, TotemFEDInfo &fedInfo, SimpleVFATFrameCollection *fc) const -{ - // get OptoRx metadata - unsigned long long head = buf[0]; - unsigned int OptoRxId = (head >> 8) & 0xFFF; - - // recast data as buffer or 16bit words, skip header - const uint16_t *payload = (const uint16_t *) (buf + 1); - - // read in OrbitCounter block - const uint32_t *ocPtr = (const uint32_t *) payload; - fedInfo.setOrbitCounter(*ocPtr); - payload += 2; - - // size in 16bit words, without header, footer and orbit counter block - unsigned int nWords = (frameSize-2) * 4 - 2; - - // process all VFAT data - for (unsigned int offset = 0; offset < nWords;) - { - unsigned int wordsProcessed = ProcessVFATDataParallel(payload + offset, OptoRxId, fc); - offset += wordsProcessed; - } - - return 0; -} - -//---------------------------------------------------------------------------------------------------- - -int RawDataUnpacker::ProcessVFATDataParallel(const uint16_t *buf, unsigned int OptoRxId, SimpleVFATFrameCollection *fc) const -{ - // start counting processed words - unsigned int wordsProcessed = 1; - - // padding word? skip it - if (buf[0] == 0xFFFF) - return wordsProcessed; - - // check header flag - unsigned int hFlag = (buf[0] >> 8) & 0xFF; - if (hFlag != vmCluster && hFlag != vmRaw) - { - LogProblem("Totem") << "Error in RawDataUnpacker::ProcessVFATDataParallel > " - << "Unknown header flag " << hFlag << ". Skipping this word." << endl; - return wordsProcessed; - } - - // compile frame position - // NOTE: DAQ group uses terms GOH and fiber in the other way - unsigned int gohIdx = (buf[0] >> 4) & 0xF; - unsigned int fiberIdx = (buf[0] >> 0) & 0xF; - TotemFramePosition fp(0, 0, OptoRxId, gohIdx, fiberIdx); - - // prepare temporary VFAT frame - VFATFrame f; - VFATFrame::word *fd = f.getData(); - - // copy footprint, BC, EC, Flags, ID, if they exist - uint8_t presenceFlags = 0; - - if (((buf[wordsProcessed] >> 12) & 0xF) == 0xA) // BC - { - presenceFlags |= 0x1; - fd[11] = buf[wordsProcessed]; - wordsProcessed++; - } - - if (((buf[wordsProcessed] >> 12) & 0xF) == 0xC) // EC, flags - { - presenceFlags |= 0x2; - fd[10] = buf[wordsProcessed]; - wordsProcessed++; - } - - if (((buf[wordsProcessed] >> 12) & 0xF) == 0xE) // ID - { - presenceFlags |= 0x4; - fd[9] = buf[wordsProcessed]; - wordsProcessed++; - } - - // save offset where channel data start - unsigned int dataOffset = wordsProcessed; - - // find trailer - if (hFlag == vmCluster) - { - unsigned int nCl = 0; - while ( (buf[wordsProcessed + nCl] >> 12) != 0xF ) - nCl++; - - wordsProcessed += nCl; - } - - if (hFlag == vmRaw) - wordsProcessed += 9; - - // process trailer - unsigned int tSig = buf[wordsProcessed] >> 12; - unsigned int tErrFlags = (buf[wordsProcessed] >> 8) & 0xF; - unsigned int tSize = buf[wordsProcessed] & 0xFF; - - f.setDAQErrorFlags(tErrFlags); - - bool skipFrame = false; - bool suppressChannelErrors = false; - - if (tSig != 0xF) - { - LogProblem("Totem") << "Error in RawDataUnpacker::ProcessVFATDataParallel > " - << "Wrong trailer signature (" << tSig << ") at " - << fp << ". This frame will be skipped." << endl; - skipFrame = true; - } - - if (tErrFlags != 0) - { - LogProblem("Totem") << "Error in RawDataUnpacker::ProcessVFATDataParallel > " - << "Error flags not zero (" << tErrFlags << ") at " - << fp << ". Channel errors will be suppressed." << endl; - suppressChannelErrors = true; - } - - wordsProcessed++; - - if (tSize != wordsProcessed) - { - LogProblem("Totem") << "Error in RawDataUnpacker::ProcessVFATDataParallel > " - << "Trailer size (" << tSize << ") does not match with words processed (" - << wordsProcessed << ") at " << fp << ". This frame will be skipped." << endl; - skipFrame = true; - } - - if (skipFrame) - return wordsProcessed; - - // get channel data - cluster mode - if (hFlag == vmCluster) - { - for (unsigned int nCl = 0; (buf[dataOffset + nCl] >> 12) != 0xF; ++nCl) - { - const uint16_t &w = buf[dataOffset + nCl]; - unsigned int upperBlock = w >> 8; - unsigned int clSize = upperBlock & 0x7F; - unsigned int clPos = (w >> 0) & 0xFF; - - // special case: upperBlock=0xD0 => numberOfClusters - if (upperBlock == 0xD0) - { - presenceFlags |= 0x10; - f.setNumberOfClusters(clPos); - continue; - } - - // special case: size=0 means chip full - if (clSize == 0) - clSize = 128; - - // activate channels - // convention - range - signed int chMax = clPos; - signed int chMin = clPos - clSize + 1; - if (chMax < 0 || chMax > 127 || chMin < 0 || chMin > 127 || chMin > chMax) - { - if (!suppressChannelErrors) - LogProblem("Totem") << "Error in RawDataUnpacker::ProcessVFATDataParallel > " - << "Invalid cluster (pos=" << clPos - << ", size=" << clSize << ", min=" << chMin << ", max=" << chMax << ") at " << fp - <<". Skipping this cluster." << endl; - - continue; - } - - for (signed int ch = chMin; ch <= chMax; ch++) - { - unsigned int wi = ch / 16; - unsigned int bi = ch % 16; - fd[wi + 1] |= (1 << bi); - } - } - } - - // get channel data and CRC - raw mode - if (hFlag == vmRaw) - { - for (unsigned int i = 0; i < 8; i++) - fd[8 - i] = buf[dataOffset + i]; - - // copy CRC - presenceFlags |= 0x8; - fd[0] = buf[dataOffset + 8]; - } - - // save frame to output - f.setPresenceFlags(presenceFlags); - fc->Insert(fp, f); - - return wordsProcessed; -} diff --git a/EventFilter/TotemRawToDigi/src/RawToDigiConverter.cc b/EventFilter/TotemRawToDigi/src/RawToDigiConverter.cc deleted file mode 100644 index 0d43eb0f47d..00000000000 --- a/EventFilter/TotemRawToDigi/src/RawToDigiConverter.cc +++ /dev/null @@ -1,296 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#include "EventFilter/TotemRawToDigi/interface/RawToDigiConverter.h" - -#include "EventFilter/TotemRawToDigi/interface/CounterChecker.h" - -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -#include "DataFormats/TotemRPDetId/interface/TotemRPDetId.h" - -//---------------------------------------------------------------------------------------------------- - -using namespace std; -using namespace edm; - -//---------------------------------------------------------------------------------------------------- - -RawToDigiConverter::RawToDigiConverter(const edm::ParameterSet &conf) : - verbosity(conf.getUntrackedParameter("verbosity", 0)), - printErrorSummary(conf.getUntrackedParameter("printErrorSummary", 1)), - printUnknownFrameSummary(conf.getUntrackedParameter("printUnknownFrameSummary", 1)), - - testFootprint(conf.getParameter("testFootprint")), - testCRC(conf.getParameter("testCRC")), - testID(conf.getParameter("testID")), - testECMostFrequent(conf.getParameter("testECMostFrequent")), - testBCMostFrequent(conf.getParameter("testBCMostFrequent")), - - EC_min(conf.getUntrackedParameter("EC_min", 10)), - BC_min(conf.getUntrackedParameter("BC_min", 10)), - - EC_fraction(conf.getUntrackedParameter("EC_fraction", 0.6)), - BC_fraction(conf.getUntrackedParameter("BC_fraction", 0.6)) -{ -} - -//---------------------------------------------------------------------------------------------------- - -void RawToDigiConverter::RunCommon(const VFATFrameCollection &input, const TotemDAQMapping &mapping, - map &records) -{ - // EC and BC checks (wrt. the most frequent value), BC checks per subsystem - CounterChecker ECChecker(CounterChecker::ECChecker, "EC", EC_min, EC_fraction, verbosity); - CounterChecker BCChecker(CounterChecker::BCChecker, "BC", BC_min, BC_fraction, verbosity); - - // initialise structure merging vfat frame data with the mapping - for (auto &p : mapping.VFATMapping) - { - TotemVFATStatus st; - st.setMissing(true); - records[p.first] = { &p.second, NULL, st }; - } - - // event error message buffer - stringstream ees; - - // associate data frames with records - for (VFATFrameCollection::Iterator fr(&input); !fr.IsEnd(); fr.Next()) - { - // frame error message buffer - stringstream fes; - - bool problemsPresent = false; - bool stopProcessing = false; - - // skip data frames not listed in the DAQ mapping - auto records_it = records.find(fr.Position()); - if (records_it == records.end()) - { - unknownSummary[fr.Position()]++; - continue; - } - - // update record - Record &record = records_it->second; - record.frame = fr.Data(); - record.status.setMissing(false); - - record.status.setNumberOfClustersSpecified(record.frame->isNumberOfClustersPresent()); - record.status.setNumberOfClusters(record.frame->getNumberOfClusters()); - - // check footprint - if (testFootprint != tfNoTest && !record.frame->checkFootprint()) - { - problemsPresent = true; - - if (verbosity > 0) - fes << " invalid footprint\n"; - - if ((testFootprint == tfErr)) - { - record.status.setFootprintError(); - stopProcessing = true; - } - } - - // check CRC - if (testCRC != tfNoTest && !record.frame->checkCRC()) - { - problemsPresent = true; - - if (verbosity > 0) - fes << " CRC failure\n"; - - if (testCRC == tfErr) - { - record.status.setCRCError(); - stopProcessing = true; - } - } - - // check the id mismatch - if (testID != tfNoTest && record.frame->isIDPresent() && (record.frame->getChipID() & 0xFFF) != (record.info->hwID & 0xFFF)) - { - problemsPresent = true; - - if (verbosity > 0) - fes << " ID mismatch (data: 0x" << hex << record.frame->getChipID() - << ", mapping: 0x" << record.info->hwID << dec << ", symbId: " << record.info->symbolicID.symbolicID << ")\n"; - - if (testID == tfErr) - { - record.status.setIDMismatch(); - stopProcessing = true; - } - } - - // if there were errors, put the information to ees buffer - if (verbosity > 0 && problemsPresent) - { - string message = (stopProcessing) ? "(and will be dropped)" : "(but will be used though)"; - if (verbosity > 2) - { - ees << " Frame at " << fr.Position() << " seems corrupted " << message << ":\n"; - ees << fes.rdbuf(); - } else - ees << " Frame at " << fr.Position() << " seems corrupted " << message << ".\n"; - } - - // if there were serious errors, do not process this frame - if (stopProcessing) - continue; - - // fill EC and BC values to the statistics - if (fr.Data()->isECPresent()) - ECChecker.Fill(fr.Data()->getEC(), fr.Position()); - - if (fr.Data()->isBCPresent()) - BCChecker.Fill(fr.Data()->getBC(), fr.Position()); - } - - // analyze EC and BC statistics - if (testECMostFrequent != tfNoTest) - ECChecker.Analyze(records, (testECMostFrequent == tfErr), ees); - - if (testBCMostFrequent != tfNoTest) - BCChecker.Analyze(records, (testBCMostFrequent == tfErr), ees); - - // add error message for missing frames - if (verbosity > 1) - { - for (const auto &p : records) - { - if (p.second.status.isMissing()) - ees << "Frame for VFAT " << p.first << " is not present in the data.\n"; - } - } - - // print error message - if (verbosity > 0 && !ees.rdbuf()->str().empty()) - { - if (verbosity > 1) - LogProblem("Totem") << "Error in RawToDigiConverter::RunCommon > " << "event contains the following problems:\n" << ees.rdbuf() << endl; - else - LogProblem("Totem") << "Error in RawToDigiConverter::RunCommon > " << "event contains problems." << endl; - } - - // increase error counters - if (printErrorSummary) - { - for (const auto &it : records) - { - if (!it.second.status.isOK()) - { - auto &m = errorSummary[it.first]; - m[it.second.status]++; - } - } - } -} - -//---------------------------------------------------------------------------------------------------- - -void RawToDigiConverter::Run(const VFATFrameCollection &input, - const TotemDAQMapping &mapping, const TotemAnalysisMask &analysisMask, - DetSetVector &rpData, DetSetVector &finalStatus) -{ - // structure merging vfat frame data with the mapping - map records; - - // common processing - frame validation - RunCommon(input, mapping, records); - - // second loop over data - for (auto &p : records) - { - Record &record = p.second; - - // check whether the data come from RP VFATs - if (record.info->symbolicID.subSystem != TotemSymbID::RP) - { - LogProblem("Totem") << "Error in RawToDigiConverter::Run > " - << "VFAT is not from RP. subSystem = " << record.info->symbolicID.subSystem; - continue; - } - - // silently ignore RP CC VFATs - if (record.info->type != TotemVFATInfo::data) - continue; - - // calculate ids - unsigned short chipId = record.info->symbolicID.symbolicID; - det_id_type detId = TotemRPDetId::decToRawId(chipId / 10); - uint8_t chipPosition = chipId % 10; - - // update chipPosition in status - record.status.setChipPosition(chipPosition); - - // produce digi only for good frames - if (record.status.isOK()) - { - // find analysis mask (needs a default=no mask, if not in present the mapping) - TotemVFATAnalysisMask anMa; - anMa.fullMask = false; - - auto analysisIter = analysisMask.analysisMask.find(record.info->symbolicID); - if (analysisIter != analysisMask.analysisMask.end()) - { - // if there is some information about masked channels - save it into conversionStatus - anMa = analysisIter->second; - if (anMa.fullMask) - record.status.setFullyMaskedOut(); - else - record.status.setPartiallyMaskedOut(); - } - - // create the digi - unsigned short offset = chipPosition * 128; - const vector &activeChannels = record.frame->getActiveChannels(); - - for (auto ch : activeChannels) - { - // skip masked channels - if (!anMa.fullMask && anMa.maskedChannels.find(ch) == anMa.maskedChannels.end()) - { - DetSet &digiDetSet = rpData.find_or_insert(detId); - digiDetSet.push_back(TotemRPDigi(offset + ch)); - } - } - } - - // save status - DetSet &statusDetSet = finalStatus.find_or_insert(detId); - statusDetSet.push_back(record.status); - } -} - -//---------------------------------------------------------------------------------------------------- - -void RawToDigiConverter::PrintSummaries() -{ - if (printErrorSummary) - { - LogVerbatim("Totem") << "* Error summary (error signature : number of such events)" << endl; - for (const auto &vit : errorSummary) - { - LogVerbatim("Totem") << vit.first << endl; - - for (const auto &it : vit.second) - LogVerbatim("Totem") << " " << it.first << " : " << it.second << endl; - } - } - - if (printUnknownFrameSummary) - { - LogVerbatim("Totem") << "* Frames found in data, but not in the mapping (frame position : number of events)" << endl; - for (const auto &it : unknownSummary) - LogVerbatim("Totem") << " " << it.first << " : " << it.second << endl; - } -} diff --git a/EventFilter/TotemRawToDigi/src/SimpleVFATFrameCollection.cc b/EventFilter/TotemRawToDigi/src/SimpleVFATFrameCollection.cc deleted file mode 100644 index c714bf292e3..00000000000 --- a/EventFilter/TotemRawToDigi/src/SimpleVFATFrameCollection.cc +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -* -* This is a part of the TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - - -#include "EventFilter/TotemRawToDigi/interface/SimpleVFATFrameCollection.h" - -//---------------------------------------------------------------------------------------------------- - -using namespace std; - -SimpleVFATFrameCollection::SimpleVFATFrameCollection() -{ -} - -//---------------------------------------------------------------------------------------------------- - -SimpleVFATFrameCollection::~SimpleVFATFrameCollection() -{ - data.clear(); -} - -//---------------------------------------------------------------------------------------------------- - -const VFATFrame* SimpleVFATFrameCollection::GetFrameByID(unsigned int ID) const -{ - // first convert ID to 12bit form - ID = ID & 0xFFF; - - for (MapType::const_iterator it = data.begin(); it != data.end(); ++it) - if (it->second.getChipID() == ID) - if (it->second.checkFootprint() && it->second.checkCRC()) - return &(it->second); - - return NULL; -} - -//---------------------------------------------------------------------------------------------------- - -const VFATFrame* SimpleVFATFrameCollection::GetFrameByIndex(TotemFramePosition index) const -{ - MapType::const_iterator it = data.find(index); - if (it != data.end()) - return &(it->second); - else - return NULL; -} - -//---------------------------------------------------------------------------------------------------- - -VFATFrameCollection::value_type SimpleVFATFrameCollection::BeginIterator() const -{ - MapType::const_iterator it = data.begin(); - return (it == data.end()) ? value_type(TotemFramePosition(), NULL) : value_type(it->first, &it->second); -} - -//---------------------------------------------------------------------------------------------------- - -VFATFrameCollection::value_type SimpleVFATFrameCollection::NextIterator(const value_type &value) const -{ - if (!value.second) - return value; - - MapType::const_iterator it = data.find(value.first); - it++; - - return (it == data.end()) ? value_type(TotemFramePosition(), NULL) : value_type(it->first, &it->second); -} - -//---------------------------------------------------------------------------------------------------- - -bool SimpleVFATFrameCollection::IsEndIterator(const value_type &value) const -{ - return (value.second == NULL); -} diff --git a/EventFilter/TotemRawToDigi/src/VFATFrame.cc b/EventFilter/TotemRawToDigi/src/VFATFrame.cc deleted file mode 100644 index 0fb3af2fd9e..00000000000 --- a/EventFilter/TotemRawToDigi/src/VFATFrame.cc +++ /dev/null @@ -1,171 +0,0 @@ -/**************************************************************************** -* -* This is a part of the TOTEM testbeam/monitoring software. -* This is a part of the TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@gmail.com) -* Leszek Grzanka -* -****************************************************************************/ - -#include "EventFilter/TotemRawToDigi/interface/VFATFrame.h" - -#include -#include - -//---------------------------------------------------------------------------------------------------- - -VFATFrame::VFATFrame(const VFATFrame::word *_data) : - presenceFlags(15), // by default BC, EC, ID and CRC are present - daqErrorFlags(0), // by default, no DAQ error - numberOfClusters(0) // no clusters by default -{ - if (_data) - setData(_data); - else - memset(data, 0, 12 * sizeof(word)); -} - -//---------------------------------------------------------------------------------------------------- - -void VFATFrame::setData(const VFATFrame::word *_data) -{ - memcpy(data, _data, 24); -} - -//---------------------------------------------------------------------------------------------------- - -std::vector VFATFrame::getActiveChannels() const -{ - std::vector channels; - - for (int i = 0; i < 8; i++) - { - // quick check - if (!data[1 + i]) - continue; - - // go throug bits - word mask; - char offset; - for (mask = 1 << 15, offset = 15; mask; mask >>= 1, offset--) - { - if (data[1 + i] & mask) - channels.push_back( i * 16 + offset ); - } - } - - return channels; -} - -//---------------------------------------------------------------------------------------------------- - -bool VFATFrame::checkFootprint() const -{ - if (isIDPresent() && (data[9] & 0xF000) != 0xE000) - return false; - - if (isECPresent() && (data[10] & 0xF000) != 0xC000) - return false; - - if (isBCPresent() && (data[11] & 0xF000) != 0xA000) - return false; - - return true; -} - -//---------------------------------------------------------------------------------------------------- - -bool VFATFrame::checkCRC() const -{ - // check DAQ error flags - if (daqErrorFlags != 0) - return false; - - // return true if CRC not present - if (! isCRCPresent()) - return true; - - // compare CRC - word crc_fin = 0xffff; - - for (int i = 11; i >= 1; i--) - crc_fin = calculateCRC(crc_fin, data[i]); - - return (crc_fin == data[0]); -} - -//---------------------------------------------------------------------------------------------------- - -VFATFrame::word VFATFrame::calculateCRC(VFATFrame::word crc_in, VFATFrame::word dato) -{ - word v = 0x0001; - word mask = 0x0001; - bool d=0; - word crc_temp = crc_in; - unsigned char datalen = 16; - - for (int i = 0; i < datalen; i++) - { - if (dato & v) - d = 1; - else - d = 0; - - if ((crc_temp & mask)^d) - crc_temp = crc_temp>>1 ^ 0x8408; - else - crc_temp = crc_temp>>1; - - v <<= 1; - } - - return crc_temp; -} - -//---------------------------------------------------------------------------------------------------- - -void VFATFrame::Print(bool binary) const -{ - if (binary) - { - for (int i = 0; i < 12; i++) - { - const word &w = data[11 - i]; - word mask = (1 << 15); - for (int j = 0; j < 16; j++) - { - if (w & mask) - printf("1"); - else - printf("0"); - mask = (mask >> 1); - if ((j + 1) % 4 == 0) - printf("|"); - } - printf("\n"); - } - } else { - printf("ID = %03x, BC = %04u, EC = %03u, flags = %2u, CRC = %04x ", getChipID(), getBC(), getEC(), getFlags(), getCRC()); - - if (checkCRC()) - printf("( OK), footprint "); - else - printf("(FAIL), footprint "); - - if (checkFootprint()) - printf(" OK"); - else - printf("FAIL"); - - printf(", frame = %04x|%04x|%04x|", data[11], data[10], data[9]); - for (int i = 8; i > 0; i--) - printf("%04x", data[i]); - printf("|%04x", data[0]); - - printf(", presFl=%x", presenceFlags); - printf(", daqErrFl=%x", daqErrorFlags); - - printf("\n"); - } -} diff --git a/EventFilter/TotemRawToDigi/src/VFATFrameCollection.cc b/EventFilter/TotemRawToDigi/src/VFATFrameCollection.cc deleted file mode 100644 index 938988d8f35..00000000000 --- a/EventFilter/TotemRawToDigi/src/VFATFrameCollection.cc +++ /dev/null @@ -1,20 +0,0 @@ -/**************************************************************************** -* -* This is a part of the TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - - -#include "EventFilter/TotemRawToDigi/interface/VFATFrameCollection.h" - -//---------------------------------------------------------------------------------------------------- - -const VFATFrame* VFATFrameCollection::GetFrameByIndexID(TotemFramePosition index, unsigned int ID) -{ - const VFATFrame* returnframe = GetFrameByIndex(index); - if (returnframe == NULL) - return NULL; - return (returnframe->getChipID() == (ID & 0xFFF)) ? returnframe : NULL; -} diff --git a/EventFilter/TotemRawToDigi/test/BuildFile.xml b/EventFilter/TotemRawToDigi/test/BuildFile.xml deleted file mode 100644 index 5277723fc53..00000000000 --- a/EventFilter/TotemRawToDigi/test/BuildFile.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/EventFilter/TotemRawToDigi/test/TotemVFATFrameAnalyzer.cc b/EventFilter/TotemRawToDigi/test/TotemVFATFrameAnalyzer.cc deleted file mode 100644 index bc64f795b27..00000000000 --- a/EventFilter/TotemRawToDigi/test/TotemVFATFrameAnalyzer.cc +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#include "FWCore/Framework/interface/global/EDAnalyzer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Utilities/interface/InputTag.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/EventSetup.h" - -#include "DataFormats/FEDRawData/interface/FEDRawData.h" -#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" - -#include "DataFormats/TotemDigi/interface/TotemFEDInfo.h" - -#include "EventFilter/TotemRawToDigi/interface/SimpleVFATFrameCollection.h" -#include "EventFilter/TotemRawToDigi/interface/RawDataUnpacker.h" - -#include - -//---------------------------------------------------------------------------------------------------- - -class TotemVFATFrameAnalyzer : public edm::global::EDAnalyzer<> -{ - public: - explicit TotemVFATFrameAnalyzer(const edm::ParameterSet&); - ~TotemVFATFrameAnalyzer(); - - virtual void analyze(edm::StreamID, const edm::Event &, const edm::EventSetup &) const override; - - private: - - std::vector fedIds; - - edm::EDGetTokenT fedDataToken; - - RawDataUnpacker rawDataUnpacker; - - template - void run(edm::Event&, const edm::EventSetup&); -}; - -//---------------------------------------------------------------------------------------------------- - -using namespace edm; -using namespace std; - -//---------------------------------------------------------------------------------------------------- - -TotemVFATFrameAnalyzer::TotemVFATFrameAnalyzer(const edm::ParameterSet &conf): - fedIds(conf.getParameter< vector >("fedIds")), - rawDataUnpacker(conf.getParameterSet("RawUnpacking")) -{ - fedDataToken = consumes(conf.getParameter("rawDataTag")); -} - -//---------------------------------------------------------------------------------------------------- - -TotemVFATFrameAnalyzer::~TotemVFATFrameAnalyzer() -{ -} - -//---------------------------------------------------------------------------------------------------- - -void TotemVFATFrameAnalyzer::analyze(edm::StreamID, const edm::Event& event, const edm::EventSetup &) const -{ - // raw data handle - edm::Handle rawData; - event.getByToken(fedDataToken, rawData); - - // raw-data unpacking - vector fedInfo; - SimpleVFATFrameCollection vfatCollection; - for (const auto &fedId : fedIds) - { - const FEDRawData &data = rawData->FEDData(fedId); - if (data.size() > 0) - rawDataUnpacker.Run(fedId, data, fedInfo, vfatCollection); - } - - // print VFAT frames - cout << endl << "----------------------------------------------------------------------------------------------------" << endl; - cout << event.id() << endl; - - for (VFATFrameCollection::Iterator fr(&vfatCollection); !fr.IsEnd(); fr.Next()) - { - cout << fr.Position() << " > "; - fr.Data()->Print(); - } -} - -//---------------------------------------------------------------------------------------------------- - -DEFINE_FWK_MODULE(TotemVFATFrameAnalyzer); diff --git a/EventFilter/TotemRawToDigi/test/analyze_vfat_frames.py b/EventFilter/TotemRawToDigi/test/analyze_vfat_frames.py deleted file mode 100644 index 6b195f8b249..00000000000 --- a/EventFilter/TotemRawToDigi/test/analyze_vfat_frames.py +++ /dev/null @@ -1,43 +0,0 @@ -import FWCore.ParameterSet.Config as cms -import FWCore.ParameterSet.VarParsing as VarParsing - -process = cms.Process("AnalyzeVFATFrames") - -# default options -options = VarParsing.VarParsing ('analysis') -options.inputFiles= 'file:/afs/cern.ch/user/j/jkaspar/public/run268608_ls0001_streamA_StorageManager.root', -options.outputFile = 'this_is_not_used' -options.maxEvents = 10 - -# parse command-line options -options.parseArguments() - -# minimum of logs -process.MessageLogger = cms.Service("MessageLogger", - statistics = cms.untracked.vstring(), - destinations = cms.untracked.vstring('cerr'), - cerr = cms.untracked.PSet( - threshold = cms.untracked.string('WARNING') - ) -) - -# raw data source -process.source = cms.Source("PoolSource", - fileNames = cms.untracked.vstring(options.inputFiles) -) - -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(options.maxEvents) -) - -# frame analyzer -process.totemVFATFrameAnalyzer = cms.EDAnalyzer("TotemVFATFrameAnalyzer", - rawDataTag = cms.InputTag("rawDataCollector"), - fedIds = cms.vuint32(578, 579, 580), - RawUnpacking = cms.PSet() -) - -# execution configuration -process.p = cms.Path( - process.totemVFATFrameAnalyzer -) diff --git a/EventFilter/TotemRawToDigi/test/emulated_data_test.py b/EventFilter/TotemRawToDigi/test/emulated_data_test.py deleted file mode 100644 index 1fbf7f5b11b..00000000000 --- a/EventFilter/TotemRawToDigi/test/emulated_data_test.py +++ /dev/null @@ -1,43 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -process = cms.Process("TotemIntegratedRawDataTest") - -# minimum of logs -process.MessageLogger = cms.Service("MessageLogger", - statistics = cms.untracked.vstring(), - destinations = cms.untracked.vstring('cerr'), - cerr = cms.untracked.PSet( - threshold = cms.untracked.string('WARNING') - ) -) - -# raw data source -process.source = cms.Source("PoolSource", - fileNames = cms.untracked.vstring('file:/afs/cern.ch/user/j/jkaspar/public/run268608_ls0001_streamA_StorageManager.root') -) - -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(10) -) - -# raw-to-digi conversion -process.load('CondFormats.TotemReadoutObjects.TotemDAQMappingESSourceXML_cfi') -process.TotemDAQMappingESSourceXML.mappingFileNames.append("CondFormats/TotemReadoutObjects/xml/ctpps_210_mapping.xml") - -# in the emulated data the trigger block contains non-sense -#process.load("EventFilter.TotemRawToDigi.totemTriggerRawToDigi_cfi") -#process.totemTriggerRawToDigi.rawDataTag = cms.InputTag("rawDataCollector") -#process.totemTriggerRawToDigi.fedId = 577 - -process.load('EventFilter.TotemRawToDigi.totemRPRawToDigi_cfi') -process.totemRPRawToDigi.rawDataTag = cms.InputTag("rawDataCollector") -process.totemRPRawToDigi.fedIds = cms.vuint32(578, 579, 580) # in the emulated data one OptoRx was not functional -process.totemRPRawToDigi.RawToDigi.testID = 0 -process.totemRPRawToDigi.RawToDigi.printErrorSummary = 1 -process.totemRPRawToDigi.RawToDigi.printUnknownFrameSummary = 1 - -# execution configuration -process.p = cms.Path( - #process.totemTriggerRawToDigi * - process.totemRPRawToDigi -) diff --git a/EventFilter/TotemRawToDigi/test/global_daq_test.py b/EventFilter/TotemRawToDigi/test/global_daq_test.py deleted file mode 100644 index ef33831d177..00000000000 --- a/EventFilter/TotemRawToDigi/test/global_daq_test.py +++ /dev/null @@ -1,37 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -process = cms.Process("TotemIntegratedRawDataTest") - -# minimum of logs -process.MessageLogger = cms.Service("MessageLogger", - statistics = cms.untracked.vstring(), - destinations = cms.untracked.vstring('cerr'), - cerr = cms.untracked.PSet( - threshold = cms.untracked.string('WARNING') - ) -) - -# raw data source -process.source = cms.Source("PoolSource", - fileNames = cms.untracked.vstring('file:/afs/cern.ch/user/j/jkaspar/public/run273062_ls0001-2_stream.root') -) - -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(-1) -) - -# raw-to-digi conversion -process.load('CondFormats.TotemReadoutObjects.TotemDAQMappingESSourceXML_cfi') -process.TotemDAQMappingESSourceXML.mappingFileNames.append("CondFormats/TotemReadoutObjects/xml/ctpps_210_mapping.xml") - -process.load("EventFilter.TotemRawToDigi.totemTriggerRawToDigi_cfi") -process.totemTriggerRawToDigi.rawDataTag = cms.InputTag("rawDataCollector") - -process.load('EventFilter.TotemRawToDigi.totemRPRawToDigi_cfi') -process.totemRPRawToDigi.rawDataTag = cms.InputTag("rawDataCollector") - -# execution configuration -process.p = cms.Path( - process.totemTriggerRawToDigi * - process.totemRPRawToDigi -) diff --git a/Geometry/VeryForwardData/data/2016_04_20_fill4828/RP_Dist_Beam_Cent.xml b/Geometry/VeryForwardData/data/2016_04_20_fill4828/RP_Dist_Beam_Cent.xml new file mode 100644 index 00000000000..f9eeb7da637 --- /dev/null +++ b/Geometry/VeryForwardData/data/2016_04_20_fill4828/RP_Dist_Beam_Cent.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/VeryForwardGeometryBuilder/src/RPAlignmentCorrectionsMethods.cc b/Geometry/VeryForwardGeometryBuilder/src/RPAlignmentCorrectionsMethods.cc index dd7d01eec41..60cc772de05 100644 --- a/Geometry/VeryForwardGeometryBuilder/src/RPAlignmentCorrectionsMethods.cc +++ b/Geometry/VeryForwardGeometryBuilder/src/RPAlignmentCorrectionsMethods.cc @@ -85,8 +85,11 @@ RPAlignmentCorrectionsData RPAlignmentCorrectionsMethods::GetCorrectionsDataFrom RPAlignmentCorrectionsData RPAlignmentCorrectionsMethods::GetCorrectionsData(DOMNode *root) { + RPAlignmentCorrectionsData result; + DOMNodeList *children = root->getChildNodes(); - for (unsigned int i = 0; i < children->getLength(); i++) { + for (unsigned int i = 0; i < children->getLength(); i++) + { DOMNode *n = children->item(i); if (n->getNodeType() != DOMNode::ELEMENT_NODE) continue; @@ -101,25 +104,29 @@ RPAlignmentCorrectionsData RPAlignmentCorrectionsMethods::GetCorrectionsData(DOM // check children if (n->getChildNodes()->getLength() > 0) + { edm::LogProblem("RPAlignmentCorrectionsMethods") << ">> RPAlignmentCorrectionsMethods::LoadXMLFile > Warning: tag `" << XMLString::transcode(n->getNodeName()) << "' has " << n->getChildNodes()->getLength() << " children nodes - they will be all ignored."; + } // default values double sh_r = 0., sh_x = 0., sh_y = 0., sh_z = 0., rot_z = 0.; double sh_r_e = 0., sh_x_e = 0., sh_y_e = 0., sh_z_e = 0., rot_z_e = 0.; -// unsigned int id = 0; + unsigned int id = 0; bool idSet = false; // get attributes DOMNamedNodeMap* attr = n->getAttributes(); - for (unsigned int j = 0; j < attr->getLength(); j++) { + for (unsigned int j = 0; j < attr->getLength(); j++) + { DOMNode *a = attr->item(j); //printf("\t%s\n", XMLString::transcode(a->getNodeName())); - if (!strcmp(XMLString::transcode(a->getNodeName()), "id")) { -// id = atoi(XMLString::transcode(a->getNodeValue())); + if (!strcmp(XMLString::transcode(a->getNodeName()), "id")) + { + id = atoi(XMLString::transcode(a->getNodeValue())); idSet = true; } else if (!strcmp(XMLString::transcode(a->getNodeName()), "sh_r")) sh_r = atof(XMLString::transcode(a->getNodeValue())); @@ -156,18 +163,18 @@ RPAlignmentCorrectionsData RPAlignmentCorrectionsMethods::GetCorrectionsData(DOM //printf("id = %u\n", id); -// // add the alignment to the right list -// if (nodeType == 1) -// AddSensorCorrection(id, a, true); -// else -// AddRPCorrection(id, a, true); - - + // add the alignment to the right list + if (nodeType == 1) + result.AddSensorCorrection(id, a, true); + else + result.AddRPCorrection(id, a, true); } - return RPAlignmentCorrectionsData(); + return result; } +//---------------------------------------------------------------------------------------------------- + #define WRITE(q, dig, lim) \ if (precise) \ fprintf(f, " " #q "=\"%.15E\"", q()*1E3);\ @@ -254,7 +261,6 @@ void RPAlignmentCorrectionsMethods::WriteXML(const RPAlignmentCorrectionData & d #undef WRITE - //---------------------------------------------------------------------------------------------------- void RPAlignmentCorrectionsMethods::WriteXMLFile(const RPAlignmentCorrectionsData & data, const string &fileName, bool precise, bool wrErrors, bool wrSh_r, diff --git a/RecoCTPPS/Configuration/python/RecoCTPPS_EventContent_cff.py b/RecoCTPPS/Configuration/python/RecoCTPPS_EventContent_cff.py deleted file mode 100644 index d3a92a827ab..00000000000 --- a/RecoCTPPS/Configuration/python/RecoCTPPS_EventContent_cff.py +++ /dev/null @@ -1,42 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -RecoCTPPSFEVT = cms.PSet( - outputCommands = cms.untracked.vstring( - 'keep TotemFEDInfos_totemRPRawToDigi_*_*', - 'keep TotemTriggerCounters_totemTriggerRawToDigi_*_*', - 'keep TotemRPDigiedmDetSetVector_totemRPRawToDigi_*_*', - 'keep TotemVFATStatusedmDetSetVector_totemRPRawToDigi_*_*', - 'keep TotemRPClusteredmDetSetVector_totemRPClusterProducer_*_*', - 'keep TotemRPRecHitedmDetSetVector_totemRPRecHitProducer_*_*', - 'keep TotemRPUVPatternedmDetSetVector_totemRPUVPatternFinder_*_*', - 'keep TotemRPLocalTrackedmDetSetVector_totemRPLocalTrackFitter_*_*' - ) -) - - -RecoCTPPSRECO = cms.PSet( - outputCommands = cms.untracked.vstring( - 'keep TotemFEDInfos_totemRPRawToDigi_*_*', - 'keep TotemTriggerCounters_totemTriggerRawToDigi_*_*', - 'keep TotemRPDigiedmDetSetVector_totemRPRawToDigi_*_*', - 'keep TotemVFATStatusedmDetSetVector_totemRPRawToDigi_*_*', - 'keep TotemRPClusteredmDetSetVector_totemRPClusterProducer_*_*', - 'keep TotemRPRecHitedmDetSetVector_totemRPRecHitProducer_*_*', - 'keep TotemRPUVPatternedmDetSetVector_totemRPUVPatternFinder_*_*', - 'keep TotemRPLocalTrackedmDetSetVector_totemRPLocalTrackFitter_*_*' - ) -) - - -RecoCTPPSAOD = cms.PSet( - outputCommands = cms.untracked.vstring( - 'keep TotemFEDInfos_totemRPRawToDigi_*_*', - 'keep TotemTriggerCounters_totemTriggerRawToDigi_*_*', - 'keep TotemRPDigiedmDetSetVector_totemRPRawToDigi_*_*', - 'keep TotemVFATStatusedmDetSetVector_totemRPRawToDigi_*_*', - 'keep TotemRPClusteredmDetSetVector_totemRPClusterProducer_*_*', - 'keep TotemRPRecHitedmDetSetVector_totemRPRecHitProducer_*_*', - 'keep TotemRPUVPatternedmDetSetVector_totemRPUVPatternFinder_*_*', - 'keep TotemRPLocalTrackedmDetSetVector_totemRPLocalTrackFitter_*_*' - ) -) diff --git a/RecoCTPPS/Configuration/python/recoCTPPS_cff.py b/RecoCTPPS/Configuration/python/recoCTPPS_cff.py deleted file mode 100644 index 5f88db9e179..00000000000 --- a/RecoCTPPS/Configuration/python/recoCTPPS_cff.py +++ /dev/null @@ -1,4 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -from RecoCTPPS.TotemRPLocal.totemRPLocalReconstruction_cff import * -recoCTPPS = cms.Sequence(totemRPLocalReconstruction) diff --git a/RecoCTPPS/Configuration/test/raw_data_test.py b/RecoCTPPS/Configuration/test/raw_data_test.py deleted file mode 100644 index 0f70e01c7a7..00000000000 --- a/RecoCTPPS/Configuration/test/raw_data_test.py +++ /dev/null @@ -1,44 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -process = cms.Process("TotemStandaloneRawDataTest") - -# minimum of logs -process.MessageLogger = cms.Service("MessageLogger", - statistics = cms.untracked.vstring(), - destinations = cms.untracked.vstring('cout'), - cout = cms.untracked.PSet( - threshold = cms.untracked.string('WARNING') - ) -) - -# raw data source -process.source = cms.Source("PoolSource", - #fileNames = cms.untracked.vstring("file:/afs/cern.ch/user/j/jkaspar/public/run273062_ls0001-2_stream.root") - fileNames = cms.untracked.vstring("/store/express/Run2016B/ExpressPhysics/FEVT/Express-v2/000/274/421/00000/FC63E66E-AB2A-E611-8BD9-02163E0144FB.root") - #fileNames = cms.untracked.vstring("/store/data/Run2016B/JetHT/RAW/v2/000/273/725/00000/9817A8A7-4F1E-E611-9248-02163E011EB4.root") -) - -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(-1) -) - -# raw-to-digi conversion -process.load("EventFilter.TotemRawToDigi.totemRawToDigi_cff") - -# RP reconstruction chain with standard settings -process.load("RecoCTPPS.Configuration.recoCTPPS_cff") - -process.p = cms.Path( - process.totemTriggerRawToDigi * - process.totemRPRawToDigi * - process.recoCTPPS -) - -# output configuration -from RecoCTPPS.Configuration.RecoCTPPS_EventContent_cff import RecoCTPPSAOD -process.output = cms.OutputModule("PoolOutputModule", - fileName = cms.untracked.string("file:./AOD.root"), - outputCommands = RecoCTPPSAOD.outputCommands -) - -process.outpath = cms.EndPath(process.output) diff --git a/RecoCTPPS/TotemRPLocal/BuildFile.xml b/RecoCTPPS/TotemRPLocal/BuildFile.xml deleted file mode 100644 index 75b8b3755e0..00000000000 --- a/RecoCTPPS/TotemRPLocal/BuildFile.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/RecoCTPPS/TotemRPLocal/interface/FastLineRecognition.h b/RecoCTPPS/TotemRPLocal/interface/FastLineRecognition.h deleted file mode 100644 index 53e8f35e805..00000000000 --- a/RecoCTPPS/TotemRPLocal/interface/FastLineRecognition.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#ifndef RecoCTPPS_TotemRPLocal_FastLineRecognition -#define RecoCTPPS_TotemRPLocal_FastLineRecognition - -#include "DataFormats/Common/interface/DetSet.h" -#include "DataFormats/Common/interface/DetSetVector.h" - -#include "Geometry/VeryForwardGeometryBuilder/interface/TotemRPGeometry.h" -#include "DataFormats/CTPPSReco/interface/TotemRPRecHit.h" -#include "DataFormats/CTPPSReco/interface/TotemRPUVPattern.h" - - -/** - * \brief Class performing optimized hough transform to recognize lines. -**/ - -class FastLineRecognition -{ - public: - FastLineRecognition(double cw_a = 0., double cw_b = 0.); - - ~FastLineRecognition(); - - void resetGeometry(const TotemRPGeometry *_g) - { - geometry = _g; - geometryMap.clear(); - } - - void getPatterns(const edm::DetSetVector &input, double _z0, double threshold, - edm::DetSet &patterns); - - protected: - /// the uncertainty of 1-hit cluster, in mm - static const double sigma0; - - /// "typical" z - double z0; - - /// cluster half widths in a and b - double chw_a, chw_b; - - /// weight threshold for accepting pattern candidates (clusters) - double threshold; - - /// pointer to the geometry - const TotemRPGeometry* geometry; - - struct GeomData - { - double z; ///< z position of a sensor (wrt. IP) - double s; ///< sensor's centre projected to its read-out direction - }; - - /// map: raw detector id --> GeomData - std::map geometryMap; - - /// expects raw detector id - GeomData getGeomData(unsigned int id); - - struct Point - { - unsigned int detId; ///< raw detector id - const TotemRPRecHit* hit; ///< pointer to original reco hit - double h; ///< hit position in global coordinate system - double z; ///< z position with respect to z0 - double w; ///< weight - bool usable; ///< whether the point can still be used - Point(unsigned int _d=0, const TotemRPRecHit* _hit=NULL, double _h=0., double _z=0., double _w=0.) : - detId(_d), hit(_hit), h(_h), z(_z), w(_w), usable(true) {} - }; - - /// cluster of intersection points - struct Cluster - { - double Saw, Sbw, Sw, S1; - double weight; - double min_a, max_a, min_b, max_b; - - std::vector contents; - - Cluster() : Saw(0.), Sbw(0.), Sw(0.), S1(0.), weight(0.) {} - - void add(const Point *p1, const Point *p2, double a, double b, double w); - - bool operator<(const Cluster &c) const - { - return (this->Sw > c.Sw) ? true : false; - } - }; - - /// gets the most significant pattern in the (remaining) points - /// returns true when a pattern was found - bool getOneLine(const std::vector &points, double threshold, Cluster &result); -}; - -#endif - diff --git a/RecoCTPPS/TotemRPLocal/interface/TotemRPClusterProducerAlgorithm.h b/RecoCTPPS/TotemRPLocal/interface/TotemRPClusterProducerAlgorithm.h deleted file mode 100644 index 8708b0c17c0..00000000000 --- a/RecoCTPPS/TotemRPLocal/interface/TotemRPClusterProducerAlgorithm.h +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Hubert Niewiadomski -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#ifndef RecoCTPPS_TotemRPLocal_TotemRPClusterProducerAlgorithm -#define RecoCTPPS_TotemRPLocal_TotemRPClusterProducerAlgorithm - -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "SimDataFormats/TrackingHit/interface/PSimHit.h" - -#include "DataFormats/TotemDigi/interface/TotemRPDigi.h" -#include "DataFormats/CTPPSReco/interface/TotemRPCluster.h" - -#include -#include - -class TotemRPClusterProducerAlgorithm -{ - public: - TotemRPClusterProducerAlgorithm(const edm::ParameterSet& param); - - ~TotemRPClusterProducerAlgorithm(); - - int buildClusters(unsigned int detId, const std::vector &digi, std::vector &clusters); - - private: - typedef std::set TotemRPDigiSet; - - TotemRPDigiSet strip_digi_set_; ///< input digi set, strip by strip - - const edm::ParameterSet ¶m_; - - int verbosity_; -}; - -#endif diff --git a/RecoCTPPS/TotemRPLocal/interface/TotemRPLocalTrackFitterAlgorithm.h b/RecoCTPPS/TotemRPLocal/interface/TotemRPLocalTrackFitterAlgorithm.h deleted file mode 100644 index 781bccc9027..00000000000 --- a/RecoCTPPS/TotemRPLocal/interface/TotemRPLocalTrackFitterAlgorithm.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Hubert Niewiadomski -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#ifndef RecoCTPPS_TotemRPLocal_TotemRPLocalTrackFitterAlgorithm -#define RecoCTPPS_TotemRPLocal_TotemRPLocalTrackFitterAlgorithm - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "DataFormats/Common/interface/DetSetVector.h" -#include "DataFormats/CTPPSReco/interface/TotemRPRecHit.h" -#include "DataFormats/CTPPSReco/interface/TotemRPLocalTrack.h" - -#include "Geometry/VeryForwardGeometryBuilder/interface/TotemRPGeometry.h" -#include "Geometry/VeryForwardRPTopology/interface/RPTopology.h" - -#include "TVector3.h" -#include "TVector2.h" - -#include - -//---------------------------------------------------------------------------------------------------- - -/** - *\brief Algorithm for fitting tracks through a single RP. - **/ -class TotemRPLocalTrackFitterAlgorithm -{ - public: - TotemRPLocalTrackFitterAlgorithm(const edm::ParameterSet &conf); - - /// performs the track fit, returns true if successful - bool fitTrack(const edm::DetSetVector &hits, double z_0, const TotemRPGeometry &tot_geom, TotemRPLocalTrack &fitted_track); - - /// Resets the reconstruction-data cache. - void reset(); - - private: - struct RPDetCoordinateAlgebraObjs - { - TVector3 centre_of_det_global_position_; - double rec_u_0_; ///< in mm, position of det. centre projected on readout direction - TVector2 readout_direction_; ///< non paralell projection and rot_cor included - bool available_; ///< if det should be included in the reconstruction - }; - - /// A cache of reconstruction data. Must be reset every time the geometry chagnges. - unordered_map det_data_map_; - - RPTopology rp_topology_; - - /// Returns the reconstruction data for the chosen detector from the cache DetReconstructionDataMap. - /// If it is not yet in the cache, calls PrepareReconstAlgebraData to make it. - RPDetCoordinateAlgebraObjs *getDetAlgebraData(unsigned int det_id, const TotemRPGeometry &tot_rp_geom); - - /// Build the reconstruction data. - RPDetCoordinateAlgebraObjs prepareReconstAlgebraData(unsigned int det_id, const TotemRPGeometry &tot_rp_geom); - - /// A matrix multiplication shorthand. - void multiplyByDiagonalInPlace(TMatrixD &mt, const TVectorD &diag); - - static TVector3 convert3vector(const CLHEP::Hep3Vector & v) - { - return TVector3(v.x(),v.y(),v.z()) ; - } -}; - -#endif diff --git a/RecoCTPPS/TotemRPLocal/interface/TotemRPRecHitProducerAlgorithm.h b/RecoCTPPS/TotemRPLocal/interface/TotemRPRecHitProducerAlgorithm.h deleted file mode 100644 index 0e47d497443..00000000000 --- a/RecoCTPPS/TotemRPLocal/interface/TotemRPRecHitProducerAlgorithm.h +++ /dev/null @@ -1,34 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Hubert Niewiadomski -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#ifndef RecoCTPPS_TotemRPLocal_TotemRPRecHitProducerAlgorithm -#define RecoCTPPS_TotemRPLocal_TotemRPRecHitProducerAlgorithm - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "DataFormats/Common/interface/DetSet.h" -#include "DataFormats/CTPPSReco/interface/TotemRPCluster.h" -#include "DataFormats/CTPPSReco/interface/TotemRPRecHit.h" - -#include "Geometry/VeryForwardRPTopology/interface/RPTopology.h" - -class TotemRPRecHitProducerAlgorithm -{ - public: - TotemRPRecHitProducerAlgorithm(const edm::ParameterSet& conf) - { - } - - void buildRecoHits(const edm::DetSet& input, edm::DetSet& output); - - private: - RPTopology rp_topology_; -}; - -#endif diff --git a/RecoCTPPS/TotemRPLocal/plugins/BuildFile.xml b/RecoCTPPS/TotemRPLocal/plugins/BuildFile.xml deleted file mode 100644 index 1a610dc313d..00000000000 --- a/RecoCTPPS/TotemRPLocal/plugins/BuildFile.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/RecoCTPPS/TotemRPLocal/plugins/TotemRPClusterProducer.cc b/RecoCTPPS/TotemRPLocal/plugins/TotemRPClusterProducer.cc deleted file mode 100644 index e8fb880a4c1..00000000000 --- a/RecoCTPPS/TotemRPLocal/plugins/TotemRPClusterProducer.cc +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Hubert Niewiadomski -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/Framework/interface/stream/EDProducer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "DataFormats/Common/interface/DetSetVector.h" -#include "DataFormats/Common/interface/DetSet.h" -#include "DataFormats/TotemDigi/interface/TotemRPDigi.h" - -#include "RecoCTPPS/TotemRPLocal/interface/TotemRPClusterProducerAlgorithm.h" - -//---------------------------------------------------------------------------------------------------- - -/** - * Merges neighbouring active TOTEM RP strips into clusters. - **/ -class TotemRPClusterProducer : public edm::stream::EDProducer<> -{ - public: - - explicit TotemRPClusterProducer(const edm::ParameterSet& conf); - - virtual ~TotemRPClusterProducer() {} - - virtual void produce(edm::Event& e, const edm::EventSetup& c) override; - - private: - edm::ParameterSet conf_; - int verbosity_; - edm::InputTag digiInputTag_; - edm::EDGetTokenT> digiInputTagToken_; - - TotemRPClusterProducerAlgorithm algorithm_; - - void run(const edm::DetSetVector &input, edm::DetSetVector &output); -}; - -//---------------------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------------------- - -using namespace std; -using namespace edm; - -//---------------------------------------------------------------------------------------------------- - -TotemRPClusterProducer::TotemRPClusterProducer(edm::ParameterSet const& conf) : - conf_(conf), algorithm_(conf) -{ - verbosity_ = conf.getParameter("verbosity"); - - digiInputTag_ = conf.getParameter("tagDigi"); - digiInputTagToken_ = consumes >(digiInputTag_); - - produces< edm::DetSetVector > (); -} - -//---------------------------------------------------------------------------------------------------- - -void TotemRPClusterProducer::produce(edm::Event& e, const edm::EventSetup& es) -{ - // get input - edm::Handle< edm::DetSetVector > input; - e.getByToken(digiInputTagToken_, input); - - // prepare output - DetSetVector output; - - // run clusterisation - if (input->size()) - run(*input, output); - - // save output to event - e.put(make_unique>(output)); -} - -//---------------------------------------------------------------------------------------------------- - -void TotemRPClusterProducer::run(const edm::DetSetVector& input, edm::DetSetVector &output) -{ - for (const auto &ds_digi : input) - { - edm::DetSet &ds_cluster = output.find_or_insert(ds_digi.id); - - algorithm_.buildClusters(ds_digi.id, ds_digi.data, ds_cluster.data); - } -} - -//---------------------------------------------------------------------------------------------------- - -DEFINE_FWK_MODULE(TotemRPClusterProducer); diff --git a/RecoCTPPS/TotemRPLocal/plugins/TotemRPLocalTrackFitter.cc b/RecoCTPPS/TotemRPLocal/plugins/TotemRPLocalTrackFitter.cc deleted file mode 100644 index 22e8b7c2019..00000000000 --- a/RecoCTPPS/TotemRPLocal/plugins/TotemRPLocalTrackFitter.cc +++ /dev/null @@ -1,187 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Hubert Niewiadomski -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Framework/interface/stream/EDProducer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/ESWatcher.h" - -#include "DataFormats/Common/interface/DetSetVector.h" -#include "DataFormats/CTPPSReco/interface/TotemRPRecHit.h" -#include "DataFormats/CTPPSReco/interface/TotemRPUVPattern.h" -#include "DataFormats/CTPPSReco/interface/TotemRPLocalTrack.h" - -#include "Geometry/Records/interface/VeryForwardRealGeometryRecord.h" -#include "Geometry/VeryForwardGeometryBuilder/interface/TotemRPGeometry.h" - -#include "RecoCTPPS/TotemRPLocal/interface/TotemRPLocalTrackFitterAlgorithm.h" - -//---------------------------------------------------------------------------------------------------- - -/** - *\brief Fits tracks trough a single RP. - **/ -class TotemRPLocalTrackFitter : public edm::stream::EDProducer<> -{ - public: - explicit TotemRPLocalTrackFitter(const edm::ParameterSet& conf); - - virtual ~TotemRPLocalTrackFitter() {} - - virtual void produce(edm::Event& e, const edm::EventSetup& c) override; - - private: - int verbosity_; - - /// Selection of the pattern-recognition module. - edm::InputTag tagUVPattern; - - edm::EDGetTokenT> patternCollectionToken; - - /// A watcher to detect geometry changes. - edm::ESWatcher geometryWatcher; - - /// The instance of the fitter module - TotemRPLocalTrackFitterAlgorithm fitter_; -}; - -//---------------------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------------------- - -using namespace std; -using namespace edm; - -//---------------------------------------------------------------------------------------------------- - -TotemRPLocalTrackFitter::TotemRPLocalTrackFitter(const edm::ParameterSet& conf) - : verbosity_(conf.getParameter("verbosity")), fitter_(conf) -{ - tagUVPattern = conf.getParameter("tagUVPattern"); - patternCollectionToken = consumes>(tagUVPattern); - - produces>(); -} - -//---------------------------------------------------------------------------------------------------- - -void TotemRPLocalTrackFitter::produce(edm::Event& e, const edm::EventSetup& setup) -{ - if (verbosity_ > 5) - LogVerbatim("TotemRPLocalTrackFitter") << ">> TotemRPLocalTrackFitter::produce"; - - // get geometry - edm::ESHandle geometry; - setup.get().get(geometry); - - if (geometryWatcher.check(setup)) - fitter_.reset(); - - // get input - edm::Handle> input; - e.getByToken(patternCollectionToken, input); - - // run fit for each RP - DetSetVector output; - - for (const auto &rpv : *input) - { - det_id_type rpId = rpv.detId(); - - // is U-V association unique? - unsigned int n_U=0, n_V=0; - unsigned int idx_U=0, idx_V=0; - for (unsigned int pi = 0; pi < rpv.size(); pi++) - { - const TotemRPUVPattern &pattern = rpv[pi]; - - // here it would make sense to skip non-fittable patterns, but to keep the logic - // equivalent to version 7_0_4, nothing is skipped - /* - if (pattern.getFittable() == false) - continue; - */ - - switch (pattern.getProjection()) - { - case TotemRPUVPattern::projU: - n_U++; - idx_U=pi; - break; - - case TotemRPUVPattern::projV: - n_V++; - idx_V=pi; - break; - - default: - break; - } - } - - if (n_U != 1 || n_V != 1) - { - if (verbosity_) - LogVerbatim("TotemRPLocalTrackFitter") - << ">> TotemRPLocalTrackFitter::produce > Impossible to combine U and V patterns in RP " << rpId - << " (n_U=" << n_U << ", n_V=" << n_V << ")."; - - continue; - } - - // again, to follow the logic from version 7_0_4, skip the non-fittable patterns here - if (!rpv[idx_U].getFittable() || !rpv[idx_V].getFittable()) - continue; - - // combine U and V hits - DetSetVector hits; - for (auto &ids : rpv[idx_U].getHits()) - { - auto &ods = hits.find_or_insert(ids.detId()); - for (auto &h : ids) - ods.push_back(h); - } - - for (auto &ids : rpv[idx_V].getHits()) - { - auto &ods = hits.find_or_insert(ids.detId()); - for (auto &h : ids) - ods.push_back(h); - } - - // run fit - double z0 = geometry->GetRPGlobalTranslation(rpId).z(); - - TotemRPLocalTrack track; - fitter_.fitTrack(hits, z0, *geometry, track); - - DetSet &ds = output.find_or_insert(rpId); - ds.push_back(track); - - if (verbosity_ > 5) - { - unsigned int n_hits = 0; - for (auto &hds : track.getHits()) - n_hits += hds.size(); - - LogVerbatim("TotemRPLocalTrackFitter") - << " track in RP " << rpId << ": valid = " << track.isValid() << ", hits = " << n_hits; - } - } - - // save results - e.put(make_unique>(output)); -} - -//---------------------------------------------------------------------------------------------------- - -DEFINE_FWK_MODULE(TotemRPLocalTrackFitter); diff --git a/RecoCTPPS/TotemRPLocal/plugins/TotemRPRecHitProducer.cc b/RecoCTPPS/TotemRPLocal/plugins/TotemRPRecHitProducer.cc deleted file mode 100644 index ada4d3d8050..00000000000 --- a/RecoCTPPS/TotemRPLocal/plugins/TotemRPRecHitProducer.cc +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Hubert Niewiadomski -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/Framework/interface/stream/EDProducer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "DataFormats/Common/interface/DetSetVector.h" -#include "DataFormats/Common/interface/DetSet.h" -#include "DataFormats/CTPPSReco/interface/TotemRPCluster.h" -#include "DataFormats/CTPPSReco/interface/TotemRPRecHit.h" - -#include "RecoCTPPS/TotemRPLocal/interface/TotemRPRecHitProducerAlgorithm.h" - -//---------------------------------------------------------------------------------------------------- - -class TotemRPRecHitProducer : public edm::stream::EDProducer<> -{ - public: - - explicit TotemRPRecHitProducer(const edm::ParameterSet& conf); - - virtual ~TotemRPRecHitProducer() {} - - virtual void produce(edm::Event& e, const edm::EventSetup& c) override; - - private: - const edm::ParameterSet conf_; - int verbosity_; - - TotemRPRecHitProducerAlgorithm algorithm_; - - edm::InputTag tagCluster_; - edm::EDGetTokenT> tokenCluster_; -}; - -//---------------------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------------------- - -using namespace std; -using namespace edm; - -//---------------------------------------------------------------------------------------------------- - -TotemRPRecHitProducer::TotemRPRecHitProducer(const edm::ParameterSet& conf) : - conf_(conf), algorithm_(conf) -{ - verbosity_ = conf.getParameter("verbosity"); - - tagCluster_ = conf.getParameter("tagCluster"); - tokenCluster_ = consumes >(tagCluster_); - - produces>(); -} - -//---------------------------------------------------------------------------------------------------- - -void TotemRPRecHitProducer::produce(edm::Event& e, const edm::EventSetup& es) -{ - // get input - edm::Handle< edm::DetSetVector > input; - e.getByToken(tokenCluster_, input); - - // prepare output - DetSetVector output; - - // build reco hits - for (auto &ids : *input) - { - DetSet &ods = output.find_or_insert(ids.detId()); - algorithm_.buildRecoHits(ids, ods); - } - - // save output - e.put(make_unique>(output)); -} - -//---------------------------------------------------------------------------------------------------- - -DEFINE_FWK_MODULE(TotemRPRecHitProducer); diff --git a/RecoCTPPS/TotemRPLocal/plugins/TotemRPUVPatternFinder.cc b/RecoCTPPS/TotemRPLocal/plugins/TotemRPUVPatternFinder.cc deleted file mode 100644 index 5667fc2bd8f..00000000000 --- a/RecoCTPPS/TotemRPLocal/plugins/TotemRPUVPatternFinder.cc +++ /dev/null @@ -1,298 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#include "FWCore/Framework/interface/stream/EDProducer.h" -#include "FWCore/Framework/interface/ESWatcher.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "DataFormats/Common/interface/DetSetVector.h" -#include "DataFormats/Common/interface/DetSet.h" -#include "DataFormats/TotemRPDetId/interface/TotemRPDetId.h" -#include "DataFormats/CTPPSReco/interface/TotemRPRecHit.h" -#include "DataFormats/CTPPSReco/interface/TotemRPUVPattern.h" - -#include "Geometry/Records/interface/VeryForwardRealGeometryRecord.h" -#include "Geometry/VeryForwardGeometryBuilder/interface/TotemRPGeometry.h" - -#include "RecoCTPPS/TotemRPLocal/interface/FastLineRecognition.h" - -//---------------------------------------------------------------------------------------------------- - -/** - * \brief Class to recognize straight line tracks, based on optimized Hough trasform. - * - * The search is perfomed in global U,V coordinates (wrt. beam). In this way (some of) - * the alignment corrections can be taken into account. -**/ -class TotemRPUVPatternFinder : public edm::stream::EDProducer<> -{ - public: - TotemRPUVPatternFinder(const edm::ParameterSet& conf); - - virtual ~TotemRPUVPatternFinder(); - - virtual void produce(edm::Event& e, const edm::EventSetup& c) override; - - private: - edm::InputTag tagRecHit; - edm::EDGetTokenT > detSetVectorTotemRPRecHitToken; - - unsigned int verbosity; - - /// minimal required number of active planes per projection to even start track recognition - unsigned char minPlanesPerProjectionToSearch; - - /// minimal required number of active planes per projection to mark track candidate as fittable - unsigned char minPlanesPerProjectionToFit; - - /// above this limit, planes are considered noisy - unsigned int maxHitsPerPlaneToSearch; - - /// the line recognition algorithm - FastLineRecognition *lrcgn; - - /// minimal weight of (Hough) cluster to accept it as candidate - double threshold; - - /// maximal angle (in any projection) to mark candidate as fittable - controls track parallelity - double max_a_toFit; - - /// block of (exceptional) settings for 1 RP - struct RPSettings - { - unsigned char minPlanesPerProjectionToFit_U, minPlanesPerProjectionToFit_V; - double threshold_U, threshold_V; - }; - - /// exceptional settings: RP Id --> settings - std::map exceptionalSettings; - - edm::ESWatcher geometryWatcher; - - /// executes line recognition in a projection - void recognizeAndSelect(TotemRPUVPattern::ProjectionType proj, double z0, double threshold, - unsigned int planes_required, - const edm::DetSetVector &hits, edm::DetSet &patterns); -}; - -//---------------------------------------------------------------------------------------------------- - -using namespace std; -using namespace edm; - -//---------------------------------------------------------------------------------------------------- - -TotemRPUVPatternFinder::TotemRPUVPatternFinder(const edm::ParameterSet& conf) : - tagRecHit(conf.getParameter("tagRecHit")), - verbosity(conf.getUntrackedParameter("verbosity", 0)), - minPlanesPerProjectionToSearch(conf.getParameter("minPlanesPerProjectionToSearch")), - minPlanesPerProjectionToFit(conf.getParameter("minPlanesPerProjectionToFit")), - maxHitsPerPlaneToSearch(conf.getParameter("maxHitsPerPlaneToSearch")), - lrcgn(new FastLineRecognition(conf.getParameter("clusterSize_a"), conf.getParameter("clusterSize_b"))), - threshold(conf.getParameter("threshold")), - max_a_toFit(conf.getParameter("max_a_toFit")) -{ - for (const auto &ps : conf.getParameter< vector >("exceptionalSettings")) - { - unsigned int rpId = ps.getParameter("rpId"); - - RPSettings settings; - settings.minPlanesPerProjectionToFit_U = ps.getParameter("minPlanesPerProjectionToFit_U"); - settings.minPlanesPerProjectionToFit_V = ps.getParameter("minPlanesPerProjectionToFit_V"); - settings.threshold_U = ps.getParameter("threshold_U"); - settings.threshold_V = ps.getParameter("threshold_V"); - - exceptionalSettings[rpId] = settings; - } - - detSetVectorTotemRPRecHitToken = consumes >(tagRecHit); - - produces>(); -} - -//---------------------------------------------------------------------------------------------------- - -TotemRPUVPatternFinder::~TotemRPUVPatternFinder() -{ - delete lrcgn; -} - -//---------------------------------------------------------------------------------------------------- - -void TotemRPUVPatternFinder::recognizeAndSelect(TotemRPUVPattern::ProjectionType proj, - double z0, double threshold_loc, unsigned int planes_required, - const DetSetVector &hits, DetSet &patterns) -{ - // run recognition - DetSet newPatterns; - lrcgn->getPatterns(hits, z0, threshold_loc, newPatterns); - - // set pattern properties and copy to the global pattern collection - for (auto &p : newPatterns) - { - p.setProjection(proj); - - p.setFittable(true); - - set planes; - for (const auto &ds : p.getHits()) - planes.insert(TotemRPDetId::rawToDecId(ds.detId()) % 10); - - if (planes.size() < planes_required) - p.setFittable(false); - - if (fabs(p.getA()) > max_a_toFit) - p.setFittable(false); - - patterns.push_back(p); - } -} - -//---------------------------------------------------------------------------------------------------- - -void TotemRPUVPatternFinder::produce(edm::Event& event, const edm::EventSetup& es) -{ - if (verbosity > 5) - LogVerbatim("TotemRPUVPatternFinder") - << ">> TotemRPUVPatternFinder::produce " << event.id().run() << ":" << event.id().event(); - - // geometry - ESHandle geometry; - es.get().get(geometry); - if (geometryWatcher.check(es)) - lrcgn->resetGeometry(geometry.product()); - - // get input - edm::Handle< edm::DetSetVector > input; - event.getByToken(detSetVectorTotemRPRecHitToken, input); - - // prepare output - DetSetVector patternsVector; - - // split input per RP and per U/V projection - struct RPData - { - DetSetVector hits_U, hits_V; - map planeOccupancy_U, planeOccupancy_V; - }; - map rpData; - - for (auto &ids : *input) - { - unsigned int detId = TotemRPDetId::rawToDecId(ids.detId()); - unsigned int rpId = TotemRPDetId::rpOfDet(detId); - unsigned int plane = detId % 10; - bool uDir = TotemRPDetId::isStripsCoordinateUDirection(detId); - - RPData &data = rpData[rpId]; - - for (auto &h : ids) - { - if (uDir) - { - auto &ods = data.hits_U.find_or_insert(ids.detId()); - ods.push_back(h); - data.planeOccupancy_U[plane]++; - } else { - auto &ods = data.hits_V.find_or_insert(ids.detId()); - ods.push_back(h); - data.planeOccupancy_V[plane]++; - } - } - } - - // track recognition pot by pot - for (auto it : rpData) - { - unsigned int rpId = it.first; - RPData &data = it.second; - - // merge default and exceptional settings (if available) - unsigned int minPlanesPerProjectionToFit_U = minPlanesPerProjectionToFit; - unsigned int minPlanesPerProjectionToFit_V = minPlanesPerProjectionToFit; - double threshold_U = threshold; - double threshold_V = threshold; - - auto setIt = exceptionalSettings.find(rpId); - if (setIt != exceptionalSettings.end()) - { - minPlanesPerProjectionToFit_U = setIt->second.minPlanesPerProjectionToFit_U; - minPlanesPerProjectionToFit_V = setIt->second.minPlanesPerProjectionToFit_V; - threshold_U = setIt->second.threshold_U; - threshold_V = setIt->second.threshold_V; - } - - auto &uColl = data.planeOccupancy_U; - auto &vColl = data.planeOccupancy_V; - - if (verbosity > 5) - { - LogVerbatim("TotemRPUVPatternFinder") - << "\tRP " << rpId - << "\n\t\tall planes: u = " << uColl.size() << ", v = " << vColl.size(); - } - - // count planes with clean data (no showers, noise, ...) - unsigned int uPlanes = 0, vPlanes = 0; - for (auto pit : uColl) - if (pit.second <= maxHitsPerPlaneToSearch) - uPlanes++; - - for (auto pit : vColl) - if (pit.second <= maxHitsPerPlaneToSearch) - vPlanes++; - - if (verbosity > 5) - LogVerbatim("TotemRPUVPatternFinder") << "\t\tplanes with clean data: u = " << uPlanes << ", v = " << vPlanes; - - // discard RPs with too few reasonable planes - if (uPlanes < minPlanesPerProjectionToSearch || vPlanes < minPlanesPerProjectionToSearch) - continue; - - // prepare data containers - DetSet &patterns = patternsVector.find_or_insert(rpId); - - // "typical" z0 for the RP - double z0 = geometry->GetRPDevice(rpId)->translation().z(); - - // u then v recognition - recognizeAndSelect(TotemRPUVPattern::projU, z0, threshold_U, minPlanesPerProjectionToFit_U, data.hits_U, patterns); - - recognizeAndSelect(TotemRPUVPattern::projV, z0, threshold_V, minPlanesPerProjectionToFit_V, data.hits_V, patterns); - - if (verbosity > 5) - { - LogVerbatim("TotemRPUVPatternFinder") << "\t\tpatterns:"; - for (const auto &p : patterns) - { - unsigned int n_hits = 0; - for (auto &hds : p.getHits()) - n_hits += hds.size(); - - LogVerbatim("TotemRPUVPatternFinder") - << "\t\t\tproj = " << ((p.getProjection() == TotemRPUVPattern::projU) ? "U" : "V") - << ", a = " << p.getA() - << ", b = " << p.getB() - << ", w = " << p.getW() - << ", fittable = " << p.getFittable() - << ", hits = " << n_hits; - } - } - } - - // save output - event.put(make_unique>(patternsVector)); -} - -//---------------------------------------------------------------------------------------------------- - -DEFINE_FWK_MODULE(TotemRPUVPatternFinder); diff --git a/RecoCTPPS/TotemRPLocal/python/totemRPClusterProducer_cfi.py b/RecoCTPPS/TotemRPLocal/python/totemRPClusterProducer_cfi.py deleted file mode 100644 index 523c355faae..00000000000 --- a/RecoCTPPS/TotemRPLocal/python/totemRPClusterProducer_cfi.py +++ /dev/null @@ -1,6 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -totemRPClusterProducer = cms.EDProducer("TotemRPClusterProducer", - verbosity = cms.int32(0), - tagDigi = cms.InputTag("totemRPRawToDigi", "RP") -) diff --git a/RecoCTPPS/TotemRPLocal/python/totemRPLocalReconstruction_cff.py b/RecoCTPPS/TotemRPLocal/python/totemRPLocalReconstruction_cff.py deleted file mode 100644 index 005d3478211..00000000000 --- a/RecoCTPPS/TotemRPLocal/python/totemRPLocalReconstruction_cff.py +++ /dev/null @@ -1,23 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -# geometry -from Geometry.VeryForwardGeometry.geometryRP_cfi import * - -# clusterization -from RecoCTPPS.TotemRPLocal.totemRPClusterProducer_cfi import * - -# reco hit production -from RecoCTPPS.TotemRPLocal.totemRPRecHitProducer_cfi import * - -# non-parallel pattern recognition -from RecoCTPPS.TotemRPLocal.totemRPUVPatternFinder_cfi import * - -# local track fitting -from RecoCTPPS.TotemRPLocal.totemRPLocalTrackFitter_cfi import * - -totemRPLocalReconstruction = cms.Sequence( - totemRPClusterProducer * - totemRPRecHitProducer * - totemRPUVPatternFinder * - totemRPLocalTrackFitter -) diff --git a/RecoCTPPS/TotemRPLocal/python/totemRPLocalTrackFitter_cfi.py b/RecoCTPPS/TotemRPLocal/python/totemRPLocalTrackFitter_cfi.py deleted file mode 100644 index 9e8245a2cd9..00000000000 --- a/RecoCTPPS/TotemRPLocal/python/totemRPLocalTrackFitter_cfi.py +++ /dev/null @@ -1,7 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -totemRPLocalTrackFitter = cms.EDProducer("TotemRPLocalTrackFitter", - verbosity = cms.int32(0), - - tagUVPattern = cms.InputTag("totemRPUVPatternFinder") -) diff --git a/RecoCTPPS/TotemRPLocal/python/totemRPRecHitProducer_cfi.py b/RecoCTPPS/TotemRPLocal/python/totemRPRecHitProducer_cfi.py deleted file mode 100644 index dc4d0939ab1..00000000000 --- a/RecoCTPPS/TotemRPLocal/python/totemRPRecHitProducer_cfi.py +++ /dev/null @@ -1,6 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -totemRPRecHitProducer = cms.EDProducer("TotemRPRecHitProducer", - verbosity = cms.int32(0), - tagCluster = cms.InputTag("totemRPClusterProducer") -) diff --git a/RecoCTPPS/TotemRPLocal/python/totemRPUVPatternFinder_cfi.py b/RecoCTPPS/TotemRPLocal/python/totemRPUVPatternFinder_cfi.py deleted file mode 100644 index b13bc18a28c..00000000000 --- a/RecoCTPPS/TotemRPLocal/python/totemRPUVPatternFinder_cfi.py +++ /dev/null @@ -1,49 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -totemRPUVPatternFinder = cms.EDProducer("TotemRPUVPatternFinder", - # input selection - tagRecHit = cms.InputTag("totemRPRecHitProducer"), - - verbosity = cms.untracked.uint32(0), - - # if a plane has more hits than this parameter, it is considered as dirty - maxHitsPerPlaneToSearch = cms.uint32(5), - - # minimal number of reasonable (= not empty and not dirty) planes per projeciton and per RP, - # to start the pattern search - minPlanesPerProjectionToSearch = cms.uint32(3), - - # (full) cluster size in slope-intercept space - clusterSize_a = cms.double(0.02), # rad - clusterSize_b = cms.double(0.3), # mm - - # minimal weight of (Hough) cluster to accept it as candidate - # weight of cluster = sum of weights of contributing points - # weight of point = sigma0 / sigma_of_point - # most often: weight of point ~ 1, thus cluster weight is roughly number of contributing points - threshold = cms.double(2.99), - - # minimal number of planes (in the recognised patterns) per projeciton and per RP, - # to tag the candidate as fittable - minPlanesPerProjectionToFit = cms.uint32(3), - - # whether to allow combination of most significant U and V pattern, in case there several of them - # don't set it to True, unless you have reason - allowAmbiguousCombination = cms.bool(False), - - # maximal angle (in any projection) to mark the candidate as fittable -> controls track parallelity with beam - # huge value -> no constraint - max_a_toFit = cms.double(10.0), - - # if a RP or projection needs adjustment of the above settings, you can use the following format - # exceptionalSettings = cms.VPSet( - # cms.PSet( - # rpId = cms.uint32(20), - # minPlanesPerProjectionToFit_U = cms.uint32(2), - # minPlanesPerProjectionToFit_V = cms.uint32(3), - # threshold_U = cms.double(1.99), - # threshold_V = cms.double(2.99) - # ) - # ) - exceptionalSettings = cms.VPSet() -) diff --git a/RecoCTPPS/TotemRPLocal/src/FastLineRecognition.cc b/RecoCTPPS/TotemRPLocal/src/FastLineRecognition.cc deleted file mode 100644 index 9f7bb000143..00000000000 --- a/RecoCTPPS/TotemRPLocal/src/FastLineRecognition.cc +++ /dev/null @@ -1,308 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#include "RecoCTPPS/TotemRPLocal/interface/FastLineRecognition.h" - -#include "DataFormats/CTPPSReco/interface/TotemRPRecHit.h" - -#include "Geometry/VeryForwardGeometryBuilder/interface/TotemRPGeometry.h" - -#include -#include -#include -#include - -//#define CTPPS_DEBUG 1 - -using namespace std; -using namespace edm; - -//---------------------------------------------------------------------------------------------------- - -const double FastLineRecognition::sigma0 = 66E-3/sqrt(12.); - -//---------------------------------------------------------------------------------------------------- - -void FastLineRecognition::Cluster::add(const Point *p1, const Point *p2, double a, double b, double w) -{ - // which points to be added to contents? - bool add1 = true, add2 = true; - for (vector::const_iterator it = contents.begin(); it != contents.end() && (add1 || add2); ++it) - { - if ((*it)->hit == p1->hit) - add1 = false; - - if ((*it)->hit == p2->hit) - add2 = false; - } - - // add the points - if (add1) - contents.push_back(p1); - if (add2) - contents.push_back(p2); - - // update sums, mins and maxs - Saw += a*w; - Sbw += b*w; - Sw += w; - S1 += 1.; - - min_a = min(a, min_a); - min_b = min(b, min_b); - max_a = max(a, max_a); - max_b = max(b, max_b); -} - -//---------------------------------------------------------------------------------------------------- -//---------------------------------------------------------------------------------------------------- - -FastLineRecognition::FastLineRecognition(double cw_a, double cw_b) : - chw_a(cw_a/2.), chw_b(cw_b/2.), geometry(NULL) -{ -} - -//---------------------------------------------------------------------------------------------------- - -FastLineRecognition::~FastLineRecognition() -{ -} - -//---------------------------------------------------------------------------------------------------- - -FastLineRecognition::GeomData FastLineRecognition::getGeomData(unsigned int id) -{ - // result already buffered? - map::iterator it = geometryMap.find(id); - if (it != geometryMap.end()) - return it->second; - - // calculate it - CLHEP::Hep3Vector d = geometry->LocalToGlobalDirection(id, CLHEP::Hep3Vector(0., 1., 0.)); - DDTranslation c = geometry->GetDetector(id)->translation(); - GeomData gd; - gd.z = c.z(); - gd.s = d.x()*c.x() + d.y()*c.y(); - - geometryMap[id] = gd; - - return gd; -} - -//---------------------------------------------------------------------------------------------------- - -void FastLineRecognition::getPatterns(const DetSetVector &input, double z0, - double threshold, DetSet &patterns) -{ - // build collection of points in the global coordinate system - std::vector points; - for (auto &ds : input) - { - unsigned int detId = ds.detId(); - - for (auto &h : ds) - { - const TotemRPRecHit *hit = &h; - const GeomData &gd = getGeomData(detId); - - double p = hit->getPosition() + gd.s; - double z = gd.z - z0; - double w = sigma0 / hit->getSigma(); - - points.push_back(Point(detId, hit, p, z, w)); - } - } - -#if CTPPS_DEBUG > 0 - printf(">> FastLineRecognition::getPatterns(z0 = %E)\n", z0); - printf(">>>>>>>>>>>>>>>>>>>\n"); -#endif - - // reset output - patterns.clear(); - - Cluster c; - while (getOneLine(points, threshold, c)) - { - // convert cluster to pattern and save it - TotemRPUVPattern pattern; - pattern.setA(c.Saw/c.Sw); - pattern.setB(c.Sbw/c.Sw); - pattern.setW(c.weight); - -#if CTPPS_DEBUG > 0 - printf("\tpoints of the selected cluster: %lu\n", c.contents.size()); -#endif - - for (auto &pit : c.contents) - { -#if CTPPS_DEBUG > 0 - printf("\t\t%.1f\n", pit->z); -#endif - pattern.addHit(pit->detId, *(pit->hit)); - } - - patterns.push_back(pattern); - -#if CTPPS_DEBUG > 0 - unsigned int u_points_b = 0; - for (vector::iterator dit = points.begin(); dit != points.end(); ++dit) - if (dit->usable) - u_points_b++; - printf("\tusable points before: %u\n", u_points_b); -#endif - - // remove points belonging to the recognized line - for (vector::iterator hit = c.contents.begin(); hit != c.contents.end(); ++hit) - { - for (vector::iterator dit = points.begin(); dit != points.end(); ++dit) - { - //printf("\t\t1: %.2f, %p vs. 2: %.2f, %p\n", (*hit)->z, (*hit)->hit, dit->z, dit->hit); - if ((*hit)->hit == dit->hit) - { - dit->usable = false; - //points.erase(dit); - break; - } - } - } - -#if CTPPS_DEBUG > 0 - unsigned int u_points_a = 0; - for (vector::iterator dit = points.begin(); dit != points.end(); ++dit) - if (dit->usable) - u_points_a++; - printf("\tusable points after: %u\n", u_points_a); -#endif - } - -#if CTPPS_DEBUG > 0 - printf("patterns at end: %lu\n", patterns.size()); - printf("<<<<<<<<<<<<<<<<<<<\n"); -#endif -} - -//---------------------------------------------------------------------------------------------------- - -bool FastLineRecognition::getOneLine(const vector &points, - double threshold, FastLineRecognition::Cluster &result) -{ -#if CTPPS_DEBUG > 0 - printf("\tFastLineRecognition::getOneLine\n"); -#endif - - if (points.size() < 2) - return false; - - vector clusters; - - // go through all the combinations of measured points - for (vector::const_iterator it1 = points.begin(); it1 != points.end(); ++it1) - { - if (!it1->usable) - continue; - - for (vector::const_iterator it2 = it1; it2 != points.end(); ++it2) - { - if (!it2->usable) - continue; - - const double &z1 = it1->z; - const double &z2 = it2->z; - - if (z1 == z2) - continue; - - const double &p1 = it1->h; - const double &p2 = it2->h; - - const double &w1 = it1->w; - const double &w2 = it2->w; - - // calculate intersection - double a = (p2 - p1) / (z2 - z1); - double b = p1 - z1 * a; - double w = w1 + w2; - -#if CTPPS_DEBUG > 0 - printf("\t\t\tz: 1=%+5.1f, 2=%+5.1f | U/V: 1=%+6.3f, 2=%+6.3f | a=%+6.3f rad, b=%+6.3f mm, w=%.1f\n", z1, z2, p1, p2, a, b, w); -#endif - - // add it to the appropriate cluster - bool newCluster = true; - for (unsigned int k = 0; k < clusters.size(); k++) - { - Cluster &c = clusters[k]; - if (c.S1 < 1. || c.Sw <= 0.) - continue; - -#if CTPPS_DEBUG > 0 - if (k < 10) - printf("\t\t\t\ttest cluster %u at a=%+6.3f, b=%+6.3f : %+6.3f, %+6.3f : %i, %i\n", k, c.Saw/c.Sw, c.Sbw/c.Sw, - chw_a, chw_b, - (std::abs(a - c.Saw/c.Sw) < chw_a), (std::abs(b - c.Sbw/c.Sw) < chw_b)); -#endif - - if ((std::abs(a - c.Saw/c.Sw) < chw_a) && (std::abs(b - c.Sbw/c.Sw) < chw_b)) - { - newCluster = false; - clusters[k].add(& (*it1), & (*it2), a, b, w); -#if CTPPS_DEBUG > 0 - printf("\t\t\t\t--> cluster %u\n", k); -#endif - break; - } - } - - // make new cluster - if (newCluster) - { -#if CTPPS_DEBUG > 0 - printf("\t\t\t\t--> new cluster %lu\n", clusters.size()); -#endif - clusters.push_back(Cluster()); - clusters.back().add(& (*it1), & (*it2), a, b, w); - } - } - } - -#if CTPPS_DEBUG > 0 - printf("\t\tclusters: %lu\n", clusters.size()); -#endif - - // find the cluster with highest weight - unsigned int mk = 0; - double mw = -1.; - for (unsigned int k = 0; k < clusters.size(); k++) - { - double w = 0; - for (vector::iterator it = clusters[k].contents.begin(); it != clusters[k].contents.end(); ++it) - w += (*it)->w; - clusters[k].weight = w; - - if (w > mw) - { - mw = w; - mk = k; - } - } - -#if CTPPS_DEBUG > 0 - printf("\t\tmw = %.1f, mk = %u\n", mw, mk); -#endif - - // rerturn result - if (mw >= threshold) - { - result = clusters[mk]; - - return true; - } else - return false; -} - diff --git a/RecoCTPPS/TotemRPLocal/src/TotemRPClusterProducerAlgorithm.cc b/RecoCTPPS/TotemRPLocal/src/TotemRPClusterProducerAlgorithm.cc deleted file mode 100644 index 00ff2211578..00000000000 --- a/RecoCTPPS/TotemRPLocal/src/TotemRPClusterProducerAlgorithm.cc +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Hubert Niewiadomski -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#include "RecoCTPPS/TotemRPLocal/interface/TotemRPClusterProducerAlgorithm.h" - -#include - -//---------------------------------------------------------------------------------------------------- - -TotemRPClusterProducerAlgorithm::TotemRPClusterProducerAlgorithm(const edm::ParameterSet ¶m) - :param_(param) -{ - verbosity_ = param_.getParameter("verbosity"); -} - -//---------------------------------------------------------------------------------------------------- - -TotemRPClusterProducerAlgorithm::~TotemRPClusterProducerAlgorithm() -{ -} - -//---------------------------------------------------------------------------------------------------- - -int TotemRPClusterProducerAlgorithm::buildClusters(unsigned int detId, const std::vector &digi, std::vector &clusters) -{ - clusters.clear(); - - strip_digi_set_.clear(); - strip_digi_set_.insert(digi.begin(), digi.end()); - - if (strip_digi_set_.size() == 0) - return 0; - - bool iter_beg=true; - int cluster_beg=-16; - int cluster_end; - int prev_strip=-16; - int cur_strip; - - for (TotemRPDigiSet::const_iterator i=strip_digi_set_.begin(); i!=strip_digi_set_.end(); ++i) - { - cur_strip = i->getStripNumber(); - bool non_continuity = (cur_strip!=prev_strip+1); - - if (iter_beg) - { - cluster_beg=cur_strip; - iter_beg=false; - } - else if (non_continuity) - { - cluster_end=prev_strip; - clusters.push_back(TotemRPCluster((uint16_t)cluster_beg, (uint16_t) cluster_end)); - - cluster_beg=cur_strip; - } - - prev_strip=cur_strip; - } - - if (!iter_beg) - { - cluster_end=prev_strip; - clusters.push_back(TotemRPCluster((uint16_t)cluster_beg, (uint16_t) cluster_end)); - } - - return clusters.size(); -} diff --git a/RecoCTPPS/TotemRPLocal/src/TotemRPLocalTrackFitterAlgorithm.cc b/RecoCTPPS/TotemRPLocal/src/TotemRPLocalTrackFitterAlgorithm.cc deleted file mode 100644 index acd3a0f83b4..00000000000 --- a/RecoCTPPS/TotemRPLocal/src/TotemRPLocalTrackFitterAlgorithm.cc +++ /dev/null @@ -1,196 +0,0 @@ -/**************************************************************************** -* -* This is a part of TOTEM offline software. -* Authors: -* Hubert Niewiadomski -* Jan Kašpar (jan.kaspar@gmail.com) -* -****************************************************************************/ - -#include "RecoCTPPS/TotemRPLocal/interface/TotemRPLocalTrackFitterAlgorithm.h" - -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -#include "TMatrixD.h" - -//---------------------------------------------------------------------------------------------------- - -using namespace std; -using namespace edm; - -//---------------------------------------------------------------------------------------------------- - -TotemRPLocalTrackFitterAlgorithm::TotemRPLocalTrackFitterAlgorithm(const edm::ParameterSet &) -{ -} - -//---------------------------------------------------------------------------------------------------- - - -void TotemRPLocalTrackFitterAlgorithm::reset() -{ - det_data_map_.clear(); -} - -//---------------------------------------------------------------------------------------------------- - -TotemRPLocalTrackFitterAlgorithm::RPDetCoordinateAlgebraObjs -TotemRPLocalTrackFitterAlgorithm::prepareReconstAlgebraData(unsigned int det_id, const TotemRPGeometry& tot_rp_geom) -{ - RPDetCoordinateAlgebraObjs det_algebra_obj; - - det_algebra_obj.centre_of_det_global_position_ = convert3vector(tot_rp_geom.GetDetTranslation(det_id)); - - HepMC::ThreeVector rp_topology_stripaxis = rp_topology_.GetStripReadoutAxisDir(); - CLHEP::Hep3Vector rp_topology_stripaxis_clhep; - - rp_topology_stripaxis_clhep.setX(rp_topology_stripaxis.x()); - rp_topology_stripaxis_clhep.setY(rp_topology_stripaxis.y()); - rp_topology_stripaxis_clhep.setZ(rp_topology_stripaxis.z()); - - TVector3 rd_dir = convert3vector( tot_rp_geom.LocalToGlobalDirection(det_id, rp_topology_stripaxis_clhep ) ); - - TVector2 v(rd_dir.X(), rd_dir.Y()); - det_algebra_obj.readout_direction_ = v.Unit(); - det_algebra_obj.rec_u_0_ = 0.0; - det_algebra_obj.available_ = true; - det_algebra_obj.rec_u_0_ = - (det_algebra_obj.readout_direction_ * det_algebra_obj.centre_of_det_global_position_.XYvector()); - - return det_algebra_obj; -} - -//---------------------------------------------------------------------------------------------------- - -TotemRPLocalTrackFitterAlgorithm::RPDetCoordinateAlgebraObjs* -TotemRPLocalTrackFitterAlgorithm::getDetAlgebraData(unsigned int det_id, const TotemRPGeometry& tot_rp_geom) -{ - auto it = det_data_map_.find(det_id); - if (it != det_data_map_.end()) - { - return &(it->second); - } else { - det_data_map_[det_id] = prepareReconstAlgebraData(det_id, tot_rp_geom); - return &det_data_map_[det_id]; - } -} - -//---------------------------------------------------------------------------------------------------- - -bool TotemRPLocalTrackFitterAlgorithm::fitTrack(const edm::DetSetVector &hits, double z_0, - const TotemRPGeometry &tot_geom, TotemRPLocalTrack &fitted_track) -{ - fitted_track.setValid(false); - - // bind hits with their algebra objects - struct HitWithAlg - { - unsigned int detId; - const TotemRPRecHit *hit; - RPDetCoordinateAlgebraObjs *alg; - }; - - vector applicable_hits; - - for (auto &ds : hits) - { - unsigned int detId = ds.detId(); - - for (auto &h : ds) - { - RPDetCoordinateAlgebraObjs * alg = getDetAlgebraData(detId, tot_geom); - if (alg->available_) - applicable_hits.push_back({ detId, &h, alg}); - } - } - - if (applicable_hits.size() < 5) - return false; - - TMatrixD H(applicable_hits.size(), 4); - TVectorD V(applicable_hits.size()); - TVectorD V_inv(applicable_hits.size()); - TVectorD U(applicable_hits.size()); - - for(unsigned int i = 0; i < applicable_hits.size(); ++i) - { - RPDetCoordinateAlgebraObjs *alg_obj = applicable_hits[i].alg; - - H(i,0) = alg_obj->readout_direction_.X(); - H(i,1) = alg_obj->readout_direction_.Y(); - double delta_z = alg_obj->centre_of_det_global_position_.Z()-z_0; - H(i,2) = alg_obj->readout_direction_.X()*delta_z; - H(i,3) = alg_obj->readout_direction_.Y()*delta_z; - double var = applicable_hits[i].hit->getSigma(); - var*=var; - V[i] = var; - V_inv[i] = 1.0/var; - U[i] = applicable_hits[i].hit->getPosition() - alg_obj->rec_u_0_; - } - - TMatrixD H_T_V_inv(TMatrixD::kTransposed, H); - multiplyByDiagonalInPlace(H_T_V_inv, V_inv); - TMatrixD V_a(H_T_V_inv); - TMatrixD V_a_mult(V_a, TMatrixD::kMult, H); - try - { - V_a_mult.Invert(); - } - catch (cms::Exception &e) - { - LogError("TotemRPLocalTrackFitterAlgorithm") << "Error in TotemRPLocalTrackFitterAlgorithm::fitTrack > " - << "Fit matrix is singular. Skipping."; - return false; - } - - TMatrixD u_to_a(V_a_mult, TMatrixD::kMult, H_T_V_inv); - TVectorD a(U); - a *= u_to_a; - - fitted_track.setZ0(z_0); - fitted_track.setParameterVector(a); - fitted_track.setCovarianceMatrix(V_a_mult); - - double Chi_2 = 0; - for(unsigned int i=0; ireadout_direction_; - double det_z = alg_obj->centre_of_det_global_position_.Z(); - double sigma_str = applicable_hits[i].hit->getSigma(); - double sigma_str_2 = sigma_str*sigma_str; - TVector2 fited_det_xy_point = fitted_track.getTrackPoint(det_z); - double U_readout = applicable_hits[i].hit->getPosition() - alg_obj->rec_u_0_; - double U_fited = (readout_dir*=fited_det_xy_point); - double residual = U_fited - U_readout; - TMatrixD V_T_Cov_X_Y(1,2); - V_T_Cov_X_Y(0,0) = readout_dir.X(); - V_T_Cov_X_Y(0,1) = readout_dir.Y(); - TMatrixD V_T_Cov_X_Y_mult(V_T_Cov_X_Y, TMatrixD::kMult, fitted_track.trackPointInterpolationCovariance(det_z)); - double fit_strip_var = V_T_Cov_X_Y_mult(0,0)*readout_dir.X() + V_T_Cov_X_Y_mult(0,1)*readout_dir.Y(); - double pull_normalization = sqrt(sigma_str_2 - fit_strip_var); - double pull = residual/pull_normalization; - - Chi_2 += residual*residual / sigma_str_2; - - TotemRPLocalTrack::FittedRecHit hit_point(*(applicable_hits[i].hit), TVector3(fited_det_xy_point.X(), - fited_det_xy_point.Y(), det_z), residual, pull); - fitted_track.addHit(applicable_hits[i].detId, hit_point); - } - - fitted_track.setChiSquared(Chi_2); - fitted_track.setValid(true); - return true; -} - -//---------------------------------------------------------------------------------------------------- - -void TotemRPLocalTrackFitterAlgorithm::multiplyByDiagonalInPlace(TMatrixD &mt, const TVectorD &diag) -{ - for(int i=0; i& input, - edm::DetSet& output) -{ - for (edm::DetSet::const_iterator it = input.begin(); it!=input.end(); ++it) - { - constexpr double nominal_sigma = 0.0191; - output.push_back(TotemRPRecHit(rp_topology_.GetHitPositionInReadoutDirection(it->getCenterStripPosition()), nominal_sigma)); - } -} diff --git a/TotemProtonTransport/TotemRPProtonTransportParametrization/interface/RPXMLConfig.h b/TotemProtonTransport/TotemRPProtonTransportParametrization/interface/RPXMLConfig.h index 04aa18fa08d..9c9ecc8a0ef 100644 --- a/TotemProtonTransport/TotemRPProtonTransportParametrization/interface/RPXMLConfig.h +++ b/TotemProtonTransport/TotemRPProtonTransportParametrization/interface/RPXMLConfig.h @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include @@ -105,13 +104,15 @@ class RPXMLConfig // default filename std::string fileName; // parser - DOMBuilder * parser; + DOMLSParser * parser; // document - DOMDocument * doc; + DOMDocument * doc; // main node - DOMNode * mn; + DOMNode * mn; // writer - DOMWriter * writer; + DOMLSSerializer * serializer; +//output + DOMLSOutput* outputDesc; // Constants XMLCh * id_string; diff --git a/TotemProtonTransport/TotemRPProtonTransportParametrization/src/RPXMLConfig.cc b/TotemProtonTransport/TotemRPProtonTransportParametrization/src/RPXMLConfig.cc index 7fd79bedb2c..54af8206fdf 100644 --- a/TotemProtonTransport/TotemRPProtonTransportParametrization/src/RPXMLConfig.cc +++ b/TotemProtonTransport/TotemRPProtonTransportParametrization/src/RPXMLConfig.cc @@ -29,11 +29,14 @@ RPXMLConfig::RPXMLConfig () DOMImplementationRegistry::getDOMImplementation (tempStr); this->parser = ((DOMImplementationLS *) impl)-> - createDOMBuilder (DOMImplementationLS::MODE_SYNCHRONOUS, 0); - this->writer = ((DOMImplementationLS *) impl)->createDOMWriter (); + createLSParser (DOMImplementationLS::MODE_SYNCHRONOUS, 0); + + this->serializer = ((DOMImplementationLS *) impl)->createLSSerializer (); + DOMConfiguration* dc = this->serializer->getDomConfig(); + dc->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true); + + this->outputDesc = ((DOMImplementationLS*)impl)->createLSOutput(); - if (this->writer->canSetFeature (XMLUni::fgDOMWRTFormatPrettyPrint, true)) - this->writer->setFeature (XMLUni::fgDOMWRTFormatPrettyPrint, true); this->doc = 0; @@ -68,7 +71,8 @@ void RPXMLConfig::save (const std::string filename) { XMLFormatTarget *myForm = new StdOutFormatTarget (); - writer->writeNode (myForm, *doc); + outputDesc->setByteStream(myForm); + serializer->write(doc, outputDesc); } void diff --git a/TotemRawData/Readers/BuildFile.xml b/TotemRawData/Readers/BuildFile.xml index 094e4a51fa0..16348d0c523 100644 --- a/TotemRawData/Readers/BuildFile.xml +++ b/TotemRawData/Readers/BuildFile.xml @@ -2,6 +2,12 @@ + + + + + + diff --git a/TotemRawData/Readers/interface/LocalStorageFile.h b/TotemRawData/Readers/interface/LocalStorageFile.h new file mode 100644 index 00000000000..d8495ceb6f2 --- /dev/null +++ b/TotemRawData/Readers/interface/LocalStorageFile.h @@ -0,0 +1,45 @@ +/**************************************************************************** +* +* This is a part of the TOTEM testbeam/monitoring software. +* This is a part of the TOTEM offline software. +* Authors: +* Mariusz Wojakowski +* +****************************************************************************/ + +#ifndef TOTEMRAWDATALIBRARY_LOCALSTORAGEFILE_H +#define TOTEMRAWDATALIBRARY_LOCALSTORAGEFILE_H + +#include +#include +#include + +#include "TotemRawData/Readers/interface/StorageFile.h" + +namespace Totem { + +/** + * An implementation of StorageFile interface that provides access to files on local filesystem. + * + * \ingroup StorageFile + **/ + + class LocalStorageFile : public StorageFile { + public: + LocalStorageFile(std::string const &fileName) : StorageFile(fileName) {} + virtual bool OpenFile(); + virtual int Seek(long position, int origin = SEEK_SET); + virtual long CurrentPosition(); + virtual bool IsOpened(); + virtual int CloseFile(); + virtual size_t ReadData(void *ptr, size_t size, size_t nmemb); + virtual int CheckEOF(); + virtual int CheckError(); + virtual void PrintError(const std::string &); + + private: + FILE *file; + }; +} + +#endif //TOTEMRAWDATALIBRARY_LOCALSTORAGEFILE_H diff --git a/TotemRawData/Readers/interface/RFIOStorageFile.h b/TotemRawData/Readers/interface/RFIOStorageFile.h new file mode 100644 index 00000000000..f3a403d0bf5 --- /dev/null +++ b/TotemRawData/Readers/interface/RFIOStorageFile.h @@ -0,0 +1,43 @@ +/**************************************************************************** +* +* This is a part of the TOTEM testbeam/monitoring software. +* This is a part of the TOTEM offline software. +* Authors: +* Mariusz Wojakowski +* +****************************************************************************/ + +#ifndef TOTEMRAWDATALIBRARY_CASTORSTORAGEFILE_H +#define TOTEMRAWDATALIBRARY_CASTORSTORAGEFILE_H + +#include "TotemRawData/Readers/interface/StorageFile.h" +#include "shift.h" + +namespace Totem { + +/** + * An implementation of StorageFile interface that provides access to files using the RFIO protocol. + * + * \ingroup StorageFile + **/ + + class RFIOStorageFile : public StorageFile { + public: + RFIOStorageFile(std::string const &fileName) : StorageFile(fileName) {} + virtual bool OpenFile(); + virtual int Seek(long position, int origin = SEEK_SET); + virtual long CurrentPosition(); + virtual bool IsOpened(); + virtual int CloseFile(); + virtual size_t ReadData(void *ptr, size_t size, size_t nmemb); + virtual int CheckEOF(); + virtual int CheckError(); + virtual void PrintError(const std::string &); + + private: + FILE *file; + void Reopen(); + }; +} + +#endif //TOTEMRAWDATALIBRARY_CASTORSTORAGEFILE_H diff --git a/TotemRawData/Readers/interface/SRSFileReader.h b/TotemRawData/Readers/interface/SRSFileReader.h index 46042ebec87..b494edba71e 100644 --- a/TotemRawData/Readers/interface/SRSFileReader.h +++ b/TotemRawData/Readers/interface/SRSFileReader.h @@ -13,6 +13,8 @@ #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" +#include "TotemRawData/Readers/interface/StorageFile.h" + #include #include @@ -63,7 +65,7 @@ class SRSFileReader unsigned int dataPtrSize; /// input file pointer - FILE *infile; + Totem::StorageFile *infile; }; #endif diff --git a/TotemRawData/Readers/interface/StorageFile.h b/TotemRawData/Readers/interface/StorageFile.h new file mode 100644 index 00000000000..41fbc4b9502 --- /dev/null +++ b/TotemRawData/Readers/interface/StorageFile.h @@ -0,0 +1,62 @@ +/**************************************************************************** +* +* This is a part of the TOTEM testbeam/monitoring software. +* This is a part of the TOTEM offline software. +* Authors: +* Mariusz Wojakowski +* +****************************************************************************/ + +#ifndef TOTEMRAWDATALIBRARY_STORAGEFILE_H +#define TOTEMRAWDATALIBRARY_STORAGEFILE_H + +#include +#include + +/** + * \defgroup StorageFile Storage + * + * StorageFile and all inherited classes provide abstraction layer upon different types of storage. + **/ + +namespace Totem { + +/** + * StorageFile is a unified interface for accessing files on different storage systems (local, CASTOR, EOS, ...). + * + * It provides methods for opening/closing file, reading data, seeking, checking errors, etc. + * If you want to use new type of storage, you have to inherit from StorageFile class and implement all methods. + * + * \ingroup StorageFile + **/ + class StorageFile { + public: + StorageFile(const std::string &fileName) : fileName(fileName) {}; + virtual ~StorageFile() {}; + virtual bool OpenFile() = 0; ///< opens a file + virtual int Seek(long position, int origin = SEEK_SET) = 0; ///< sets the position indicator to a provided as an argument position + virtual long CurrentPosition() = 0; ///< returns current position of the position indicator + virtual bool IsOpened() = 0; ///< returns true when file is opened + virtual int CloseFile() = 0; ///< closes the file associated with StorageFile object + virtual size_t ReadData(void *ptr, size_t size, size_t nmemb) = 0; ///< reads 'nmemb' elements of size 'size' and stores them in block of memory pointed by 'ptr' + virtual int CheckEOF() = 0; ///< returns a value different from zero when meets EOF + virtual int CheckError() = 0; ///< returns a value different from zero when meets an error + virtual void PrintError(const std::string &) = 0; ///< prints error on standard output + virtual std::string GetURLPath(); ///< returns URL path of file associated with StorageFile object + + /** + * Creates an instance of appropriate StorageFile object for given URL path. + * The match between URL path and type of object is chosen using the given criteria: + * - RFIOStorageFile: if URL path starts with "/castor" or "rfio://" + * - XRootStorageFile: if URL path starts with "root://" or "xroot://" + * - LocalStorageFile: when none of the above requirements is met + **/ + static StorageFile* CreateInstance(const std::string &urlPath); + + protected: + const std::string fileName; + }; +} + + +#endif //TOTEMRAWDATALIBRARY_STORAGEFILE_H diff --git a/TotemRawData/Readers/interface/XRootStorageFile.h b/TotemRawData/Readers/interface/XRootStorageFile.h new file mode 100644 index 00000000000..27cd253e5aa --- /dev/null +++ b/TotemRawData/Readers/interface/XRootStorageFile.h @@ -0,0 +1,46 @@ +/**************************************************************************** +* +* This is a part of the TOTEM testbeam/monitoring software. +* This is a part of the TOTEM offline software. +* Authors: +* Mariusz Wojakowski +* +****************************************************************************/ + +#ifndef TOTEMRAWDATALIBRARY_XROOTSTORAGEFILE_H +#define TOTEMRAWDATALIBRARY_XROOTSTORAGEFILE_H + +#include "TotemRawData/Readers/interface/StorageFile.h" +#include +//#include "XrdClient/XrdClient.hh" + + +using namespace std; + +namespace Totem { + +/** + * An implementation of StorageFile interface that provides access to files using XRoot protocol. + * + * \ingroup StorageFile + **/ + + class XRootStorageFile : public StorageFile { + public: + XRootStorageFile(std::string const &fileName) : StorageFile(fileName) {} + virtual bool OpenFile(); + virtual int Seek(long position, int origin = SEEK_SET); + virtual long CurrentPosition(); + virtual bool IsOpened(); + virtual int CloseFile(); + virtual size_t ReadData(void *ptr, size_t size, size_t nmemb); + virtual int CheckEOF(); + virtual int CheckError(); + virtual void PrintError(const std::string &); + + private: + int fd; + }; +} + +#endif //TOTEMRAWDATALIBRARY_XROOTSTORAGEFILE_H diff --git a/TotemRawData/Readers/src/LocalStorageFile.cc b/TotemRawData/Readers/src/LocalStorageFile.cc new file mode 100644 index 00000000000..a6da6b29db6 --- /dev/null +++ b/TotemRawData/Readers/src/LocalStorageFile.cc @@ -0,0 +1,42 @@ +#include "TotemRawData/Readers/interface/LocalStorageFile.h" + +namespace Totem { + bool LocalStorageFile::OpenFile() { + file = fopen(const_cast(fileName.c_str()), const_cast("r")); + return (bool) file; + } + + int LocalStorageFile::Seek(long position, int origin) { + return fseek(file, position, origin); + } + + long LocalStorageFile::CurrentPosition() { + return ftell(file); + } + + bool LocalStorageFile::IsOpened() { + return (bool) file; + } + + int LocalStorageFile::CloseFile() { + if(file) + return fclose(file); + return -1; + } + + size_t LocalStorageFile::ReadData(void *ptr, size_t size, size_t nmemb) { + return fread(ptr, size, nmemb, file); + } + + int LocalStorageFile::CheckEOF() { + return feof(file); + } + + int LocalStorageFile::CheckError() { + return ferror(file); + } + + void LocalStorageFile::PrintError(const std::string &string) { + perror(const_cast(string.c_str())); + } +} diff --git a/TotemRawData/Readers/src/RFIOStorageFile.cc b/TotemRawData/Readers/src/RFIOStorageFile.cc new file mode 100644 index 00000000000..bcaafc6c0f5 --- /dev/null +++ b/TotemRawData/Readers/src/RFIOStorageFile.cc @@ -0,0 +1,48 @@ +#include "TotemRawData/Readers/interface/StorageFile.h" +#include "TotemRawData/Readers/interface/RFIOStorageFile.h" + +namespace Totem { + bool RFIOStorageFile::OpenFile() { + file = rfio_fopen(const_cast(fileName.c_str()), const_cast("r")); + return (bool) file; + } + + int RFIOStorageFile::Seek(long position, int origin) { + if (rfio_feof(file)) { + Reopen(); + } + return rfio_fseek(file, position, origin); + } + + long RFIOStorageFile::CurrentPosition() { + return rfio_ftell(file); + } + + bool RFIOStorageFile::IsOpened() { + return (bool) file; + } + + int RFIOStorageFile::CloseFile() { + return rfio_fclose(file); + } + + size_t RFIOStorageFile::ReadData(void *ptr, size_t size, size_t nmemb) { + return rfio_fread(ptr, size, nmemb, file); + } + int RFIOStorageFile::CheckEOF() { + return rfio_feof(file); + } + + int RFIOStorageFile::CheckError() { + return rfio_ferror(file); + } + + void RFIOStorageFile::PrintError(const std::string &string) { + rfio_perror(const_cast(string.c_str())); + } + + void RFIOStorageFile::Reopen() { + rfio_fclose(file); + file = rfio_fopen(const_cast(fileName.c_str()), const_cast("r")); + } +} diff --git a/TotemRawData/Readers/src/SRSFileReader.cc b/TotemRawData/Readers/src/SRSFileReader.cc index d451b6c420b..d0d386cdcc7 100644 --- a/TotemRawData/Readers/src/SRSFileReader.cc +++ b/TotemRawData/Readers/src/SRSFileReader.cc @@ -16,6 +16,7 @@ //---------------------------------------------------------------------------------------------------- using namespace std; +using namespace Totem; //---------------------------------------------------------------------------------------------------- @@ -41,11 +42,12 @@ SRSFileReader::~SRSFileReader() int SRSFileReader::Open(const std::string &fn) { - infile = fopen(fn.c_str(), "r"); + infile = StorageFile::CreateInstance(fn); + infile->OpenFile(); - if (infile == NULL) + if (!infile->IsOpened()) { - perror("Error while opening file in SRSFileReader::Open"); + infile->PrintError("Error while opening file in SRSFile::Open"); return 1; } @@ -57,8 +59,9 @@ int SRSFileReader::Open(const std::string &fn) void SRSFileReader::Close() { if (infile) - fclose(infile); + infile->CloseFile(); + delete infile; infile = NULL; } @@ -96,8 +99,8 @@ unsigned char SRSFileReader::ReadToBuffer(unsigned int bytesToRead, unsigned int } // read data at given offset - unsigned int bytesRead = fread(dataPtr + offset, sizeof(char), bytesToRead, infile); - int eofFlag = feof(infile); + unsigned int bytesRead = infile->ReadData(dataPtr + offset, sizeof(char), bytesToRead); + int eofFlag = infile->CheckEOF(); if (bytesRead != bytesToRead && !(bytesRead == 0 && eofFlag)) { @@ -119,7 +122,7 @@ unsigned char SRSFileReader::GetNextEvent(uint64_t ×tamp, FEDRawDataCollect eventHeaderStruct *eventHeader = NULL; - while (!feof(infile)) + while (!infile->CheckEOF()) { // read next header if (ReadToBuffer(eventHeaderSize, 0) != 0) @@ -158,7 +161,7 @@ unsigned char SRSFileReader::GetNextEvent(uint64_t ×tamp, FEDRawDataCollect } // check if the end of the file has been reached - if (feof(infile)) + if (infile->CheckEOF()) return 1; // process the buffer diff --git a/TotemRawData/Readers/src/StorageFile.cc b/TotemRawData/Readers/src/StorageFile.cc new file mode 100644 index 00000000000..909aab12cb4 --- /dev/null +++ b/TotemRawData/Readers/src/StorageFile.cc @@ -0,0 +1,30 @@ +#include +#include "TotemRawData/Readers/interface/StorageFile.h" +#include "TotemRawData/Readers/interface/LocalStorageFile.h" + +#include "TotemRawData/Readers/interface/RFIOStorageFile.h" + +#include "TotemRawData/Readers/interface/XRootStorageFile.h" + +namespace Totem { + +StorageFile* StorageFile::CreateInstance(const std::string &urlPath) +{ + if (urlPath.find("/castor") == 0 || urlPath.find("rfio://") == 0) + { + return new RFIOStorageFile(urlPath); + } + else if (urlPath.find("root://") == 0 || urlPath.find("xroot://") == 0) + { + return new XRootStorageFile(urlPath); + } + + return new LocalStorageFile(urlPath); +} + +std::string StorageFile::GetURLPath() +{ + return fileName; +} + +} diff --git a/TotemRawData/Readers/src/XRootStorageFile.cc b/TotemRawData/Readers/src/XRootStorageFile.cc new file mode 100644 index 00000000000..554a24e49c1 --- /dev/null +++ b/TotemRawData/Readers/src/XRootStorageFile.cc @@ -0,0 +1,50 @@ +#include +#include "TotemRawData/Readers/interface/XRootStorageFile.h" + +namespace Totem { + bool XRootStorageFile::OpenFile() { + fd = XrdPosixXrootd::Open(fileName.c_str(), O_RDONLY); + + return fd != -1; + } + + int XRootStorageFile::Seek(long position, int origin) { + return XrdPosixXrootd::Lseek(fd, position, origin); + } + + long XRootStorageFile::CurrentPosition() { + return XrdPosixXrootd::Lseek(fd, 0, SEEK_CUR); + } + + bool XRootStorageFile::IsOpened() { + return fd != -1; + } + + int XRootStorageFile::CloseFile() { + return XrdPosixXrootd::Close(fd); + } + + size_t XRootStorageFile::ReadData(void *ptr, size_t size, size_t nmemb) { + return XrdPosixXrootd::Read(fd, ptr, size*nmemb); + } + + int XRootStorageFile::CheckEOF() { + char buf[2]; + int read = XrdPosixXrootd::Read(fd, buf, 1); + if(read==0) { + return 1; + } + else { + Seek(-1, SEEK_CUR); + return 0; + } + } + + int XRootStorageFile::CheckError() { + return XrdPosixXrootd::Read(fd, NULL, 0); + } + + void XRootStorageFile::PrintError(string const &message) { + perror(const_cast(message.c_str())); + } +}