CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripDaqInfo.cc
Go to the documentation of this file.
4 
7 
11 
12 //Run Info
16 // FED cabling and numbering
20 
21 #include <iostream>
22 #include <iomanip>
23 #include <stdio.h>
24 #include <string>
25 #include <sstream>
26 #include <math.h>
27 #include <vector>
28 
29 //
30 // -- Contructor
31 //
33  // Create MessageSender
34  edm::LogInfo( "SiStripDaqInfo") << "SiStripDaqInfo::Deleting SiStripDaqInfo ";
35 
36  // get back-end interface
38  nFedTotal = 0;
39  bookedStatus_ = false;
40 }
42  edm::LogInfo("SiStripDaqInfo") << "SiStripDaqInfo::Deleting SiStripDaqInfo ";
43 
44 }
45 //
46 // -- Begin Job
47 //
49 
50 }
51 //
52 // -- Book MEs for SiStrip Daq Fraction
53 //
55  edm::LogInfo( "SiStripDcsInfo") << " SiStripDaqInfo::bookStatus " << bookedStatus_;
56  if (!bookedStatus_) {
57  dqmStore_->cd();
58  std::string strip_dir = "";
59  SiStripUtility::getTopFolderPath(dqmStore_, "SiStrip", strip_dir);
60  if (strip_dir.size() > 0) dqmStore_->setCurrentFolder(strip_dir+"/EventInfo");
61  else dqmStore_->setCurrentFolder("SiStrip/EventInfo");
62 
63 
64  DaqFraction_= dqmStore_->bookFloat("DAQSummary");
65 
66  dqmStore_->cd();
67  if (strip_dir.size() > 0) dqmStore_->setCurrentFolder(strip_dir+"/EventInfo/DAQContents");
68  else dqmStore_->setCurrentFolder("SiStrip/EventInfo/DAQContents");
69 
70  std::vector<std::string> det_type;
71  det_type.push_back("TIB");
72  det_type.push_back("TOB");
73  det_type.push_back("TIDF");
74  det_type.push_back("TIDB");
75  det_type.push_back("TECF");
76  det_type.push_back("TECB");
77 
78  for ( std::vector<std::string>::iterator it = det_type.begin(); it != det_type.end(); it++) {
79  std::string det = (*it);
80 
81  SubDetMEs local_mes;
82  std::string me_name;
83  me_name = "SiStrip_" + det;
84  local_mes.DaqFractionME = dqmStore_->bookFloat(me_name);
85  local_mes.ConnectedFeds = 0;
86  SubDetMEsMap.insert(make_pair(det, local_mes));
87  }
88  bookedStatus_ = true;
89  dqmStore_->cd();
90  }
91 }
92 //
93 // -- Fill with Dummy values
94 //
96  if (!bookedStatus_) bookStatus();
97  if (bookedStatus_) {
98  for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin(); it != SubDetMEsMap.end(); it++) {
99  it->second.DaqFractionME->Reset();
100  it->second.DaqFractionME->Fill(-1.0);
101  }
102  DaqFraction_->Reset();
103  DaqFraction_->Fill(-1.0);
104  }
105 }
106 //
107 // -- Begin Run
108 //
110  edm::LogInfo ("SiStripDaqInfo") <<"SiStripDaqInfo:: Begining of Run";
111 
112  // Check latest Fed cabling and create TrackerMapCreator
113  unsigned long long cacheID = eSetup.get<SiStripFedCablingRcd>().cacheIdentifier();
114  if (m_cacheID_ != cacheID) {
115  m_cacheID_ = cacheID;
116 
117  eSetup.get<SiStripFedCablingRcd>().get(fedCabling_);
118 
120  }
121  if (!bookedStatus_) bookStatus();
122  if (nFedTotal == 0) {
123  fillDummyStatus();
124  edm::LogInfo ("SiStripDaqInfo") <<" SiStripDaqInfo::No FEDs Connected!!!";
125  return;
126  }
127 
128  float nFEDConnected = 0.0;
129  const int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
130  const int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID;
131 
133  if( eSetup.find( recordKey ) != 0) {
134 
135  edm::ESHandle<RunInfo> sumFED;
136  eSetup.get<RunInfoRcd>().get(sumFED);
137 
138  if ( sumFED.isValid() ) {
139  std::vector<int> FedsInIds= sumFED->m_fed_in;
140  for(unsigned int it = 0; it < FedsInIds.size(); ++it) {
141  int fedID = FedsInIds[it];
142 
143  if(fedID>=siStripFedIdMin && fedID<=siStripFedIdMax) ++nFEDConnected;
144  }
145  edm::LogInfo ("SiStripDaqInfo") <<" SiStripDaqInfo::Total # of FEDs " << nFedTotal
146  << " Connected FEDs " << nFEDConnected;
147  if (nFEDConnected > 0) {
148  DaqFraction_->Reset();
149  DaqFraction_->Fill(nFEDConnected/nFedTotal);
150  readSubdetFedFractions(FedsInIds);
151  }
152  }
153  }
154 }
155 //
156 // -- Analyze
157 //
159 }
160 
161 //
162 // -- End Luminosity Block
163 //
165  edm::LogInfo( "SiStripDaqInfo") << "SiStripDaqInfo::endLuminosityBlock";
166 }
167 //
168 // -- End Run
169 //
171  edm::LogInfo ("SiStripDaqInfo") <<"SiStripDaqInfo::EndRun";
172 }
173 //
174 // -- Read Sub Detector FEDs
175 //
177  const std::vector<uint16_t>& feds = fedCabling_->feds();
178 
179  nFedTotal = feds.size();
180  for(std::vector<unsigned short>::const_iterator ifed = feds.begin(); ifed != feds.end(); ifed++){
181  const std::vector<FedChannelConnection> fedChannels = fedCabling_->connections( *ifed );
182  for (std::vector<FedChannelConnection>::const_iterator iconn = fedChannels.begin(); iconn < fedChannels.end(); iconn++){
183  if (!iconn->isConnected()) continue;
184  uint32_t detId = iconn->detId();
185  if (detId == 0 || detId == 0xFFFFFFFF) continue;
186  std::string subdet_tag;
187  SiStripUtility::getSubDetectorTag(detId,subdet_tag);
188  subDetFedMap[subdet_tag].push_back(*ifed);
189  break;
190  }
191  }
192 }
193 //
194 // -- Fill Subdet FEDIds
195 //
196 void SiStripDaqInfo::readSubdetFedFractions(std::vector<int>& fed_ids) {
197 
198  const int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
199  const int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID;
200 
201  // initialiase
202  for (std::map<std::string, std::vector<unsigned short> >::const_iterator it = subDetFedMap.begin();
203  it != subDetFedMap.end(); it++) {
204  std::string name = it->first;
205  std::map<std::string, SubDetMEs>::iterator iPos = SubDetMEsMap.find(name);
206  if (iPos == SubDetMEsMap.end()) continue;
207  iPos->second.ConnectedFeds = 0;
208  }
209  // count sub detector feds
210 
211 
212  for (std::map<std::string, std::vector<unsigned short> >::const_iterator it = subDetFedMap.begin();
213  it != subDetFedMap.end(); it++) {
214  std::string name = it->first;
215  std::vector<unsigned short> subdetIds = it->second;
216  std::map<std::string, SubDetMEs>::iterator iPos = SubDetMEsMap.find(name);
217  if (iPos == SubDetMEsMap.end()) continue;
218  iPos->second.ConnectedFeds = 0;
219  for (std::vector<unsigned short>::iterator iv = subdetIds.begin();
220  iv != subdetIds.end(); iv++) {
221  bool fedid_found = false;
222  for(unsigned int it = 0; it < fed_ids.size(); ++it) {
223  unsigned short fedID = fed_ids[it];
224  if(fedID < siStripFedIdMin || fedID > siStripFedIdMax) continue;
225  if ((*iv) == fedID) {
226  fedid_found = true;
227  iPos->second.ConnectedFeds++;
228  break;
229  }
230  }
231  if (!fedid_found) findExcludedModule((*iv));
232  }
233  int nFedsConnected = iPos->second.ConnectedFeds;
234  int nFedSubDet = subdetIds.size();
235  if (nFedSubDet > 0) {
236  iPos->second.DaqFractionME->Reset();
237  iPos->second.DaqFractionME->Fill(nFedsConnected*1.0/nFedSubDet);
238  }
239  }
240 }
241 //
242 // -- find Excluded Modules
243 //
244 void SiStripDaqInfo::findExcludedModule(unsigned short fed_id) {
245  dqmStore_->cd();
246  std::string mdir = "MechanicalView";
247  if (!SiStripUtility::goToDir(dqmStore_, mdir)) {
248  dqmStore_->setCurrentFolder("SiStrip/"+mdir);
249  }
250  std::string mechanical_dir = dqmStore_->pwd();
251  const std::vector<FedChannelConnection> fedChannels = fedCabling_->connections(fed_id);
252  int ichannel = 0;
253  std::string tag = "ExcludedFedChannel";
254  std::string bad_module_folder;
255  for (std::vector<FedChannelConnection>::const_iterator iconn = fedChannels.begin();
256  iconn < fedChannels.end(); iconn++){
257  if (!iconn->isConnected()) continue;
258  uint32_t detId = iconn->detId();
259  if (detId == 0 || detId == 0xFFFFFFFF) continue;
260 
261  ichannel++;
262  if (ichannel == 1) {
263  std::string subdet_folder ;
264  SiStripFolderOrganizer folder_organizer;
265  folder_organizer.getSubDetFolder(detId,subdet_folder);
266  if (!dqmStore_->dirExists(subdet_folder)) {
267  subdet_folder = mechanical_dir + subdet_folder.substr(subdet_folder.find(mdir)+mdir.size());
268  }
269  bad_module_folder = subdet_folder + "/" + "BadModuleList";
270  dqmStore_->setCurrentFolder(bad_module_folder);
271  }
272  std::ostringstream detid_str;
273  detid_str << detId;
274  std::string full_path = bad_module_folder + "/" + detid_str.str();
275  MonitorElement* me = dqmStore_->get(full_path);
276  uint16_t flag = 0;
277  if (me) {
278  flag = me->getIntValue();
279  me->Reset();
280  } else me = dqmStore_->bookInt(detid_str.str());
282  me->Fill(flag);
283  }
284  dqmStore_->cd();
285 }
static void setBadModuleFlag(std::string &hname, uint16_t &flg)
long int flag
Definition: mlp_lapack.h:47
void getSubDetFolder(const uint32_t &detid, std::string &folder_name)
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &iSetup)
End Of Luminosity.
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:406
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void readFedIds(const edm::ESHandle< SiStripFedCabling > &fedcabling)
void endRun(edm::Run const &run, edm::EventSetup const &eSetup)
EndRun.
virtual ~SiStripDaqInfo()
Destructor.
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:654
static void getSubDetectorTag(uint32_t det_id, std::string &subdet_tag)
dictionary map
Definition: Association.py:205
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:90
void Fill(long long x)
edm::ESHandle< SiStripFedCabling > fedCabling_
const std::string subdet_tag("SubDet")
SiStripDaqInfo(const edm::ParameterSet &ps)
Constructor.
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1468
void analyze(edm::Event const &, edm::EventSetup const &)
Analyze.
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
DQMStore * dqmStore_
std::map< std::string, SubDetMEs > SubDetMEsMap
bool dirExists(const std::string &path) const
true if directory exists
Definition: DQMStore.cc:493
void readSubdetFedFractions(std::vector< int > &fed_ids)
std::map< std::string, std::vector< unsigned short > > subDetFedMap
int64_t getIntValue(void) const
const T & get() const
Definition: EventSetup.h:55
MonitorElement * DaqFractionME
void beginRun(edm::Run const &run, edm::EventSetup const &eSetup)
Begin Run.
void findExcludedModule(unsigned short fed_id)
void fillDummyStatus()
MonitorElement * DaqFraction_
bool isValid() const
Definition: ESHandle.h:37
MonitorElement * bookInt(const char *name)
Book int.
Definition: DQMStore.cc:624
unsigned long long m_cacheID_
void Reset(void)
reset ME (ie. contents, errors, etc)
static bool goToDir(DQMStore *dqm_store, std::string name)
void beginJob()
BeginJob.
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
Definition: Run.h:33
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
Definition: HCTypeTag.cc:129
const std::string & pwd(void) const
Definition: DQMStore.cc:401
static void getTopFolderPath(DQMStore *dqm_store, std::string type, std::string &path)