10#include <ecl/modules/eclMuMuECollector/eclMuMuECollectorModule.h>
13#include <ecl/dataobjects/ECLDigit.h>
14#include <ecl/dataobjects/ECLElementNumbers.h>
15#include <ecl/dbobjects/ECLCrystalCalib.h>
16#include <ecl/geometry/ECLNeighbours.h>
19#include <framework/dataobjects/EventMetaData.h>
20#include <framework/gearbox/Const.h>
21#include <mdst/dataobjects/ECLCluster.h>
22#include <mdst/dataobjects/Track.h>
23#include <mdst/dataobjects/TRGSummary.h>
24#include <tracking/dataobjects/ExtHit.h>
50 setDescription(
"Calibration Collector Module for ECL single crystal energy calibration using muons");
81 auto ExpEvsCrys =
new TH1F(
"ExpEvsCrys",
"Sum expected energy vs crystal ID;crystal ID;Energy (GeV)",
85 auto ElecCalibvsCrys =
new TH1F(
"ElecCalibvsCrys",
"Sum electronics calib const vs crystal ID;crystal ID;calibration constant",
89 auto InitialCalibvsCrys =
new TH1F(
"InitialCalibvsCrys",
94 auto CalibEntriesvsCrys =
new TH1F(
"CalibEntriesvsCrys",
"Entries in calib vs crys histograms;crystal ID;Entries per crystal",
100 auto RawDigitAmpvsCrys =
new TH2F(
"RawDigitAmpvsCrys",
"Digit Amplitude vs crystal ID;crystal ID;Amplitude",
111 auto hitCrysVsExtrapolatedCrys =
new TH2F(
"hitCrysVsExtrapolatedCrys",
112 "Crystals with high energy vs extrapolated crystals with no energy;extrapolated crystalID;High crystalID",
126 B2INFO(
"Input parameters to eclMuMuECollector:");
164 for (
int ic = 1; ic < 9000; ic += 1000) {
165 B2INFO(
"DB constants for cellID=" << ic <<
": ExpMuMuE = " <<
ExpMuMuE[ic - 1] <<
" ElectronicsCalib = " <<
ElectronicsCalib[ic - 1]
172 if (
ExpMuMuE[crysID] == 0) {B2FATAL(
"eclMuMuECollector: ExpMuMuE = 0 for crysID = " << crysID);}
173 if (
MuMuECalib[crysID] == 0) {B2FATAL(
"eclMuMuECollector: MuMuECalib = 0 for crysID = " << crysID);}
200 if (
iEvent % 10000 == 0) {B2INFO(
"eclMuMuECollector: iEvent = " <<
iEvent);}
205 bool newConst =
false;
213 B2INFO(
"ECLCrystalElectronics has changed, exp = " <<
m_evtMetaData->getExperiment() <<
" run = " <<
m_evtMetaData->getRun());
228 for (
int ic = 1; ic < 9000; ic += 1000) {
229 B2INFO(
"DB constants for cellID=" << ic <<
": ExpMuMuE = " <<
ExpMuMuE[ic - 1] <<
" ElectronicsCalib = " <<
237 if (
ExpMuMuE[crysID] == 0) {B2FATAL(
"eclMuMuECollector: ExpMuMuE = 0 for crysID = " << crysID);}
238 if (
MuMuECalib[crysID] == 0) {B2FATAL(
"eclMuMuECollector: MuMuECalib = 0 for crysID = " << crysID);}
247 unsigned int L1TriggerResults =
m_TRGResults->getTRGSummary(0);
248 if (L1TriggerResults == 0) {
return;}
254 if (nTrack < 2) {
return;}
257 double maxpt[2] = {0., 0.};
258 int iTrack[2] = { -1, -1};
259 for (
int it = 0; it < nTrack; it++) {
261 if (not temptrackFit) {
continue;}
274 if (iTrack[0] == -1 || iTrack[1] == -1) {
return; }
283 int extCrysID[2] = { -1, -1};
285 for (
int imu = 0; imu < 2; imu++) {
286 ROOT::Math::XYZVector temppos[2] = {};
288 for (
auto& extHit :
m_trackArray[iTrack[imu]]->getRelationsTo<ExtHit>()) {
289 int pdgCode = extHit.getPdgCode();
291 int temp0 = extHit.getCopyID();
294 if (detectorID == eclID && TMath::Abs(pdgCode) ==
Const::muon.getPDGCode() && extHit.getStatus() == EXT_ENTER) {
296 temppos[0] = extHit.getPosition();
300 if (detectorID == eclID && TMath::Abs(pdgCode) ==
Const::muon.getPDGCode() && extHit.getStatus() == EXT_EXIT && temp0 == IDEnter) {
301 temppos[1] = extHit.getPosition();
304 double trackLength = (temppos[1] - temppos[0]).
R();
312 if (extCrysID[0] == -1 && extCrysID[1] == -1) {
return; }
319 const double highEnergyThresh = 0.18;
320 std::vector<int> highECrys;
324 int crysID = eclDigit.getCellId() - 1;
331 if (
EperCrys[crysID] > highEnergyThresh) {highECrys.push_back(crysID);}
333 getObjectPtr<TH2F>(
"RawDigitTimevsCrys")->Fill(crysID + 0.001, eclDigit.getTimeFit());
355 for (
int imu = 0; imu < 2; imu++) {
356 int crysID = extCrysID[imu];
357 int cellID = crysID + 1;
362 bool noNeighbourSignal =
true;
363 bool highNeighourSignal =
false;
365 for (
const auto& tempCellID :
myNeighbours4->getNeighbours(cellID)) {
366 int tempCrysID = tempCellID - 1;
368 noNeighbourSignal =
false;
369 if (
EperCrys[tempCrysID] > highEnergyThresh) {highNeighourSignal =
true;}
373 for (
const auto& tempCellID :
myNeighbours8->getNeighbours(cellID)) {
374 int tempCrysID = tempCellID - 1;
376 noNeighbourSignal =
false;
377 if (
EperCrys[tempCrysID] > highEnergyThresh) {highNeighourSignal =
true;}
383 if (noNeighbourSignal) {
395 for (
auto&
id : highECrys) {
void registerObject(std::string name, T *obj)
Register object with a name, takes ownership, do not access the pointer beyond prepare()
CalibrationCollectorModule()
Constructor. Sets the default prefix for calibration dataobjects.
T * getObjectPtr(std::string name)
Calls the CalibObjManager to get the requested stored collector data.
Provides a type-safe way to pass members of the chargedStableSet set.
static const ChargedStable muon
muon particle
EDetector
Enum for identifying the detector components (detector and subdetector).
@ c_nPhotons
CR is split into n photons (N1)
Class to get the neighbours for a given cell id.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Values of the result of a track fit with a given particle hypothesis.
short getChargeSign() const
Return track charge (1 or -1).
double getCotTheta() const
Getter for tanLambda with CDF naming convention.
double getTransverseMomentum() const
Getter for the absolute value of the transverse momentum at the perigee.
StoreArray< ECLDigit > m_eclDigitArray
Required input array of eclDigits.
double m_MaxNeighbourE
maximum signal allowed in a neighbouring crystal (0.010 GeV)
bool m_requireL1
require events to satisfy a level 1 trigger (true)
DBObjPtr< ECLCrystalCalib > m_ECLExpMuMuE
Expected energies from database.
double m_minTrackLength
minimum extrapolated track length in the crystal (30 cm)
ECL::ECLNeighbours * myNeighbours8
class to return 8 nearest neighbours to crystal
StoreArray< ECLCluster > m_eclClusterArray
Required input array of ECLClusters.
StoreObjPtr< TRGSummary > m_TRGResults
DataStore TRGSummary.
std::vector< float > ExpMuMuE
vector obtained from DB object
std::vector< float > EperCrys
ECL digit energy for each crystal.
double cotThetaLabMin
Some other useful quantities.
void collect() override
Select events and crystals and accumulate histograms.
double m_minPairMass
Parameters to control the job.
StoreObjPtr< EventMetaData > m_evtMetaData
DataStore EventMetaData.
std::vector< float > ElectronicsCalib
vector obtained from DB object
int firstcellIDN4
Neighbours of each ECL crystal.
DBObjPtr< ECLCrystalCalib > m_CrystalEnergy
Existing single single calibration from DB is used to find expected E.
int lastcellIDN4
last cellID where we only need 4 neighbours
void prepare() override
Define histograms and read payloads from DB.
ECL::ECLNeighbours * myNeighbours4
class to return 4 nearest neighbours to crystal
double m_thetaLabMaxDeg
maximum muon theta in lab (150 degrees)
double m_thetaLabMinDeg
minimum muon theta in lab (17 degrees)
std::vector< float > CrystalEnergy
vector obtained from DB object
std::vector< float > MuMuECalib
vector obtained from DB object
DBObjPtr< ECLCrystalCalib > m_MuMuECalib
Existing single muon pair calibration from DB; will be updated by CAF.
DBObjPtr< ECLCrystalCalib > m_ElectronicsCalib
Electronics calibration from database.
eclMuMuECollectorModule()
Constructor: Sets the description, the properties and the parameters of the module.
bool m_measureTrueEnergy
use eclCalDigit to determine MC deposited energy (false)
double cotThetaLabMax
m_thetaLabMaxDeg converted to cotangent
StoreArray< Track > m_trackArray
Required arrays.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
double tan(double a)
tan for double
const int c_NCrystals
Number of crystals.
Abstract base class for different kinds of events.