9 #include <alignment/modules/AlignmentDQM/AlignDQMModule.h>
10 #include <alignment/modules/AlignmentDQM/AlignDQMEventProcessor.h>
11 #include <tracking/dqmUtils/HistogramFactory.h>
13 #include <TDirectory.h>
16 using namespace Belle2::HistogramFactory;
32 setDescription(
"DQM of Alignment for off line "
33 "residuals per sensor, layer, "
34 "keep also On-Line DQM from tracking: "
36 "Number of hits in tracks, "
50 B2WARNING(
"Missing geometry for VXD.");
52 TDirectory* originalDirectory = gDirectory;
53 TDirectory* alignmentDirectory = originalDirectory->mkdir(
"AlignmentDQM");
54 TDirectory* sensorsDirectory = originalDirectory->mkdir(
"AlignmentDQMSensors");
55 TDirectory* layersDirectory = originalDirectory->mkdir(
"AlignmentDQMLayers");
57 alignmentDirectory->cd();
60 DefineMomentumAngles();
61 DefineMomentumCoordinates();
62 DefineHelixParametersAndCorrelations();
63 DefineTrackFitStatus();
65 DefineUBResidualsVXD();
66 DefineHalfShellsVXD();
68 sensorsDirectory->cd();
71 layersDirectory->cd();
74 originalDirectory->cd();
76 for (
auto change : m_histogramParameterChanges)
77 ProcessHistogramParameterChange(get<0>(change), get<1>(change), get<2>(change));
83 if (!histogramsDefined)
97 int layerIndex = gTools->
getLayerIndex(layer.getLayerNumber());
98 m_ResMeanUPhiThetaLayer[layerIndex]->Divide(m_ResMeanPhiThetaLayerCounts[layerIndex]);
99 m_ResMeanVPhiThetaLayer[layerIndex]->Divide(m_ResMeanPhiThetaLayerCounts[layerIndex]);
101 ComputeMean(m_ResMeanUPhiLayer[layerIndex], m_ResUPhiLayer[layerIndex]);
102 ComputeMean(m_ResMeanVPhiLayer[layerIndex], m_ResVPhiLayer[layerIndex]);
104 ComputeMean(m_ResMeanUThetaLayer[layerIndex], m_ResUThetaLayer[layerIndex]);
105 ComputeMean(m_ResMeanVThetaLayer[layerIndex], m_ResVThetaLayer[layerIndex]);
108 for (
int sensorIndex = 0; sensorIndex < gTools->getNumberOfSensors(); sensorIndex++) {
109 m_ResMeanUPosUVSens[sensorIndex]->Divide(m_ResMeanPosUVSensCounts[sensorIndex]);
110 m_ResMeanVPosUVSens[sensorIndex]->Divide(m_ResMeanPosUVSensCounts[sensorIndex]);
112 ComputeMean(m_ResMeanUPosUSens[sensorIndex], m_ResUPosUSens[sensorIndex]);
113 ComputeMean(m_ResMeanVPosUSens[sensorIndex], m_ResVPosUSens[sensorIndex]);
115 ComputeMean(m_ResMeanUPosVSens[sensorIndex], m_ResUPosVSens[sensorIndex]);
116 ComputeMean(m_ResMeanVPosVSens[sensorIndex], m_ResVPosVSens[sensorIndex]);
122 TDirectory* originalDirectory = gDirectory;
124 TDirectory* helixParameters = originalDirectory->mkdir(
"HelixPars");
125 TDirectory* helixCorrelations = originalDirectory->mkdir(
"HelixCorrelations");
128 double fZ0Range = 10.0;
130 double fD0Range = 1.0;
131 int iMomRangeBig = 600;
132 int iMomRangeSmall = 60;
133 double fMomRange = 6.0;
135 double fPhiRange = 180.0;
136 int iLambdaRange = 100;
137 double fLambdaRange = 4.0;
138 int iOmegaRange = 100;
139 double fOmegaRange = 0.1;
141 auto phi =
Axis(iPhiRange, -fPhiRange, fPhiRange,
"#phi [deg]");
142 auto D0 =
Axis(iD0Range, -fD0Range, fD0Range,
"d0 [cm]");
143 auto Z0 =
Axis(iZ0Range, -fZ0Range, fZ0Range,
"z0 [cm]");
144 auto tanLambda =
Axis(iLambdaRange, -fLambdaRange, fLambdaRange,
"Tan Lambda");
145 auto omega =
Axis(iOmegaRange, -fOmegaRange, fOmegaRange,
"Omega");
146 auto momentumBig =
Axis(2 * iMomRangeBig, 0.0, fMomRange,
"Momentum");
147 auto momentumSmall =
Axis(2 * iMomRangeSmall, 0.0, fMomRange,
"Momentum");
151 helixParameters->cd();
153 factory.yTitleDefault(
"Arb. Units");
155 m_Z0 = factory.xAxis(Z0).CreateTH1F(
"Z0",
"z0 - the z coordinate of the perigee (beam spot position)");
156 m_D0 = factory.xAxis(D0).CreateTH1F(
"D0",
"d0 - the signed distance to the IP in the r-phi plane");
157 m_Phi = factory.xAxis(phi).CreateTH1F(
"Phi",
158 "Phi - angle of the transverse momentum in the r-phi plane, with CDF naming convention");
159 m_Omega = factory.xAxis(omega).CreateTH1F(
"Omega",
160 "Omega - the curvature of the track. It's sign is defined by the charge of the particle");
161 m_TanLambda = factory.xAxis(tanLambda).CreateTH1F(
"TanLambda",
"TanLambda - the slope of the track in the r-z plane");
162 m_MomPt = factory.xAxis(momentumBig).yTitle(
"counts").CreateTH1F(
"TrackMomentumPt",
"Track Momentum pT");
164 helixCorrelations->cd();
166 factory.zTitleDefault(
"Arb. Units");
168 m_PhiD0 = factory.xAxis(phi).yAxis(D0).CreateTH2F(
"PhiD0",
169 "Phi - angle of the transverse momentum in the r-phi plane vs. d0 - signed distance to the IP in r-phi");
170 m_PhiZ0 = factory.xAxis(phi).yAxis(Z0).CreateTH2F(
"PhiZ0",
171 "Phi - angle of the transverse momentum in the r-phi plane vs. z0 of the perigee (to see primary vertex shifts along R or z)");
172 m_PhiMomPt = factory.xAxis(phi).yAxis(momentumSmall).CreateTH2F(
"PhiMomPt",
173 "Phi - angle of the transverse momentum in the r-phi plane vs. Track momentum Pt");
174 m_PhiOmega = factory.xAxis(phi).yAxis(omega).CreateTH2F(
"PhiOmega",
175 "Phi - angle of the transverse momentum in the r-phi plane vs. Omega - the curvature of the track");
176 m_PhiTanLambda = factory.xAxis(phi).yAxis(tanLambda).CreateTH2F(
"PhiTanLambda",
177 "dPhi - angle of the transverse momentum in the r-phi plane vs. TanLambda - the slope of the track in the r-z plane");
178 m_D0Z0 = factory.xAxis(D0).yAxis(Z0).CreateTH2F(
"D0Z0",
179 "d0 - signed distance to the IP in r-phi vs. z0 of the perigee (to see primary vertex shifts along R or z)");
180 m_D0MomPt = factory.xAxis(D0).yAxis(momentumSmall).CreateTH2F(
"D0MomPt",
181 "d0 - signed distance to the IP in r-phi vs. Track momentum Pt");
182 m_D0Omega = factory.xAxis(D0).yAxis(omega).CreateTH2F(
"D0Omega",
183 "d0 - signed distance to the IP in r-phi vs. Omega - the curvature of the track");
184 m_D0TanLambda = factory.xAxis(D0).yAxis(tanLambda).CreateTH2F(
"D0TanLambda",
185 "d0 - signed distance to the IP in r-phi vs. TanLambda - the slope of the track in the r-z plane");
186 m_Z0MomPt = factory.xAxis(Z0).yAxis(momentumSmall).CreateTH2F(
"Z0MomPt",
187 "z0 - the z0 coordinate of the perigee vs. Track momentum Pt");
188 m_Z0Omega = factory.xAxis(Z0).yAxis(omega).CreateTH2F(
"Z0Omega",
189 "z0 - the z0 coordinate of the perigee vs. Omega - the curvature of the track");
190 m_Z0TanLambda = factory.xAxis(Z0).yAxis(tanLambda).CreateTH2F(
"Z0TanLambda",
191 "z0 - the z0 coordinate of the perigee vs. TanLambda - the slope of the track in the r-z plane");
192 m_MomPtOmega = factory.xAxis(momentumSmall).yAxis(omega).CreateTH2F(
"MomPtOmega",
193 "Track momentum Pt vs. Omega - the curvature of the track");
194 m_MomPtTanLambda = factory.xAxis(momentumSmall).yAxis(tanLambda).CreateTH2F(
"MomPtTanLambda",
195 "Track momentum Pt vs. TanLambda - the slope of the track in the r-z plane");
196 m_OmegaTanLambda = factory.xAxis(omega).yAxis(tanLambda).CreateTH2F(
"OmegaTanLambda",
197 "Omega - the curvature of the track vs. TanLambda - the slope of the track in the r-z plane");
199 originalDirectory->cd();
204 TDirectory* originalDirectory = gDirectory;
206 TDirectory* resMeanUPosUV = originalDirectory->mkdir(
"ResidMeanUPositUV");
207 TDirectory* resMeanVPosUV = originalDirectory->mkdir(
"ResidMeanVPositUV");
208 TDirectory* resMeanPosUVCounts = originalDirectory->mkdir(
"ResidMeanPositUVCounts");
209 TDirectory* resMeanUPosU = originalDirectory->mkdir(
"ResidMeanUPositU");
210 TDirectory* resMeanVPosU = originalDirectory->mkdir(
"ResidMeanVPositU");
211 TDirectory* resMeanUPosV = originalDirectory->mkdir(
"ResidMeanUPositV");
212 TDirectory* resMeanVPosV = originalDirectory->mkdir(
"ResidMeanVPositV");
213 TDirectory* resUPosU = originalDirectory->mkdir(
"ResidUPositU");
214 TDirectory* resVPosU = originalDirectory->mkdir(
"ResidVPositU");
215 TDirectory* resUPosV = originalDirectory->mkdir(
"ResidUPositV");
216 TDirectory* resVPosV = originalDirectory->mkdir(
"ResidVPositV");
217 TDirectory* resids2D = originalDirectory->mkdir(
"Residuals2D");
218 TDirectory* resids1D = originalDirectory->mkdir(
"Residuals1D");
221 double fSizeMin = -50;
222 double fSizeMax = -fSizeMin;
223 double residualRange = 400;
225 auto positionU =
Axis(iSizeBins, fSizeMin, fSizeMax,
"position U [mm]");
226 auto positionV =
Axis(positionU).
title(
"position V [mm]");
227 auto residualU =
Axis(200, -residualRange, residualRange,
"residual U [#mum]");
228 auto residualV =
Axis(residualU).
title(
"residual V [#mum]");
232 factory.xAxisDefault(positionU).yAxisDefault(positionV);
235 m_ResMeanUPosUVSens = factory.zTitle(
"residual U [#mum]").CreateSensorsTH2F(format(
"ResMeanUPosUVSens_%1%"),
236 format(
"Residual Mean U in Position UV, %1%"));
238 m_ResMeanVPosUVSens = factory.zTitle(
"residual V [#mum]").CreateSensorsTH2F(format(
"ResMeanVPosUVSens_%1%"),
239 format(
"Residual Mean V in Position UV, %1%"));
240 resMeanPosUVCounts->cd();
241 m_ResMeanPosUVSensCounts = factory.zTitle(
"counts").CreateSensorsTH2F(format(
"ResMeanPosUVCountsSens_%1%"),
242 format(
"Residual Mean Counts in Position UV, %1%"));
244 m_ResMeanUPosUSens = factory.yTitle(
"residual mean U [#mum]").CreateSensorsTH1F(format(
"ResMeanUPosUSens_%1%"),
245 format(
"Residual Mean U in Position U, %1%"));
247 m_ResMeanVPosUSens = factory.yTitle(
"residual mean V [#mum]").CreateSensorsTH1F(format(
"ResMeanVPosUSens_%1%"),
248 format(
"Residual Mean V in Position U, %1%"));
250 factory.xAxisDefault(positionV);
253 m_ResMeanUPosVSens = factory.yTitle(
"residual mean U [#mum]").CreateSensorsTH1F(format(
"ResMeanUPosVSens_%1%"),
254 format(
"Residual Mean U in Position V, %1%"));
256 m_ResMeanVPosVSens = factory.yTitle(
"residual mean V [#mum]").CreateSensorsTH1F(format(
"ResMeanVPosVSens_%1%"),
257 format(
"Residual Mean V in Position V, %1%"));
259 factory.xAxisDefault(positionU).zTitleDefault(
"counts");
262 m_ResUPosUSens = factory.yAxis(residualU).CreateSensorsTH2F(format(
"ResUPosUSensor_%1%"),
263 format(
"Residual U in Position U, %1%"));
265 m_ResVPosUSens = factory.yAxis(residualV).CreateSensorsTH2F(format(
"ResVPosUSensor_%1%"),
266 format(
"Residual V in Position U, %1%"));
268 factory.xAxisDefault(positionV);
271 m_ResUPosVSens = factory.yAxis(residualU).CreateSensorsTH2F(format(
"ResUPosVSensor_%1%"),
272 format(
"Residual U in Position V, %1%"));
274 m_ResVPosVSens = factory.yAxis(residualV).CreateSensorsTH2F(format(
"ResVPosVSensor_%1%"),
275 format(
"Residual V in Position V, %1%"));
278 m_UBResidualsSensor = factory.xAxis(residualU).yAxis(residualV).CreateSensorsTH2F(format(
"UBResiduals_%1%"),
279 format(
"PXD Unbiased residuals for sensor %1%"));
281 factory.yTitleDefault(
"counts");
284 m_UBResidualsSensorU = factory.xAxis(residualU).CreateSensorsTH1F(format(
"UBResidualsU_%1%"),
285 format(
"PXD Unbiased U residuals for sensor %1%"));
286 m_UBResidualsSensorV = factory.xAxis(residualV).CreateSensorsTH1F(format(
"UBResidualsV_%1%"),
287 format(
"PXD Unbiased V residuals for sensor %1%"));
289 originalDirectory->cd();
294 TDirectory* originalDirectory = gDirectory;
296 TDirectory* resMeanUPosUV = originalDirectory->mkdir(
"ResidLayerMeanUPositPhiTheta");
297 TDirectory* resMeanVPosUV = originalDirectory->mkdir(
"ResidLayerMeanVPositPhiTheta");
298 TDirectory* resMeanPosUVCounts = originalDirectory->mkdir(
"ResidLayerMeanPositPhiThetaCounts");
299 TDirectory* resMeanUPosU = originalDirectory->mkdir(
"ResidLayerMeanUPositPhi");
300 TDirectory* resMeanVPosU = originalDirectory->mkdir(
"ResidLayerMeanVPositPhi");
301 TDirectory* resMeanUPosV = originalDirectory->mkdir(
"ResidLayerMeanUPositTheta");
302 TDirectory* resMeanVPosV = originalDirectory->mkdir(
"ResidLayerMeanVPositTheta");
303 TDirectory* resUPosU = originalDirectory->mkdir(
"ResidLayerUPositPhi");
304 TDirectory* resVPosU = originalDirectory->mkdir(
"ResidLayerVPositPhi");
305 TDirectory* resUPosV = originalDirectory->mkdir(
"ResidLayerUPositTheta");
306 TDirectory* resVPosV = originalDirectory->mkdir(
"ResidLayerVPositTheta");
309 int iThetGran = iPhiGran / 2;
311 double residualRange = 400;
313 auto phi =
Axis(iPhiGran, -180, 180,
"Phi [deg]");
314 auto theta =
Axis(iThetGran, 0, 180,
"Theta [deg]");
315 auto residual =
Axis(iYResGran, -residualRange, residualRange,
"residual [#mum]");
318 factory.xAxisDefault(phi).yAxisDefault(theta).zTitleDefault(
"counts");
321 m_ResMeanUPhiThetaLayer = factory.zTitle(
"residual [#mum]").CreateLayersTH2F(format(
"ResMeanUPhiThetaLayer_%1%"),
322 format(
"Residuals Mean U in Phi Theta, Layer %1%"));
324 m_ResMeanVPhiThetaLayer = factory.zTitle(
"residual [#mum]").CreateLayersTH2F(format(
"ResMeanVPhiThetaLayer_%1%"),
325 format(
"Residuals Mean V in Phi Theta, Layer %1%"));
326 resMeanPosUVCounts->cd();
327 m_ResMeanPhiThetaLayerCounts = factory.CreateLayersTH2F(format(
"ResCounterPhiThetaLayer_%1%"),
328 format(
"Residuals counter in Phi Theta, Layer %1%"));
330 factory.yAxisDefault(residual);
333 m_ResUPhiLayer = factory.CreateLayersTH2F(format(
"ResUPhiLayer_%1%"), format(
"Residuals U in Phi, Layer %1%"));
335 m_ResVPhiLayer = factory.CreateLayersTH2F(format(
"ResVPhiLayer_%1%"), format(
"Residuals V in Phi, Layer %1%"));
337 factory.xAxisDefault(theta);
340 m_ResUThetaLayer = factory.CreateLayersTH2F(format(
"ResUThetaLayer_%1%"), format(
"Residuals U in Theta, Layer %1%"));
342 m_ResVThetaLayer = factory.CreateLayersTH2F(format(
"ResVThetaLayer_%1%"), format(
"Residuals V in Theta, Layer %1%"));
344 m_ResMeanUThetaLayer = factory.CreateLayersTH1F(format(
"ResMeanUThetaLayer_%1%"),
345 format(
"Residuals Mean U in Theta, Layer %1%"));
347 m_ResMeanVThetaLayer = factory.CreateLayersTH1F(format(
"ResMeanVThetaLayer_%1%"),
348 format(
"Residuals Mean V in Theta, Layer %1%"));
350 factory.xAxisDefault(phi).yTitleDefault(
"residual [#mum]");
353 m_ResMeanUPhiLayer = factory.CreateLayersTH1F(format(
"ResMeanUPhiLayer_%1%"),
354 format(
"Residuals Mean U in Phi, Layer %1%"));
356 m_ResMeanVPhiLayer = factory.CreateLayersTH1F(format(
"ResMeanVPhiLayer_%1%"),
357 format(
"Residuals Mean V in Phi, Layer %1%"));
359 originalDirectory->cd();
383 float positionU_mm = position.x() /
Unit::mm;
384 float positionV_mm = position.y() /
Unit::mm;
386 m_ResMeanPosUVSensCounts[sensorIndex]->Fill(positionU_mm, positionV_mm);
387 m_ResMeanUPosUVSens[sensorIndex]->Fill(positionU_mm, positionV_mm, residual_um.x());
388 m_ResMeanVPosUVSens[sensorIndex]->Fill(positionU_mm, positionV_mm, residual_um.y());
389 m_ResUPosUSens[sensorIndex]->Fill(positionU_mm, residual_um.x());
390 m_ResUPosVSens[sensorIndex]->Fill(positionV_mm, residual_um.x());
391 m_ResVPosUSens[sensorIndex]->Fill(positionU_mm, residual_um.y());
392 m_ResVPosVSens[sensorIndex]->Fill(positionV_mm, residual_um.y());
397 m_ResMeanPhiThetaLayerCounts[layerIndex]->Fill(phi_deg, theta_deg);
398 m_ResMeanUPhiThetaLayer[layerIndex]->Fill(phi_deg, theta_deg, residual_um.x());
399 m_ResMeanVPhiThetaLayer[layerIndex]->Fill(phi_deg, theta_deg, residual_um.y());
400 m_ResUPhiLayer[layerIndex]->Fill(phi_deg, residual_um.x());
401 m_ResVPhiLayer[layerIndex]->Fill(phi_deg, residual_um.y());
402 m_ResUThetaLayer[layerIndex]->Fill(theta_deg, residual_um.x());
403 m_ResVThetaLayer[layerIndex]->Fill(theta_deg, residual_um.y());
406 TH1F*
AlignDQMModule::Create(
string name,
string title,
int nbinsx,
double xlow,
double xup,
string xTitle,
string yTitle)
411 TH2F*
AlignDQMModule::Create(
string name,
string title,
int nbinsx,
double xlow,
double xup,
int nbinsy,
double ylow,
double yup,
412 string xTitle,
string yTitle,
string zTitle)
414 return DQMHistoModuleBase::Create(
"Alig_" + name, title, nbinsx, xlow, xup, nbinsy, ylow, yup, xTitle, yTitle, zTitle);
The purpose of this class is to process one event() in AlignDQMModule.
DQM of Alignment for off line residuals per sensor, layer, keep also On-Line DQM from tracking: their...
void DefineSensors()
Define histograms which depend on position for individual sensors.
virtual void FillHelixParametersAndCorrelations(const TrackFitResult *tfr) override
Fill histograms with helix parameters and their correlations.
virtual void event() override
Module function event.
virtual TH1F * Create(std::string name, std::string title, int nbinsx, double xlow, double xup, std::string xTitle, std::string yTitle) override
Function to create TH1F and add it to the vector of histograms (m_histograms).
virtual void endRun() override
Module function endRun.
virtual void DefineHelixParametersAndCorrelations() override
All the following Define- functions should be used in the defineHisto() function to define histograms...
virtual void FillLayers(TVector3 residual_um, float phi_deg, float theta_deg, int layerIndex)
Fill histograms which depend on layerIndex.
virtual void FillPositionSensors(TVector3 residual_um, TVector3 position, int sensorIndex)
Fill histograms which depend on position for individual sensors.
virtual void DefineLayers()
Define histograms which depend on layerIndex.
virtual void defineHisto() override
Histogram definitions such as TH1(), TH2(), TNtuple(), TTree()....
virtual void Run()
Call this to start processing the event data and filling histograms.
This class serves as a base for the TrackDQMModule and AlignDQMModule (and possibly other DQM histogr...
virtual void event() override
This method is called for each event.
virtual TH1F * Create(std::string name, std::string title, int nbinsx, double xlow, double xup, std::string xTitle, std::string yTitle)
Function to create TH1F and add it to the vector of histograms (m_histograms).
virtual void FillHelixParametersAndCorrelations(const TrackFitResult *tfr)
Fill histograms with helix parameters and their correlations.
virtual void defineHisto() override
Histogram definitions such as TH1(), TH2(), TNtuple(), TTree()....
This class unites some parameters for Factory which describe one axis of histogram.
Axis & title(std::string title)
Set value of title.
This class is used for creating TH1F and TH2F objects.
Values of the result of a track fit with a given particle hypothesis.
double getOmega() const
Getter for omega.
TVector3 getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
double getD0() const
Getter for d0.
double getTanLambda() const
Getter for tanLambda.
double getZ0() const
Getter for z0.
double getPhi0() const
Getter for phi0.
static const double mm
[millimeters]
static const double deg
degree to radians
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
const std::set< Belle2::VxdID > getLayers(SensorInfoBase::SensorType sensortype=SensorInfoBase::VXD)
Return a set of all known Layers.
static GeoCache & getInstance()
Return a reference to the singleton instance.
const GeoTools * getGeoTools()
Return a raw pointer to a GeoTools object.
Class to uniquely identify a any structure of the PXD and SVD.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.