Skip to content

Commit

Permalink
Merge pull request #1007 from rlcee/ped_crv_230714
Browse files Browse the repository at this point in the history
fix CRV pedantic errors
  • Loading branch information
kutschke authored Jul 18, 2023
2 parents c8af6e2 + 53441b9 commit 715e270
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
19 changes: 10 additions & 9 deletions CRVResponse/src/CrvCoincidenceCheck_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "CLHEP/Units/GlobalSystemOfUnits.h"

#include <string>
#include <vector>

#include <TMath.h>
#include <TH2D.h>
Expand Down Expand Up @@ -459,10 +460,10 @@ if(crvCoincidenceCollection->size()==0)
size_t n=layerIterators.size();
if(n==0) return;

double maxTimeDifferences[n];
double times[n];
double timesPulseStart[n], timesPulseEnd[n];
double x[n], y[n];
std::vector<double> maxTimeDifferences(n);
std::vector<double> times(n);
std::vector<double> timesPulseStart(n), timesPulseEnd(n);
std::vector<double> x(n), y(n);
std::vector<art::Ptr<CrvRecoPulse> > crvRecoPulses;
std::vector<int> layers;
for(size_t i=0; i<n; ++i)
Expand All @@ -480,15 +481,15 @@ if(crvCoincidenceCollection->size()==0)

if(!_usePulseOverlaps)
{
double maxTimeDifference=*std::max_element(maxTimeDifferences,maxTimeDifferences+n);
double timeMin = *std::min_element(times,times+n);
double timeMax = *std::max_element(times,times+n);
double maxTimeDifference=*std::max_element(maxTimeDifferences.begin(),maxTimeDifferences.end());
double timeMin = *std::min_element(times.begin(),times.end());
double timeMax = *std::max_element(times.begin(),times.end());
if(timeMax-timeMin>maxTimeDifference) return; //hits don't fall within the time window
}
else
{
double timeMaxPulseStart = *std::max_element(timesPulseStart,timesPulseStart+n);
double timeMinPulseEnd = *std::min_element(timesPulseEnd,timesPulseEnd+n);
double timeMaxPulseStart = *std::max_element(timesPulseStart.begin(),timesPulseStart.end());
double timeMinPulseEnd = *std::min_element(timesPulseEnd.begin(),timesPulseEnd.end());
if(timeMinPulseEnd-timeMaxPulseStart<_minOverlapTime) return; //pulses don't overlap, or overlap time too short
}

Expand Down
9 changes: 5 additions & 4 deletions CRVResponse/src/CrvCoincidenceFinder_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "Offline/CosmicRayShieldGeom/inc/CosmicRayShield.hh"
#include "Offline/DataProducts/inc/CRSScintillatorBarIndex.hh"
#include "Offline/DataProducts/inc/CRVId.hh"

#include "Offline/GeometryService/inc/GeomHandle.hh"
#include "Offline/GeometryService/inc/GeometryService.hh"
Expand All @@ -22,6 +23,7 @@
#include "fhiclcpp/types/Sequence.h"

#include <string>
#include <array>

namespace mu2e
{
Expand Down Expand Up @@ -159,7 +161,6 @@ namespace mu2e
void checkCoincidence(const std::vector<CrvHit> &hits, std::list<CrvHit> &coincidenceHits);
bool checkCombination(std::vector<CrvHit>::const_iterator layerIterators[], int n);

constexpr static const int nLayers = 4;
};

CrvCoincidenceFinder::CrvCoincidenceFinder(const Parameters& conf) :
Expand Down Expand Up @@ -578,7 +579,7 @@ namespace mu2e
{
if(hits.empty()) return;

std::vector<CrvHit> hitsLayers[nLayers]; //separated by layers
std::vector<CrvHit> hitsLayers[CRVId::nLayers]; //separated by layers
std::vector<CrvHit>::const_iterator iterHit;
for(iterHit=hits.begin(); iterHit!=hits.end(); ++iterHit)
{
Expand All @@ -602,7 +603,7 @@ namespace mu2e
//this cluster has so many hits that it makes no sense anymore to search for individual coincidences.
//we still need to check that the minimum number of layers were hit to skip the coincidence check.
int nonEmptyLayers=0;
for(int iLayer=0; iLayer<nLayers; ++iLayer)
for(size_t iLayer=0; iLayer<CRVId::nLayers; ++iLayer)
{
if(!hitsLayers[iLayer].empty()) ++nonEmptyLayers;
}
Expand Down Expand Up @@ -757,7 +758,7 @@ namespace mu2e
[](L &a, L &b){return a->_maxSlope < b->_maxSlope;}))->_maxSlope;
double maxSlopeDifference = (*std::max_element(layerIterators,layerIterators+n,
[](L &a, L &b){return a->_maxSlopeDifference < b->_maxSlopeDifference;}))->_maxSlopeDifference;
double slopes[n-1];
std::array<double,CRVId::nLayers-1> slopes;
for(int d=0; d<n-1; ++d)
{
//slope = width direction / thickness direction
Expand Down
1 change: 1 addition & 0 deletions DataProducts/inc/CRVId.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace mu2e {
constexpr static std::size_t nChanPerBar = 4;
// some bars have only 2 SiPMs so this count is sparse
constexpr static std::size_t nChannels = nBars*nChanPerBar;
constexpr static std::size_t nLayers = 4;
// not all the implied possible channels below are active
// these are the dimensions of sparse containers
constexpr static std::size_t nChanPerFEB = 64;
Expand Down
2 changes: 1 addition & 1 deletion GeometryService/inc/CosmicRayShieldMaker.hh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace mu2e
int isector,
const std::string &name,
const CLHEP::Hep3Vector &firstCounter,
const CLHEP::Hep3Vector *layerOffsets,
const std::vector<CLHEP::Hep3Vector> &layerOffsets,
const CLHEP::Hep3Vector &VTNCSmallGap,
const CLHEP::Hep3Vector &VTNCLargeGap,
const CLHEP::Hep3Vector &VTNCBetweenModules,
Expand Down
4 changes: 2 additions & 2 deletions GeometryService/src/CosmicRayShieldMaker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ namespace mu2e
const int isector,
const std::string &name,
const CLHEP::Hep3Vector &firstCounter,
const CLHEP::Hep3Vector *layerOffsets,
const std::vector<CLHEP::Hep3Vector> &layerOffsets,
const CLHEP::Hep3Vector &VTNCSmallGap,
const CLHEP::Hep3Vector &VTNCLargeGap,
const CLHEP::Hep3Vector &VTNCBetweenModules,
Expand Down Expand Up @@ -357,7 +357,7 @@ namespace mu2e
counterHalfLengths[thicknessDirection]=_counterThickness/2.0;
counterHalfLengths[widthDirection]=_counterWidth/2.0;

CLHEP::Hep3Vector layerOffsets[_nLayers];
std::vector<CLHEP::Hep3Vector> layerOffsets(_nLayers);
layerOffsets[0].set(0,0,0);
for(int j=1; j<_nLayers; j++)
{
Expand Down

0 comments on commit 715e270

Please sign in to comment.