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

Port SiStripDetSummary from subdetector-DetId classes to TrackerTopology #20274

Merged
11 changes: 5 additions & 6 deletions CalibFormats/SiStripObjects/interface/SiStripDelay.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class SiStripDelay
SiStripDelay() {};
virtual ~SiStripDelay() {};

SiStripDelay(const SiStripDelay&) = delete;
const SiStripDelay& operator=(const SiStripDelay&) = delete;

inline SiStripDelay(const SiStripBaseDelay& baseDelay, const int sumSign,
const std::pair<std::string, std::string> & recordLabelPair)
{
Expand Down Expand Up @@ -82,15 +85,11 @@ class SiStripDelay
}

/// Prints the average value of the delays for all layers and wheels in the SiStripTracker
void printSummary(std::stringstream& ss) const;
void printSummary(std::stringstream& ss, const TrackerTopology* trackerTopo) const;
/// Prints the delays for all the detIds
void printDebug(std::stringstream& ss) const;
void printDebug(std::stringstream& ss, const TrackerTopology* tTopo) const;

private:

SiStripDelay(const SiStripDelay&); // stop default
const SiStripDelay& operator=(const SiStripDelay&); // stop default

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

std::vector<const SiStripBaseDelay *> baseDelayVector_;
Expand Down
10 changes: 6 additions & 4 deletions CalibFormats/SiStripObjects/interface/SiStripDetCabling.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class SiStripDetCabling
SiStripDetCabling(const TrackerTopology* const topology);
virtual ~SiStripDetCabling();
SiStripDetCabling(const SiStripFedCabling &,const TrackerTopology* const topology);

SiStripDetCabling(const SiStripDetCabling&) = delete;
const SiStripDetCabling& operator=(const SiStripDetCabling&) = delete;

void addDevices(const FedChannelConnection &, std::map< uint32_t, std::vector<const FedChannelConnection *> >&);
void addDevices(const FedChannelConnection &); // special case of above addDevices
// getters
Expand Down Expand Up @@ -50,9 +54,9 @@ class SiStripDetCabling
void print( std::stringstream& ) const;

/** The printSummary method outputs the number of connected/detected/undetected modules for each layer of each subdetector.*/
void printSummary(std::stringstream& ss) const;
void printSummary(std::stringstream& ss, const TrackerTopology* trackerTopo) const;
/** The printDebug method returns all the connected/detected/undetected modules.*/
void printDebug(std::stringstream& ss) const;
void printDebug(std::stringstream& ss, const TrackerTopology* trackerTopo) const;

// Methods to get the number of connected, detected and undetected modules for each layer of each subdetector.
uint32_t connectedNumber(const std::string & subDet, const uint16_t layer) const { return detNumber(subDet, layer, 0); }
Expand All @@ -64,8 +68,6 @@ class SiStripDetCabling
std::map< uint32_t, std::vector<int> > const & connected() const { return connected_;}

private:
SiStripDetCabling(const SiStripDetCabling&); // stop default
const SiStripDetCabling& operator=(const SiStripDetCabling&); // stop default
void addFromSpecificConnection( std::map<uint32_t, std::vector<int> > & , const std::map< uint32_t, std::vector<int> > &, std::map< int16_t, uint32_t >* connectionsToFill = nullptr ) const;
bool IsInMap(const uint32_t& det_id, const std::map<uint32_t, std::vector<int> > &) const;
int16_t layerSearch( const uint32_t detId ) const;
Expand Down
16 changes: 9 additions & 7 deletions CalibFormats/SiStripObjects/interface/SiStripGain.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,25 @@
#include <vector>
#include <memory>

class TrackerTopology;

class SiStripGain
{
public:
SiStripGain() {}
SiStripGain(const SiStripGain&) = delete;
const SiStripGain& operator=(const SiStripGain&) = delete;

/// Kept for compatibility
inline SiStripGain(const SiStripApvGain& apvgain, const double & factor) :
apvgain_(0)
apvgain_(nullptr)
{
multiply(apvgain, factor, std::make_pair("", ""));
}

inline SiStripGain(const SiStripApvGain& apvgain, const double & factor,
const std::pair<std::string, std::string> & recordLabelPair) :
apvgain_(0)
apvgain_(nullptr)
{
multiply(apvgain, factor, recordLabelPair);
}
Expand Down Expand Up @@ -101,15 +105,13 @@ class SiStripGain
return normVector_[index];
}

