CMS 3D CMS Logo

SiStripDCSStatus.cc
Go to the documentation of this file.
5 
7 
10 
11 // FED cabling and numbering
14 
18 
20 #include <iostream>
21 
22 //
23 // -- Constructor
24 //
26  : TIBTIDinDAQ(false),
27  TOBinDAQ(false),
28  TECFinDAQ(false),
29  TECBinDAQ(false),
30  trackerAbsent(false),
31  rawdataAbsent(true),
32  initialised(false) {
33  dcsStatusToken_ = iC.consumes<DcsStatusCollection>(edm::InputTag("scalersRawToDigi"));
34  rawDataToken_ = iC.consumes<FEDRawDataCollection>(edm::InputTag("rawDataCollector"));
37 }
38 //
39 // -- Get State
40 //
42  bool retVal = true;
43  if (!initialised)
44  initialise(e, eSetup);
45 
47  // e.getByLabel("scalersRawToDigi", dcsStatus);
48  e.getByToken(dcsStatusToken_, dcsStatus);
49  if (trackerAbsent || !dcsStatus.isValid())
50  return retVal;
51  if ((*dcsStatus).empty())
52  return retVal;
53 
54  bool statusTIBTID = true;
55  bool statusTOB = true;
56  bool statusTECF = true;
57  bool statusTECB = true;
58 
59  bool dcsTIBTID = ((*dcsStatus)[0].ready(DcsStatus::TIBTID));
60  bool dcsTOB = ((*dcsStatus)[0].ready(DcsStatus::TOB));
61  bool dcsTECF = ((*dcsStatus)[0].ready(DcsStatus::TECp));
62  bool dcsTECB = ((*dcsStatus)[0].ready(DcsStatus::TECm));
63  if (rawdataAbsent) {
64  statusTIBTID = dcsTIBTID;
65  statusTOB = dcsTOB;
66  statusTECF = dcsTECF;
67  statusTECB = dcsTECB;
68  } else {
69  if (TIBTIDinDAQ && !dcsTIBTID)
70  statusTIBTID = false;
71  if (TOBinDAQ && !dcsTOB)
72  statusTOB = false;
73  if (TECFinDAQ && !dcsTECF)
74  statusTECF = false;
75  if (TECBinDAQ && !dcsTECB)
76  statusTECB = false;
77  }
78 
79  LogDebug("SiStripDCSStatus") << " SiStripDCSStatus :: Detectors in DAQ (TIBTID, TOB, TEC+ TEC-)" << TIBTIDinDAQ << " "
80  << TOBinDAQ << " " << TECFinDAQ << " " << TECBinDAQ << std::endl;
81  LogDebug("SiStripDCSStatus") << " SiStripDCSStatus :: Detectors in ON (TIBTID, TOB, TEC+ TEC-)" << dcsTIBTID << " "
82  << dcsTOB << " " << dcsTECF << " " << dcsTECB << std::endl;
83 
84  LogDebug("SiStripDCSStatus") << " SiStripDCSStatus :: Final Flags (TIBTID, TOB, TEC+ TEC-)" << statusTIBTID << " "
85  << statusTOB << " " << statusTECF << " " << statusTECB << std::endl;
86  if (statusTIBTID && statusTOB && statusTECF && statusTECB)
87  retVal = true;
88  else
89  retVal = false;
90  LogDebug("SiStripDCSStatus") << " Return Value " << retVal;
91  return retVal;
92 }
93 //
94 // -- initialise
95 //
97  //Retrieve tracker topology from geometry
98  const auto& tTopo = eSetup.getData(tTopoToken_);
99  const auto& fedCabling_ = eSetup.getData(fedCablingToken_);
100 
101  auto connectedFEDs = fedCabling_.fedIds();
102 
103  edm::Handle<FEDRawDataCollection> rawDataHandle;
104  // e.getByLabel("source", rawDataHandle);
105  e.getByToken(rawDataToken_, rawDataHandle);
106 
107  if (!rawDataHandle.isValid()) {
108  rawdataAbsent = true;
109  return;
110  }
111 
112  rawdataAbsent = false;
113  const FEDRawDataCollection& rawDataCollection = *rawDataHandle;
114  for (std::vector<unsigned short>::const_iterator ifed = connectedFEDs.begin(); ifed != connectedFEDs.end(); ifed++) {
115  auto fedChannels = fedCabling_.fedConnections(*ifed);
116  if (!(rawDataCollection.FEDData(*ifed).size()) || !(rawDataCollection.FEDData(*ifed).data()))
117  continue;
118  // Check Modules Connected
119  for (std::vector<FedChannelConnection>::const_iterator iconn = fedChannels.begin(); iconn < fedChannels.end();
120  iconn++) {
121  if (!iconn->isConnected())
122  continue;
123  uint32_t detId = iconn->detId();
124  StripSubdetector subdet(detId);
125  if ((subdet.subdetId() == StripSubdetector::TIB) || (subdet.subdetId() == StripSubdetector::TID)) {
126  TIBTIDinDAQ = true;
127  break;
128  } else if (subdet.subdetId() == StripSubdetector::TOB) {
129  TOBinDAQ = true;
130  break;
131  } else if (subdet.subdetId() == StripSubdetector::TEC) {
132  if (tTopo.tecSide(detId) == 2)
133  TECFinDAQ = true;
134  else if (tTopo.tecSide(detId) == 1)
135  TECBinDAQ = true;
136  break;
137  }
138  }
140  break;
141  }
142  initialised = true;
143  if (!TIBTIDinDAQ && !TOBinDAQ && !TECFinDAQ && !TECBinDAQ)
144  trackerAbsent = true;
145 }
#define LogDebug(id)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
static constexpr auto TEC
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
edm::EDGetTokenT< FEDRawDataCollection > rawDataToken_
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
bool getData(T &iHolder) const
Definition: EventSetup.h:113
bool getStatus(edm::Event const &e, edm::EventSetup const &eSetup)
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
edm::ESGetToken< SiStripFedCabling, SiStripFedCablingRcd > fedCablingToken_
static constexpr auto TOB
bool isValid() const
Definition: HandleBase.h:70
std::vector< DcsStatus > DcsStatusCollection
Definition: DcsStatus.h:110
static constexpr auto TIB
void initialise(edm::Event const &e, edm::EventSetup const &eSetup)
SiStripDCSStatus(edm::ConsumesCollector &&iC)
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
edm::EDGetTokenT< DcsStatusCollection > dcsStatusToken_
static constexpr auto TID