54 #include "TGraphErrors.h"
81 void getLasBeams(
TkFittedLasBeam &beam,vector<TrajectoryStateOnSurface> &tsosLas);
83 vector<const GeomDetUnit*> &gd, vector<GlobalPoint> &globHit,
84 unsigned int &hitsAtTecPlus);
89 static double tecPlusFunction(
double *
x,
double *par);
90 static double tecMinusFunction(
double *x,
double *par);
91 static double atFunction(
double *x,
double *par);
94 unsigned int &hitsAtTecPlus,
unsigned int &nFitParams,
95 std::vector<double> &hitPhi, std::vector<double> &hitPhiError, std::vector<double> &hitZprimeError,
96 double &zMin,
double &zMax,
double &bsAngleParam,
97 double &
offset,
double &offsetError,
double &
slope,
double &slopeError,
98 double &phiAtMinusParam,
double &phiAtPlusParam,
99 double &atThetaSplitParam);
102 double &
trackPhi,
double &trackPhiRef,
103 double &offset,
double &slope,
double &bsAngleParam,
104 double &phiAtMinusParam,
double &phiAtPlusParam,
105 double &atThetaSplitParam, std::vector<GlobalPoint> &globHit);
108 unsigned int &hit,
unsigned int &hitsAtTecPlus,
109 double &trackPhi,
double &trackPhiRef,
110 std::vector<GlobalPoint> &globHit, std::vector<GlobalPoint> &globPtrack,
111 GlobalPoint &globPref, std::vector<double> &hitPhiError);
114 vector<const GeomDetUnit*> &gd, std::vector<GlobalPoint> &globPtrack,
115 vector<TrajectoryStateOnSurface> &tsosLas,
GlobalPoint &globPref);
118 unsigned int &hitsAtTecPlus,
unsigned int &nFitParams,
119 double &offset,
double &slope, vector<GlobalPoint> &globPtrack,
120 double &bsAngleParam,
double &chi2);
144 TH1F *h_bsAngle, *h_hitX, *h_hitXTecPlus, *h_hitXTecMinus,
145 *h_hitXAt, *h_chi2, *h_chi2ndof, *h_pull, *h_res,
147 TH2F *h_bsAngleVsBeam, *h_hitXvsZTecPlus, *h_hitXvsZTecMinus,
149 *h_resVsHitTecPlus, *h_resVsHitTecMinus, *h_resVsHitAt;
184 src_(iConfig.getParameter<edm::
InputTag>(
"src")),
185 fitBeamSplitters_(iConfig.getParameter<bool>(
"fitBeamSplitters")),
186 nAtParameters_(iConfig.getParameter<unsigned int>(
"numberOfFittedAtParameters")),
187 h_bsAngle(0), h_hitX(0), h_hitXTecPlus(0), h_hitXTecMinus(0),
188 h_hitXAt(0), h_chi2(0), h_chi2ndof(0), h_pull(0), h_res(0),
189 h_resTecPlus(0), h_resTecMinus(0), h_resAt(0),
190 h_bsAngleVsBeam(0), h_hitXvsZTecPlus(0), h_hitXvsZTecMinus(0),
191 h_hitXvsZAt(0), h_resVsZTecPlus(0), h_resVsZTecMinus(0), h_resVsZAt(0),
192 h_resVsHitTecPlus(0), h_resVsHitTecMinus(0), h_resVsHitAt(0)
195 this->produces<TkFittedLasBeamCollection, edm::InRun>();
196 this->produces<TsosVectorCollection, edm::InRun>();
236 h_hitX =
fs->
make<TH1F>(
"hitX",
"local x of LAS hits;local x [cm];N",100,-0.5,0.5);
237 h_hitXTecPlus =
fs->
make<TH1F>(
"hitXTecPlus",
"local x of LAS hits in TECplus;local x [cm];N",100,-0.5,0.5);
238 h_hitXTecMinus =
fs->
make<TH1F>(
"hitXTecMinus",
"local x of LAS hits in TECminus;local x [cm];N",100,-0.5,0.5);
239 h_hitXAt =
fs->
make<TH1F>(
"hitXAt",
"local x of LAS hits in ATs;local x [cm];N",100,-2.5,2.5);
240 h_hitXvsZTecPlus =
fs->
make<TH2F>(
"hitXvsZTecPlus",
"local x vs z in TECplus;z [cm];local x [cm]",80,120,280,100,-0.5,0.5);
241 h_hitXvsZTecMinus =
fs->
make<TH2F>(
"hitXvsZTecMinus",
"local x vs z in TECMinus;z [cm];local x [cm]",80,-280,-120,100,-0.5,0.5);
242 h_hitXvsZAt =
fs->
make<TH2F>(
"hitXvsZAt",
"local x vs z in ATs;z [cm];local x [cm]",200,-200,200,100,-0.5,0.5);
243 h_chi2 =
fs->
make<TH1F>(
"chi2",
"#chi^{2};#chi^{2};N",100,0,2000);
244 h_chi2ndof =
fs->
make<TH1F>(
"chi2ndof",
"#chi^{2} per degree of freedom;#chi^{2}/N_{dof};N",100,0,300);
245 h_pull =
fs->
make<TH1F>(
"pull",
"pulls of #phi residuals;pull;N",50,-10,10);
246 h_res =
fs->
make<TH1F>(
"res",
"#phi residuals;#phi_{track} - #phi_{hit} [rad];N",60,-0.0015,0.0015);
247 h_resTecPlus =
fs->
make<TH1F>(
"resTecPlus",
"#phi residuals in TECplus;#phi_{track} - #phi_{hit} [rad];N",30,-0.0015,0.0015);
248 h_resTecMinus =
fs->
make<TH1F>(
"resTecMinus",
"#phi residuals in TECminus;#phi_{track} - #phi_{hit} [rad];N",60,-0.0015,0.0015);
249 h_resAt =
fs->
make<TH1F>(
"resAt",
"#phi residuals in ATs;#phi_{track} - #phi_{hit} [rad];N",30,-0.0015,0.0015);
250 h_resVsZTecPlus =
fs->
make<TH2F>(
"resVsZTecPlus",
"phi residuals vs. z in TECplus;z [cm];#phi_{track} - #phi_{hit} [rad]",
251 80,120,280,100,-0.0015,0.0015);
252 h_resVsZTecMinus =
fs->
make<TH2F>(
"resVsZTecMinus",
"phi residuals vs. z in TECminus;z [cm];#phi_{track} - #phi_{hit} [rad]",
253 80,-280,-120,100,-0.0015,0.0015);
254 h_resVsZAt =
fs->
make<TH2F>(
"resVsZAt",
"#phi residuals vs. z in ATs;N;#phi_{track} - #phi_{hit} [rad]",
255 200,-200,200,100,-0.0015,0.0015);
256 h_resVsHitTecPlus =
fs->
make<TH2F>(
"resVsHitTecPlus",
"#phi residuals vs. hits in TECplus;hit no.;#phi_{track} - #phi_{hit} [rad]",
257 144,0,144,100,-0.0015,0.0015);
258 h_resVsHitTecMinus =
fs->
make<TH2F>(
"resVsHitTecMinus",
"#phi residuals vs. hits in TECminus;hit no.;#phi_{track} - #phi_{hit} [rad]",
259 144,0,144,100,-0.0015,0.0015);
260 h_resVsHitAt =
fs->
make<TH2F>(
"resVsHitAt",
"#phi residuals vs. hits in ATs;hit no.;#phi_{track} - #phi_{hit} [rad]",
261 176,0,176,100,-0.0015,0.0015);
262 h_bsAngle =
fs->
make<TH1F>(
"bsAngle",
"fitted beam splitter angle;BS angle [rad];N",40,-0.004,0.004);
263 h_bsAngleVsBeam =
fs->
make<TH2F>(
"bsAngleVsBeam",
"fitted beam splitter angle per beam;Beam no.;BS angle [rad]",
264 40,0,300,100,-0.004,0.004);
287 double bsParams[40] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
288 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
291 unsigned int beamNo(0);
295 else cout <<
"BS fixed, not fitted!" << endl;
299 iBeam != iEnd; ++iBeam){
302 vector<TrajectoryStateOnSurface> tsosLas;
311 fittedBeams->push_back(beam);
312 tsosesVec->push_back(tsosLas);
325 run.
put(fittedBeams);
334 cout <<
"---------------------------------------" << endl;
349 vector<const GeomDetUnit*> gd;
350 vector<GlobalPoint> globHit;
351 unsigned int hitsAtTecPlus(0);
360 this->
getLasHits(beam, hit, gd, globHit, hitsAtTecPlus);
361 sumZ += globHit.back().z();
382 gBeamZ0 = sumZ / globHit.size();
383 double zMin(0.), zMax(0.);
404 vector<double> hitPhi, hitPhiError, hitZprimeError;
406 for(
unsigned int hit = 0;
hit < globHit.size(); ++
hit){
407 hitPhi.push_back(static_cast<double>(globHit[
hit].
phi()));
409 hitPhiError.push_back( 0.003 / globHit[
hit].
perp());
411 hitZprimeError.push_back(0.0);
432 unsigned int tecParams(3), atParams(0);
436 unsigned int nFitParams(0);
439 tecParams = tecParams - 1;
440 atParams = atParams - 1;
443 nFitParams = tecParams;
446 nFitParams = atParams;
450 double offset(0.), offsetError(0.),
slope(0.), slopeError(0.),
451 bsAngleParam(0.), phiAtMinusParam(0.), phiAtPlusParam(0.),
452 atThetaSplitParam(0.);
461 this->
fitter(beam, covMatrix,
462 hitsAtTecPlus, nFitParams,
463 hitPhi, hitPhiError, hitZprimeError,
464 zMin, zMax, bsAngleParam,
466 phiAtMinusParam, phiAtPlusParam,
469 vector<GlobalPoint> globPtrack;
476 double trackPhi(0.), trackPhiRef(0.);
480 phiAtMinusParam, phiAtPlusParam,
481 atThetaSplitParam, globHit);
484 <<
", hit phi = " << hitPhi[
hit]
486 <<
" r = " << globHit[
hit].perp() << endl;
490 globHit, globPtrack, globPref,
494 const double phiResidual = globPtrack[
hit].phi() - globHit[
hit].phi();
496 const double phiResidualPull = phiResidual / hitPhiError[
hit];
501 chi2 += phiResidual*phiResidual / (hitPhiError[
hit]*hitPhiError[
hit]);
504 h_res->Fill(phiResidual);
507 h_pull->Fill(phiResidualPull);
521 h_pull->Fill(phiResidualPull);
535 h_pull->Fill(phiResidualPull);
544 cout <<
"chi^2 = " << chi2 <<
", chi^2/ndof = " << chi2/(
gHitZprime.size() - nFitParams) << endl;
545 this->
fitBeam(beam, covMatrix, hitsAtTecPlus, nFitParams,
548 cout <<
"bsAngleParam = " << bsAngleParam << endl;
554 if(bsAngleParam != 0.0){
555 h_bsAngle->Fill(2.0*atan(0.5*bsAngleParam));
563 vector<const GeomDetUnit*> &gd, vector<GlobalPoint> &globHit,
564 unsigned int &hitsAtTecPlus)
571 globHit.push_back(globPtemp);
574 if(
abs(globPtemp.
z()) > 112.3){
576 else hitsAtTecPlus++ ;
588 return par[0] + par[1] *
z;
607 return par[0] + par[1] *
z;
625 return par[0] + par[1] *
z;
632 return par[0] + par[1] * z +
gTOBparam * (par[2] + par[4]);
636 return par[0] + par[1] * z -
gTIBparam * (par[2] - par[4]);
644 return par[0] + par[1] * z +
gTOBparam * (par[3] - par[4]);
648 return par[0] + par[1] * z -
gTIBparam * (par[3] + par[4]);
666 unsigned int &hitsAtTecPlus,
unsigned int &nFitParams,
667 vector<double> &hitPhi, vector<double> &hitPhiError, vector<double> &hitZprimeError,
668 double &zMin,
double &zMax,
double &bsAngleParam,
669 double &
offset,
double &offsetError,
double &
slope,
double &slopeError,
670 double &phiAtMinusParam,
double &phiAtPlusParam,
double &atThetaSplitParam)
672 TGraphErrors *lasData =
new TGraphErrors(
gHitZprime.size(),
674 &(hitZprimeError[0]), &(hitPhiError[0]));
679 tecPlus.SetParameter( 1, 0 );
680 tecPlus.SetParameter( nFitParams - 1, 0 );
681 lasData->Fit(
"tecPlus",
"R");
685 tecMinus.SetParameter( 1, 0 );
686 tecMinus.SetParameter( nFitParams - 1, 0 );
687 lasData->Fit(
"tecMinus",
"R");
691 at.SetParameter( 1, 0 );
692 at.SetParameter( nFitParams - 1, 0 );
693 lasData->Fit(
"at",
"R");
697 gMinuit->GetParameter(0, offset, offsetError);
698 gMinuit->GetParameter(1, slope, slopeError);
702 double bsAngleParamError(0.), phiAtMinusParamError(0.),
703 phiAtPlusParamError(0.), atThetaSplitParamError(0.);
706 gMinuit->GetParameter(2, phiAtMinusParam, phiAtMinusParamError);
707 gMinuit->GetParameter(3, phiAtPlusParam, phiAtPlusParamError);
708 gMinuit->GetParameter(4, atThetaSplitParam, atThetaSplitParamError);
716 gMinuit->GetParameter( nFitParams - 1 , bsAngleParam, bsAngleParamError);
724 vector<double> vec( covMatrix.num_col() * covMatrix.num_col() );
725 gMinuit->mnemat( &vec[0], covMatrix.num_col() );
726 for(
int col = 0; col < covMatrix.num_col(); col++){
727 for(
int row = 0; row < covMatrix.num_col(); row++){
728 covMatrix[col][row] = vec[row + covMatrix.num_col()*col];
740 double &
trackPhi,
double &trackPhiRef,
741 double &
offset,
double &
slope,
double &bsAngleParam,
742 double &phiAtMinusParam,
double &phiAtPlusParam,
743 double &atThetaSplitParam, vector<GlobalPoint> &globHit)
749 trackPhiRef = offset + slope * (gHitZprime[hit] + 1.0);
754 trackPhiRef = offset + slope * (
gHitZprime[hit] + 1.0)
762 trackPhiRef = offset + slope * (gHitZprime[hit] + 1.0);
767 trackPhiRef = offset + slope * (
gHitZprime[hit] + 1.0)
776 trackPhiRef = offset + slope * (gHitZprime[hit] + 1.0);
781 trackPhi = offset + slope *
gHitZprime[hit] +
gTOBparam * (phiAtMinusParam + atThetaSplitParam);
784 trackPhi = offset + slope *
gHitZprime[hit] -
gTIBparam * (phiAtMinusParam - atThetaSplitParam);
791 trackPhi = offset + slope *
gHitZprime[hit] +
gTOBparam * (phiAtPlusParam - atThetaSplitParam);
794 trackPhi = offset + slope *
gHitZprime[hit] -
gTIBparam * (phiAtPlusParam + atThetaSplitParam);
802 trackPhiRef = offset + slope * (
gHitZprime[hit] + 1.0)
811 unsigned int &
hit,
unsigned int &hitsAtTecPlus,
812 double &
trackPhi,
double &trackPhiRef,
813 vector<GlobalPoint> &globHit, vector<GlobalPoint> &globPtrack,
814 GlobalPoint &globPref, vector<double> &hitPhiError)
829 else if(hit >
gHitZprime.size() - hitsAtTecPlus - 1){
844 vector<const GeomDetUnit*> &gd, vector<GlobalPoint> &globPtrack,
845 vector<TrajectoryStateOnSurface> &tsosLas,
GlobalPoint &globPref)
852 trajectoryState =
GlobalVector(globPref-globPtrack[hit]);
856 trajectoryState =
GlobalVector(globPtrack[hit]-globPref);
862 trajectoryState =
GlobalVector(globPtrack[hit]-globPref);
866 trajectoryState =
GlobalVector(globPref-globPtrack[hit]);
870 trajectoryState =
GlobalVector(globPtrack[hit]-globPref);
882 unsigned int &hitsAtTecPlus,
unsigned int &nFitParams,
883 double &
offset,
double &
slope, vector<GlobalPoint> &globPtrack,
884 double &bsAngleParam,
double &chi2)
887 unsigned int paramType(0);
893 const unsigned int nPedeParams(nFitParams);
896 std::vector<TkFittedLasBeam::Scalar> params(nPedeParams);
907 derivatives[
hit][0] = 1.0;
912 derivatives[
hit][1] = globPtrack[
hit].z();
922 derivatives[
hit][1] = globPtrack[
hit].z();
934 derivatives[
hit][1] = globPtrack[
hit].z();
941 derivatives[
hit][1] = globPtrack[
hit].z();
956 unsigned int firstFixedParam(covMatrix.num_col());
961 beam.
setParameters(paramType, params, covMatrix, derivatives, firstFixedParam, chi2);
ESHandle< MagneticField > fieldHandle
static vector< double > gHitZprime
bool getByLabel(std::string const &label, Handle< PROD > &result) const
static double tecMinusFunction(double *x, double *par)
static double tecPlusFunction(double *x, double *par)
#define DEFINE_FWK_MODULE(type)
TkLasBeamFitter(const edm::ParameterSet &config)
static const double slope[3]
Global3DPoint GlobalPoint
bool isRing6(void) const
true if this beam hits TEC R6 (last digit of beamId)
static vector< double > gBarrelModuleRadius
virtual LocalPoint localPosition() const
bool fitBeam(TkFittedLasBeam &beam, AlgebraicSymMatrix &covMatrix, unsigned int &hitsAtTecPlus, unsigned int &nFitParams, double &offset, double &slope, vector< GlobalPoint > &globPtrack, double &bsAngleParam, double &chi2)
static bool gFitBeamSplitters
bool isTecInternal(int side=0) const
true if this is a TEC internal beam (from 10^2 digit of beamId). side parameter: -1 = ask if TEC-...
virtual void endRun(edm::Run &run, const edm::EventSetup &setup)
Handle< TkLasBeamCollection > laserBeams
static bool gIsInnerBarrel
unsigned int nAtParameters_
CLHEP::HepMatrix AlgebraicMatrix
unsigned int getBeamId(void) const
return the full beam identifier
void globalTrackPoint(TkFittedLasBeam &beam, unsigned int &hit, unsigned int &hitsAtTecPlus, double &trackPhi, double &trackPhiRef, std::vector< GlobalPoint > &globHit, std::vector< GlobalPoint > &globPtrack, GlobalPoint &globPref, std::vector< double > &hitPhiError)
static double gBeamSplitterZprime
std::vector< SiStripLaserRecHit2D >::const_iterator end(void) const
access iterator to the collection of hits
TH2F * h_resVsHitTecMinus
std::vector< SiStripLaserRecHit2D >::const_iterator begin(void) const
access iterator to the collection of hits
unsigned int offset(bool)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
static unsigned int gHitsAtTecMinus
void fitter(TkFittedLasBeam &beam, AlgebraicSymMatrix &covMatrix, unsigned int &hitsAtTecPlus, unsigned int &nFitParams, std::vector< double > &hitPhi, std::vector< double > &hitPhiError, std::vector< double > &hitZprimeError, double &zMin, double &zMax, double &bsAngleParam, double &offset, double &offsetError, double &slope, double &slopeError, double &phiAtMinusParam, double &phiAtPlusParam, double &atThetaSplitParam)
const SiStripDetId & getDetId(void) const
void buildTrajectory(TkFittedLasBeam &beam, unsigned int &hit, vector< const GeomDetUnit * > &gd, std::vector< GlobalPoint > &globPtrack, vector< TrajectoryStateOnSurface > &tsosLas, GlobalPoint &globPref)
virtual void produce(edm::Event &event, const edm::EventSetup &setup)
T const * product() const
static vector< double > gBarrelModuleOffset
ESHandle< TrackerGeometry > geometry
T perp() const
Magnitude of transverse component.
void trackPhi(TkFittedLasBeam &beam, unsigned int &hit, double &trackPhi, double &trackPhiRef, double &offset, double &slope, double &bsAngleParam, double &phiAtMinusParam, double &phiAtPlusParam, double &atThetaSplitParam, std::vector< GlobalPoint > &globHit)
std::vector< TkFittedLasBeam > TkFittedLasBeamCollection
CLHEP::HepSymMatrix AlgebraicSymMatrix
T * make() const
make new ROOT object
static double atFunction(double *x, double *par)
void put(std::auto_ptr< PROD > product)
Put a new product.
void getLasBeams(TkFittedLasBeam &beam, vector< TrajectoryStateOnSurface > &tsosLas)
std::vector< std::vector< TrajectoryStateOnSurface > > TsosVectorCollection
void getLasHits(TkFittedLasBeam &beam, const SiStripLaserRecHit2D &hit, vector< const GeomDetUnit * > &gd, vector< GlobalPoint > &globHit, unsigned int &hitsAtTecPlus)
edm::Service< TFileService > fs
std::vector< SiStripLaserRecHit2D >::const_iterator const_iterator
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
bool isAlignmentTube(void) const
true if this is an AT beam (from 10^2 digit of beamId)
Global3DVector GlobalVector
void setParameters(unsigned int parametrisation, const std::vector< Scalar > ¶ms, const AlgebraicSymMatrix ¶mCovariance, const AlgebraicMatrix &derivatives, unsigned int firstFixedParam, float chi2)