CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
Vx3DHLTAnalyzer Class Reference

#include <interface/Vx3DHLTAnalyzer.h>

Inheritance diagram for Vx3DHLTAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 Vx3DHLTAnalyzer (const ParameterSet &)
 
 ~Vx3DHLTAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void analyze (const Event &, const EventSetup &)
 
virtual void beginJob ()
 
virtual void beginLuminosityBlock (const LuminosityBlock &lumiBlock, const EventSetup &iSetup)
 
virtual void beginRun (const Run &iRun, const EventSetup &iSetup)
 
virtual void endJob ()
 
virtual void endLuminosityBlock (const LuminosityBlock &lumiBlock, const EventSetup &iSetup)
 
virtual string formatTime (const time_t &t)
 
virtual unsigned int HitCounter (const Event &iEvent)
 
virtual int MyFit (vector< double > *vals)
 
virtual void reset (string ResetType)
 
virtual void writeToFile (vector< double > *vals, TimeValue_t BeginTimeOfFit, TimeValue_t EndTimeOfFit, unsigned int BeginLumiOfFit, unsigned int EndLumiOfFit, int dataType)
 

Private Attributes

unsigned int beginLumiOfFit
 
TimeValue_t beginTimeOfFit
 
bool dataFromFit
 
bool debugMode
 
MonitorElementdxdzlumi
 
MonitorElementdydzlumi
 
unsigned int endLumiOfFit
 
TimeValue_t endTimeOfFit
 
string fileName
 
MonitorElementfitResults
 
MonitorElementgoodVxCounter
 
MonitorElementgoodVxCountHistory
 
MonitorElementhitCounter
 
MonitorElementhitCountHistory
 
bool internalDebug
 
unsigned int lastLumiOfFit
 
unsigned int lumiCounter
 
unsigned int lumiCounterHisto
 
unsigned int maxLumiIntegration
 
unsigned int minNentries
 
double minVxDoF
 
MonitorElementmXlumi
 
MonitorElementmYlumi
 
MonitorElementmZlumi
 
unsigned int nBinsHistoricalPlot
 
unsigned int nBinsWholeHistory
 
unsigned int nLumiReset
 
unsigned int numberFits
 
unsigned int numberGoodFits
 
ofstream outputDebugFile
 
ofstream outputFile
 
EDGetTokenT
< SiPixelRecHitCollection
pixelHitCollection
 
unsigned int prescaleHistory
 
MonitorElementreportSummary
 
MonitorElementreportSummaryMap
 
unsigned int runNumber
 
MonitorElementsXlumi
 
MonitorElementsYlumi
 
MonitorElementsZlumi
 
unsigned int totalHits
 
EDGetTokenT< VertexCollectionvertexCollection
 
MonitorElementVx_X
 
MonitorElementVx_XY
 
MonitorElementVx_Y
 
MonitorElementVx_Z
 
MonitorElementVx_ZX
 
MonitorElementVx_ZY
 
double xRange
 
double xStep
 
double yRange
 
double yStep
 
double zRange
 
double zStep
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: beam-spot monitor entirely based on pixel detector information Implementation: the monitoring is based on a 3D fit to the vertex cloud

Definition at line 75 of file Vx3DHLTAnalyzer.h.

Constructor & Destructor Documentation

Vx3DHLTAnalyzer::Vx3DHLTAnalyzer ( const ParameterSet iConfig)
explicit

Definition at line 26 of file Vx3DHLTAnalyzer.cc.

References dataFromFit, debugMode, fileName, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), minNentries, nLumiReset, pixelHitCollection, vertexCollection, VxErrCorr, xRange, xStep, yRange, yStep, zRange, and zStep.

27 {
28  debugMode = true;
29  nLumiReset = 2; // Number of integrated lumis to perform the fit
30  dataFromFit = true; // The Beam Spot data can be either taken from the histograms or from the fit results
31  minNentries = 20; // Minimum number of good vertices to perform the fit
32  xRange = 1.; // [cm]
33  xStep = 0.001; // [cm]
34  yRange = 1.; // [cm]
35  yStep = 0.001; // [cm]
36  zRange = 30.; // [cm]
37  zStep = 0.05; // [cm]
38  VxErrCorr = 1.3;
39  fileName = "BeamPixelResults.txt";
40 
41  vertexCollection = consumes<VertexCollection> (iConfig.getUntrackedParameter<InputTag>("vertexCollection", InputTag("pixelVertices")));
42  pixelHitCollection = consumes<SiPixelRecHitCollection>(iConfig.getUntrackedParameter<InputTag>("pixelHitCollection", InputTag("siPixelRecHits")));
43 
44  debugMode = iConfig.getParameter<bool>("debugMode");
45  nLumiReset = iConfig.getParameter<unsigned int>("nLumiReset");
46  dataFromFit = iConfig.getParameter<bool>("dataFromFit");
47  minNentries = iConfig.getParameter<unsigned int>("minNentries");
48  xRange = iConfig.getParameter<double>("xRange");
49  xStep = iConfig.getParameter<double>("xStep");
50  yRange = iConfig.getParameter<double>("yRange");
51  yStep = iConfig.getParameter<double>("yStep");
52  zRange = iConfig.getParameter<double>("zRange");
53  zStep = iConfig.getParameter<double>("zStep");
54  VxErrCorr = iConfig.getParameter<double>("VxErrCorr");
55  fileName = iConfig.getParameter<string>("fileName");
56 }
EDGetTokenT< SiPixelRecHitCollection > pixelHitCollection
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
unsigned int minNentries
unsigned int nLumiReset
EDGetTokenT< VertexCollection > vertexCollection
double VxErrCorr
Vx3DHLTAnalyzer::~Vx3DHLTAnalyzer ( )

Definition at line 59 of file Vx3DHLTAnalyzer.cc.

60 {
61 }

Member Function Documentation

void Vx3DHLTAnalyzer::analyze ( const Event iEvent,
const EventSetup iSetup 
)
privatevirtual

Implements edm::EDAnalyzer.

Definition at line 64 of file Vx3DHLTAnalyzer.cc.

References beginLuminosityBlock(), beginTimeOfFit, gather_cfg::cout, VertexType::Covariance, debugMode, DIM, fileName, MonitorElement::Fill(), edm::Event::getByToken(), edm::Event::getLuminosityBlock(), HitCounter(), i, edm::EventBase::id(), internalDebug, edm::isNotFinite(), j, minVxDoF, dbtoconf::out, outputDebugFile, reset(), edm::EventID::run(), runNumber, tmp, totalHits, vertexCollection, Vertices, Vx_X, Vx_XY, Vx_Y, Vx_Z, Vx_ZX, Vx_ZY, VertexType::x, VertexType::y, and VertexType::z.

65 {
66  Handle<VertexCollection> Vx3DCollection;
67  iEvent.getByToken(vertexCollection, Vx3DCollection);
68 
69  unsigned int i,j;
70  double det;
71  VertexType MyVertex;
72 
73  if (runNumber != iEvent.id().run())
74  {
75  reset("scratch");
76  runNumber = iEvent.id().run();
77 
78  if (debugMode == true)
79  {
80  stringstream debugFile;
81  string tmp(fileName);
82 
83  if (outputDebugFile.is_open() == true) outputDebugFile.close();
84  tmp.erase(strlen(fileName.c_str())-4,4);
85  debugFile << tmp.c_str() << "_Run" << iEvent.id().run() << ".txt";
86  outputDebugFile.open(debugFile.str().c_str(), ios::out);
87  outputDebugFile.close();
88  outputDebugFile.open(debugFile.str().c_str(), ios::app);
89  }
90 
92  }
93  else if (beginTimeOfFit != 0)
94  {
95  totalHits += HitCounter(iEvent);
96 
97  for (vector<Vertex>::const_iterator it3DVx = Vx3DCollection->begin(); it3DVx != Vx3DCollection->end(); it3DVx++)
98  {
99  if ((it3DVx->isValid() == true) &&
100  (it3DVx->isFake() == false) &&
101  (it3DVx->ndof() >= minVxDoF))
102  {
103  for (i = 0; i < DIM; i++)
104  {
105  for (j = 0; j < DIM; j++)
106  {
107  MyVertex.Covariance[i][j] = it3DVx->covariance(i,j);
108  if (isNotFinite(MyVertex.Covariance[i][j]) == true) break;
109  }
110  if (j != DIM) break;
111  }
112  det = std::fabs(MyVertex.Covariance[0][0])*(std::fabs(MyVertex.Covariance[1][1])*std::fabs(MyVertex.Covariance[2][2]) - MyVertex.Covariance[1][2]*MyVertex.Covariance[1][2]) -
113  MyVertex.Covariance[0][1]*(MyVertex.Covariance[0][1]*std::fabs(MyVertex.Covariance[2][2]) - MyVertex.Covariance[0][2]*MyVertex.Covariance[1][2]) +
114  MyVertex.Covariance[0][2]*(MyVertex.Covariance[0][1]*MyVertex.Covariance[1][2] - MyVertex.Covariance[0][2]*std::fabs(MyVertex.Covariance[1][1]));
115  if ((i == DIM) && (det > 0.))
116  {
117  MyVertex.x = it3DVx->x();
118  MyVertex.y = it3DVx->y();
119  MyVertex.z = it3DVx->z();
120  Vertices.push_back(MyVertex);
121  }
122  else if (internalDebug == true)
123  {
124  cout << "Vertex discarded !" << endl;
125  for (i = 0; i < DIM; i++)
126  for (j = 0; j < DIM; j++)
127  cout << "(i,j) --> " << i << "," << j << " --> " << MyVertex.Covariance[i][j] << endl;
128  }
129 
130  Vx_X->Fill(it3DVx->x());
131  Vx_Y->Fill(it3DVx->y());
132  Vx_Z->Fill(it3DVx->z());
133 
134  Vx_ZX->Fill(it3DVx->z(), it3DVx->x());
135  Vx_ZY->Fill(it3DVx->z(), it3DVx->y());
136  Vx_XY->Fill(it3DVx->x(), it3DVx->y());
137  }
138  }
139  }
140 }
RunNumber_t run() const
Definition: EventID.h:39
int i
Definition: DBlmapReader.cc:9
MonitorElement * Vx_ZX
unsigned int totalHits
virtual unsigned int HitCounter(const Event &iEvent)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
vector< VertexType > Vertices
MonitorElement * Vx_X
virtual void beginLuminosityBlock(const LuminosityBlock &lumiBlock, const EventSetup &iSetup)
void Fill(long long x)
MonitorElement * Vx_XY
double Covariance[3][3]
bool isNotFinite(T x)
Definition: isFinite.h:10
MonitorElement * Vx_ZY
int j
Definition: DBlmapReader.cc:9
LuminosityBlock const & getLuminosityBlock() const
Definition: Event.h:77
MonitorElement * Vx_Z
tuple out
Definition: dbtoconf.py:99
ofstream outputDebugFile
#define DIM
TimeValue_t beginTimeOfFit
EDGetTokenT< VertexCollection > vertexCollection
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
edm::EventID id() const
Definition: EventBase.h:56
unsigned int runNumber
tuple cout
Definition: gather_cfg.py:121
virtual void reset(string ResetType)
MonitorElement * Vx_Y
void Vx3DHLTAnalyzer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 1067 of file Vx3DHLTAnalyzer.cc.

References considerVxCovariance, internalDebug, maxLumiIntegration, minVxDoF, pi, and prescaleHistory.

