16 #include <Math/Minimizer.h> 17 #include <Math/Factory.h> 18 #include <Math/Functor.h> 31 maxLumiIntegration = 15;
32 nLumiXaxisRange = 5000;
52 nLumiFit = iConfig.
getParameter<
unsigned int>(
"nLumiFit");
53 maxLumiIntegration = iConfig.
getParameter<
unsigned int>(
"maxLumiIntegration");
54 nLumiXaxisRange = iConfig.
getParameter<
unsigned int>(
"nLumiXaxisRange");
56 minNentries = iConfig.
getParameter<
unsigned int>(
"minNentries");
71 internalDebug =
false;
72 considerVxCovariance =
true;
73 pi = 3.141592653589793238;
98 if (debugMode ==
true)
100 stringstream debugFile;
103 if (outputDebugFile.is_open() ==
true) outputDebugFile.close();
104 tmp.erase(strlen(
fileName.c_str())-4,4);
105 debugFile << tmp.c_str() <<
"_Run" << iEvent.
id().
run() <<
".txt";
106 outputDebugFile.open(debugFile.str().c_str(),
ios::out);
107 outputDebugFile.close();
108 outputDebugFile.open(debugFile.str().c_str(), ios::app);
113 else if (beginTimeOfFit != 0)
115 totalHits += HitCounter(iEvent);
117 if (internalDebug ==
true)
119 cout <<
"[Vx3DHLTAnalyzer]::\tI found " << totalHits <<
" pixel hits until now" << endl;
120 cout <<
"[Vx3DHLTAnalyzer]::\tIn this event there are " << Vx3DCollection->size() <<
" vertex cadidates" << endl;
123 for (vector<Vertex>::const_iterator it3DVx = Vx3DCollection->begin(); it3DVx != Vx3DCollection->end(); it3DVx++)
125 if (internalDebug ==
true)
127 cout <<
"[Vx3DHLTAnalyzer]::\tVertex selections:" << endl;
128 cout <<
"[Vx3DHLTAnalyzer]::\tEvent ID = " << iEvent.
id() << endl;
129 cout <<
"[Vx3DHLTAnalyzer]::\tVertex number = " << it3DVx - Vx3DCollection->begin() << endl;
130 cout <<
"[Vx3DHLTAnalyzer]::\tisValid = " << it3DVx->isValid() << endl;
131 cout <<
"[Vx3DHLTAnalyzer]::\tisFake = " << it3DVx->isFake() << endl;
132 cout <<
"[Vx3DHLTAnalyzer]::\tnodof = " << it3DVx->ndof() << endl;
133 cout <<
"[Vx3DHLTAnalyzer]::\ttracksSize = " << it3DVx->tracksSize() << endl;
136 if ((it3DVx->isValid() ==
true) &&
137 (it3DVx->isFake() ==
false) &&
138 (it3DVx->ndof() >= minVxDoF) &&
139 (it3DVx->tracksSize() > 0) &&
140 ((it3DVx->ndof()+3.) / ((double)it3DVx->tracksSize()) >= 2.*minVxWgt))
142 for (i = 0; i <
DIM; i++)
144 for (j = 0; j <
DIM; j++)
146 MyVertex.
Covariance[
i][j] = it3DVx->covariance(i,j);
158 if ((i == DIM) && (det > 0.))
160 if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tVertex accepted !" << endl;
162 MyVertex.
x = it3DVx->x();
163 MyVertex.
y = it3DVx->y();
164 MyVertex.
z = it3DVx->z();
167 Vx_X->Fill(it3DVx->x());
168 Vx_Y->Fill(it3DVx->y());
169 Vx_Z->Fill(it3DVx->z());
171 Vx_ZX->Fill(it3DVx->z(), it3DVx->x());
172 Vx_ZY->Fill(it3DVx->z(), it3DVx->y());
173 Vx_XY->Fill(it3DVx->x(), it3DVx->y());
175 Vx_X_Cum->Fill(it3DVx->x());
176 Vx_Y_Cum->Fill(it3DVx->y());
177 Vx_Z_Cum->Fill(it3DVx->z());
179 Vx_ZX_Cum->Fill(it3DVx->z(), it3DVx->x());
180 Vx_ZY_Cum->Fill(it3DVx->z(), it3DVx->y());
181 Vx_XY_Cum->Fill(it3DVx->x(), it3DVx->y());
183 else if (internalDebug ==
true)
185 cout <<
"[Vx3DHLTAnalyzer]::\tVertex discarded !" << endl;
187 for (i = 0; i <
DIM; i++)
188 for (j = 0; j <
DIM; j++)
189 cout <<
"(i,j) --> " << i <<
"," << j <<
" --> " << MyVertex.
Covariance[i][j] << endl;
192 else if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tVertex discarded !" << endl;
201 iEvent.
getByToken(pixelHitCollection, rechitspixel);
215 strftime(ts,
sizeof(ts),
"%Y.%m.%d %H:%M:%S %Z", gmtime(&t));
217 string ts_string(ts);
244 (std::fabs(
Vertices[
i].z-zPos) <= maxLongLength))
246 if (considerVxCovariance ==
true)
248 K[0][0] = std::fabs(par[0]) + VxErrCorr*VxErrCorr * std::fabs(
Vertices[
i].
Covariance[0][0]);
249 K[1][1] = std::fabs(par[1]) + VxErrCorr*VxErrCorr * std::fabs(
Vertices[
i].Covariance[1][1]);
250 K[2][2] = std::fabs(par[2]) + VxErrCorr*VxErrCorr * std::fabs(
Vertices[
i].Covariance[2][2]);
251 K[0][1] = K[1][0] = par[3] + VxErrCorr*VxErrCorr *
Vertices[
i].Covariance[0][1];
252 K[1][2] = K[2][1] = par[4]*(std::fabs(par[2])-std::fabs(par[1])) - par[5]*par[3] + VxErrCorr*VxErrCorr *
Vertices[
i].Covariance[1][2];
253 K[0][2] = K[2][0] = par[5]*(std::fabs(par[2])-std::fabs(par[0])) - par[4]*par[3] + VxErrCorr*VxErrCorr *
Vertices[
i].Covariance[0][2];
257 K[0][0] = std::fabs(par[0]);
258 K[1][1] = std::fabs(par[1]);
259 K[2][2] = std::fabs(par[2]);
260 K[0][1] = K[1][0] = par[3];
261 K[1][2] = K[2][1] = par[4]*(std::fabs(par[2])-std::fabs(par[1])) - par[5]*par[3];
262 K[0][2] = K[2][0] = par[5]*(std::fabs(par[2])-std::fabs(par[0])) - par[4]*par[3];
265 det = K[0][0]*(K[1][1]*K[2][2] - K[1][2]*K[1][2]) -
266 K[0][1]*(K[0][1]*K[2][2] - K[0][2]*K[1][2]) +
267 K[0][2]*(K[0][1]*K[1][2] - K[0][2]*K[1][1]);
269 M[0][0] = (K[1][1]*K[2][2] - K[1][2]*K[1][2]) / det;
270 M[1][1] = (K[0][0]*K[2][2] - K[0][2]*K[0][2]) / det;
271 M[2][2] = (K[0][0]*K[1][1] - K[0][1]*K[0][1]) / det;
272 M[0][1] = M[1][0] = (K[0][2]*K[1][2] - K[0][1]*K[2][2]) / det;
273 M[1][2] = M[2][1] = (K[0][2]*K[0][1] - K[1][2]*K[0][0]) / det;
274 M[0][2] = M[2][0] = (K[0][1]*K[1][2] - K[0][2]*K[1][1]) / det;
305 if ((vals !=
NULL) && (vals->size() == nParams*2))
307 double nSigmaXY = 10.;
309 double parDistanceXY = 1
e-3;
310 double parDistanceZ = 1
e-2;
311 double parDistanceddZ = 1
e-3;
312 double parDistanceCxy = 1
e-5;
315 const unsigned int trials = 4;
316 double largerDist[trials] = {0.1, 5., 10., 100.};
318 double covxz,covyz,det;
320 int bestMovementX = 1;
321 int bestMovementY = 1;
322 int bestMovementZ = 1;
327 vector<double>::const_iterator it = vals->begin();
329 ROOT::Math::Minimizer* Gauss3D = ROOT::Math::Factory::CreateMinimizer(
"Minuit2",
"Migrad");
330 Gauss3D->SetErrorDef(1.0);
331 if (internalDebug ==
true) Gauss3D->SetPrintLevel(3);
332 else Gauss3D->SetPrintLevel(0);
335 Gauss3D->SetFunction(_Gauss3DFunc);
337 if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\t@@@ START FITTING @@@" << endl;
341 for (
int i = 0;
i < 3;
i++)
343 deltaMean = (double(
i)-1.)*
std::sqrt(*(it+0));
344 if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tdeltaMean --> " << deltaMean << endl;
348 Gauss3D->SetVariable(0,
"var x ", *(it+0), parDistanceXY * parDistanceXY);
349 Gauss3D->SetVariable(1,
"var y ", *(it+1), parDistanceXY * parDistanceXY);
350 Gauss3D->SetVariable(2,
"var z ", *(it+2), parDistanceZ * parDistanceZ);
351 Gauss3D->SetVariable(3,
"cov xy", *(it+3), parDistanceCxy);
352 Gauss3D->SetVariable(4,
"dydz ", *(it+4), parDistanceddZ);
353 Gauss3D->SetVariable(5,
"dxdz ", *(it+5), parDistanceddZ);
354 Gauss3D->SetVariable(6,
"mean x", *(it+6)+deltaMean, parDistanceXY);
355 Gauss3D->SetVariable(7,
"mean y", *(it+7), parDistanceXY);
356 Gauss3D->SetVariable(8,
"mean z", *(it+8), parDistanceZ);
359 xPos = Gauss3D->X()[6];
360 yPos = Gauss3D->X()[7];
361 zPos = Gauss3D->X()[8];
364 maxTransRadius = nSigmaXY *
std::sqrt(std::fabs(Gauss3D->X()[0]) + std::fabs(Gauss3D->X()[1])) / 2.;
365 maxLongLength = nSigmaZ *
std::sqrt(std::fabs(Gauss3D->X()[2]));
368 goodData = Gauss3D->Status();
369 edm = Gauss3D->Edm();
371 if (counterVx < minNentries) goodData = -2;
372 else if (
isNotFinite(edm) ==
true) { goodData = -1;
if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tNot finite edm !" << endl; }
373 else for (
unsigned int j = 0; j < nParams; j++)
377 if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tNot finite errors !" << endl;
382 covyz = Gauss3D->X()[4]*(std::fabs(Gauss3D->X()[2])-std::fabs(Gauss3D->X()[1])) - Gauss3D->X()[5]*Gauss3D->X()[3];
383 covxz = Gauss3D->X()[5]*(std::fabs(Gauss3D->X()[2])-std::fabs(Gauss3D->X()[0])) - Gauss3D->X()[4]*Gauss3D->X()[3];
385 det = std::fabs(Gauss3D->X()[0]) * (std::fabs(Gauss3D->X()[1])*std::fabs(Gauss3D->X()[2]) - covyz*covyz) -
386 Gauss3D->X()[3] * (Gauss3D->X()[3]*std::fabs(Gauss3D->X()[2]) - covxz*covyz) +
387 covxz * (Gauss3D->X()[3]*covyz - covxz*std::fabs(Gauss3D->X()[1]));
388 if (det < 0.) { goodData = -4;
if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tNegative determinant !" << endl; }
391 if ((goodData == 0) && (std::fabs(edm) < bestEdm)) { bestEdm = edm; bestMovementX =
i; }
393 if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tFound bestMovementX --> " << bestMovementX << endl;
397 for (
int i = 0;
i < 3;
i++)
399 deltaMean = (double(
i)-1.)*
std::sqrt(*(it+1));
400 if (internalDebug ==
true)
402 cout <<
"[Vx3DHLTAnalyzer]::\tdeltaMean --> " << deltaMean << endl;
403 cout <<
"[Vx3DHLTAnalyzer]::\tdeltaMean X --> " << (double(bestMovementX)-1.)*
std::sqrt(*(it+0)) << endl;
408 Gauss3D->SetVariable(0,
"var x ", *(it+0), parDistanceXY * parDistanceXY);
409 Gauss3D->SetVariable(1,
"var y ", *(it+1), parDistanceXY * parDistanceXY);
410 Gauss3D->SetVariable(2,
"var z ", *(it+2), parDistanceZ * parDistanceZ);
411 Gauss3D->SetVariable(3,
"cov xy", *(it+3), parDistanceCxy);
412 Gauss3D->SetVariable(4,
"dydz ", *(it+4), parDistanceddZ);
413 Gauss3D->SetVariable(5,
"dxdz ", *(it+5), parDistanceddZ);
414 Gauss3D->SetVariable(6,
"mean x", *(it+6)+(
double(bestMovementX)-1.)*
std::sqrt(*(it+0)), parDistanceXY);
415 Gauss3D->SetVariable(7,
"mean y", *(it+7)+deltaMean, parDistanceXY);
416 Gauss3D->SetVariable(8,
"mean z", *(it+8), parDistanceZ);
419 xPos = Gauss3D->X()[6];
420 yPos = Gauss3D->X()[7];
421 zPos = Gauss3D->X()[8];
424 maxTransRadius = nSigmaXY *
std::sqrt(std::fabs(Gauss3D->X()[0]) + std::fabs(Gauss3D->X()[1])) / 2.;
425 maxLongLength = nSigmaZ *
std::sqrt(std::fabs(Gauss3D->X()[2]));
428 goodData = Gauss3D->Status();
429 edm = Gauss3D->Edm();
431 if (counterVx < minNentries) goodData = -2;
432 else if (
isNotFinite(edm) ==
true) { goodData = -1;
if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tNot finite edm !" << endl; }
433 else for (
unsigned int j = 0; j < nParams; j++)
437 if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tNot finite errors !" << endl;
442 covyz = Gauss3D->X()[4]*(std::fabs(Gauss3D->X()[2])-std::fabs(Gauss3D->X()[1])) - Gauss3D->X()[5]*Gauss3D->X()[3];
443 covxz = Gauss3D->X()[5]*(std::fabs(Gauss3D->X()[2])-std::fabs(Gauss3D->X()[0])) - Gauss3D->X()[4]*Gauss3D->X()[3];
445 det = std::fabs(Gauss3D->X()[0]) * (std::fabs(Gauss3D->X()[1])*std::fabs(Gauss3D->X()[2]) - covyz*covyz) -
446 Gauss3D->X()[3] * (Gauss3D->X()[3]*std::fabs(Gauss3D->X()[2]) - covxz*covyz) +
447 covxz * (Gauss3D->X()[3]*covyz - covxz*std::fabs(Gauss3D->X()[1]));
448 if (det < 0.) { goodData = -4;
if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tNegative determinant !" << endl; }
451 if ((goodData == 0) && (std::fabs(edm) < bestEdm)) { bestEdm = edm; bestMovementY =
i; }
453 if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tFound bestMovementY --> " << bestMovementY << endl;
457 for (
int i = 0;
i < 3;
i++)
459 deltaMean = (double(
i)-1.)*
std::sqrt(*(it+2));
460 if (internalDebug ==
true)
462 cout <<
"[Vx3DHLTAnalyzer]::\tdeltaMean --> " << deltaMean << endl;
463 cout <<
"[Vx3DHLTAnalyzer]::\tdeltaMean X --> " << (double(bestMovementX)-1.)*
std::sqrt(*(it+0)) << endl;
464 cout <<
"[Vx3DHLTAnalyzer]::\tdeltaMean Y --> " << (double(bestMovementY)-1.)*
std::sqrt(*(it+1)) << endl;
469 Gauss3D->SetVariable(0,
"var x ", *(it+0), parDistanceXY * parDistanceXY);
470 Gauss3D->SetVariable(1,
"var y ", *(it+1), parDistanceXY * parDistanceXY);
471 Gauss3D->SetVariable(2,
"var z ", *(it+2), parDistanceZ * parDistanceZ);
472 Gauss3D->SetVariable(3,
"cov xy", *(it+3), parDistanceCxy);
473 Gauss3D->SetVariable(4,
"dydz ", *(it+4), parDistanceddZ);
474 Gauss3D->SetVariable(5,
"dxdz ", *(it+5), parDistanceddZ);
475 Gauss3D->SetVariable(6,
"mean x", *(it+6)+(
double(bestMovementX)-1.)*
std::sqrt(*(it+0)), parDistanceXY);
476 Gauss3D->SetVariable(7,
"mean y", *(it+7)+(
double(bestMovementY)-1.)*
std::sqrt(*(it+1)), parDistanceXY);
477 Gauss3D->SetVariable(8,
"mean z", *(it+8)+deltaMean, parDistanceZ);
480 xPos = Gauss3D->X()[6];
481 yPos = Gauss3D->X()[7];
482 zPos = Gauss3D->X()[8];
485 maxTransRadius = nSigmaXY *
std::sqrt(std::fabs(Gauss3D->X()[0]) + std::fabs(Gauss3D->X()[1])) / 2.;
486 maxLongLength = nSigmaZ *
std::sqrt(std::fabs(Gauss3D->X()[2]));
489 goodData = Gauss3D->Status();
490 edm = Gauss3D->Edm();
492 if (counterVx < minNentries) goodData = -2;
493 else if (
isNotFinite(edm) ==
true) { goodData = -1;
if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tNot finite edm !" << endl; }
494 else for (
unsigned int j = 0; j < nParams; j++)
498 if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tNot finite errors !" << endl;
503 covyz = Gauss3D->X()[4]*(std::fabs(Gauss3D->X()[2])-std::fabs(Gauss3D->X()[1])) - Gauss3D->X()[5]*Gauss3D->X()[3];
504 covxz = Gauss3D->X()[5]*(std::fabs(Gauss3D->X()[2])-std::fabs(Gauss3D->X()[0])) - Gauss3D->X()[4]*Gauss3D->X()[3];
506 det = std::fabs(Gauss3D->X()[0]) * (std::fabs(Gauss3D->X()[1])*std::fabs(Gauss3D->X()[2]) - covyz*covyz) -
507 Gauss3D->X()[3] * (Gauss3D->X()[3]*std::fabs(Gauss3D->X()[2]) - covxz*covyz) +
508 covxz * (Gauss3D->X()[3]*covyz - covxz*std::fabs(Gauss3D->X()[1]));
509 if (det < 0.) { goodData = -4;
if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tNegative determinant !" << endl; }
512 if ((goodData == 0) && (std::fabs(edm) < bestEdm)) { bestEdm = edm; bestMovementZ =
i; }
514 if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tFound bestMovementZ --> " << bestMovementZ << endl;
519 Gauss3D->SetVariable(0,
"var x ", *(it+0), parDistanceXY * parDistanceXY);
520 Gauss3D->SetVariable(1,
"var y ", *(it+1), parDistanceXY * parDistanceXY);
521 Gauss3D->SetVariable(2,
"var z ", *(it+2), parDistanceZ * parDistanceZ);
522 Gauss3D->SetVariable(3,
"cov xy", *(it+3), parDistanceCxy);
523 Gauss3D->SetVariable(4,
"dydz ", *(it+4), parDistanceddZ);
524 Gauss3D->SetVariable(5,
"dxdz ", *(it+5), parDistanceddZ);
525 Gauss3D->SetVariable(6,
"mean x", *(it+6)+(
double(bestMovementX)-1.)*
std::sqrt(*(it+0)), parDistanceXY);
526 Gauss3D->SetVariable(7,
"mean y", *(it+7)+(
double(bestMovementY)-1.)*
std::sqrt(*(it+1)), parDistanceXY);
527 Gauss3D->SetVariable(8,
"mean z", *(it+8)+(
double(bestMovementZ)-1.)*
std::sqrt(*(it+2)), parDistanceZ);
530 xPos = Gauss3D->X()[6];
531 yPos = Gauss3D->X()[7];
532 zPos = Gauss3D->X()[8];
535 maxTransRadius = nSigmaXY *
std::sqrt(std::fabs(Gauss3D->X()[0]) + std::fabs(Gauss3D->X()[1])) / 2.;
536 maxLongLength = nSigmaZ *
std::sqrt(std::fabs(Gauss3D->X()[2]));
539 goodData = Gauss3D->Status();
540 edm = Gauss3D->Edm();
542 if (counterVx < minNentries) goodData = -2;
543 else if (
isNotFinite(edm) ==
true) { goodData = -1;
if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tNot finite edm !" << endl; }
544 else for (
unsigned int j = 0; j < nParams; j++)
548 if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tNot finite errors !" << endl;
553 covyz = Gauss3D->X()[4]*(std::fabs(Gauss3D->X()[2])-std::fabs(Gauss3D->X()[1])) - Gauss3D->X()[5]*Gauss3D->X()[3];
554 covxz = Gauss3D->X()[5]*(std::fabs(Gauss3D->X()[2])-std::fabs(Gauss3D->X()[0])) - Gauss3D->X()[4]*Gauss3D->X()[3];
556 det = std::fabs(Gauss3D->X()[0]) * (std::fabs(Gauss3D->X()[1])*std::fabs(Gauss3D->X()[2]) - covyz*covyz) -
557 Gauss3D->X()[3] * (Gauss3D->X()[3]*std::fabs(Gauss3D->X()[2]) - covxz*covyz) +
558 covxz * (Gauss3D->X()[3]*covyz - covxz*std::fabs(Gauss3D->X()[1]));
559 if (det < 0.) { goodData = -4;
if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tNegative determinant !" << endl; }
563 for (
unsigned int i = 0;
i < trials;
i++)
565 if ((goodData != 0) && (goodData != -2))
569 if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tFIT WITH DIFFERENT PARAMETER DISTANCES - STEP " <<
i+1 << endl;
571 Gauss3D->SetVariable(0,
"var x ", *(it+0), parDistanceXY * parDistanceXY * largerDist[
i]);
572 Gauss3D->SetVariable(1,
"var y ", *(it+1), parDistanceXY * parDistanceXY * largerDist[i]);
573 Gauss3D->SetVariable(2,
"var z ", *(it+2), parDistanceZ * parDistanceZ * largerDist[i]);
574 Gauss3D->SetVariable(3,
"cov xy", *(it+3), parDistanceCxy * largerDist[i]);
575 Gauss3D->SetVariable(4,
"dydz ", *(it+4), parDistanceddZ * largerDist[i]);
576 Gauss3D->SetVariable(5,
"dxdz ", *(it+5), parDistanceddZ * largerDist[i]);
577 Gauss3D->SetVariable(6,
"mean x", *(it+6)+(
double(bestMovementX)-1.)*std::sqrt(*(it+0)), parDistanceXY * largerDist[i]);
578 Gauss3D->SetVariable(7,
"mean y", *(it+7)+(
double(bestMovementY)-1.)*std::sqrt(*(it+1)), parDistanceXY * largerDist[i]);
579 Gauss3D->SetVariable(8,
"mean z", *(it+8)+(
double(bestMovementZ)-1.)*std::sqrt(*(it+2)), parDistanceZ * largerDist[i]);
582 xPos = Gauss3D->X()[6];
583 yPos = Gauss3D->X()[7];
584 zPos = Gauss3D->X()[8];
587 maxTransRadius = nSigmaXY *
std::sqrt(std::fabs(Gauss3D->X()[0]) + std::fabs(Gauss3D->X()[1])) / 2.;
588 maxLongLength = nSigmaZ *
std::sqrt(std::fabs(Gauss3D->X()[2]));
591 goodData = Gauss3D->Status();
592 edm = Gauss3D->Edm();
594 if (counterVx < minNentries) goodData = -2;
595 else if (
isNotFinite(edm) ==
true) { goodData = -1;
if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tNot finite edm !" << endl; }
596 else for (
unsigned int j = 0; j < nParams; j++)
600 if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tNot finite errors !" << endl;
605 covyz = Gauss3D->X()[4]*(std::fabs(Gauss3D->X()[2])-std::fabs(Gauss3D->X()[1])) - Gauss3D->X()[5]*Gauss3D->X()[3];
606 covxz = Gauss3D->X()[5]*(std::fabs(Gauss3D->X()[2])-std::fabs(Gauss3D->X()[0])) - Gauss3D->X()[4]*Gauss3D->X()[3];
608 det = std::fabs(Gauss3D->X()[0]) * (std::fabs(Gauss3D->X()[1])*std::fabs(Gauss3D->X()[2]) - covyz*covyz) -
609 Gauss3D->X()[3] * (Gauss3D->X()[3]*std::fabs(Gauss3D->X()[2]) - covxz*covyz) +
610 covxz * (Gauss3D->X()[3]*covyz - covxz*std::fabs(Gauss3D->X()[1]));
611 if (det < 0.) { goodData = -4;
if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tNegative determinant !" << endl; }
617 for (
unsigned int i = 0;
i < nParams;
i++)
619 vals->operator[](
i) = Gauss3D->X()[
i];
620 vals->operator[](
i+nParams) = Gauss3D->Errors()[
i];
633 if ((debugMode ==
true) && (outputDebugFile.is_open() ==
true))
635 outputDebugFile <<
"Runnumber " <<
runNumber << endl;
636 outputDebugFile <<
"BeginTimeOfFit " <<
formatTime(beginTimeOfFit >> 32) <<
" " << (beginTimeOfFit >> 32) << endl;
637 outputDebugFile <<
"BeginLumiRange " << beginLumiOfFit << endl;
638 outputDebugFile <<
"EndTimeOfFit " <<
formatTime(endTimeOfFit >> 32) <<
" " << (endTimeOfFit >> 32) << endl;
639 outputDebugFile <<
"EndLumiRange " << endLumiOfFit << endl;
640 outputDebugFile <<
"LumiCounter " << lumiCounter << endl;
641 outputDebugFile <<
"LastLumiOfFit " << lastLumiOfFit << endl;
645 if (ResetType.compare(
"scratch") == 0)
680 goodVxCounter->Reset();
681 statusCounter->Reset();
684 reportSummary->Fill(-1);
685 reportSummaryMap->getTH1()->SetBinContent(1, 1, -1);
696 if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tReset issued: scratch" << endl;
697 if ((debugMode ==
true) && (outputDebugFile.is_open() ==
true)) outputDebugFile <<
"Reset -scratch- issued\n" << endl;
699 else if (ResetType.compare(
"whole") == 0)
718 if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tReset issued: whole" << endl;
719 if ((debugMode ==
true) && (outputDebugFile.is_open() ==
true)) outputDebugFile <<
"Reset -whole- issued\n" << endl;
721 else if (ResetType.compare(
"hitCounter") == 0)
725 if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tReset issued: hitCounter" << endl;
726 if ((debugMode ==
true) && (outputDebugFile.is_open() ==
true)) outputDebugFile <<
"Reset -hitCounter- issued\n" << endl;
734 unsigned int BeginLumiOfFit,
735 unsigned int EndLumiOfFit,
738 stringstream BufferString;
739 BufferString.precision(5);
743 if ((
outputFile.is_open() ==
true) && (vals !=
NULL) && (vals->size() == (nParams-1)*2))
745 vector<double>::const_iterator it = vals->begin();
748 outputFile <<
"BeginTimeOfFit " <<
formatTime(beginTimeOfFit >> 32) <<
" " << (beginTimeOfFit >> 32) << endl;
749 outputFile <<
"EndTimeOfFit " <<
formatTime(endTimeOfFit >> 32) <<
" " << (endTimeOfFit >> 32) << endl;
750 outputFile <<
"LumiRange " << beginLumiOfFit <<
" - " << endLumiOfFit << endl;
756 BufferString << *(it+0);
757 outputFile <<
"X0 " << BufferString.str().c_str() << endl;
758 BufferString.str(
"");
760 BufferString << *(it+1);
761 outputFile <<
"Y0 " << BufferString.str().c_str() << endl;
762 BufferString.str(
"");
764 BufferString << *(it+2);
765 outputFile <<
"Z0 " << BufferString.str().c_str() << endl;
766 BufferString.str(
"");
768 BufferString << *(it+5);
769 outputFile <<
"sigmaZ0 " << BufferString.str().c_str() << endl;
770 BufferString.str(
"");
772 BufferString << *(it+6);
773 outputFile <<
"dxdz " << BufferString.str().c_str() << endl;
774 BufferString.str(
"");
776 BufferString << *(it+7);
777 outputFile <<
"dydz " << BufferString.str().c_str() << endl;
778 BufferString.str(
"");
780 BufferString << *(it+3);
781 outputFile <<
"BeamWidthX " << BufferString.str().c_str() << endl;
782 BufferString.str(
"");
784 BufferString << *(it+4);
785 outputFile <<
"BeamWidthY " << BufferString.str().c_str() << endl;
786 BufferString.str(
"");
788 outputFile <<
"Cov(0,j) " << *(it+8) <<
" 0 0 0 0 0 0" << endl;
789 outputFile <<
"Cov(1,j) 0 " << *(it+9) <<
" 0 0 0 0 0" << endl;
790 outputFile <<
"Cov(2,j) 0 0 " << *(it+10) <<
" 0 0 0 0" << endl;
791 outputFile <<
"Cov(3,j) 0 0 0 " << *(it+13) <<
" 0 0 0" << endl;
792 outputFile <<
"Cov(4,j) 0 0 0 0 " << *(it+14) <<
" 0 0" << endl;
793 outputFile <<
"Cov(5,j) 0 0 0 0 0 " << *(it+15) <<
" 0" << endl;
794 outputFile <<
"Cov(6,j) 0 0 0 0 0 0 " << ((*(it+11)) + (*(it+12)) + 2.*
std::sqrt((*(it+11))*(*(it+12)))) / 4. << endl;
809 if ((debugMode ==
true) && (outputDebugFile.is_open() ==
true) && (vals !=
NULL) && (vals->size() == (nParams-1)*2))
811 vector<double>::const_iterator it = vals->begin();
813 outputDebugFile <<
"Runnumber " <<
runNumber << endl;
814 outputDebugFile <<
"BeginTimeOfFit " <<
formatTime(beginTimeOfFit >> 32) <<
" " << (beginTimeOfFit >> 32) << endl;
815 outputDebugFile <<
"EndTimeOfFit " <<
formatTime(endTimeOfFit >> 32) <<
" " << (endTimeOfFit >> 32) << endl;
816 outputDebugFile <<
"LumiRange " << beginLumiOfFit <<
" - " << endLumiOfFit << endl;
817 outputDebugFile <<
"Type " << dataType << endl;
822 BufferString << *(it+0);
823 outputDebugFile <<
"X0 " << BufferString.str().c_str() << endl;
824 BufferString.str(
"");
826 BufferString << *(it+1);
827 outputDebugFile <<
"Y0 " << BufferString.str().c_str() << endl;
828 BufferString.str(
"");
830 BufferString << *(it+2);
831 outputDebugFile <<
"Z0 " << BufferString.str().c_str() << endl;
832 BufferString.str(
"");
834 BufferString << *(it+5);
835 outputDebugFile <<
"sigmaZ0 " << BufferString.str().c_str() << endl;
836 BufferString.str(
"");
838 BufferString << *(it+6);
839 outputDebugFile <<
"dxdz " << BufferString.str().c_str() << endl;
840 BufferString.str(
"");
842 BufferString << *(it+7);
843 outputDebugFile <<
"dydz " << BufferString.str().c_str() << endl;
844 BufferString.str(
"");
846 BufferString << *(it+3);
847 outputDebugFile <<
"BeamWidthX " << BufferString.str().c_str() << endl;
848 BufferString.str(
"");
850 BufferString << *(it+4);
851 outputDebugFile <<
"BeamWidthY " << BufferString.str().c_str() << endl;
852 BufferString.str(
"");
854 outputDebugFile <<
"Cov(0,j) " << *(it+8) <<
" 0 0 0 0 0 0" << endl;
855 outputDebugFile <<
"Cov(1,j) 0 " << *(it+9) <<
" 0 0 0 0 0" << endl;
856 outputDebugFile <<
"Cov(2,j) 0 0 " << *(it+10) <<
" 0 0 0 0" << endl;
857 outputDebugFile <<
"Cov(3,j) 0 0 0 " << *(it+13) <<
" 0 0 0" << endl;
858 outputDebugFile <<
"Cov(4,j) 0 0 0 0 " << *(it+14) <<
" 0 0" << endl;
859 outputDebugFile <<
"Cov(5,j) 0 0 0 0 0 " << *(it+15) <<
" 0" << endl;
860 outputDebugFile <<
"Cov(6,j) 0 0 0 0 0 0 " << ((*(it+11)) + (*(it+12)) + 2.*
std::sqrt((*(it+11))*(*(it+12)))) / 4. << endl;
862 outputDebugFile <<
"EmittanceX 0" << endl;
863 outputDebugFile <<
"EmittanceY 0" << endl;
864 outputDebugFile <<
"BetaStar 0" << endl;
865 outputDebugFile <<
"events 0" << endl;
866 outputDebugFile <<
"meanPV 0" << endl;
867 outputDebugFile <<
"meanErrPV 0" << endl;
868 outputDebugFile <<
"rmsPV 0" << endl;
869 outputDebugFile <<
"rmsErrPV 0" << endl;
870 outputDebugFile <<
"maxPV 0" << endl;
871 outputDebugFile <<
"nPV " << counterVx << endl;
873 outputDebugFile <<
"\n" <<
"Used vertices: " << counterVx <<
"\n" << endl;
880 cout <<
"var x --> " << fitResults[0] <<
" +/- " << fitResults[0+nParams] << endl;
881 cout <<
"var y --> " << fitResults[1] <<
" +/- " << fitResults[1+nParams] << endl;
882 cout <<
"var z --> " << fitResults[2] <<
" +/- " << fitResults[2+nParams] << endl;
883 cout <<
"cov xy --> " << fitResults[3] <<
" +/- " << fitResults[3+nParams] << endl;
884 cout <<
"dydz --> " << fitResults[4] <<
" +/- " << fitResults[4+nParams] << endl;
885 cout <<
"dxdz --> " << fitResults[5] <<
" +/- " << fitResults[5+nParams] << endl;
886 cout <<
"mean x --> " << fitResults[6] <<
" +/- " << fitResults[6+nParams] << endl;
887 cout <<
"mean y --> " << fitResults[7] <<
" +/- " << fitResults[7+nParams] << endl;
888 cout <<
"mean z --> " << fitResults[8] <<
" +/- " << fitResults[8+nParams] << endl;
895 if ((lumiCounter == 0) && (lumiBlock.
luminosityBlock() > lastLumiOfFit))
901 else if ((lumiCounter != 0) && (lumiBlock.
luminosityBlock() >= (beginLumiOfFit+lumiCounter))) lumiCounter++;
902 else reset(
"scratch");
908 stringstream histTitle;
911 if ((nLumiFit != 0) && (lumiCounter%nLumiFit == 0) && (beginTimeOfFit != 0) && (
runNumber != 0))
915 lastLumiOfFit = endLumiOfFit;
918 hitCounter->getTH1()->SetBinContent(lastLumiOfFit, (
double)totalHits);
919 hitCounter->getTH1()->SetBinError(lastLumiOfFit, (totalHits != 0 ? 1. : 0.));
921 if (dataFromFit ==
true)
923 vector<double> fitResults;
925 fitResults.push_back(Vx_X->getTH1()->GetRMS()*Vx_X->getTH1()->GetRMS());
926 fitResults.push_back(Vx_Y->getTH1()->GetRMS()*Vx_Y->getTH1()->GetRMS());
927 fitResults.push_back(Vx_Z->getTH1()->GetRMS()*Vx_Z->getTH1()->GetRMS());
928 fitResults.push_back(0.0);
929 fitResults.push_back(0.0);
930 fitResults.push_back(0.0);
931 fitResults.push_back(Vx_X->getTH1()->GetMean());
932 fitResults.push_back(Vx_Y->getTH1()->GetMean());
933 fitResults.push_back(Vx_Z->getTH1()->GetMean());
934 for (
unsigned int i = 0;
i < nParams;
i++) fitResults.push_back(0.0);
936 if (internalDebug ==
true)
938 cout <<
"[Vx3DHLTAnalyzer]::\t@@@ Beam Spot parameters - prefit @@@" << endl;
940 printFitParams(fitResults);
943 cout <<
"BeginTimeOfFit " <<
formatTime(beginTimeOfFit >> 32) <<
" " << (beginTimeOfFit >> 32) << endl;
944 cout <<
"EndTimeOfFit " <<
formatTime(endTimeOfFit >> 32) <<
" " << (endTimeOfFit >> 32) << endl;
945 cout <<
"LumiRange " << beginLumiOfFit <<
" - " << endLumiOfFit << endl;
948 goodData = MyFit(&fitResults);
950 if (internalDebug ==
true)
952 cout <<
"[Vx3DHLTAnalyzer]::\t@@@ Beam Spot parameters - postfit @@@" << endl;
954 printFitParams(fitResults);
956 cout <<
"goodData --> " << goodData << endl;
957 cout <<
"Used vertices --> " << counterVx << endl;
962 vals.push_back(fitResults[6]);
963 vals.push_back(fitResults[7]);
964 vals.push_back(fitResults[8]);
965 vals.push_back(
std::sqrt(std::fabs(fitResults[0])));
966 vals.push_back(
std::sqrt(std::fabs(fitResults[1])));
967 vals.push_back(
std::sqrt(std::fabs(fitResults[2])));
968 vals.push_back(fitResults[5]);
969 vals.push_back(fitResults[4]);
971 vals.push_back(
std::pow(fitResults[6+nParams],2.));
972 vals.push_back(
std::pow(fitResults[7+nParams],2.));
973 vals.push_back(
std::pow(fitResults[8+nParams],2.));
974 vals.push_back(
std::pow(std::fabs(fitResults[0+nParams]) / (2.*
std::sqrt(std::fabs(fitResults[0]))),2.));
975 vals.push_back(
std::pow(std::fabs(fitResults[1+nParams]) / (2.*
std::sqrt(std::fabs(fitResults[1]))),2.));
976 vals.push_back(
std::pow(std::fabs(fitResults[2+nParams]) / (2.*
std::sqrt(std::fabs(fitResults[2]))),2.));
977 vals.push_back(
std::pow(fitResults[5+nParams],2.));
978 vals.push_back(
std::pow(fitResults[4+nParams],2.));
980 else for (
unsigned int i = 0;
i < (nParams-1)*2;
i++) vals.push_back(0.0);
986 counterVx = Vx_X->getTH1F()->GetEntries();
988 if (Vx_X->getTH1F()->GetEntries() >= minNentries)
992 vals.push_back(Vx_X->getTH1F()->GetMean());
993 vals.push_back(Vx_Y->getTH1F()->GetMean());
994 vals.push_back(Vx_Z->getTH1F()->GetMean());
995 vals.push_back(Vx_X->getTH1F()->GetRMS());
996 vals.push_back(Vx_Y->getTH1F()->GetRMS());
997 vals.push_back(Vx_Z->getTH1F()->GetRMS());
1001 vals.push_back(
std::pow(Vx_X->getTH1F()->GetMeanError(),2.));
1002 vals.push_back(
std::pow(Vx_Y->getTH1F()->GetMeanError(),2.));
1003 vals.push_back(
std::pow(Vx_Z->getTH1F()->GetMeanError(),2.));
1004 vals.push_back(
std::pow(Vx_X->getTH1F()->GetRMSError(),2.));
1005 vals.push_back(
std::pow(Vx_Y->getTH1F()->GetRMSError(),2.));
1006 vals.push_back(
std::pow(Vx_Z->getTH1F()->GetRMSError(),2.));
1007 vals.push_back(0.0);
1008 vals.push_back(0.0);
1013 for (
unsigned int i = 0;
i < (nParams-1)*2;
i++) vals.push_back(0.0);
1036 writeToFile(&vals, beginTimeOfFit, endTimeOfFit, beginLumiOfFit, endLumiOfFit, 3);
1037 if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tUsed vertices: " << counterVx << endl;
1039 statusCounter->getTH1()->SetBinContent(lastLumiOfFit, (
double)goodData);
1040 statusCounter->getTH1()->SetBinError(lastLumiOfFit, 1
e-3);
1046 histTitle <<
"Ongoing: fitted lumis " << beginLumiOfFit <<
" - " << endLumiOfFit;
1051 if (goodData == -2) histTitle <<
"Ongoing: not enough evts (" << lumiCounter <<
" - " << maxLumiIntegration <<
" lumis)";
1052 else histTitle <<
"Ongoing: temporary problems (" << lumiCounter <<
" - " << maxLumiIntegration <<
" lumis)";
1054 if (lumiCounter >= maxLumiIntegration)
1056 statusCounter->getTH1()->SetBinContent(lastLumiOfFit, -5);
1057 statusCounter->getTH1()->SetBinError(lastLumiOfFit, 1
e-3);
1060 else reset(
"hitCounter");
1063 reportSummary->Fill((numberFits != 0 ? ((
double)numberGoodFits) / ((
double)numberFits) : -1));
1064 reportSummaryMap->getTH1()->SetBinContent(1, 1, (numberFits != 0 ? ((
double)numberGoodFits) / ((
double)numberFits) : -1));
1066 fitResults->setAxisTitle(histTitle.str().c_str(), 1);
1068 fitResults->setBinContent(1, 9, vals[0]);
1069 fitResults->setBinContent(1, 8, vals[1]);
1070 fitResults->setBinContent(1, 7, vals[2]);
1071 fitResults->setBinContent(1, 6, vals[3]);
1072 fitResults->setBinContent(1, 5, vals[4]);
1073 fitResults->setBinContent(1, 4, vals[5]);
1074 fitResults->setBinContent(1, 3, vals[6]);
1075 fitResults->setBinContent(1, 2, vals[7]);
1076 fitResults->setBinContent(1, 1, counterVx);
1078 fitResults->setBinContent(2, 9,
std::sqrt(vals[8]));
1079 fitResults->setBinContent(2, 8,
std::sqrt(vals[9]));
1080 fitResults->setBinContent(2, 7,
std::sqrt(vals[10]));
1081 fitResults->setBinContent(2, 6,
std::sqrt(vals[11]));
1082 fitResults->setBinContent(2, 5,
std::sqrt(vals[12]));
1083 fitResults->setBinContent(2, 4,
std::sqrt(vals[13]));
1084 fitResults->setBinContent(2, 3,
std::sqrt(vals[14]));
1085 fitResults->setBinContent(2, 2,
std::sqrt(vals[15]));
1086 fitResults->setBinContent(2, 1,
std::sqrt(counterVx));
1089 TF1* myLinFit =
new TF1(
"myLinFit",
"[0] + [1]*x", mXlumi->getTH1()->GetXaxis()->GetXmin(), mXlumi->getTH1()->GetXaxis()->GetXmax());
1090 myLinFit->SetLineColor(2);
1091 myLinFit->SetLineWidth(2);
1092 myLinFit->SetParName(0,
"Inter.");
1093 myLinFit->SetParName(1,
"Slope");
1095 mXlumi->getTH1()->SetBinContent(lastLumiOfFit, vals[0]);
1096 mXlumi->getTH1()->SetBinError(lastLumiOfFit,
std::sqrt(vals[8]));
1097 myLinFit->SetParameter(0, mXlumi->getTH1()->GetMean(2));
1098 myLinFit->SetParameter(1, 0.0);
1099 mXlumi->getTH1()->Fit(myLinFit,
"QR");
1101 mYlumi->getTH1()->SetBinContent(lastLumiOfFit, vals[1]);
1102 mYlumi->getTH1()->SetBinError(lastLumiOfFit,
std::sqrt(vals[9]));
1103 myLinFit->SetParameter(0, mYlumi->getTH1()->GetMean(2));
1104 myLinFit->SetParameter(1, 0.0);
1105 mYlumi->getTH1()->Fit(myLinFit,
"QR");
1107 mZlumi->getTH1()->SetBinContent(lastLumiOfFit, vals[2]);
1108 mZlumi->getTH1()->SetBinError(lastLumiOfFit,
std::sqrt(vals[10]));
1109 myLinFit->SetParameter(0, mZlumi->getTH1()->GetMean(2));
1110 myLinFit->SetParameter(1, 0.0);
1111 mZlumi->getTH1()->Fit(myLinFit,
"QR");
1113 sXlumi->getTH1()->SetBinContent(lastLumiOfFit, vals[3]);
1114 sXlumi->getTH1()->SetBinError(lastLumiOfFit,
std::sqrt(vals[11]));
1115 myLinFit->SetParameter(0, sXlumi->getTH1()->GetMean(2));
1116 myLinFit->SetParameter(1, 0.0);
1117 sXlumi->getTH1()->Fit(myLinFit,
"QR");
1119 sYlumi->getTH1()->SetBinContent(lastLumiOfFit, vals[4]);
1120 sYlumi->getTH1()->SetBinError(lastLumiOfFit,
std::sqrt(vals[12]));
1121 myLinFit->SetParameter(0, sYlumi->getTH1()->GetMean(2));
1122 myLinFit->SetParameter(1, 0.0);
1123 sYlumi->getTH1()->Fit(myLinFit,
"QR");
1125 sZlumi->getTH1()->SetBinContent(lastLumiOfFit, vals[5]);
1126 sZlumi->getTH1()->SetBinError(lastLumiOfFit,
std::sqrt(vals[13]));
1127 myLinFit->SetParameter(0, sZlumi->getTH1()->GetMean(2));
1128 myLinFit->SetParameter(1, 0.0);
1129 sZlumi->getTH1()->Fit(myLinFit,
"QR");
1131 dxdzlumi->getTH1()->SetBinContent(lastLumiOfFit, vals[6]);
1132 dxdzlumi->getTH1()->SetBinError(lastLumiOfFit,
std::sqrt(vals[14]));
1133 myLinFit->SetParameter(0, dxdzlumi->getTH1()->GetMean(2));
1134 myLinFit->SetParameter(1, 0.0);
1135 dxdzlumi->getTH1()->Fit(myLinFit,
"QR");
1137 dydzlumi->getTH1()->SetBinContent(lastLumiOfFit, vals[7]);
1138 dydzlumi->getTH1()->SetBinError(lastLumiOfFit,
std::sqrt(vals[15]));
1139 myLinFit->SetParameter(0, dydzlumi->getTH1()->GetMean(2));
1140 myLinFit->SetParameter(1, 0.0);
1141 dydzlumi->getTH1()->Fit(myLinFit,
"QR");
1143 myLinFit->SetParameter(0, hitCounter->getTH1()->GetMean(2));
1144 myLinFit->SetParameter(1, 0.0);
1145 hitCounter->getTH1()->Fit(myLinFit,
"QR");
1147 goodVxCounter->getTH1()->SetBinContent(lastLumiOfFit, (
double)counterVx);
1148 goodVxCounter->getTH1()->SetBinError(lastLumiOfFit, (counterVx != 0 ? 1. : 0.));
1149 myLinFit->SetParameter(0, goodVxCounter->getTH1()->GetMean(2));
1150 myLinFit->SetParameter(1, 0.0);
1151 goodVxCounter->getTH1()->Fit(myLinFit,
"QR");
1156 else if ((nLumiFit != 0) && (lumiCounter%nLumiFit != 0) && (beginTimeOfFit != 0) && (
runNumber != 0))
1158 histTitle <<
"Ongoing: accumulating evts (" << lumiCounter%nLumiFit <<
" - " << nLumiFit <<
" in " << lumiCounter <<
" - " << maxLumiIntegration <<
" lumis)";
1159 fitResults->setAxisTitle(histTitle.str().c_str(), 1);
1160 if ((debugMode ==
true) && (outputDebugFile.is_open() ==
true))
1162 outputDebugFile <<
"\n" <<
"Runnumber " <<
runNumber << endl;
1163 outputDebugFile <<
"BeginTimeOfFit " <<
formatTime(beginTimeOfFit >> 32) <<
" " << (beginTimeOfFit >> 32) << endl;
1164 outputDebugFile <<
"BeginLumiRange " << beginLumiOfFit << endl;
1165 outputDebugFile << histTitle.str().c_str() <<
"\n" << endl;
1168 else if ((nLumiFit == 0) || (beginTimeOfFit == 0) || (
runNumber == 0))
1170 histTitle <<
"Ongoing: no ongoing fits";
1171 fitResults->setAxisTitle(histTitle.str().c_str(), 1);
1172 if ((debugMode ==
true) && (outputDebugFile.is_open() ==
true)) outputDebugFile << histTitle.str().c_str() <<
"\n" << endl;
1176 hitCounter->getTH1()->SetBinContent(endLumiOfFit, (
double)totalHits);
1177 hitCounter->getTH1()->SetBinError(endLumiOfFit,
std::sqrt((
double)totalHits));
1182 if (internalDebug ==
true)
cout <<
"[Vx3DHLTAnalyzer]::\tHistogram title: " << histTitle.str() << endl;
1190 Vx_X = ibooker.
book1D(
"F - vertex x",
"Primary Vertex X Distribution",
int(rint(xRange/xStep)), -xRange/2., xRange/2.);
1191 Vx_Y = ibooker.
book1D(
"F - vertex y",
"Primary Vertex Y Distribution",
int(rint(yRange/yStep)), -yRange/2., yRange/2.);
1192 Vx_Z = ibooker.
book1D(
"F - vertex z",
"Primary Vertex Z Distribution",
int(rint(zRange/
zStep)), -zRange/2., zRange/2.);
1194 Vx_X->setAxisTitle(
"Entries [#]",2);
1195 Vx_Y->setAxisTitle(
"Primary Vertices Y [cm]",1);
1196 Vx_Y->setAxisTitle(
"Entries [#]",2);
1197 Vx_Z->setAxisTitle(
"Primary Vertices Z [cm]",1);
1198 Vx_Z->setAxisTitle(
"Entries [#]",2);
1200 Vx_X_Cum = ibooker.
book1D(
"H - vertex x cum",
"Primary Vertex X Distribution (Cumulative)",
int(rint(xRange/xStep)), -xRange/2., xRange/2.);
1201 Vx_Y_Cum = ibooker.
book1D(
"H - vertex y cum",
"Primary Vertex Y Distribution (Cumulative)",
int(rint(yRange/yStep)), -yRange/2., yRange/2.);
1202 Vx_Z_Cum = ibooker.
book1D(
"H - vertex z cum",
"Primary Vertex Z Distribution (Cumulative)",
int(rint(zRange/
zStep)), -zRange/2., zRange/2.);
1204 Vx_X_Cum->setAxisTitle(
"Entries [#]",2);
1205 Vx_Y_Cum->setAxisTitle(
"Primary Vertices Y [cm]",1);
1206 Vx_Y_Cum->setAxisTitle(
"Entries [#]",2);
1207 Vx_Z_Cum->setAxisTitle(
"Primary Vertices Z [cm]",1);
1208 Vx_Z_Cum->setAxisTitle(
"Entries [#]",2);
1210 mXlumi = ibooker.
book1D(
"B - muX vs lumi",
"#mu_{x} vs. Lumisection", nLumiXaxisRange, 0.5, ((
double)nLumiXaxisRange)+0.5);
1211 mYlumi = ibooker.
book1D(
"B - muY vs lumi",
"#mu_{y} vs. Lumisection", nLumiXaxisRange, 0.5, ((
double)nLumiXaxisRange)+0.5);
1212 mZlumi = ibooker.
book1D(
"B - muZ vs lumi",
"#mu_{z} vs. Lumisection", nLumiXaxisRange, 0.5, ((
double)nLumiXaxisRange)+0.5);
1214 mXlumi->setAxisTitle(
"#mu_{x} [cm]",2);
1215 mXlumi->getTH1()->SetOption(
"E1");
1216 mYlumi->setAxisTitle(
"Lumisection [#]",1);
1217 mYlumi->setAxisTitle(
"#mu_{y} [cm]",2);
1218 mYlumi->getTH1()->SetOption(
"E1");
1219 mZlumi->setAxisTitle(
"Lumisection [#]",1);
1220 mZlumi->setAxisTitle(
"#mu_{z} [cm]",2);
1221 mZlumi->getTH1()->SetOption(
"E1");
1223 sXlumi = ibooker.
book1D(
"C - sigmaX vs lumi",
"#sigma_{x} vs. Lumisection", nLumiXaxisRange, 0.5, ((
double)nLumiXaxisRange)+0.5);
1224 sYlumi = ibooker.
book1D(
"C - sigmaY vs lumi",
"#sigma_{y} vs. Lumisection", nLumiXaxisRange, 0.5, ((
double)nLumiXaxisRange)+0.5);
1225 sZlumi = ibooker.
book1D(
"C - sigmaZ vs lumi",
"#sigma_{z} vs. Lumisection", nLumiXaxisRange, 0.5, ((
double)nLumiXaxisRange)+0.5);
1227 sXlumi->setAxisTitle(
"#sigma_{x} [cm]",2);
1228 sXlumi->getTH1()->SetOption(
"E1");
1229 sYlumi->setAxisTitle(
"Lumisection [#]",1);
1230 sYlumi->setAxisTitle(
"#sigma_{y} [cm]",2);
1231 sYlumi->getTH1()->SetOption(
"E1");
1232 sZlumi->setAxisTitle(
"Lumisection [#]",1);
1233 sZlumi->setAxisTitle(
"#sigma_{z} [cm]",2);
1234 sZlumi->getTH1()->SetOption(
"E1");
1236 dxdzlumi = ibooker.
book1D(
"D - dxdz vs lumi",
"dX/dZ vs. Lumisection", nLumiXaxisRange, 0.5, ((
double)nLumiXaxisRange)+0.5);
1237 dydzlumi = ibooker.
book1D(
"D - dydz vs lumi",
"dY/dZ vs. Lumisection", nLumiXaxisRange, 0.5, ((
double)nLumiXaxisRange)+0.5);
1239 dxdzlumi->setAxisTitle(
"dX/dZ [rad]",2);
1240 dxdzlumi->getTH1()->SetOption(
"E1");
1241 dydzlumi->setAxisTitle(
"Lumisection [#]",1);
1242 dydzlumi->setAxisTitle(
"dY/dZ [rad]",2);
1243 dydzlumi->getTH1()->SetOption(
"E1");
1245 Vx_ZX = ibooker.
book2D(
"E - vertex zx",
"Primary Vertex ZX Distribution",
int(rint(zRange/
zStep)), -zRange/2., zRange/2.,
int(rint(xRange/xStep)), -xRange/2., xRange/2.);
1246 Vx_ZY = ibooker.
book2D(
"E - vertex zy",
"Primary Vertex ZY Distribution",
int(rint(zRange/
zStep)), -zRange/2., zRange/2.,
int(rint(yRange/yStep)), -yRange/2., yRange/2.);
1247 Vx_XY = ibooker.
book2D(
"E - vertex xy",
"Primary Vertex XY Distribution",
int(rint(xRange/xStep)), -xRange/2., xRange/2.,
int(rint(yRange/yStep)), -yRange/2., yRange/2.);
1249 Vx_ZX->setAxisTitle(
"Primary Vertices X [cm]",2);
1250 Vx_ZX->setAxisTitle(
"Entries [#]",3);
1251 Vx_ZY->setAxisTitle(
"Primary Vertices Z [cm]",1);
1252 Vx_ZY->setAxisTitle(
"Primary Vertices Y [cm]",2);
1253 Vx_ZY->setAxisTitle(
"Entries [#]",3);
1254 Vx_XY->setAxisTitle(
"Primary Vertices X [cm]",1);
1255 Vx_XY->setAxisTitle(
"Primary Vertices Y [cm]",2);
1256 Vx_XY->setAxisTitle(
"Entries [#]",3);
1258 Vx_ZX_Cum = ibooker.
book2D(
"G - vertex zx cum",
"Primary Vertex ZX Distribution (Cumulative)",
int(rint(zRange/
zStep)), -zRange/2., zRange/2.,
int(rint(xRange/xStep)), -xRange/2., xRange/2.);
1259 Vx_ZY_Cum = ibooker.
book2D(
"G - vertex zy cum",
"Primary Vertex ZY Distribution (Cumulative)",
int(rint(zRange/
zStep)), -zRange/2., zRange/2.,
int(rint(yRange/yStep)), -yRange/2., yRange/2.);
1260 Vx_XY_Cum = ibooker.
book2D(
"G - vertex xy cum",
"Primary Vertex XY Distribution (Cumulative)",
int(rint(xRange/xStep)), -xRange/2., xRange/2.,
int(rint(yRange/yStep)), -yRange/2., yRange/2.);
1262 Vx_ZX_Cum->setAxisTitle(
"Primary Vertices X [cm]",2);
1263 Vx_ZX_Cum->setAxisTitle(
"Entries [#]",3);
1264 Vx_ZY_Cum->setAxisTitle(
"Primary Vertices Z [cm]",1);
1265 Vx_ZY_Cum->setAxisTitle(
"Primary Vertices Y [cm]",2);
1266 Vx_ZY_Cum->setAxisTitle(
"Entries [#]",3);
1267 Vx_XY_Cum->setAxisTitle(
"Primary Vertices X [cm]",1);
1268 Vx_XY_Cum->setAxisTitle(
"Primary Vertices Y [cm]",2);
1269 Vx_XY_Cum->setAxisTitle(
"Entries [#]",3);
1271 hitCounter = ibooker.
book1D(
"J - pixelHits vs lumi",
"# Pixel-Hits vs. Lumisection", nLumiXaxisRange, 0.5, ((
double)nLumiXaxisRange)+0.5);
1273 hitCounter->setAxisTitle(
"Pixel-Hits [#]",2);
1274 hitCounter->getTH1()->SetOption(
"E1");
1276 goodVxCounter = ibooker.
book1D(
"I - good vertices vs lumi",
"# Good vertices vs. Lumisection", nLumiXaxisRange, 0.5, ((
double)nLumiXaxisRange)+0.5);
1278 goodVxCounter->setAxisTitle(
"Good vertices [#]",2);
1279 goodVxCounter->getTH1()->SetOption(
"E1");
1281 statusCounter = ibooker.
book1D(
"K - status vs lumi",
"App. Status vs. Lumisection", nLumiXaxisRange, 0.5, ((
double)nLumiXaxisRange)+0.5);
1283 statusCounter->getTH1()->SetOption(
"E1");
1284 statusCounter->getTH1()->GetYaxis()->Set(11,-5.5,5.5);
1285 statusCounter->getTH1()->GetYaxis()->SetBinLabel(1,
"Max Lumi.");
1286 statusCounter->getTH1()->GetYaxis()->SetBinLabel(2,
"Neg. det.");
1287 statusCounter->getTH1()->GetYaxis()->SetBinLabel(3,
"Infinite err.");
1288 statusCounter->getTH1()->GetYaxis()->SetBinLabel(4,
"No vtx.");
1289 statusCounter->getTH1()->GetYaxis()->SetBinLabel(5,
"Infinite EDM");
1290 statusCounter->getTH1()->GetYaxis()->SetBinLabel(6,
"OK");
1291 statusCounter->getTH1()->GetYaxis()->SetBinLabel(7,
"MINUIT stat.");
1292 statusCounter->getTH1()->GetYaxis()->SetBinLabel(8,
"MINUIT stat.");
1293 statusCounter->getTH1()->GetYaxis()->SetBinLabel(9,
"MINUIT stat.");
1294 statusCounter->getTH1()->GetYaxis()->SetBinLabel(10,
"MINUIT stat.");
1295 statusCounter->getTH1()->GetYaxis()->SetBinLabel(11,
"MINUIT stat.");
1297 fitResults = ibooker.
book2D(
"A - fit results",
"Results of Beam Spot Fit", 2, 0., 2., 9, 0., 9.);
1299 fitResults->setBinLabel(9,
"X[cm]", 2);
1300 fitResults->setBinLabel(8,
"Y[cm]", 2);
1301 fitResults->setBinLabel(7,
"Z[cm]", 2);
1302 fitResults->setBinLabel(6,
"#sigma_{X}[cm]", 2);
1303 fitResults->setBinLabel(5,
"#sigma_{Y}[cm]", 2);
1304 fitResults->setBinLabel(4,
"#sigma_{Z}[cm]", 2);
1305 fitResults->setBinLabel(3,
"#frac{dX}{dZ}[rad]", 2);
1306 fitResults->setBinLabel(2,
"#frac{dY}{dZ}[rad]", 2);
1307 fitResults->setBinLabel(1,
"Vtx[#]", 2);
1308 fitResults->setBinLabel(1,
"Value", 1);
1309 fitResults->setBinLabel(2,
"Error (stat)", 1);
1310 fitResults->getTH1()->SetOption(
"text");
1315 reportSummary = ibooker.
bookFloat(
"reportSummary");
1316 reportSummary->
Fill(-1);
1317 reportSummaryMap = ibooker.
book2D(
"reportSummaryMap",
"Pixel-Vertices Beam Spot: % Good Fits", 1, 0., 1., 1, 0., 1.);
1318 reportSummaryMap->
getTH1()->SetBinContent(1, 1, -1);
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const_iterator end(bool update=false) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
int MyFit(std::vector< double > *vals)
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
void endLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup) override
data_type const * const_iterator
Timestamp const & beginTime() const
unsigned int HitCounter(const edm::Event &iEvent)
void beginLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup) override
double Gauss3DFunc(const double *par)
void writeToFile(std::vector< double > *vals, edm::TimeValue_t BeginTimeOfFit, edm::TimeValue_t EndTimeOfFit, unsigned int BeginLumiOfFit, unsigned int EndLumiOfFit, int dataType)
LuminosityBlockNumber_t luminosityBlock() const
T x() const
Cartesian x coordinate.
static ELstring formatTime(const time_t t)
Vx3DHLTAnalyzer(const edm::ParameterSet &)
std::string formatTime(const time_t &t)
Timestamp const & endTime() const
MonitorElement * book1D(Args &&...args)
LuminosityBlock const & getLuminosityBlock() const
void reset(std::string ResetType)
unsigned long long TimeValue_t
void setCurrentFolder(const std::string &fullpath)
MonitorElement * book2D(Args &&...args)
std::vector< std::vector< double > > tmp
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
void printFitParams(const std::vector< double > &fitResults)
static std::atomic< unsigned int > counter
MonitorElement * bookFloat(Args &&...args)
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void reset(double vett[256])
TimeValue_t value() const
Power< A, B >::type pow(const A &a, const B &b)
const_iterator begin(bool update=false) const