CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
34  dcsStatusToken_ = iC.consumes<DcsStatusCollection>(edm::InputTag("scalersRawToDigi"));
36 }
37 //
38 // -- Destructor
39 //
41 }
42 //
43 // -- Get State
44 //
46 
47  bool retVal = true;
48  if (!initialised) initialise(e, eSetup);
49 
51  // e.getByLabel("scalersRawToDigi", dcsStatus);
52  e.getByToken(dcsStatusToken_, dcsStatus);
53  if ( trackerAbsent || !dcsStatus.isValid()) return retVal;
54  if ((*dcsStatus).size() == 0) return retVal;
55 
56  statusTIBTID = true;
57  statusTOB = true;
58  statusTECF = true;
59  statusTECB = true;
60 
61  bool dcsTIBTID = ((*dcsStatus)[0].ready(DcsStatus::TIBTID));
62  bool dcsTOB = ((*dcsStatus)[0].ready(DcsStatus::TOB));
63  bool dcsTECF = ((*dcsStatus)[0].ready(DcsStatus::TECp));
64  bool dcsTECB = ((*dcsStatus)[0].ready(DcsStatus::TECm));
65  if (rawdataAbsent) {
66  statusTIBTID = dcsTIBTID;
67  statusTOB = dcsTOB;
68  statusTECF = dcsTECF;
69  statusTECB = dcsTECB;
70  } else {
71  if ( TIBTIDinDAQ && !dcsTIBTID ) statusTIBTID = false;
72  if ( TOBinDAQ && !dcsTOB ) statusTOB = false;
73  if ( TECFinDAQ && !dcsTECF ) statusTECF = false;
74  if ( TECBinDAQ && !dcsTECB ) statusTECB = false;
75  }
76 
77  LogDebug("SiStripDCSStatus") << " SiStripDCSStatus :: Detectors in DAQ (TIBTID, TOB, TEC+ TEC-)"
78  << TIBTIDinDAQ << " "
79  << TOBinDAQ << " "
80  << TECFinDAQ << " "
81  << TECBinDAQ << std::endl;
82  LogDebug("SiStripDCSStatus") << " SiStripDCSStatus :: Detectors in ON (TIBTID, TOB, TEC+ TEC-)"
83  << dcsTIBTID << " "
84  << dcsTOB << " "
85  << dcsTECF << " "
86  << dcsTECB << std::endl;
87 
88  LogDebug("SiStripDCSStatus") << " SiStripDCSStatus :: Final Flags (TIBTID, TOB, TEC+ TEC-)"
89  << statusTIBTID << " "
90  << statusTOB << " "
91  << statusTECF << " "
92  << statusTECB << std::endl;
93  if (statusTIBTID && statusTOB && statusTECF && statusTECB) retVal = true;
94  else retVal = false;
95  LogDebug("SiStripDCSStatus") << " Return Value " << retVal ;
96  return retVal;
97 }
98 //
99 // -- initialise
100 //
102  //Retrieve tracker topology from geometry
103  edm::ESHandle<TrackerTopology> tTopoHandle;
104  eSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
105  const TrackerTopology* const tTopo = tTopoHandle.product();
106 
108  eSetup.get<SiStripFedCablingRcd>().get(fedCabling_);
109  auto connectedFEDs = fedCabling_->fedIds();
110 
111  edm::Handle<FEDRawDataCollection> rawDataHandle;
112  // e.getByLabel("source", rawDataHandle);
113  e.getByToken(rawDataToken_, rawDataHandle);
114 
115  if ( !rawDataHandle.isValid() ) {
116  rawdataAbsent = true;
117  return;
118  }
119 
120  rawdataAbsent = false;
121  const FEDRawDataCollection& rawDataCollection = *rawDataHandle;
122  for(std::vector<unsigned short>::const_iterator ifed = connectedFEDs.begin(); ifed != connectedFEDs.end(); ifed++){
123  auto fedChannels = fedCabling_->fedConnections( *ifed );
124  if (!(rawDataCollection.FEDData(*ifed).size()) || !(rawDataCollection.FEDData(*ifed).data()) ) continue;
125  // Check Modules Connected
126  for (std::vector<FedChannelConnection>::const_iterator iconn = fedChannels.begin();
127  iconn < fedChannels.end(); iconn++){
128  if (!iconn->isConnected()) continue;
129  uint32_t detId = iconn->detId();
130  StripSubdetector subdet(detId);
131  if ( (subdet.subdetId() == StripSubdetector::TIB) || (subdet.subdetId() == StripSubdetector::TID)) {
132  TIBTIDinDAQ = true;
133  break;
134  } else if (subdet.subdetId() == StripSubdetector::TOB) {
135  TOBinDAQ = true;
136  break;
137  } else if (subdet.subdetId() == StripSubdetector::TEC) {
138  if (tTopo->tecSide(detId) == 2) TECFinDAQ = true;
139  else if (tTopo->tecSide(detId) == 1) TECBinDAQ = true;
140  break;
141  }
142  }
143  if (TIBTIDinDAQ && TOBinDAQ && TECFinDAQ && TECBinDAQ) break;
144  }
145  initialised = true;
146  if (!TIBTIDinDAQ && !TOBinDAQ && !TECFinDAQ && !TECBinDAQ) trackerAbsent = true;
147 }
#define LogDebug(id)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
edm::EDGetTokenT< FEDRawDataCollection > rawDataToken_
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
bool getStatus(edm::Event const &e, edm::EventSetup const &eSetup)
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
bool isValid() const
Definition: HandleBase.h:75
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
std::vector< DcsStatus > DcsStatusCollection
Definition: DcsStatus.h:116
void initialise(edm::Event const &e, edm::EventSetup const &eSetup)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
SiStripDCSStatus(edm::ConsumesCollector &&iC)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
edm::EDGetTokenT< DcsStatusCollection > dcsStatusToken_
volatile std::atomic< bool > shutdown_flag false
unsigned int tecSide(const DetId &id) const