1068 {
1069  // ### Set internal variables ###
1070  prescaleHistory = 1; // Set the number of lumis to update historical plot
1071  maxLumiIntegration = 15; // If failing fits, this is the maximum number of integrated lumis after which a reset is issued
1072  minVxDoF = 10.; // Good vertex selection cut
1073  // For vertex fitter without track-weight: d.o.f. = 2*NTracks - 3
1074  // For vertex fitter with track-weight: d.o.f. = sum_NTracks(2*track_weight) - 3
1075  internalDebug = false;
1076  considerVxCovariance = true; // Deconvolute vertex covariance matrix
1077  pi = 3.141592653589793238;
1078  // ##############################
1079 }
unsigned int maxLumiIntegration
const Double_t pi
bool considerVxCovariance
unsigned int prescaleHistory
void Vx3DHLTAnalyzer::beginLuminosityBlock ( const LuminosityBlock lumiBlock,
const EventSetup iSetup 
)
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 773 of file Vx3DHLTAnalyzer.cc.

References beginLumiOfFit, edm::LuminosityBlockBase::beginTime(), beginTimeOfFit, lastLumiOfFit, lumiCounter, lumiCounterHisto, edm::LuminosityBlockBase::luminosityBlock(), and edm::Timestamp::value().

Referenced by analyze().

774 {
775  if ((lumiCounter == 0) && (lumiBlock.luminosityBlock() > lastLumiOfFit))
776  {
777  beginTimeOfFit = lumiBlock.beginTime().value();
778  beginLumiOfFit = lumiBlock.luminosityBlock();
779  lumiCounter++;
781  }
782  else if ((lumiCounter != 0) && (lumiBlock.luminosityBlock() >= (beginLumiOfFit+lumiCounter))) { lumiCounter++; lumiCounterHisto++; }
783 }
unsigned int lumiCounter
unsigned int beginLumiOfFit
Timestamp const & beginTime() const
LuminosityBlockNumber_t luminosityBlock() const
unsigned int lastLumiOfFit
unsigned int lumiCounterHisto
TimeValue_t beginTimeOfFit
TimeValue_t value() const
Definition: Timestamp.h:56
void Vx3DHLTAnalyzer::beginRun ( const Run iRun,
const EventSetup iSetup 
)
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 1085 of file Vx3DHLTAnalyzer.cc.

References AlcaSiStripGainsHarvester_cff::DQMStore, dxdzlumi, dydzlumi, MonitorElement::Fill(), fitResults, MonitorElement::getTH1(), goodVxCounter, goodVxCountHistory, hitCounter, hitCountHistory, mXlumi, mYlumi, mZlumi, nBinsHistoricalPlot, nBinsWholeHistory, cppFunctionSkipper::operator, reportSummary, reportSummaryMap, reset(), MonitorElement::setAxisTitle(), MonitorElement::setBinLabel(), sXlumi, sYlumi, sZlumi, Vx_X, Vx_XY, Vx_Y, Vx_Z, Vx_ZX, Vx_ZY, xRange, xStep, yRange, yStep, zRange, and zStep.

1086 {
1087  DQMStore* dbe = 0;
1088  dbe = Service<DQMStore>().operator->();
1089 
1090  // ### Set internal variables ###
1091  nBinsHistoricalPlot = 80;
1092  nBinsWholeHistory = 3000; // Correspond to about 20h of data taking: 20h * 60min * 60s / 23s per lumi-block = 3130
1093  // ##############################
1094 
1095  if ( dbe )
1096  {
1097  dbe->setCurrentFolder("BeamPixel");
1098 
1099  Vx_X = dbe->book1D("vertex x", "Primary Vertex X Coordinate Distribution", int(rint(xRange/xStep)), -xRange/2., xRange/2.);
1100  Vx_Y = dbe->book1D("vertex y", "Primary Vertex Y Coordinate Distribution", int(rint(yRange/yStep)), -yRange/2., yRange/2.);
1101  Vx_Z = dbe->book1D("vertex z", "Primary Vertex Z Coordinate Distribution", int(rint(zRange/zStep)), -zRange/2., zRange/2.);
1102  Vx_X->setAxisTitle("Primary Vertices X [cm]",1);
1103  Vx_X->setAxisTitle("Entries [#]",2);
1104  Vx_Y->setAxisTitle("Primary Vertices Y [cm]",1);
1105  Vx_Y->setAxisTitle("Entries [#]",2);
1106  Vx_Z->setAxisTitle("Primary Vertices Z [cm]",1);
1107  Vx_Z->setAxisTitle("Entries [#]",2);
1108 
1109  mXlumi = dbe->book1D("muX vs lumi", "#mu_{x} vs. Lumisection", nBinsHistoricalPlot, 0.5, (double)nBinsHistoricalPlot+0.5);
1110  mYlumi = dbe->book1D("muY vs lumi", "#mu_{y} vs. Lumisection", nBinsHistoricalPlot, 0.5, (double)nBinsHistoricalPlot+0.5);
1111  mZlumi = dbe->book1D("muZ vs lumi", "#mu_{z} vs. Lumisection", nBinsHistoricalPlot, 0.5, (double)nBinsHistoricalPlot+0.5);
1112  mXlumi->setAxisTitle("Lumisection [#]",1);
1113  mXlumi->setAxisTitle("#mu_{x} [cm]",2);
1114  mXlumi->getTH1()->SetOption("E1");
1115  mYlumi->setAxisTitle("Lumisection [#]",1);
1116  mYlumi->setAxisTitle("#mu_{y} [cm]",2);
1117  mYlumi->getTH1()->SetOption("E1");
1118  mZlumi->setAxisTitle("Lumisection [#]",1);
1119  mZlumi->setAxisTitle("#mu_{z} [cm]",2);
1120  mZlumi->getTH1()->SetOption("E1");
1121 
1122  sXlumi = dbe->book1D("sigmaX vs lumi", "#sigma_{x} vs. Lumisection", nBinsHistoricalPlot, 0.5, (double)nBinsHistoricalPlot+0.5);
1123  sYlumi = dbe->book1D("sigmaY vs lumi", "#sigma_{y} vs. Lumisection", nBinsHistoricalPlot, 0.5, (double)nBinsHistoricalPlot+0.5);
1124  sZlumi = dbe->book1D("sigmaZ vs lumi", "#sigma_{z} vs. Lumisection", nBinsHistoricalPlot, 0.5, (double)nBinsHistoricalPlot+0.5);
1125  sXlumi->setAxisTitle("Lumisection [#]",1);
1126  sXlumi->setAxisTitle("#sigma_{x} [cm]",2);
1127  sXlumi->getTH1()->SetOption("E1");
1128  sYlumi->setAxisTitle("Lumisection [#]",1);
1129  sYlumi->setAxisTitle("#sigma_{y} [cm]",2);
1130  sYlumi->getTH1()->SetOption("E1");
1131  sZlumi->setAxisTitle("Lumisection [#]",1);
1132  sZlumi->setAxisTitle("#sigma_{z} [cm]",2);
1133  sZlumi->getTH1()->SetOption("E1");
1134 
1135  dxdzlumi = dbe->book1D("dxdz vs lumi", "dX/dZ vs. Lumisection", nBinsHistoricalPlot, 0.5, (double)nBinsHistoricalPlot+0.5);
1136  dydzlumi = dbe->book1D("dydz vs lumi", "dY/dZ vs. Lumisection", nBinsHistoricalPlot, 0.5, (double)nBinsHistoricalPlot+0.5);
1137  dxdzlumi->setAxisTitle("Lumisection [#]",1);
1138  dxdzlumi->setAxisTitle("dX/dZ [rad]",2);
1139  dxdzlumi->getTH1()->SetOption("E1");
1140  dydzlumi->setAxisTitle("Lumisection [#]",1);
1141  dydzlumi->setAxisTitle("dY/dZ [rad]",2);
1142  dydzlumi->getTH1()->SetOption("E1");
1143 
1144  Vx_ZX = dbe->book2D("vertex zx", "Primary Vertex ZX Coordinate Distribution", int(rint(zRange/zStep/5.)), -zRange/2., zRange/2., int(rint(xRange/xStep/5.)), -xRange/2., xRange/2.);
1145  Vx_ZY = dbe->book2D("vertex zy", "Primary Vertex ZY Coordinate Distribution", int(rint(zRange/zStep/5.)), -zRange/2., zRange/2., int(rint(yRange/yStep/5.)), -yRange/2., yRange/2.);
1146  Vx_XY = dbe->book2D("vertex xy", "Primary Vertex XY Coordinate Distribution", int(rint(xRange/xStep/5.)), -xRange/2., xRange/2., int(rint(yRange/yStep/5.)), -yRange/2., yRange/2.);
1147  Vx_ZX->setAxisTitle("Primary Vertices Z [cm]",1);
1148  Vx_ZX->setAxisTitle("Primary Vertices X [cm]",2);
1149  Vx_ZX->setAxisTitle("Entries [#]",3);
1150  Vx_ZY->setAxisTitle("Primary Vertices Z [cm]",1);
1151  Vx_ZY->setAxisTitle("Primary Vertices Y [cm]",2);
1152  Vx_ZY->setAxisTitle("Entries [#]",3);
1153  Vx_XY->setAxisTitle("Primary Vertices X [cm]",1);
1154  Vx_XY->setAxisTitle("Primary Vertices Y [cm]",2);
1155  Vx_XY->setAxisTitle("Entries [#]",3);
1156 
1157  hitCounter = dbe->book1D("pixelHits vs lumi", "# Pixel-Hits vs. Lumisection", nBinsHistoricalPlot, 0.5, (double)nBinsHistoricalPlot+0.5);
1158  hitCounter->setAxisTitle("Lumisection [#]",1);
1159  hitCounter->setAxisTitle("Pixel-Hits [#]",2);
1160  hitCounter->getTH1()->SetOption("E1");
1161 
1162  hitCountHistory = dbe->book1D("hist pixelHits vs lumi", "History: # Pixel-Hits vs. Lumi", nBinsWholeHistory, 0.5, (double)nBinsWholeHistory+0.5);
1163  hitCountHistory->setAxisTitle("Lumisection [#]",1);
1164  hitCountHistory->setAxisTitle("Pixel-Hits [#]",2);
1165  hitCountHistory->getTH1()->SetOption("E1");
1166 
1167  goodVxCounter = dbe->book1D("good vertices vs lumi", "# Good vertices vs. Lumisection", nBinsHistoricalPlot, 0.5, (double)nBinsHistoricalPlot+0.5);
1168  goodVxCounter->setAxisTitle("Lumisection [#]",1);
1169  goodVxCounter->setAxisTitle("Good vertices [#]",2);
1170  goodVxCounter->getTH1()->SetOption("E1");
1171 
1172  goodVxCountHistory = dbe->book1D("hist good vx vs lumi", "History: # Good vx vs. Lumi", nBinsWholeHistory, 0.5, (double)nBinsWholeHistory+0.5);
1173  goodVxCountHistory->setAxisTitle("Lumisection [#]",1);
1174  goodVxCountHistory->setAxisTitle("Good vertices [#]",2);
1175  goodVxCountHistory->getTH1()->SetOption("E1");
1176 
1177  fitResults = dbe->book2D("fit results","Results of Beam Spot Fit", 2, 0., 2., 9, 0., 9.);
1178  fitResults->setAxisTitle("Fitted Beam Spot [cm]", 1);
1179  fitResults->setBinLabel(9, "X", 2);
1180  fitResults->setBinLabel(8, "Y", 2);
1181  fitResults->setBinLabel(7, "Z", 2);
1182  fitResults->setBinLabel(6, "#sigma_{Z}", 2);
1183  fitResults->setBinLabel(5, "#frac{dX}{dZ}[rad]", 2);
1184  fitResults->setBinLabel(4, "#frac{dY}{dZ}[rad]", 2);
1185  fitResults->setBinLabel(3, "#sigma_{X}", 2);
1186  fitResults->setBinLabel(2, "#sigma_{Y}", 2);
1187  fitResults->setBinLabel(1, "Vertices", 2);
1188  fitResults->setBinLabel(1, "Value", 1);
1189  fitResults->setBinLabel(2, "Stat. Error", 1);
1190  fitResults->getTH1()->SetOption("text");
1191 
1192  dbe->setCurrentFolder("BeamPixel/EventInfo");
1193  reportSummary = dbe->bookFloat("reportSummary");
1194  reportSummary->Fill(0.);
1195  reportSummaryMap = dbe->book2D("reportSummaryMap","Pixel-Vertices Beam Spot: % Good Fits", 1, 0., 1., 1, 0., 1.);
1196  reportSummaryMap->Fill(0.5, 0.5, 0.);
1197  dbe->setCurrentFolder("BeamPixel/EventInfo/reportSummaryContents");
1198 
1199  // Convention for reportSummary and reportSummaryMap:
1200  // - 0% at the moment of creation of the histogram
1201  // - n% numberGoodFits / numberFits
1202 
1203  reset("scratch"); // Initialize histograms after creation
1204  }
1205 }
MonitorElement * dxdzlumi
MonitorElement * Vx_ZX
MonitorElement * hitCountHistory
MonitorElement * Vx_X
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
MonitorElement * mYlumi
MonitorElement * sYlumi
MonitorElement * reportSummaryMap
unsigned int nBinsHistoricalPlot
void Fill(long long x)
MonitorElement * Vx_XY
MonitorElement * sZlumi
MonitorElement * fitResults
MonitorElement * Vx_ZY
MonitorElement * reportSummary
MonitorElement * goodVxCounter
MonitorElement * dydzlumi
TH1 * getTH1(void) const
MonitorElement * Vx_Z
MonitorElement * mXlumi
MonitorElement * mZlumi
MonitorElement * sXlumi
unsigned int nBinsWholeHistory
MonitorElement * goodVxCountHistory
MonitorElement * hitCounter
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
virtual void reset(string ResetType)
MonitorElement * Vx_Y
void Vx3DHLTAnalyzer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 1082 of file Vx3DHLTAnalyzer.cc.

