10 #include <ecl/modules/eclGammaGammaECollector/eclGammaGammaECollectorModule.h>
13 #include <ecl/dataobjects/ECLDigit.h>
14 #include <ecl/dataobjects/ECLElementNumbers.h>
15 #include <ecl/dbobjects/ECLCrystalCalib.h>
18 #include <analysis/ClusterUtility/ClusterUtils.h>
19 #include <analysis/utility/PCmsLabTransform.h>
20 #include <framework/dataobjects/EventMetaData.h>
21 #include <framework/gearbox/Const.h>
22 #include <framework/geometry/VectorUtil.h>
23 #include <mdst/dataobjects/ECLCluster.h>
24 #include <mdst/dataobjects/HitPatternCDC.h>
25 #include <mdst/dataobjects/Track.h>
26 #include <mdst/dataobjects/TrackFitResult.h>
27 #include <mdst/dataobjects/TRGSummary.h>
30 #include <Math/Vector3D.h>
31 #include <Math/Vector4D.h>
50 m_ECLExpGammaGammaE(
"ECLExpGammaGammaE"),
51 m_ElectronicsCalib(
"ECLCrystalElectronics"), m_GammaGammaECalib(
"ECLCrystalEnergyGammaGamma")
54 setDescription(
"Calibration Collector Module for ECL single crystal energy calibration using gamma gamma events");
58 addParam(
"minPairMass",
m_minPairMass,
"minimum invariant mass of the pair of photons (GeV/c^2)", 9.);
79 registerObject<TH2F>(
"EnVsCrysID", EnVsCrysID);
81 auto ExpEvsCrys =
new TH1F(
"ExpEvsCrys",
"Sum expected energy vs crystal ID;crystal ID;Energy (GeV)",
83 registerObject<TH1F>(
"ExpEvsCrys", ExpEvsCrys);
85 auto ElecCalibvsCrys =
new TH1F(
"ElecCalibvsCrys",
"Sum electronics calib const vs crystal ID;crystal ID;calibration constant",
87 registerObject<TH1F>(
"ElecCalibvsCrys", ElecCalibvsCrys);
89 auto InitialCalibvsCrys =
new TH1F(
"InitialCalibvsCrys",
92 registerObject<TH1F>(
"InitialCalibvsCrys", InitialCalibvsCrys);
94 auto CalibEntriesvsCrys =
new TH1F(
"CalibEntriesvsCrys",
"Entries in calib vs crys histograms;crystal ID;Entries per crystal",
97 registerObject<TH1F>(
"CalibEntriesvsCrys", CalibEntriesvsCrys);
100 auto RawDigitAmpvsCrys =
new TH2F(
"RawDigitAmpvsCrys",
"Digit Amplitude vs crystal ID;crystal ID;Amplitude",
103 registerObject<TH2F>(
"RawDigitAmpvsCrys", RawDigitAmpvsCrys);
108 registerObject<TH2F>(
"RawDigitTimevsCrys", RawDigitTimevsCrys);
110 auto TimeMinusAverage =
new TH1F(
"TimeMinusAverage",
"Photon time - average / dt99;(T-T_ave)/dt99 ", 100, -10, 10);
111 registerObject<TH1F>(
"TimeMinusAverage", TimeMinusAverage);
116 B2INFO(
"Input parameters to eclGammaGammaECollector:");
137 for (
int ic = 1; ic < 9000; ic += 1000) {
138 B2INFO(
"DB constants for cellID=" << ic <<
": ExpGammaGammaE = " <<
ExpGammaGammaE[ic - 1] <<
" ElectronicsCalib = " <<
146 if (
ExpGammaGammaE[crysID] == 0) {B2FATAL(
"eclGammaGammaECollector: ExpGammaGammaE = 0 for crysID = " << crysID);}
147 if (
GammaGammaECalib[crysID] == 0) {B2FATAL(
"eclGammaGammaECollector: GammaGammaECalib = 0 for crysID = " << crysID);}
167 getObjectPtr<TH1F>(
"ExpEvsCrys")->Fill(crysID + 0.001,
ExpGammaGammaE[crysID]);
168 getObjectPtr<TH1F>(
"ElecCalibvsCrys")->Fill(crysID + 0.001,
ElectronicsCalib[crysID]);
169 getObjectPtr<TH1F>(
"InitialCalibvsCrys")->Fill(crysID + 0.001,
GammaGammaECalib[crysID]);
170 getObjectPtr<TH1F>(
"CalibEntriesvsCrys")->Fill(crysID + 0.001);
177 bool newConst =
false;
185 B2INFO(
"ECLCrystalElectronics has changed, exp = " <<
m_evtMetaData->getExperiment() <<
" run = " <<
m_evtMetaData->getRun());
190 B2INFO(
"ECLCrystalEnergyGammaGamma has changed, exp = " <<
m_evtMetaData->getExperiment() <<
" run = " <<
m_evtMetaData->getRun());
195 for (
int ic = 1; ic < 9000; ic += 1000) {
196 B2INFO(
"DB constants for cellID=" << ic <<
": ExpGammaGammaE = " <<
ExpGammaGammaE[ic - 1] <<
" ElectronicsCalib = " <<
204 if (
ExpGammaGammaE[crysID] == 0) {B2FATAL(
"eclGammaGammaECollector: ExpGammaGammaE = 0 for crysID = " << crysID);}
205 if (
GammaGammaECalib[crysID] == 0) {B2FATAL(
"eclGammaGammaECollector: GammaGammaECalib = 0 for crysID = " << crysID);}
212 unsigned int L1TriggerResults =
m_TRGResults->getTRGSummary(0);
213 if (L1TriggerResults == 0) {
return;}
223 double z0 = temptrackFit->
getZ0();
224 double d0 = temptrackFit->
getD0();
225 double pValue = temptrackFit->
getPValue();
230 if (nGoodTrk > 0) {
return;}
235 int icMax[2] = { -1, -1};
236 double maxClustE[2] = { -1., -1.};
238 for (
int ic = 0; ic < nclust; ic++) {
241 if (eClust > maxClustE[0]) {
242 maxClustE[1] = maxClustE[0];
244 maxClustE[0] = eClust;
246 }
else if (eClust > maxClustE[1]) {
247 maxClustE[1] = eClust;
256 if (icMax[0] == -1 || icMax[1] == -1) {
return;}
259 if (theta0 < thetaLabMin || theta0 >
thetaLabMax || theta1 < thetaLabMin || theta1 >
thetaLabMax) {
return;}
266 double taverage = (t0 / (t990 * t990) + t1 / (t991 * t991)) / (1. / (t990 * t990) + 1. / (t991 * t991));
267 if (abs(t0 - taverage) > t990 *
m_maxTime || abs(t1 - taverage) > t991 *
m_maxTime) {
return;}
271 const ROOT::Math::XYZVector clustervertex = cUtil.
GetIPPosition();
274 ROOT::Math::XYZVector p30;
275 VectorUtil::setMagThetaPhi(p30, maxClustE[0], theta0, phi0);
279 ROOT::Math::XYZVector p31;
280 VectorUtil::setMagThetaPhi(p31, maxClustE[1], theta1, phi1);
283 double pairmass = (p40 + p41).M();
288 ROOT::Math::PxPyPzEVector p40COM = boostrotate.
rotateLabToCms() * p40;
289 ROOT::Math::PxPyPzEVector p41COM = boostrotate.
rotateLabToCms() * p41;
290 double dphi = abs(p41COM.Phi() - p40COM.Phi()) * TMath::RadToDeg();
291 if (dphi > 180.) {dphi = 360. - dphi;}
296 int crysIDMax[2] = { -1, -1};
297 for (
int ic = 0; ic < 2; ic++) {
306 int crysID = eclDigit.getCellId() - 1;
307 getObjectPtr<TH2F>(
"RawDigitAmpvsCrys")->Fill(crysID + 0.001, eclDigit.getAmp());
312 getObjectPtr<TH2F>(
"RawDigitTimevsCrys")->Fill(crysID + 0.001, eclDigit.getTimeFit());
320 for (
int ic = 0; ic < 2; ic++) {
330 for (
int ic = 0; ic < 2; ic++) {
331 if (crysIDMax[ic] >= 0) {
333 getObjectPtr<TH2F>(
"EnVsCrysID")->Fill(crysIDMax[ic] + 0.001,
EperCrys[crysIDMax[ic]] / abs(
ExpGammaGammaE[crysIDMax[ic]]));
334 getObjectPtr<TH1F>(
"ExpEvsCrys")->Fill(crysIDMax[ic] + 0.001,
ExpGammaGammaE[crysIDMax[ic]]);
335 getObjectPtr<TH1F>(
"ElecCalibvsCrys")->Fill(crysIDMax[ic] + 0.001,
ElectronicsCalib[crysIDMax[ic]]);
336 getObjectPtr<TH1F>(
"InitialCalibvsCrys")->Fill(crysIDMax[ic] + 0.001,
GammaGammaECalib[crysIDMax[ic]]);
337 getObjectPtr<TH1F>(
"CalibEntriesvsCrys")->Fill(crysIDMax[ic] + 0.001);
340 if (crysIDMax[0] >= 0 && crysIDMax[1] >= 0) {
341 getObjectPtr<TH1F>(
"TimeMinusAverage")->Fill((t0 - taverage) / t990);
342 getObjectPtr<TH1F>(
"TimeMinusAverage")->Fill((t1 - taverage) / t991);
Calibration collector module base class.
Class to provide momentum-related information from ECLClusters.
const ROOT::Math::PxPyPzEVector Get4MomentumFromCluster(const ECLCluster *cluster, ECLCluster::EHypothesisBit hypo)
Returns four momentum vector.
const ROOT::Math::XYZVector GetIPPosition()
Returns default IP position from beam parameters.
Provides a type-safe way to pass members of the chargedStableSet set.
EHypothesisBit
The hypothesis bits for this ECLCluster (Connected region (CR) is split using this hypothesis.
@ c_nPhotons
CR is split into n photons (N1)
unsigned short getNHits() const
Get the total Number of CDC hits in the fit.
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.
double getPValue() const
Getter for Chi2 Probability of the track fit.
double getD0() const
Getter for d0.
double getTransverseMomentum() const
Getter for the absolute value of the transverse momentum at the perigee.
double getZ0() const
Getter for z0.
HitPatternCDC getHitPatternCDC() const
Getter for the hit pattern in the CDC;.
DBObjPtr< ECLCrystalCalib > m_ECLExpGammaGammaE
Expected energies from database.
double maxD0
(cm) maximum abs(D0) of a good track
double minTrkpt
(GeV/c) minimum pt of a good track
StoreArray< ECLDigit > m_eclDigitArray
Required input array of ECLDigits.
DBObjPtr< ECLCrystalCalib > m_GammaGammaECalib
Existing single crystal calibration from DB; will be updated by CAF.
bool m_requireL1
require events to satisfy a level 1 trigger (true)
double m_maxTime
maximum photon (time - <t>)/dt99 (1)
double m_mindPhi
minimum delta phi between clusters (179 deg)
StoreArray< ECLCluster > m_eclClusterArray
Required input array of ECLClusters.
StoreObjPtr< TRGSummary > m_TRGResults
dataStore TRGSummary
std::vector< float > ExpGammaGammaE
vector obtained from DB object
double thetaLabMin
Some other useful quantities.
bool storeCalib
force the input calibration constants to be saved first event
std::vector< float > EperCrys
ECL digit energy for each crystal.
void collect() override
Select events and crystals and accumulate histograms.
double m_minPairMass
minimum invariant mass of the pair of photons (9 GeV/c^2)
StoreObjPtr< EventMetaData > m_evtMetaData
dataStore EventMetaData
std::vector< float > ElectronicsCalib
vector obtained from DB object
int minCDChits
minimum CDC hits for a good track
double minpValue
minimum p value of a good track
void prepare() override
Define histograms and read payloads from DB.
double maxZ0
(cm) maximum abs(Z0) of a good track
double thetaLabMax
m_thetaLabMaxDeg converted to radians (coneversion in Module::init)
double m_thetaLabMaxDeg
maximum photon theta in lab (180 degrees)
double m_thetaLabMinDeg
Parameters to control the job.
DBObjPtr< ECLCrystalCalib > m_ElectronicsCalib
Electronics calibration from database.
bool m_measureTrueEnergy
use eclCalDigit to determine MC deposited energy (false)
std::vector< float > GammaGammaECalib
vector obtained from DB object
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.
const int c_NCrystals
Number of crystals.
Abstract base class for different kinds of events.