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

change MixItr to be const to avoid newing Crossingframe products #17640

Merged
merged 4 commits into from Feb 28, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
64 changes: 26 additions & 38 deletions Validation/EcalDigis/src/EcalDigisValidation.cc
Expand Up @@ -213,26 +213,22 @@ 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 () ;
++hitItr) {
for ( auto const & iHit : barrelHits ) {

EBDetId ebid = EBDetId(hitItr->id()) ;
EBDetId ebid = EBDetId(iHit.id()) ;

LogDebug("HitInfo")
<< " CaloHit " << hitItr->getName() << "\n"
<< " DetID = " << hitItr->id()<< " EBDetId = " << ebid.ieta() << " " << ebid.iphi() << "\n"
<< " Time = " << hitItr->time() << " Event id. = " << hitItr->eventId().rawId() << "\n"
<< " Track Id = " << hitItr->geantTrackId() << "\n"
<< " Energy = " << hitItr->energy();
<< " CaloHit " << iHit.getName() << "\n"
<< " DetID = " << iHit.id()<< " EBDetId = " << ebid.ieta() << " " << ebid.iphi() << "\n"
<< " Time = " << iHit.time() << " Event id. = " << iHit.eventId().rawId() << "\n"
<< " Track Id = " << iHit.geantTrackId() << "\n"
<< " Energy = " << iHit.energy();

uint32_t crystid = ebid.rawId();
ebSimMap[crystid] += hitItr->energy();
ebSimMap[crystid] += iHit.energy();

}

Expand Down Expand Up @@ -306,26 +302,22 @@ 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 () ;
++hitItr) {
for ( auto const & iHit : endcapHits ) {

EEDetId eeid = EEDetId(hitItr->id()) ;
EEDetId eeid = EEDetId(iHit.id()) ;

LogDebug("HitInfo")
<< " CaloHit " << hitItr->getName() << "\n"
<< " DetID = "<<hitItr->id()<< " EEDetId side = " << eeid.zside() << " = " << eeid.ix() << " " << eeid.iy() << "\n"
<< " Time = " << hitItr->time() << " Event id. = " << hitItr->eventId().rawId() << "\n"
<< " Track Id = " << hitItr->geantTrackId() << "\n"
<< " Energy = " << hitItr->energy();
<< " CaloHit " << iHit.getName() << "\n"
<< " DetID = "<<iHit.id()<< " EEDetId side = " << eeid.zside() << " = " << eeid.ix() << " " << eeid.iy() << "\n"
<< " Time = " << iHit.time() << " Event id. = " << iHit.eventId().rawId() << "\n"
<< " Track Id = " << iHit.geantTrackId() << "\n"
<< " Energy = " << iHit.energy();

uint32_t crystid = eeid.rawId();
eeSimMap[crystid] += hitItr->energy();
eeSimMap[crystid] += iHit.energy();

}

Expand Down Expand Up @@ -393,21 +385,17 @@ 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 () ;
++hitItr) {
const MixCollection<PCaloHit> preshowerHits(crossingFrame.product());
for ( auto const &iHit : preshowerHits ) {

ESDetId esid = ESDetId(hitItr->id()) ;
ESDetId esid = ESDetId(iHit.id()) ;

LogDebug("HitInfo")
<< " CaloHit " << hitItr->getName() << "\n"
<< " DetID = " << hitItr->id()<< "ESDetId: z side " << esid.zside() << " plane " << esid.plane() << esid.six() << ',' << esid.siy() << ':' << esid.strip() << "\n"
<< " Time = " << hitItr->time() << " Event id. = " << hitItr->eventId().rawId() << "\n"
<< " Track Id = " << hitItr->geantTrackId() << "\n"
<< " Energy = " << hitItr->energy();
<< " CaloHit " << iHit.getName() << "\n"
<< " DetID = " << iHit.id()<< "ESDetId: z side " << esid.zside() << " plane " << esid.plane() << esid.six() << ',' << esid.siy() << ':' << esid.strip() << "\n"
<< " Time = " << iHit.time() << " Event id. = " << iHit.eventId().rawId() << "\n"
<< " Track Id = " << iHit.geantTrackId() << "\n"
<< " Energy = " << iHit.energy();

}

Expand Down
82 changes: 36 additions & 46 deletions Validation/EcalDigis/src/EcalMixingModuleValidation.cc
Expand Up @@ -358,31 +358,28 @@ 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 () ;
++hitItr) {
for ( auto const &iHit : barrelHits ) {

EBDetId ebid = EBDetId(hitItr->id()) ;
EBDetId ebid = EBDetId(iHit.id()) ;

LogDebug("HitInfo")
<< " CaloHit " << hitItr->getName() << "\n"
<< " DetID = "<<hitItr->id()<< " EBDetId = " << ebid.ieta() << " " << ebid.iphi() << "\n"
<< " Time = " << hitItr->time() << " Event id. = " << hitItr->eventId().rawId() << "\n"
<< " Track Id = " << hitItr->geantTrackId() << "\n"
<< " Energy = " << hitItr->energy();
<< " CaloHit " << iHit.getName() << "\n"
<< " DetID = "<<iHit.id()<< " EBDetId = " << ebid.ieta() << " " << ebid.iphi() << "\n"
<< " Time = " << iHit.time() << " Event id. = " << iHit.eventId().rawId() << "\n"
<< " Track Id = " << iHit.geantTrackId() << "\n"
<< " Energy = " << iHit.energy();

uint32_t crystid = ebid.rawId();

if ( hitItr->eventId().rawId() == 0 ) ebSignalSimMap[crystid] += hitItr->energy();
if ( iHit.eventId().rawId() == 0 ) ebSignalSimMap[crystid] += iHit.energy();

if ( meEBbunchCrossing_ ) meEBbunchCrossing_->Fill(hitItr->eventId().bunchCrossing());
if ( meEBbunchCrossing_ ) meEBbunchCrossing_->Fill(iHit.eventId().bunchCrossing());

}

Expand Down Expand Up @@ -448,7 +445,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,31 +456,27 @@ 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 () ;
++hitItr) {
for ( auto const & iHit : endcapHits ) {

EEDetId eeid = EEDetId(hitItr->id()) ;
EEDetId eeid = EEDetId(iHit.id()) ;

LogDebug("HitInfo")
<< " CaloHit " << hitItr->getName() << "\n"
<< " DetID = "<<hitItr->id()<< " EEDetId side = " << eeid.zside() << " = " << eeid.ix() << " " << eeid.iy() << "\n"
<< " Time = " << hitItr->time() << " Event id. = " << hitItr->eventId().rawId() << "\n"
<< " Track Id = " << hitItr->geantTrackId() << "\n"
<< " Energy = " << hitItr->energy();
<< " CaloHit " << iHit.getName() << "\n"
<< " DetID = "<<iHit.id()<< " EEDetId side = " << eeid.zside() << " = " << eeid.ix() << " " << eeid.iy() << "\n"
<< " Time = " << iHit.time() << " Event id. = " << iHit.eventId().rawId() << "\n"
<< " Track Id = " << iHit.geantTrackId() << "\n"
<< " Energy = " << iHit.energy();

uint32_t crystid = eeid.rawId();

if ( hitItr->eventId().rawId() == 0 ) eeSignalSimMap[crystid] += hitItr->energy();
if ( iHit.eventId().rawId() == 0 ) eeSignalSimMap[crystid] += iHit.energy();

if ( meEEbunchCrossing_ ) meEEbunchCrossing_->Fill(hitItr->eventId().bunchCrossing());
if ( meEEbunchCrossing_ ) meEEbunchCrossing_->Fill(iHit.eventId().bunchCrossing());

}

Expand Down Expand Up @@ -548,35 +541,32 @@ 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 () ;
++hitItr) {

for ( auto const & iHit : preshowerHits ) {

ESDetId esid = ESDetId(hitItr->id()) ;
ESDetId esid = ESDetId(iHit.id()) ;

LogDebug("HitInfo")
<< " CaloHit " << hitItr->getName() << "\n"
<< " DetID = "<<hitItr->id()<< "ESDetId: z side " << esid.zside() << " plane " << esid.plane() << esid.six() << ',' << esid.siy() << ':' << esid.strip() << "\n"
<< " Time = " << hitItr->time() << " Event id. = " << hitItr->eventId().rawId() << "\n"
<< " Track Id = " << hitItr->geantTrackId() << "\n"
<< " Energy = " << hitItr->energy();
<< " CaloHit " << iHit.getName() << "\n"
<< " DetID = "<<iHit.id()<< "ESDetId: z side " << esid.zside() << " plane " << esid.plane() << esid.six() << ',' << esid.siy() << ':' << esid.strip() << "\n"
<< " Time = " << iHit.time() << " Event id. = " << iHit.eventId().rawId() << "\n"
<< " Track Id = " << iHit.geantTrackId() << "\n"
<< " Energy = " << iHit.energy();

uint32_t stripid = esid.rawId();

if ( hitItr->eventId().rawId() == 0 ) esSignalSimMap[stripid] += hitItr->energy();
if ( iHit.eventId().rawId() == 0 ) esSignalSimMap[stripid] += iHit.energy();

if ( meESbunchCrossing_ ) meESbunchCrossing_->Fill(hitItr->eventId().bunchCrossing());
if ( meESbunchCrossing_ ) meESbunchCrossing_->Fill(iHit.eventId().bunchCrossing());

// loop over Digis

Expand Down Expand Up @@ -625,7 +615,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 +714,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