CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripLorentzAngleDQM.cc
Go to the documentation of this file.
3 #include "TCanvas.h"
4 
5 // -----
7  edm::ParameterSet const& hPSet,
8  edm::ParameterSet const& fPSet):SiStripBaseCondObjDQM(eSetup, hPSet, fPSet){
9 
10  // Build the Histo_TkMap:
11  if(HistoMaps_On_ ) Tk_HM_ = new TkHistoMap("SiStrip/Histo_Map","LA_TkMap",0.);
12 
13 }
14 // -----
15 
16 
17 
18 // -----
20 // -----
21 
22 
23 // -----
25 
26  getConditionObject(eSetup);
27 
28  std::map<uint32_t,float>::const_iterator LAMapIter_;
29  std::map<uint32_t,float> LAMap_ = lorentzangleHandle_->getLorentzAngles();
30 
31  for( LAMapIter_ = LAMap_.begin();
32  LAMapIter_!= LAMap_.end(); LAMapIter_++){
33 
34  activeDetIds.push_back((*LAMapIter_).first);
35  }
36 
37 }
38 // -----
39 
40 
41 // -----
42 void SiStripLorentzAngleDQM::fillSummaryMEs(const std::vector<uint32_t> & selectedDetIds){
43 
44  // -----
45  // LA on layer-level : fill at once all detIds belonging to same layer when encountering first detID in the layer
46 
47  bool fillNext = true;
48  for(unsigned int i=0;i<selectedDetIds.size();i++){
49  int subDetId_ = ((selectedDetIds[i]>>25)&0x7);
50  if( subDetId_<3 ||subDetId_>6 ){
51  edm::LogError("SiStripLorentzAngle")
52  << "[SiStripLorentzAngle::fillSummaryMEs] WRONG INPUT : no such subdetector type : "
53  << subDetId_ << " and detId " << selectedDetIds[i] << " therefore no filling!"
54  << std::endl;
55  }
56  else if (SummaryOnLayerLevel_On_) {
57  if( fillNext) { fillMEsForLayer(/*SummaryMEsMap_,*/ selectedDetIds[i]);}
58  if( getLayerNameAndId(selectedDetIds[i+1])==getLayerNameAndId(selectedDetIds[i])){ fillNext=false;}
59  else { fillNext=true;}
60  }
61  else if (SummaryOnStringLevel_On_) {
62  if( fillNext) { fillMEsForLayer(/*SummaryMEsMap_,*/ selectedDetIds[i]);}
63  if( getStringNameAndId(selectedDetIds[i+1])==getStringNameAndId(selectedDetIds[i])){ fillNext=false;}
64  else { fillNext=true;}
65  }
66  }
67 
68  for (std::map<uint32_t, ModMEs>::iterator iter=SummaryMEsMap_.begin(); iter!=SummaryMEsMap_.end(); iter++){
69 
70  ModMEs selME;
71  selME = iter->second;
72 
74 
75  if (fPSet_.getParameter<bool>("OutputSummaryProfileAtLayerLevelAsImage")){
76 
77  TCanvas c1("c1");
78  selME.SummaryOfProfileDistr->getTProfile()->Draw();
79  std::string name (selME.SummaryOfProfileDistr->getTProfile()->GetTitle());
80  name+=".png";
81  c1.Print(name.c_str());
82  }
83 
84  if (fPSet_.getParameter<bool>("OutputCumulativeSummaryAtLayerLevelAsImage")){
85 
86  TCanvas c2("c2");
87  selME.SummaryOfCumulDistr->getTH1()->Draw();
88  std::string name2 (selME.SummaryOfCumulDistr->getTH1()->GetTitle());
89  name2+=".png";
90  c2.Print(name2.c_str());
91  }
92 
93  }
94  else{
95  if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel") && fPSet_.getParameter<bool>("OutputSummaryProfileAtLayerLevelAsImage")){
96 
97  TCanvas c1("c1");
98  selME.SummaryOfProfileDistr->getTProfile()->Draw();
99  std::string name (selME.SummaryOfProfileDistr->getTProfile()->GetTitle());
100  name+=".png";
101  c1.Print(name.c_str());
102  }
103 
104  if(hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel") && fPSet_.getParameter<bool>("OutputCumulativeSummaryAtLayerLevelAsImage")){
105 
106  TCanvas c1("c1");
107  selME.SummaryOfCumulDistr->getTH1()->Draw();
108  std::string name (selME.SummaryOfCumulDistr->getTH1()->GetTitle());
109  name+=".png";
110  c1.Print(name.c_str());
111  }
112  }
113 
114  }
115 
116 }
117 // -----
118 
119 
120 
121 // -----
122 void SiStripLorentzAngleDQM::fillMEsForLayer( /*std::map<uint32_t, ModMEs> selMEsMap_,*/ uint32_t selDetId_){
123 
125 
126 
127  std::string hSummaryOfProfile_description;
128  hSummaryOfProfile_description = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
129 
130  std::string hSummary_name;
131 
132  int subDetId_ = ((selDetId_>>25)&0x7);
133 
134  if( subDetId_<3 || subDetId_>6 ){
135  edm::LogError("SiStripLorentzAngleDQM")
136  << "[SiStripLorentzAngleDQM::fillMEsForLayer] WRONG INPUT : no such subdetector type : "
137  << subDetId_ << " no folder set!"
138  << std::endl;
139  return;
140  }
141 
142  uint32_t selSubDetId_ = ((selDetId_>>25)&0x7);
143  SiStripSubStructure substructure_;
144 
145  std::vector<uint32_t> sameLayerDetIds_;
146  sameLayerDetIds_.clear();
147 
148  if (SummaryOnStringLevel_On_) { //FILLING FOR STRING LEVEL
149 
150  hSummary_name = hidmanager.createHistoLayer(hSummaryOfProfile_description, "layer", getStringNameAndId(selDetId_).first, "") ;
151  std::map<uint32_t, ModMEs>::iterator selMEsMapIter_ = SummaryMEsMap_.find(getStringNameAndId(selDetId_).second);
152 
153  ModMEs selME_;
154  if ( selMEsMapIter_ != SummaryMEsMap_.end())
155  selME_ =selMEsMapIter_->second;
156 
157  getSummaryMEs(selME_,selDetId_ );
158 
159  // -----
160  sameLayerDetIds_.clear();
161 
162  if(selSubDetId_==3){ // TIB
163  if(TIBDetId(selDetId_).isInternalString()){
164  substructure_.getTIBDetectors(activeDetIds, sameLayerDetIds_, TIBDetId(selDetId_).layerNumber(),0,1,TIBDetId(selDetId_).stringNumber());
165  }
166  if(TIBDetId(selDetId_).isExternalString()){
167  substructure_.getTIBDetectors(activeDetIds, sameLayerDetIds_, TIBDetId(selDetId_).layerNumber(),0,2,TIBDetId(selDetId_).stringNumber());
168  }
169  }
170  else if(selSubDetId_==4){ // TID
171  substructure_.getTIDDetectors(activeDetIds, sameLayerDetIds_, 0,0,0,0);
172  }
173  else if(selSubDetId_==5){ // TOB
174  substructure_.getTOBDetectors(activeDetIds, sameLayerDetIds_, TOBDetId(selDetId_).layerNumber(),0,TOBDetId(selDetId_).rodNumber());
175  }
176  else if(selSubDetId_==6){ // TEC
177  substructure_.getTECDetectors(activeDetIds, sameLayerDetIds_, 0,0,0,0,0,0);
178  }
179 
180  // -----
181 
182  for(unsigned int i=0;i< sameLayerDetIds_.size(); i++){
183  selME_.SummaryOfProfileDistr->Fill(i+1,lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
184 
185  // Fill the Histo_TkMap+TkMap with the LA:
186  if(HistoMaps_On_ ) Tk_HM_->fill(sameLayerDetIds_[i], lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
187 
188  std::cout<<sameLayerDetIds_[i]<<"\t"<<lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i])<<std::endl;
189 
190  if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")){
191  fillTkMap(sameLayerDetIds_[i], lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
192  }
193 
194  }
195 
196  std::string hSummaryOfCumul_description;
197  hSummaryOfCumul_description = hPSet_.getParameter<std::string>("SummaryOfCumul_description");
198 
199  std::string hSummaryOfCumul_name;
200 
201  if( subDetId_<3 || subDetId_>6 ){
202  edm::LogError("SiStripLorentzAngleDQM")
203  << "[SiStripLorentzAngleDQM::fillMEsForLayer] WRONG INPUT : no such subdetector type : "
204  << subDetId_ << " no folder set!"
205  << std::endl;
206  return;
207  }
208 
209  hSummaryOfCumul_name = hidmanager.createHistoLayer(hSummaryOfCumul_description, "layer", getStringNameAndId(selDetId_).first, "") ;
210 
211  for(unsigned int i=0;i< sameLayerDetIds_.size(); i++){
212  selME_.SummaryOfCumulDistr->Fill(lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
213  }
214  } //FILLING FOR STRING LEVEL
215 
216 
217  else { //FILLING FOR LAYER LEVEL
218 
219  std::map<uint32_t, ModMEs>::iterator selMEsMapIter_ = SummaryMEsMap_.find(getLayerNameAndId(selDetId_).second);
220 
221  ModMEs selME_;
222  if ( selMEsMapIter_ != SummaryMEsMap_.end())
223  selME_ =selMEsMapIter_->second;
224 
225  getSummaryMEs(selME_,selDetId_ );
226 
227  if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")){
228 
229  hSummary_name = hidmanager.createHistoLayer(hSummaryOfProfile_description, "layer", getLayerNameAndId(selDetId_).first, "") ;
230 
231  // -----
232  sameLayerDetIds_.clear();
233 
234  sameLayerDetIds_=GetSameLayerDetId(activeDetIds,selDetId_);
235 
236  for(unsigned int i=0;i< sameLayerDetIds_.size(); i++){
237  selME_.SummaryOfProfileDistr->Fill(i+1,lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
238 
239  // Fill the Histo_TkMap with LA:
240  if(HistoMaps_On_ ) Tk_HM_->fill(sameLayerDetIds_[i], lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
241 
242  if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")){
243  fillTkMap(sameLayerDetIds_[i], lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
244 
245  }
246 
247  }
248  }//if Fill ...
249 
250  if(hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel")){
251 
252  std::string hSummaryOfCumul_description;
253  hSummaryOfCumul_description = hPSet_.getParameter<std::string>("SummaryOfCumul_description");
254 
255  std::string hSummaryOfCumul_name;
256 
257  if( subDetId_<3 || subDetId_>6 ){
258  edm::LogError("SiStripLorentzAngleDQM")
259  << "[SiStripLorentzAngleDQM::fillMEsForLayer] WRONG INPUT : no such subdetector type : "
260  << subDetId_ << " no folder set!"
261  << std::endl;
262  return;
263  }
264 
265  hSummaryOfCumul_name = hidmanager.createHistoLayer(hSummaryOfCumul_description, "layer", getLayerNameAndId(selDetId_).first, "") ;
266 
267  for(unsigned int i=0;i< sameLayerDetIds_.size(); i++){
268  selME_.SummaryOfCumulDistr->Fill(lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
269  }
270  }//if Fill ...
271  } //FILLING FOR LAYER LEVEL
272 
273 }
274 // -----
275 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
SiStripLorentzAngleDQM(const edm::EventSetup &eSetup, edm::ParameterSet const &hPSet, edm::ParameterSet const &fPSet)
ADDITON OF TK_HISTO_MAP.
unsigned int rodNumber(align::ID)
Rod number increases with phi.
Definition: TOBNameSpace.h:41
std::vector< uint32_t > GetSameLayerDetId(std::vector< uint32_t > activeDetIds, uint32_t selDetId)
edm::ESHandle< SiStripLorentzAngle > lorentzangleHandle_
unsigned int layerNumber(align::ID)
Layer number increases with rho from 1 to 8.
Definition: TIBNameSpace.h:85
void fillSummaryMEs(const std::vector< uint32_t > &selectedDetIds)
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 getTOBDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tobDetRawIds, uint32_t layer=0, uint32_t bkw_frw=0, uint32_t rod=0) const
void fill(uint32_t &detid, float value)
Definition: TkHistoMap.cc:130
TH1 * getTH1(void) const
bool first
Definition: L1TdeRCT.cc:94
void getActiveDetIds(const edm::EventSetup &eSetup)
std::pair< std::string, uint32_t > getStringNameAndId(const uint32_t &detId_)
unsigned int stringNumber(align::ID)
Definition: TIBNameSpace.h:51
std::pair< std::string, uint32_t > getLayerNameAndId(const uint32_t &detId_)
void getTECDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tecDetRawIds, uint32_t side=0, uint32_t wheel=0, uint32_t petal_bkw_frw=0, uint32_t petal=0, uint32_t ring=0, uint32_t ster=0) const
void fillMEsForLayer(uint32_t selDetId_)
TProfile * getTProfile(void) const
void getTIBDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tibDetRawIds, uint32_t layer=0, uint32_t bkw_frw=0, uint32_t int_ext=0, uint32_t string=0) const
std::vector< uint32_t > activeDetIds
tuple cout
Definition: gather_cfg.py:121
void getTIDDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tidDetRawIds, uint32_t side=0, uint32_t wheel=0, uint32_t ring=0, uint32_t ster=0) const
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_)
void getConditionObject(const edm::EventSetup &eSetup)