00001 #include "DQM/SiStripMonitorSummary/interface/SiStripLorentzAngleDQM.h"
00002 #include "DQMServices/Core/interface/MonitorElement.h"
00003 #include "TCanvas.h"
00004
00005
00006 SiStripLorentzAngleDQM::SiStripLorentzAngleDQM(const edm::EventSetup & eSetup,
00007 edm::ParameterSet const& hPSet,
00008 edm::ParameterSet const& fPSet):SiStripBaseCondObjDQM(eSetup, hPSet, fPSet){
00009
00010
00011 if(HistoMaps_On_ ) Tk_HM_ = new TkHistoMap("SiStrip/Histo_Map","LA_TkMap",0.);
00012
00013 }
00014
00015
00016
00017
00018
00019 SiStripLorentzAngleDQM::~SiStripLorentzAngleDQM(){}
00020
00021
00022
00023
00024 void SiStripLorentzAngleDQM::getActiveDetIds(const edm::EventSetup & eSetup){
00025
00026 getConditionObject(eSetup);
00027
00028 std::map<uint32_t,float>::const_iterator LAMapIter_;
00029 std::map<uint32_t,float> LAMap_ = lorentzangleHandle_->getLorentzAngles();
00030
00031 for( LAMapIter_ = LAMap_.begin();
00032 LAMapIter_!= LAMap_.end(); LAMapIter_++){
00033
00034 activeDetIds.push_back((*LAMapIter_).first);
00035 }
00036
00037 }
00038
00039
00040
00041
00042 void SiStripLorentzAngleDQM::fillSummaryMEs(const std::vector<uint32_t> & selectedDetIds){
00043
00044
00045
00046
00047 bool fillNext = true;
00048 for(unsigned int i=0;i<selectedDetIds.size();i++){
00049 int subDetId_ = ((selectedDetIds[i]>>25)&0x7);
00050 if( subDetId_<3 ||subDetId_>6 ){
00051 edm::LogError("SiStripLorentzAngle")
00052 << "[SiStripLorentzAngle::fillSummaryMEs] WRONG INPUT : no such subdetector type : "
00053 << subDetId_ << " and detId " << selectedDetIds[i] << " therefore no filling!"
00054 << std::endl;
00055 }
00056 else if (SummaryOnLayerLevel_On_) {
00057 if( fillNext) { fillMEsForLayer(SummaryMEsMap_, selectedDetIds[i]);}
00058 if( getLayerNameAndId(selectedDetIds[i+1])==getLayerNameAndId(selectedDetIds[i])){ fillNext=false;}
00059 else { fillNext=true;}
00060 }
00061 else if (SummaryOnStringLevel_On_) {
00062 if( fillNext) { fillMEsForLayer(SummaryMEsMap_, selectedDetIds[i]);}
00063 if( getStringNameAndId(selectedDetIds[i+1])==getStringNameAndId(selectedDetIds[i])){ fillNext=false;}
00064 else { fillNext=true;}
00065 }
00066 }
00067
00068 for (std::map<uint32_t, ModMEs>::iterator iter=SummaryMEsMap_.begin(); iter!=SummaryMEsMap_.end(); iter++){
00069
00070 ModMEs selME;
00071 selME = iter->second;
00072
00073 if(SummaryOnStringLevel_On_){
00074
00075 if (fPSet_.getParameter<bool>("OutputSummaryProfileAtLayerLevelAsImage")){
00076
00077 TCanvas c1("c1");
00078 selME.SummaryOfProfileDistr->getTProfile()->Draw();
00079 std::string name (selME.SummaryOfProfileDistr->getTProfile()->GetTitle());
00080 name+=".png";
00081 c1.Print(name.c_str());
00082 }
00083
00084 if (fPSet_.getParameter<bool>("OutputCumulativeSummaryAtLayerLevelAsImage")){
00085
00086 TCanvas c2("c2");
00087 selME.SummaryOfCumulDistr->getTH1()->Draw();
00088 std::string name2 (selME.SummaryOfCumulDistr->getTH1()->GetTitle());
00089 name2+=".png";
00090 c2.Print(name2.c_str());
00091 }
00092
00093 }
00094 else{
00095 if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel") && fPSet_.getParameter<bool>("OutputSummaryProfileAtLayerLevelAsImage")){
00096
00097 TCanvas c1("c1");
00098 selME.SummaryOfProfileDistr->getTProfile()->Draw();
00099 std::string name (selME.SummaryOfProfileDistr->getTProfile()->GetTitle());
00100 name+=".png";
00101 c1.Print(name.c_str());
00102 }
00103
00104 if(hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel") && fPSet_.getParameter<bool>("OutputCumulativeSummaryAtLayerLevelAsImage")){
00105
00106 TCanvas c1("c1");
00107 selME.SummaryOfCumulDistr->getTH1()->Draw();
00108 std::string name (selME.SummaryOfCumulDistr->getTH1()->GetTitle());
00109 name+=".png";
00110 c1.Print(name.c_str());
00111 }
00112 }
00113
00114 }
00115
00116 }
00117
00118
00119
00120
00121
00122 void SiStripLorentzAngleDQM::fillMEsForLayer( std::map<uint32_t, ModMEs> selMEsMap_, uint32_t selDetId_){
00123
00124 SiStripHistoId hidmanager;
00125
00126
00127 std::string hSummaryOfProfile_description;
00128 hSummaryOfProfile_description = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
00129
00130 std::string hSummary_name;
00131
00132 int subDetId_ = ((selDetId_>>25)&0x7);
00133
00134 if( subDetId_<3 || subDetId_>6 ){
00135 edm::LogError("SiStripLorentzAngleDQM")
00136 << "[SiStripLorentzAngleDQM::fillMEsForLayer] WRONG INPUT : no such subdetector type : "
00137 << subDetId_ << " no folder set!"
00138 << std::endl;
00139 return;
00140 }
00141
00142 uint32_t selSubDetId_ = ((selDetId_>>25)&0x7);
00143 SiStripSubStructure substructure_;
00144
00145 std::vector<uint32_t> sameLayerDetIds_;
00146 sameLayerDetIds_.clear();
00147
00148 if (SummaryOnStringLevel_On_) {
00149
00150 hSummary_name = hidmanager.createHistoLayer(hSummaryOfProfile_description, "layer", getStringNameAndId(selDetId_).first, "") ;
00151 std::map<uint32_t, ModMEs>::iterator selMEsMapIter_ = selMEsMap_.find(getStringNameAndId(selDetId_).second);
00152
00153 ModMEs selME_;
00154 selME_ =selMEsMapIter_->second;
00155
00156 getSummaryMEs(selME_,selDetId_ );
00157
00158
00159 sameLayerDetIds_.clear();
00160
00161 if(selSubDetId_==3){
00162 if(TIBDetId(selDetId_).isInternalString()){
00163 substructure_.getTIBDetectors(activeDetIds, sameLayerDetIds_, TIBDetId(selDetId_).layerNumber(),0,1,TIBDetId(selDetId_).stringNumber());
00164 }
00165 if(TIBDetId(selDetId_).isExternalString()){
00166 substructure_.getTIBDetectors(activeDetIds, sameLayerDetIds_, TIBDetId(selDetId_).layerNumber(),0,2,TIBDetId(selDetId_).stringNumber());
00167 }
00168 }
00169 else if(selSubDetId_==4){
00170 substructure_.getTIDDetectors(activeDetIds, sameLayerDetIds_, 0,0,0,0);
00171 }
00172 else if(selSubDetId_==5){
00173 substructure_.getTOBDetectors(activeDetIds, sameLayerDetIds_, TOBDetId(selDetId_).layerNumber(),0,TOBDetId(selDetId_).rodNumber());
00174 }
00175 else if(selSubDetId_==6){
00176 substructure_.getTECDetectors(activeDetIds, sameLayerDetIds_, 0,0,0,0,0,0);
00177 }
00178
00179
00180
00181 for(unsigned int i=0;i< sameLayerDetIds_.size(); i++){
00182 selME_.SummaryOfProfileDistr->Fill(i+1,lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
00183
00184
00185 if(HistoMaps_On_ ) Tk_HM_->fill(sameLayerDetIds_[i], lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
00186
00187 std::cout<<sameLayerDetIds_[i]<<"\t"<<lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i])<<std::endl;
00188
00189 if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")){
00190 fillTkMap(sameLayerDetIds_[i], lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
00191 }
00192
00193 }
00194
00195 std::string hSummaryOfCumul_description;
00196 hSummaryOfCumul_description = hPSet_.getParameter<std::string>("SummaryOfCumul_description");
00197
00198 std::string hSummaryOfCumul_name;
00199
00200 if( subDetId_<3 || subDetId_>6 ){
00201 edm::LogError("SiStripLorentzAngleDQM")
00202 << "[SiStripLorentzAngleDQM::fillMEsForLayer] WRONG INPUT : no such subdetector type : "
00203 << subDetId_ << " no folder set!"
00204 << std::endl;
00205 return;
00206 }
00207
00208 hSummaryOfCumul_name = hidmanager.createHistoLayer(hSummaryOfCumul_description, "layer", getStringNameAndId(selDetId_).first, "") ;
00209
00210 for(unsigned int i=0;i< sameLayerDetIds_.size(); i++){
00211 selME_.SummaryOfCumulDistr->Fill(lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
00212 }
00213 }
00214
00215
00216 else {
00217
00218 std::map<uint32_t, ModMEs>::iterator selMEsMapIter_ = selMEsMap_.find(getLayerNameAndId(selDetId_).second);
00219
00220 ModMEs selME_;
00221 selME_ =selMEsMapIter_->second;
00222
00223 getSummaryMEs(selME_,selDetId_ );
00224
00225 if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")){
00226
00227 hSummary_name = hidmanager.createHistoLayer(hSummaryOfProfile_description, "layer", getLayerNameAndId(selDetId_).first, "") ;
00228
00229
00230 sameLayerDetIds_.clear();
00231
00232 sameLayerDetIds_=GetSameLayerDetId(activeDetIds,selDetId_);
00233
00234 for(unsigned int i=0;i< sameLayerDetIds_.size(); i++){
00235 selME_.SummaryOfProfileDistr->Fill(i+1,lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
00236
00237
00238 if(HistoMaps_On_ ) Tk_HM_->fill(sameLayerDetIds_[i], lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
00239
00240 if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")){
00241 fillTkMap(sameLayerDetIds_[i], lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
00242
00243 }
00244
00245 }
00246 }
00247
00248 if(hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel")){
00249
00250 std::string hSummaryOfCumul_description;
00251 hSummaryOfCumul_description = hPSet_.getParameter<std::string>("SummaryOfCumul_description");
00252
00253 std::string hSummaryOfCumul_name;
00254
00255 if( subDetId_<3 || subDetId_>6 ){
00256 edm::LogError("SiStripLorentzAngleDQM")
00257 << "[SiStripLorentzAngleDQM::fillMEsForLayer] WRONG INPUT : no such subdetector type : "
00258 << subDetId_ << " no folder set!"
00259 << std::endl;
00260 return;
00261 }
00262
00263 hSummaryOfCumul_name = hidmanager.createHistoLayer(hSummaryOfCumul_description, "layer", getLayerNameAndId(selDetId_).first, "") ;
00264
00265 for(unsigned int i=0;i< sameLayerDetIds_.size(); i++){
00266 selME_.SummaryOfCumulDistr->Fill(lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
00267 }
00268 }
00269 }
00270
00271 }
00272
00273