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/SiStripDetId/interface/SiStripSubStructure.h"
00018 #include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
00019 #include "DQM/SiStripCommon/interface/SiStripFolderOrganizer.h"
00020 #include "DQM/SiStripCommon/interface/SiStripHistoId.h"
00021 #include "DQM/SiStripMonitorDigi/interface/SiStripMonitorDigi.h"
00022 #include "DQMServices/Core/interface/DQMStore.h"
00023 #include "DQMServices/Core/interface/MonitorElement.h"
00024
00025 #include "TMath.h"
00026 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00027 #include "DataFormats/SiStripDetId/interface/TECDetId.h"
00028 #include "DataFormats/SiStripDetId/interface/TIBDetId.h"
00029 #include "DataFormats/SiStripDetId/interface/TIDDetId.h"
00030 #include "DataFormats/SiStripDetId/interface/TOBDetId.h"
00031
00032
00033
00034 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), m_cacheID_(0), folder_organizer()
00035 {
00036 firstEvent = -1;
00037 eventNb = 0;
00038
00039
00040 edm::ParameterSet ParametersNumberOfDigis = conf_.getParameter<edm::ParameterSet>("TH1NumberOfDigis");
00041 layerswitchnumdigison = ParametersNumberOfDigis.getParameter<bool>("layerswitchon");
00042 moduleswitchnumdigison = ParametersNumberOfDigis.getParameter<bool>("moduleswitchon");
00043
00044 edm::ParameterSet ParametersADCsHottestStrip = conf_.getParameter<edm::ParameterSet>("TH1ADCsHottestStrip");
00045 layerswitchadchotteston = ParametersADCsHottestStrip.getParameter<bool>("layerswitchon");
00046 moduleswitchadchotteston = ParametersADCsHottestStrip.getParameter<bool>("moduleswitchon");
00047
00048 edm::ParameterSet ParametersADCsCoolestStrip = conf_.getParameter<edm::ParameterSet>("TH1ADCsCoolestStrip");
00049 layerswitchadccooleston = ParametersADCsCoolestStrip.getParameter<bool>("layerswitchon");
00050 moduleswitchadccooleston = ParametersADCsCoolestStrip.getParameter<bool>("moduleswitchon");
00051
00052 edm::ParameterSet ParametersDigiADCs = conf_.getParameter<edm::ParameterSet>("TH1DigiADCs");
00053 layerswitchdigiadcson = ParametersDigiADCs.getParameter<bool>("layerswitchon");
00054 moduleswitchdigiadcson = ParametersDigiADCs.getParameter<bool>("moduleswitchon");
00055
00056 edm::ParameterSet ParametersStripOccupancy = conf_.getParameter<edm::ParameterSet>("TH1StripOccupancy");
00057 layerswitchstripoccupancyon = ParametersStripOccupancy.getParameter<bool>("layerswitchon");
00058 moduleswitchstripoccupancyon = ParametersStripOccupancy.getParameter<bool>("moduleswitchon");
00059
00060 edm::ParameterSet ParametersDigiProf = conf_.getParameter<edm::ParameterSet>("TProfNumberOfDigi");
00061 layerswitchnumdigisprofon = ParametersDigiProf.getParameter<bool>("layerswitchon");
00062 edm::ParameterSet ParametersDigiADC = conf_.getParameter<edm::ParameterSet>("TProfDigiADC");
00063 layerswitchdigiadcprofon = ParametersDigiProf.getParameter<bool>("layerswitchon");
00064
00065 edm::ParameterSet ParametersTotDigiProf = conf_.getParameter<edm::ParameterSet>("TProfTotalNumberOfDigis");
00066 subdetswitchtotdigiprofon = ParametersTotDigiProf.getParameter<bool>("subdetswitchon");
00067
00068 edm::ParameterSet ParametersDetsOn = conf_.getParameter<edm::ParameterSet>("detectorson");
00069 tibon = ParametersDetsOn.getParameter<bool>("tibon");
00070 tidon = ParametersDetsOn.getParameter<bool>("tidon");
00071 tobon = ParametersDetsOn.getParameter<bool>("tobon");
00072 tecon = ParametersDetsOn.getParameter<bool>("tecon");
00073
00074 createTrendMEs = conf_.getParameter<bool>("CreateTrendMEs");
00075 Mod_On_ = conf_.getParameter<bool>("Mod_On");
00076
00077 }
00078
00079 SiStripMonitorDigi::~SiStripMonitorDigi() { }
00080
00081
00082 void SiStripMonitorDigi::beginRun(const edm::Run& run, const edm::EventSetup& es){
00083
00084 if (show_mechanical_structure_view) {
00085 unsigned long long cacheID = es.get<SiStripDetCablingRcd>().cacheIdentifier();
00086 if (m_cacheID_ != cacheID) {
00087 m_cacheID_ = cacheID;
00088 edm::LogInfo("SiStripMonitorDigi") <<"SiStripMonitorDigi::beginRun: "
00089 << " Creating MEs for new Cabling ";
00090 createMEs(es);
00091 }
00092 } else if (reset_each_run) {
00093 edm::LogInfo("SiStripMonitorDigi") <<"SiStripMonitorDigi::beginRun: "
00094 << " Resetting MEs ";
00095 for (std::map<uint32_t, ModMEs >::const_iterator idet = DigiMEs.begin() ; idet!=DigiMEs.end() ; idet++) {
00096 ResetModuleMEs(idet->first);
00097 }
00098 }
00099 }
00100
00101
00102 void SiStripMonitorDigi::endRun(const edm::Run&, const edm::EventSetup&){
00103 }
00104
00105
00106
00107
00108 void SiStripMonitorDigi::beginJob(const edm::EventSetup& es){
00109 }
00110
00111
00112
00113 void SiStripMonitorDigi::createMEs(const edm::EventSetup& es){
00114
00115 if ( show_mechanical_structure_view ){
00116
00117 edm::ESHandle<SiStripDetCabling> tkmechstruct;
00118 es.get<SiStripDetCablingRcd>().get(tkmechstruct);
00119
00120
00121 std::vector<uint32_t> activeDets;
00122 activeDets.clear();
00123 tkmechstruct->addActiveDetectorsRawIds(activeDets);
00124 SiStripSubStructure substructure;
00125
00126 std::vector<uint32_t> SelectedDetIds;
00127 if(select_all_detectors){
00128
00129 SelectedDetIds = activeDets;
00130 }else{
00131
00132
00133
00134 if(tibon) substructure.getTIBDetectors(activeDets, SelectedDetIds, 0, 0, 0, 0);
00135 if(tobon) substructure.getTOBDetectors(activeDets, SelectedDetIds, 0, 0, 0);
00136 if(tidon) substructure.getTIDDetectors(activeDets, SelectedDetIds, 0, 0, 0, 0);
00137 if(tecon) substructure.getTECDetectors(activeDets, SelectedDetIds, 0, 0, 0, 0, 0, 0);
00138
00139 }
00140
00141
00142 for(std::vector<uint32_t>::iterator idets = SelectedDetIds.begin(); idets != SelectedDetIds.end(); idets++){
00143 if(*idets == 0) SelectedDetIds.erase(idets);
00144 }
00145
00146
00147 SiStripFolderOrganizer folder_organizer;
00148
00149 std::vector<uint32_t> tibDetIds;
00150
00151 edm::LogInfo("SiStripTkDQM|SiStripMonitorDigi")<<"nr. of SelectedDetIds: "<<SelectedDetIds.size();
00152 for(std::vector<uint32_t>::const_iterator detid_iterator = SelectedDetIds.begin(); detid_iterator!=SelectedDetIds.end(); detid_iterator++){
00153
00154 uint32_t detid = (*detid_iterator);
00155
00156 ModMEs local_modmes;
00157 local_modmes.nStrip = tkmechstruct->nApvPairs(detid) * 2 * 128;
00158
00159 if (Mod_On_) {
00160
00161 folder_organizer.setDetectorFolder(detid);
00162 if (reset_each_run) ResetModuleMEs(detid);
00163 createModuleMEs(local_modmes, detid);
00164 }
00165
00166 DigiMEs.insert( std::make_pair(detid, local_modmes));
00167
00168
00169 std::pair<std::string,int32_t> det_layer_pair = folder_organizer.GetSubDetAndLayer(detid);
00170 if (DetectedLayers.find(det_layer_pair) == DetectedLayers.end()){
00171 DetectedLayers[det_layer_pair]=true;
00172
00173 int32_t lnumber = det_layer_pair.second;
00174 std::vector<uint32_t> layerDetIds;
00175 if (det_layer_pair.first == "TIB") {
00176 substructure.getTIBDetectors(SelectedDetIds,layerDetIds,lnumber,0,0,0);
00177 if (subdetswitchtotdigiprofon && SubDetMEsMap.find("TIB") == SubDetMEsMap.end()) createSubDetMEs("TIB");
00178 } else if (det_layer_pair.first == "TOB") {
00179 substructure.getTOBDetectors(SelectedDetIds,layerDetIds,lnumber,0,0);
00180 if (subdetswitchtotdigiprofon && SubDetMEsMap.find("TOB") == SubDetMEsMap.end()) createSubDetMEs("TOB");
00181 } else if (det_layer_pair.first == "TID" && lnumber > 0) {
00182 substructure.getTIDDetectors(SelectedDetIds,layerDetIds,2,abs(lnumber),0,0);
00183 if (subdetswitchtotdigiprofon && SubDetMEsMap.find("TID") == SubDetMEsMap.end()) createSubDetMEs("TID");
00184 } else if (det_layer_pair.first == "TID" && lnumber < 0) {
00185 substructure.getTIDDetectors(SelectedDetIds,layerDetIds,1,abs(lnumber),0,0);
00186 if (subdetswitchtotdigiprofon && SubDetMEsMap.find("TID") == SubDetMEsMap.end()) createSubDetMEs("TID");
00187 } else if (det_layer_pair.first == "TEC" && lnumber > 0) {
00188 substructure.getTECDetectors(SelectedDetIds,layerDetIds,2,abs(lnumber),0,0,0,0);
00189 if (subdetswitchtotdigiprofon && SubDetMEsMap.find("TEC") == SubDetMEsMap.end()) createSubDetMEs("TEC");
00190 } else if (det_layer_pair.first == "TEC" && lnumber < 0) {
00191 substructure.getTECDetectors(SelectedDetIds,layerDetIds,1,abs(lnumber),0,0,0,0);
00192 if (subdetswitchtotdigiprofon && SubDetMEsMap.find("TEC") == SubDetMEsMap.end()) createSubDetMEs("TEC");
00193 }
00194
00195 int subdetid;
00196 int subsubdetid;
00197 std::string label;
00198 getLayerLabel(detid, label, subdetid, subsubdetid);
00199 LayerDetMap[label] = layerDetIds;
00200
00201
00202 folder_organizer.setLayerFolder(detid,det_layer_pair.second);
00203
00204 createLayerMEs(label, layerDetIds.size());
00205 }
00206
00207 }
00208
00209 }
00210
00211 }
00212
00213
00214
00215
00216 void SiStripMonitorDigi::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup){
00217
00218
00219 using namespace edm;
00220
00221 runNb = iEvent.id().run();
00222
00223 eventNb++;
00224 float iOrbit = iEvent.orbitNumber()/11223.0;
00225
00226
00227
00228 typedef std::vector<edm::ParameterSet> Parameters;
00229 Parameters DigiProducersList = conf_.getParameter<Parameters>("DigiProducersList");
00230 Parameters::iterator itDigiProducersList = DigiProducersList.begin();
00231 int icoll = 0;
00232 for(; itDigiProducersList != DigiProducersList.end(); ++itDigiProducersList ) {
00233 std::string digiProducer = itDigiProducersList->getParameter<std::string>("DigiProducer");
00234 std::string digiLabel = itDigiProducersList->getParameter<std::string>("DigiLabel");
00235 iEvent.getByLabel(digiProducer,digiLabel,digi_detsetvektor[icoll]);
00236 icoll++;
00237 }
00238 int nTotDigiTIB = 0;
00239 int nTotDigiTOB = 0;
00240 int nTotDigiTEC = 0;
00241 int nTotDigiTID = 0;
00242
00243 for (std::map<std::string, std::vector< uint32_t > >::const_iterator iterLayer = LayerDetMap.begin();
00244 iterLayer != LayerDetMap.end(); iterLayer++) {
00245
00246 std::string layer_label = iterLayer->first;
00247 std::vector< uint32_t > layer_dets = iterLayer->second;
00248 std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(layer_label);
00249
00250
00251 LayerMEs local_layermes;
00252 if(iLayerME == LayerMEsMap.end()) continue;
00253 else local_layermes = iLayerME->second;
00254 int largest_adc_layer= 0;
00255 int smallest_adc_layer= 99999;
00256 int ndigi_layer = 0;
00257
00258 uint16_t iDet = 0;
00259
00260 for (std::vector< uint32_t >::const_iterator iterDets = layer_dets.begin() ;
00261 iterDets != layer_dets.end() ; iterDets++) {
00262 iDet++;
00263
00264 uint32_t detid = (*iterDets);
00265
00266
00267 std::map<uint32_t, ModMEs >::iterator pos = DigiMEs.find(detid);
00268 ModMEs local_modmes = pos->second;
00269
00270
00271 edm::DetSet<SiStripDigi> digi_detset;
00272 int ndigi_det = getDigiSource(detid, digi_detset);
00273
00274 if(Mod_On_ && moduleswitchnumdigison && (local_modmes.NumberOfDigis != NULL))
00275 (local_modmes.NumberOfDigis)->Fill(ndigi_det);
00276
00277 if (layerswitchnumdigisprofon)
00278 local_layermes.LayerNumberOfDigisProfile->Fill(iDet*1.0,ndigi_det);
00279
00280 if (ndigi_det == 0) continue;
00281
00282 ndigi_layer += ndigi_det;
00283
00284 int largest_adc=(digi_detset.data.begin())->adc();
00285 int smallest_adc=(digi_detset.data.begin())->adc();
00286
00287 int subdetid;
00288 int subsubdetid;
00289 std::string label;
00290 getLayerLabel(detid, label, subdetid, subsubdetid);
00291 float det_occupancy = 0.0;
00292
00293 for(edm::DetSet<SiStripDigi>::const_iterator digiIter = digi_detset.data.begin();
00294 digiIter!= digi_detset.data.end(); digiIter++ ){
00295
00296 int this_adc = digiIter->adc();
00297 if (this_adc > 0.0) det_occupancy++;
00298
00299 if(this_adc>largest_adc) largest_adc = this_adc;
00300 if(this_adc<smallest_adc) smallest_adc = this_adc;
00301
00302 if(Mod_On_ && moduleswitchdigiadcson && (local_modmes.DigiADCs != NULL) )
00303 (local_modmes.DigiADCs)->Fill(static_cast<float>(this_adc));
00304
00305
00306 if(layerswitchdigiadcson) {
00307 fillME(local_layermes.LayerDigiADCs , this_adc);
00308 if (createTrendMEs) fillTrend(local_layermes.LayerDigiADCsTrend, this_adc);
00309 }
00310
00311 if (layerswitchdigiadcprofon)
00312 local_layermes.LayerDigiADCProfile->Fill(iDet*1.0,this_adc);
00313
00314 }
00315
00316
00317 if (local_modmes.nStrip > 0 && det_occupancy > 0 ) {
00318 det_occupancy = det_occupancy/local_modmes.nStrip;
00319 if (Mod_On_ && moduleswitchstripoccupancyon && (local_modmes.StripOccupancy != NULL))
00320 (local_modmes.StripOccupancy)->Fill(det_occupancy);
00321 if (layerswitchstripoccupancyon) {
00322 fillME(local_layermes.LayerStripOccupancy, det_occupancy);
00323 if (createTrendMEs) fillTrend(local_layermes.LayerStripOccupancyTrend, det_occupancy);
00324 }
00325 }
00326
00327 if (largest_adc > largest_adc_layer) largest_adc_layer = largest_adc;
00328 if (smallest_adc < smallest_adc_layer) smallest_adc_layer = smallest_adc;
00329
00330
00331 if( Mod_On_ && moduleswitchadchotteston && (local_modmes.ADCsHottestStrip != NULL))
00332 (local_modmes.ADCsHottestStrip)->Fill(static_cast<float>(largest_adc));
00333
00334
00335 if(Mod_On_ && moduleswitchadccooleston && (local_modmes.ADCsCoolestStrip != NULL))
00336 (local_modmes.ADCsCoolestStrip)->Fill(static_cast<float>(smallest_adc));
00337
00338 }
00339
00340 if(layerswitchnumdigison) {
00341 fillME(local_layermes.LayerNumberOfDigis,ndigi_layer);
00342 if (createTrendMEs) fillTrend(local_layermes.LayerNumberOfDigisTrend,ndigi_layer);
00343 }
00344 if(layerswitchadchotteston) {
00345 fillME(local_layermes.LayerADCsHottestStrip,largest_adc_layer);
00346 if (createTrendMEs) fillTrend(local_layermes.LayerADCsHottestStripTrend,largest_adc_layer);
00347 }
00348 if(layerswitchadccooleston) {
00349 fillME(local_layermes.LayerADCsCoolestStrip ,smallest_adc_layer);
00350 if (createTrendMEs) fillTrend(local_layermes.LayerADCsCoolestStripTrend,smallest_adc_layer);
00351 }
00352
00353 if (layer_label.find("TIB") != std::string::npos) nTotDigiTIB += ndigi_layer;
00354 else if (layer_label.find("TOB") != std::string::npos) nTotDigiTOB += ndigi_layer;
00355 else if (layer_label.find("TEC") != std::string::npos) nTotDigiTEC += ndigi_layer;
00356 else if (layer_label.find("TID") != std::string::npos) nTotDigiTID += ndigi_layer;
00357 }
00358 if (subdetswitchtotdigiprofon) {
00359 for (std::map<std::string, MonitorElement*>::iterator it = SubDetMEsMap.begin();
00360 it != SubDetMEsMap.end(); it++) {
00361 MonitorElement* me = it->second;
00362 if (!me) continue;
00363 if (it->first == "TIB") me->Fill(iOrbit,nTotDigiTIB);
00364 else if (it->first == "TOB") me->Fill(iOrbit,nTotDigiTOB);
00365 else if (it->first == "TID") me->Fill(iOrbit,nTotDigiTID);
00366 else if (it->first == "TEC") me->Fill(iOrbit,nTotDigiTEC);
00367 }
00368 }
00369 }
00370
00371 void SiStripMonitorDigi::endJob(void){
00372 bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
00373 std::string outputFileName = conf_.getParameter<std::string>("OutputFileName");
00374
00375
00376 if(outputMEsInRootFile) dqmStore_->save(outputFileName);
00377
00378 }
00379
00380 void SiStripMonitorDigi::ResetModuleMEs(uint32_t idet){
00381 std::map<uint32_t, ModMEs >::iterator pos = DigiMEs.find(idet);
00382 ModMEs mod_me = pos->second;
00383
00384 if(Mod_On_ && moduleswitchnumdigison) mod_me.NumberOfDigis->Reset();
00385 if(Mod_On_ && moduleswitchadchotteston) mod_me.ADCsHottestStrip->Reset();
00386 if(Mod_On_ && moduleswitchadccooleston) mod_me.ADCsCoolestStrip->Reset();
00387 if(Mod_On_ && moduleswitchdigiadcson) mod_me.DigiADCs->Reset();
00388 if(Mod_On_ && moduleswitchstripoccupancyon) mod_me.StripOccupancy->Reset();
00389
00390 }
00391
00392 MonitorElement* SiStripMonitorDigi::bookMETrend(const char* ParameterSetLabel, const char* HistoName)
00393 {
00394 Parameters = conf_.getParameter<edm::ParameterSet>(ParameterSetLabel);
00395 edm::ParameterSet ParametersTrend = conf_.getParameter<edm::ParameterSet>("Trending");
00396 MonitorElement* me = dqmStore_->bookProfile(HistoName,HistoName,
00397 ParametersTrend.getParameter<int32_t>("Nbins"),
00398
00399 ParametersTrend.getParameter<double>("xmin"),
00400 ParametersTrend.getParameter<double>("xmax"),
00401
00402 100,
00403 ParametersTrend.getParameter<double>("ymin"),
00404 ParametersTrend.getParameter<double>("ymax"),
00405 "" );
00406 if(!me) return me;
00407 char buffer[256];
00408 sprintf(buffer,"EventId/%d",ParametersTrend.getParameter<int32_t>("Steps"));
00409 me->setAxisTitle(std::string(buffer),1);
00410 return me;
00411 }
00412
00413
00414 MonitorElement* SiStripMonitorDigi::bookME1D(const char* ParameterSetLabel, const char* HistoName)
00415 {
00416 Parameters = conf_.getParameter<edm::ParameterSet>(ParameterSetLabel);
00417 return dqmStore_->book1D(HistoName,HistoName,
00418 Parameters.getParameter<int32_t>("Nbinx"),
00419 Parameters.getParameter<double>("xmin"),
00420 Parameters.getParameter<double>("xmax")
00421 );
00422 }
00423
00424
00425 void SiStripMonitorDigi::fillTrend(MonitorElement* me ,float value)
00426 {
00427 if(!me) return;
00428
00429 int option = conf_.getParameter<edm::ParameterSet>("Trending").getParameter<int32_t>("UpdateMode");
00430 if(firstEvent==-1) firstEvent = eventNb;
00431 int CurrentStep = atoi(me->getAxisTitle(1).c_str()+8);
00432 int firstEventUsed = firstEvent;
00433 int presentOverflow = (int)me->getBinEntries(me->getNbinsX()+1);
00434 if(option==2) firstEventUsed += CurrentStep * int(me->getBinEntries(me->getNbinsX()+1));
00435 else if(option==3) firstEventUsed += CurrentStep * int(me->getBinEntries(me->getNbinsX()+1)) * me->getNbinsX();
00436
00437 me->Fill((eventNb-firstEventUsed)/CurrentStep,value);
00438
00439 if(eventNb-firstEvent<1) return;
00440
00441 if(presentOverflow == me->getBinEntries(me->getNbinsX()+1)) return;
00442 switch(option) {
00443 case 1:
00444 {
00445
00446 int NbinsX = me->getNbinsX();
00447 float entries = 0.;
00448 float content = 0.;
00449 float error = 0.;
00450 int bin = 1;
00451 int totEntries = int(me->getEntries());
00452 for(;bin<=NbinsX/2;++bin) {
00453 content = (me->getBinContent(2*bin-1) + me->getBinContent(2*bin))/2.;
00454 error = pow((me->getBinError(2*bin-1)*me->getBinError(2*bin-1)) + (me->getBinError(2*bin)*me->getBinError(2*bin)),0.5)/2.;
00455 entries = me->getBinEntries(2*bin-1) + me->getBinEntries(2*bin);
00456 me->setBinContent(bin,content*entries);
00457 me->setBinError(bin,error);
00458 me->setBinEntries(bin,entries);
00459 }
00460 for(;bin<=NbinsX+1;++bin) {
00461 me->setBinContent(bin,0);
00462 me->setBinError(bin,0);
00463 me->setBinEntries(bin,0);
00464 }
00465 me->setEntries(totEntries);
00466 char buffer[256];
00467 sprintf(buffer,"EventId/%d",CurrentStep*2);
00468 me->setAxisTitle(std::string(buffer),1);
00469 break;
00470 }
00471 case 2:
00472 {
00473
00474 int bin=1;
00475 int NbinsX = me->getNbinsX();
00476 for(;bin<=NbinsX;++bin) {
00477 me->setBinContent(bin,me->getBinContent(bin+1)*me->getBinEntries(bin+1));
00478 me->setBinError(bin,me->getBinError(bin+1));
00479 me->setBinEntries(bin,me->getBinEntries(bin+1));
00480 }
00481 break;
00482 }
00483 case 3:
00484 {
00485
00486 int NbinsX = me->getNbinsX();
00487 for(int bin=0;bin<=NbinsX;++bin) {
00488 me->setBinContent(bin,0);
00489 me->setBinError(bin,0);
00490 me->setBinEntries(bin,0);
00491 }
00492 break;
00493 }
00494 }
00495 }
00496
00497
00498
00499
00500 void SiStripMonitorDigi::createModuleMEs(ModMEs& mod_single, uint32_t detid) {
00501
00502
00503 SiStripHistoId hidmanager;
00504 std::string hid;
00505
00506
00507 if(moduleswitchnumdigison) {
00508 hid = hidmanager.createHistoId("NumberOfDigis","det",detid);
00509 mod_single.NumberOfDigis = dqmStore_->book1D(hid, hid, 21, -0.5, 20.5);
00510 dqmStore_->tag(mod_single.NumberOfDigis, detid);
00511 mod_single.NumberOfDigis->setAxisTitle("number of digis in one detector module");
00512 mod_single.NumberOfDigis->getTH1()->StatOverflows(kTRUE);
00513 }
00514
00515
00516 if(moduleswitchadchotteston) {
00517 hid = hidmanager.createHistoId("ADCsHottestStrip","det",detid);
00518 mod_single.ADCsHottestStrip = bookME1D("TH1ADCsHottestStrip", hid.c_str());
00519 dqmStore_->tag(mod_single.ADCsHottestStrip, detid);
00520 mod_single.ADCsHottestStrip->setAxisTitle("number of ADCs for hottest strip");
00521 }
00522
00523
00524 if(moduleswitchadccooleston) {
00525 hid = hidmanager.createHistoId("ADCsCoolestStrip","det",detid);
00526 mod_single.ADCsCoolestStrip = bookME1D("TH1ADCsCoolestStrip", hid.c_str());
00527 dqmStore_->tag(mod_single.ADCsCoolestStrip, detid);
00528 mod_single.ADCsCoolestStrip->setAxisTitle("number of ADCs for coolest strip");
00529 }
00530
00531
00532 if(moduleswitchdigiadcson) {
00533 hid = hidmanager.createHistoId("DigiADCs","det",detid);
00534 mod_single.DigiADCs = bookME1D("TH1DigiADCs", hid.c_str());
00535 dqmStore_->tag(mod_single.DigiADCs, detid);
00536 mod_single.DigiADCs->setAxisTitle("number of ADCs for each digi");
00537 }
00538
00539
00540 if(moduleswitchstripoccupancyon) {
00541 hid = hidmanager.createHistoId("StripOccupancy","det",detid);
00542 mod_single.StripOccupancy = bookME1D("TH1StripOccupancy", hid.c_str());
00543 dqmStore_->tag(mod_single.StripOccupancy, detid);
00544 mod_single.StripOccupancy->setAxisTitle("strip occupancy");
00545 }
00546
00547 }
00548
00549
00550
00551
00552
00553 void SiStripMonitorDigi::createLayerMEs(std::string label, int ndets) {
00554
00555 std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(label);
00556 if(iLayerME==LayerMEsMap.end()){
00557 SiStripHistoId hidmanager;
00558 LayerMEs layerMEs;
00559
00560
00561 if(layerswitchnumdigison) {
00562 layerMEs.LayerNumberOfDigis=bookME1D("TH1NumberOfDigis", hidmanager.createHistoLayer("Summary_TotalNumberOfDigis","layer",label,"").c_str());
00563 if (createTrendMEs) layerMEs.LayerNumberOfDigisTrend=bookMETrend("TH1NumberOfDigis", hidmanager.createHistoLayer("Trend_NumberOfDigis","layer",label,"").c_str());
00564 }
00565
00566
00567 if(layerswitchadchotteston) {
00568 layerMEs.LayerADCsHottestStrip=bookME1D("TH1ADCsHottestStrip", hidmanager.createHistoLayer("Summary_ADCsHottestStrip","layer",label,"").c_str());
00569 if (createTrendMEs) layerMEs.LayerADCsHottestStripTrend=bookMETrend("TH1ADCsHottestStrip", hidmanager.createHistoLayer("Trend_ADCsHottestStrip","layer",label,"").c_str());
00570 }
00571
00572
00573 if(layerswitchadccooleston) {
00574 layerMEs.LayerADCsCoolestStrip=bookME1D("TH1ADCsCoolestStrip", hidmanager.createHistoLayer("Summary_ADCsCoolestStrip","layer",label,"").c_str());
00575 if (createTrendMEs) layerMEs.LayerADCsCoolestStripTrend=bookMETrend("TH1ADCsCoolestStrip", hidmanager.createHistoLayer("Trend_ADCsCoolestStrip","layer",label,"").c_str());
00576 }
00577
00578
00579 if(layerswitchdigiadcson) {
00580 layerMEs.LayerDigiADCs=bookME1D("TH1DigiADCs", hidmanager.createHistoLayer("Summary_DigiADCs","layer",label,"").c_str());
00581 if (createTrendMEs) layerMEs.LayerDigiADCsTrend=bookMETrend("TH1DigiADCs", hidmanager.createHistoLayer("Trend_DigiADCs","layer",label,"").c_str());
00582 }
00583
00584
00585 if(layerswitchstripoccupancyon) {
00586 layerMEs.LayerStripOccupancy=bookME1D("TH1StripOccupancy", hidmanager.createHistoLayer("Summary_StripOccupancy","layer",label,"").c_str());
00587 if (createTrendMEs) layerMEs.LayerStripOccupancyTrend=bookMETrend("TH1StripOccupancy", hidmanager.createHistoLayer("Trend_StripOccupancy","layer",label,"").c_str());
00588
00589 }
00590
00591 if(layerswitchnumdigisprofon) {
00592 std::string hid = hidmanager.createHistoLayer("NumberOfDigiProfile","layer",label,"");
00593 layerMEs.LayerNumberOfDigisProfile = dqmStore_->bookProfile(hid, hid, ndets, 0.5, ndets+0.5,21, -0.5, 20.5);
00594 }
00595
00596
00597 if(layerswitchdigiadcprofon) {
00598 std::string hid = hidmanager.createHistoLayer("DigiADCProfile","layer",label,"");
00599 layerMEs.LayerDigiADCProfile = dqmStore_->bookProfile(hid, hid, ndets, 0.5, ndets+0.5, 64, -0.5, 255.5);
00600 }
00601
00602 LayerMEsMap[label]=layerMEs;
00603 }
00604
00605 }
00606
00607
00608
00609 void SiStripMonitorDigi::createSubDetMEs(std::string label) {
00610 edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TProfTotalNumberOfDigis");
00611 std::string HistoName;
00612 dqmStore_->cd("SiStrip/MechanicalView/"+label);
00613 HistoName = "TotalNumberOfDigiProfile__" + label;
00614 MonitorElement* me = dqmStore_->bookProfile(HistoName,HistoName,
00615 Parameters.getParameter<int32_t>("Nbins"),
00616 Parameters.getParameter<double>("xmin"),
00617 Parameters.getParameter<double>("xmax"),
00618 100,
00619 Parameters.getParameter<double>("ymin"),
00620 Parameters.getParameter<double>("ymax"),
00621 "" );
00622 if (!me) return;
00623 me->setAxisTitle("Event Time in Seconds",1);
00624 if (me->kind() == MonitorElement::DQM_KIND_TPROFILE) me->getTH1()->SetBit(TH1::kCanRebin);
00625 SubDetMEsMap.insert( std::make_pair(label, me));
00626 }
00627
00628 void SiStripMonitorDigi::getLayerLabel(uint32_t detid, std::string& label, int& subdetid, int& subsubdetid) {
00629 StripSubdetector subdet(detid);
00630 std::ostringstream label_str;
00631
00632
00633
00634 subsubdetid = 14;
00635
00636 if(subdet.subdetId() == StripSubdetector::TIB ){
00637
00638 TIBDetId tib1 = TIBDetId(detid);
00639 label_str << "TIB__layer__" << tib1.layer();
00640 subdetid = 3;
00641 subsubdetid = tib1.layer()-1;
00642 }else if(subdet.subdetId() == StripSubdetector::TID){
00643
00644 TIDDetId tid1 = TIDDetId(detid);
00645 label_str << "TID__side__" << tid1.side() << "__wheel__" << tid1.wheel();
00646 subdetid = 4;
00647 subsubdetid = (tid1.wheel()-1)+3*(tid1.side()-1);
00648 }else if(subdet.subdetId() == StripSubdetector::TOB){
00649
00650 TOBDetId tob1 = TOBDetId(detid);
00651 label_str << "TOB__layer__" << tob1.layer();
00652 subdetid = 5;
00653 subsubdetid = tob1.layer()-1;
00654 }else if(subdet.subdetId() == StripSubdetector::TEC) {
00655
00656 TECDetId tec1 = TECDetId(detid);
00657 label_str << "TEC__side__"<<tec1.side() << "__wheel__" << tec1.wheel();
00658 subdetid = 6;
00659 subsubdetid = (tec1.wheel()-1)+9*(tec1.side()-1);
00660 }else{
00661
00662 edm::LogError("SiStripTkDQM|WrongInput")<<"no such subdetector type :"<<subdet.subdetId()<<" no folder set!"<<std::endl;
00663 label_str << "";
00664 }
00665 label = label_str.str();
00666 }
00667
00668
00669
00670 int SiStripMonitorDigi::getDigiSource(uint32_t id, edm::DetSet<SiStripDigi>& digi_detset) {
00671 int nDigi = 0;
00672 for (unsigned int ival = 0; ival < 4; ival++) {
00673 if (!digi_detsetvektor[ival].isValid() ) continue;
00674 edm::DetSetVector<SiStripDigi>::const_iterator isearch = digi_detsetvektor[ival]->find(id);
00675 if(isearch == digi_detsetvektor[ival]->end()) nDigi = 0;
00676 else {
00677
00678
00679
00680 digi_detset = (*(digi_detsetvektor[ival]))[id];
00681 nDigi = digi_detset.size();
00682 return nDigi;
00683 }
00684 }
00685 return nDigi;
00686 }
00687
00688 DEFINE_FWK_MODULE(SiStripMonitorDigi);