CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripDQMProfileToTkMapConverter.cc
Go to the documentation of this file.
5 
6 
8  conf_(iConfig),
9  filename(iConfig.getUntrackedParameter<std::string>("rootFilename","CondDB_TKCC_20X_v3_hlt_50822.root")),
10  dirpath(iConfig.getUntrackedParameter<std::string>("rootDirPath","")),
11  TkMapFileName_(iConfig.getUntrackedParameter<std::string>("TkMapFileName",""))
12 {
13  edm::LogInfo("SiStripDQMProfileToTkMapConverter") << " ctor ";
15 
16  edm::LogInfo("SiStripDQMProfileToTkMapConverter") << " before opening file " << filename.c_str();
18  dqmStore_->setVerbose(iConfig.getUntrackedParameter<uint32_t>("verbosity",0));
19 
20  dqmStore_->open(filename.c_str(), false,dirpath);
21  edm::LogInfo("SiStripDQMProfileToTkMapConverter") << " after opening file ";
22 }
23 
24 
26  edm::LogInfo("SiStripDQMProfileToTkMapConverter") << " dtor";
27 }
28 
30 
31  tkMap=new TrackerMap( "DigiOcc" );
32  tkhisto=new TkHistoMap("DigiOcc","DigiOcc",-1.);
33 
34  //******************************
35  //Get DetCabling to translate the DQM TProfile in TkMaps
36 
38  es.get<SiStripDetCablingRcd>().get(tkmechstruct);
39 
40  // get list of active detectors from SiStripDetCabling
41  std::vector<uint32_t> activeDets;
42  activeDets.clear(); // just in case
43  tkmechstruct->addActiveDetectorsRawIds(activeDets);
44  SiStripSubStructure substructure;
45 
46  std::vector<uint32_t> SelectedDetIds[34];
47  size_t i=0;
48 
49  //i=0-3
50  for(size_t j=1;j<5;j++)
51  substructure.getTIBDetectors(activeDets,SelectedDetIds[i++],j,0,0,0);
52 
53  //i=4-9
54  for(size_t j=1;j<7;j++)
55  substructure.getTOBDetectors(activeDets,SelectedDetIds[i++],j,0,0);
56 
57  //i=10-12
58  for(size_t j=1;j<4;j++)
59  substructure.getTIDDetectors(activeDets,SelectedDetIds[i++],1,j,0,0);
60 
61  //i=13-15
62  for(size_t j=1;j<4;j++)
63  substructure.getTIDDetectors(activeDets,SelectedDetIds[i++],2,j,0,0);
64 
65  //i=16-24
66  for(size_t j=1;j<10;j++)
67  substructure.getTECDetectors(activeDets,SelectedDetIds[i++],1,j,0,0,0,0);
68 
69  //i=25-33
70  for(size_t j=1;j<10;j++)
71  substructure.getTECDetectors(activeDets,SelectedDetIds[i++],2,j,0,0,0,0);
72 
73  //******************************
74 
75 
76  //**********************
77  // Get ME from the DQM root file and search for interesting histograms
78 
79  edm::LogInfo("SiStripDQMProfileToTkMapConverter") <<" [SiStripDQMProfileToTkMapConverter] dirpath " << dirpath << std::endl;
80 
81  std::vector<MonitorElement*> MEs = dqmStore_->getAllContents(dirpath);
82 
83  edm::LogInfo("SiStripQualityHotStripIdentifierRoot") <<" [SiStripQualityHotStripIdentifierRoot::bookHistos] vector size " << MEs.size()<< std::endl;
84 
85  std::vector<MonitorElement*>::const_iterator iter=MEs.begin();
86  std::vector<MonitorElement*>::const_iterator iterEnd=MEs.end();
87 
88  std::stringstream ssFull, ssReport;
89 
90  const TProfile* histo;
91  size_t layerIdx;
92  for (; iter!=iterEnd;++iter) {
93  std::string me_name = (*iter)->getName();
94 
95  if (strstr(me_name.c_str(),"NumberOfDigiProfile__")==NULL)
96  continue;
97 
98  ssFull << me_name.c_str() << std::endl;
99  layerIdx=0;
100 
101  std::stringstream ss;
102  if(strstr(me_name.c_str(),"TIB")!=NULL){
103  ss<<strstr(me_name.c_str(), "layer__")[7];
104  ssReport << "\nTIB Layer " << ss.str() << "\n";
105  layerIdx=atoi(ss.str().c_str());
106  }else if(strstr(me_name.c_str(),"TOB")!=NULL){
107  ss<<strstr(me_name.c_str(), "layer__")[7];
108  layerIdx=atoi(ss.str().c_str())+4;
109  ssReport << "\nTOB Layer " << ss.str() << "\n";
110  }else if(strstr(me_name.c_str(),"TID")!=NULL){
111  ss<<strstr(me_name.c_str(), "wheel__")[7];
112  layerIdx=atoi(ss.str().c_str())+10;
113  if(strstr(me_name.c_str(),"side__2")!=NULL){
114  layerIdx+=3;
115  }
116  ssReport << "\nTID Disk " << ss.str() << "\n";
117  }else if(strstr(me_name.c_str(),"TEC")!=NULL){
118  ss<<strstr(me_name.c_str(), "wheel__")[7];
119  layerIdx=atoi(ss.str().c_str())+16;
120  if(strstr(me_name.c_str(),"side__2")!=NULL){
121  layerIdx+=9;
122  }
123  ssReport << "\nTEC Wheel " << ss.str() << "\n";
124  }
125 
126  std::cout << ss.str() << " " << layerIdx << " selected dets size " << SelectedDetIds[layerIdx-1].size()<< std::endl;
127 
128  if(layerIdx!=0){
129  histo= (TProfile *) (*(*iter)).getTProfile();
130  for(int ibin=1;ibin<histo->GetNbinsX();++ibin){
131  ssFull << layerIdx << " " << ibin << " " << SelectedDetIds[layerIdx-1][ibin-1] << " " << histo->GetBinContent(ibin) << std::endl;
132  tkMap->fill(SelectedDetIds[layerIdx-1][ibin-1],1/(histo->GetBinContent(ibin)+0.0000001));
133  tkhisto->fill(SelectedDetIds[layerIdx-1][ibin-1],1/(histo->GetBinContent(ibin)+0.0000001));
134 
135  if(histo->GetBinContent(ibin)==0)
136  ssReport << "\t" << layerIdx << " \t " << ibin << " \t " << SelectedDetIds[layerIdx-1][ibin-1] << std::endl;
137  }
138  }
139  }
140  LogDebug("SiStripDQMProfileToTkMapConverter") <<" [SiStripDQMProfileToTkMapConverter] fullPrint " << ssFull.str() << std::endl;
141  edm::LogInfo("SiStripDQMProfileToTkMapConverter") <<" [SiStripDQMProfileToTkMapConverter] fullPrint " << ssReport.str() << std::endl;
142 }
143 
145 
146  std::string filename=TkMapFileName_;
147  if (filename!=""){
148  edm::LogInfo("SiStripDQMProfileToTkMapConverter") <<" [SiStripDQMProfileToTkMapConverter] endJob Saving.........." << std::endl;
149  tkMap->save(false,0,0,filename.c_str());
150  filename.erase(filename.begin()+filename.find("."),filename.end());
151  tkhisto->save(filename+".root");
152  tkhisto->saveAsCanvas(filename+"_Canvas.root",conf_.getUntrackedParameter<std::string>("TkMapDrawOption","E"));
153  }
154 
155 }
156 
157 
158 
#define LogDebug(id)
SiStripDQMProfileToTkMapConverter(const edm::ParameterSet &)
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
TProfile * getTProfile(std::string name, std::string process, std::string rootfolder, DQMStore *dbe_, bool verb, bool clone)
#define NULL
Definition: scimark2.h:8
std::vector< MonitorElement * > getAllContents(const std::string &path) const
Definition: DQMStore.cc:1672
void saveAsCanvas(std::string filename, std::string options="", std::string mode="RECREATE")
Definition: TkHistoMap.cc:202
void save(std::string filename)
Definition: TkHistoMap.cc:41
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
void save(bool print_total=true, float minval=0., float maxval=0., std::string s="svgmap.svg", int width=1500, int height=800)
Definition: TrackerMap.cc:632
int j
Definition: DBlmapReader.cc:9
void beginRun(const edm::Run &, const edm::EventSetup &)
void setVerbose(unsigned level)
Definition: DQMStore.cc:393
const T & get() const
Definition: EventSetup.h:55
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 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
tuple filename
Definition: lut2db_cfg.py:20
bool open(const std::string &filename, bool overwrite=false, const std::string &path="", const std::string &prepend="", OpenRunDirs stripdirs=KeepRunDirs, bool fileMustExist=true)
Definition: DQMStore.cc:2432
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 fullPath() const
Definition: FileInPath.cc:171
void fill(int layer, int ring, int nmod, float x)
Definition: TrackerMap.cc:2549
Definition: Run.h:33