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

Remove some const-away casts from DQM and validation #25042

Merged
merged 6 commits into from Oct 31, 2018
2 changes: 1 addition & 1 deletion DQM/EcalMonitorTasks/src/RawDataTask.cc
Expand Up @@ -61,7 +61,7 @@ namespace ecaldqm {
// Get GT L1 info
const FEDRawData &gtFED(_fedRaw.FEDData(812));
if(gtFED.size() > sizeof(uint64_t)){ // FED header is one 64 bit word
uint32_t *halfHeader((uint32_t *)gtFED.data());
const uint32_t *halfHeader = reinterpret_cast<const uint32_t *>(gtFED.data());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@makortel for my understanding, could you please explain why here reinterpret_cast is preferable to static_cast?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabiocos
The return type of FEDRawData::data() is const unsigned char *, which then gets re-interpreted here as const uint32_t *.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, there is no relationship among the original and casted version...

l1A_ = *(halfHeader + 1) & 0xffffff;
}

Expand Down
Expand Up @@ -61,7 +61,7 @@ std::vector<std::pair< std::pair<DetId, LocalPoint> ,float> > SiStripFineDelayTL
const SiStripRecHit2D* hit=dynamic_cast<const SiStripRecHit2D*>((*thit).hit());
LocalVector trackdirection=tsos.localDirection();
if(matchedhit){//if matched hit...
GluedGeomDet * gdet=(GluedGeomDet *)tracker->idToDet(matchedhit->geographicalId());
const GluedGeomDet * gdet=static_cast<const GluedGeomDet *>(tracker->idToDet(matchedhit->geographicalId()));
GlobalVector gtrkdir=gdet->toGlobal(trackdirection);
// trackdirection on mono det
// this the pointer to the mono hit of a matched hit
Expand All @@ -70,7 +70,7 @@ std::vector<std::pair< std::pair<DetId, LocalPoint> ,float> > SiStripFineDelayTL
LocalVector monotkdir=monodet->toLocal(gtrkdir);
if(monotkdir.z()!=0){
// the local angle (mono)
float localpitch = ((StripTopology*)(&monodet->topology()))->localPitch(tsos.localPosition());
float localpitch = static_cast<const StripTopology&>(monodet->topology()).localPitch(tsos.localPosition());
float thickness = ((((((monohit.geographicalId())>>25)&0x7f)==0xd)||
((((monohit.geographicalId())>>25)&0x7f)==0xe))&&
((((monohit.geographicalId())>>5)&0x7)>4)) ? 0.0500 : 0.0320;
Expand All @@ -83,7 +83,7 @@ std::vector<std::pair< std::pair<DetId, LocalPoint> ,float> > SiStripFineDelayTL
LocalVector stereotkdir=stereodet->toLocal(gtrkdir);
if(stereotkdir.z()!=0){
// the local angle (stereo)
float localpitch = ((StripTopology*)(&stereodet->topology()))->localPitch(tsos.localPosition());
float localpitch = static_cast<const StripTopology&>(stereodet->topology()).localPitch(tsos.localPosition());
float thickness = ((((((stereohit.geographicalId())>>25)&0x7f)==0xd)||
((((stereohit.geographicalId())>>25)&0x7f)==0xe))&&
((((stereohit.geographicalId())>>5)&0x7)>4)) ? 0.0500 : 0.0320;
Expand All @@ -93,11 +93,11 @@ std::vector<std::pair< std::pair<DetId, LocalPoint> ,float> > SiStripFineDelayTL
}
}
else if(hit){
GeomDetUnit * det=(GeomDetUnit *)tracker->idToDet(hit->geographicalId());
const GeomDetUnit * det=tracker->idToDet(hit->geographicalId());
// hit= pointer to the rechit
if(trackdirection.z()!=0){
// the local angle (single hit)
float localpitch = ((StripTopology*)(&det->topology()))->localPitch(tsos.localPosition());
float localpitch = static_cast<const StripTopology&>(det->topology()).localPitch(tsos.localPosition());
float thickness = ((((((hit->geographicalId())>>25)&0x7f)==0xd)||
((((hit->geographicalId())>>25)&0x7f)==0xe))&&
((((hit->geographicalId())>>5)&0x7)>4)) ? 0.0500 : 0.0320;
Expand Down
6 changes: 3 additions & 3 deletions DQM/SiStripCommissioningSources/src/FineDelayTask.cc
Expand Up @@ -79,9 +79,9 @@ void FineDelayTask::fill( const SiStripEventSummary& summary,
const edm::DetSet<SiStripRawDigi>& digis ) {
LogDebug("Commissioning") << "[FineDelayTask::fill]";
// retrieve the delay from the EventSummary
float delay = const_cast<SiStripEventSummary&>(summary).ttcrx();
uint32_t latencyCode = (const_cast<SiStripEventSummary&>(summary).layerScanned()>>24)&0xff;
LogDebug("Commissioning") << "[FineDelayTask::fill]: layerScanned() is " << const_cast<SiStripEventSummary&>(summary).layerScanned();
float delay = summary.ttcrx();
uint32_t latencyCode = (summary.layerScanned()>>24)&0xff;
LogDebug("Commissioning") << "[FineDelayTask::fill]: layerScanned() is " << summary.layerScanned();
int latencyShift = latencyCode & 0x3f; // number of bunch crossings between current value and start of scan... must be positive
if(latencyShift>32) latencyShift -=64; // allow negative values: we cover [-32,32].. should not be needed.
if((latencyCode>>6)==2) latencyShift -= 3; // layer in deconv, rest in peak
Expand Down
2 changes: 1 addition & 1 deletion DQM/SiStripCommissioningSources/src/LatencyTask.cc
Expand Up @@ -130,7 +130,7 @@ void LatencyTask::fill( const SiStripEventSummary& summary,
const edm::DetSet<SiStripRawDigi>& digis ) {
LogDebug("Commissioning") << "[LatencyTask::fill]";
// retrieve the delay from the EventSummary
int32_t delay = static_cast<int32_t>( const_cast<SiStripEventSummary&>(summary).latency() );
int32_t delay = static_cast<int32_t>( summary.latency() );
if(firstReading_==-1) firstReading_ = delay;
float correctedDelay = 0.;
LogDebug("Commissioning") << "[LatencyTask::fill]; the delay is " << delay;
Expand Down
4 changes: 2 additions & 2 deletions DQM/SiStripCommissioningSources/src/VpspScanTask.cc
Expand Up @@ -63,8 +63,8 @@ void VpspScanTask::fill( const SiStripEventSummary& summary,
const edm::DetSet<SiStripRawDigi>& digis ) {

// Retrieve VPSP setting and CCU channel
uint32_t vpsp = const_cast<SiStripEventSummary&>(summary).vpsp();
uint32_t ccu_chan = const_cast<SiStripEventSummary&>(summary).vpspCcuChan();
uint32_t vpsp = summary.vpsp();
uint32_t ccu_chan = summary.vpspCcuChan();

// Check CCU channel from EventSummary is consistent with this module
if ( SiStripFecKey( fecKey() ).ccuChan() != ccu_chan ) { return; }
Expand Down
3 changes: 1 addition & 2 deletions DQMOffline/Trigger/plugins/JetMETHLTOfflineSource.cc
Expand Up @@ -852,8 +852,7 @@ JetMETHLTOfflineSource::fillMEforEffAllTrigger(const Event & iEvent, const edm::
if(!isdigit(tpath[trig])) break;
jetTrigVal+=tpath[trig];
}
auto *cjetTrigVal = (char*)jetTrigVal.c_str();
jetVal=atof(cjetTrigVal);
jetVal=atof(jetTrigVal.c_str());
//
if(jetVal>0.){
if(jetVal<50.){
Expand Down
5 changes: 2 additions & 3 deletions Validation/HGCalValidation/plugins/SimG4HGCalValidation.cc
Expand Up @@ -193,8 +193,7 @@ void SimG4HGCalValidation::update(const BeginOfJob * job) {
edm::ESHandle<HcalDDDSimConstants> hdc;
es->get<HcalSimNumberingRecord>().get(hdc);
if (hdc.isValid()) {
HcalDDDSimConstants* hcalConstants = (HcalDDDSimConstants*)(&(*hdc));
numberingFromDDD_ = new HcalNumberingFromDDD(hcalConstants);
numberingFromDDD_ = new HcalNumberingFromDDD(hdc.product());
layers = 18;
} else {
edm::LogError("ValidHGCal") << "Cannot find HcalDDDSimConstant";
Expand Down Expand Up @@ -263,7 +262,7 @@ void SimG4HGCalValidation::update(const G4Step * aStep) {
// Right type of SD
if (type >= 0) {
//Get the 32-bit index of the hit cell
G4TouchableHistory* touchable = (G4TouchableHistory*)aStep->GetPreStepPoint()->GetTouchable();
const G4TouchableHistory* touchable = static_cast<const G4TouchableHistory*>(aStep->GetPreStepPoint()->GetTouchable());
unsigned int index(0);
int layer(0);
G4ThreeVector hitPoint = aStep->GetPreStepPoint()->GetPosition();
Expand Down
10 changes: 4 additions & 6 deletions Validation/TrackerRecHits/src/SiStripRecHitsValid.cc
Expand Up @@ -222,8 +222,7 @@ void SiStripRecHitsValid::analyze(const edm::Event& e, const edm::EventSetup& es
if(iLayerME != LayerMEsMap.end()){
for(auto const& rechit : theDetSet){
const GeomDetUnit * det = tracker.idToDetUnit(detid);
const StripGeomDetUnit * stripdet=(const StripGeomDetUnit*)(det);
const StripTopology &topol=(StripTopology&)stripdet->topology();
const StripTopology &topol=static_cast<const StripGeomDetUnit*>(det)->specificTopology();
//analyze RecHits
rechitanalysis(rechit,topol,associate);
// fill the result in a histogram
Expand Down Expand Up @@ -262,8 +261,7 @@ void SiStripRecHitsValid::analyze(const edm::Event& e, const edm::EventSetup& es
if(iStereoAndMatchedME != StereoAndMatchedMEsMap.end()){
for (auto const& rechit : theDetSet) {
const GeomDetUnit * det = tracker.idToDetUnit(detid);
const StripGeomDetUnit * stripdet=(const StripGeomDetUnit*)(det);
const StripTopology &topol=(StripTopology&)stripdet->topology();
const StripTopology &topol=static_cast<const StripGeomDetUnit*>(det)->specificTopology();
//analyze RecHits
rechitanalysis(rechit,topol,associate);
// fill the result in a histogram
Expand Down Expand Up @@ -301,7 +299,7 @@ void SiStripRecHitsValid::analyze(const edm::Event& e, const edm::EventSetup& es
//loop over rechits-matched in the same subdetector
if(iStereoAndMatchedME != StereoAndMatchedMEsMap.end()){
for (auto const& rechit : theDetSet) {
const GluedGeomDet* gluedDet = (const GluedGeomDet*)tracker.idToDet(rechit.geographicalId());
const GluedGeomDet* gluedDet = static_cast<const GluedGeomDet*>(tracker.idToDet(rechit.geographicalId()));
//analyze RecHits
rechitanalysis_matched(rechit, gluedDet, associate);
// fill the result in a histogram
Expand Down Expand Up @@ -462,7 +460,7 @@ void SiStripRecHitsValid::rechitanalysis_matched(SiStripMatchedRecHit2D const re
PSimHit const * closest = nullptr;
std::pair<LocalPoint,LocalVector> closestPair;

const StripGeomDetUnit* partnerstripdet =(StripGeomDetUnit*) gluedDet->stereoDet();
const StripGeomDetUnit* partnerstripdet = static_cast<const StripGeomDetUnit*>(gluedDet->stereoDet());
std::pair<LocalPoint,LocalVector> hitPair;

for(auto const &m : matched){
Expand Down