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 "CondFormats/SiStripObjects/interface/FedChannelConnection.h"
00030 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
00031
00032 #include "TMath.h"
00033 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00034 #include "DataFormats/SiStripDetId/interface/TECDetId.h"
00035 #include "DataFormats/SiStripDetId/interface/TIBDetId.h"
00036 #include "DataFormats/SiStripDetId/interface/TIDDetId.h"
00037 #include "DataFormats/SiStripDetId/interface/TOBDetId.h"
00038
00039 #include "iostream"
00040
00041
00042
00043 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)
00044 {
00045 firstEvent = -1;
00046 eventNb = 0;
00047
00048
00049 SubDetPhasePartMap["TIB"] = "TI";
00050 SubDetPhasePartMap["TID__side__1"] = "TI";
00051 SubDetPhasePartMap["TID__side__2"] = "TI";
00052 SubDetPhasePartMap["TOB"] = "TO";
00053 SubDetPhasePartMap["TEC__side__1"] = "TM";
00054 SubDetPhasePartMap["TEC__side__2"] = "TP";
00055
00056
00057 digiProducerList = conf_.getParameter<std::vector<edm::InputTag> >("DigiProducersList");
00058
00059
00060 edm::ParameterSet ParametersNumberOfDigis = conf_.getParameter<edm::ParameterSet>("TH1NumberOfDigis");
00061 layerswitchnumdigison = ParametersNumberOfDigis.getParameter<bool>("layerswitchon");
00062 moduleswitchnumdigison = ParametersNumberOfDigis.getParameter<bool>("moduleswitchon");
00063
00064 edm::ParameterSet ParametersNumberOfDigisPerStrip = conf_.getParameter<edm::ParameterSet>("TH1NumberOfDigisPerStrip");
00065 moduleswitchnumdigispstripon = ParametersNumberOfDigisPerStrip.getParameter<bool>("moduleswitchon");
00066
00067 edm::ParameterSet ParametersADCsHottestStrip = conf_.getParameter<edm::ParameterSet>("TH1ADCsHottestStrip");
00068 layerswitchadchotteston = ParametersADCsHottestStrip.getParameter<bool>("layerswitchon");
00069 moduleswitchadchotteston = ParametersADCsHottestStrip.getParameter<bool>("moduleswitchon");
00070
00071 edm::ParameterSet ParametersADCsCoolestStrip = conf_.getParameter<edm::ParameterSet>("TH1ADCsCoolestStrip");
00072 layerswitchadccooleston = ParametersADCsCoolestStrip.getParameter<bool>("layerswitchon");
00073 moduleswitchadccooleston = ParametersADCsCoolestStrip.getParameter<bool>("moduleswitchon");
00074
00075 edm::ParameterSet ParametersDigiADCs = conf_.getParameter<edm::ParameterSet>("TH1DigiADCs");
00076 layerswitchdigiadcson = ParametersDigiADCs.getParameter<bool>("layerswitchon");
00077 moduleswitchdigiadcson = ParametersDigiADCs.getParameter<bool>("moduleswitchon");
00078
00079 edm::ParameterSet ParametersStripOccupancy = conf_.getParameter<edm::ParameterSet>("TH1StripOccupancy");
00080 layerswitchstripoccupancyon = ParametersStripOccupancy.getParameter<bool>("layerswitchon");
00081 moduleswitchstripoccupancyon = ParametersStripOccupancy.getParameter<bool>("moduleswitchon");
00082
00083 edm::ParameterSet ParametersDigiProf = conf_.getParameter<edm::ParameterSet>("TProfNumberOfDigi");
00084 layerswitchnumdigisprofon = ParametersDigiProf.getParameter<bool>("layerswitchon");
00085
00086 edm::ParameterSet ParametersDigiADC = conf_.getParameter<edm::ParameterSet>("TProfDigiADC");
00087 layerswitchdigiadcprofon = ParametersDigiProf.getParameter<bool>("layerswitchon");
00088
00089 edm::ParameterSet ParametersTotDigiProf = conf_.getParameter<edm::ParameterSet>("TProfTotalNumberOfDigis");
00090 subdetswitchtotdigiprofon = ParametersTotDigiProf.getParameter<bool>("subdetswitchon");
00091
00092 edm::ParameterSet ParametersTotDigisProfVsLS = conf_.getParameter<edm::ParameterSet>("TProfTotalNumberOfDigisVsLS");
00093 subdetswitchtotdigiproflson = ParametersTotDigisProfVsLS.getParameter<bool>("subdetswitchon");
00094
00095 edm::ParameterSet ParametersTotDigiFailure = conf_.getParameter<edm::ParameterSet>("TotalNumberOfDigisFailure");
00096 subdetswitchtotdigifailureon = ParametersTotDigiFailure.getParameter<bool>("subdetswitchon");
00097
00098 edm::ParameterSet ParametersDigiApvProf = conf_.getParameter<edm::ParameterSet>("TProfDigiApvCycle");
00099 subdetswitchapvcycleprofon = ParametersDigiApvProf.getParameter<bool>("subdetswitchon");
00100
00101 edm::ParameterSet ParametersDigiApvTH2 = conf_.getParameter<edm::ParameterSet>("TH2DigiApvCycle");
00102 subdetswitchapvcycleth2on = ParametersDigiApvTH2.getParameter<bool>("subdetswitchon");
00103
00104 edm::ParameterSet ParametersNApvShots = conf_.getParameter<edm::ParameterSet>("TH1NApvShots");
00105 subdetswitchnapvshotson = ParametersNApvShots.getParameter<bool>("subdetswitchon");
00106
00107 edm::ParameterSet ParametersNStripApvShots = conf_.getParameter<edm::ParameterSet>("TH1NStripsApvShots");
00108 subdetswitchnstripsapvshotson = ParametersNStripApvShots.getParameter<bool>("subdetswitchon");
00109
00110 edm::ParameterSet ParametersChargeMedianApvShots = conf_.getParameter<edm::ParameterSet>("TH1ChargeMedianApvShots");
00111 subdetswitchchargemedianapvshotson = ParametersChargeMedianApvShots.getParameter<bool>("subdetswitchon");
00112
00113 edm::ParameterSet ParametersApvNumberApvShots = conf_.getParameter<edm::ParameterSet>("TH1ApvNumApvShots");
00114 subdetswitchapvshotsApvon = ParametersChargeMedianApvShots.getParameter<bool>("subdetswitchon");
00115
00116 edm::ParameterSet ParametersNApvShotsProf = conf_.getParameter<edm::ParameterSet>("TProfNShotsVsTime");
00117 subdetswitchapvshotsonprof = ParametersNApvShotsProf.getParameter<bool>("subdetswitchon");
00118
00119
00120
00121 edm::ParameterSet ParametersGlobalNApvShots = conf_.getParameter<edm::ParameterSet>("TH1NApvShots");
00122 globalswitchnapvshotson = ParametersGlobalNApvShots.getParameter<bool>("globalswitchon");
00123
00124 edm::ParameterSet ParametersGlobalNApvShotsProf = conf_.getParameter<edm::ParameterSet>("TProfGlobalNShots");
00125 globalsummaryapvshotson = ParametersGlobalNApvShotsProf.getParameter<bool>("globalswitchon");
00126
00127 edm::ParameterSet ParametersGlobalNStripApvShots = conf_.getParameter<edm::ParameterSet>("TH1NStripsApvShots");
00128 globalswitchnstripsapvshotson = ParametersGlobalNStripApvShots.getParameter<bool>("globalswitchon");
00129
00130 edm::ParameterSet ParametersGlobalApvNumApvShots = conf_.getParameter<edm::ParameterSet>("TH1ApvNumApvShots");
00131 globalswitchapvshotsApvon = ParametersGlobalApvNumApvShots.getParameter<bool>("globalswitchon");
00132
00133 edm::ParameterSet ParametersGlobalChargeMedianApvShots = conf_.getParameter<edm::ParameterSet>("TH1ChargeMedianApvShots");
00134 globalswitchchargemedianapvshotson = ParametersGlobalChargeMedianApvShots.getParameter<bool>("globalswitchon");
00135
00136 edm::ParameterSet ParametersGlobalNApvShotsTimeProf = conf_.getParameter<edm::ParameterSet>("TProfNShotsVsTime");
00137 globalswitchapvshotsonprof = ParametersGlobalNApvShotsTimeProf.getParameter<bool>("globalswitchon");
00138
00139
00140
00141 digitkhistomapon = conf_.getParameter<bool>("TkHistoMap_On");
00142
00143 shotshistomapon= conf_.getParameter<bool>("TkHistoMapNApvShots_On");
00144 shotsstripshistomapon= conf_.getParameter<bool>("TkHistoMapNStripApvShots_On");
00145 shotschargehistomapon= conf_.getParameter<bool>("TkHistoMapMedianChargeApvShots_On");
00146
00147 createTrendMEs = conf_.getParameter<bool>("CreateTrendMEs");
00148 Mod_On_ = conf_.getParameter<bool>("Mod_On");
00149 xLumiProf = conf_.getParameter<int>("xLumiProf");
00150
00151
00152 historyProducer_ = conf_.getParameter<edm::InputTag>("HistoryProducer");
00153
00154
00155 apvPhaseProducer_ = conf_.getParameter<edm::InputTag>("ApvPhaseProducer");
00156
00157
00158 bool checkDCS = conf_.getParameter<bool>("UseDCSFiltering");
00159 if (checkDCS) dcsStatus_ = new SiStripDCSStatus();
00160 else dcsStatus_ = 0;
00161 }
00162
00163
00164 SiStripMonitorDigi::~SiStripMonitorDigi() {
00165 if (dcsStatus_) delete dcsStatus_;
00166 }
00167
00168
00169 void SiStripMonitorDigi::beginRun(const edm::Run& run, const edm::EventSetup& es){
00170
00171 if (show_mechanical_structure_view) {
00172 unsigned long long cacheID = es.get<SiStripDetCablingRcd>().cacheIdentifier();
00173 if (m_cacheID_ != cacheID) {
00174 m_cacheID_ = cacheID;
00175 edm::LogInfo("SiStripMonitorDigi") <<"SiStripMonitorDigi::beginRun: "
00176 << " Creating MEs for new Cabling ";
00177 createMEs(es);
00178 }
00179 } else if (reset_each_run) {
00180 edm::LogInfo("SiStripMonitorDigi") <<"SiStripMonitorDigi::beginRun: "
00181 << " Resetting MEs ";
00182 for (std::map<uint32_t, ModMEs >::const_iterator idet = DigiMEs.begin() ; idet!=DigiMEs.end() ; idet++) {
00183 ResetModuleMEs(idet->first);
00184 }
00185 }
00186 }
00187
00188
00189 void SiStripMonitorDigi::endRun(const edm::Run&, const edm::EventSetup&){
00190 }
00191
00192
00193 void SiStripMonitorDigi::beginLuminosityBlock(const edm::LuminosityBlock& lb, const edm::EventSetup& es){
00194 if (lb.id().luminosityBlock() % xLumiProf == 0) {
00195 if (subdetswitchtotdigiproflson){
00196 if (digiFailureMEs.SubDetTotDigiProfLS) digiFailureMEs.SubDetTotDigiProfLS->Reset();
00197 }
00198 }
00199 }
00200
00201
00202 void SiStripMonitorDigi::endLuminosityBlock(const edm::LuminosityBlock& lb, const edm::EventSetup& es) {
00203 if(lb.id().luminosityBlock() % xLumiProf == 0){
00204 if (subdetswitchtotdigifailureon){
00205 if (digiFailureMEs.SubDetDigiFailures) digiFailureMEs.SubDetDigiFailures->Reset();
00206 MonitorElement * me = dqmStore_->get("SiStrip/MechanicalView/NumberOfDigisInLastLS");
00207 if (me){
00208 for (int ibin = 1; ibin<7;ibin++){
00209 float value = me->getBinContent(ibin);
00210 if (value < 50.){
00211 digiFailureMEs.SubDetDigiFailures -> Fill(ibin,0);
00212 }else{
00213 digiFailureMEs.SubDetDigiFailures -> Fill(ibin,1);
00214 }
00215 }
00216 }
00217 }
00218 }
00219 }
00220
00221 void SiStripMonitorDigi::beginJob(){
00222 }
00223
00224
00225
00226 void SiStripMonitorDigi::createMEs(const edm::EventSetup& es){
00227
00228 if ( show_mechanical_structure_view ){
00229
00230 es.get<SiStripDetCablingRcd>().get(SiStripDetCabling_);
00231
00232
00233 std::vector<uint32_t> activeDets;
00234 activeDets.clear();
00235 SiStripDetCabling_->addActiveDetectorsRawIds(activeDets);
00236
00237 SiStripSubStructure substructure;
00238
00239
00240 for(std::vector<uint32_t>::iterator idets = activeDets.begin(); idets != activeDets.end(); idets++){
00241 if(*idets == 0) activeDets.erase(idets);
00242 }
00243
00244
00245 SiStripFolderOrganizer folder_organizer;
00246
00247
00248
00249 if (digitkhistomapon) tkmapdigi = new TkHistoMap("SiStrip/TkHisto","TkHMap_NumberOfDigi",0.0,1);
00250 if (shotshistomapon) tkmapNApvshots = new TkHistoMap("SiStrip/TkHisto","TkHMap_NApvShots",0.0,1);
00251 if (shotsstripshistomapon) tkmapNstripApvshot= new TkHistoMap("SiStrip/TkHisto","TkHMap_NStripApvShots",0.0,1);
00252 if (shotschargehistomapon) tkmapMedianChargeApvshots= new TkHistoMap("SiStrip/TkHisto","TkHMap_MedianChargeApvShots",0.0,1);
00253
00254 std::vector<uint32_t> tibDetIds;
00255
00256
00257 edm::LogInfo("SiStripTkDQM|SiStripMonitorDigi")<<"nr. of activeDets: "<<activeDets.size();
00258 for(std::vector<uint32_t>::const_iterator detid_iterator = activeDets.begin(); detid_iterator!=activeDets.end(); detid_iterator++){
00259
00260 uint32_t detid = (*detid_iterator);
00261
00262 ModMEs local_modmes;
00263
00264 local_modmes.NumberOfDigis = 0;
00265 local_modmes.NumberOfDigisPerStrip = 0;
00266 local_modmes.ADCsHottestStrip = 0;
00267 local_modmes.ADCsCoolestStrip = 0;
00268 local_modmes.DigiADCs = 0;
00269 local_modmes.StripOccupancy = 0;
00270
00271 if (Mod_On_) {
00272
00273
00274 folder_organizer.setDetectorFolder(detid);
00275 if (reset_each_run) ResetModuleMEs(detid);
00276 createModuleMEs(local_modmes, detid);
00277
00278
00279 DigiMEs.insert( std::make_pair(detid, local_modmes));
00280 }
00281
00282
00283 std::pair<std::string,int32_t> det_layer_pair = folder_organizer.GetSubDetAndLayer(detid);
00284 SiStripHistoId hidmanager;
00285 std::string label = hidmanager.getSubdetid(detid,false);
00286
00287
00288 std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(label);
00289
00290 if(iLayerME==LayerMEsMap.end()) {
00291 int32_t lnumber = det_layer_pair.second;
00292 std::vector<uint32_t> layerDetIds;
00293 if (det_layer_pair.first == "TIB") {
00294 substructure.getTIBDetectors(activeDets,layerDetIds,lnumber,0,0,0);
00295 } else if (det_layer_pair.first == "TOB") {
00296 substructure.getTOBDetectors(activeDets,layerDetIds,lnumber,0,0);
00297 } else if (det_layer_pair.first == "TID" && lnumber > 0) {
00298 substructure.getTIDDetectors(activeDets,layerDetIds,2,abs(lnumber),0,0);
00299 } else if (det_layer_pair.first == "TID" && lnumber < 0) {
00300 substructure.getTIDDetectors(activeDets,layerDetIds,1,abs(lnumber),0,0);
00301 } else if (det_layer_pair.first == "TEC" && lnumber > 0) {
00302 substructure.getTECDetectors(activeDets,layerDetIds,2,abs(lnumber),0,0,0,0);
00303 } else if (det_layer_pair.first == "TEC" && lnumber < 0) {
00304 substructure.getTECDetectors(activeDets,layerDetIds,1,abs(lnumber),0,0,0,0);
00305 }
00306
00307 LayerDetMap[label] = layerDetIds;
00308
00309
00310 folder_organizer.setLayerFolder(detid,det_layer_pair.second);
00311 createLayerMEs(label, layerDetIds.size());
00312 }
00313
00314
00315 std::pair<std::string,std::string> sdet_pair = folder_organizer.getSubDetFolderAndTag(detid);
00316 if (SubDetMEsMap.find(sdet_pair.second) == SubDetMEsMap.end()){
00317 dqmStore_->setCurrentFolder(sdet_pair.first);
00318 createSubDetMEs(sdet_pair.second);
00319 }
00320
00321 }
00322
00323
00324
00325 dqmStore_->setCurrentFolder("SiStrip/MechanicalView/");
00326
00327 if (globalsummaryapvshotson) {
00328 const char* HistoName = "Summary Mean Apv shots for SubDets";
00329 NApvShotsGlobalProf= dqmStore_->bookProfile(HistoName, HistoName,
00330 6,0.5,6.5,
00331 100, 0., 0., "" );
00332 NApvShotsGlobalProf->setBinLabel(1, std::string("TECB"));
00333 NApvShotsGlobalProf->setBinLabel(2, std::string("TECF"));
00334 NApvShotsGlobalProf->setBinLabel(3, std::string("TIB"));
00335 NApvShotsGlobalProf->setBinLabel(4, std::string("TIDB"));
00336 NApvShotsGlobalProf->setBinLabel(5, std::string("TIDF"));
00337 NApvShotsGlobalProf->setBinLabel(6, std::string("TOB"));
00338 NApvShotsGlobalProf->setAxisTitle(" mean APV shots # / evt",2);
00339 }
00340
00341
00342 if (globalswitchapvshotsonprof){
00343 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TProfNShotsVsTime");
00344 const char* HistoName = "NApv_Shots_vs_Time";
00345 ShotsVsTimeApvShotsGlobal=dqmStore_->bookProfile(HistoName,HistoName,
00346 Parameters.getParameter<int32_t>("Nbins"),
00347 Parameters.getParameter<double>("xmin"),
00348 Parameters.getParameter<double>("xmax"),
00349 200,
00350 Parameters.getParameter<double>("ymin"),
00351 Parameters.getParameter<double>("ymax"),
00352 "" );
00353 ShotsVsTimeApvShotsGlobal->setAxisTitle("Time (s)",1);
00354 ShotsVsTimeApvShotsGlobal->setAxisTitle("# Apv Shots",2);
00355 if (ShotsVsTimeApvShotsGlobal->kind() == MonitorElement::DQM_KIND_TPROFILE) ShotsVsTimeApvShotsGlobal->getTH1()->SetBit(TH1::kCanRebin);
00356 }
00357
00358
00359 if (globalswitchnstripsapvshotson){
00360 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TH1NStripsApvShots");
00361 const char* HistoName = "Number_of_Strips_in_Apv_Shots";
00362 StripMultiplicityApvShotsGlobal=dqmStore_->book1D(HistoName,HistoName,
00363 Parameters.getParameter<int32_t>("Nbins"),
00364 Parameters.getParameter<double>("xmin"),
00365 Parameters.getParameter<double>("xmax"));
00366 StripMultiplicityApvShotsGlobal->setAxisTitle("# strips in Apv Shots",1);
00367 }
00368
00369
00370 if (globalswitchnapvshotson){
00371 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TH1NApvShots");
00372 const char* HistoName = "Number_of_Apv_Shots";
00373 NApvShotsGlobal=dqmStore_->book1D(HistoName,HistoName,
00374 Parameters.getParameter<int32_t>("Nbins"),
00375 Parameters.getParameter<double>("xmin"),
00376 Parameters.getParameter<double>("xmax"));
00377 NApvShotsGlobal->setAxisTitle("# Apv Shots",1);
00378 }
00379
00380
00381 if (globalswitchchargemedianapvshotson){
00382 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TH1ChargeMedianApvShots");
00383
00384 const char* HistoName = "Apv_Shots_Charge_Median";
00385 MedianChargeApvShotsGlobal=dqmStore_->book1D(HistoName,HistoName,
00386 Parameters.getParameter<int32_t>("Nbins"),
00387 Parameters.getParameter<double>("xmin"),
00388 Parameters.getParameter<double>("xmax"));
00389 MedianChargeApvShotsGlobal->setAxisTitle("Apv Shots Charge Median (ADC)",1);
00390 }
00391
00392
00393 if (globalswitchapvshotsApvon){
00394 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TH1ApvNumApvShots");
00395
00396 const char* HistoName = "Apv_Shots_Apv_Number";
00397 NApvApvShotsGlobal=dqmStore_->book1D(HistoName,HistoName,
00398 Parameters.getParameter<int32_t>("Nbins"),
00399 Parameters.getParameter<double>("xmin"),
00400 Parameters.getParameter<double>("xmax"));
00401 NApvApvShotsGlobal->setAxisTitle("Apv Number",1);
00402 }
00403
00404
00405
00406
00407
00408 digiFailureMEs.SubDetTotDigiProfLS = 0;
00409 digiFailureMEs.SubDetDigiFailures = 0;
00410
00411 std::stringstream ss;
00412
00413 folder_organizer.getLayerFolderName(ss, 0);
00414 dqmStore_->setCurrentFolder(ss.str().c_str());
00415
00416 if (subdetswitchtotdigiproflson) {
00417 const char* HistoName = "NumberOfDigisInLastLS";
00418 digiFailureMEs.SubDetTotDigiProfLS= dqmStore_->bookProfile(HistoName, HistoName,
00419 6,0.5,6.5,
00420 100, 0., 10000., "" );
00421 digiFailureMEs.SubDetTotDigiProfLS->setBinLabel(1, std::string("TECB"));
00422 digiFailureMEs.SubDetTotDigiProfLS->setBinLabel(2, std::string("TECF"));
00423 digiFailureMEs.SubDetTotDigiProfLS->setBinLabel(3, std::string("TIB"));
00424 digiFailureMEs.SubDetTotDigiProfLS->setBinLabel(4, std::string("TIDB"));
00425 digiFailureMEs.SubDetTotDigiProfLS->setBinLabel(5, std::string("TIDF"));
00426 digiFailureMEs.SubDetTotDigiProfLS->setBinLabel(6, std::string("TOB"));
00427 }
00428
00429 if (subdetswitchtotdigifailureon) {
00430 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TotalNumberOfDigisFailure");
00431 std::string HistoName = "DataPresentInLastLS";
00432 digiFailureMEs.SubDetDigiFailures = dqmStore_->book2D(HistoName,HistoName,
00433 Parameters.getParameter<int32_t>("Nbins"),
00434 Parameters.getParameter<double>("xmin"),
00435 Parameters.getParameter<double>("xmax"),
00436 Parameters.getParameter<int32_t>("Nbinsy"),
00437 Parameters.getParameter<double>("ymin"),
00438 Parameters.getParameter<double>("ymax"));
00439 digiFailureMEs.SubDetDigiFailures->setBinLabel(1, std::string("TECB"));
00440 digiFailureMEs.SubDetDigiFailures->setBinLabel(2, std::string("TECF"));
00441 digiFailureMEs.SubDetDigiFailures->setBinLabel(3, std::string("TIB"));
00442 digiFailureMEs.SubDetDigiFailures->setBinLabel(4, std::string("TIDB"));
00443 digiFailureMEs.SubDetDigiFailures->setBinLabel(5, std::string("TIDF"));
00444 digiFailureMEs.SubDetDigiFailures->setBinLabel(6, std::string("TOB"));
00445 }
00446 }
00447
00448 }
00449
00450
00451 void SiStripMonitorDigi::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup){
00452
00453
00454 if (dcsStatus_ && !dcsStatus_->getStatus(iEvent, iSetup)) return;
00455
00456 TotalNShots=0;
00457
00458 runNb = iEvent.id().run();
00459 eventNb++;
00460
00461 float iOrbitSec = iEvent.orbitNumber()/11223.0;
00462
00463 digi_detset_handles.clear();
00464 for(std::vector<edm::InputTag>::iterator itDigiProducerList = digiProducerList.begin();
00465 itDigiProducerList != digiProducerList.end(); ++itDigiProducerList ) {
00466
00467 edm::Handle< edm::DetSetVector<SiStripDigi> > digi_handle;
00468
00469 iEvent.getByLabel((*itDigiProducerList),digi_handle);
00470
00471 if (digi_handle.isValid()) digi_detset_handles.push_back(digi_handle.product());
00472 }
00473
00474
00475 for (std::map<std::string, SubDetMEs>::iterator iSubdet = SubDetMEsMap.begin();
00476 iSubdet != SubDetMEsMap.end(); iSubdet++) {
00477 iSubdet->second.totNDigis = 0;
00478 iSubdet->second.SubDetApvShots.clear();
00479 }
00480
00481 for (std::map<std::string, std::vector< uint32_t > >::const_iterator iterLayer = LayerDetMap.begin();
00482 iterLayer != LayerDetMap.end(); iterLayer++) {
00483
00484 std::string layer_label = iterLayer->first;
00485
00486 std::vector< uint32_t > layer_dets = iterLayer->second;
00487 std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(layer_label);
00488
00489
00490 LayerMEs local_layermes;
00491
00492 if(iLayerME == LayerMEsMap.end()) continue;
00493 else local_layermes = iLayerME->second;
00494
00495 int largest_adc_layer= 0;
00496 int smallest_adc_layer= 99999;
00497
00498 int ndigi_layer = 0;
00499
00500 uint16_t iDet = 0;
00501
00502 std::string subdet_label = "";
00503
00504
00505 for (std::vector< uint32_t >::const_iterator iterDets = layer_dets.begin() ;
00506 iterDets != layer_dets.end() ; iterDets++) {
00507 iDet++;
00508
00509
00510 uint32_t detid = (*iterDets);
00511
00512
00513 if (subdet_label.size() == 0) subdet_label = folder_organizer.getSubDetFolderAndTag(detid).second;
00514
00515
00516
00517 std::map<uint32_t, ModMEs >::iterator pos = DigiMEs.find(detid);
00518 ModMEs local_modmes = pos->second;
00519
00520
00521 int loc = getDigiSourceIndex(detid);
00522
00523 int ndigi_det = 0;
00524
00525 if (loc > -1) {
00526 ndigi_det = (*(digi_detset_handles[loc]))[detid].size();
00527 APVShotFinder theShotFinder = APVShotFinder((*(digi_detset_handles[loc]))[detid]);
00528 const std::vector<APVShot>& shots = theShotFinder.getShots();
00529 AddApvShotsToSubDet(shots,SubDetMEsMap[subdet_label].SubDetApvShots);
00530 if (shotshistomapon) tkmapNApvshots->fill(detid,shots.size());
00531 if (shotsstripshistomapon) FillApvShotsMap(tkmapNstripApvshot,shots,detid,1);
00532 if (shotschargehistomapon) FillApvShotsMap(tkmapMedianChargeApvshots,shots,detid,2);
00533 }
00534
00535 if(Mod_On_ && moduleswitchnumdigison && (local_modmes.NumberOfDigis != NULL))
00536 (local_modmes.NumberOfDigis)->Fill(ndigi_det);
00537
00538 if (layerswitchnumdigisprofon)
00539 local_layermes.LayerNumberOfDigisProfile->Fill(iDet*1.0,ndigi_det);
00540
00541 if (digitkhistomapon) tkmapdigi->fill(detid,ndigi_det);
00542
00543 if (ndigi_det == 0) continue;
00544
00545 const edm::DetSet<SiStripDigi> & digi_detset = (*(digi_detset_handles[loc]))[detid];
00546
00547 ndigi_layer += ndigi_det;
00548
00549
00550 int largest_adc=(digi_detset.data.begin())->adc();
00551 int smallest_adc=(digi_detset.data.begin())->adc();
00552
00553
00554
00555 float det_occupancy = 0.0;
00556
00557 for(edm::DetSet<SiStripDigi>::const_iterator digiIter = digi_detset.data.begin();
00558 digiIter!= digi_detset.data.end(); digiIter++ ){
00559
00560 int this_adc = digiIter->adc();
00561
00562 if (this_adc > 0.0) det_occupancy++;
00563
00564 if(this_adc>largest_adc) largest_adc = this_adc;
00565 if(this_adc<smallest_adc) smallest_adc = this_adc;
00566
00567 if(Mod_On_ && moduleswitchnumdigispstripon && (local_modmes.NumberOfDigisPerStrip != NULL) && (this_adc > 0.0) )
00568 (local_modmes.NumberOfDigisPerStrip)->Fill(digiIter->strip());
00569
00570 if(Mod_On_ && moduleswitchdigiadcson && (local_modmes.DigiADCs != NULL) )
00571 (local_modmes.DigiADCs)->Fill(static_cast<float>(this_adc));
00572
00573
00574 if(layerswitchdigiadcson) {
00575 fillME(local_layermes.LayerDigiADCs , this_adc);
00576 if (createTrendMEs) fillTrend(local_layermes.LayerDigiADCsTrend, this_adc, iOrbitSec);
00577 }
00578
00579 if (layerswitchdigiadcprofon)
00580 local_layermes.LayerDigiADCProfile->Fill(iDet*1.0,this_adc);
00581
00582 }
00583
00584
00585 short nstrips = SiStripDetCabling_->nApvPairs(detid) * 2 * 128;
00586 if (nstrips > 0 && det_occupancy > 0 ) {
00587 det_occupancy = det_occupancy/nstrips;
00588 if (Mod_On_ && moduleswitchstripoccupancyon && (local_modmes.StripOccupancy != NULL))
00589 (local_modmes.StripOccupancy)->Fill(det_occupancy);
00590 if (layerswitchstripoccupancyon) {
00591 fillME(local_layermes.LayerStripOccupancy, det_occupancy);
00592 if (createTrendMEs) fillTrend(local_layermes.LayerStripOccupancyTrend, det_occupancy, iOrbitSec);
00593 }
00594 }
00595
00596 if (largest_adc > largest_adc_layer) largest_adc_layer = largest_adc;
00597 if (smallest_adc < smallest_adc_layer) smallest_adc_layer = smallest_adc;
00598
00599
00600 if( Mod_On_ && moduleswitchadchotteston && (local_modmes.ADCsHottestStrip != NULL))
00601 (local_modmes.ADCsHottestStrip)->Fill(static_cast<float>(largest_adc));
00602
00603
00604 if(Mod_On_ && moduleswitchadccooleston && (local_modmes.ADCsCoolestStrip != NULL))
00605 (local_modmes.ADCsCoolestStrip)->Fill(static_cast<float>(smallest_adc));
00606
00607 }
00608
00609 if(layerswitchnumdigison) {
00610 fillME(local_layermes.LayerNumberOfDigis,ndigi_layer);
00611 if (createTrendMEs) fillTrend(local_layermes.LayerNumberOfDigisTrend, ndigi_layer, iOrbitSec);
00612 }
00613 if(layerswitchadchotteston) {
00614 fillME(local_layermes.LayerADCsHottestStrip,largest_adc_layer);
00615 if (createTrendMEs) fillTrend(local_layermes.LayerADCsHottestStripTrend, largest_adc_layer, iOrbitSec);
00616 }
00617 if(layerswitchadccooleston) {
00618 fillME(local_layermes.LayerADCsCoolestStrip ,smallest_adc_layer);
00619 if (createTrendMEs) fillTrend(local_layermes.LayerADCsCoolestStripTrend, smallest_adc_layer, iOrbitSec);
00620 }
00621
00622 std::map<std::string, SubDetMEs>::iterator iSubdet = SubDetMEsMap.find(subdet_label);
00623 if(iSubdet != SubDetMEsMap.end()) {
00624 iSubdet->second.totNDigis += ndigi_layer;
00625
00626 }
00627 }
00628
00629 for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin();
00630 it != SubDetMEsMap.end(); it++) {
00631
00632 if (subdetswitchtotdigiproflson) {
00633 if (strcmp(it->first.c_str(),"TEC__side__1")==0){
00634 digiFailureMEs.SubDetTotDigiProfLS->Fill(1, it->second.totNDigis);
00635 }else if (strcmp(it->first.c_str(),"TEC__side__2")==0){
00636 digiFailureMEs.SubDetTotDigiProfLS->Fill(2, it->second.totNDigis);
00637 }else if (strcmp(it->first.c_str(),"TIB")==0){
00638 digiFailureMEs.SubDetTotDigiProfLS->Fill(3, it->second.totNDigis);
00639 }else if (strcmp(it->first.c_str(),"TID__side__1")==0){
00640 digiFailureMEs.SubDetTotDigiProfLS->Fill(4, it->second.totNDigis);
00641 }else if (strcmp(it->first.c_str(),"TID__side__2")==0){
00642 digiFailureMEs.SubDetTotDigiProfLS->Fill(5, it->second.totNDigis);
00643 }else if (strcmp(it->first.c_str(),"TOB")==0){
00644 digiFailureMEs.SubDetTotDigiProfLS->Fill(6, it->second.totNDigis);
00645 }
00646 }
00647
00648 if (globalsummaryapvshotson) {
00649 if (strcmp(it->first.c_str(),"TEC__side__1")==0){
00650 NApvShotsGlobalProf->Fill(1,it->second.SubDetApvShots.size());
00651 }else if (strcmp(it->first.c_str(),"TEC__side__2")==0){
00652 NApvShotsGlobalProf->Fill(2,it->second.SubDetApvShots.size());
00653 }else if (strcmp(it->first.c_str(),"TIB")==0){
00654 NApvShotsGlobalProf->Fill(3,it->second.SubDetApvShots.size());
00655 }else if (strcmp(it->first.c_str(),"TID__side__1")==0){
00656 NApvShotsGlobalProf->Fill(4,it->second.SubDetApvShots.size());
00657 }else if (strcmp(it->first.c_str(),"TID__side__2")==0){
00658 NApvShotsGlobalProf->Fill(5,it->second.SubDetApvShots.size());
00659 }else if (strcmp(it->first.c_str(),"TOB")==0){
00660 NApvShotsGlobalProf->Fill(6,it->second.SubDetApvShots.size());
00661 }
00662 }
00663
00664 SubDetMEs subdetmes= it->second;
00665 std::string subdet = it->first;
00666
00667
00668
00669 uint ShotsSize=subdetmes.SubDetApvShots.size();
00670 TotalNShots+=ShotsSize;
00671
00672 if (subdetswitchnapvshotson ) subdetmes.SubDetNApvShotsTH1->Fill(ShotsSize);
00673 if (subdetswitchapvshotsonprof) subdetmes.SubDetNApvShotsProf ->Fill(iOrbitSec,ShotsSize);
00674
00675 for (uint i=0; i< ShotsSize; ++i){
00676
00677 if (subdetswitchapvshotsApvon) subdetmes.SubDetNApvShotsNApvTH1->Fill((subdetmes.SubDetApvShots[i].apvNumber()+1));
00678 if (globalswitchapvshotsApvon) NApvApvShotsGlobal->Fill((subdetmes.SubDetApvShots[i].apvNumber()+1));
00679
00680 if (subdetswitchnstripsapvshotson) subdetmes.SubDetNStripsApvShotsTH1->Fill(subdetmes.SubDetApvShots[i].nStrips());
00681 if (globalswitchnstripsapvshotson) StripMultiplicityApvShotsGlobal->Fill(subdetmes.SubDetApvShots[i].nStrips());
00682
00683 if (subdetswitchchargemedianapvshotson) subdetmes.SubDetChargeMedianApvShotsTH1->Fill(subdetmes.SubDetApvShots[i].median());
00684 if (globalswitchchargemedianapvshotson) MedianChargeApvShotsGlobal->Fill(subdetmes.SubDetApvShots[i].median());
00685
00686 }
00687
00688 if (subdetswitchtotdigiprofon)subdetmes.SubDetTotDigiProf->Fill(iOrbitSec,subdetmes.totNDigis);
00689 }
00690
00691 if (globalswitchnapvshotson) NApvShotsGlobal->Fill(TotalNShots);
00692 if (globalswitchapvshotsonprof) ShotsVsTimeApvShotsGlobal->Fill(iOrbitSec,TotalNShots);
00693
00694
00695
00696 edm::Handle<EventWithHistory> event_history;
00697 iEvent.getByLabel(historyProducer_,event_history);
00698
00699
00700 edm::Handle<APVCyclePhaseCollection> apv_phase_collection;
00701 iEvent.getByLabel(apvPhaseProducer_,apv_phase_collection);
00702
00703 if (event_history.isValid()
00704 && !event_history.failedToGet()
00705 && apv_phase_collection.isValid()
00706 && !apv_phase_collection.failedToGet()) {
00707
00708
00709 long long tbx = event_history->absoluteBX();
00710
00711
00712 for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin();
00713 it != SubDetMEsMap.end(); it++) {
00714
00715 SubDetMEs subdetmes;
00716 std::string subdet = it->first;
00717 subdetmes = it->second;
00718
00719 int the_phase = APVCyclePhaseCollection::invalid;
00720 long long tbx_corr = tbx;
00721
00722 if (SubDetPhasePartMap.find(subdet) != SubDetPhasePartMap.end()) the_phase = apv_phase_collection->getPhase(SubDetPhasePartMap[subdet]);
00723 if(the_phase==APVCyclePhaseCollection::nopartition ||
00724 the_phase==APVCyclePhaseCollection::multiphase ||
00725 the_phase==APVCyclePhaseCollection::invalid) the_phase=30;
00726 tbx_corr -= the_phase;
00727
00728 if (subdetswitchapvcycleprofon)subdetmes.SubDetDigiApvProf->Fill(tbx_corr%70,subdetmes.totNDigis);
00729 if (subdetswitchapvcycleth2on) subdetmes.SubDetDigiApvTH2->Fill(tbx_corr%70,subdetmes.totNDigis);
00730 }
00731 }
00732 }
00733
00734
00735 void SiStripMonitorDigi::endJob(void){
00736 bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
00737 std::string outputFileName = conf_.getParameter<std::string>("OutputFileName");
00738
00739
00740 if(outputMEsInRootFile) dqmStore_->save(outputFileName);
00741
00742 }
00743
00744 void SiStripMonitorDigi::ResetModuleMEs(uint32_t idet){
00745 std::map<uint32_t, ModMEs >::iterator pos = DigiMEs.find(idet);
00746 ModMEs mod_me = pos->second;
00747
00748 if(Mod_On_ && moduleswitchnumdigison) mod_me.NumberOfDigis->Reset();
00749 if(Mod_On_ && moduleswitchnumdigispstripon) mod_me.NumberOfDigisPerStrip ->Reset();
00750 if(Mod_On_ && moduleswitchadchotteston) mod_me.ADCsHottestStrip->Reset();
00751 if(Mod_On_ && moduleswitchadccooleston) mod_me.ADCsCoolestStrip->Reset();
00752 if(Mod_On_ && moduleswitchdigiadcson) mod_me.DigiADCs->Reset();
00753 if(Mod_On_ && moduleswitchstripoccupancyon) mod_me.StripOccupancy->Reset();
00754
00755 }
00756
00757 MonitorElement* SiStripMonitorDigi::bookMETrend(const char* ParameterSetLabel, const char* HistoName)
00758 {
00759 edm::ParameterSet ParametersTrend = conf_.getParameter<edm::ParameterSet>("Trending");
00760 MonitorElement* me = dqmStore_->bookProfile(HistoName,HistoName,
00761 ParametersTrend.getParameter<int32_t>("Nbins"),
00762
00763 ParametersTrend.getParameter<double>("xmin"),
00764 ParametersTrend.getParameter<double>("xmax"),
00765
00766 100,
00767 ParametersTrend.getParameter<double>("ymin"),
00768 ParametersTrend.getParameter<double>("ymax"),
00769 "" );
00770 if(!me) return me;
00771
00772 me->setAxisTitle("Event Time in Seconds",1);
00773 if (me->kind() == MonitorElement::DQM_KIND_TPROFILE) me->getTH1()->SetBit(TH1::kCanRebin);
00774 return me;
00775 }
00776
00777
00778 MonitorElement* SiStripMonitorDigi::bookME1D(const char* ParameterSetLabel, const char* HistoName)
00779 {
00780 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>(ParameterSetLabel);
00781 return dqmStore_->book1D(HistoName,HistoName,
00782 Parameters.getParameter<int32_t>("Nbinx"),
00783 Parameters.getParameter<double>("xmin"),
00784 Parameters.getParameter<double>("xmax")
00785 );
00786 }
00787
00788
00789 void SiStripMonitorDigi::fillTrend(MonitorElement* me ,float value, float timeinorbit)
00790 {
00791 if(!me) return;
00792 me->Fill(timeinorbit,value);
00793 }
00794
00795
00796
00797
00798 void SiStripMonitorDigi::createModuleMEs(ModMEs& mod_single, uint32_t detid) {
00799
00800
00801 SiStripHistoId hidmanager;
00802 std::string hid;
00803
00804
00805 if(moduleswitchnumdigison) {
00806 hid = hidmanager.createHistoId("NumberOfDigis","det",detid);
00807 mod_single.NumberOfDigis = dqmStore_->book1D(hid, hid, 21, -0.5, 20.5);
00808 dqmStore_->tag(mod_single.NumberOfDigis, detid);
00809 mod_single.NumberOfDigis->setAxisTitle("number of digis in one detector module");
00810 mod_single.NumberOfDigis->getTH1()->StatOverflows(kTRUE);
00811 }
00812
00813
00814 if(moduleswitchnumdigispstripon){
00815 hid = hidmanager.createHistoId("NumberOfDigisPerStrip","det",detid);
00816 short nstrips = SiStripDetCabling_->nApvPairs(detid) * 2 * 128;
00817 mod_single.NumberOfDigisPerStrip = dqmStore_->book1D(hid, hid, nstrips, -0.5, nstrips+0.5);
00818 dqmStore_->tag(mod_single.NumberOfDigisPerStrip, detid);
00819 mod_single.NumberOfDigisPerStrip->setAxisTitle("number of (digis > 0) per strip");
00820 mod_single.NumberOfDigisPerStrip->getTH1()->StatOverflows(kTRUE);
00821 }
00822
00823 if(moduleswitchadchotteston) {
00824 hid = hidmanager.createHistoId("ADCsHottestStrip","det",detid);
00825 mod_single.ADCsHottestStrip = bookME1D("TH1ADCsHottestStrip", hid.c_str());
00826 dqmStore_->tag(mod_single.ADCsHottestStrip, detid);
00827 mod_single.ADCsHottestStrip->setAxisTitle("number of ADCs for hottest strip");
00828 }
00829
00830
00831 if(moduleswitchadccooleston) {
00832 hid = hidmanager.createHistoId("ADCsCoolestStrip","det",detid);
00833 mod_single.ADCsCoolestStrip = bookME1D("TH1ADCsCoolestStrip", hid.c_str());
00834 dqmStore_->tag(mod_single.ADCsCoolestStrip, detid);
00835 mod_single.ADCsCoolestStrip->setAxisTitle("number of ADCs for coolest strip");
00836 }
00837
00838
00839 if(moduleswitchdigiadcson) {
00840 hid = hidmanager.createHistoId("DigiADCs","det",detid);
00841 mod_single.DigiADCs = bookME1D("TH1DigiADCs", hid.c_str());
00842 dqmStore_->tag(mod_single.DigiADCs, detid);
00843 mod_single.DigiADCs->setAxisTitle("number of ADCs for each digi");
00844 }
00845
00846
00847 if(moduleswitchstripoccupancyon) {
00848 hid = hidmanager.createHistoId("StripOccupancy","det",detid);
00849 mod_single.StripOccupancy = bookME1D("TH1StripOccupancy", hid.c_str());
00850 dqmStore_->tag(mod_single.StripOccupancy, detid);
00851 mod_single.StripOccupancy->setAxisTitle("strip occupancy");
00852 }
00853
00854 }
00855
00856
00857
00858
00859
00860 void SiStripMonitorDigi::createLayerMEs(std::string label, int ndets) {
00861
00862 std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(label);
00863 if(iLayerME==LayerMEsMap.end()){
00864 SiStripHistoId hidmanager;
00865 LayerMEs layerMEs;
00866 layerMEs.LayerNumberOfDigis = 0;
00867 layerMEs.LayerNumberOfDigisTrend = 0;
00868 layerMEs.LayerADCsHottestStrip = 0;
00869 layerMEs.LayerADCsHottestStripTrend = 0;
00870 layerMEs.LayerADCsCoolestStrip = 0;
00871 layerMEs.LayerADCsCoolestStripTrend = 0;
00872 layerMEs.LayerDigiADCs = 0;
00873 layerMEs.LayerDigiADCsTrend = 0;
00874 layerMEs.LayerStripOccupancy = 0;
00875 layerMEs.LayerStripOccupancyTrend = 0;
00876 layerMEs.LayerNumberOfDigisProfile = 0;
00877 layerMEs.LayerDigiADCProfile = 0;
00878
00879
00880
00881 if(layerswitchnumdigison) {
00882 layerMEs.LayerNumberOfDigis=bookME1D("TH1NumberOfDigis", hidmanager.createHistoLayer("Summary_TotalNumberOfDigis","layer",label,"").c_str());
00883 if (createTrendMEs) layerMEs.LayerNumberOfDigisTrend=bookMETrend("TH1NumberOfDigis", hidmanager.createHistoLayer("Trend_NumberOfDigis","layer",label,"").c_str());
00884 }
00885
00886
00887 if(layerswitchadchotteston) {
00888 layerMEs.LayerADCsHottestStrip=bookME1D("TH1ADCsHottestStrip", hidmanager.createHistoLayer("Summary_ADCsHottestStrip","layer",label,"").c_str());
00889 if (createTrendMEs) layerMEs.LayerADCsHottestStripTrend=bookMETrend("TH1ADCsHottestStrip", hidmanager.createHistoLayer("Trend_ADCsHottestStrip","layer",label,"").c_str());
00890 }
00891
00892
00893 if(layerswitchadccooleston) {
00894 layerMEs.LayerADCsCoolestStrip=bookME1D("TH1ADCsCoolestStrip", hidmanager.createHistoLayer("Summary_ADCsCoolestStrip","layer",label,"").c_str());
00895 if (createTrendMEs) layerMEs.LayerADCsCoolestStripTrend=bookMETrend("TH1ADCsCoolestStrip", hidmanager.createHistoLayer("Trend_ADCsCoolestStrip","layer",label,"").c_str());
00896 }
00897
00898
00899 if(layerswitchdigiadcson) {
00900 layerMEs.LayerDigiADCs=bookME1D("TH1DigiADCs", hidmanager.createHistoLayer("Summary_DigiADCs","layer",label,"").c_str());
00901 if (createTrendMEs) layerMEs.LayerDigiADCsTrend=bookMETrend("TH1DigiADCs", hidmanager.createHistoLayer("Trend_DigiADCs","layer",label,"").c_str());
00902 }
00903
00904
00905 if(layerswitchstripoccupancyon) {
00906 layerMEs.LayerStripOccupancy=bookME1D("TH1StripOccupancy", hidmanager.createHistoLayer("Summary_StripOccupancy","layer",label,"").c_str());
00907 if (createTrendMEs) layerMEs.LayerStripOccupancyTrend=bookMETrend("TH1StripOccupancy", hidmanager.createHistoLayer("Trend_StripOccupancy","layer",label,"").c_str());
00908
00909 }
00910
00911 if(layerswitchnumdigisprofon) {
00912 std::string hid = hidmanager.createHistoLayer("NumberOfDigiProfile","layer",label,"");
00913 layerMEs.LayerNumberOfDigisProfile = dqmStore_->bookProfile(hid, hid, ndets, 0.5, ndets+0.5,21, -0.5, 200.5);
00914 }
00915
00916
00917 if(layerswitchdigiadcprofon) {
00918 std::string hid = hidmanager.createHistoLayer("DigiADCProfile","layer",label,"");
00919 layerMEs.LayerDigiADCProfile = dqmStore_->bookProfile(hid, hid, ndets, 0.5, ndets+0.5, 64, -0.5, 255.5);
00920 }
00921
00922 LayerMEsMap[label]=layerMEs;
00923 }
00924 }
00925
00926
00927
00928 void SiStripMonitorDigi::createSubDetMEs(std::string label) {
00929
00930 SubDetMEs subdetMEs;
00931 subdetMEs.totNDigis = 0;
00932 subdetMEs.SubDetTotDigiProf = 0;
00933 subdetMEs.SubDetDigiApvProf = 0;
00934 subdetMEs.SubDetDigiApvTH2 = 0;
00935
00936 subdetMEs.SubDetApvShots.clear();
00937 subdetMEs.SubDetNApvShotsTH1 = 0;
00938 subdetMEs.SubDetChargeMedianApvShotsTH1 = 0;
00939 subdetMEs.SubDetNStripsApvShotsTH1 = 0;
00940 subdetMEs.SubDetNApvShotsProf = 0;
00941
00942 std::string HistoName;
00943
00944
00945 if(subdetswitchtotdigiprofon){
00946 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TProfTotalNumberOfDigis");
00947 HistoName = "TotalNumberOfDigiProfile__" + label;
00948 subdetMEs.SubDetTotDigiProf=dqmStore_->bookProfile(HistoName,HistoName,
00949 Parameters.getParameter<int32_t>("Nbins"),
00950 Parameters.getParameter<double>("xmin"),
00951 Parameters.getParameter<double>("xmax"),
00952 100,
00953 Parameters.getParameter<double>("ymin"),
00954 Parameters.getParameter<double>("ymax"),
00955 "" );
00956 subdetMEs.SubDetTotDigiProf->setAxisTitle("Event Time in Seconds",1);
00957 if (subdetMEs.SubDetTotDigiProf->kind() == MonitorElement::DQM_KIND_TPROFILE) subdetMEs.SubDetTotDigiProf->getTH1()->SetBit(TH1::kCanRebin);
00958 }
00959
00960
00961 if(subdetswitchapvcycleprofon){
00962 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TProfDigiApvCycle");
00963 HistoName = "Digi_vs_ApvCycle__" + label;
00964 subdetMEs.SubDetDigiApvProf=dqmStore_->bookProfile(HistoName,HistoName,
00965 Parameters.getParameter<int32_t>("Nbins"),
00966 Parameters.getParameter<double>("xmin"),
00967 Parameters.getParameter<double>("xmax"),
00968 200,
00969 Parameters.getParameter<double>("ymin"),
00970 Parameters.getParameter<double>("ymax"),
00971 "" );
00972 subdetMEs.SubDetDigiApvProf->setAxisTitle("ApvCycle (Corrected Absolute Bx % 70)",1);
00973 }
00974
00975
00976 if(subdetswitchapvcycleth2on){
00977 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TH2DigiApvCycle");
00978
00979 HistoName = "Digi_vs_ApvCycle_2D__" + label;
00980
00981 double h2ymax = 9999.0;
00982 double yfact = Parameters.getParameter<double>("yfactor");
00983 if(label.find("TIB") != std::string::npos) h2ymax = (6984.*256.)*yfact;
00984 else if (label.find("TID") != std::string::npos) h2ymax = (2208.*256.)*yfact;
00985 else if (label.find("TOB") != std::string::npos) h2ymax = (12906.*256.)*yfact;
00986 else if (label.find("TEC") != std::string::npos) h2ymax = (7552.*2.*256.)*yfact;
00987 subdetMEs.SubDetDigiApvTH2=dqmStore_->book2D(HistoName,HistoName,
00988 Parameters.getParameter<int32_t>("Nbins"),
00989 Parameters.getParameter<double>("xmin"),
00990 Parameters.getParameter<double>("xmax"),
00991 Parameters.getParameter<int32_t>("Nbinsy"),
00992 Parameters.getParameter<double>("ymin"),
00993 h2ymax);
00994 subdetMEs.SubDetDigiApvTH2->setAxisTitle("absolute Bx mod(70)",1);
00995 }
00996
00997
00998 if (subdetswitchnapvshotson){
00999 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TH1NApvShots");
01000
01001 HistoName = "Number_of_Apv_Shots_" + label;
01002 subdetMEs.SubDetNApvShotsTH1=dqmStore_->book1D(HistoName,HistoName,
01003 Parameters.getParameter<int32_t>("Nbins"),
01004 Parameters.getParameter<double>("xmin"),
01005 Parameters.getParameter<double>("xmax"));
01006 subdetMEs.SubDetNApvShotsTH1->setAxisTitle("# Apv Shots",1);
01007 }
01008
01009
01010 if (subdetswitchnstripsapvshotson){
01011 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TH1NStripsApvShots");
01012
01013 HistoName = "Number_of_Strips_in_Apv_Shots_" + label;
01014 subdetMEs.SubDetNStripsApvShotsTH1=dqmStore_->book1D(HistoName,HistoName,
01015 Parameters.getParameter<int32_t>("Nbins"),
01016 Parameters.getParameter<double>("xmin"),
01017 Parameters.getParameter<double>("xmax"));
01018 subdetMEs.SubDetNStripsApvShotsTH1->setAxisTitle("# strips in Apv Shots",1);
01019 }
01020
01021
01022 if (subdetswitchchargemedianapvshotson){
01023 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TH1ChargeMedianApvShots");
01024
01025 HistoName = "Apv_Shots_Charge_Median_" + label;
01026 subdetMEs.SubDetChargeMedianApvShotsTH1=dqmStore_->book1D(HistoName,HistoName,
01027 Parameters.getParameter<int32_t>("Nbins"),
01028 Parameters.getParameter<double>("xmin"),
01029 Parameters.getParameter<double>("xmax"));
01030 subdetMEs.SubDetChargeMedianApvShotsTH1->setAxisTitle("Apv Shots Charge Median (ADC)",1);
01031 }
01032
01033
01034 if (subdetswitchchargemedianapvshotson){
01035 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TH1ApvNumApvShots");
01036
01037 HistoName = "Apv_Shots_Apv_Number_" + label;
01038 subdetMEs.SubDetNApvShotsNApvTH1=dqmStore_->book1D(HistoName,HistoName,
01039 Parameters.getParameter<int32_t>("Nbins"),
01040 Parameters.getParameter<double>("xmin"),
01041 Parameters.getParameter<double>("xmax"));
01042 subdetMEs.SubDetNApvShotsNApvTH1->setAxisTitle("Apv Number",1);
01043 }
01044
01045
01046
01047
01048
01049
01050 if(subdetswitchapvshotsonprof){
01051 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TProfNShotsVsTime");
01052 HistoName = "NApv_Shots_vs_Time_" + label;
01053 subdetMEs.SubDetNApvShotsProf=dqmStore_->bookProfile(HistoName,HistoName,
01054 Parameters.getParameter<int32_t>("Nbins"),
01055 Parameters.getParameter<double>("xmin"),
01056 Parameters.getParameter<double>("xmax"),
01057 200,
01058 Parameters.getParameter<double>("ymin"),
01059 Parameters.getParameter<double>("ymax"),
01060 "" );
01061 subdetMEs.SubDetNApvShotsProf->setAxisTitle("Time (s)",1);
01062 subdetMEs.SubDetNApvShotsProf->setAxisTitle("# Apv Shots",2);
01063 if (subdetMEs.SubDetNApvShotsProf->kind() == MonitorElement::DQM_KIND_TPROFILE) subdetMEs.SubDetNApvShotsProf->getTH1()->SetBit(TH1::kCanRebin);
01064 }
01065
01066
01067
01068
01069
01070
01071
01072 SubDetMEsMap[label]=subdetMEs;
01073 }
01074
01075
01076
01077 int SiStripMonitorDigi::getDigiSourceIndex(uint32_t id) {
01078 int location = -1;
01079 for (unsigned int ival = 0; ival < digi_detset_handles.size(); ++ival){
01080 edm::DetSetVector<SiStripDigi>::const_iterator isearch = digi_detset_handles[ival]->find(id);
01081 if(isearch != digi_detset_handles[ival]->end()) {
01082 location = ival;
01083 break;
01084 }
01085 }
01086 return location;
01087 }
01088
01089 void SiStripMonitorDigi::AddApvShotsToSubDet(const std::vector<APVShot> & moduleShots, std::vector<APVShot> & subdetShots){
01090
01091 for (uint i=0; i<moduleShots.size(); i++){
01092 subdetShots.push_back(moduleShots[i]);
01093 }
01094 }
01095
01096 void SiStripMonitorDigi::FillApvShotsMap(TkHistoMap* the_map, const std::vector<APVShot> & shots, uint32_t id ,int mode){
01097
01098 for (uint i=0; i<shots.size(); i++){
01099 if (mode==1) the_map->fill(id,shots[i].nStrips());
01100 if (mode==2) the_map->fill(id,shots[i].median());
01101 }
01102 }
01103
01104
01105
01106 DEFINE_FWK_MODULE(SiStripMonitorDigi);