Skip to content

Commit

Permalink
Merged refs/pull/17490/head from repository cms-sw
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlange6 committed Feb 27, 2017
2 parents d5fdb16 + b3f9875 commit 620eee0
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 81 deletions.
2 changes: 1 addition & 1 deletion SimCalorimetry/CaloSimAlgos/interface/CaloHitResponse.h
Expand Up @@ -58,7 +58,7 @@ class CaloHitResponse
virtual void finalizeHits(CLHEP::HepRandomEngine*) {}

/// Complete cell digitization.
virtual void run(MixCollection<PCaloHit> & hits, CLHEP::HepRandomEngine*);
virtual void run(const MixCollection<PCaloHit> & hits, CLHEP::HepRandomEngine*);

/// process a single SimHit
virtual void add(const PCaloHit & hit, CLHEP::HepRandomEngine*);
Expand Down
2 changes: 1 addition & 1 deletion SimCalorimetry/CaloSimAlgos/src/CaloHitResponse.cc
Expand Up @@ -58,7 +58,7 @@ void CaloHitResponse::setBunchRange(int minBunch, int maxBunch) {
theMaxBunch = maxBunch;
}

void CaloHitResponse::run(MixCollection<PCaloHit> & hits, CLHEP::HepRandomEngine* engine) {
void CaloHitResponse::run(const MixCollection<PCaloHit> & hits, CLHEP::HepRandomEngine* engine) {

for(MixCollection<PCaloHit>::MixItr hitItr = hits.begin();
hitItr != hits.end(); ++hitItr) {
Expand Down
20 changes: 10 additions & 10 deletions SimDataFormats/CrossingFrame/interface/MixCollection.h
Expand Up @@ -65,7 +65,7 @@ class MixCollection {
/** constructors */
MixItr():first_(true), internalCtr_(0) {;}
MixItr(typename std::vector<const T *>::const_iterator it) : pMixItr_(it),nrDets_(0),first_(true),internalCtr_(0) {;}
MixItr(MixCollection *shc, int nrDets) :
MixItr(const MixCollection *shc, int nrDets) :
mixCol_(shc),nrDets_(nrDets),first_(true),iSignal_(0),iPileup_(0),internalCtr_(0) {;}


Expand All @@ -76,8 +76,8 @@ class MixCollection {
// default version valid for HepMCProduct
const T* operator->() const { return *(pMixItr_.operator->()); }
const T& operator*() const {return *(pMixItr_.operator*()); }
MixItr operator++ () {return next();}
MixItr operator++ (int) {return next();}
const MixItr operator++ () {return next();}
const MixItr operator++ (int) {return next();}
bool operator!= (const MixItr& itr){return pMixItr_!=itr.pMixItr_;}

/**getters*/
Expand All @@ -98,23 +98,23 @@ class MixCollection {
typename std::vector<const T *>::const_iterator pMixItrEnd_;

const CrossingFrame<T> * myCF_;
MixCollection *mixCol_;
const MixCollection *mixCol_;
int nrDets_;
bool first_;
int iSignal_, iPileup_;
bool trigger_;
unsigned int internalCtr_; //this is the internal counter pointing into the vector of piled up objects

MixItr next();
const MixItr next();
void reset() {;}
bool getNewSignal(typename std::vector<const T *>::const_iterator &first,typename std::vector<const T *>::const_iterator &last);

bool getNewPileups(typename std::vector<const T *>::const_iterator &first,typename std::vector<const T *>::const_iterator &last) ;
};

typedef MixItr iterator;
iterator begin();
iterator end() ;
iterator begin() const;
iterator end() const;

private:
void init( const range bunchRange);
Expand Down Expand Up @@ -235,7 +235,7 @@ bool MixCollection<T>::MixItr::getNewPileups(typename std::vector<const T*>::co
}

template <class T>
typename MixCollection<T>::MixItr MixCollection<T>::MixItr::next() {
const typename MixCollection<T>::MixItr MixCollection<T>::MixItr::next() {

// initialisation
if (first_) {
Expand Down Expand Up @@ -268,12 +268,12 @@ typename MixCollection<T>::MixItr MixCollection<T>::MixItr::next() {
}

template <class T>
typename MixCollection<T>::MixItr MixCollection<T>::begin() {
typename MixCollection<T>::MixItr MixCollection<T>::begin() const {
return MixItr(this,nrDets_)++;
}

template <class T>
typename MixCollection<T>::MixItr MixCollection<T >::end() {
typename MixCollection<T>::MixItr MixCollection<T >::end() const {
typename std::vector<const T *>::const_iterator first;
typename std::vector<const T*>::const_iterator last;
crossingFrames_[nrDets_-1]->getPileups(first, last);
Expand Down
Expand Up @@ -160,7 +160,7 @@ void endRun(const edm::Run& r, const edm::EventSetup& c) override;
CaloHitResponse * theEBResponse;
CaloHitResponse * theEEResponse;

void computeSDBunchDigi(const edm::EventSetup & eventSetup, MixCollection<PCaloHit> & theHits, MapType & ebSignalSimMap, const EcalSubdetector & thisDet, const double & theSimThreshold, CLHEP::HepRandomEngine*);
void computeSDBunchDigi(const edm::EventSetup & eventSetup, const MixCollection<PCaloHit> & theHits, MapType & ebSignalSimMap, const EcalSubdetector & thisDet, const double & theSimThreshold, CLHEP::HepRandomEngine*);

void bunchSumTest(std::vector<MonitorElement *> & theBunches, MonitorElement* & theTotal, MonitorElement* & theRatio, int nSample);

Expand Down
22 changes: 9 additions & 13 deletions Validation/EcalDigis/src/EcalDigisValidation.cc
Expand Up @@ -213,13 +213,12 @@ void EcalDigisValidation::analyze(edm::Event const & e, edm::EventSetup const &
if ( isBarrel ) {

e.getByToken( crossingFramePCaloHitEBToken_, crossingFrame );
std::auto_ptr<MixCollection<PCaloHit> >
barrelHits( new MixCollection<PCaloHit>( crossingFrame.product() ) );
const MixCollection<PCaloHit> &barrelHits = crossingFrame.product();

MapType ebSimMap;

for (MixCollection<PCaloHit>::MixItr hitItr = barrelHits->begin () ;
hitItr != barrelHits->end () ;
for (MixCollection<PCaloHit>::MixItr hitItr = barrelHits.begin () ;
hitItr != barrelHits.end () ;
++hitItr) {

EBDetId ebid = EBDetId(hitItr->id()) ;
Expand Down Expand Up @@ -306,13 +305,12 @@ void EcalDigisValidation::analyze(edm::Event const & e, edm::EventSetup const &
if ( isEndcap ) {

e.getByToken( crossingFramePCaloHitEEToken_, crossingFrame );
std::auto_ptr<MixCollection<PCaloHit> >
endcapHits( new MixCollection<PCaloHit>( crossingFrame.product() ) );
const MixCollection<PCaloHit> &endcapHits = crossingFrame.product();

MapType eeSimMap;

for (MixCollection<PCaloHit>::MixItr hitItr = endcapHits->begin () ;
hitItr != endcapHits->end () ;
for (MixCollection<PCaloHit>::MixItr hitItr = endcapHits.begin () ;
hitItr != endcapHits.end () ;
++hitItr) {

EEDetId eeid = EEDetId(hitItr->id()) ;
Expand Down Expand Up @@ -393,11 +391,9 @@ void EcalDigisValidation::analyze(edm::Event const & e, edm::EventSetup const &
if ( isPreshower) {

e.getByToken( crossingFramePCaloHitESToken_, crossingFrame );
std::auto_ptr<MixCollection<PCaloHit> >
preshowerHits (new MixCollection<PCaloHit>(crossingFrame.product ()));

for (MixCollection<PCaloHit>::MixItr hitItr = preshowerHits->begin () ;
hitItr != preshowerHits->end () ;
const MixCollection<PCaloHit> &preshowerHits = crossingFrame.product();
for (MixCollection<PCaloHit>::MixItr hitItr = preshowerHits.begin () ;
hitItr != preshowerHits.end () ;
++hitItr) {

ESDetId esid = ESDetId(hitItr->id()) ;
Expand Down
32 changes: 14 additions & 18 deletions Validation/EcalDigis/src/EcalMixingModuleValidation.cc
Expand Up @@ -358,15 +358,14 @@ void EcalMixingModuleValidation::analyze(edm::Event const & e, edm::EventSetup c
if ( isBarrel ) {

e.getByToken( crossingFramePCaloHitEBToken_, crossingFrame );
std::auto_ptr<MixCollection<PCaloHit> >
barrelHits (new MixCollection<PCaloHit>(crossingFrame.product ()));
const MixCollection<PCaloHit> &barrelHits = crossingFrame.product();

MapType ebSignalSimMap;

double ebSimThreshold = 0.5*theGunEnergy;

for (MixCollection<PCaloHit>::MixItr hitItr = barrelHits->begin () ;
hitItr != barrelHits->end () ;
for (MixCollection<PCaloHit>::MixItr hitItr = barrelHits.begin () ;
hitItr != barrelHits.end () ;
++hitItr) {

EBDetId ebid = EBDetId(hitItr->id()) ;
Expand Down Expand Up @@ -448,7 +447,7 @@ void EcalMixingModuleValidation::analyze(edm::Event const & e, edm::EventSetup c
}

EcalSubdetector thisDet = EcalBarrel;
computeSDBunchDigi(c, *barrelHits, ebSignalSimMap, thisDet, ebSimThreshold, randomEngine(e.streamID()));
computeSDBunchDigi(c, barrelHits, ebSignalSimMap, thisDet, ebSimThreshold, randomEngine(e.streamID()));
}


Expand All @@ -459,15 +458,13 @@ void EcalMixingModuleValidation::analyze(edm::Event const & e, edm::EventSetup c
if ( isEndcap ) {

e.getByToken( crossingFramePCaloHitEEToken_, crossingFrame );
std::auto_ptr<MixCollection<PCaloHit> >
endcapHits (new MixCollection<PCaloHit>(crossingFrame.product ()));

const MixCollection<PCaloHit> &endcapHits = crossingFrame.product();
MapType eeSignalSimMap;

double eeSimThreshold = 0.4*theGunEnergy;

for (MixCollection<PCaloHit>::MixItr hitItr = endcapHits->begin () ;
hitItr != endcapHits->end () ;
for (MixCollection<PCaloHit>::MixItr hitItr = endcapHits.begin () ;
hitItr != endcapHits.end () ;
++hitItr) {

EEDetId eeid = EEDetId(hitItr->id()) ;
Expand Down Expand Up @@ -548,19 +545,18 @@ void EcalMixingModuleValidation::analyze(edm::Event const & e, edm::EventSetup c
}

EcalSubdetector thisDet = EcalEndcap;
computeSDBunchDigi(c, *endcapHits, eeSignalSimMap, thisDet, eeSimThreshold, randomEngine(e.streamID()));
computeSDBunchDigi(c, endcapHits, eeSignalSimMap, thisDet, eeSimThreshold, randomEngine(e.streamID()));
}

if ( isPreshower) {

e.getByToken(crossingFramePCaloHitESToken_, crossingFrame );
std::auto_ptr<MixCollection<PCaloHit> >
preshowerHits (new MixCollection<PCaloHit>(crossingFrame.product ()));

const MixCollection<PCaloHit> &preshowerHits = crossingFrame.product();

MapType esSignalSimMap;

for (MixCollection<PCaloHit>::MixItr hitItr = preshowerHits->begin () ;
hitItr != preshowerHits->end () ;
for (MixCollection<PCaloHit>::MixItr hitItr = preshowerHits.begin () ;
hitItr != preshowerHits.end () ;
++hitItr) {

ESDetId esid = ESDetId(hitItr->id()) ;
Expand Down Expand Up @@ -625,7 +621,7 @@ void EcalMixingModuleValidation::analyze(edm::Event const & e, edm::EventSetup c
}

EcalSubdetector thisDet = EcalPreshower;
computeSDBunchDigi(c, *preshowerHits, esSignalSimMap, thisDet, esThreshold_, randomEngine(e.streamID()));
computeSDBunchDigi(c, preshowerHits, esSignalSimMap, thisDet, esThreshold_, randomEngine(e.streamID()));

}

Expand Down Expand Up @@ -724,7 +720,7 @@ void EcalMixingModuleValidation::findPedestal(const DetId & detId, int gainId, d
}
}

void EcalMixingModuleValidation::computeSDBunchDigi(const edm::EventSetup & eventSetup, MixCollection<PCaloHit> & theHits, MapType & SignalSimMap, const EcalSubdetector & thisDet, const double & theSimThreshold, CLHEP::HepRandomEngine* engine)
void EcalMixingModuleValidation::computeSDBunchDigi(const edm::EventSetup & eventSetup, const MixCollection<PCaloHit> & theHits, MapType & SignalSimMap, const EcalSubdetector & thisDet, const double & theSimThreshold, CLHEP::HepRandomEngine* engine)
{

if ( thisDet != EcalBarrel && thisDet != EcalEndcap && thisDet != EcalPreshower ) {
Expand Down
15 changes: 6 additions & 9 deletions Validation/EcalRecHits/src/EcalRecHitsValidation.cc
Expand Up @@ -344,8 +344,7 @@ void EcalRecHitsValidation::analyze(const Event& e, const EventSetup& c){

// 1) loop over simHits
e.getByToken(EBHits_Token_,crossingFrame);
std::auto_ptr<MixCollection<PCaloHit> >
barrelHits (new MixCollection<PCaloHit>(crossingFrame.product ()));
const MixCollection<PCaloHit> &barrelHits = crossingFrame.product();

MapType ebSimMap;
MapType ebRecMap;
Expand All @@ -355,7 +354,7 @@ void EcalRecHitsValidation::analyze(const Event& e, const EventSetup& c){
for( int i=0; i<ebcSize; i++ ) { ebcontr[i] = 0.0; ebcontr25[i] = 0.0; }
double ebtotal = 0.;

for (MixCollection<PCaloHit>::MixItr hitItr = barrelHits->begin (); hitItr != barrelHits->end (); ++hitItr) {
for (MixCollection<PCaloHit>::MixItr hitItr = barrelHits.begin (); hitItr != barrelHits.end (); ++hitItr) {
EBDetId ebid = EBDetId(hitItr->id());

LogDebug("SimHitInfo, barrel")
Expand Down Expand Up @@ -494,8 +493,7 @@ void EcalRecHitsValidation::analyze(const Event& e, const EventSetup& c){

// 1) loop over simHits
e.getByToken(EEHits_Token_,crossingFrame);
std::auto_ptr<MixCollection<PCaloHit> >
endcapHits (new MixCollection<PCaloHit>(crossingFrame.product ()));
const MixCollection<PCaloHit> &endcapHits=crossingFrame.product();

MapType eeSimMap;
MapType eeRecMap;
Expand All @@ -505,7 +503,7 @@ void EcalRecHitsValidation::analyze(const Event& e, const EventSetup& c){
for( int i=0; i<eecSize; i++ ) { eecontr[i] = 0.0; eecontr25[i] = 0.0; }
double eetotal = 0.;

for (MixCollection<PCaloHit>::MixItr hitItr = endcapHits->begin(); hitItr != endcapHits->end(); ++hitItr) {
for (MixCollection<PCaloHit>::MixItr hitItr = endcapHits.begin(); hitItr != endcapHits.end(); ++hitItr) {
EEDetId eeid = EEDetId(hitItr->id()) ;

LogDebug("Endcap, HitInfo")
Expand Down Expand Up @@ -633,8 +631,7 @@ void EcalRecHitsValidation::analyze(const Event& e, const EventSetup& c){

// 1) loop over simHits
e.getByToken(ESHits_Token_,crossingFrame);
std::auto_ptr<MixCollection<PCaloHit> >
preshowerHits (new MixCollection<PCaloHit>(crossingFrame.product ()));
const MixCollection<PCaloHit> & preshowerHits = crossingFrame.product();

MapType esSimMap;
const int escSize = 90;
Expand All @@ -643,7 +640,7 @@ void EcalRecHitsValidation::analyze(const Event& e, const EventSetup& c){
double estotal = 0.;


for (MixCollection<PCaloHit>::MixItr hitItr = preshowerHits->begin(); hitItr != preshowerHits->end(); ++hitItr) {
for (MixCollection<PCaloHit>::MixItr hitItr = preshowerHits.begin(); hitItr != preshowerHits.end(); ++hitItr) {
ESDetId esid = ESDetId(hitItr->id()) ;

LogDebug("Preshower, HitInfo")
Expand Down
21 changes: 9 additions & 12 deletions Validation/GlobalDigis/src/GlobalDigisAnalyzer.cc
Expand Up @@ -550,13 +550,12 @@ void GlobalDigisAnalyzer::fillECal(const edm::Event& iEvent,
validXFrame = false;
}
if (validXFrame) {
std::auto_ptr<MixCollection<PCaloHit> >
barrelHits(new MixCollection<PCaloHit>(crossingFrame.product()));
const MixCollection<PCaloHit> & barrelHits = crossingFrame.product();

// keep track of sum of simhit energy in each crystal
for (MixCollection<PCaloHit>::MixItr hitItr
= barrelHits->begin();
hitItr != barrelHits->end();
= barrelHits.begin();
hitItr != barrelHits.end();
++hitItr) {

EBDetId ebid = EBDetId(hitItr->id());
Expand Down Expand Up @@ -676,13 +675,12 @@ void GlobalDigisAnalyzer::fillECal(const edm::Event& iEvent,
validXFrame = false;
}
if (validXFrame) {
std::auto_ptr<MixCollection<PCaloHit> >
endcapHits(new MixCollection<PCaloHit>(crossingFrame.product()));
const MixCollection<PCaloHit> &endcapHits = crossingFrame.product();

// keep track of sum of simhit energy in each crystal
for (MixCollection<PCaloHit>::MixItr hitItr
= endcapHits->begin();
hitItr != endcapHits->end();
= endcapHits.begin();
hitItr != endcapHits.end();
++hitItr) {

EEDetId eeid = EEDetId(hitItr->id());
Expand Down Expand Up @@ -807,14 +805,13 @@ void GlobalDigisAnalyzer::fillECal(const edm::Event& iEvent,
validXFrame = false;
}
if (validXFrame) {
std::auto_ptr<MixCollection<PCaloHit> >
preshowerHits(new MixCollection<PCaloHit>(crossingFrame.product()));
const MixCollection<PCaloHit> & preshowerHits = crossingFrame.product();

// keep track of sum of simhit energy in each crystal
MapType esSimMap;
for (MixCollection<PCaloHit>::MixItr hitItr
= preshowerHits->begin();
hitItr != preshowerHits->end();
= preshowerHits.begin();
hitItr != preshowerHits.end();
++hitItr) {

ESDetId esid = ESDetId(hitItr->id());
Expand Down

0 comments on commit 620eee0

Please sign in to comment.