Go to the documentation of this file.00001 #include "DQM/SiStripMonitorSummary/interface/SiStripApvGainsDQM.h"
00002
00003
00004 #include "DQMServices/Core/interface/MonitorElement.h"
00005 #include "TCanvas.h"
00006
00007
00008 SiStripApvGainsDQM::SiStripApvGainsDQM(const edm::EventSetup & eSetup,
00009 edm::ParameterSet const& hPSet,
00010 edm::ParameterSet const& fPSet):SiStripBaseCondObjDQM(eSetup,hPSet, fPSet){
00011
00012
00013 if(HistoMaps_On_ ) Tk_HM_ = new TkHistoMap("SiStrip/Histo_Map","MeanApvGain_TkMap",0.);
00014
00015 }
00016
00017
00018
00019 SiStripApvGainsDQM::~SiStripApvGainsDQM(){}
00020
00021
00022
00023
00024 void SiStripApvGainsDQM::getActiveDetIds(const edm::EventSetup & eSetup){
00025
00026 getConditionObject(eSetup);
00027 gainHandle_->getDetIds(activeDetIds);
00028
00029 }
00030
00031
00032
00033
00034
00035
00036 void SiStripApvGainsDQM::fillModMEs(const std::vector<uint32_t> & selectedDetIds){
00037
00038 ModMEs CondObj_ME;
00039
00040 for(std::vector<uint32_t>::const_iterator detIter_ =selectedDetIds.begin();
00041 detIter_!=selectedDetIds.end();++detIter_){
00042 fillMEsForDet(CondObj_ME,*detIter_);
00043 }
00044 }
00045
00046
00047
00048 void SiStripApvGainsDQM::fillMEsForDet(ModMEs selModME_, uint32_t selDetId_){
00049
00050 std::vector<uint32_t> DetIds;
00051 gainHandle_->getDetIds(DetIds);
00052
00053 SiStripApvGain::Range gainRange = gainHandle_->getRange(selDetId_);
00054
00055 int nApv = reader->getNumberOfApvsAndStripLength(selDetId_).first;
00056
00057 getModMEs(selModME_,selDetId_);
00058
00059 for( int iapv=0;iapv<nApv;++iapv){
00060 if( CondObj_fillId_ =="onlyProfile" || CondObj_fillId_ =="ProfileAndCumul"){
00061 selModME_.ProfileDistr->Fill(iapv+1,gainHandle_->getApvGain(iapv,gainRange));
00062 }
00063 if( CondObj_fillId_ =="onlyCumul" || CondObj_fillId_ =="ProfileAndCumul"){
00064 selModME_.CumulDistr ->Fill(gainHandle_->getApvGain(iapv,gainRange));
00065 }
00066
00067
00068 if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")){
00069 fillTkMap(selDetId_, gainHandle_->getApvGain(iapv,gainRange));
00070 }
00071
00072 }
00073 }
00074
00075
00076 void SiStripApvGainsDQM::fillSummaryMEs(const std::vector<uint32_t> & selectedDetIds){
00077
00078 for(std::vector<uint32_t>::const_iterator detIter_ = selectedDetIds.begin();
00079 detIter_!= selectedDetIds.end();detIter_++){
00080 fillMEsForLayer(SummaryMEsMap_, *detIter_);
00081 }
00082
00083 for (std::map<uint32_t, ModMEs>::iterator iter=SummaryMEsMap_.begin(); iter!=SummaryMEsMap_.end(); iter++){
00084
00085 ModMEs selME;
00086 selME = iter->second;
00087
00088 if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel") && fPSet_.getParameter<bool>("OutputSummaryProfileAtLayerLevelAsImage")){
00089
00090 TCanvas c1("c1");
00091 selME.SummaryOfProfileDistr->getTProfile()->Draw();
00092 std::string name (selME.SummaryOfProfileDistr->getTProfile()->GetTitle());
00093 name+=".png";
00094 c1.Print(name.c_str());
00095 }
00096 if(hPSet_.getParameter<bool>("FillSummaryAtLayerLevel") && fPSet_.getParameter<bool>("OutputSummaryAtLayerLevelAsImage")){
00097
00098 TCanvas c1("c1");
00099 selME.SummaryDistr->getTH1()->Draw();
00100 std::string name (selME.SummaryDistr->getTH1()->GetTitle());
00101 name+=".png";
00102 c1.Print(name.c_str());
00103 }
00104 }
00105
00106 }
00107
00108
00109 void SiStripApvGainsDQM::fillMEsForLayer( std::map<uint32_t, ModMEs> selMEsMap_, uint32_t selDetId_){
00110
00111 int subdetectorId_ = ((selDetId_>>25)&0x7);
00112
00113 if( subdetectorId_<3 ||subdetectorId_>6 ){
00114 edm::LogError("SiStripApvGainsDQM")
00115 << "[SiStripApvGainsDQM::fillMEsForLayer] WRONG INPUT : no such subdetector type : "
00116 << subdetectorId_ << " no folder set!"
00117 << std::endl;
00118 return;
00119 }
00120
00121
00122 std::map<uint32_t, ModMEs>::iterator selMEsMapIter_ = selMEsMap_.find(getLayerNameAndId(selDetId_).second);
00123 ModMEs selME_;
00124 selME_ =selMEsMapIter_->second;
00125 getSummaryMEs(selME_,selDetId_);
00126
00127 SiStripApvGain::Range gainRange = gainHandle_->getRange(selDetId_);
00128 int nApv = reader->getNumberOfApvsAndStripLength(selDetId_).first;
00129
00130 float meanApvGain=0;
00131
00132 SiStripHistoId hidmanager;
00133
00134 if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")){
00135
00136
00137 std::string hSummaryOfProfile_description;
00138 hSummaryOfProfile_description = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
00139
00140 std::string hSummaryOfProfile_name;
00141 hSummaryOfProfile_name = hidmanager.createHistoLayer(hSummaryOfProfile_description,
00142 "layer",
00143 getLayerNameAndId(selDetId_).first, "") ;
00144
00145 for( int iapv=0;iapv<nApv;++iapv){
00146
00147 meanApvGain = meanApvGain +gainHandle_ ->getApvGain(iapv,gainRange);
00148 selME_.SummaryOfProfileDistr->Fill(iapv+1,gainHandle_->getApvGain(iapv,gainRange));
00149
00150
00151 if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")){
00152 fillTkMap(selDetId_, gainHandle_->getApvGain(iapv,gainRange));
00153 }
00154
00155 }
00156
00157 meanApvGain = meanApvGain/nApv;
00158
00159
00160 if(HistoMaps_On_ ) Tk_HM_->setBinContent(selDetId_, meanApvGain);
00161
00162 }
00163
00164
00165 if(hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")){
00166
00167
00168 std::string hSummary_description;
00169 hSummary_description = hPSet_.getParameter<std::string>("Summary_description");
00170
00171 std::string hSummary_name;
00172 hSummary_name = hidmanager.createHistoLayer(hSummary_description,
00173 "layer",
00174 getLayerNameAndId(selDetId_).first,
00175 "") ;
00176
00177
00178
00179
00180 std::vector<uint32_t> sameLayerDetIds_;
00181
00182 sameLayerDetIds_.clear();
00183
00184 sameLayerDetIds_=GetSameLayerDetId(activeDetIds,selDetId_);
00185
00186 unsigned int iBin=0;
00187 for(unsigned int i=0;i<sameLayerDetIds_.size();i++){
00188 if(sameLayerDetIds_[i]==selDetId_){iBin=i+1;}
00189 }
00190
00191 for( int iapv=0;iapv<nApv;++iapv){
00192 meanApvGain = meanApvGain +gainHandle_ ->getApvGain(iapv,gainRange);
00193 selME_.SummaryDistr->Fill(iBin,gainHandle_->getApvGain(iapv,gainRange));
00194 }
00195 meanApvGain = meanApvGain/nApv;
00196
00197
00198
00199
00200 }
00201 }
00202
00203
00204
00205
00206
00207
00208