10 #include <ecl/modules/eclCRFinder/ECLCRFinderModule.h>
13 #include <framework/core/Environment.h>
14 #include <framework/gearbox/Unit.h>
15 #include <framework/logging/LogConfig.h>
16 #include <framework/logging/Logger.h>
19 #include <ecl/geometry/ECLNeighbours.h>
20 #include <ecl/dataobjects/ECLCalDigit.h>
21 #include <ecl/dataobjects/ECLConnectedRegion.h>
24 #include <mdst/dataobjects/EventLevelClusteringInfo.h>
42 m_eclConnectedRegions(eclConnectedRegionArrayName()), m_eventLevelClusteringInfo(eventLevelClusteringInfoName())
45 setDescription(
"ECLCRFinderModule");
48 setPropertyFlags(c_ParallelProcessingCertified);
51 addParam(
"energyCut0", m_energyCut[0],
"Seed energy cut.", 10.0 *
Belle2::Unit::MeV);
52 addParam(
"energyCut1", m_energyCut[1],
"Growth energy cut.", 10.0 *
Belle2::Unit::MeV);
53 addParam(
"energyCut2", m_energyCut[2],
"Digit energy cut.", 0.5 *
Belle2::Unit::MeV);
54 addParam(
"energyCutBkgd0", m_energyCutBkgd[0],
"Seed energy cut (for high background).", 10.0 *
Belle2::Unit::MeV);
55 addParam(
"energyCutBkgd1", m_energyCutBkgd[1],
"Growth energy cut (for high background).", 10.0 *
Belle2::Unit::MeV);
56 addParam(
"energyCutBkgd2", m_energyCutBkgd[2],
"Digit energy cut (for high background).", 0.5 *
Belle2::Unit::MeV);
57 addParam(
"timeCut0", m_timeCut[0],
"Seed time cut (negative values for residual cut).", 99999.);
58 addParam(
"timeCut1", m_timeCut[1],
"Growth time cut (negative values for residual cut).", 99999.);
59 addParam(
"timeCut2", m_timeCut[2],
"Digit time cut (negative values for residual cut).", 99999.);
60 addParam(
"mapType0", m_mapType[0],
"Map type for seed crystals.", std::string(
"N"));
61 addParam(
"mapType1", m_mapType[1],
"Map type for growth crystals.", std::string(
"N"));
62 addParam(
"mapPar0", m_mapPar[0],
63 "Map parameter for seed crystals (radius (type=R), integer (for type=N) or fraction (for type=MC)).", 1.0);
64 addParam(
"mapPar1", m_mapPar[1],
65 "Map parameter for growth crystals (radius (type=R), integer (for type=N) or fraction (for type=MC)).", 1.0);
66 addParam(
"useBackgroundLevel", m_useBackgroundLevel,
"Use background dependent time and energy cuts.", 0);
67 addParam(
"skipFailedTimeFitDigits", m_skipFailedTimeFitDigits,
"Digits with failed fits are skipped when checking timing cuts.", 0);
68 addParam(
"fullBkgdCount", m_fullBkgdCount,
"Full background count (via eventLevelClusteringInfo).", 182);
79 B2DEBUG(200,
"ECLCRFinderModule::initialize()");
90 if (
m_energyCut[0] <
m_energyCut[1]) B2FATAL(
"ECLCRFinderModule::initialize(): m_energyCut[0] must be larger than m_energyCut[1].");
91 if (
m_energyCut[1] <
m_energyCut[2]) B2FATAL(
"ECLCRFinderModule::initialize(): m_energyCut[1] must be larger than m_energyCut[2].");
92 if (
m_energyCut[0] <
m_energyCut[2]) B2FATAL(
"ECLCRFinderModule::initialize(): m_energyCut[0] must be larger than m_energyCut[2].");
95 B2FATAL(
"ECLCRFinderModule::initialize(): m_energyCutBkgd[0] must be larger than m_energyCutBkgd[1].");
98 B2FATAL(
"ECLCRFinderModule::initialize(): m_energyCutBkgd[1] must be larger than m_energyCutBkgd[2].");
101 B2FATAL(
"ECLCRFinderModule::initialize(): m_energyCutBkgd[0] must be larger than m_energyCutBkgd[2].");
104 B2FATAL(
"ECLCRFinderModule::initialize(): m_energyCut[0] must be smaller than m_energyCutBkgd[0].");
107 B2FATAL(
"ECLCRFinderModule::initialize(): m_energyCut[1] must be smaller than m_energyCutBkgd[1].");
110 B2FATAL(
"ECLCRFinderModule::initialize(): m_energyCut[2] must be smaller than m_energyCutBkgd[2].");
118 for (
int i = 0; i < 3; i++) {
145 B2DEBUG(200,
"ECLCRFinderModule::event()");
176 B2DEBUG(175,
"ECLCRFinderModule::event(), Background count for this event: " << bkgdcount <<
" (expected for full bkgd: " <<
180 for (
int i = 0; i < 3; i++) {
182 B2DEBUG(200,
"ECLCRFinderModule::event(), Energy cut value m_energyCutMod[" << i <<
"] = " <<
m_energyCutMod[i] <<
183 ", without bkgd scale m_energyCut[" << i <<
"] = " <<
m_energyCut[i]);
190 const double energy = eclCalDigit.getEnergy();
191 const double time = eclCalDigit.getTime();
192 const double timeresolution = eclCalDigit.getTimeResolution();
193 const int cellid = eclCalDigit.getCellId();
194 const bool fitfailed = eclCalDigit.isFailedFit();
196 double timeresidual = 999.;
197 if (!fitfailed and fabs(timeresolution) > 1e-9) {
198 timeresidual = time / timeresolution;
213 B2DEBUG(250,
"ECLCRFinderModule::event(), adding 'seed digit' with cellid = " << cellid);
217 unsigned isGrowth = 0;
229 B2DEBUG(250,
"ECLCRFinderModule::event(), adding 'growth digit' with cellid = " << cellid);
243 B2DEBUG(250,
"ECLCRFinderModule::event(), adding 'digit' with cellid = " << cellid);
265 std::map< int, int > tempCRIdToCRIdMap;
266 std::map< int, int>::iterator tempCRIdToCRIdMapIterator;
274 if (tempCRIdToCRIdMapIterator == tempCRIdToCRIdMap.end()) {
282 for (
const auto& entry : tempCRIdToCRIdMap) {
283 int connectedRegionID = entry.second;
291 aCR->setCRId(connectedRegionID);
307 B2DEBUG(200,
"ECLCRFinderModule::endRun()");
313 B2DEBUG(200,
"ECLCRFinderModule::terminate()");
323 B2DEBUG(200,
"ECLCRFinderModule::checkNeighbours() type=" << type);
325 for (
const auto& neighbour :
m_neighbourMaps[type]->getNeighbours(cellid)) {
326 B2DEBUG(200,
"ECLCRFinderModule::checkNeighbours(): neighbour=" << neighbour);
335 B2DEBUG(300,
" --> ECLCRFinderModule::checkNeighbours(): tempcrid=" << tempcrid);
338 B2DEBUG(300,
" --> ECLCRFinderModule::checkNeighbours(): " << neighbour);
340 B2DEBUG(300,
" --> ECLCRFinderModule::checkNeighbours(): isAdded=" << isAdded);
346 B2DEBUG(300,
" --> ECLCRFinderModule::checkNeighbours(): m_cellIdToTempCRIdVec[" << neighbour <<
"] " <<
369 B2DEBUG(200,
"ECLCRFinderModule::updateCRs()");
Class to find connected regions.
double m_mapPar[2]
Parameters for neighbour maps.
double m_energyCutMod[3]
modified energy cut taking into account bkgd per event for seed, neighbours, ...
std::vector< int > m_cellIdToDigitVec
cellid -> above threshold digits.
virtual ~ECLCRFinderModule()
Destructor.
StoreArray< ECLConnectedRegion > m_eclConnectedRegions
Store array: ECLConnectedRegion.
double m_timeCut[3]
Time cut for seed, neighbours, ...
bool m_isOnlineProcessing
Other variables.
std::vector< int > m_cellIdToGrowthVec
cellid -> growth digits.
virtual void initialize() override
Initialize.
int m_useBackgroundLevel
Background dependend energy and timing cuts.
std::map< int, int > m_cellIdToTempCRIdMap
cellid -> temporary CR.
double m_energyCut[3]
Energy cut for seed, neighbours, ...
std::vector< int > m_cellIdToCheckVec
Digit vectors.
virtual void event() override
Event.
std::vector< int > m_cellIdToSeedVec
cellid -> seed digit.
int m_tempCRId
Temporary CR ID.
void updateCRs(int cellid, int tempcr)
Update CRs.
virtual void endRun() override
End run.
virtual void terminate() override
Terminate (close ROOT files here if you have opened any).
std::vector< int > m_cellIdToTempCRIdVec
Connected Region map.
int m_skipFailedTimeFitDigits
Handling of digits with failed time fits.
std::vector< int > m_calDigitStoreArrPosition
vector (8736+1 entries) with cell id to store array positions
virtual void beginRun() override
Begin.
int m_fullBkgdCount
Number of expected background digits at full background.
virtual const char * eventLevelClusteringInfoName() const
Name to be used for default option: EventLevelClusteringInfo.
std::vector< ECL::ECLNeighbours * > m_neighbourMaps
Neighbour maps.
std::string m_mapType[2]
Neighbour map types.
double m_energyCutBkgd[3]
Energy cut (for high background) for seed, neighbours, ...
virtual const char * eclCalDigitArrayName() const
Name to be used for default or PureCsI option: ECLCalDigits.
void checkNeighbours(const int cellid, const int tempcrid, const int type)
Neighbour finder.
StoreObjPtr< EventLevelClusteringInfo > m_eventLevelClusteringInfo
Store object pointer: EventLevelClusteringInfo.
StoreArray< ECLCalDigit > m_eclCalDigits
Store array: ECLCalDigit.
virtual const char * eclConnectedRegionArrayName() const
Name to be used for default option: ECLConnectedRegions.
Class to get the neighbours for a given cell id.
static Environment & Instance()
Static method to get a reference to the Environment instance.
LogConfig::ELogRealm getRealm() const
Get the basf2 execution realm.
@ c_Online
Online data taking.
static const double MeV
[megaelectronvolt]
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.