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, const edm::EventSetup& es){
43 
44  //Retrieve tracker topology from geometry
46  es.get<IdealGeometryRecord>().get(tTopoHandle);
47  const TrackerTopology* const tTopo = tTopoHandle.product();
48 
49  // -----
50  // LA on layer-level : fill at once all detIds belonging to same layer when encountering first detID in the layer
51 
52  bool fillNext = true;
53  for(unsigned int i=0;i<selectedDetIds.size();i++){
54  int subDetId_ = ((selectedDetIds[i]>>25)&0x7);
55  if( subDetId_<3 ||subDetId_>6 ){
56  edm::LogError("SiStripLorentzAngle")
57  << "[SiStripLorentzAngle::fillSummaryMEs] WRONG INPUT : no such subdetector type : "
58  << subDetId_ << " and detId " << selectedDetIds[i] << " therefore no filling!"
59  << std::endl;
60  }
61  else if (SummaryOnLayerLevel_On_) {
62  if( fillNext) { fillMEsForLayer(/*SummaryMEsMap_,*/ selectedDetIds[i],tTopo);}
63  if( getLayerNameAndId(selectedDetIds[i+1],tTopo)==getLayerNameAndId(selectedDetIds[i],tTopo)){ fillNext=false;}
64  else { fillNext=true;}
65  }
66  else if (SummaryOnStringLevel_On_) {
67  if( fillNext) { fillMEsForLayer(/*SummaryMEsMap_,*/ selectedDetIds[i],tTopo);}
68  if( getStringNameAndId(selectedDetIds[i+1],tTopo)==getStringNameAndId(selectedDetIds[i],tTopo)){ fillNext=false;}
69  else { fillNext=true;}
70  }
71  }
72 
73  for (std::map<uint32_t, ModMEs>::iterator iter=SummaryMEsMap_.begin(); iter!=SummaryMEsMap_.end(); iter++){
74 
75  ModMEs selME;
76  selME = iter->second;
77 
79 
80  if (fPSet_.getParameter<bool>("OutputSummaryProfileAtLayerLevelAsImage")){
81 
82  TCanvas c1("c1");
83  selME.SummaryOfProfileDistr->getTProfile()->Draw();
84  std::string name (selME.SummaryOfProfileDistr->getTProfile()->GetTitle());
85  name+=".png";
86  c1.Print(name.c_str());
87  }
88 
89  if (fPSet_.getParameter<bool>("OutputCumulativeSummaryAtLayerLevelAsImage")){
90 
91  TCanvas c2("c2");
92  selME.SummaryOfCumulDistr->getTH1()->Draw();
93  std::string name2 (selME.SummaryOfCumulDistr->getTH1()->GetTitle());
94  name2+=".png";
95  c2.Print(name2.c_str());
96  }
97 
98  }
99  else{
100  if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel") && fPSet_.getParameter<bool>("OutputSummaryProfileAtLayerLevelAsImage")){
101 
102  TCanvas c1("c1");
103  selME.SummaryOfProfileDistr->getTProfile()->Draw();
104  std::string name (selME.SummaryOfProfileDistr->getTProfile()->GetTitle());
105  name+=".png";
106  c1.Print(name.c_str());
107  }
108 
109  if(hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel") && fPSet_.getParameter<bool>("OutputCumulativeSummaryAtLayerLevelAsImage")){
110 
111  TCanvas c1("c1");
112  selME.SummaryOfCumulDistr->getTH1()->Draw();
113  std::string name (selME.SummaryOfCumulDistr->getTH1()->GetTitle());
114  name+=".png";
115  c1.Print(name.c_str());
116  }
117  }
118 
119  }
120 
121 }
122 // -----
123 
124 
125 
126 // -----
127 void SiStripLorentzAngleDQM::fillMEsForLayer( /*std::map<uint32_t, ModMEs> selMEsMap_,*/ uint32_t selDetId_, const TrackerTopology* tTopo){
128 
130 
131 
132  std::string hSummaryOfProfile_description;
133  hSummaryOfProfile_description = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
134 
135  std::string hSummary_name;
136 
137  int subDetId_ = ((selDetId_>>25)&0x7);
138 
139  if( subDetId_<3 || subDetId_>6 ){
140  edm::LogError("SiStripLorentzAngleDQM")
141  << "[SiStripLorentzAngleDQM::fillMEsForLayer] WRONG INPUT : no such subdetector type : "
142  << subDetId_ << " no folder set!"
143  << std::endl;
144  return;
145  }
146 
147  uint32_t selSubDetId_ = ((selDetId_>>25)&0x7);
148  SiStripSubStructure substructure_;
149 
150  std::vector<uint32_t> sameLayerDetIds_;
151  sameLayerDetIds_.clear();
152 
153  if (SummaryOnStringLevel_On_) { //FILLING FOR STRING LEVEL
154 
155  hSummary_name = hidmanager.createHistoLayer(hSummaryOfProfile_description, "layer", getStringNameAndId(selDetId_,tTopo).first, "") ;
156  std::map<uint32_t, ModMEs>::iterator selMEsMapIter_ = SummaryMEsMap_.find(getStringNameAndId(selDetId_,tTopo).second);
157 
158  ModMEs selME_;
159  if ( selMEsMapIter_ != SummaryMEsMap_.end())
160  selME_ =selMEsMapIter_->second;
161 
162  getSummaryMEs(selME_,selDetId_,tTopo);
163 
164  // -----
165  sameLayerDetIds_.clear();
166 
167  if(selSubDetId_==3){ // TIB
168  if(tTopo->tibIsInternalString(selDetId_)){
169  substructure_.getTIBDetectors(activeDetIds, sameLayerDetIds_, tTopo->tibLayer(selDetId_),0,1,tTopo->tibString(selDetId_));
170  }
171  if(tTopo->tibIsExternalString(selDetId_)){
172  substructure_.getTIBDetectors(activeDetIds, sameLayerDetIds_, tTopo->tibLayer(selDetId_),0,2,tTopo->tibString(selDetId_));
173  }
174  }
175  else if(selSubDetId_==4){ // TID
176  substructure_.getTIDDetectors(activeDetIds, sameLayerDetIds_, 0,0,0,0);
177  }
178  else if(selSubDetId_==5){ // TOB
179  substructure_.getTOBDetectors(activeDetIds, sameLayerDetIds_, tTopo->tobLayer(selDetId_),0,tTopo->tobRod(selDetId_));
180  }
181  else if(selSubDetId_==6){ // TEC
182  substructure_.getTECDetectors(activeDetIds, sameLayerDetIds_, 0,0,0,0,0,0);
183  }
184 
185  // -----
186 
187  for(unsigned int i=0;i< sameLayerDetIds_.size(); i++){
188  selME_.SummaryOfProfileDistr->Fill(i+1,lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
189 
190  // Fill the Histo_TkMap+TkMap with the LA:
191  if(HistoMaps_On_ ) Tk_HM_->fill(sameLayerDetIds_[i], lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
192 
193  std::cout<<sameLayerDetIds_[i]<<"\t"<<lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i])<<std::endl;
194 
195  if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")){
196  fillTkMap(sameLayerDetIds_[i], lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
197  }
198 
199  }
200 
201  std::string hSummaryOfCumul_description;
202  hSummaryOfCumul_description = hPSet_.getParameter<std::string>("SummaryOfCumul_description");
203 
204  std::string hSummaryOfCumul_name;
205 
206  if( subDetId_<3 || subDetId_>6 ){
207  edm::LogError("SiStripLorentzAngleDQM")
208  << "[SiStripLorentzAngleDQM::fillMEsForLayer] WRONG INPUT : no such subdetector type : "
209  << subDetId_ << " no folder set!"
210  << std::endl;
211  return;
212  }
213 
214  hSummaryOfCumul_name = hidmanager.createHistoLayer(hSummaryOfCumul_description, "layer", getStringNameAndId(selDetId_,tTopo).first, "") ;
215 
216  for(unsigned int i=0;i< sameLayerDetIds_.size(); i++){
217  selME_.SummaryOfCumulDistr->Fill(lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
218  }
219  } //FILLING FOR STRING LEVEL
220 
221 
222  else { //FILLING FOR LAYER LEVEL
223 
224  std::map<uint32_t, ModMEs>::iterator selMEsMapIter_ = SummaryMEsMap_.find(getLayerNameAndId(selDetId_,tTopo).second);
225 
226  ModMEs selME_;
227  if ( selMEsMapIter_ != SummaryMEsMap_.end())
228  selME_ =selMEsMapIter_->second;
229 
230  getSummaryMEs(selME_,selDetId_,tTopo);
231 
232  if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")){
233 
234  hSummary_name = hidmanager.createHistoLayer(hSummaryOfProfile_description, "layer", getLayerNameAndId(selDetId_,tTopo).first, "") ;
235 
236  // -----
237  sameLayerDetIds_.clear();
238 
239  sameLayerDetIds_=GetSameLayerDetId(activeDetIds,selDetId_,tTopo);
240 
241  for(unsigned int i=0;i< sameLayerDetIds_.size(); i++){
242  selME_.SummaryOfProfileDistr->Fill(i+1,lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
243 
244  // Fill the Histo_TkMap with LA:
245  if(HistoMaps_On_ ) Tk_HM_->fill(sameLayerDetIds_[i], lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
246 
247  if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")){
248  fillTkMap(sameLayerDetIds_[i], lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
249 
250  }
251 
252  }
253  }//if Fill ...
254 
255  if(hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel")){
256 
257  std::string hSummaryOfCumul_description;
258  hSummaryOfCumul_description = hPSet_.getParameter<std::string>("SummaryOfCumul_description");
259 
260  std::string hSummaryOfCumul_name;
261 
262  if( subDetId_<3 || subDetId_>6 ){
263  edm::LogError("SiStripLorentzAngleDQM")
264  << "[SiStripLorentzAngleDQM::fillMEsForLayer] WRONG INPUT : no such subdetector type : "
265  << subDetId_ << " no folder set!"
266  << std::endl;
267  return;
268  }
269 
270  hSummaryOfCumul_name = hidmanager.createHistoLayer(hSummaryOfCumul_description, "layer", getLayerNameAndId(selDetId_,tTopo).first, "") ;
271 
272  for(unsigned int i=0;i< sameLayerDetIds_.size(); i++){
273  selME_.SummaryOfCumulDistr->Fill(lorentzangleHandle_->getLorentzAngle(sameLayerDetIds_[i]));
274  }
275  }//if Fill ...
276  } //FILLING FOR LAYER LEVEL
277 
278 }
279 // -----
280 
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)
unsigned int tibLayer(const DetId &id) const
unsigned int tibString(const DetId &id) const
edm::ESHandle< SiStripLorentzAngle > lorentzangleHandle_
void getSummaryMEs(ModMEs &CondObj_ME, const uint32_t &detId_, const TrackerTopology *tTopo)
void fillMEsForLayer(uint32_t selDetId_, const TrackerTopology *tTopo)
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_
bool tibIsExternalString(const DetId &id) const
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
std::vector< uint32_t > GetSameLayerDetId(const std::vector< uint32_t > &activeDetIds, uint32_t selDetId, const TrackerTopology *tTopo)
TH1 * getTH1(void) const
std::pair< std::string, uint32_t > getStringNameAndId(const uint32_t &detId_, const TrackerTopology *tTopo)
bool first
Definition: L1TdeRCT.cc:94
void getActiveDetIds(const edm::EventSetup &eSetup)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
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
std::pair< std::string, uint32_t > getLayerNameAndId(const uint32_t &detId_, const TrackerTopology *tTopo)
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
void fillSummaryMEs(const std::vector< uint32_t > &selectedDetIds, const edm::EventSetup &es)
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)
unsigned int tobRod(const DetId &id) const
bool tibIsInternalString(const DetId &id) const
void getConditionObject(const edm::EventSetup &eSetup)
unsigned int tobLayer(const DetId &id) const