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>
23#include <CLHEP/Units/SystemOfUnits.h>
53 for (
int i = 0; i < 200; ++i) {
58 for (
int i = 0; i < 15; ++i) {
66 setDescription(
"analyze bklm efficiency associated to CDC, check performance of bklm et al.");
83 m_extTree =
new TTree(
"exthit",
"ext hit");
94 float thetaMin = 35.0;
95 float thetaMax = 130.0;
97 for (
int iL = 0; iL < 15 ; iL ++) {
99 sprintf(hname,
"denominator_Layer%i", iL + 1);
100 m_totalThephi[iL] =
new TH2F(hname, hname, phiBins, phiMin, phiMax, thetaBins, thetaMin, thetaMax);
103 sprintf(hname,
"numerator_Layer%i", iL + 1);
104 m_passThephi[iL] =
new TH2F(hname, hname, phiBins, phiMin, phiMax, thetaBins, thetaMin, thetaMax);
105 sprintf(hname,
"effi_Layer%i", iL + 1);
108 m_effiThephi[iL] =
new TH2F(hname, hname, phiBins, phiMin, phiMax, thetaBins, thetaMin, thetaMax);
112 sprintf(hname,
"Denominator_Layer%i", iL + 1);
113 m_totalTrkThephi[iL] =
new TH2F(hname, hname, phiBins, phiMin, phiMax, thetaBins, thetaMin, thetaMax);
116 sprintf(hname,
"Numerator_Layer%i", iL + 1);
117 m_passTrkThephi[iL] =
new TH2F(hname, hname, phiBins, phiMin, phiMax, thetaBins, thetaMin, thetaMax);
118 sprintf(hname,
"Effi_Layer%i", iL + 1);
121 m_effiTrkThephi[iL] =
new TH2F(hname, hname, phiBins, phiMin, phiMax, thetaBins, thetaMin, thetaMax);
132 m_hdistance =
new TH1F(
"m_hdistance",
" distance between matched extHit and bklmHit2d ", 100, 0, 30);
134 m_totalMom =
new TH1F(
"m_totalMom",
" denominator vs. p", mNbin, mommin, mommax);
135 m_passMom =
new TH1F(
"m_passMom",
" numerator vs. p", mNbin, mommin, mommax);
136 m_effiMom =
new TH1F(
"m_effiMom",
" effi. vs. p", mNbin, mommin, mommax);
137 m_effiMom->GetXaxis()->SetTitle(
"p (GeV)");
138 m_effiMom->GetYaxis()->SetTitle(
"Efficiency (GeV)");
140 m_totalYX =
new TH2F(
"m_totalYX",
" denominator Y vs. X", gNbin, gmin, gmax, gNbin, gmin, gmax);
141 m_passYX =
new TH2F(
"m_passYX",
" numerator Y vs. X", gNbin, gmin, gmax, gNbin, gmin, gmax);
142 m_totalYZ =
new TH2F(
"m_totalYZ",
" denominator Y vs. Z", gNbin, gmin, gmax, gNbin, gmin, gmax);
143 m_passYZ =
new TH2F(
"m_passYZ",
" numerator Y vs. Z", gNbin, gmin, gmax, gNbin, gmin, gmax);
144 m_effiYX =
new TH2F(
"m_effiYX",
" effi. Y vs. X", gNbin, gmin, gmax, gNbin, gmin, gmax);
145 m_effiYZ =
new TH2F(
"m_effiYZ",
" effi. Y vs. Z", gNbin, gmin, gmax, gNbin, gmin, gmax);
146 m_effiYX->GetXaxis()->SetTitle(
"x (cm)");
147 m_effiYX->GetYaxis()->SetTitle(
"y (cm)");
148 m_effiYZ->GetXaxis()->SetTitle(
"z (cm)");
149 m_effiYZ->GetYaxis()->SetTitle(
"y (cm)");
161 unsigned long runNumber = eventMetaData->getRun();
176 for (
int t = 0; t <
extHits.getEntries(); t++) {
191 for (
int k = 0; k <
tracks.getEntries(); k++) {
199 double trkphi = p3.Phi() * TMath::RadToDeg();
200 double trktheta = p3.Theta() * TMath::RadToDeg();
202 trkphi = trkphi + 360.0;
205 for (
unsigned int t = 0; t < relatedExtHit.size(); t++) {
206 ExtHit* exthit = relatedExtHit[t];
213 bool crossed =
false;
217 int extPattern = muid->getExtLayerPattern();
218 if ((extPattern & (1 << (layer - 1))) != 0)
223 ROOT::Math::XYZVector extVec = exthit->
getPosition();
224 bool matched =
false;
227 float phi = extVec.Phi() * TMath::RadToDeg();
228 float theta = extVec.Theta() * TMath::RadToDeg();
237 for (
int mHit = 0; mHit <
hits2D.getEntries(); mHit++) {
242 if (hit->getSection() != section)
244 if (hit->getSector() != sector)
246 if (hit->getLayer() != layer)
248 ROOT::Math::XYZVector position = hit->getPosition();
249 ROOT::Math::XYZVector distance = extVec - position;
253 if (distance.R() < 20)
260 m_passYX->Fill(extVec.X(), extVec.Y());
261 m_passYZ->Fill(extVec.Z(), extVec.Y());
277 for (
int iL = 0; iL < 15; iL ++) {
280 float num =
m_passThephi[iL]->GetBinContent(i + 1, j + 1);
281 float denom =
m_totalThephi[iL]->GetBinContent(i + 1, j + 1);
283 m_effiThephi[iL]->SetBinContent(i + 1, j + 1, num / denom);
284 m_effiThephi[iL]->SetBinError(i + 1, j + 1,
sqrt(num * (denom - num) / (denom * denom * denom)));
293 for (
int iL = 0; iL < 15; iL ++) {
300 m_effiTrkThephi[iL]->SetBinError(i + 1, j + 1,
sqrt(num * (denom - num) / (denom * denom * denom)));
310 for (
int i = 0; i <
m_totalYX->GetNbinsX(); i++) {
311 for (
int j = 0; j <
m_totalYX->GetNbinsY(); j++) {
312 float num =
m_passYX->GetBinContent(i + 1, j + 1);
313 float denom =
m_totalYX->GetBinContent(i + 1, j + 1);
315 m_effiYX->SetBinContent(i + 1, j + 1, num / denom);
316 m_effiYX->SetBinError(i + 1, j + 1,
sqrt(num * (denom - num) / (denom * denom * denom)));
318 m_effiYX->SetBinContent(i + 1, j + 1, 0);
319 m_effiYX->SetBinError(i + 1, j + 1, 0);
322 num =
m_passYZ->GetBinContent(i + 1, j + 1);
323 denom =
m_totalYZ->GetBinContent(i + 1, j + 1);
325 m_effiYZ->SetBinContent(i + 1, j + 1, num / denom);
326 m_effiYZ->SetBinError(i + 1, j + 1,
sqrt(num * (denom - num) / (denom * denom * denom)));
328 m_effiYZ->SetBinContent(i + 1, j + 1, 0);
329 m_effiYZ->SetBinError(i + 1, j + 1, 0);
334 for (
int i = 0; i <
m_totalMom->GetNbinsX(); i++) {
335 float num =
m_passMom->GetBinContent(i + 1);
336 float denom =
m_totalMom->GetBinContent(i + 1);
338 m_effiMom->SetBinContent(i + 1, num / denom);
339 m_effiMom->SetBinError(i + 1,
sqrt(num * (denom - num) / (denom * denom * denom)));
357 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 information 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.
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 sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.