00001
00004
00005
00006
00007 #include<fstream>
00008 #include "TNamed.h"
00009 #include "FWCore/Framework/interface/ESHandle.h"
00010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00011 #include "FWCore/ServiceRegistry/interface/Service.h"
00012 #include "CalibTracker/Records/interface/SiStripDetCablingRcd.h"
00013 #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
00014 #include "DataFormats/Common/interface/DetSetNew.h"
00015 #include "DataFormats/Common/interface/DetSetVectorNew.h"
00016 #include "DataFormats/Common/interface/DetSetVector.h"
00017 #include "DataFormats/Common/interface/Handle.h"
00018 #include "DataFormats/SiStripDetId/interface/SiStripSubStructure.h"
00019 #include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
00020 #include "DQM/SiStripCommon/interface/SiStripFolderOrganizer.h"
00021 #include "DQM/SiStripCommon/interface/SiStripHistoId.h"
00022 #include "DQM/SiStripMonitorDigi/interface/SiStripMonitorDigi.h"
00023 #include "DQMServices/Core/interface/DQMStore.h"
00024 #include "DQMServices/Core/interface/MonitorElement.h"
00025 #include "DPGAnalysis/SiStripTools/interface/APVCyclePhaseCollection.h"
00026 #include "DPGAnalysis/SiStripTools/interface/EventWithHistory.h"
00027 #include "CalibTracker/SiStripCommon/interface/SiStripDCSStatus.h"
00028
00029 #include "TMath.h"
00030 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00031 #include "DataFormats/SiStripDetId/interface/TECDetId.h"
00032 #include "DataFormats/SiStripDetId/interface/TIBDetId.h"
00033 #include "DataFormats/SiStripDetId/interface/TIDDetId.h"
00034 #include "DataFormats/SiStripDetId/interface/TOBDetId.h"
00035
00036 #include "iostream"
00037
00038
00039
00040 SiStripMonitorDigi::SiStripMonitorDigi(const edm::ParameterSet& iConfig) : dqmStore_(edm::Service<DQMStore>().operator->()), conf_(iConfig), show_mechanical_structure_view(true), show_readout_view(false), show_control_view(false), select_all_detectors(true), reset_each_run(false), folder_organizer(), m_cacheID_(0)
00041 {
00042 firstEvent = -1;
00043 eventNb = 0;
00044
00045
00046 SubDetPhasePartMap["TIB"] = "TI";
00047 SubDetPhasePartMap["TID__side__1"] = "TI";
00048 SubDetPhasePartMap["TID__side__2"] = "TI";
00049 SubDetPhasePartMap["TOB"] = "TO";
00050 SubDetPhasePartMap["TEC__side__1"] = "TM";
00051 SubDetPhasePartMap["TEC__side__2"] = "TP";
00052
00053
00054 digiProducerList = conf_.getParameter<std::vector<edm::InputTag> >("DigiProducersList");
00055
00056
00057 edm::ParameterSet ParametersNumberOfDigis = conf_.getParameter<edm::ParameterSet>("TH1NumberOfDigis");
00058 layerswitchnumdigison = ParametersNumberOfDigis.getParameter<bool>("layerswitchon");
00059 moduleswitchnumdigison = ParametersNumberOfDigis.getParameter<bool>("moduleswitchon");
00060
00061 edm::ParameterSet ParametersNumberOfDigisPerStrip = conf_.getParameter<edm::ParameterSet>("TH1NumberOfDigisPerStrip");
00062 moduleswitchnumdigispstripon = ParametersNumberOfDigisPerStrip.getParameter<bool>("moduleswitchon");
00063
00064 edm::ParameterSet ParametersADCsHottestStrip = conf_.getParameter<edm::ParameterSet>("TH1ADCsHottestStrip");
00065 layerswitchadchotteston = ParametersADCsHottestStrip.getParameter<bool>("layerswitchon");
00066 moduleswitchadchotteston = ParametersADCsHottestStrip.getParameter<bool>("moduleswitchon");
00067
00068 edm::ParameterSet ParametersADCsCoolestStrip = conf_.getParameter<edm::ParameterSet>("TH1ADCsCoolestStrip");
00069 layerswitchadccooleston = ParametersADCsCoolestStrip.getParameter<bool>("layerswitchon");
00070 moduleswitchadccooleston = ParametersADCsCoolestStrip.getParameter<bool>("moduleswitchon");
00071
00072 edm::ParameterSet ParametersDigiADCs = conf_.getParameter<edm::ParameterSet>("TH1DigiADCs");
00073 layerswitchdigiadcson = ParametersDigiADCs.getParameter<bool>("layerswitchon");
00074 moduleswitchdigiadcson = ParametersDigiADCs.getParameter<bool>("moduleswitchon");
00075
00076 edm::ParameterSet ParametersStripOccupancy = conf_.getParameter<edm::ParameterSet>("TH1StripOccupancy");
00077 layerswitchstripoccupancyon = ParametersStripOccupancy.getParameter<bool>("layerswitchon");
00078 moduleswitchstripoccupancyon = ParametersStripOccupancy.getParameter<bool>("moduleswitchon");
00079
00080 edm::ParameterSet ParametersDigiProf = conf_.getParameter<edm::ParameterSet>("TProfNumberOfDigi");
00081 layerswitchnumdigisprofon = ParametersDigiProf.getParameter<bool>("layerswitchon");
00082 edm::ParameterSet ParametersDigiADC = conf_.getParameter<edm::ParameterSet>("TProfDigiADC");
00083 layerswitchdigiadcprofon = ParametersDigiProf.getParameter<bool>("layerswitchon");
00084
00085 edm::ParameterSet ParametersTotDigiProf = conf_.getParameter<edm::ParameterSet>("TProfTotalNumberOfDigis");
00086 subdetswitchtotdigiprofon = ParametersTotDigiProf.getParameter<bool>("subdetswitchon");
00087
00088 edm::ParameterSet ParametersTotDigisProfVsLS = conf_.getParameter<edm::ParameterSet>("TProfTotalNumberOfDigisVsLS");
00089 subdetswitchtotdigiproflson = ParametersTotDigisProfVsLS.getParameter<bool>("subdetswitchon");
00090
00091 edm::ParameterSet ParametersTotDigiFailure = conf_.getParameter<edm::ParameterSet>("TotalNumberOfDigisFailure");
00092 subdetswitchtotdigifailureon = ParametersTotDigiFailure.getParameter<bool>("subdetswitchon");
00093
00094 edm::ParameterSet ParametersDigiApvProf = conf_.getParameter<edm::ParameterSet>("TProfDigiApvCycle");
00095 subdetswitchapvcycleprofon = ParametersDigiApvProf.getParameter<bool>("subdetswitchon");
00096
00097 edm::ParameterSet ParametersDigiApvTH2 = conf_.getParameter<edm::ParameterSet>("TH2DigiApvCycle");
00098 subdetswitchapvcycleth2on = ParametersDigiApvTH2.getParameter<bool>("subdetswitchon");
00099
00100 digitkhistomapon = conf_.getParameter<bool>("TkHistoMap_On");
00101
00102 createTrendMEs = conf_.getParameter<bool>("CreateTrendMEs");
00103 Mod_On_ = conf_.getParameter<bool>("Mod_On");
00104 xLumiProf = conf_.getParameter<int>("xLumiProf");
00105
00106
00107 historyProducer_ = conf_.getParameter<edm::InputTag>("HistoryProducer");
00108
00109 apvPhaseProducer_ = conf_.getParameter<edm::InputTag>("ApvPhaseProducer");
00110
00111
00112 bool checkDCS = conf_.getParameter<bool>("UseDCSFiltering");
00113 if (checkDCS) dcsStatus_ = new SiStripDCSStatus();
00114 else dcsStatus_ = 0;
00115 }
00116
00117 SiStripMonitorDigi::~SiStripMonitorDigi() {
00118 if (dcsStatus_) delete dcsStatus_;
00119 }
00120
00121
00122 void SiStripMonitorDigi::beginRun(const edm::Run& run, const edm::EventSetup& es){
00123
00124 if (show_mechanical_structure_view) {
00125 unsigned long long cacheID = es.get<SiStripDetCablingRcd>().cacheIdentifier();
00126 if (m_cacheID_ != cacheID) {
00127 m_cacheID_ = cacheID;
00128 edm::LogInfo("SiStripMonitorDigi") <<"SiStripMonitorDigi::beginRun: "
00129 << " Creating MEs for new Cabling ";
00130 createMEs(es);
00131 }
00132 } else if (reset_each_run) {
00133 edm::LogInfo("SiStripMonitorDigi") <<"SiStripMonitorDigi::beginRun: "
00134 << " Resetting MEs ";
00135 for (std::map<uint32_t, ModMEs >::const_iterator idet = DigiMEs.begin() ; idet!=DigiMEs.end() ; idet++) {
00136 ResetModuleMEs(idet->first);
00137 }
00138 }
00139 }
00140
00141
00142 void SiStripMonitorDigi::endRun(const edm::Run&, const edm::EventSetup&){
00143 }
00144
00145
00146 void SiStripMonitorDigi::beginLuminosityBlock(const edm::LuminosityBlock& lb, const edm::EventSetup& es){
00147 if (lb.id().luminosityBlock() % xLumiProf == 0) {
00148 if (subdetswitchtotdigiproflson){
00149 if (digiFailureMEs.SubDetTotDigiProfLS) digiFailureMEs.SubDetTotDigiProfLS->Reset();
00150 }
00151 }
00152 }
00153
00154
00155 void SiStripMonitorDigi::endLuminosityBlock(const edm::LuminosityBlock& lb, const edm::EventSetup& es) {
00156 if(lb.id().luminosityBlock() % xLumiProf == 0){
00157 if (subdetswitchtotdigifailureon){
00158 if (digiFailureMEs.SubDetDigiFailures) digiFailureMEs.SubDetDigiFailures->Reset();
00159 MonitorElement * me = dqmStore_->get("SiStrip/MechanicalView/NumberOfDigisInLastLS");
00160 if (me){
00161 for (int ibin = 1; ibin<7;ibin++){
00162 float value = me->getBinContent(ibin);
00163 if (value < 50.){
00164 digiFailureMEs.SubDetDigiFailures -> Fill(ibin,0);
00165 }else{
00166 digiFailureMEs.SubDetDigiFailures -> Fill(ibin,1);
00167 }
00168 }
00169 }
00170 }
00171 }
00172 }
00173
00174 void SiStripMonitorDigi::beginJob(){
00175 }
00176
00177
00178
00179 void SiStripMonitorDigi::createMEs(const edm::EventSetup& es){
00180
00181 if ( show_mechanical_structure_view ){
00182
00183 es.get<SiStripDetCablingRcd>().get(SiStripDetCabling_);
00184
00185
00186 std::vector<uint32_t> activeDets;
00187 activeDets.clear();
00188 SiStripDetCabling_->addActiveDetectorsRawIds(activeDets);
00189
00190 SiStripSubStructure substructure;
00191
00192
00193 for(std::vector<uint32_t>::iterator idets = activeDets.begin(); idets != activeDets.end(); idets++){
00194 if(*idets == 0) activeDets.erase(idets);
00195 }
00196
00197
00198 SiStripFolderOrganizer folder_organizer;
00199
00200
00201 if (digitkhistomapon) tkmapdigi = new TkHistoMap("SiStrip/TkHisto","TkHMap_NumberOfDigi",0.0,1);
00202
00203 std::vector<uint32_t> tibDetIds;
00204
00205 edm::LogInfo("SiStripTkDQM|SiStripMonitorDigi")<<"nr. of activeDets: "<<activeDets.size();
00206 for(std::vector<uint32_t>::const_iterator detid_iterator = activeDets.begin(); detid_iterator!=activeDets.end(); detid_iterator++){
00207
00208 uint32_t detid = (*detid_iterator);
00209
00210 ModMEs local_modmes;
00211 local_modmes.NumberOfDigis = 0;
00212 local_modmes.NumberOfDigisPerStrip = 0;
00213 local_modmes.ADCsHottestStrip = 0;
00214 local_modmes.ADCsCoolestStrip = 0;
00215 local_modmes.DigiADCs = 0;
00216 local_modmes.StripOccupancy = 0;
00217
00218 if (Mod_On_) {
00219
00220 folder_organizer.setDetectorFolder(detid);
00221 if (reset_each_run) ResetModuleMEs(detid);
00222 createModuleMEs(local_modmes, detid);
00223
00224 DigiMEs.insert( std::make_pair(detid, local_modmes));
00225 }
00226
00227
00228 std::pair<std::string,int32_t> det_layer_pair = folder_organizer.GetSubDetAndLayer(detid);
00229 SiStripHistoId hidmanager;
00230 std::string label = hidmanager.getSubdetid(detid,false);
00231
00232
00233 std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(label);
00234 if(iLayerME==LayerMEsMap.end()) {
00235 int32_t lnumber = det_layer_pair.second;
00236 std::vector<uint32_t> layerDetIds;
00237 if (det_layer_pair.first == "TIB") {
00238 substructure.getTIBDetectors(activeDets,layerDetIds,lnumber,0,0,0);
00239 } else if (det_layer_pair.first == "TOB") {
00240 substructure.getTOBDetectors(activeDets,layerDetIds,lnumber,0,0);
00241 } else if (det_layer_pair.first == "TID" && lnumber > 0) {
00242 substructure.getTIDDetectors(activeDets,layerDetIds,2,abs(lnumber),0,0);
00243 } else if (det_layer_pair.first == "TID" && lnumber < 0) {
00244 substructure.getTIDDetectors(activeDets,layerDetIds,1,abs(lnumber),0,0);
00245 } else if (det_layer_pair.first == "TEC" && lnumber > 0) {
00246 substructure.getTECDetectors(activeDets,layerDetIds,2,abs(lnumber),0,0,0,0);
00247 } else if (det_layer_pair.first == "TEC" && lnumber < 0) {
00248 substructure.getTECDetectors(activeDets,layerDetIds,1,abs(lnumber),0,0,0,0);
00249 }
00250
00251 LayerDetMap[label] = layerDetIds;
00252
00253
00254 folder_organizer.setLayerFolder(detid,det_layer_pair.second);
00255 createLayerMEs(label, layerDetIds.size());
00256 }
00257
00258
00259 std::pair<std::string,std::string> sdet_pair = folder_organizer.getSubDetFolderAndTag(detid);
00260 if (SubDetMEsMap.find(sdet_pair.second) == SubDetMEsMap.end()){
00261 dqmStore_->setCurrentFolder(sdet_pair.first);
00262 createSubDetMEs(sdet_pair.second);
00263 }
00264
00265 }
00266
00267
00268
00269 digiFailureMEs.SubDetTotDigiProfLS = 0;
00270 digiFailureMEs.SubDetDigiFailures = 0;
00271 std::stringstream ss;
00272 folder_organizer.getLayerFolderName(ss, 0);
00273 dqmStore_->setCurrentFolder(ss.str().c_str());
00274 if (subdetswitchtotdigiproflson) {
00275 const char* HistoName = "NumberOfDigisInLastLS";
00276 digiFailureMEs.SubDetTotDigiProfLS= dqmStore_->bookProfile(HistoName, HistoName,
00277 6,0.5,6.5,
00278 100, 0., 10000., "" );
00279 digiFailureMEs.SubDetTotDigiProfLS->setBinLabel(1, std::string("TECB"));
00280 digiFailureMEs.SubDetTotDigiProfLS->setBinLabel(2, std::string("TECF"));
00281 digiFailureMEs.SubDetTotDigiProfLS->setBinLabel(3, std::string("TIB"));
00282 digiFailureMEs.SubDetTotDigiProfLS->setBinLabel(4, std::string("TIDB"));
00283 digiFailureMEs.SubDetTotDigiProfLS->setBinLabel(5, std::string("TIDF"));
00284 digiFailureMEs.SubDetTotDigiProfLS->setBinLabel(6, std::string("TOB"));
00285 }
00286
00287 if (subdetswitchtotdigifailureon) {
00288 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TotalNumberOfDigisFailure");
00289 std::string HistoName = "DataPresentInLastLS";
00290 digiFailureMEs.SubDetDigiFailures = dqmStore_->book2D(HistoName,HistoName,
00291 Parameters.getParameter<int32_t>("Nbins"),
00292 Parameters.getParameter<double>("xmin"),
00293 Parameters.getParameter<double>("xmax"),
00294 Parameters.getParameter<int32_t>("Nbinsy"),
00295 Parameters.getParameter<double>("ymin"),
00296 Parameters.getParameter<double>("ymax"));
00297 digiFailureMEs.SubDetDigiFailures->setBinLabel(1, std::string("TECB"));
00298 digiFailureMEs.SubDetDigiFailures->setBinLabel(2, std::string("TECF"));
00299 digiFailureMEs.SubDetDigiFailures->setBinLabel(3, std::string("TIB"));
00300 digiFailureMEs.SubDetDigiFailures->setBinLabel(4, std::string("TIDB"));
00301 digiFailureMEs.SubDetDigiFailures->setBinLabel(5, std::string("TIDF"));
00302 digiFailureMEs.SubDetDigiFailures->setBinLabel(6, std::string("TOB"));
00303 }
00304 }
00305
00306 }
00307
00308
00309 void SiStripMonitorDigi::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup){
00310
00311
00312 if (dcsStatus_ && !dcsStatus_->getStatus(iEvent, iSetup)) return;
00313
00314 runNb = iEvent.id().run();
00315 eventNb++;
00316 float iOrbitSec = iEvent.orbitNumber()/11223.0;
00317
00318 digi_detset_handles.clear();
00319 for(std::vector<edm::InputTag>::iterator itDigiProducerList = digiProducerList.begin();
00320 itDigiProducerList != digiProducerList.end(); ++itDigiProducerList ) {
00321
00322 edm::Handle< edm::DetSetVector<SiStripDigi> > digi_handle;
00323
00324 iEvent.getByLabel((*itDigiProducerList),digi_handle);
00325 if (digi_handle.isValid()) digi_detset_handles.push_back(digi_handle.product());
00326 }
00327
00328
00329 for (std::map<std::string, SubDetMEs>::iterator iSubdet = SubDetMEsMap.begin();
00330 iSubdet != SubDetMEsMap.end(); iSubdet++) {
00331 iSubdet->second.totNDigis = 0;
00332 }
00333
00334 for (std::map<std::string, std::vector< uint32_t > >::const_iterator iterLayer = LayerDetMap.begin();
00335 iterLayer != LayerDetMap.end(); iterLayer++) {
00336
00337 std::string layer_label = iterLayer->first;
00338 std::vector< uint32_t > layer_dets = iterLayer->second;
00339 std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(layer_label);
00340
00341
00342 LayerMEs local_layermes;
00343 if(iLayerME == LayerMEsMap.end()) continue;
00344 else local_layermes = iLayerME->second;
00345 int largest_adc_layer= 0;
00346 int smallest_adc_layer= 99999;
00347 int ndigi_layer = 0;
00348
00349 uint16_t iDet = 0;
00350 std::string subdet_label = "";
00351
00352 for (std::vector< uint32_t >::const_iterator iterDets = layer_dets.begin() ;
00353 iterDets != layer_dets.end() ; iterDets++) {
00354 iDet++;
00355
00356 uint32_t detid = (*iterDets);
00357
00358
00359 if (subdet_label.size() == 0) subdet_label = folder_organizer.getSubDetFolderAndTag(detid).second;
00360
00361
00362 std::map<uint32_t, ModMEs >::iterator pos = DigiMEs.find(detid);
00363 ModMEs local_modmes = pos->second;
00364
00365
00366 int loc = getDigiSourceIndex(detid);
00367
00368 int ndigi_det = 0;
00369 if (loc > -1) ndigi_det = (*(digi_detset_handles[loc]))[detid].size();
00370
00371
00372
00373 if(Mod_On_ && moduleswitchnumdigison && (local_modmes.NumberOfDigis != NULL))
00374 (local_modmes.NumberOfDigis)->Fill(ndigi_det);
00375
00376 if (layerswitchnumdigisprofon)
00377 local_layermes.LayerNumberOfDigisProfile->Fill(iDet*1.0,ndigi_det);
00378
00379 if (digitkhistomapon) tkmapdigi->fill(detid,ndigi_det);
00380
00381 if (ndigi_det == 0) continue;
00382
00383 const edm::DetSet<SiStripDigi> & digi_detset = (*(digi_detset_handles[loc]))[detid];
00384
00385 ndigi_layer += ndigi_det;
00386
00387 int largest_adc=(digi_detset.data.begin())->adc();
00388 int smallest_adc=(digi_detset.data.begin())->adc();
00389
00390
00391
00392 float det_occupancy = 0.0;
00393
00394 for(edm::DetSet<SiStripDigi>::const_iterator digiIter = digi_detset.data.begin();
00395 digiIter!= digi_detset.data.end(); digiIter++ ){
00396
00397 int this_adc = digiIter->adc();
00398 if (this_adc > 0.0) det_occupancy++;
00399
00400 if(this_adc>largest_adc) largest_adc = this_adc;
00401 if(this_adc<smallest_adc) smallest_adc = this_adc;
00402
00403 if(Mod_On_ && moduleswitchnumdigispstripon && (local_modmes.NumberOfDigisPerStrip != NULL) && (this_adc > 0.0) )
00404 (local_modmes.NumberOfDigisPerStrip)->Fill(digiIter->strip());
00405
00406 if(Mod_On_ && moduleswitchdigiadcson && (local_modmes.DigiADCs != NULL) )
00407 (local_modmes.DigiADCs)->Fill(static_cast<float>(this_adc));
00408
00409
00410 if(layerswitchdigiadcson) {
00411 fillME(local_layermes.LayerDigiADCs , this_adc);
00412 if (createTrendMEs) fillTrend(local_layermes.LayerDigiADCsTrend, this_adc, iOrbitSec);
00413 }
00414
00415 if (layerswitchdigiadcprofon)
00416 local_layermes.LayerDigiADCProfile->Fill(iDet*1.0,this_adc);
00417
00418 }
00419
00420
00421 short nstrips = SiStripDetCabling_->nApvPairs(detid) * 2 * 128;
00422 if (nstrips > 0 && det_occupancy > 0 ) {
00423 det_occupancy = det_occupancy/nstrips;
00424 if (Mod_On_ && moduleswitchstripoccupancyon && (local_modmes.StripOccupancy != NULL))
00425 (local_modmes.StripOccupancy)->Fill(det_occupancy);
00426 if (layerswitchstripoccupancyon) {
00427 fillME(local_layermes.LayerStripOccupancy, det_occupancy);
00428 if (createTrendMEs) fillTrend(local_layermes.LayerStripOccupancyTrend, det_occupancy, iOrbitSec);
00429 }
00430 }
00431
00432 if (largest_adc > largest_adc_layer) largest_adc_layer = largest_adc;
00433 if (smallest_adc < smallest_adc_layer) smallest_adc_layer = smallest_adc;
00434
00435
00436 if( Mod_On_ && moduleswitchadchotteston && (local_modmes.ADCsHottestStrip != NULL))
00437 (local_modmes.ADCsHottestStrip)->Fill(static_cast<float>(largest_adc));
00438
00439
00440 if(Mod_On_ && moduleswitchadccooleston && (local_modmes.ADCsCoolestStrip != NULL))
00441 (local_modmes.ADCsCoolestStrip)->Fill(static_cast<float>(smallest_adc));
00442
00443 }
00444
00445 if(layerswitchnumdigison) {
00446 fillME(local_layermes.LayerNumberOfDigis,ndigi_layer);
00447 if (createTrendMEs) fillTrend(local_layermes.LayerNumberOfDigisTrend, ndigi_layer, iOrbitSec);
00448 }
00449 if(layerswitchadchotteston) {
00450 fillME(local_layermes.LayerADCsHottestStrip,largest_adc_layer);
00451 if (createTrendMEs) fillTrend(local_layermes.LayerADCsHottestStripTrend, largest_adc_layer, iOrbitSec);
00452 }
00453 if(layerswitchadccooleston) {
00454 fillME(local_layermes.LayerADCsCoolestStrip ,smallest_adc_layer);
00455 if (createTrendMEs) fillTrend(local_layermes.LayerADCsCoolestStripTrend, smallest_adc_layer, iOrbitSec);
00456 }
00457 std::map<std::string, SubDetMEs>::iterator iSubdet = SubDetMEsMap.find(subdet_label);
00458 if(iSubdet != SubDetMEsMap.end()) iSubdet->second.totNDigis += ndigi_layer;
00459 }
00460
00461 for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin();
00462 it != SubDetMEsMap.end(); it++) {
00463 if (subdetswitchtotdigiproflson) {
00464 if (strcmp(it->first.c_str(),"TEC__side__1")==0){
00465 digiFailureMEs.SubDetTotDigiProfLS->Fill(1, it->second.totNDigis);
00466 }else if (strcmp(it->first.c_str(),"TEC__side__2")==0){
00467 digiFailureMEs.SubDetTotDigiProfLS->Fill(2, it->second.totNDigis);
00468 }else if (strcmp(it->first.c_str(),"TIB")==0){
00469 digiFailureMEs.SubDetTotDigiProfLS->Fill(3, it->second.totNDigis);
00470 }else if (strcmp(it->first.c_str(),"TID__side__1")==0){
00471 digiFailureMEs.SubDetTotDigiProfLS->Fill(4, it->second.totNDigis);
00472 }else if (strcmp(it->first.c_str(),"TID__side__2")==0){
00473 digiFailureMEs.SubDetTotDigiProfLS->Fill(5, it->second.totNDigis);
00474 }else if (strcmp(it->first.c_str(),"TOB")==0){
00475 digiFailureMEs.SubDetTotDigiProfLS->Fill(6, it->second.totNDigis);
00476 }
00477 }
00478 }
00479
00480
00481 edm::Handle<EventWithHistory> event_history;
00482 iEvent.getByLabel(historyProducer_,event_history);
00483
00484
00485 edm::Handle<APVCyclePhaseCollection> apv_phase_collection;
00486 iEvent.getByLabel(apvPhaseProducer_,apv_phase_collection);
00487
00488 if (event_history.isValid()
00489 && !event_history.failedToGet()
00490 && apv_phase_collection.isValid()
00491 && !apv_phase_collection.failedToGet()) {
00492
00493
00494 long long tbx = event_history->absoluteBX();
00495 float iOrbitSec = iEvent.orbitNumber()/11223.0;
00496
00497 for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin();
00498 it != SubDetMEsMap.end(); it++) {
00499
00500 SubDetMEs subdetmes;
00501 std::string subdet = it->first;
00502 subdetmes = it->second;
00503
00504 int the_phase = APVCyclePhaseCollection::invalid;
00505 long long tbx_corr = tbx;
00506
00507 if (SubDetPhasePartMap.find(subdet) != SubDetPhasePartMap.end()) the_phase = apv_phase_collection->getPhase(SubDetPhasePartMap[subdet]);
00508 if(the_phase==APVCyclePhaseCollection::nopartition ||
00509 the_phase==APVCyclePhaseCollection::multiphase ||
00510 the_phase==APVCyclePhaseCollection::invalid) the_phase=30;
00511 tbx_corr -= the_phase;
00512
00513 if (subdetswitchtotdigiprofon)subdetmes.SubDetTotDigiProf->Fill(iOrbitSec,subdetmes.totNDigis);
00514 if (subdetswitchapvcycleprofon)subdetmes.SubDetDigiApvProf->Fill(tbx_corr%70,subdetmes.totNDigis);
00515 if (subdetswitchapvcycleth2on) subdetmes.SubDetDigiApvTH2->Fill(tbx_corr%70,subdetmes.totNDigis);
00516 }
00517 }
00518 }
00519
00520 void SiStripMonitorDigi::endJob(void){
00521 bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
00522 std::string outputFileName = conf_.getParameter<std::string>("OutputFileName");
00523
00524
00525 if(outputMEsInRootFile) dqmStore_->save(outputFileName);
00526
00527 }
00528
00529 void SiStripMonitorDigi::ResetModuleMEs(uint32_t idet){
00530 std::map<uint32_t, ModMEs >::iterator pos = DigiMEs.find(idet);
00531 ModMEs mod_me = pos->second;
00532
00533 if(Mod_On_ && moduleswitchnumdigison) mod_me.NumberOfDigis->Reset();
00534 if(Mod_On_ && moduleswitchnumdigispstripon) mod_me.NumberOfDigisPerStrip ->Reset();
00535 if(Mod_On_ && moduleswitchadchotteston) mod_me.ADCsHottestStrip->Reset();
00536 if(Mod_On_ && moduleswitchadccooleston) mod_me.ADCsCoolestStrip->Reset();
00537 if(Mod_On_ && moduleswitchdigiadcson) mod_me.DigiADCs->Reset();
00538 if(Mod_On_ && moduleswitchstripoccupancyon) mod_me.StripOccupancy->Reset();
00539
00540 }
00541
00542 MonitorElement* SiStripMonitorDigi::bookMETrend(const char* ParameterSetLabel, const char* HistoName)
00543 {
00544 edm::ParameterSet ParametersTrend = conf_.getParameter<edm::ParameterSet>("Trending");
00545 MonitorElement* me = dqmStore_->bookProfile(HistoName,HistoName,
00546 ParametersTrend.getParameter<int32_t>("Nbins"),
00547
00548 ParametersTrend.getParameter<double>("xmin"),
00549 ParametersTrend.getParameter<double>("xmax"),
00550
00551 100,
00552 ParametersTrend.getParameter<double>("ymin"),
00553 ParametersTrend.getParameter<double>("ymax"),
00554 "" );
00555 if(!me) return me;
00556
00557 me->setAxisTitle("Event Time in Seconds",1);
00558 if (me->kind() == MonitorElement::DQM_KIND_TPROFILE) me->getTH1()->SetBit(TH1::kCanRebin);
00559 return me;
00560 }
00561
00562
00563 MonitorElement* SiStripMonitorDigi::bookME1D(const char* ParameterSetLabel, const char* HistoName)
00564 {
00565 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>(ParameterSetLabel);
00566 return dqmStore_->book1D(HistoName,HistoName,
00567 Parameters.getParameter<int32_t>("Nbinx"),
00568 Parameters.getParameter<double>("xmin"),
00569 Parameters.getParameter<double>("xmax")
00570 );
00571 }
00572
00573
00574 void SiStripMonitorDigi::fillTrend(MonitorElement* me ,float value, float timeinorbit)
00575 {
00576 if(!me) return;
00577 me->Fill(timeinorbit,value);
00578 }
00579
00580
00581
00582
00583 void SiStripMonitorDigi::createModuleMEs(ModMEs& mod_single, uint32_t detid) {
00584
00585
00586 SiStripHistoId hidmanager;
00587 std::string hid;
00588
00589
00590 if(moduleswitchnumdigison) {
00591 hid = hidmanager.createHistoId("NumberOfDigis","det",detid);
00592 mod_single.NumberOfDigis = dqmStore_->book1D(hid, hid, 21, -0.5, 20.5);
00593 dqmStore_->tag(mod_single.NumberOfDigis, detid);
00594 mod_single.NumberOfDigis->setAxisTitle("number of digis in one detector module");
00595 mod_single.NumberOfDigis->getTH1()->StatOverflows(kTRUE);
00596 }
00597
00598
00599 if(moduleswitchnumdigispstripon){
00600 hid = hidmanager.createHistoId("NumberOfDigisPerStrip","det",detid);
00601 short nstrips = SiStripDetCabling_->nApvPairs(detid) * 2 * 128;
00602 mod_single.NumberOfDigisPerStrip = dqmStore_->book1D(hid, hid, nstrips, -0.5, nstrips+0.5);
00603 dqmStore_->tag(mod_single.NumberOfDigisPerStrip, detid);
00604 mod_single.NumberOfDigisPerStrip->setAxisTitle("number of (digis > 0) per strip");
00605 mod_single.NumberOfDigisPerStrip->getTH1()->StatOverflows(kTRUE);
00606 }
00607
00608 if(moduleswitchadchotteston) {
00609 hid = hidmanager.createHistoId("ADCsHottestStrip","det",detid);
00610 mod_single.ADCsHottestStrip = bookME1D("TH1ADCsHottestStrip", hid.c_str());
00611 dqmStore_->tag(mod_single.ADCsHottestStrip, detid);
00612 mod_single.ADCsHottestStrip->setAxisTitle("number of ADCs for hottest strip");
00613 }
00614
00615
00616 if(moduleswitchadccooleston) {
00617 hid = hidmanager.createHistoId("ADCsCoolestStrip","det",detid);
00618 mod_single.ADCsCoolestStrip = bookME1D("TH1ADCsCoolestStrip", hid.c_str());
00619 dqmStore_->tag(mod_single.ADCsCoolestStrip, detid);
00620 mod_single.ADCsCoolestStrip->setAxisTitle("number of ADCs for coolest strip");
00621 }
00622
00623
00624 if(moduleswitchdigiadcson) {
00625 hid = hidmanager.createHistoId("DigiADCs","det",detid);
00626 mod_single.DigiADCs = bookME1D("TH1DigiADCs", hid.c_str());
00627 dqmStore_->tag(mod_single.DigiADCs, detid);
00628 mod_single.DigiADCs->setAxisTitle("number of ADCs for each digi");
00629 }
00630
00631
00632 if(moduleswitchstripoccupancyon) {
00633 hid = hidmanager.createHistoId("StripOccupancy","det",detid);
00634 mod_single.StripOccupancy = bookME1D("TH1StripOccupancy", hid.c_str());
00635 dqmStore_->tag(mod_single.StripOccupancy, detid);
00636 mod_single.StripOccupancy->setAxisTitle("strip occupancy");
00637 }
00638
00639 }
00640
00641
00642
00643
00644
00645 void SiStripMonitorDigi::createLayerMEs(std::string label, int ndets) {
00646
00647 std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(label);
00648 if(iLayerME==LayerMEsMap.end()){
00649 SiStripHistoId hidmanager;
00650 LayerMEs layerMEs;
00651 layerMEs.LayerNumberOfDigis = 0;
00652 layerMEs.LayerNumberOfDigisTrend = 0;
00653 layerMEs.LayerADCsHottestStrip = 0;
00654 layerMEs.LayerADCsHottestStripTrend = 0;
00655 layerMEs.LayerADCsCoolestStrip = 0;
00656 layerMEs.LayerADCsCoolestStripTrend = 0;
00657 layerMEs.LayerDigiADCs = 0;
00658 layerMEs.LayerDigiADCsTrend = 0;
00659 layerMEs.LayerStripOccupancy = 0;
00660 layerMEs.LayerStripOccupancyTrend = 0;
00661 layerMEs.LayerNumberOfDigisProfile = 0;
00662 layerMEs.LayerDigiADCProfile = 0;
00663
00664
00665
00666 if(layerswitchnumdigison) {
00667 layerMEs.LayerNumberOfDigis=bookME1D("TH1NumberOfDigis", hidmanager.createHistoLayer("Summary_TotalNumberOfDigis","layer",label,"").c_str());
00668 if (createTrendMEs) layerMEs.LayerNumberOfDigisTrend=bookMETrend("TH1NumberOfDigis", hidmanager.createHistoLayer("Trend_NumberOfDigis","layer",label,"").c_str());
00669 }
00670
00671
00672 if(layerswitchadchotteston) {
00673 layerMEs.LayerADCsHottestStrip=bookME1D("TH1ADCsHottestStrip", hidmanager.createHistoLayer("Summary_ADCsHottestStrip","layer",label,"").c_str());
00674 if (createTrendMEs) layerMEs.LayerADCsHottestStripTrend=bookMETrend("TH1ADCsHottestStrip", hidmanager.createHistoLayer("Trend_ADCsHottestStrip","layer",label,"").c_str());
00675 }
00676
00677
00678 if(layerswitchadccooleston) {
00679 layerMEs.LayerADCsCoolestStrip=bookME1D("TH1ADCsCoolestStrip", hidmanager.createHistoLayer("Summary_ADCsCoolestStrip","layer",label,"").c_str());
00680 if (createTrendMEs) layerMEs.LayerADCsCoolestStripTrend=bookMETrend("TH1ADCsCoolestStrip", hidmanager.createHistoLayer("Trend_ADCsCoolestStrip","layer",label,"").c_str());
00681 }
00682
00683
00684 if(layerswitchdigiadcson) {
00685 layerMEs.LayerDigiADCs=bookME1D("TH1DigiADCs", hidmanager.createHistoLayer("Summary_DigiADCs","layer",label,"").c_str());
00686 if (createTrendMEs) layerMEs.LayerDigiADCsTrend=bookMETrend("TH1DigiADCs", hidmanager.createHistoLayer("Trend_DigiADCs","layer",label,"").c_str());
00687 }
00688
00689
00690 if(layerswitchstripoccupancyon) {
00691 layerMEs.LayerStripOccupancy=bookME1D("TH1StripOccupancy", hidmanager.createHistoLayer("Summary_StripOccupancy","layer",label,"").c_str());
00692 if (createTrendMEs) layerMEs.LayerStripOccupancyTrend=bookMETrend("TH1StripOccupancy", hidmanager.createHistoLayer("Trend_StripOccupancy","layer",label,"").c_str());
00693
00694 }
00695
00696 if(layerswitchnumdigisprofon) {
00697 std::string hid = hidmanager.createHistoLayer("NumberOfDigiProfile","layer",label,"");
00698 layerMEs.LayerNumberOfDigisProfile = dqmStore_->bookProfile(hid, hid, ndets, 0.5, ndets+0.5,21, -0.5, 200.5);
00699 }
00700
00701
00702 if(layerswitchdigiadcprofon) {
00703 std::string hid = hidmanager.createHistoLayer("DigiADCProfile","layer",label,"");
00704 layerMEs.LayerDigiADCProfile = dqmStore_->bookProfile(hid, hid, ndets, 0.5, ndets+0.5, 64, -0.5, 255.5);
00705 }
00706
00707 LayerMEsMap[label]=layerMEs;
00708 }
00709 }
00710
00711
00712
00713 void SiStripMonitorDigi::createSubDetMEs(std::string label) {
00714
00715 SubDetMEs subdetMEs;
00716 subdetMEs.totNDigis = 0;
00717 subdetMEs.SubDetTotDigiProf = 0;
00718 subdetMEs.SubDetDigiApvProf = 0;
00719 subdetMEs.SubDetDigiApvTH2 = 0;
00720
00721 std::string HistoName;
00722
00723
00724 if(subdetswitchtotdigiprofon){
00725 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TProfTotalNumberOfDigis");
00726 HistoName = "TotalNumberOfDigiProfile__" + label;
00727 subdetMEs.SubDetTotDigiProf=dqmStore_->bookProfile(HistoName,HistoName,
00728 Parameters.getParameter<int32_t>("Nbins"),
00729 Parameters.getParameter<double>("xmin"),
00730 Parameters.getParameter<double>("xmax"),
00731 100,
00732 Parameters.getParameter<double>("ymin"),
00733 Parameters.getParameter<double>("ymax"),
00734 "" );
00735 subdetMEs.SubDetTotDigiProf->setAxisTitle("Event Time in Seconds",1);
00736 if (subdetMEs.SubDetTotDigiProf->kind() == MonitorElement::DQM_KIND_TPROFILE) subdetMEs.SubDetTotDigiProf->getTH1()->SetBit(TH1::kCanRebin);
00737 }
00738
00739
00740 if(subdetswitchapvcycleprofon){
00741 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TProfDigiApvCycle");
00742 HistoName = "Digi_vs_ApvCycle__" + label;
00743 subdetMEs.SubDetDigiApvProf=dqmStore_->bookProfile(HistoName,HistoName,
00744 Parameters.getParameter<int32_t>("Nbins"),
00745 Parameters.getParameter<double>("xmin"),
00746 Parameters.getParameter<double>("xmax"),
00747 200,
00748 Parameters.getParameter<double>("ymin"),
00749 Parameters.getParameter<double>("ymax"),
00750 "" );
00751 subdetMEs.SubDetDigiApvProf->setAxisTitle("ApvCycle (Corrected Absolute Bx % 70)",1);
00752 }
00753
00754
00755 if(subdetswitchapvcycleth2on){
00756 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TH2DigiApvCycle");
00757 dqmStore_->setCurrentFolder("SiStrip/MechanicalView/"+label);
00758 HistoName = "Digi_vs_ApvCycle_2D__" + label;
00759
00760 double h2ymax = 9999.0;
00761 double yfact = Parameters.getParameter<double>("yfactor");
00762 if(label.find("TIB") != std::string::npos) h2ymax = (6984.*256.)*yfact;
00763 else if (label.find("TID") != std::string::npos) h2ymax = (2208.*256.)*yfact;
00764 else if (label.find("TOB") != std::string::npos) h2ymax = (12906.*256.)*yfact;
00765 else if (label.find("TEC") != std::string::npos) h2ymax = (7552.*2.*256.)*yfact;
00766 subdetMEs.SubDetDigiApvTH2=dqmStore_->book2D(HistoName,HistoName,
00767 Parameters.getParameter<int32_t>("Nbins"),
00768 Parameters.getParameter<double>("xmin"),
00769 Parameters.getParameter<double>("xmax"),
00770 Parameters.getParameter<int32_t>("Nbinsy"),
00771 Parameters.getParameter<double>("ymin"),
00772 h2ymax);
00773 subdetMEs.SubDetDigiApvTH2->setAxisTitle("absolute Bx mod(70)",1);
00774 }
00775 SubDetMEsMap[label]=subdetMEs;
00776 }
00777
00778
00779
00780 int SiStripMonitorDigi::getDigiSourceIndex(uint32_t id) {
00781 int location = -1;
00782 for (unsigned int ival = 0; ival < digi_detset_handles.size(); ++ival){
00783 edm::DetSetVector<SiStripDigi>::const_iterator isearch = digi_detset_handles[ival]->find(id);
00784 if(isearch != digi_detset_handles[ival]->end()) {
00785 location = ival;
00786 break;
00787 }
00788 }
00789 return location;
00790 }
00791
00792 DEFINE_FWK_MODULE(SiStripMonitorDigi);