Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize SiStripMonitorTrack to perform less string operations. #8352

Merged
merged 1 commit into from
Mar 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DQM/SiStripCommon/interface/SiStripFolderOrganizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class SiStripFolderOrganizer
void getRingFolderName(std::stringstream& ss, uint32_t rawdetid, const TrackerTopology* tTopo) { getLayerFolderName(ss,rawdetid,tTopo,true); }
// SubDetector Folder
void getSubDetFolder(const uint32_t& detid, const TrackerTopology* tTopo, std::string& folder_name);
std::pair<std::string, std::string> getSubDetFolderAndTag(const uint32_t& detid, const TrackerTopology* tTopo);
std::pair<const std::string, const char *> getSubDetFolderAndTag(const uint32_t& detid, const TrackerTopology* tTopo);
private:
SiStripFolderOrganizer(const SiStripFolderOrganizer&); // stop default
const SiStripFolderOrganizer& operator=(const SiStripFolderOrganizer&); // stop default
Expand Down
32 changes: 19 additions & 13 deletions DQM/SiStripCommon/src/SiStripFolderOrganizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#define MECHANICAL_FOLDER_NAME "MechanicalView"
#define SEP "/"

#include <cstring>

SiStripFolderOrganizer::SiStripFolderOrganizer()
{
TopFolderName="SiStrip";
Expand Down Expand Up @@ -452,46 +454,50 @@ void SiStripFolderOrganizer::getLayerFolderName(std::stringstream& ss, uint32_t
//
// -- Get Subdetector Folder name and the Tag
//
std::pair<std::string, std::string> SiStripFolderOrganizer::getSubDetFolderAndTag(const uint32_t& detid, const TrackerTopology* tTopo) {
std::pair<std::string, std::string> result;
result.first = TopFolderName + SEP MECHANICAL_FOLDER_NAME SEP;
std::string subdet_folder;
std::pair<const std::string, const char *> SiStripFolderOrganizer::getSubDetFolderAndTag(const uint32_t& detid, const TrackerTopology* tTopo) {

const char *subdet_folder = "";
const char *tag = "";
switch(StripSubdetector::SubDetector(StripSubdetector(detid).subdetId()))
{
case StripSubdetector::TIB:
subdet_folder = "TIB";
result.second = subdet_folder;
tag = subdet_folder;
break;
case StripSubdetector::TOB:
subdet_folder = "TOB";
result.second = subdet_folder;
tag = subdet_folder;
break;
case StripSubdetector::TID:
if (tTopo->tidSide(detid) == 2) {
subdet_folder = "TID/PLUS";
result.second = "TID__PLUS";
tag = "TID__PLUS";
} else if (tTopo->tidSide(detid) == 1) {
subdet_folder = "TID/MINUS";
result.second = "TID__MINUS";
tag = "TID__MINUS";
}
break;
case StripSubdetector::TEC:
if (tTopo->tecSide(detid) == 2) {
subdet_folder = "TEC/PLUS";
result.second = "TEC__PLUS";
tag = "TEC__PLUS";
} else if (tTopo->tecSide(detid) == 1) {
subdet_folder = "TEC/MINUS";
result.second = "TEC__MINUS";
tag = "TEC__MINUS";
}
break;
default:
{
edm::LogWarning("SiStripCommon") << "WARNING!!! this detid does not belong to tracker" << std::endl;
edm::LogWarning("SiStripCommon") << "WARNING!!! this detid does not belong to tracker" << std::endl;
subdet_folder = "";
}
}
result.first += subdet_folder;
return result;

std::string folder;
folder.reserve(TopFolderName.size() + strlen(SEP MECHANICAL_FOLDER_NAME SEP) + strlen(subdet_folder) + 1);
folder = TopFolderName + SEP MECHANICAL_FOLDER_NAME SEP + subdet_folder;

return std::pair<const std::string, const char *>(folder, tag);
}


Expand Down
14 changes: 6 additions & 8 deletions DQM/SiStripCommon/src/SiStripHistoId.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ std::string SiStripHistoId::createHistoLayer(std::string description, std::strin

//std::string SiStripHistoId::getSubdetid(uint32_t id, const TrackerTopology* tTopo, bool flag_ring, bool flag_thickness){
std::string SiStripHistoId::getSubdetid(uint32_t id, const TrackerTopology* tTopo, bool flag_ring){
std::string rest1;

const int buf_len = 50;
char temp_str[buf_len];

Expand All @@ -96,16 +94,16 @@ std::string SiStripHistoId::getSubdetid(uint32_t id, const TrackerTopology* tTop
}else if( subdet.subdetId() == StripSubdetector::TID){
// --------------------------- TID --------------------------- //

std::string side = "";
const char *side = "";
if (tTopo->tidSide(id) == 1)
side = "MINUS";
else if (tTopo->tidSide(id) == 2)
side = "PLUS";

if (flag_ring)
snprintf(temp_str, buf_len, "TID__%s__ring__%i", side.c_str(), tTopo->tidRing(id) );
snprintf(temp_str, buf_len, "TID__%s__ring__%i", side, tTopo->tidRing(id) );
else
snprintf(temp_str, buf_len, "TID__%s__wheel__%i", side.c_str(), tTopo->tidWheel(id));
snprintf(temp_str, buf_len, "TID__%s__wheel__%i", side, tTopo->tidWheel(id));

}else if(subdet.subdetId() == StripSubdetector::TOB){
// --------------------------- TOB --------------------------- //
Expand All @@ -114,14 +112,14 @@ std::string SiStripHistoId::getSubdetid(uint32_t id, const TrackerTopology* tTop
}else if(subdet.subdetId() == StripSubdetector::TEC){
// --------------------------- TEC --------------------------- //

std::string side = "";
const char *side = "";
if (tTopo->tecSide(id) == 1)
side = "MINUS";
else if (tTopo->tecSide(id) == 2)
side = "PLUS";

if (flag_ring)
snprintf(temp_str, buf_len, "TEC__%s__ring__%i", side.c_str(), tTopo->tecRing(id) );
snprintf(temp_str, buf_len, "TEC__%s__ring__%i", side, tTopo->tecRing(id) );
else {
/*
if (flag_thickness) {
Expand All @@ -133,7 +131,7 @@ std::string SiStripHistoId::getSubdetid(uint32_t id, const TrackerTopology* tTop
}
else
*/
snprintf(temp_str, buf_len, "TEC__%s__wheel__%i", side.c_str(), tTopo->tecWheel(id));
snprintf(temp_str, buf_len, "TEC__%s__wheel__%i", side, tTopo->tecWheel(id));
}
}else{
// --------------------------- ??? --------------------------- //
Expand Down
2 changes: 1 addition & 1 deletion DQM/SiStripMonitorCluster/src/SiStripMonitorCluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ void SiStripMonitorCluster::createMEs(const edm::EventSetup& es , DQMStore::IBoo
createLayerMEs(label, layerDetIds.size() , ibooker );
}
// book sub-detector plots
std::pair<std::string,std::string> sdet_pair = folder_organizer.getSubDetFolderAndTag(detid, tTopo);
auto sdet_pair = folder_organizer.getSubDetFolderAndTag(detid, tTopo);
if (SubDetMEsMap.find(sdet_pair.second) == SubDetMEsMap.end()){
ibooker.setCurrentFolder(sdet_pair.first);

Expand Down
2 changes: 1 addition & 1 deletion DQM/SiStripMonitorDigi/src/SiStripMonitorDigi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ void SiStripMonitorDigi::createMEs(DQMStore::IBooker & ibooker , const edm::Even
}

// book sub-detector plots
std::pair<std::string,std::string> sdet_pair = folder_organizer.getSubDetFolderAndTag(detid, tTopo);
auto sdet_pair = folder_organizer.getSubDetFolderAndTag(detid, tTopo);
if (SubDetMEsMap.find(sdet_pair.second) == SubDetMEsMap.end()){
ibooker.setCurrentFolder(sdet_pair.first);
createSubDetMEs( ibooker , sdet_pair.second );
Expand Down
27 changes: 19 additions & 8 deletions DQM/SiStripMonitorTrack/interface/SiStripMonitorTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,16 @@ class SiStripMonitorTrack : public DQMEDAnalyzer {
OffTrack,
OnTrack
};

struct Det2MEs;

//booking
void book(DQMStore::IBooker &, const TrackerTopology* tTopo);
void bookModMEs(DQMStore::IBooker &, const uint32_t& );
void bookLayerMEs(DQMStore::IBooker &, const uint32_t&, std::string&);
void bookRing(DQMStore::IBooker &, const uint32_t&, std::string&);
void bookModMEs(DQMStore::IBooker &, const uint32_t );
void bookLayerMEs(DQMStore::IBooker &, const uint32_t, std::string&);
void bookRing(DQMStore::IBooker &, const uint32_t, std::string&);
MonitorElement* handleBookMEs(DQMStore::IBooker &, std::string&, std::string&, std::string&, std::string&);
void bookRingMEs(DQMStore::IBooker &, const uint32_t&, std::string&);
void bookRingMEs(DQMStore::IBooker &, const uint32_t, std::string&);
void bookSubDetMEs(DQMStore::IBooker &, std::string& name);
MonitorElement * bookME1D(DQMStore::IBooker & , const char*, const char*);
MonitorElement * bookME2D(DQMStore::IBooker & , const char*, const char*);
Expand All @@ -99,19 +102,21 @@ class SiStripMonitorTrack : public DQMEDAnalyzer {
const SiStripRecHit2D* hit2D,
const SiStripRecHit1D* hit1D,
LocalVector localMomentum);
bool clusterInfos(SiStripClusterInfo* cluster, const uint32_t& detid, const TrackerTopology* tTopo, enum ClusterFlags flags, LocalVector LV);
bool clusterInfos(SiStripClusterInfo* cluster, const uint32_t detid, enum ClusterFlags flags, LocalVector LV, const Det2MEs& MEs);
template <class T> void RecHitInfo(const T* tkrecHit, LocalVector LV, const edm::EventSetup&);

// fill monitorables
void fillModMEs(SiStripClusterInfo* cluster,std::string name, float cos, uint32_t detid, const LocalVector LV);
void fillMEs(SiStripClusterInfo*,uint32_t detid, const TrackerTopology* tTopo, float,enum ClusterFlags, const LocalVector LV);
void fillModMEs(SiStripClusterInfo* cluster,std::string name, float cos, const uint32_t detid, const LocalVector LV);
void fillMEs(SiStripClusterInfo*,const uint32_t detid, float,enum ClusterFlags, const LocalVector LV, const Det2MEs& MEs);

inline void fillME(MonitorElement* ME,float value1){if (ME!=0)ME->Fill(value1);}
inline void fillME(MonitorElement* ME,float value1,float value2){if (ME!=0)ME->Fill(value1,value2);}
inline void fillME(MonitorElement* ME,float value1,float value2,float value3){if (ME!=0)ME->Fill(value1,value2,value3);}
inline void fillME(MonitorElement* ME,float value1,float value2,float value3,float value4){if (ME!=0)ME->Fill(value1,value2,value3,value4);}

Det2MEs findMEs(const TrackerTopology* tTopo, const uint32_t detid);

// ----------member data ---------------------------

private:
edm::ParameterSet conf_;
std::string histname;
Expand Down Expand Up @@ -182,6 +187,12 @@ class SiStripMonitorTrack : public DQMEDAnalyzer {
std::map<std::string, LayerMEs> LayerMEsMap;
std::map<std::string, RingMEs> RingMEsMap;
std::map<std::string, SubDetMEs> SubDetMEsMap;

struct Det2MEs {
struct LayerMEs *iLayer;
struct RingMEs *iRing;
struct SubDetMEs *iSubdet;
};

edm::ESHandle<TrackerGeometry> tkgeom_;
edm::ESHandle<SiStripDetCabling> SiStripDetCabling_;
Expand Down
Loading