References reset().

1082 { reset("scratch"); }
virtual void reset(string ResetType)
void Vx3DHLTAnalyzer::endLuminosityBlock ( const LuminosityBlock lumiBlock,
const EventSetup iSetup 
)
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 786 of file Vx3DHLTAnalyzer.cc.

References beginLumiOfFit, beginTimeOfFit, counterVx, gather_cfg::cout, dataFromFit, dxdzlumi, dydzlumi, endLumiOfFit, edm::LuminosityBlockBase::endTime(), endTimeOfFit, MonitorElement::Fill(), fitResults, MonitorElement::getTH1(), MonitorElement::getTH1F(), goodVxCounter, goodVxCountHistory, hitCounter, hitCountHistory, i, internalDebug, lastLumiOfFit, lumiCounter, lumiCounterHisto, edm::LuminosityBlockBase::luminosityBlock(), maxLumiIntegration, minNentries, mXlumi, MyFit(), mYlumi, mZlumi, nBinsWholeHistory, nLumiReset, numberFits, numberGoodFits, outputDebugFile, funct::pow(), prescaleHistory, reportSummary, reportSummaryMap, reset(), runNumber, MonitorElement::setAxisTitle(), MonitorElement::setBinContent(), MonitorElement::ShiftFillLast(), mathSSE::sqrt(), sXlumi, sYlumi, sZlumi, totalHits, create_public_pileup_plots::vals, edm::Timestamp::value(), Vx_X, Vx_Y, Vx_Z, and writeToFile().