void printDebug(std::stringstream& ss) const;
void printSummary(std::stringstream& ss) const;
void printDebug(std::stringstream& ss, const TrackerTopology* trackerTopo) const;
void printSummary(std::stringstream& ss, const TrackerTopology* trackerTopo) const;

private:

void fillNewGain(const SiStripApvGain * apvgain, const double & factor,
const SiStripApvGain * apvgain2 = 0, const double & factor2 = 1.);
SiStripGain(const SiStripGain&); // stop default
const SiStripGain& operator=(const SiStripGain&); // stop default
const SiStripApvGain * apvgain2 = nullptr, const double & factor2 = 1.);

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

Expand Down
6 changes: 3 additions & 3 deletions CalibFormats/SiStripObjects/src/SiStripDelay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,17 @@ void SiStripDelay::clear()
delays_.clear();
}

void SiStripDelay::printDebug(std::stringstream & ss) const
void SiStripDelay::printDebug(std::stringstream & ss, const TrackerTopology* /*trackerTopo*/) const
{
boost::unordered_map<uint32_t, double>::const_iterator it = delays_.begin();
for( ; it != delays_.end(); ++it ) {
ss << "detId = " << it->first << " delay = " << it->second << std::endl;
}
}

void SiStripDelay::printSummary(std::stringstream& ss) const
void SiStripDelay::printSummary(std::stringstream& ss, const TrackerTopology* trackerTopo) const
{
SiStripDetSummary summaryDelays;
SiStripDetSummary summaryDelays{trackerTopo};
boost::unordered_map<uint32_t, double>::const_iterator it = delays_.begin();
for( ; it != delays_.end(); ++it ) {
summaryDelays.add(it->first, it->second);
Expand Down
20 changes: 10 additions & 10 deletions CalibFormats/SiStripObjects/src/SiStripDetCabling.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <iostream>

//---- default constructor / destructor
SiStripDetCabling::SiStripDetCabling(const TrackerTopology* const topology) : fedCabling_(0), tTopo(topology) {}
SiStripDetCabling::SiStripDetCabling(const TrackerTopology* const topology) : fedCabling_(nullptr), tTopo(topology) {}
SiStripDetCabling::~SiStripDetCabling() {}

//---- construct detector view (DetCabling) out of readout view (FedCabling)
Expand Down Expand Up @@ -43,7 +43,7 @@ SiStripDetCabling::SiStripDetCabling(const SiStripFedCabling& fedcabling,const T
if(iconn->i2cAddr(0)) vector_of_connected_apvs.push_back(2*which_apv_pair + 0); // first apv of the pair
if(iconn->i2cAddr(1)) vector_of_connected_apvs.push_back(2*which_apv_pair + 1); // second apv of the pair
}
if(vector_of_connected_apvs.size() != 0){ // add only is smth. there, obviously
if(!vector_of_connected_apvs.empty()){ // add only is smth. there, obviously
std::map<uint32_t, std::vector<int> > map_of_connected_apvs;
map_of_connected_apvs.insert(std::make_pair(iconn->detId(),vector_of_connected_apvs));
addFromSpecificConnection(connected_, map_of_connected_apvs, &(connectionCount[0]));
Expand All @@ -61,7 +61,7 @@ SiStripDetCabling::SiStripDetCabling(const SiStripFedCabling& fedcabling,const T
if(idtct->i2cAddr(0)) vector_of_detected_apvs.push_back(2*which_apv_pair + 0); // first apv of the pair
if(idtct->i2cAddr(1)) vector_of_detected_apvs.push_back(2*which_apv_pair + 1); // second apv of the pair
}
if(vector_of_detected_apvs.size() != 0){ // add only is smth. there, obviously
if(!vector_of_detected_apvs.empty()){ // add only is smth. there, obviously
std::map<uint32_t,std::vector<int> > map_of_detected_apvs;
map_of_detected_apvs.insert(std::make_pair(idtct->detId(),vector_of_detected_apvs));
addFromSpecificConnection(detected_, map_of_detected_apvs, &(connectionCount[1]) );
Expand All @@ -78,7 +78,7 @@ SiStripDetCabling::SiStripDetCabling(const SiStripFedCabling& fedcabling,const T
if(iudtct->i2cAddr(0)) vector_of_undetected_apvs.push_back(2*which_apv_pair + 0); // first apv of the pair
if(iudtct->i2cAddr(1)) vector_of_undetected_apvs.push_back(2*which_apv_pair + 1); // second apv of the pair
}
if(vector_of_undetected_apvs.size() != 0){ // add only is smth. there, obviously
if(!vector_of_undetected_apvs.empty()){ // add only is smth. there, obviously
std::map<uint32_t, std::vector<int> > map_of_undetected_apvs;
map_of_undetected_apvs.insert(std::make_pair(iudtct->detId(),vector_of_undetected_apvs));
addFromSpecificConnection(undetected_, map_of_undetected_apvs, &(connectionCount[2]));
Expand Down Expand Up @@ -147,7 +147,7 @@ const std::vector<const FedChannelConnection *>& SiStripDetCabling::getConnectio
const FedChannelConnection& SiStripDetCabling::getConnection( uint32_t det_id, unsigned short apv_pair ) const{
const std::vector<const FedChannelConnection *>& fcconns = getConnections(det_id);
for(std::vector<const FedChannelConnection *>::const_iterator iconn = fcconns.begin(); iconn!=fcconns.end();++iconn){
if ( ((*iconn) != 0) && (((*iconn)->apvPairNumber()) == apv_pair) ) { // check if apvPairNumber() of present FedChannelConnection is the same as requested one
if ( ((*iconn) != nullptr) && (((*iconn)->apvPairNumber()) == apv_pair) ) { // check if apvPairNumber() of present FedChannelConnection is the same as requested one
return (**iconn); // if yes, return the FedChannelConnection object
}
}
Expand All @@ -159,7 +159,7 @@ const FedChannelConnection& SiStripDetCabling::getConnection( uint32_t det_id, u
//----
const unsigned int SiStripDetCabling::getDcuId( uint32_t det_id ) const{
const std::vector<const FedChannelConnection *>& fcconns = getConnections( det_id );
if(fcconns.size()!=0) {
if(!fcconns.empty()) {
// patch needed to take into account the possibility that the first component of fcconns is invalid
for(size_t i=0;i<fcconns.size();++i)
if (fcconns.at(i) && fcconns.at(i)->detId() != sistrip::invalid32_ && fcconns.at(i)->detId() != 0 )
Expand All @@ -173,10 +173,10 @@ const unsigned int SiStripDetCabling::getDcuId( uint32_t det_id ) const{
//---- one can find the nr of apvs from fullcabling_ -> std::vector<FedChannelConnection> -> size * 2
const uint16_t SiStripDetCabling::nApvPairs(uint32_t det_id) const{
const std::vector<const FedChannelConnection *>& fcconns = getConnections( det_id );
if(fcconns.size()!=0) {
if(!fcconns.empty()) {
// patch needed to take into account the possibility that the first component of fcconns is invalid
for(size_t i=0;i<fcconns.size();++i) {
if ( (fcconns.at(i) != 0) && (fcconns.at(i)->nApvPairs() != sistrip::invalid_) ) {
if ( (fcconns.at(i) != nullptr) && (fcconns.at(i)->nApvPairs() != sistrip::invalid_) ) {
return fcconns.at(i)->nApvPairs(); // nr of apvpairs for associated module
}
}
Expand Down Expand Up @@ -358,7 +358,7 @@ void SiStripDetCabling::print( std::stringstream& ss ) const {
<< "Number of connections: " << total << std::endl;
}

void SiStripDetCabling::printSummary(std::stringstream& ss) const {
void SiStripDetCabling::printSummary(std::stringstream& ss, const TrackerTopology* trackerTopo) const {
for( int connectionType = 0; connectionType < 3; ++connectionType ) {
if( connectionType == 0 ) ss << "Connected modules:" << std::endl;
else if( connectionType == 1 ) ss << "Detected modules:" << std::endl;
Expand Down Expand Up @@ -389,6 +389,6 @@ void SiStripDetCabling::printSummary(std::stringstream& ss) const {
}
}

void SiStripDetCabling::printDebug(std::stringstream& ss) const {
void SiStripDetCabling::printDebug(std::stringstream& ss, const TrackerTopology* /*trackerTopo*/) const {
print(ss);
}
14 changes: 7 additions & 7 deletions CalibFormats/SiStripObjects/src/SiStripGain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void SiStripGain::multiply(const SiStripApvGain & apvgain, const double & factor
const std::pair<std::string, std::string> & recordLabelPair)
{
// When inserting the first ApvGain
if( apvgain_ == 0 ) {
if( apvgain_ == nullptr ) {
if( (factor != 1) && (factor != 0) ) {
fillNewGain( &apvgain, factor );
}
Expand All @@ -42,7 +42,7 @@ void SiStripGain::fillNewGain(const SiStripApvGain * apvgain, const double & fac
SiStripApvGain * newApvGain = new SiStripApvGain;
edm::FileInPath fp("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat");
SiStripDetInfoFileReader reader(fp.fullPath());
const std::map<uint32_t, SiStripDetInfoFileReader::DetInfo> DetInfos = reader.getAllData();
const std::map<uint32_t, SiStripDetInfoFileReader::DetInfo>& DetInfos = reader.getAllData();

// Loop on the apvgain in input and fill the newApvGain with the values/factor.
std::vector<uint32_t> detIds;
Expand All @@ -59,14 +59,14 @@ void SiStripGain::fillNewGain(const SiStripApvGain * apvgain, const double & fac
SiStripApvGain::Range range = apvgain->getRange(*it);

SiStripApvGain::Range range2;
if( apvgain2 != 0 ) {
if( apvgain2 != nullptr ) {
range2 = apvgain2->getRange(*it);
}

for( int apv = 0; apv < detInfoIt->second.nApvs; ++apv ) {
float apvGainValue = apvgain->getApvGain( apv, range )/factor;

if( (apvgain2 != 0) && (factor2 != 0.) ) {
if( (apvgain2 != nullptr) && (factor2 != 0.) ) {
apvGainValue *= apvgain2->getApvGain( apv, range2 )/factor2;
}

Expand Down Expand Up @@ -117,7 +117,7 @@ const SiStripApvGain::Range SiStripGain::getRange(const uint32_t& DetId, const u
return apvgainVector_[index]->getRange(DetId);
}

void SiStripGain::printDebug(std::stringstream & ss) const
void SiStripGain::printDebug(std::stringstream & ss, const TrackerTopology* /*trackerTopo*/) const
{
std::vector<unsigned int> detIds;
getDetIds(detIds);
Expand All @@ -136,9 +136,9 @@ void SiStripGain::printDebug(std::stringstream & ss) const
}
}

void SiStripGain::printSummary(std::stringstream& ss) const
void SiStripGain::printSummary(std::stringstream& ss, const TrackerTopology* trackerTopo) const
{
SiStripDetSummary summaryGain;
SiStripDetSummary summaryGain{trackerTopo};

std::vector<unsigned int> detIds;
getDetIds(detIds);
Expand Down
3 changes: 2 additions & 1 deletion CalibTracker/SiStripDCS/interface/SiStripDetVOffBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "CondFormats/Common/interface/TimeConversions.h"
//#include "DataFormats/Provenance/interface/Timestamp.h"

class TrackerTopology;

#include <fstream>
#include <iostream>
Expand All @@ -46,7 +47,7 @@ class SiStripDetVOffBuilder
/** Default constructor. */
SiStripDetVOffBuilder(const edm::ParameterSet&,const edm::ActivityRegistry&);
/** Build the SiStripDetVOff object for transfer. */
void BuildDetVOffObj();
void BuildDetVOffObj(const TrackerTopology* trackerTopo);
/** Return modules Off vector of objects. */
std::vector< std::pair<SiStripDetVOff*,cond::Time_t> > getModulesVOff() {
reduction(deltaTmin_, maxIOVlength_);
Expand Down
11 changes: 7 additions & 4 deletions CalibTracker/SiStripDCS/plugins/SiStripDetVOffHandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
class SiStripDetVOffHandler : public edm::EDAnalyzer {
public:
explicit SiStripDetVOffHandler(const edm::ParameterSet& iConfig );
virtual ~SiStripDetVOffHandler();
virtual void analyze( const edm::Event& evt, const edm::EventSetup& evtSetup);
virtual void endJob();
~SiStripDetVOffHandler() override;
void analyze( const edm::Event& evt, const edm::EventSetup& evtSetup) override;
void endJob() override;

private:
cond::persistency::ConnectionPool m_connectionPool;
Expand Down Expand Up @@ -72,10 +72,13 @@ void SiStripDetVOffHandler::analyze(const edm::Event& evt, const edm::EventSetup
}
condDbSession.transaction().commit();

edm::ESHandle<TrackerTopology> tTopo;
evtSetup.get<TrackerTopologyRcd>().get(tTopo);

// build the object!
newPayloads.clear();
modHVBuilder->setLastSiStripDetVOff( lastPayload.get(), lastIov );
modHVBuilder->BuildDetVOffObj();
modHVBuilder->BuildDetVOffObj(tTopo.product());
newPayloads = modHVBuilder->getModulesVOff();
edm::LogInfo("SiStripDetVOffHandler") << "[SiStripDetVOffHandler::" << __func__ << "] "
<< "Finished building " << newPayloads.size() << " new payloads.";
Expand Down