CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/DQM/SiStripMonitorSummary/src/SiStripLorentzAngleDQM.cc

Go to the documentation of this file.
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   // Build the Histo_TkMap:
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, const edm::EventSetup& es){
00043 
00044   //Retrieve tracker topology from geometry
00045   edm::ESHandle<TrackerTopology> tTopoHandle;
00046   es.get<IdealGeometryRecord>().get(tTopoHandle);
00047   const TrackerTopology* const tTopo = tTopoHandle.product();
00048 
00049   // -----
00050   // LA on layer-level : fill at once all detIds belonging to same layer when encountering first detID in the layer 
00051 
00052   bool fillNext = true; 
00053   for(unsigned int i=0;i<selectedDetIds.size();i++){                                        
00054     int subDetId_ = ((selectedDetIds[i]>>25)&0x7);
00055     if( subDetId_<3 ||subDetId_>6 ){ 
00056       edm::LogError("SiStripLorentzAngle")
00057         << "[SiStripLorentzAngle::fillSummaryMEs] WRONG INPUT : no such subdetector type : "
00058         << subDetId_ << " and detId " << selectedDetIds[i] << " therefore no filling!" 
00059         << std::endl;
00060     }    
00061     else if (SummaryOnLayerLevel_On_) {    
00062       if( fillNext) { fillMEsForLayer(/*SummaryMEsMap_,*/ selectedDetIds[i],tTopo);} 
00063       if( getLayerNameAndId(selectedDetIds[i+1],tTopo)==getLayerNameAndId(selectedDetIds[i],tTopo)){ fillNext=false;}
00064       else { fillNext=true;}
00065     } 
00066     else if (SummaryOnStringLevel_On_) {
00067       if( fillNext) { fillMEsForLayer(/*SummaryMEsMap_,*/ selectedDetIds[i],tTopo);} 
00068       if( getStringNameAndId(selectedDetIds[i+1],tTopo)==getStringNameAndId(selectedDetIds[i],tTopo)){ fillNext=false;}
00069       else { fillNext=true;}
00070     } 
00071   }
00072 
00073   for (std::map<uint32_t, ModMEs>::iterator iter=SummaryMEsMap_.begin(); iter!=SummaryMEsMap_.end(); iter++){
00074 
00075     ModMEs selME;
00076     selME = iter->second;
00077 
00078     if(SummaryOnStringLevel_On_){
00079 
00080       if (fPSet_.getParameter<bool>("OutputSummaryProfileAtLayerLevelAsImage")){
00081 
00082         TCanvas c1("c1");
00083         selME.SummaryOfProfileDistr->getTProfile()->Draw();
00084         std::string name (selME.SummaryOfProfileDistr->getTProfile()->GetTitle());
00085         name+=".png";
00086         c1.Print(name.c_str());
00087       }
00088 
00089       if (fPSet_.getParameter<bool>("OutputCumulativeSummaryAtLayerLevelAsImage")){
00090 
00091         TCanvas c2("c2");
00092         selME.SummaryOfCumulDistr->getTH1()->Draw();
00093         std::string name2 (selME.SummaryOfCumulDistr->getTH1()->GetTitle());
00094         name2+=".png";
00095         c2.Print(name2.c_str());
00096       }
00097 
00098     }
00099     else{
00100       if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel") && fPSet_.getParameter<bool>("OutputSummaryProfileAtLayerLevelAsImage")){
00101 
00102         TCanvas c1("c1");
00103         selME.SummaryOfProfileDistr->getTProfile()->Draw();
00104         std::string name (selME.SummaryOfProfileDistr->getTProfile()->GetTitle());
00105         name+=".png";
00106         c1.Print(name.c_str());
00107       }
00108 
00109       if(hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel") && fPSet_.getParameter<bool>("OutputCumulativeSummaryAtLayerLevelAsImage")){
00110 
00111         TCanvas c1("c1");
00112         selME.SummaryOfCumulDistr->getTH1()->Draw();
00113         std::string name (selME.SummaryOfCumulDistr->getTH1()->GetTitle());
00114         name+=".png";
00115         c1.Print(name.c_str());
00116       }
00117     }
00118 
00119   }
00120 
00121 }
00122 // -----
00123 
00124 
00125 
00126 // -----
00127 void SiStripLorentzAngleDQM::fillMEsForLayer( /*std::map<uint32_t, ModMEs> selMEsMap_,*/ uint32_t selDetId_, const TrackerTopology* tTopo){
00128 
00129   SiStripHistoId hidmanager;
00130 
00131       
00132   std::string hSummaryOfProfile_description;
00133   hSummaryOfProfile_description  = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
00134 
00135   std::string hSummary_name; 
00136 
00137   int subDetId_ = ((selDetId_>>25)&0x7);
00138   
00139   if( subDetId_<3 || subDetId_>6 ){ 
00140     edm::LogError("SiStripLorentzAngleDQM")
00141       << "[SiStripLorentzAngleDQM::fillMEsForLayer] WRONG INPUT : no such subdetector type : "
00142       << subDetId_ << " no folder set!" 
00143       << std::endl;
00144     return;
00145   }
00146 
00147   uint32_t selSubDetId_ =  ((selDetId_>>25)&0x7);
00148   SiStripSubStructure substructure_;
00149   
00150   std::vector<uint32_t> sameLayerDetIds_;
00151   sameLayerDetIds_.clear();
00152 
00153   if (SummaryOnStringLevel_On_) {  //FILLING FOR STRING LEVEL
00154 
00155     hSummary_name = hidmanager.createHistoLayer(hSummaryOfProfile_description, "layer", getStringNameAndId(selDetId_,tTopo).first, "") ;
00156     std::map<uint32_t, ModMEs>::iterator selMEsMapIter_ = SummaryMEsMap_.find(getStringNameAndId(selDetId_,tTopo).second);
00157     
00158     ModMEs selME_;
00159     if ( selMEsMapIter_ != SummaryMEsMap_.end())
00160       selME_ =selMEsMapIter_->second;
00161 
00162     getSummaryMEs(selME_,selDetId_,tTopo);
00163   
00164     // -----                                       
00165     sameLayerDetIds_.clear();
00166    
00167     if(selSubDetId_==3){  //  TIB
00168       if(tTopo->tibIsInternalString(selDetId_)){
00169         substructure_.getTIBDetectors(activeDetIds, sameLayerDetIds_, tTopo->tibLayer(selDetId_),0,1,tTopo->tibString(selDetId_));
00170       }
00171       if(tTopo->tibIsExternalString(selDetId_)){
00172         substructure_.getTIBDetectors(activeDetIds, sameLayerDetIds_, tTopo->tibLayer(selDetId_),0,2,tTopo->tibString(selDetId_));
00173       } 
00174     }
00175     else if(selSubDetId_==4){  // TID
00176       substructure_.getTIDDetectors(activeDetIds, sameLayerDetIds_, 0,0,0,0);
00177     }
00178     else if(selSubDetId_==5){  // TOB
00179       substructure_.getTOBDetectors(activeDetIds, sameLayerDetIds_, tTopo->tobLayer(selDetId_),0,tTopo->tobRod(selDetId_));
00180     }
00181     else if(selSubDetId_==6){  // TEC
00182       substructure_.getTECDetectors(activeDetIds, sameLayerDetIds_, 0,0,0,0,0,0);
00183     }
00184  
00185     // -----
00186 
00187     for(unsigned int i=0;i< sameLayerDetIds_.size(); i++){
00188         selME_.SummaryOfProfileDistr->Fill(i+1,lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
00189 
00190         // Fill the Histo_TkMap+TkMap with the LA:
00191         if(HistoMaps_On_ ) Tk_HM_->fill(sameLayerDetIds_[i], lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
00192 
00193           std::cout<<sameLayerDetIds_[i]<<"\t"<<lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i])<<std::endl;
00194 
00195         if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")){
00196           fillTkMap(sameLayerDetIds_[i], lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
00197         }
00198         
00199     } 
00200     
00201     std::string hSummaryOfCumul_description;
00202     hSummaryOfCumul_description  = hPSet_.getParameter<std::string>("SummaryOfCumul_description");
00203     
00204     std::string hSummaryOfCumul_name; 
00205     
00206     if( subDetId_<3 || subDetId_>6 ){ 
00207       edm::LogError("SiStripLorentzAngleDQM")
00208         << "[SiStripLorentzAngleDQM::fillMEsForLayer] WRONG INPUT : no such subdetector type : "
00209         << subDetId_ << " no folder set!" 
00210         << std::endl;
00211       return;
00212     }
00213     
00214     hSummaryOfCumul_name = hidmanager.createHistoLayer(hSummaryOfCumul_description, "layer", getStringNameAndId(selDetId_,tTopo).first, "") ;
00215     
00216     for(unsigned int i=0;i< sameLayerDetIds_.size(); i++){
00217         selME_.SummaryOfCumulDistr->Fill(lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
00218     } 
00219   } //FILLING FOR STRING LEVEL
00220   
00221   
00222   else { //FILLING FOR LAYER LEVEL
00223 
00224     std::map<uint32_t, ModMEs>::iterator selMEsMapIter_ = SummaryMEsMap_.find(getLayerNameAndId(selDetId_,tTopo).second);
00225     
00226     ModMEs selME_;
00227     if ( selMEsMapIter_ != SummaryMEsMap_.end())
00228       selME_ =selMEsMapIter_->second;
00229     
00230     getSummaryMEs(selME_,selDetId_,tTopo);
00231     
00232     if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")){
00233 
00234       hSummary_name = hidmanager.createHistoLayer(hSummaryOfProfile_description, "layer", getLayerNameAndId(selDetId_,tTopo).first, "") ;    
00235     
00236       // -----                                             
00237       sameLayerDetIds_.clear();
00238 
00239       sameLayerDetIds_=GetSameLayerDetId(activeDetIds,selDetId_,tTopo);     
00240 
00241       for(unsigned int i=0;i< sameLayerDetIds_.size(); i++){
00242           selME_.SummaryOfProfileDistr->Fill(i+1,lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
00243 
00244           // Fill the Histo_TkMap with LA:
00245           if(HistoMaps_On_ ) Tk_HM_->fill(sameLayerDetIds_[i], lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
00246 
00247         if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")){
00248           fillTkMap(sameLayerDetIds_[i], lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
00249 
00250         }
00251 
00252       } 
00253     }//if Fill ...
00254 
00255     if(hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel")){
00256 
00257       std::string hSummaryOfCumul_description;
00258       hSummaryOfCumul_description  = hPSet_.getParameter<std::string>("SummaryOfCumul_description");
00259     
00260       std::string hSummaryOfCumul_name; 
00261     
00262       if( subDetId_<3 || subDetId_>6 ){ 
00263         edm::LogError("SiStripLorentzAngleDQM")
00264           << "[SiStripLorentzAngleDQM::fillMEsForLayer] WRONG INPUT : no such subdetector type : "
00265           << subDetId_ << " no folder set!" 
00266           << std::endl;
00267         return;
00268       }
00269     
00270       hSummaryOfCumul_name = hidmanager.createHistoLayer(hSummaryOfCumul_description, "layer", getLayerNameAndId(selDetId_,tTopo).first, "") ;
00271     
00272       for(unsigned int i=0;i< sameLayerDetIds_.size(); i++){
00273           selME_.SummaryOfCumulDistr->Fill(lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
00274       }
00275     }//if Fill ... 
00276   } //FILLING FOR LAYER LEVEL
00277   
00278 }  
00279 // -----
00280