787 {
788  stringstream histTitle;
789  int goodData;
790  unsigned int nParams = 9;
791 
792  if ((lumiCounter%nLumiReset == 0) && (nLumiReset != 0) && (beginTimeOfFit != 0) && (runNumber != 0))
793  {
794  endTimeOfFit = lumiBlock.endTime().value();
795  endLumiOfFit = lumiBlock.luminosityBlock();
797  vector<double> vals;
798 
799  hitCounter->ShiftFillLast((double)totalHits, std::sqrt((double)totalHits), nLumiReset);
800 
801  if (lastLumiOfFit % prescaleHistory == 0)
802  {
803  hitCountHistory->getTH1()->SetBinContent(lastLumiOfFit, (double)totalHits);
804  hitCountHistory->getTH1()->SetBinError(lastLumiOfFit, std::sqrt((double)totalHits));
805  }
806 
807  if (dataFromFit == true)
808  {
809  vector<double> fitResults;
810 
811  fitResults.push_back(Vx_X->getTH1()->GetRMS()*Vx_X->getTH1()->GetRMS());
812  fitResults.push_back(Vx_Y->getTH1()->GetRMS()*Vx_Y->getTH1()->GetRMS());
813  fitResults.push_back(Vx_Z->getTH1()->GetRMS()*Vx_Z->getTH1()->GetRMS());
814  fitResults.push_back(0.0);
815  fitResults.push_back(0.0);
816  fitResults.push_back(0.0);
817  fitResults.push_back(Vx_X->getTH1()->GetMean());
818  fitResults.push_back(Vx_Y->getTH1()->GetMean());
819  fitResults.push_back(Vx_Z->getTH1()->GetMean());
820  for (unsigned int i = 0; i < nParams; i++) fitResults.push_back(0.0);
821 
822  goodData = MyFit(&fitResults);
823 
824  if (internalDebug == true)
825  {
826  cout << "goodData --> " << goodData << endl;
827  cout << "Used vertices --> " << counterVx << endl;
828  cout << "var x --> " << fitResults[0] << " +/- " << fitResults[0+nParams] << endl;
829  cout << "var y --> " << fitResults[1] << " +/- " << fitResults[1+nParams] << endl;
830  cout << "var z --> " << fitResults[2] << " +/- " << fitResults[2+nParams] << endl;
831  cout << "cov xy --> " << fitResults[3] << " +/- " << fitResults[3+nParams] << endl;
832  cout << "dydz --> " << fitResults[4] << " +/- " << fitResults[4+nParams] << endl;
833  cout << "dxdz --> " << fitResults[5] << " +/- " << fitResults[5+nParams] << endl;
834  cout << "mean x --> " << fitResults[6] << " +/- " << fitResults[6+nParams] << endl;
835  cout << "mean y --> " << fitResults[7] << " +/- " << fitResults[7+nParams] << endl;
836  cout << "mean z --> " << fitResults[8] << " +/- " << fitResults[8+nParams] << endl;
837  }
838 
839  if (goodData == 0)
840  {
841  vals.push_back(fitResults[6]);
842  vals.push_back(fitResults[7]);
843  vals.push_back(fitResults[8]);
844  vals.push_back(std::sqrt(std::fabs(fitResults[2])));
845  vals.push_back(fitResults[5]);
846  vals.push_back(fitResults[4]);
847  vals.push_back(std::sqrt(std::fabs(fitResults[0])));
848  vals.push_back(std::sqrt(std::fabs(fitResults[1])));
849 
850  vals.push_back(std::pow(fitResults[6+nParams],2.));
851  vals.push_back(std::pow(fitResults[7+nParams],2.));
852  vals.push_back(std::pow(fitResults[8+nParams],2.));
853  vals.push_back(std::pow(std::fabs(fitResults[2+nParams]) / (2.*std::sqrt(std::fabs(fitResults[2]))),2.));
854  vals.push_back(std::pow(fitResults[5+nParams],2.));
855  vals.push_back(std::pow(fitResults[4+nParams],2.));
856  vals.push_back(std::pow(std::fabs(fitResults[0+nParams]) / (2.*std::sqrt(std::fabs(fitResults[0]))),2.));
857  vals.push_back(std::pow(std::fabs(fitResults[1+nParams]) / (2.*std::sqrt(std::fabs(fitResults[1]))),2.));
858  }
859  else for (unsigned int i = 0; i < 8*2; i++) vals.push_back(0.0);
860 
861  fitResults.clear();
862  }
863  else
864  {
865  counterVx = Vx_X->getTH1F()->GetEntries();
866 
867  if (Vx_X->getTH1F()->GetEntries() >= minNentries)
868  {
869  goodData = 0;
870 
871  vals.push_back(Vx_X->getTH1F()->GetMean());
872  vals.push_back(Vx_Y->getTH1F()->GetMean());
873  vals.push_back(Vx_Z->getTH1F()->GetMean());
874  vals.push_back(Vx_Z->getTH1F()->GetRMS());
875  vals.push_back(0.0);
876  vals.push_back(0.0);
877  vals.push_back(Vx_X->getTH1F()->GetRMS());
878  vals.push_back(Vx_Y->getTH1F()->GetRMS());
879 
880  vals.push_back(std::pow(Vx_X->getTH1F()->GetMeanError(),2.));
881  vals.push_back(std::pow(Vx_Y->getTH1F()->GetMeanError(),2.));
882  vals.push_back(std::pow(Vx_Z->getTH1F()->GetMeanError(),2.));
883  vals.push_back(std::pow(Vx_Z->getTH1F()->GetRMSError(),2.));
884  vals.push_back(0.0);
885  vals.push_back(0.0);
886  vals.push_back(std::pow(Vx_X->getTH1F()->GetRMSError(),2.));
887  vals.push_back(std::pow(Vx_Y->getTH1F()->GetRMSError(),2.));
888  }
889  else
890  {
891  goodData = -2;
892  for (unsigned int i = 0; i < 8*2; i++) vals.push_back(0.0);
893  }
894  }
895 
896  // vals[0] = X0
897  // vals[1] = Y0
898  // vals[2] = Z0
899  // vals[3] = sigmaZ0
900  // vals[4] = dxdz
901  // vals[5] = dydz
902  // vals[6] = BeamWidthX
903  // vals[7] = BeamWidthY
904 
905  // vals[8] = err^2 X0
906  // vals[9] = err^2 Y0
907  // vals[10] = err^2 Z0
908  // vals[11] = err^2 sigmaZ0
909  // vals[12] = err^2 dxdz
910  // vals[13] = err^2 dydz
911  // vals[14] = err^2 BeamWidthX
912  // vals[15] = err^2 BeamWidthY
913 
914  // "goodData" CODE:
915  // 0 == OK --> Reset
916  // -2 == NO OK - not enough "minNentries" --> Wait for more lumisections
917  // Any other number == NO OK --> Reset
918 
919  numberFits++;
920  if (goodData == 0)
921  {
923  if ((internalDebug == true) && (outputDebugFile.is_open() == true)) outputDebugFile << "Used vertices: " << counterVx << endl;
924 
925  numberGoodFits++;
926 
927  histTitle << "Fitted Beam Spot [cm] (Lumi start: " << beginLumiOfFit << " - Lumi end: " << endLumiOfFit << ")";
928  if (lumiCounterHisto >= maxLumiIntegration) reset("whole");
929  else reset("partial");
930  }
931  else
932  {
933  writeToFile(&vals, beginTimeOfFit, endTimeOfFit, beginLumiOfFit, endLumiOfFit, -1);
934  if ((internalDebug == true) && (outputDebugFile.is_open() == true)) outputDebugFile << "Used vertices: " << counterVx << endl;
935 
936  if (goodData == -2)
937  {
938  histTitle << "Fitted Beam Spot [cm] (not enough statistics)";
939  if (lumiCounter >= maxLumiIntegration) reset("whole");
940  else reset("hitCounter");
941  }
942  else
943  {
944  histTitle << "Fitted Beam Spot [cm] (problems)";
945  if (lumiCounterHisto >= maxLumiIntegration) reset("whole");
946  else reset("partial");
947 
948  counterVx = 0;
949  }
950  }
951 
952  reportSummary->Fill(numberFits != 0 ? (double)numberGoodFits/(double)numberFits : 0.0);
953  reportSummaryMap->Fill(0.5, 0.5, numberFits != 0 ? (double)numberGoodFits/(double)numberFits : 0.0);
954 
955  fitResults->setAxisTitle(histTitle.str().c_str(), 1);
956 
957  fitResults->setBinContent(1, 9, vals[0]);
958  fitResults->setBinContent(1, 8, vals[1]);
959  fitResults->setBinContent(1, 7, vals[2]);
960  fitResults->setBinContent(1, 6, vals[3]);
961  fitResults->setBinContent(1, 5, vals[4]);
962  fitResults->setBinContent(1, 4, vals[5]);
963  fitResults->setBinContent(1, 3, vals[6]);
964  fitResults->setBinContent(1, 2, vals[7]);
965  fitResults->setBinContent(1, 1, counterVx);
966 
967  fitResults->setBinContent(2, 9, std::sqrt(vals[8]));
968  fitResults->setBinContent(2, 8, std::sqrt(vals[9]));
969  fitResults->setBinContent(2, 7, std::sqrt(vals[10]));
970  fitResults->setBinContent(2, 6, std::sqrt(vals[11]));
971  fitResults->setBinContent(2, 5, std::sqrt(vals[12]));
972  fitResults->setBinContent(2, 4, std::sqrt(vals[13]));
973  fitResults->setBinContent(2, 3, std::sqrt(vals[14]));
974  fitResults->setBinContent(2, 2, std::sqrt(vals[15]));
975  fitResults->setBinContent(2, 1, std::sqrt(counterVx));
976 
977  // Linear fit to the historical plots
978  TF1* myLinFit = new TF1("myLinFit", "[0] + [1]*x", mXlumi->getTH1()->GetXaxis()->GetXmin(), mXlumi->getTH1()->GetXaxis()->GetXmax());
979  myLinFit->SetLineColor(2);
980  myLinFit->SetLineWidth(2);
981  myLinFit->SetParName(0,"Intercept");
982  myLinFit->SetParName(1,"Slope");
983 
984  mXlumi->ShiftFillLast(vals[0], std::sqrt(vals[8]), nLumiReset);
985  myLinFit->SetParameter(0, mXlumi->getTH1()->GetMean(2));
986  myLinFit->SetParameter(1, 0.0);
987  mXlumi->getTH1()->Fit(myLinFit,"QR");
988 
989  mYlumi->ShiftFillLast(vals[1], std::sqrt(vals[9]), nLumiReset);
990  myLinFit->SetParameter(0, mYlumi->getTH1()->GetMean(2));
991  myLinFit->SetParameter(1, 0.0);
992  mYlumi->getTH1()->Fit(myLinFit,"QR");
993 
994  mZlumi->ShiftFillLast(vals[2], std::sqrt(vals[10]), nLumiReset);
995  myLinFit->SetParameter(0, mZlumi->getTH1()->GetMean(2));
996  myLinFit->SetParameter(1, 0.0);
997  mZlumi->getTH1()->Fit(myLinFit,"QR");
998 
999  sXlumi->ShiftFillLast(vals[6], std::sqrt(vals[14]), nLumiReset);
1000  myLinFit->SetParameter(0, sXlumi->getTH1()->GetMean(2));
1001  myLinFit->SetParameter(1, 0.0);
1002  sXlumi->getTH1()->Fit(myLinFit,"QR");
1003 
1004  sYlumi->ShiftFillLast(vals[7], std::sqrt(vals[15]), nLumiReset);
1005  myLinFit->SetParameter(0, sYlumi->getTH1()->GetMean(2));
1006  myLinFit->SetParameter(1, 0.0);
1007  sYlumi->getTH1()->Fit(myLinFit,"QR");
1008 
1009  sZlumi->ShiftFillLast(vals[3], std::sqrt(vals[11]), nLumiReset);
1010  myLinFit->SetParameter(0, sZlumi->getTH1()->GetMean(2));
1011  myLinFit->SetParameter(1, 0.0);
1012  sZlumi->getTH1()->Fit(myLinFit,"QR");
1013 
1014  dxdzlumi->ShiftFillLast(vals[4], std::sqrt(vals[12]), nLumiReset);
1015  myLinFit->SetParameter(0, dxdzlumi->getTH1()->GetMean(2));
1016  myLinFit->SetParameter(1, 0.0);
1017  dxdzlumi->getTH1()->Fit(myLinFit,"QR");
1018 
1019  dydzlumi->ShiftFillLast(vals[5], std::sqrt(vals[13]), nLumiReset);
1020  myLinFit->SetParameter(0, dydzlumi->getTH1()->GetMean(2));
1021  myLinFit->SetParameter(1, 0.0);
1022  dydzlumi->getTH1()->Fit(myLinFit,"QR");
1023 
1024  goodVxCounter->ShiftFillLast((double)counterVx, std::sqrt((double)counterVx), nLumiReset);
1025  myLinFit->SetParameter(0, goodVxCounter->getTH1()->GetMean(2));
1026  myLinFit->SetParameter(1, 0.0);
1027  goodVxCounter->getTH1()->Fit(myLinFit,"QR");
1028 
1029  delete myLinFit;
1030 
1031  // Exponential fit to the historical plots
1032  TF1* myExpFit = new TF1("myExpFit", "[0]*exp(-x/[1])", hitCountHistory->getTH1()->GetXaxis()->GetXmin(), hitCountHistory->getTH1()->GetXaxis()->GetXmax());
1033  myExpFit->SetLineColor(2);
1034  myExpFit->SetLineWidth(2);
1035  myExpFit->SetParName(0,"Amplitude");
1036  myExpFit->SetParName(1,"#tau");
1037 
1038  myExpFit->SetParameter(0, hitCountHistory->getTH1()->GetBinContent(1));
1039  myExpFit->SetParameter(1, nBinsWholeHistory/2);
1040  hitCountHistory->getTH1()->Fit(myExpFit,"QR");
1041 
1042  if (lastLumiOfFit % prescaleHistory == 0)
1043  {
1044  goodVxCountHistory->getTH1()->SetBinContent(lastLumiOfFit, (double)counterVx);
1045  goodVxCountHistory->getTH1()->SetBinError(lastLumiOfFit, std::sqrt((double)counterVx));
1046 
1047  myExpFit->SetParameter(0, goodVxCountHistory->getTH1()->GetBinContent(1));
1048  myExpFit->SetParameter(1, nBinsWholeHistory/2);
1049  goodVxCountHistory->getTH1()->Fit(myExpFit,"QR");
1050  }
1051 
1052  delete myExpFit;
1053 
1054  vals.clear();
1055  }
1056  else if (nLumiReset == 0)
1057  {
1058  histTitle << "Fitted Beam Spot [cm] (no ongoing fits)";
1059  fitResults->setAxisTitle(histTitle.str().c_str(), 1);
1060  reportSummaryMap->Fill(0.5, 0.5, 1.0);
1061  hitCounter->ShiftFillLast(totalHits, std::sqrt(totalHits), 1);
1062  reset("nohisto");
1063  }
1064 }
unsigned int lumiCounter
int i
Definition: DBlmapReader.cc:9
MonitorElement * dxdzlumi
unsigned int totalHits
unsigned int maxLumiIntegration
unsigned int numberFits
unsigned int beginLumiOfFit
MonitorElement * hitCountHistory
unsigned int minNentries
MonitorElement * Vx_X
unsigned int nLumiReset
MonitorElement * mYlumi
MonitorElement * sYlumi
MonitorElement * reportSummaryMap
void Fill(long long x)
MonitorElement * sZlumi
LuminosityBlockNumber_t luminosityBlock() const
void ShiftFillLast(double y, double ye=0., int32_t xscale=1)
MonitorElement * fitResults
unsigned int endLumiOfFit
unsigned int numberGoodFits
T sqrt(T t)
Definition: SSEVec.h:48
MonitorElement * reportSummary
Timestamp const & endTime() const
MonitorElement * goodVxCounter
virtual int MyFit(vector< double > *vals)
MonitorElement * dydzlumi
TH1 * getTH1(void) const
MonitorElement * Vx_Z
MonitorElement * mXlumi
MonitorElement * mZlumi
MonitorElement * sXlumi
unsigned int lastLumiOfFit
ofstream outputDebugFile
unsigned int nBinsWholeHistory
unsigned int lumiCounterHisto
TimeValue_t beginTimeOfFit
TH1F * getTH1F(void) const
unsigned int runNumber
virtual void writeToFile(vector< double > *vals, TimeValue_t BeginTimeOfFit, TimeValue_t EndTimeOfFit, unsigned int BeginLumiOfFit, unsigned int EndLumiOfFit, int dataType)
TimeValue_t endTimeOfFit
unsigned int counterVx
tuple cout
Definition: gather_cfg.py:121
unsigned int prescaleHistory
MonitorElement * goodVxCountHistory
MonitorElement * hitCounter
TimeValue_t value() const
Definition: Timestamp.h:56
virtual void reset(string ResetType)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
MonitorElement * Vx_Y
string Vx3DHLTAnalyzer::formatTime ( const time_t &  t)
privatevirtual

Definition at line 157 of file Vx3DHLTAnalyzer.cc.

Referenced by writeToFile().

158 {
159  char ts[25];
160  strftime(ts, sizeof(ts), "%Y.%m.%d %H:%M:%S %Z", gmtime(&t));
161 
162  string ts_string(ts);
163 
164  return ts_string;
165 }
unsigned int Vx3DHLTAnalyzer::HitCounter ( const Event iEvent)
privatevirtual

Definition at line 143 of file Vx3DHLTAnalyzer.cc.

References counter, edm::Event::getByToken(), h, j, and pixelHitCollection.

Referenced by analyze().

144 {
145  Handle<SiPixelRecHitCollection> rechitspixel;
146  iEvent.getByToken(pixelHitCollection, rechitspixel);
147 
148  unsigned int counter = 0;
149 
150  for (SiPixelRecHitCollection::const_iterator j = rechitspixel->begin(); j != rechitspixel->end(); j++)
151  for (edmNew::DetSet<SiPixelRecHit>::const_iterator h = j->begin(); h != j->end(); h++) counter += h->cluster()->size();
152 
153  return counter;
154 }
EDGetTokenT< SiPixelRecHitCollection > pixelHitCollection
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
data_type const * const_iterator
Definition: DetSetNew.h:30
int j
Definition: DBlmapReader.cc:9
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
static std::atomic< unsigned int > counter
int Vx3DHLTAnalyzer::MyFit ( vector< double > *  vals)
privatevirtual

