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( 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( 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( 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_ = SummaryMEsMap_.find(getStringNameAndId(selDetId_).second);
00152
00153 ModMEs selME_;
00154 if ( selMEsMapIter_ != SummaryMEsMap_.end())
00155 selME_ =selMEsMapIter_->second;
00156
00157 getSummaryMEs(selME_,selDetId_ );
00158
00159
00160 sameLayerDetIds_.clear();
00161
00162 if(selSubDetId_==3){
00163 if(TIBDetId(selDetId_).isInternalString()){
00164 substructure_.getTIBDetectors(activeDetIds, sameLayerDetIds_, TIBDetId(selDetId_).layerNumber(),0,1,TIBDetId(selDetId_).stringNumber());
00165 }
00166 if(TIBDetId(selDetId_).isExternalString()){
00167 substructure_.getTIBDetectors(activeDetIds, sameLayerDetIds_, TIBDetId(selDetId_).layerNumber(),0,2,TIBDetId(selDetId_).stringNumber());
00168 }
00169 }
00170 else if(selSubDetId_==4){
00171 substructure_.getTIDDetectors(activeDetIds, sameLayerDetIds_, 0,0,0,0);
00172 }
00173 else if(selSubDetId_==5){
00174 substructure_.getTOBDetectors(activeDetIds, sameLayerDetIds_, TOBDetId(selDetId_).layerNumber(),0,TOBDetId(selDetId_).rodNumber());
00175 }
00176 else if(selSubDetId_==6){
00177 substructure_.getTECDetectors(activeDetIds, sameLayerDetIds_, 0,0,0,0,0,0);
00178 }
00179
00180
00181
00182 for(unsigned int i=0;i< sameLayerDetIds_.size(); i++){
00183 selME_.SummaryOfProfileDistr->Fill(i+1,lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
00184
00185
00186 if(HistoMaps_On_ ) Tk_HM_->fill(sameLayerDetIds_[i], lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
00187
00188 std::cout<<sameLayerDetIds_[i]<<"\t"<<lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i])<<std::endl;
00189
00190 if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")){
00191 fillTkMap(sameLayerDetIds_[i], lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
00192 }
00193
00194 }
00195
00196 std::string hSummaryOfCumul_description;
00197 hSummaryOfCumul_description = hPSet_.getParameter<std::string>("SummaryOfCumul_description");
00198
00199 std::string hSummaryOfCumul_name;
00200
00201 if( subDetId_<3 || subDetId_>6 ){
00202 edm::LogError("SiStripLorentzAngleDQM")
00203 << "[SiStripLorentzAngleDQM::fillMEsForLayer] WRONG INPUT : no such subdetector type : "
00204 << subDetId_ << " no folder set!"
00205 << std::endl;
00206 return;
00207 }
00208
00209 hSummaryOfCumul_name = hidmanager.createHistoLayer(hSummaryOfCumul_description, "layer", getStringNameAndId(selDetId_).first, "") ;
00210
00211 for(unsigned int i=0;i< sameLayerDetIds_.size(); i++){
00212 selME_.SummaryOfCumulDistr->Fill(lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
00213 }
00214 }
00215
00216
00217 else {
00218
00219 std::map<uint32_t, ModMEs>::iterator selMEsMapIter_ = SummaryMEsMap_.find(getLayerNameAndId(selDetId_).second);
00220
00221 ModMEs selME_;
00222 if ( selMEsMapIter_ != SummaryMEsMap_.end())
00223 selME_ =selMEsMapIter_->second;
00224
00225 getSummaryMEs(selME_,selDetId_ );
00226
00227 if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")){
00228
00229 hSummary_name = hidmanager.createHistoLayer(hSummaryOfProfile_description, "layer", getLayerNameAndId(selDetId_).first, "") ;
00230
00231
00232 sameLayerDetIds_.clear();
00233
00234 sameLayerDetIds_=GetSameLayerDetId(activeDetIds,selDetId_);
00235
00236 for(unsigned int i=0;i< sameLayerDetIds_.size(); i++){
00237 selME_.SummaryOfProfileDistr->Fill(i+1,lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
00238
00239
00240 if(HistoMaps_On_ ) Tk_HM_->fill(sameLayerDetIds_[i], lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
00241
00242 if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")){
00243 fillTkMap(sameLayerDetIds_[i], lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
00244
00245 }
00246
00247 }
00248 }
00249
00250 if(hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel")){
00251
00252 std::string hSummaryOfCumul_description;
00253 hSummaryOfCumul_description = hPSet_.getParameter<std::string>("SummaryOfCumul_description");
00254
00255 std::string hSummaryOfCumul_name;
00256
00257 if( subDetId_<3 || subDetId_>6 ){
00258 edm::LogError("SiStripLorentzAngleDQM")
00259 << "[SiStripLorentzAngleDQM::fillMEsForLayer] WRONG INPUT : no such subdetector type : "
00260 << subDetId_ << " no folder set!"
00261 << std::endl;
00262 return;
00263 }
00264
00265 hSummaryOfCumul_name = hidmanager.createHistoLayer(hSummaryOfCumul_description, "layer", getLayerNameAndId(selDetId_).first, "") ;
00266
00267 for(unsigned int i=0;i< sameLayerDetIds_.size(); i++){
00268 selME_.SummaryOfCumulDistr->Fill(lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
00269 }
00270 }
00271 }
00272
00273 }
00274
00275