diff --git a/include/OverlayTiming.h b/include/OverlayTiming.h index 24fc31a..5ba89e3 100644 --- a/include/OverlayTiming.h +++ b/include/OverlayTiming.h @@ -147,6 +147,8 @@ namespace overlay { float _tpcVdrift_mm_ns = 5.0e-2 ; bool _randomBX = false, _Poisson = false; + bool _checkMCC = true; + typedef std::map DestMap; typedef std::map CollDestMap; CollDestMap collDestMap{}; diff --git a/src/OverlayTiming.cc b/src/OverlayTiming.cc index c85c766..f306e81 100644 --- a/src/OverlayTiming.cc +++ b/src/OverlayTiming.cc @@ -263,6 +263,12 @@ namespace overlay { m_startWithBackgroundEvent); + // processo MCContribution + registerProcessorParameter("ProcessMCContribution", + "Merging the SimCaloHits check if the MCContributions already exist", + _checkMCC, + bool(true) ); + } //------------------------------------------------------------------------------------------------------------------------------------------ @@ -551,7 +557,7 @@ namespace overlay { delete permutation; ++_nEvt; - //we clear the map of calorimeter hits for the next event + // we clear the map of calorimeter hits for the next event collDestMap.clear(); const std::vector *collection_names_in_evt = evt->getCollectionNames(); @@ -560,9 +566,8 @@ namespace overlay { streamlog_out(DEBUG) << "Collection " << collection_names_in_evt->at(i) << " has now " << evt->getCollection(collection_names_in_evt->at(i))->getNumberOfElements() << " elements" << std::endl; } - // reset pointer + // reset pointer at end overlay_Evt = nullptr; - } //------------------------------------------------------------------------------------------------------------------------------------------ @@ -794,7 +799,7 @@ namespace overlay { { SimCalorimeterHit *CalorimeterHit = static_cast(source_collection->getElementAt(k)); const float _time_of_flight = time_of_flight(CalorimeterHit->getPosition()[0], CalorimeterHit->getPosition()[1], CalorimeterHit->getPosition()[2]); - + float nullStep[3] = { 0.,0.,0. } ; //check whether there is already a hit at this position const unsigned long long lookfor = cellID2long(CalorimeterHit->getCellID0(), CalorimeterHit->getCellID1()); DestMap::const_iterator destMapIt = collDestMap[currentDest].find(lookfor); @@ -809,7 +814,10 @@ namespace overlay { if (((CalorimeterHit->getTimeCont(j) + time_offset) > (this_start + _time_of_flight)) && ((CalorimeterHit->getTimeCont(j) + time_offset) < (this_stop + _time_of_flight))) { add_Hit = true; - newCalorimeterHit->addMCParticleContribution(CalorimeterHit->getParticleCont(j), CalorimeterHit->getEnergyCont(j), CalorimeterHit->getTimeCont(j) + time_offset); + if ( _checkMCC ) + newCalorimeterHit->addMCParticleContribution(CalorimeterHit->getParticleCont(j), CalorimeterHit->getEnergyCont(j), CalorimeterHit->getTimeCont(j) + time_offset); + else + newCalorimeterHit->addMCParticleContribution(CalorimeterHit->getParticleCont(j), CalorimeterHit->getEnergyCont(j), CalorimeterHit->getTimeCont(j) + time_offset, 0, 0, nullStep); } } if (add_Hit) @@ -862,7 +870,11 @@ namespace overlay { { if (((CalorimeterHit->getTimeCont(j) + time_offset) > (this_start + _time_of_flight)) && ((CalorimeterHit->getTimeCont(j) + time_offset) < (this_stop + _time_of_flight))) { - newCalorimeterHit->addMCParticleContribution(CalorimeterHit->getParticleCont(j), CalorimeterHit->getEnergyCont(j), CalorimeterHit->getTimeCont(j) + time_offset); + if ( _checkMCC ) + newCalorimeterHit->addMCParticleContribution(CalorimeterHit->getParticleCont(j), CalorimeterHit->getEnergyCont(j), CalorimeterHit->getTimeCont(j) + time_offset); + else + newCalorimeterHit->addMCParticleContribution(CalorimeterHit->getParticleCont(j), CalorimeterHit->getEnergyCont(j), CalorimeterHit->getTimeCont(j) + time_offset, 0, 0, nullStep); + } } } diff --git a/src/OverlayTimingGeneric.cc b/src/OverlayTimingGeneric.cc index da76093..60e3e89 100644 --- a/src/OverlayTimingGeneric.cc +++ b/src/OverlayTimingGeneric.cc @@ -100,6 +100,12 @@ OverlayTimingGeneric::OverlayTimingGeneric(): OverlayTiming("OverlayTimingGeneri "Starting integration time. Should be shortly before the BX, but may need to be shifted earlier if the vertex is smeared in time.", _DefaultStart_int, float(-0.25)); + // processo MCContribution + registerProcessorParameter("ProcessMCContribution", + "Merging the SimCaloHits check if the MCContributions already exist", + _checkMCC, + bool(true) ); + } void OverlayTimingGeneric::init()