Definition at line 237 of file Vx3DHLTAnalyzer.cc.

References counterVx, gather_cfg::cout, alignCSCRings::e, Gauss3DFunc(), i, internalDebug, edm::isNotFinite(), j, maxLongLength, maxTransRadius, minNentries, NULL, mathSSE::sqrt(), xPos, yPos, and zPos.

Referenced by endLuminosityBlock().

238 {
239  // RETURN CODE:
240  // 0 == OK
241  // -2 == NO OK - not enough "minNentries"
242  // Any other number == NO OK
243  unsigned int nParams = 9;
244 
245  if ((vals != NULL) && (vals->size() == nParams*2))
246  {
247  double nSigmaXY = 100.;
248  double nSigmaZ = 100.;
249  double varFactor = 4./25.; // Take into account the difference between the RMS and sigma (RMS usually greater than sigma)
250  double parDistanceXY = 0.005; // Unit: [cm]
251  double parDistanceZ = 0.5; // Unit: [cm]
252  double parDistanceddZ = 1e-3; // Unit: [rad]
253  double parDistanceCxy = 1e-5; // Unit: [cm^2]
254  double bestEdm = 1e-1;
255 
256  const unsigned int trials = 4;
257  double largerDist[trials] = {0.1, 5., 10., 100.};
258 
259  double covxz,covyz,det;
260  double deltaMean;
261  int bestMovementX = 1;
262  int bestMovementY = 1;
263  int bestMovementZ = 1;
264  int goodData;
265 
266  double edm;
267 
268  vector<double>::const_iterator it = vals->begin();
269 
270  ROOT::Math::Minimizer* Gauss3D = ROOT::Math::Factory::CreateMinimizer("Minuit2","Migrad");
271  Gauss3D->SetMaxFunctionCalls(1e4);
272  Gauss3D->SetTolerance(1e-9); // Tolerance on likelihood
273  if (internalDebug == true) Gauss3D->SetPrintLevel(3);
274  else Gauss3D->SetPrintLevel(0);
275 
276  ROOT::Math::Functor _Gauss3DFunc(&Gauss3DFunc,nParams);
277  Gauss3D->SetFunction(_Gauss3DFunc);
278 
279  if (internalDebug == true) cout << "\n@@@ START FITTING @@@" << endl;
280 
281  // @@@ Fit at X-deltaMean | X | X+deltaMean @@@
282  bestEdm = 1.;
283  for (int i = 0; i < 3; i++)
284  {
285  deltaMean = (double(i)-1.)*std::sqrt((*(it+0))*varFactor);
286  if (internalDebug == true) cout << "deltaMean --> " << deltaMean << endl;
287 
288  Gauss3D->Clear();
289 
290  Gauss3D->SetVariable(0,"var x ", *(it+0)*varFactor, parDistanceXY*parDistanceXY);
291  Gauss3D->SetVariable(1,"var y ", *(it+1)*varFactor, parDistanceXY*parDistanceXY);
292  Gauss3D->SetVariable(2,"var z ", *(it+2), parDistanceZ*parDistanceZ);
293  Gauss3D->SetVariable(3,"cov xy", *(it+3), parDistanceCxy);
294  Gauss3D->SetVariable(4,"dydz ", *(it+4), parDistanceddZ);
295  Gauss3D->SetVariable(5,"dxdz ", *(it+5), parDistanceddZ);
296  Gauss3D->SetVariable(6,"mean x", *(it+6)+deltaMean, parDistanceXY);
297  Gauss3D->SetVariable(7,"mean y", *(it+7), parDistanceXY);
298  Gauss3D->SetVariable(8,"mean z", *(it+8), parDistanceZ);
299 
300  // Set the central positions of the centroid for vertex rejection
301  xPos = Gauss3D->X()[6];
302  yPos = Gauss3D->X()[7];
303  zPos = Gauss3D->X()[8];
304 
305  // Set dimensions of the centroid for vertex rejection
306  maxTransRadius = nSigmaXY * std::sqrt(std::fabs(Gauss3D->X()[0]) + std::fabs(Gauss3D->X()[1])) / 2.;
307  maxLongLength = nSigmaZ * std::sqrt(std::fabs(Gauss3D->X()[2]));
308 
309  Gauss3D->Minimize();
310  goodData = Gauss3D->Status();
311  edm = Gauss3D->Edm();
312 
313  if (counterVx < minNentries) goodData = -2;
314  else if (isNotFinite(edm) == true) goodData = -1;
315  else for (unsigned int j = 0; j < nParams; j++) if (isNotFinite(Gauss3D->Errors()[j]) == true) { goodData = -1; break; }
316  if (goodData == 0)
317  {
318  covyz = Gauss3D->X()[4]*(std::fabs(Gauss3D->X()[2])-std::fabs(Gauss3D->X()[1])) - Gauss3D->X()[5]*Gauss3D->X()[3];
319  covxz = Gauss3D->X()[5]*(std::fabs(Gauss3D->X()[2])-std::fabs(Gauss3D->X()[0])) - Gauss3D->X()[4]*Gauss3D->X()[3];
320 
321  det = std::fabs(Gauss3D->X()[0]) * (std::fabs(Gauss3D->X()[1])*std::fabs(Gauss3D->X()[2]) - covyz*covyz) -
322  Gauss3D->X()[3] * (Gauss3D->X()[3]*std::fabs(Gauss3D->X()[2]) - covxz*covyz) +
323  covxz * (Gauss3D->X()[3]*covyz - covxz*std::fabs(Gauss3D->X()[1]));
324  if (det < 0.) { goodData = -1; if (internalDebug == true) cout << "Negative determinant !" << endl; }
325  }
326 
327  if ((goodData == 0) && (std::fabs(edm) < bestEdm)) { bestEdm = edm; bestMovementX = i; }
328  }
329  if (internalDebug == true) cout << "Found bestMovementX --> " << bestMovementX << endl;
330 
331  // @@@ Fit at Y-deltaMean | Y | Y+deltaMean @@@
332  bestEdm = 1.;
333  for (int i = 0; i < 3; i++)
334  {
335  deltaMean = (double(i)-1.)*std::sqrt((*(it+1))*varFactor);
336  if (internalDebug == true)
337  {
338  cout << "deltaMean --> " << deltaMean << endl;
339  cout << "deltaMean X --> " << (double(bestMovementX)-1.)*std::sqrt((*(it+0))*varFactor) << endl;
340  }
341 
342  Gauss3D->Clear();
343 
344  Gauss3D->SetVariable(0,"var x ", *(it+0)*varFactor, parDistanceXY*parDistanceXY);
345  Gauss3D->SetVariable(1,"var y ", *(it+1)*varFactor, parDistanceXY*parDistanceXY);
346  Gauss3D->SetVariable(2,"var z ", *(it+2), parDistanceZ*parDistanceZ);
347  Gauss3D->SetVariable(3,"cov xy", *(it+3), parDistanceCxy);
348  Gauss3D->SetVariable(4,"dydz ", *(it+4), parDistanceddZ);
349  Gauss3D->SetVariable(5,"dxdz ", *(it+5), parDistanceddZ);
350  Gauss3D->SetVariable(6,"mean x", *(it+6)+(double(bestMovementX)-1.)*std::sqrt((*(it+0))*varFactor), parDistanceXY);
351  Gauss3D->SetVariable(7,"mean y", *(it+7)+deltaMean, parDistanceXY);
352  Gauss3D->SetVariable(8,"mean z", *(it+8), parDistanceZ);
353 
354  // Set the central positions of the centroid for vertex rejection
355  xPos = Gauss3D->X()[6];
356  yPos = Gauss3D->X()[7];
357  zPos = Gauss3D->X()[8];
358 
359  // Set dimensions of the centroid for vertex rejection
360  maxTransRadius = nSigmaXY * std::sqrt(std::fabs(Gauss3D->X()[0]) + std::fabs(Gauss3D->X()[1])) / 2.;
361  maxLongLength = nSigmaZ * std::sqrt(std::fabs(Gauss3D->X()[2]));
362 
363  Gauss3D->Minimize();
364  goodData = Gauss3D->Status();
365  edm = Gauss3D->Edm();
366 
367  if (counterVx < minNentries) goodData = -2;
368  else if (isNotFinite(edm) == true) goodData = -1;
369  else for (unsigned int j = 0; j < nParams; j++) if (isNotFinite(Gauss3D->Errors()[j]) == true) { goodData = -1; break; }
370  if (goodData == 0)
371  {
372  covyz = Gauss3D->X()[4]*(std::fabs(Gauss3D->X()[2])-std::fabs(Gauss3D->X()[1])) - Gauss3D->X()[5]*Gauss3D->X()[3];
373  covxz = Gauss3D->X()[5]*(std::fabs(Gauss3D->X()[2])-std::fabs(Gauss3D->X()[0])) - Gauss3D->X()[4]*Gauss3D->X()[3];
374 
375  det = std::fabs(Gauss3D->X()[0]) * (std::fabs(Gauss3D->X()[1])*std::fabs(Gauss3D->X()[2]) - covyz*covyz) -
376  Gauss3D->X()[3] * (Gauss3D->X()[3]*std::fabs(Gauss3D->X()[2]) - covxz*covyz) +
377  covxz * (Gauss3D->X()[3]*covyz - covxz*std::fabs(Gauss3D->X()[1]));
378  if (det < 0.) { goodData = -1; if (internalDebug == true) cout << "Negative determinant !" << endl; }
379  }
380 
381  if ((goodData == 0) && (std::fabs(edm) < bestEdm)) { bestEdm = edm; bestMovementY = i; }
382  }
383  if (internalDebug == true) cout << "Found bestMovementY --> " << bestMovementY << endl;
384 
385  // @@@ Fit at Z-deltaMean | Z | Z+deltaMean @@@
386  bestEdm = 1.;
387  for (int i = 0; i < 3; i++)
388  {
389  deltaMean = (double(i)-1.)*std::sqrt(*(it+2));
390  if (internalDebug == true)
391  {
392  cout << "deltaMean --> " << deltaMean << endl;
393  cout << "deltaMean X --> " << (double(bestMovementX)-1.)*std::sqrt((*(it+0))*varFactor) << endl;
394  cout << "deltaMean Y --> " << (double(bestMovementY)-1.)*std::sqrt((*(it+1))*varFactor) << endl;
395  }
396 
397  Gauss3D->Clear();
398 
399  Gauss3D->SetVariable(0,"var x ", *(it+0)*varFactor, parDistanceXY*parDistanceXY);
400  Gauss3D->SetVariable(1,"var y ", *(it+1)*varFactor, parDistanceXY*parDistanceXY);
401  Gauss3D->SetVariable(2,"var z ", *(it+2), parDistanceZ*parDistanceZ);
402  Gauss3D->SetVariable(3,"cov xy", *(it+3), parDistanceCxy);
403  Gauss3D->SetVariable(4,"dydz ", *(it+4), parDistanceddZ);
404  Gauss3D->SetVariable(5,"dxdz ", *(it+5), parDistanceddZ);
405  Gauss3D->SetVariable(6,"mean x", *(it+6)+(double(bestMovementX)-1.)*std::sqrt((*(it+0))*varFactor), parDistanceXY);
406  Gauss3D->SetVariable(7,"mean y", *(it+7)+(double(bestMovementY)-1.)*std::sqrt((*(it+1))*varFactor), parDistanceXY);
407  Gauss3D->SetVariable(8,"mean z", *(it+8)+deltaMean, parDistanceZ);
408 
409  // Set the central positions of the centroid for vertex rejection
410  xPos = Gauss3D->X()[6];
411  yPos = Gauss3D->X()[7];
412  zPos = Gauss3D->X()[8];
413 
414  // Set dimensions of the centroid for vertex rejection
415  maxTransRadius = nSigmaXY * std::sqrt(std::fabs(Gauss3D->X()[0]) + std::fabs(Gauss3D->X()[1])) / 2.;
416  maxLongLength = nSigmaZ * std::sqrt(std::fabs(Gauss3D->X()[2]));
417 
418  Gauss3D->Minimize();
419  goodData = Gauss3D->Status();
420  edm = Gauss3D->Edm();
421 
422  if (counterVx < minNentries) goodData = -2;
423  else if (isNotFinite(edm) == true) goodData = -1;
424  else for (unsigned int j = 0; j < nParams; j++) if (isNotFinite(Gauss3D->Errors()[j]) == true) { goodData = -1; break; }
425  if (goodData == 0)
426  {
427  covyz = Gauss3D->X()[4]*(std::fabs(Gauss3D->X()[2])-std::fabs(Gauss3D->X()[1])) - Gauss3D->X()[5]*Gauss3D->X()[3];
428  covxz = Gauss3D->X()[5]*(std::fabs(Gauss3D->X()[2])-std::fabs(Gauss3D->X()[0])) - Gauss3D->X()[4]*Gauss3D->X()[3];
429 
430  det = std::fabs(Gauss3D->X()[0]) * (std::fabs(Gauss3D->X()[1])*std::fabs(Gauss3D->X()[2]) - covyz*covyz) -
431  Gauss3D->X()[3] * (Gauss3D->X()[3]*std::fabs(Gauss3D->X()[2]) - covxz*covyz) +
432  covxz * (Gauss3D->X()[3]*covyz - covxz*std::fabs(Gauss3D->X()[1]));
433  if (det < 0.) { goodData = -1; if (internalDebug == true) cout << "Negative determinant !" << endl; }
434  }
435 
436  if ((goodData == 0) && (std::fabs(edm) < bestEdm)) { bestEdm = edm; bestMovementZ = i; }
437  }
438  if (internalDebug == true) cout << "Found bestMovementZ --> " << bestMovementZ << endl;
439 
440  Gauss3D->Clear();
441 
442  // @@@ FINAL FIT @@@
443  Gauss3D->SetVariable(0,"var x ", *(it+0)*varFactor, parDistanceXY*parDistanceXY);
444  Gauss3D->SetVariable(1,"var y ", *(it+1)*varFactor, parDistanceXY*parDistanceXY);
445  Gauss3D->SetVariable(2,"var z ", *(it+2), parDistanceZ*parDistanceZ);
446  Gauss3D->SetVariable(3,"cov xy", *(it+3), parDistanceCxy);
447  Gauss3D->SetVariable(4,"dydz ", *(it+4), parDistanceddZ);
448  Gauss3D->SetVariable(5,"dxdz ", *(it+5), parDistanceddZ);
449  Gauss3D->SetVariable(6,"mean x", *(it+6)+(double(bestMovementX)-1.)*std::sqrt((*(it+0))*varFactor), parDistanceXY);
450  Gauss3D->SetVariable(7,"mean y", *(it+7)+(double(bestMovementY)-1.)*std::sqrt((*(it+1))*varFactor), parDistanceXY);
451  Gauss3D->SetVariable(8,"mean z", *(it+8)+(double(bestMovementZ)-1.)*std::sqrt(*(it+2)), parDistanceZ);
452 
453  // Set the central positions of the centroid for vertex rejection
454  xPos = Gauss3D->X()[6];
455  yPos = Gauss3D->X()[7];
456  zPos = Gauss3D->X()[8];
457 
458  // Set dimensions of the centroid for vertex rejection
459  maxTransRadius = nSigmaXY * std::sqrt(std::fabs(Gauss3D->X()[0]) + std::fabs(Gauss3D->X()[1])) / 2.;
460  maxLongLength = nSigmaZ * std::sqrt(std::fabs(Gauss3D->X()[2]));
461 
462  Gauss3D->Minimize();
463  goodData = Gauss3D->Status();
464  edm = Gauss3D->Edm();
465 
466  if (counterVx < minNentries) goodData = -2;
467  else if (isNotFinite(edm) == true) goodData = -1;
468  else for (unsigned int j = 0; j < nParams; j++) if (isNotFinite(Gauss3D->Errors()[j]) == true) { goodData = -1; break; }
469  if (goodData == 0)
470  {
471  covyz = Gauss3D->X()[4]*(std::fabs(Gauss3D->X()[2])-std::fabs(Gauss3D->X()[1])) - Gauss3D->X()[5]*Gauss3D->X()[3];
472  covxz = Gauss3D->X()[5]*(std::fabs(Gauss3D->X()[2])-std::fabs(Gauss3D->X()[0])) - Gauss3D->X()[4]*Gauss3D->X()[3];
473 
474  det = std::fabs(Gauss3D->X()[0]) * (std::fabs(Gauss3D->X()[1])*std::fabs(Gauss3D->X()[2]) - covyz*covyz) -
475  Gauss3D->X()[3] * (Gauss3D->X()[3]*std::fabs(Gauss3D->X()[2]) - covxz*covyz) +
476  covxz * (Gauss3D->X()[3]*covyz - covxz*std::fabs(Gauss3D->X()[1]));
477  if (det < 0.) { goodData = -1; if (internalDebug == true) cout << "Negative determinant !" << endl; }
478  }
479 
480  // @@@ FIT WITH DIFFERENT PARAMETER DISTANCES @@@
481  for (unsigned int i = 0; i < trials; i++)
482  {
483  if ((goodData != 0) && (goodData != -2))
484  {
485  Gauss3D->Clear();
486 
487  if (internalDebug == true) cout << "FIT WITH DIFFERENT PARAMETER DISTANCES - STEP " << i+1 << endl;
488 
489  Gauss3D->SetVariable(0,"var x ", *(it+0)*varFactor, parDistanceXY*parDistanceXY * largerDist[i]);
490  Gauss3D->SetVariable(1,"var y ", *(it+1)*varFactor, parDistanceXY*parDistanceXY * largerDist[i]);
491  Gauss3D->SetVariable(2,"var z ", *(it+2), parDistanceZ*parDistanceZ * largerDist[i]);
492  Gauss3D->SetVariable(3,"cov xy", *(it+3), parDistanceCxy * largerDist[i]);
493  Gauss3D->SetVariable(4,"dydz ", *(it+4), parDistanceddZ * largerDist[i]);
494  Gauss3D->SetVariable(5,"dxdz ", *(it+5), parDistanceddZ * largerDist[i]);
495  Gauss3D->SetVariable(6,"mean x", *(it+6)+(double(bestMovementX)-1.)*std::sqrt((*(it+0))*varFactor), parDistanceXY * largerDist[i]);
496  Gauss3D->SetVariable(7,"mean y", *(it+7)+(double(bestMovementY)-1.)*std::sqrt((*(it+1))*varFactor), parDistanceXY * largerDist[i]);
497  Gauss3D->SetVariable(8,"mean z", *(it+8)+(double(bestMovementZ)-1.)*std::sqrt(*(it+2)), parDistanceZ * largerDist[i]);
498 
499  // Set the central positions of the centroid for vertex rejection
500  xPos = Gauss3D->X()[6];
501  yPos = Gauss3D->X()[7];
502  zPos = Gauss3D->X()[8];
503 
504  // Set dimensions of the centroid for vertex rejection
505  maxTransRadius = nSigmaXY * std::sqrt(std::fabs(Gauss3D->X()[0]) + std::fabs(Gauss3D->X()[1])) / 2.;
506  maxLongLength = nSigmaZ * std::sqrt(std::fabs(Gauss3D->X()[2]));
507 
508  Gauss3D->Minimize();
509  goodData = Gauss3D->Status();
510  edm = Gauss3D->Edm();
511 
512  if (counterVx < minNentries) goodData = -2;
513  else if (isNotFinite(edm) == true) goodData = -1;
514  else for (unsigned int j = 0; j < nParams; j++) if (isNotFinite(Gauss3D->Errors()[j]) == true) { goodData = -1; break; }
515  if (goodData == 0)
516  {
517  covyz = Gauss3D->X()[4]*(std::fabs(Gauss3D->X()[2])-std::fabs(Gauss3D->X()[1])) - Gauss3D->X()[5]*Gauss3D->X()[3];
518  covxz = Gauss3D->X()[5]*(std::fabs(Gauss3D->X()[2])-std::fabs(Gauss3D->X()[0])) - Gauss3D->X()[4]*Gauss3D->X()[3];
519 
520  det = std::fabs(Gauss3D->X()[0]) * (std::fabs(Gauss3D->X()[1])*std::fabs(Gauss3D->X()[2]) - covyz*covyz) -
521  Gauss3D->X()[3] * (Gauss3D->X()[3]*std::fabs(Gauss3D->X()[2]) - covxz*covyz) +
522  covxz * (Gauss3D->X()[3]*covyz - covxz*std::fabs(Gauss3D->X()[1]));
523  if (det < 0.) { goodData = -1; if (internalDebug == true) cout << "Negative determinant !" << endl; }
524  }
525  } else break;
526  }
527 
528  if (goodData == 0)
529  for (unsigned int i = 0; i < nParams; i++)
530  {
531  vals->operator[](i) = Gauss3D->X()[i];
532  vals->operator[](i+nParams) = Gauss3D->Errors()[i];
533  }
534 
535  delete Gauss3D;
536  return goodData;
537  }
538 
539  return -1;
540 }
int i
Definition: DBlmapReader.cc:9
double maxLongLength
double zPos
unsigned int minNentries
#define NULL
Definition: scimark2.h:8
double maxTransRadius
double Gauss3DFunc(const double *par)
double xPos
bool isNotFinite(T x)
Definition: isFinite.h:10
T sqrt(T t)
Definition: SSEVec.h:48
int j
Definition: DBlmapReader.cc:9
double yPos
unsigned int counterVx
tuple cout
Definition: gather_cfg.py:121
void Vx3DHLTAnalyzer::reset ( string  ResetType)
privatevirtual

