Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <iostream>
00016 #include <sstream>
00017
00018 #include "FWCore/ServiceRegistry/interface/Service.h"
00019
00020 #include "DataFormats/SiStripDetId/interface/TIBDetId.h"
00021 #include "DataFormats/SiStripDetId/interface/TIDDetId.h"
00022 #include "DataFormats/SiStripDetId/interface/TOBDetId.h"
00023 #include "DataFormats/SiStripDetId/interface/TECDetId.h"
00024
00025 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00026
00027 #include "DQMServices/Core/interface/DQMStore.h"
00028
00029 #include "DQM/SiStripCommon/interface/SiStripFolderOrganizer.h"
00030 #define CONTROL_FOLDER_NAME "ControlView"
00031 #define MECHANICAL_FOLDER_NAME "MechanicalView"
00032 #define SEP "/"
00033
00034 SiStripFolderOrganizer::SiStripFolderOrganizer()
00035 {
00036 TopFolderName="SiStrip";
00037
00038 dbe_ = edm::Service<DQMStore>().operator->();
00039 }
00040
00041
00042 SiStripFolderOrganizer::~SiStripFolderOrganizer()
00043 {
00044 }
00045
00046 void SiStripFolderOrganizer::setSiStripFolderName(std::string name){
00047 TopFolderName = name;
00048 }
00049
00050 std::string SiStripFolderOrganizer::getSiStripFolder(){
00051 return TopFolderName;
00052 }
00053
00054
00055 void SiStripFolderOrganizer::setSiStripFolder(){
00056 dbe_->setCurrentFolder(TopFolderName);
00057 return;
00058 }
00059
00060
00061 std::string SiStripFolderOrganizer::getSiStripTopControlFolder(){
00062 std::string lokal_folder = TopFolderName + CONTROL_FOLDER_NAME;
00063 return lokal_folder;
00064 }
00065
00066
00067 void SiStripFolderOrganizer::setSiStripTopControlFolder(){
00068 std::string lokal_folder = TopFolderName + CONTROL_FOLDER_NAME;
00069 dbe_->setCurrentFolder(lokal_folder);
00070 return;
00071 }
00072
00073
00074 std::string SiStripFolderOrganizer::getSiStripControlFolder(
00075
00076 unsigned short slot,
00077 unsigned short ring,
00078 unsigned short addr,
00079 unsigned short chan
00080
00081 ) {
00082 std::stringstream lokal_folder;
00083 lokal_folder << getSiStripTopControlFolder();
00084
00085
00086 if ( slot != all_ ) {
00087 lokal_folder << SEP << "FecSlot" << slot;
00088 if ( ring != all_ ) {
00089 lokal_folder << SEP << "FecRing" << ring;
00090 if ( addr != all_ ) {
00091 lokal_folder << SEP << "CcuAddr" << addr;
00092 if ( chan != all_ ) {
00093 lokal_folder << SEP << "CcuChan" << chan;
00094
00095
00096
00097 }
00098 }
00099 }
00100 }
00101
00102 std::string folder_name = lokal_folder.str();
00103 return folder_name;
00104 }
00105
00106
00107 void SiStripFolderOrganizer::setSiStripControlFolder(
00108
00109 unsigned short slot,
00110 unsigned short ring,
00111 unsigned short addr,
00112 unsigned short chan
00113
00114 ) {
00115 std::string lokal_folder = getSiStripControlFolder(slot, ring, addr, chan);
00116 dbe_->setCurrentFolder(lokal_folder);
00117 return;
00118 }
00119
00120 std::pair<std::string,int32_t> SiStripFolderOrganizer::GetSubDetAndLayer(const uint32_t& detid, bool ring_flag){
00121 std::string cSubDet;
00122 int32_t layer=0;
00123 switch(StripSubdetector::SubDetector(StripSubdetector(detid).subdetId()))
00124 {
00125 case StripSubdetector::TIB:
00126 cSubDet="TIB";
00127 layer=TIBDetId(detid).layer();
00128 break;
00129 case StripSubdetector::TOB:
00130 cSubDet="TOB";
00131 layer=TOBDetId(detid).layer();
00132 break;
00133 case StripSubdetector::TID:
00134 cSubDet="TID";
00135 if(ring_flag)
00136 layer=TIDDetId(detid).ring() * ( TIDDetId(detid).side()==1 ? -1 : +1);
00137 else
00138 layer=TIDDetId(detid).wheel() * ( TIDDetId(detid).side()==1 ? -1 : +1);
00139 break;
00140 case StripSubdetector::TEC:
00141 cSubDet="TEC";
00142 if(ring_flag)
00143 layer=TECDetId(detid).ring() * ( TECDetId(detid).side()==1 ? -1 : +1);
00144 else
00145 layer=TECDetId(detid).wheel() * ( TECDetId(detid).side()==1 ? -1 : +1);
00146 break;
00147 default:
00148 edm::LogWarning("SiStripMonitorTrack") << "WARNING!!! this detid does not belong to tracker" << std::endl;
00149 }
00150 return std::make_pair(cSubDet,layer);
00151 }
00152
00153
00154 void SiStripFolderOrganizer::setDetectorFolder(uint32_t rawdetid){
00155 std::string folder_name;
00156 getFolderName(rawdetid, folder_name);
00157 dbe_->setCurrentFolder(folder_name);
00158 }
00159
00160 void SiStripFolderOrganizer::getSubDetLayerFolderName(std::stringstream& ss, SiStripDetId::SubDetector subDet, uint32_t layer, uint32_t side){
00161 ss << TopFolderName << SEP << MECHANICAL_FOLDER_NAME;
00162
00163 if(subDet == SiStripDetId::TIB){
00164 ss << SEP << "TIB" << SEP << "layer_" << layer << SEP;
00165 } else if(subDet == SiStripDetId::TID){
00166 ss << SEP << "TID" << SEP << "side_" << side << SEP << "wheel_" << layer << SEP;
00167 } else if( subDet == SiStripDetId::TOB){
00168 ss << SEP << "TOB" << SEP << "layer_" << layer << SEP;
00169 }else if(subDet == SiStripDetId::TEC){
00170 ss << SEP << "TEC" << SEP << "side_" << side << SEP << "wheel_" << layer << SEP;
00171 }else{
00172
00173 edm::LogWarning("SiStripTkDQM|WrongInput")<<"no such SubDet :"<< subDet <<" no folder set!"<<std::endl;
00174 }
00175 }
00176
00177
00178 void SiStripFolderOrganizer::getFolderName(int32_t rawdetid, std::string& lokal_folder){
00179 lokal_folder = "";
00180 if(rawdetid == 0 ){
00181 return;
00182 }
00183 std::stringstream rest;
00184 SiStripDetId stripdet = SiStripDetId(rawdetid);
00185
00186 if (stripdet.subDetector() == SiStripDetId::TIB){
00187
00188 TIBDetId tib = TIBDetId(rawdetid);
00189 getSubDetLayerFolderName(rest,stripdet.subDetector(),tib.layerNumber());
00190 if (tib.isZMinusSide()) rest << "backward_strings" << SEP;
00191 else rest << "forward_strings" << SEP;
00192 if (tib.isExternalString()) rest << "external_strings" << SEP;
00193 else rest << "internal_strings" << SEP;
00194 rest << "string_" << tib.stringNumber() << SEP << "module_" << rawdetid;
00195 } else if(stripdet.subDetector() == SiStripDetId::TID){
00196
00197 TIDDetId tid = TIDDetId(rawdetid);
00198 getSubDetLayerFolderName(rest,stripdet.subDetector(),tid.wheel(),tid.side());
00199 rest<< "ring_" << tid.ring() << SEP;
00200
00201 if (tid.isStereo()) rest << "stereo_modules" << SEP;
00202 else rest << "mono_modules" << SEP;
00203 rest << "module_" << rawdetid;
00204 } else if( stripdet.subDetector() == SiStripDetId::TOB){
00205
00206 TOBDetId tob = TOBDetId(rawdetid);
00207 getSubDetLayerFolderName(rest,stripdet.subDetector(),tob.layerNumber());
00208 if (tob.isZMinusSide()) rest << "backward_rods" << SEP;
00209 else rest << "forward_rods" << SEP;
00210 rest << "rod_" << tob.rodNumber() << SEP<< "module_" << rawdetid;
00211 }else if(stripdet.subDetector() == SiStripDetId::TEC){
00212
00213 TECDetId tec = TECDetId(rawdetid);
00214 getSubDetLayerFolderName(rest,stripdet.subDetector(),tec.wheel(),tec.side());
00215 if (tec.isBackPetal()) rest << "backward_petals" << SEP;
00216 else rest << "forward_petals" << SEP;
00217
00218 rest << "petal_" << tec.petalNumber() << SEP
00219 << "ring_"<< tec.ringNumber() << SEP;
00220
00221 if (tec.isStereo()) rest << "stereo_modules" << SEP;
00222 else rest << "mono_modules" << SEP;
00223
00224 rest << "module_" << rawdetid;
00225 }else{
00226
00227 edm::LogWarning("SiStripTkDQM|WrongInput")<<"no such subdetector type :"<<stripdet.subDetector() <<" no folder set!"<<std::endl;
00228 return;
00229 }
00230 lokal_folder += rest.str();
00231
00232 }
00233
00234 void SiStripFolderOrganizer::setLayerFolder(uint32_t rawdetid, int32_t layer, bool ring_flag){
00235 std::string lokal_folder = TopFolderName + SEP + MECHANICAL_FOLDER_NAME;
00236 if(rawdetid == 0 ){
00237 dbe_->setCurrentFolder(lokal_folder);
00238 return;
00239 }
00240
00241 std::ostringstream rest;
00242 SiStripDetId stripdet = SiStripDetId(rawdetid);
00243 if(stripdet.subDetector() == SiStripDetId::TIB ){
00244
00245 TIBDetId tib1 = TIBDetId(rawdetid);
00246 int tib_layer = tib1.layer();
00247 if (abs(layer) != tib_layer) {
00248 edm::LogWarning("SiStripTkDQM|Layer mismatch!!!")<< " expect "<< abs(layer) << " but getting " << tib1.layer() <<std::endl;
00249 return;
00250 }
00251 rest<<SEP<<"TIB"<<SEP<<"layer_"<<tib1.layer();
00252 }else if(stripdet.subDetector() == SiStripDetId::TID){
00253
00254 TIDDetId tid1 = TIDDetId(rawdetid);
00255 int tid_ring = tid1.ring();
00256 if(ring_flag){
00257 if(abs(layer) != tid_ring) {
00258 edm::LogWarning("SiStripTkDQM|Layer mismatch!!!")<< " expect "<< abs(layer) << " but getting " << tid1.ring() <<std::endl;
00259 return;
00260 }
00261 rest<<SEP<<"TID"<<SEP<<"side_"<<tid1.side()<<SEP<<"ring_"<<tid1.ring();
00262 }else{
00263 int tid_wheel = tid1.wheel();
00264 if (abs(layer) != tid_wheel) {
00265 edm::LogWarning("SiStripTkDQM|Layer mismatch!!!")<< " expect "<< abs(layer) << " but getting " << tid1.wheel() <<std::endl;
00266 return;
00267 }
00268 rest<<SEP<<"TID"<<SEP<<"side_"<<tid1.side()<<SEP<<"wheel_"<<tid1.wheel();
00269 }
00270 }else if(stripdet.subDetector() == SiStripDetId::TOB){
00271
00272 TOBDetId tob1 = TOBDetId(rawdetid);
00273 int tob_layer = tob1.layer();
00274 if (abs(layer) != tob_layer) {
00275 edm::LogWarning("SiStripTkDQM|Layer mismatch!!!")<< " expect "<< abs(layer) << " but getting " << tob1.layer() <<std::endl;
00276 return;
00277 }
00278 rest<<SEP<<"TOB"<<SEP<<"layer_"<<tob1.layer();
00279 }else if( stripdet.subDetector() == SiStripDetId::TEC){
00280
00281 TECDetId tec1 = TECDetId(rawdetid);
00282 if(ring_flag){
00283 int tec_ring = tec1.ring();
00284 if (abs(layer) != tec_ring) {
00285 edm::LogWarning("SiStripTkDQM|Layer mismatch!!!")<< " expect "<< abs(layer) << " but getting " << tec1.ring() <<std::endl;
00286 return;
00287 }
00288 rest<<SEP<<"TEC"<<SEP<<"side_"<<tec1.side()<<SEP<<"ring_"<<tec1.ring();
00289 }else{
00290 int tec_wheel = tec1.wheel();
00291 if (abs(layer) != tec_wheel) {
00292 edm::LogWarning("SiStripTkDQM|Layer mismatch!!!")<< " expect "<< abs(layer) << " but getting " << tec1.wheel() <<std::endl;
00293 return;
00294 }
00295 rest<<SEP<<"TEC"<<SEP<<"side_"<<tec1.side()<<SEP<<"wheel_"<<tec1.wheel();
00296 }
00297 }else{
00298
00299 edm::LogWarning("SiStripTkDQM|WrongInput")<<"no such subdetector type :"<<stripdet.subDetector()<<" no folder set!"<<std::endl;
00300 return;
00301 }
00302
00303 lokal_folder += rest.str();
00304 dbe_->setCurrentFolder(lokal_folder);
00305 }
00306
00307 void SiStripFolderOrganizer::getSubDetFolder(const uint32_t& detid, std::string& folder_name){
00308
00309 std::pair<std::string, std::string> subdet_and_tag = getSubDetFolderAndTag(detid);
00310 folder_name = subdet_and_tag.first;
00311 }
00312
00313
00314
00315 void SiStripFolderOrganizer::getLayerFolderName(std::stringstream& ss, uint32_t rawdetid,bool ring_flag){
00316 ss << TopFolderName + SEP + MECHANICAL_FOLDER_NAME;
00317 if(rawdetid == 0 ){
00318 return;
00319 }
00320
00321 SiStripDetId stripdet = SiStripDetId(rawdetid);
00322 if(stripdet.subDetector() == SiStripDetId::TIB ){
00323
00324 TIBDetId tib1 = TIBDetId(rawdetid);
00325 ss<<SEP<<"TIB"<<SEP<<"layer_"<<tib1.layer();
00326 }else if(stripdet.subDetector() == SiStripDetId::TID){
00327
00328 TIDDetId tid1 = TIDDetId(rawdetid);
00329 if(ring_flag){
00330 ss<<SEP<<"TID"<<SEP<<"side_"<<tid1.side()<<SEP<<"ring_"<<tid1.ring();
00331 }else{
00332 ss<<SEP<<"TID"<<SEP<<"side_"<<tid1.side()<<SEP<<"wheel_"<<tid1.wheel();
00333 }
00334 }else if(stripdet.subDetector() == SiStripDetId::TOB){
00335
00336 TOBDetId tob1 = TOBDetId(rawdetid);
00337 ss<<SEP<<"TOB"<<SEP<<"layer_"<<tob1.layer();
00338 }else if( stripdet.subDetector() == SiStripDetId::TEC){
00339
00340 TECDetId tec1 = TECDetId(rawdetid);
00341 if(ring_flag){
00342 ss<<SEP<<"TEC"<<SEP<<"side_"<<tec1.side()<<SEP<<"ring_"<<tec1.ring();
00343 }else{
00344 ss<<SEP<<"TEC"<<SEP<<"side_"<<tec1.side()<<SEP<<"wheel_"<<tec1.wheel();
00345 }
00346 }else{
00347
00348 edm::LogWarning("SiStripTkDQM|WrongInput")<<"no such subdetector type :"<<stripdet.subDetector()<<" no folder set!"<<std::endl;
00349 return;
00350 }
00351 }
00352
00353
00354
00355 std::pair<std::string, std::string> SiStripFolderOrganizer::getSubDetFolderAndTag(const uint32_t& detid) {
00356 std::pair<std::string, std::string> result;
00357 result.first = TopFolderName + SEP MECHANICAL_FOLDER_NAME SEP;
00358 std::string subdet_folder;
00359 switch(StripSubdetector::SubDetector(StripSubdetector(detid).subdetId()))
00360 {
00361 case StripSubdetector::TIB:
00362 subdet_folder = "TIB";
00363 result.second = subdet_folder;
00364 break;
00365 case StripSubdetector::TOB:
00366 subdet_folder = "TOB";
00367 result.second = subdet_folder;
00368 break;
00369 case StripSubdetector::TID:
00370 if (TIDDetId(detid).side() == 2) {
00371 subdet_folder = "TID/side_2";
00372 result.second = "TID__side__2";
00373 } else if (TIDDetId(detid).side() == 1) {
00374 subdet_folder = "TID/side_1";
00375 result.second = "TID__side__1";
00376 }
00377 break;
00378 case StripSubdetector::TEC:
00379 if (TECDetId(detid).side() == 2) {
00380 subdet_folder = "TEC/side_2";
00381 result.second = "TEC__side__2";
00382 } else if (TECDetId(detid).side() == 1) {
00383 subdet_folder = "TEC/side_1";
00384 result.second = "TEC__side__1";
00385 }
00386 break;
00387 default:
00388 {
00389 edm::LogWarning("SiStripCommon") << "WARNING!!! this detid does not belong to tracker" << std::endl;
00390 subdet_folder = "";
00391 }
00392 }
00393 result.first += subdet_folder;
00394 return result;
00395 }