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