Definition at line 543 of file Vx3DHLTAnalyzer.cc.

References beginLumiOfFit, beginTimeOfFit, dxdzlumi, dydzlumi, endLumiOfFit, endTimeOfFit, MonitorElement::Fill(), fitResults, goodVxCounter, goodVxCountHistory, hitCounter, hitCountHistory, lastLumiOfFit, lumiCounter, lumiCounterHisto, mXlumi, mYlumi, mZlumi, numberFits, numberGoodFits, reportSummary, reportSummaryMap, MonitorElement::Reset(), runNumber, sXlumi, sYlumi, sZlumi, totalHits, Vertices, Vx_X, Vx_XY, Vx_Y, Vx_Z, Vx_ZX, and Vx_ZY.

Referenced by analyze(), beginRun(), endJob(), and endLuminosityBlock().

544 {
545  if (ResetType.compare("scratch") == 0)
546  {
547  runNumber = 0;
548  numberGoodFits = 0;
549  numberFits = 0;
550  lastLumiOfFit = 0;
551 
552  Vx_X->Reset();
553  Vx_Y->Reset();
554  Vx_Z->Reset();
555 
556  Vx_ZX->Reset();
557  Vx_ZY->Reset();
558  Vx_XY->Reset();
559 
560  mXlumi->Reset();
561  mYlumi->Reset();
562  mZlumi->Reset();
563 
564  sXlumi->Reset();
565  sYlumi->Reset();
566  sZlumi->Reset();
567 
568  dxdzlumi->Reset();
569  dydzlumi->Reset();
570 
571  hitCounter->Reset();
573  goodVxCounter->Reset();
575  fitResults->Reset();
576 
577  reportSummary->Fill(0.);
578  reportSummaryMap->Fill(0.5, 0.5, 0.);
579 
580  Vertices.clear();
581 
582  lumiCounter = 0;
583  lumiCounterHisto = 0;
584  totalHits = 0;
585  beginTimeOfFit = 0;
586  endTimeOfFit = 0;
587  beginLumiOfFit = 0;
588  endLumiOfFit = 0;
589  }
590  else if (ResetType.compare("whole") == 0)
591  {
592  Vx_X->Reset();
593  Vx_Y->Reset();
594  Vx_Z->Reset();
595 
596  Vx_ZX->Reset();
597  Vx_ZY->Reset();
598  Vx_XY->Reset();
599 
600  Vertices.clear();
601 
602  lumiCounter = 0;
603  lumiCounterHisto = 0;
604  totalHits = 0;
605  beginTimeOfFit = 0;
606  endTimeOfFit = 0;
607  beginLumiOfFit = 0;
608  endLumiOfFit = 0;
609  }
610  else if (ResetType.compare("partial") == 0)
611  {
612  Vx_X->Reset();
613  Vx_Y->Reset();
614  Vx_Z->Reset();
615 
616  Vertices.clear();
617 
618  lumiCounter = 0;
619  totalHits = 0;
620  beginTimeOfFit = 0;
621  endTimeOfFit = 0;
622  beginLumiOfFit = 0;
623  endLumiOfFit = 0;
624  }
625  else if (ResetType.compare("nohisto") == 0)
626  {
627  Vertices.clear();
628 
629  lumiCounter = 0;
630  lumiCounterHisto = 0;
631  totalHits = 0;
632  beginTimeOfFit = 0;
633  endTimeOfFit = 0;
634  beginLumiOfFit = 0;
635  endLumiOfFit = 0;
636  }
637  else if (ResetType.compare("hitCounter") == 0)
638  totalHits = 0;
639 }
unsigned int lumiCounter
MonitorElement * dxdzlumi
MonitorElement * Vx_ZX
unsigned int totalHits
unsigned int numberFits
vector< VertexType > Vertices
unsigned int beginLumiOfFit
MonitorElement * hitCountHistory
MonitorElement * Vx_X
MonitorElement * mYlumi
MonitorElement * sYlumi
MonitorElement * reportSummaryMap
void Fill(long long x)
MonitorElement * Vx_XY
MonitorElement * sZlumi
MonitorElement * fitResults
MonitorElement * Vx_ZY
unsigned int endLumiOfFit
unsigned int numberGoodFits
MonitorElement * reportSummary
MonitorElement * goodVxCounter
MonitorElement * dydzlumi
MonitorElement * Vx_Z
MonitorElement * mXlumi
MonitorElement * mZlumi
MonitorElement * sXlumi
unsigned int lastLumiOfFit
unsigned int lumiCounterHisto
TimeValue_t beginTimeOfFit
unsigned int runNumber
TimeValue_t endTimeOfFit
MonitorElement * goodVxCountHistory
MonitorElement * hitCounter
void Reset(void)
reset ME (ie. contents, errors, etc)
MonitorElement * Vx_Y
void Vx3DHLTAnalyzer::writeToFile ( vector< double > *  vals,
TimeValue_t  BeginTimeOfFit,
TimeValue_t  EndTimeOfFit,
unsigned int  BeginLumiOfFit,
unsigned int  EndLumiOfFit,
int  dataType 
)
privatevirtual

