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 
8 
12 
13 // FED cabling and numbering
16 
20 
22 #include <iostream>
23 
24 //
25 // -- Constructor
26 //
28  TIBTIDinDAQ(false),
29  TOBinDAQ(false),
30  TECFinDAQ(false),
31  TECBinDAQ(false),
32  trackerAbsent(false),
33  rawdataAbsent(true),
34  initialised(false) {
35 }
36 //
37 // -- Destructor
38 //
40 }
41 //
42 // -- Get State
43 //
45 
46  bool retVal = true;
47  if (!initialised) initialise(e, eSetup);
48 
50  e.getByLabel("scalersRawToDigi", dcsStatus);
51  if ( trackerAbsent || !dcsStatus.isValid()) return retVal;
52  if ((*dcsStatus).size() == 0) return retVal;
53 
54  statusTIBTID = true;
55  statusTOB = true;
56  statusTECF = true;
57  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 ) statusTIBTID = false;
70  if ( TOBinDAQ && !dcsTOB ) statusTOB = false;
71  if ( TECFinDAQ && !dcsTECF ) statusTECF = false;
72  if ( TECBinDAQ && !dcsTECB ) statusTECB = false;
73  }
74 
75  LogDebug("SiStripDCSStatus") << " SiStripDCSStatus :: Detectors in DAQ (TIBTID, TOB, TEC+ TEC-)"
76  << TIBTIDinDAQ << " "
77  << TOBinDAQ << " "
78  << TECFinDAQ << " "
79  << TECBinDAQ << std::endl;
80  LogDebug("SiStripDCSStatus") << " SiStripDCSStatus :: Detectors in ON (TIBTID, TOB, TEC+ TEC-)"
81  << dcsTIBTID << " "
82  << dcsTOB << " "
83  << dcsTECF << " "
84  << dcsTECB << std::endl;
85 
86  LogDebug("SiStripDCSStatus") << " SiStripDCSStatus :: Final Flags (TIBTID, TOB, TEC+ TEC-)"
87  << statusTIBTID << " "
88  << statusTOB << " "
89  << statusTECF << " "
90  << statusTECB << std::endl;
91  if (statusTIBTID && statusTOB && statusTECF && statusTECB) retVal = true;
92  else retVal = false;
93  LogDebug("SiStripDCSStatus") << " Return Value " << retVal ;
94  return retVal;
95 }
96 //
97 // -- initialise
98 //
100  //Retrieve tracker topology from geometry
101  edm::ESHandle<TrackerTopology> tTopoHandle;
102  eSetup.get<IdealGeometryRecord>().get(tTopoHandle);
103  const TrackerTopology* const tTopo = tTopoHandle.product();
104 
106  eSetup.get<SiStripFedCablingRcd>().get(fedCabling_);
107  const std::vector<uint16_t>& connectedFEDs = fedCabling_->feds();
108 
109  edm::Handle<FEDRawDataCollection> rawDataHandle;
110  e.getByLabel("source", rawDataHandle);
111 
112  if ( !rawDataHandle.isValid() ) {
113  rawdataAbsent = true;
114  return;
115  }
116 
117  rawdataAbsent = false;
118  const FEDRawDataCollection& rawDataCollection = *rawDataHandle;
119  for(std::vector<unsigned short>::const_iterator ifed = connectedFEDs.begin(); ifed != connectedFEDs.end(); ifed++){
120  const std::vector<FedChannelConnection> fedChannels = fedCabling_->connections( *ifed );
121  if (!(rawDataCollection.FEDData(*ifed).size()) || !(rawDataCollection.FEDData(*ifed).data()) ) continue;
122  // Check Modules Connected
123  for (std::vector<FedChannelConnection>::const_iterator iconn = fedChannels.begin();
124  iconn < fedChannels.end(); iconn++){
125  if (!iconn->isConnected()) continue;
126  uint32_t detId = iconn->detId();
127  StripSubdetector subdet(detId);
128  if ( (subdet.subdetId() == StripSubdetector::TIB) || (subdet.subdetId() == StripSubdetector::TID)) {
129  TIBTIDinDAQ = true;
130  break;
131  } else if (subdet.subdetId() == StripSubdetector::TOB) {
132  TOBinDAQ = true;
133  break;
134  } else if (subdet.subdetId() == StripSubdetector::TEC) {
135  if (tTopo->tecSide(detId) == 2) TECFinDAQ = true;
136  else if (tTopo->tecSide(detId) == 1) TECBinDAQ = true;
137  break;
138  }
139  }
140  if (TIBTIDinDAQ && TOBinDAQ && TECFinDAQ && TECBinDAQ) break;
141  }
142  initialised = true;
143  if (!TIBTIDinDAQ && !TOBinDAQ && !TECFinDAQ && !TECBinDAQ) trackerAbsent = true;
144 }
#define LogDebug(id)
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:49
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:76
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
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:62
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:29
unsigned int tecSide(const DetId &id) const