CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripApvGainsDQM.cc
Go to the documentation of this file.
2 
3 
5 #include "TCanvas.h"
6 
7 // -----
9  edm::ParameterSet const& hPSet,
10  edm::ParameterSet const& fPSet):SiStripBaseCondObjDQM(eSetup,hPSet, fPSet){
11 
12  // Build the Histo_TkMap:
13  if(HistoMaps_On_ ) Tk_HM_ = new TkHistoMap("SiStrip/Histo_Map","MeanApvGain_TkMap",0.);
14 
15 }
16 // -----
17 
18 // -----
20 // -----
21 
22 
23 // -----
25 
26  getConditionObject(eSetup);
27  gainHandle_->getDetIds(activeDetIds);
28 
29 }
30 // -----
31 
32 
33 
34 
35 // -----
36 void SiStripApvGainsDQM::fillModMEs(const std::vector<uint32_t> & selectedDetIds){
37 
38  ModMEs CondObj_ME;
39 
40  for(std::vector<uint32_t>::const_iterator detIter_ =selectedDetIds.begin();
41  detIter_!=selectedDetIds.end();++detIter_){
42  fillMEsForDet(CondObj_ME,*detIter_);
43  }
44 }
45 
46 
47 // -----
48 void SiStripApvGainsDQM::fillMEsForDet(ModMEs selModME_, uint32_t selDetId_){
49 
50  std::vector<uint32_t> DetIds;
51  gainHandle_->getDetIds(DetIds);
52 
53  SiStripApvGain::Range gainRange = gainHandle_->getRange(selDetId_);
54 
55  int nApv = reader->getNumberOfApvsAndStripLength(selDetId_).first;
56 
57  getModMEs(selModME_,selDetId_);
58 
59  for( int iapv=0;iapv<nApv;++iapv){
60  if( CondObj_fillId_ =="onlyProfile" || CondObj_fillId_ =="ProfileAndCumul"){
61  selModME_.ProfileDistr->Fill(iapv+1,gainHandle_->getApvGain(iapv,gainRange));
62  }
63  if( CondObj_fillId_ =="onlyCumul" || CondObj_fillId_ =="ProfileAndCumul"){
64  selModME_.CumulDistr ->Fill(gainHandle_->getApvGain(iapv,gainRange));
65  }
66 
67  // Fill the TkMap
68  if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")){
69  fillTkMap(selDetId_, gainHandle_->getApvGain(iapv,gainRange));
70  }
71 
72  }
73 }
74 
75 // -----
76 void SiStripApvGainsDQM::fillSummaryMEs(const std::vector<uint32_t> & selectedDetIds){
77 
78  for(std::vector<uint32_t>::const_iterator detIter_ = selectedDetIds.begin();
79  detIter_!= selectedDetIds.end();detIter_++){
80  fillMEsForLayer(/*SummaryMEsMap_,*/ *detIter_);
81  }
82 
83  for (std::map<uint32_t, ModMEs>::iterator iter=SummaryMEsMap_.begin(); iter!=SummaryMEsMap_.end(); iter++){
84 
85  ModMEs selME;
86  selME = iter->second;
87 
88  if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel") && fPSet_.getParameter<bool>("OutputSummaryProfileAtLayerLevelAsImage")){
89 
90  TCanvas c1("c1");
91  selME.SummaryOfProfileDistr->getTProfile()->Draw();
92  std::string name (selME.SummaryOfProfileDistr->getTProfile()->GetTitle());
93  name+=".png";
94  c1.Print(name.c_str());
95  }
96  if(hPSet_.getParameter<bool>("FillSummaryAtLayerLevel") && fPSet_.getParameter<bool>("OutputSummaryAtLayerLevelAsImage")){
97 
98  TCanvas c1("c1");
99  selME.SummaryDistr->getTH1()->Draw();
100  std::string name (selME.SummaryDistr->getTH1()->GetTitle());
101  name+=".png";
102  c1.Print(name.c_str());
103  }
104  }
105 
106 }
107 
108 // -----
109 void SiStripApvGainsDQM::fillMEsForLayer( /*std::map<uint32_t, ModMEs> selMEsMap_, */uint32_t selDetId_){
110 
111  int subdetectorId_ = ((selDetId_>>25)&0x7);
112 
113  if( subdetectorId_<3 ||subdetectorId_>6 ){
114  edm::LogError("SiStripApvGainsDQM")
115  << "[SiStripApvGainsDQM::fillMEsForLayer] WRONG INPUT : no such subdetector type : "
116  << subdetectorId_ << " no folder set!"
117  << std::endl;
118  return;
119  }
120  // ----
121 
122  std::map<uint32_t, ModMEs>::iterator selMEsMapIter_ = SummaryMEsMap_.find(getLayerNameAndId(selDetId_).second);
123  ModMEs selME_;
124  if ( selMEsMapIter_ != SummaryMEsMap_.end())
125  selME_ =selMEsMapIter_->second;
126  getSummaryMEs(selME_,selDetId_);
127 
128  SiStripApvGain::Range gainRange = gainHandle_->getRange(selDetId_);
129  int nApv = reader->getNumberOfApvsAndStripLength(selDetId_).first;
130 
131  float meanApvGain=0;
132 
134 
135  if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")){
136 
137  // --> profile summary
138  std::string hSummaryOfProfile_description;
139  hSummaryOfProfile_description = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
140 
141  std::string hSummaryOfProfile_name;
142  hSummaryOfProfile_name = hidmanager.createHistoLayer(hSummaryOfProfile_description,
143  "layer",
144  getLayerNameAndId(selDetId_).first, "") ;
145 
146  for( int iapv=0;iapv<nApv;++iapv){
147 
148  meanApvGain = meanApvGain +gainHandle_ ->getApvGain(iapv,gainRange);
149  selME_.SummaryOfProfileDistr->Fill(iapv+1,gainHandle_->getApvGain(iapv,gainRange));
150 
151  // Fill the TkMap
152  if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")){
153  fillTkMap(selDetId_, gainHandle_->getApvGain(iapv,gainRange));
154  }
155 
156  }// iapv
157 
158  meanApvGain = meanApvGain/nApv;
159 
160  // Fill the TkHistoMap with meanApvgain:
161  if(HistoMaps_On_ ) Tk_HM_->setBinContent(selDetId_, meanApvGain);
162 
163  }//if Fill ...
164 
165 
166  if(hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")){
167 
168  // --> summary
169  std::string hSummary_description;
170  hSummary_description = hPSet_.getParameter<std::string>("Summary_description");
171 
172  std::string hSummary_name;
173  hSummary_name = hidmanager.createHistoLayer(hSummary_description,
174  "layer",
175  getLayerNameAndId(selDetId_).first,
176  "") ;
177 
178 
179  // get detIds belonging to same layer to fill X-axis with detId-number
180 
181  std::vector<uint32_t> sameLayerDetIds_;
182 
183  sameLayerDetIds_.clear();
184 
185  sameLayerDetIds_=GetSameLayerDetId(activeDetIds,selDetId_);
186 
187  unsigned int iBin=0;
188  for(unsigned int i=0;i<sameLayerDetIds_.size();i++){
189  if(sameLayerDetIds_[i]==selDetId_){iBin=i+1;}
190  }
191 
192  for( int iapv=0;iapv<nApv;++iapv){
193  meanApvGain = meanApvGain +gainHandle_ ->getApvGain(iapv,gainRange);
194  selME_.SummaryDistr->Fill(iBin,gainHandle_->getApvGain(iapv,gainRange));
195  }//iapv
196  meanApvGain = meanApvGain/nApv;
197 
198  // Fill the TkHistoMap with meanApvgain:
199  // if(HistoMaps_On_ ) Tk_HM_->setBinContent(selDetId_, meanApvGain);
200 
201  }//if Fill ...
202 }
203 // -----
204 
205 
206 
207 
208 
209 
void getModMEs(ModMEs &CondObj_ME, const uint32_t &detId_)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
ADDITON OF TK_HISTO_MAP.
SiStripApvGainsDQM(const edm::EventSetup &eSetup, edm::ParameterSet const &hPSet, edm::ParameterSet const &fPSet)
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
std::vector< uint32_t > GetSameLayerDetId(std::vector< uint32_t > activeDetIds, uint32_t selDetId)
void fillModMEs(const std::vector< uint32_t > &selectedDetIds)
void getActiveDetIds(const edm::EventSetup &eSetup)
void fillTkMap(const uint32_t &detid, const float &value)
void Fill(long long x)
U second(std::pair< T, U > const &p)
std::map< uint32_t, ModMEs > SummaryMEsMap_
void fillSummaryMEs(const std::vector< uint32_t > &selectedDetIds)
SiStripDetInfoFileReader * reader
void fillMEsForDet(ModMEs selModME_, uint32_t selDetId_)
std::pair< ContainerIterator, ContainerIterator > Range
TH1 * getTH1(void) const
void getConditionObject(const edm::EventSetup &eSetup)
edm::ESHandle< SiStripApvGain > gainHandle_
bool first
Definition: L1TdeRCT.cc:94
void setBinContent(uint32_t &detid, float value)
Definition: TkHistoMap.cc:146
void fillMEsForLayer(uint32_t selDetId_)
std::pair< std::string, uint32_t > getLayerNameAndId(const uint32_t &detId_)
TProfile * getTProfile(void) const
std::vector< uint32_t > activeDetIds
std::string createHistoLayer(std::string description, std::string id_type, std::string path, std::string flag)
void getSummaryMEs(ModMEs &CondObj_ME, const uint32_t &detId_)