Definition at line 642 of file Vx3DHLTAnalyzer.cc.

References beginLumiOfFit, beginTimeOfFit, debugMode, endLumiOfFit, endTimeOfFit, fileName, formatTime(), NULL, dbtoconf::out, outputDebugFile, outputFile, runNumber, and mathSSE::sqrt().

Referenced by endLuminosityBlock().

648 {
649  stringstream BufferString;
650  BufferString.precision(5);
651 
652  outputFile.open(fileName.c_str(), ios::out);
653 
654  if ((outputFile.is_open() == true) && (vals != NULL) && (vals->size() == 8*2))
655  {
656  vector<double>::const_iterator it = vals->begin();
657 
658  outputFile << "Runnumber " << runNumber << endl;
659  outputFile << "BeginTimeOfFit " << formatTime(beginTimeOfFit >> 32) << " " << (beginTimeOfFit >> 32) << endl;
660  outputFile << "EndTimeOfFit " << formatTime(endTimeOfFit >> 32) << " " << (endTimeOfFit >> 32) << endl;
661  outputFile << "LumiRange " << beginLumiOfFit << " - " << endLumiOfFit << endl;
662  outputFile << "Type " << dataType << endl;
663  // 3D Vertexing with Pixel Tracks:
664  // Good data = Type 3
665  // Bad data = Type -1
666 
667  BufferString << *(it+0);
668  outputFile << "X0 " << BufferString.str().c_str() << endl;
669  BufferString.str("");
670 
671  BufferString << *(it+1);
672  outputFile << "Y0 " << BufferString.str().c_str() << endl;
673  BufferString.str("");
674 
675  BufferString << *(it+2);
676  outputFile << "Z0 " << BufferString.str().c_str() << endl;
677  BufferString.str("");
678 
679  BufferString << *(it+3);
680  outputFile << "sigmaZ0 " << BufferString.str().c_str() << endl;
681  BufferString.str("");
682 
683  BufferString << *(it+4);
684  outputFile << "dxdz " << BufferString.str().c_str() << endl;
685  BufferString.str("");
686 
687  BufferString << *(it+5);
688  outputFile << "dydz " << BufferString.str().c_str() << endl;
689  BufferString.str("");
690 
691  BufferString << *(it+6);
692  outputFile << "BeamWidthX " << BufferString.str().c_str() << endl;
693  BufferString.str("");
694 
695  BufferString << *(it+7);
696  outputFile << "BeamWidthY " << BufferString.str().c_str() << endl;
697  BufferString.str("");
698 
699  outputFile << "Cov(0,j) " << *(it+8) << " 0.0 0.0 0.0 0.0 0.0 0.0" << endl;
700  outputFile << "Cov(1,j) 0.0 " << *(it+9) << " 0.0 0.0 0.0 0.0 0.0" << endl;
701  outputFile << "Cov(2,j) 0.0 0.0 " << *(it+10) << " 0.0 0.0 0.0 0.0" << endl;
702  outputFile << "Cov(3,j) 0.0 0.0 0.0 " << *(it+11) << " 0.0 0.0 0.0" << endl;
703  outputFile << "Cov(4,j) 0.0 0.0 0.0 0.0 " << *(it+12) << " 0.0 0.0" << endl;
704  outputFile << "Cov(5,j) 0.0 0.0 0.0 0.0 0.0 " << *(it+13) << " 0.0" << endl;
705  outputFile << "Cov(6,j) 0.0 0.0 0.0 0.0 0.0 0.0 " << ((*(it+14)) + (*(it+15)) + 2.*std::sqrt((*(it+14))*(*(it+15)))) / 4. << endl;
706 
707  outputFile << "EmittanceX 0.0" << endl;
708  outputFile << "EmittanceY 0.0" << endl;
709  outputFile << "BetaStar 0.0" << endl;
710  }
711  outputFile.close();
712 
713  if ((debugMode == true) && (outputDebugFile.is_open() == true) && (vals != NULL) && (vals->size() == 8*2))
714  {
715  vector<double>::const_iterator it = vals->begin();
716 
717  outputDebugFile << "Runnumber " << runNumber << endl;
718  outputDebugFile << "BeginTimeOfFit " << formatTime(beginTimeOfFit >> 32) << " " << (beginTimeOfFit >> 32) << endl;
719  outputDebugFile << "EndTimeOfFit " << formatTime(endTimeOfFit >> 32) << " " << (endTimeOfFit >> 32) << endl;
720  outputDebugFile << "LumiRange " << beginLumiOfFit << " - " << endLumiOfFit << endl;
721  outputDebugFile << "Type " << dataType << endl;
722  // 3D Vertexing with Pixel Tracks:
723  // Good data = Type 3
724  // Bad data = Type -1
725 
726  BufferString << *(it+0);
727  outputDebugFile << "X0 " << BufferString.str().c_str() << endl;
728  BufferString.str("");
729 
730  BufferString << *(it+1);
731  outputDebugFile << "Y0 " << BufferString.str().c_str() << endl;
732  BufferString.str("");
733 
734  BufferString << *(it+2);
735  outputDebugFile << "Z0 " << BufferString.str().c_str() << endl;
736  BufferString.str("");
737 
738  BufferString << *(it+3);
739  outputDebugFile << "sigmaZ0 " << BufferString.str().c_str() << endl;
740  BufferString.str("");
741 
742  BufferString << *(it+4);
743  outputDebugFile << "dxdz " << BufferString.str().c_str() << endl;
744  BufferString.str("");
745 
746  BufferString << *(it+5);
747  outputDebugFile << "dydz " << BufferString.str().c_str() << endl;
748  BufferString.str("");
749 
750  BufferString << *(it+6);
751  outputDebugFile << "BeamWidthX " << BufferString.str().c_str() << endl;
752  BufferString.str("");
753 
754  BufferString << *(it+7);
755  outputDebugFile << "BeamWidthY " << BufferString.str().c_str() << endl;
756  BufferString.str("");
757 
758  outputDebugFile << "Cov(0,j) " << *(it+8) << " 0.0 0.0 0.0 0.0 0.0 0.0" << endl;
759  outputDebugFile << "Cov(1,j) 0.0 " << *(it+9) << " 0.0 0.0 0.0 0.0 0.0" << endl;
760  outputDebugFile << "Cov(2,j) 0.0 0.0 " << *(it+10) << " 0.0 0.0 0.0 0.0" << endl;
761  outputDebugFile << "Cov(3,j) 0.0 0.0 0.0 " << *(it+11) << " 0.0 0.0 0.0" << endl;
762  outputDebugFile << "Cov(4,j) 0.0 0.0 0.0 0.0 " << *(it+12) << " 0.0 0.0" << endl;
763  outputDebugFile << "Cov(5,j) 0.0 0.0 0.0 0.0 0.0 " << *(it+13) << " 0.0" << endl;
764  outputDebugFile << "Cov(6,j) 0.0 0.0 0.0 0.0 0.0 0.0 " << ((*(it+14)) + (*(it+15)) + 2.*std::sqrt((*(it+14))*(*(it+15)))) / 4. << endl;
765 
766  outputDebugFile << "EmittanceX 0.0" << endl;
767  outputDebugFile << "EmittanceY 0.0" << endl;
768  outputDebugFile << "BetaStar 0.0" << endl;
769  }
770 }
unsigned int beginLumiOfFit
#define NULL
Definition: scimark2.h:8
virtual string formatTime(const time_t &t)
unsigned int endLumiOfFit
T sqrt(T t)
Definition: SSEVec.h:48
tuple out
Definition: dbtoconf.py:99
ofstream outputDebugFile
TimeValue_t beginTimeOfFit
unsigned int runNumber
TimeValue_t endTimeOfFit

