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>
46 m_ElectronicsCalib(
"ECLCrystalElectronics"), m_MuMuECalib(
"ECLCrystalEnergyMuMu"), m_CrystalEnergy(
"ECLCrystalEnergy")
49 setDescription(
"Calibration Collector Module for ECL single crystal energy calibration using muons");
74 registerObject<TH1F>(
"TrkPerCrysID", TrkPerCrysID);
78 registerObject<TH2F>(
"EnVsCrysID", EnVsCrysID);
80 auto ExpEvsCrys =
new TH1F(
"ExpEvsCrys",
"Sum expected energy vs crystal ID;crystal ID;Energy (GeV)",
82 registerObject<TH1F>(
"ExpEvsCrys", ExpEvsCrys);
84 auto ElecCalibvsCrys =
new TH1F(
"ElecCalibvsCrys",
"Sum electronics calib const vs crystal ID;crystal ID;calibration constant",
86 registerObject<TH1F>(
"ElecCalibvsCrys", ElecCalibvsCrys);
88 auto InitialCalibvsCrys =
new TH1F(
"InitialCalibvsCrys",
91 registerObject<TH1F>(
"InitialCalibvsCrys", InitialCalibvsCrys);
93 auto CalibEntriesvsCrys =
new TH1F(
"CalibEntriesvsCrys",
"Entries in calib vs crys histograms;crystal ID;Entries per crystal",
96 registerObject<TH1F>(
"CalibEntriesvsCrys", CalibEntriesvsCrys);
99 auto RawDigitAmpvsCrys =
new TH2F(
"RawDigitAmpvsCrys",
"Digit Amplitude vs crystal ID;crystal ID;Amplitude",
102 registerObject<TH2F>(
"RawDigitAmpvsCrys", RawDigitAmpvsCrys);
107 registerObject<TH2F>(
"RawDigitTimevsCrys", RawDigitTimevsCrys);
110 auto hitCrysVsExtrapolatedCrys =
new TH2F(
"hitCrysVsExtrapolatedCrys",
111 "Crystals with high energy vs extrapolated crystals with no energy;extrapolated crystalID;High crystalID",
114 registerObject<TH2F>(
"hitCrysVsExtrapolatedCrys", hitCrysVsExtrapolatedCrys);
125 B2INFO(
"Input parameters to eclMuMuECollector:");
163 for (
int ic = 1; ic < 9000; ic += 1000) {
164 B2INFO(
"DB constants for cellID=" << ic <<
": ExpMuMuE = " <<
ExpMuMuE[ic - 1] <<
" ElectronicsCalib = " <<
ElectronicsCalib[ic - 1]
171 if (
ExpMuMuE[crysID] == 0) {B2FATAL(
"eclMuMuECollector: ExpMuMuE = 0 for crysID = " << crysID);}
172 if (
MuMuECalib[crysID] == 0) {B2FATAL(
"eclMuMuECollector: MuMuECalib = 0 for crysID = " << crysID);}
192 getObjectPtr<TH1F>(
"ExpEvsCrys")->Fill(crysID + 0.001,
ExpMuMuE[crysID]);
193 getObjectPtr<TH1F>(
"ElecCalibvsCrys")->Fill(crysID + 0.001,
ElectronicsCalib[crysID]);
194 getObjectPtr<TH1F>(
"InitialCalibvsCrys")->Fill(crysID + 0.001,
MuMuECalib[crysID]);
195 getObjectPtr<TH1F>(
"CalibEntriesvsCrys")->Fill(crysID + 0.001);
199 if (
iEvent % 10000 == 0) {B2INFO(
"eclMuMuECollector: iEvent = " <<
iEvent);}
204 bool newConst =
false;
212 B2INFO(
"ECLCrystalElectronics has changed, exp = " <<
m_evtMetaData->getExperiment() <<
" run = " <<
m_evtMetaData->getRun());
227 for (
int ic = 1; ic < 9000; ic += 1000) {
228 B2INFO(
"DB constants for cellID=" << ic <<
": ExpMuMuE = " <<
ExpMuMuE[ic - 1] <<
" ElectronicsCalib = " <<
236 if (
ExpMuMuE[crysID] == 0) {B2FATAL(
"eclMuMuECollector: ExpMuMuE = 0 for crysID = " << crysID);}
237 if (
MuMuECalib[crysID] == 0) {B2FATAL(
"eclMuMuECollector: MuMuECalib = 0 for crysID = " << crysID);}
246 unsigned int L1TriggerResults =
m_TRGResults->getTRGSummary(0);
247 if (L1TriggerResults == 0) {
return;}
253 if (nTrack < 2) {
return;}
256 double maxpt[2] = {0., 0.};
257 int iTrack[2] = { -1, -1};
258 for (
int it = 0; it < nTrack; it++) {
260 if (not temptrackFit) {
continue;}
273 if (iTrack[0] == -1 || iTrack[1] == -1) {
return; }
282 int extCrysID[2] = { -1, -1};
284 for (
int imu = 0; imu < 2; imu++) {
285 ROOT::Math::XYZVector temppos[2] = {};
287 for (
auto& extHit :
m_trackArray[iTrack[imu]]->getRelationsTo<ExtHit>()) {
288 int pdgCode = extHit.getPdgCode();
290 int temp0 = extHit.getCopyID();
293 if (detectorID == eclID && TMath::Abs(pdgCode) ==
Const::muon.getPDGCode() && extHit.getStatus() == EXT_ENTER) {
295 temppos[0] = extHit.getPosition();
299 if (detectorID == eclID && TMath::Abs(pdgCode) ==
Const::muon.getPDGCode() && extHit.getStatus() == EXT_EXIT && temp0 == IDEnter) {
300 temppos[1] = extHit.getPosition();
303 double trackLength = (temppos[1] - temppos[0]).
R();
311 if (extCrysID[0] == -1 && extCrysID[1] == -1) {
return; }
318 const double highEnergyThresh = 0.18;
319 std::vector<int> highECrys;
323 int crysID = eclDigit.getCellId() - 1;
324 getObjectPtr<TH2F>(
"RawDigitAmpvsCrys")->Fill(crysID + 0.001, eclDigit.getAmp());
330 if (
EperCrys[crysID] > highEnergyThresh) {highECrys.push_back(crysID);}
332 getObjectPtr<TH2F>(
"RawDigitTimevsCrys")->Fill(crysID + 0.001, eclDigit.getTimeFit());
354 for (
int imu = 0; imu < 2; imu++) {
355 int crysID = extCrysID[imu];
356 int cellID = crysID + 1;
359 getObjectPtr<TH1F>(
"TrkPerCrysID")->Fill(crysID + 0.001);
361 bool noNeighbourSignal =
true;
362 bool highNeighourSignal =
false;
365 int tempCrysID = tempCellID - 1;
367 noNeighbourSignal =
false;
368 if (
EperCrys[tempCrysID] > highEnergyThresh) {highNeighourSignal =
true;}
373 int tempCrysID = tempCellID - 1;
375 noNeighbourSignal =
false;
376 if (
EperCrys[tempCrysID] > highEnergyThresh) {highNeighourSignal =
true;}
382 if (noNeighbourSignal) {
385 getObjectPtr<TH2F>(
"EnVsCrysID")->Fill(crysID + 0.001,
EperCrys[crysID] / abs(
ExpMuMuE[crysID]));
386 getObjectPtr<TH1F>(
"ExpEvsCrys")->Fill(crysID + 0.001,
ExpMuMuE[crysID]);
387 getObjectPtr<TH1F>(
"ElecCalibvsCrys")->Fill(crysID + 0.001,
ElectronicsCalib[crysID]);
388 getObjectPtr<TH1F>(
"InitialCalibvsCrys")->Fill(crysID + 0.001,
MuMuECalib[crysID]);
389 getObjectPtr<TH1F>(
"CalibEntriesvsCrys")->Fill(crysID + 0.001);
394 for (
auto&
id : highECrys) {
395 getObjectPtr<TH2F>(
"hitCrysVsExtrapolatedCrys")->Fill(crysID + 0.0001,
id + 0.0001);
Calibration collector module base class.
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.
const std::vector< short int > & getNeighbours(short int cid) const
Return 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
miniumum 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.
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.