10 #include <klm/bklm/modules/bklmAna/BKLMAnaModule.h>
13 #include <framework/dataobjects/EventMetaData.h>
14 #include <framework/datastore/StoreObjPtr.h>
15 #include <mdst/dataobjects/Track.h>
16 #include <mdst/dataobjects/TrackFitResult.h>
17 #include <klm/dataobjects/KLMMuidLikelihood.h>
20 #include <CLHEP/Units/SystemOfUnits.h>
23 using namespace CLHEP;
50 for (
int i = 0; i < 200; ++i) {
55 for (
int i = 0; i < 15; ++i) {
63 setDescription(
"analyze bklm efficiency associated to CDC, check performance of bklm et al.");
80 m_extTree =
new TTree(
"exthit",
"ext hit");
91 float thetaMin = 35.0;
92 float thetaMax = 130.0;
94 for (
int iL = 0; iL < 15 ; iL ++) {
96 sprintf(hname,
"denominator_Layer%i", iL + 1);
97 m_totalThephi[iL] =
new TH2F(hname, hname, phiBins, phiMin, phiMax, thetaBins, thetaMin, thetaMax);
100 sprintf(hname,
"numerator_Layer%i", iL + 1);
101 m_passThephi[iL] =
new TH2F(hname, hname, phiBins, phiMin, phiMax, thetaBins, thetaMin, thetaMax);
102 sprintf(hname,
"effi_Layer%i", iL + 1);
105 m_effiThephi[iL] =
new TH2F(hname, hname, phiBins, phiMin, phiMax, thetaBins, thetaMin, thetaMax);
109 sprintf(hname,
"Denominator_Layer%i", iL + 1);
110 m_totalTrkThephi[iL] =
new TH2F(hname, hname, phiBins, phiMin, phiMax, thetaBins, thetaMin, thetaMax);
113 sprintf(hname,
"Numerator_Layer%i", iL + 1);
114 m_passTrkThephi[iL] =
new TH2F(hname, hname, phiBins, phiMin, phiMax, thetaBins, thetaMin, thetaMax);
115 sprintf(hname,
"Effi_Layer%i", iL + 1);
118 m_effiTrkThephi[iL] =
new TH2F(hname, hname, phiBins, phiMin, phiMax, thetaBins, thetaMin, thetaMax);
129 m_hdistance =
new TH1F(
"m_hdistance",
" distance between mathced extHit and bklmHit2d ", 100, 0, 30);
131 m_totalMom =
new TH1F(
"m_totalMom",
" denominator vs. p", mNbin, mommin, mommax);
132 m_passMom =
new TH1F(
"m_passMom",
" numerator vs. p", mNbin, mommin, mommax);
133 m_effiMom =
new TH1F(
"m_effiMom",
" effi. vs. p", mNbin, mommin, mommax);
134 m_effiMom->GetXaxis()->SetTitle(
"p (GeV)");
135 m_effiMom->GetYaxis()->SetTitle(
"Efficiency (GeV)");
137 m_totalYX =
new TH2F(
"m_totalYX",
" denominator Y vs. X", gNbin, gmin, gmax, gNbin, gmin, gmax);
138 m_passYX =
new TH2F(
"m_passYX",
" numerator Y vs. X", gNbin, gmin, gmax, gNbin, gmin, gmax);
139 m_totalYZ =
new TH2F(
"m_totalYZ",
" denominator Y vs. Z", gNbin, gmin, gmax, gNbin, gmin, gmax);
140 m_passYZ =
new TH2F(
"m_passYZ",
" numerator Y vs. Z", gNbin, gmin, gmax, gNbin, gmin, gmax);
141 m_effiYX =
new TH2F(
"m_effiYX",
" effi. Y vs. X", gNbin, gmin, gmax, gNbin, gmin, gmax);
142 m_effiYZ =
new TH2F(
"m_effiYZ",
" effi. Y vs. Z", gNbin, gmin, gmax, gNbin, gmin, gmax);
143 m_effiYX->GetXaxis()->SetTitle(
"x (cm)");
144 m_effiYX->GetYaxis()->SetTitle(
"y (cm)");
145 m_effiYZ->GetXaxis()->SetTitle(
"z (cm)");
146 m_effiYZ->GetYaxis()->SetTitle(
"y (cm)");
158 unsigned long runNumber = eventMetaData->getRun();
173 for (
int t = 0; t <
extHits.getEntries(); t++) {
188 for (
int k = 0; k <
tracks.getEntries(); k++) {
196 double trkphi = p3.Phi() * TMath::RadToDeg();
197 double trktheta = p3.Theta() * TMath::RadToDeg();
199 trkphi = trkphi + 360.0;
202 for (
unsigned int t = 0; t < relatedExtHit.size(); t++) {
203 ExtHit* exthit = relatedExtHit[t];
210 bool crossed =
false;
214 int extPattern = muid->getExtLayerPattern();
215 if ((extPattern & (1 << (layer - 1))) != 0)
220 ROOT::Math::XYZVector extVec = exthit->
getPosition();
221 bool matched =
false;
224 float phi = extVec.Phi() * TMath::RadToDeg();
225 float theta = extVec.Theta() * TMath::RadToDeg();
234 for (
int mHit = 0; mHit <
hits2D.getEntries(); mHit++) {
239 if (hit->getSection() != section)
241 if (hit->getSector() != sector)
243 if (hit->getLayer() != layer)
245 ROOT::Math::XYZVector position = hit->getPosition();
246 ROOT::Math::XYZVector distance = extVec - position;
250 if (distance.R() < 20)
257 m_passYX->Fill(extVec.X(), extVec.Y());
258 m_passYZ->Fill(extVec.Z(), extVec.Y());
274 for (
int iL = 0; iL < 15; iL ++) {
277 float num =
m_passThephi[iL]->GetBinContent(i + 1, j + 1);
278 float denom =
m_totalThephi[iL]->GetBinContent(i + 1, j + 1);
280 m_effiThephi[iL]->SetBinContent(i + 1, j + 1, num / denom);
281 m_effiThephi[iL]->SetBinError(i + 1, j + 1,
sqrt(num * (denom - num) / (denom * denom * denom)));
290 for (
int iL = 0; iL < 15; iL ++) {
297 m_effiTrkThephi[iL]->SetBinError(i + 1, j + 1,
sqrt(num * (denom - num) / (denom * denom * denom)));
307 for (
int i = 0; i <
m_totalYX->GetNbinsX(); i++) {
308 for (
int j = 0; j <
m_totalYX->GetNbinsY(); j++) {
309 float num =
m_passYX->GetBinContent(i + 1, j + 1);
310 float denom =
m_totalYX->GetBinContent(i + 1, j + 1);
312 m_effiYX->SetBinContent(i + 1, j + 1, num / denom);
313 m_effiYX->SetBinError(i + 1, j + 1,
sqrt(num * (denom - num) / (denom * denom * denom)));
315 m_effiYX->SetBinContent(i + 1, j + 1, 0);
316 m_effiYX->SetBinError(i + 1, j + 1, 0);
319 num =
m_passYZ->GetBinContent(i + 1, j + 1);
320 denom =
m_totalYZ->GetBinContent(i + 1, j + 1);
322 m_effiYZ->SetBinContent(i + 1, j + 1, num / denom);
323 m_effiYZ->SetBinError(i + 1, j + 1,
sqrt(num * (denom - num) / (denom * denom * denom)));
325 m_effiYZ->SetBinContent(i + 1, j + 1, 0);
326 m_effiYZ->SetBinError(i + 1, j + 1, 0);
331 for (
int i = 0; i <
m_totalMom->GetNbinsX(); i++) {
332 float num =
m_passMom->GetBinContent(i + 1);
333 float denom =
m_totalMom->GetBinContent(i + 1);
335 m_effiMom->SetBinContent(i + 1, num / denom);
336 m_effiMom->SetBinError(i + 1,
sqrt(num * (denom - num) / (denom * denom * denom)));
354 for (
int i = 0; i < 15; i++) {
TH2F * m_passYZ
Y Z coordinate of extHit with matched bklmHit2d.
TH2F * m_effiYX
associated efficiencies vs glaoble y, x coordinate
float m_exty[200]
keep the global position of validated ExtHit in BKLM
void initialize() override
Initialize at start of job.
float m_extx[200]
keep the global position of validated ExtHit in BKLM
void event() override
This method is called for each event.
void endRun() override
Do any needed actions at the end of a simulation run.
void terminate() override
Terminate at the end of job.
StoreArray< ExtHit > extHits
extHits StoreArray
BKLMAnaModule()
Constructor.
TH2F * m_passThephi[15]
histogram of entries with matched bklmHit2d of extHit vs.theta phi angle of ExtHit
~BKLMAnaModule()
Destructor.
TH2F * m_totalTrkThephi[15]
histogram of total entries of extHit associating to ExtHit of each layer vs. theta phi angle of the t...
TH2F * m_totalYX
Y X coordinate of total entries of extHit that in klm region.
void beginRun() override
Do any needed actions at the start of a simulation run.
TH1F * m_hdistance
bklm GeometryPar
TH1F * m_totalMom
histogram of total entries of extHit vs. track momentum
StoreArray< KLMHit2d > hits2D
hits2D StoreArray
TFile * m_file
output TFile
int m_nExtHit
number of validated ExtHit in BKLM in one event
float m_extz[200]
keep the global position of validated ExtHit in BKLM
TH2F * m_totalThephi[15]
histogram of total entries of extHit associating to ExtHit of each layer vs.theta phi angle of ExtHit
TH2F * m_effiThephi[15]
efficiency associating to ExtHit of each layer vs.theta phi angle of ExtHit
std::string m_filename
name of the output TFile
TH2F * m_effiYZ
associated efficiencies vs glaoble y, z coordinate
TH1F * m_effiMom
efficiency associating to ExtHit vs. track momentum
StoreArray< Track > tracks
tracks StoreArray
TH2F * m_totalYZ
Y Z coordinate of total entries of extHit that in klm region.
TH2F * m_passTrkThephi[15]
histogram of extHit with matched bklmHit2d of each layer vs. theta phi angle of the track
TH2F * m_effiTrkThephi[15]
efficiency associating to ExtHit of each layer vs. theta phi angle of the track
TH2F * m_passYX
Y X coordinate of extHit with matched bklmHit2d.
TTree * m_extTree
TTree that holds several variable of interest.
TH1F * m_passMom
histogram of entries with matched bklmHit2d of extHit vs. track momentum
static int getSectorByModule(int module)
Get sector number by module identifier.
static int getLayerByModule(int module)
Get layer number by module identifier.
static int getSectionByModule(int module)
Get section number by module identifier.
static const ChargedStable muon
muon particle
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
Store one Ext hit as a ROOT object.
int getCopyID() const
Get detector-element ID of sensitive element within detector.
Const::EDetector getDetectorID() const
Get detector ID of this extrapolation hit.
ROOT::Math::XYZVector getPosition() const
Get position of this extrapolation hit.
Class to store the likelihoods from KLM with additional informations related to the extrapolation.
void setDescription(const std::string &description)
Sets the description of the module.
Class for type safe access to objects that are referred to in relations.
Type-safe access to single objects in the data store.
Values of the result of a track fit with a given particle hypothesis.
ROOT::Math::XYZVector getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
Class that bundles various TrackFitResults.
REG_MODULE(arichBtest)
Register the Module.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.