Member Data Documentation

unsigned int Vx3DHLTAnalyzer::beginLumiOfFit
private

Definition at line 168 of file Vx3DHLTAnalyzer.h.

Referenced by beginLuminosityBlock(), endLuminosityBlock(), reset(), and writeToFile().

TimeValue_t Vx3DHLTAnalyzer::beginTimeOfFit
private
bool Vx3DHLTAnalyzer::dataFromFit
private

Definition at line 107 of file Vx3DHLTAnalyzer.h.

Referenced by endLuminosityBlock(), and Vx3DHLTAnalyzer().

bool Vx3DHLTAnalyzer::debugMode
private

Definition at line 105 of file Vx3DHLTAnalyzer.h.

Referenced by analyze(), Vx3DHLTAnalyzer(), and writeToFile().

MonitorElement* Vx3DHLTAnalyzer::dxdzlumi
private

Definition at line 129 of file Vx3DHLTAnalyzer.h.

Referenced by beginRun(), endLuminosityBlock(), and reset().

MonitorElement* Vx3DHLTAnalyzer::dydzlumi
private

Definition at line 130 of file Vx3DHLTAnalyzer.h.

Referenced by beginRun(), endLuminosityBlock(), and reset().

unsigned int Vx3DHLTAnalyzer::endLumiOfFit
private

Definition at line 169 of file Vx3DHLTAnalyzer.h.

Referenced by endLuminosityBlock(), reset(), and writeToFile().

TimeValue_t Vx3DHLTAnalyzer::endTimeOfFit
private

Definition at line 157 of file Vx3DHLTAnalyzer.h.

Referenced by endLuminosityBlock(), reset(), and writeToFile().

string Vx3DHLTAnalyzer::fileName
private

Definition at line 115 of file Vx3DHLTAnalyzer.h.

Referenced by analyze(), readConfig.fileINI::read(), Vx3DHLTAnalyzer(), and writeToFile().

MonitorElement* Vx3DHLTAnalyzer::fitResults
private

Definition at line 149 of file Vx3DHLTAnalyzer.h.

Referenced by beginRun(), endLuminosityBlock(), and reset().

MonitorElement* Vx3DHLTAnalyzer::goodVxCounter
private

Definition at line 140 of file Vx3DHLTAnalyzer.h.

Referenced by beginRun(), endLuminosityBlock(), and reset().

MonitorElement* Vx3DHLTAnalyzer::goodVxCountHistory
private

Definition at line 141 of file Vx3DHLTAnalyzer.h.

Referenced by beginRun(), endLuminosityBlock(), and reset().

MonitorElement* Vx3DHLTAnalyzer::hitCounter
private

Definition at line 143 of file Vx3DHLTAnalyzer.h.

Referenced by beginRun(), endLuminosityBlock(), and reset().

MonitorElement* Vx3DHLTAnalyzer::hitCountHistory
private

Definition at line 144 of file Vx3DHLTAnalyzer.h.

Referenced by beginRun(), endLuminosityBlock(), and reset().

bool Vx3DHLTAnalyzer::internalDebug
private

Definition at line 172 of file Vx3DHLTAnalyzer.h.

Referenced by analyze(), beginJob(), endLuminosityBlock(), and MyFit().

unsigned int Vx3DHLTAnalyzer::lastLumiOfFit
private

Definition at line 170 of file Vx3DHLTAnalyzer.h.

Referenced by beginLuminosityBlock(), endLuminosityBlock(), and reset().

unsigned int Vx3DHLTAnalyzer::lumiCounter
private

Definition at line 161 of file Vx3DHLTAnalyzer.h.

Referenced by beginLuminosityBlock(), endLuminosityBlock(), and reset().

unsigned int Vx3DHLTAnalyzer::lumiCounterHisto
private

Definition at line 162 of file Vx3DHLTAnalyzer.h.

Referenced by beginLuminosityBlock(), endLuminosityBlock(), and reset().

unsigned int Vx3DHLTAnalyzer::maxLumiIntegration
private

Definition at line 164 of file Vx3DHLTAnalyzer.h.

Referenced by beginJob(), and endLuminosityBlock().

unsigned int Vx3DHLTAnalyzer::minNentries
private

Definition at line 108 of file Vx3DHLTAnalyzer.h.

Referenced by endLuminosityBlock(), MyFit(), and Vx3DHLTAnalyzer().

double Vx3DHLTAnalyzer::minVxDoF
private

Definition at line 171 of file Vx3DHLTAnalyzer.h.

Referenced by analyze(), and beginJob().

MonitorElement* Vx3DHLTAnalyzer::mXlumi
private

Definition at line 121 of file Vx3DHLTAnalyzer.h.

Referenced by beginRun(), endLuminosityBlock(), and reset().

MonitorElement* Vx3DHLTAnalyzer::mYlumi
private

Definition at line 122 of file Vx3DHLTAnalyzer.h.

Referenced by beginRun(), endLuminosityBlock(), and reset().

MonitorElement* Vx3DHLTAnalyzer::mZlumi
private

Definition at line 123 of file Vx3DHLTAnalyzer.h.

Referenced by beginRun(), endLuminosityBlock(), and reset().

unsigned int Vx3DHLTAnalyzer::nBinsHistoricalPlot
private

Definition at line 158 of file Vx3DHLTAnalyzer.h.

Referenced by beginRun().

unsigned int Vx3DHLTAnalyzer::nBinsWholeHistory
private

Definition at line 159 of file Vx3DHLTAnalyzer.h.

Referenced by beginRun(), and endLuminosityBlock().

unsigned int Vx3DHLTAnalyzer::nLumiReset
private

Definition at line 106 of file Vx3DHLTAnalyzer.h.

Referenced by endLuminosityBlock(), and Vx3DHLTAnalyzer().

unsigned int Vx3DHLTAnalyzer::numberFits
private

Definition at line 167 of file Vx3DHLTAnalyzer.h.

Referenced by endLuminosityBlock(), and reset().

unsigned int Vx3DHLTAnalyzer::numberGoodFits
private

Definition at line 166 of file Vx3DHLTAnalyzer.h.

Referenced by endLuminosityBlock(), and reset().

ofstream Vx3DHLTAnalyzer::outputDebugFile
private

Definition at line 155 of file Vx3DHLTAnalyzer.h.

Referenced by analyze(), endLuminosityBlock(), and writeToFile().

ofstream Vx3DHLTAnalyzer::outputFile
private

Definition at line 154 of file Vx3DHLTAnalyzer.h.

Referenced by writeToFile().

EDGetTokenT<SiPixelRecHitCollection> Vx3DHLTAnalyzer::pixelHitCollection
private

Definition at line 104 of file Vx3DHLTAnalyzer.h.

Referenced by HitCounter(), and Vx3DHLTAnalyzer().

unsigned int Vx3DHLTAnalyzer::prescaleHistory
private

Definition at line 165 of file Vx3DHLTAnalyzer.h.

Referenced by beginJob(), and endLuminosityBlock().

MonitorElement* Vx3DHLTAnalyzer::reportSummary
private

Definition at line 146 of file Vx3DHLTAnalyzer.h.

Referenced by beginRun(), endLuminosityBlock(), and reset().

MonitorElement* Vx3DHLTAnalyzer::reportSummaryMap
private

Definition at line 147 of file Vx3DHLTAnalyzer.h.

Referenced by beginRun(), endLuminosityBlock(), and reset().

unsigned int Vx3DHLTAnalyzer::runNumber
private

Definition at line 160 of file Vx3DHLTAnalyzer.h.

Referenced by analyze(), endLuminosityBlock(), reset(), and writeToFile().

MonitorElement* Vx3DHLTAnalyzer::sXlumi
private

Definition at line 125 of file Vx3DHLTAnalyzer.h.

Referenced by beginRun(), endLuminosityBlock(), and reset().

MonitorElement* Vx3DHLTAnalyzer::sYlumi
private

Definition at line 126 of file Vx3DHLTAnalyzer.h.

Referenced by beginRun(), endLuminosityBlock(), and reset().

MonitorElement* Vx3DHLTAnalyzer::sZlumi
private

Definition at line 127 of file Vx3DHLTAnalyzer.h.

Referenced by beginRun(), endLuminosityBlock(), and reset().

unsigned int Vx3DHLTAnalyzer::totalHits
private

Definition at line 163 of file Vx3DHLTAnalyzer.h.

Referenced by analyze(), endLuminosityBlock(), and reset().

EDGetTokenT<VertexCollection> Vx3DHLTAnalyzer::vertexCollection
private

Definition at line 103 of file Vx3DHLTAnalyzer.h.

Referenced by analyze(), and Vx3DHLTAnalyzer().

MonitorElement* Vx3DHLTAnalyzer::Vx_X
private

Definition at line 132 of file Vx3DHLTAnalyzer.h.

Referenced by analyze(), beginRun(), endLuminosityBlock(), and reset().

MonitorElement* Vx3DHLTAnalyzer::Vx_XY
private

Definition at line 138 of file Vx3DHLTAnalyzer.h.

Referenced by analyze(), beginRun(), and reset().

MonitorElement* Vx3DHLTAnalyzer::Vx_Y
private

Definition at line 133 of file Vx3DHLTAnalyzer.h.

Referenced by analyze(), beginRun(), endLuminosityBlock(), and reset().

MonitorElement* Vx3DHLTAnalyzer::Vx_Z
private

Definition at line 134 of file Vx3DHLTAnalyzer.h.

Referenced by analyze(), beginRun(), endLuminosityBlock(), and reset().

MonitorElement* Vx3DHLTAnalyzer::Vx_ZX
private

Definition at line 136 of file Vx3DHLTAnalyzer.h.

Referenced by analyze(), beginRun(), and reset().

MonitorElement* Vx3DHLTAnalyzer::Vx_ZY
private

Definition at line 137 of file Vx3DHLTAnalyzer.h.

Referenced by analyze(), beginRun(), and reset().

double Vx3DHLTAnalyzer::xRange
private

Definition at line 109 of file Vx3DHLTAnalyzer.h.

Referenced by beginRun(), and Vx3DHLTAnalyzer().

double Vx3DHLTAnalyzer::xStep
private

Definition at line 110 of file Vx3DHLTAnalyzer.h.

Referenced by beginRun(), and Vx3DHLTAnalyzer().

double Vx3DHLTAnalyzer::yRange
private

Definition at line 111 of file Vx3DHLTAnalyzer.h.

Referenced by beginRun(), and Vx3DHLTAnalyzer().

double Vx3DHLTAnalyzer::yStep
private

Definition at line 112 of file Vx3DHLTAnalyzer.h.

Referenced by beginRun(), and Vx3DHLTAnalyzer().

double Vx3DHLTAnalyzer::zRange
private

Definition at line 113 of file Vx3DHLTAnalyzer.h.

Referenced by beginRun(), and Vx3DHLTAnalyzer().

double Vx3DHLTAnalyzer::zStep
private

Definition at line 114 of file Vx3DHLTAnalyzer.h.

Referenced by beginRun(), and Vx3DHLTAnalyzer().