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"))
189 this->produces<TkFittedLasBeamCollection, edm::InRun>();
190 this->produces<TsosVectorCollection, edm::InRun>();
230 h_hitX =
fs->
make<TH1F>(
"hitX",
"local x of LAS hits;local x [cm];N",100,-0.5,0.5);
231 h_hitXTecPlus =
fs->
make<TH1F>(
"hitXTecPlus",
"local x of LAS hits in TECplus;local x [cm];N",100,-0.5,0.5);
232 h_hitXTecMinus =
fs->
make<TH1F>(
"hitXTecMinus",
"local x of LAS hits in TECminus;local x [cm];N",100,-0.5,0.5);
233 h_hitXAt =
fs->
make<TH1F>(
"hitXAt",
"local x of LAS hits in ATs;local x [cm];N",100,-2.5,2.5);
234 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);
235 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);
236 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);
237 h_chi2 =
fs->
make<TH1F>(
"chi2",
"#chi^{2};#chi^{2};N",100,0,2000);
238 h_chi2ndof =
fs->
make<TH1F>(
"chi2ndof",
"#chi^{2} per degree of freedom;#chi^{2}/N_{dof};N",100,0,300);
239 h_pull =
fs->
make<TH1F>(
"pull",
"pulls of #phi residuals;pull;N",50,-10,10);
240 h_res =
fs->
make<TH1F>(
"res",
"#phi residuals;#phi_{track} - #phi_{hit} [rad];N",60,-0.0015,0.0015);
241 h_resTecPlus =
fs->
make<TH1F>(
"resTecPlus",
"#phi residuals in TECplus;#phi_{track} - #phi_{hit} [rad];N",30,-0.0015,0.0015);
242 h_resTecMinus =
fs->
make<TH1F>(
"resTecMinus",
"#phi residuals in TECminus;#phi_{track} - #phi_{hit} [rad];N",60,-0.0015,0.0015);
243 h_resAt =
fs->
make<TH1F>(
"resAt",
"#phi residuals in ATs;#phi_{track} - #phi_{hit} [rad];N",30,-0.0015,0.0015);
244 h_resVsZTecPlus =
fs->
make<TH2F>(
"resVsZTecPlus",
"phi residuals vs. z in TECplus;z [cm];#phi_{track} - #phi_{hit} [rad]",
245 80,120,280,100,-0.0015,0.0015);
246 h_resVsZTecMinus =
fs->
make<TH2F>(
"resVsZTecMinus",
"phi residuals vs. z in TECminus;z [cm];#phi_{track} - #phi_{hit} [rad]",
247 80,-280,-120,100,-0.0015,0.0015);
248 h_resVsZAt =
fs->
make<TH2F>(
"resVsZAt",
"#phi residuals vs. z in ATs;N;#phi_{track} - #phi_{hit} [rad]",
249 200,-200,200,100,-0.0015,0.0015);
250 h_resVsHitTecPlus =
fs->
make<TH2F>(
"resVsHitTecPlus",
"#phi residuals vs. hits in TECplus;hit no.;#phi_{track} - #phi_{hit} [rad]",
251 144,0,144,100,-0.0015,0.0015);
252 h_resVsHitTecMinus =
fs->
make<TH2F>(
"resVsHitTecMinus",
"#phi residuals vs. hits in TECminus;hit no.;#phi_{track} - #phi_{hit} [rad]",
253 144,0,144,100,-0.0015,0.0015);
254 h_resVsHitAt =
fs->
make<TH2F>(
"resVsHitAt",
"#phi residuals vs. hits in ATs;hit no.;#phi_{track} - #phi_{hit} [rad]",
255 176,0,176,100,-0.0015,0.0015);
256 h_bsAngle =
fs->
make<TH1F>(
"bsAngle",
"fitted beam splitter angle;BS angle [rad];N",40,-0.004,0.004);
257 h_bsAngleVsBeam =
fs->
make<TH2F>(
"bsAngleVsBeam",
"fitted beam splitter angle per beam;Beam no.;BS angle [rad]",
258 40,0,300,100,-0.004,0.004);
281 double bsParams[40] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
282 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
285 unsigned int beamNo(0);
289 else cout <<
"BS fixed, not fitted!" << endl;
293 iBeam != iEnd; ++iBeam){
296 vector<TrajectoryStateOnSurface> tsosLas;
305 fittedBeams->push_back(beam);
306 tsosesVec->push_back(tsosLas);
319 run.
put(fittedBeams);
328 cout <<
"---------------------------------------" << endl;
343 vector<const GeomDetUnit*> gd;
344 vector<GlobalPoint> globHit;
345 unsigned int hitsAtTecPlus(0);
354 this->
getLasHits(beam, hit, gd, globHit, hitsAtTecPlus);
355 sumZ += globHit.back().z();
376 gBeamZ0 = sumZ / globHit.size();
377 double zMin(0.), zMax(0.);
398 vector<double> hitPhi, hitPhiError, hitZprimeError;
400 for(
unsigned int hit = 0;
hit < globHit.size(); ++
hit){
401 hitPhi.push_back(static_cast<double>(globHit[
hit].
phi()));
403 hitPhiError.push_back( 0.003 / globHit[
hit].
perp());
405 hitZprimeError.push_back(0.0);
426 unsigned int tecParams(3), atParams(0);
430 unsigned int nFitParams(0);
433 tecParams = tecParams - 1;
434 atParams = atParams - 1;
437 nFitParams = tecParams;
440 nFitParams = atParams;
444 double offset(0.), offsetError(0.),
slope(0.), slopeError(0.),
445 bsAngleParam(0.), phiAtMinusParam(0.), phiAtPlusParam(0.),
446 atThetaSplitParam(0.);
455 this->
fitter(beam, covMatrix,
456 hitsAtTecPlus, nFitParams,
457 hitPhi, hitPhiError, hitZprimeError,
458 zMin, zMax, bsAngleParam,
460 phiAtMinusParam, phiAtPlusParam,
463 vector<GlobalPoint> globPtrack;
470 double trackPhi(0.), trackPhiRef(0.);
474 phiAtMinusParam, phiAtPlusParam,
475 atThetaSplitParam, globHit);
478 <<
", hit phi = " << hitPhi[
hit]
480 <<
" r = " << globHit[
hit].perp() << endl;
484 globHit, globPtrack, globPref,
488 const double phiResidual = globPtrack[
hit].phi() - globHit[
hit].phi();
490 const double phiResidualPull = phiResidual / hitPhiError[
hit];
495 chi2 += phiResidual*phiResidual / (hitPhiError[
hit]*hitPhiError[
hit]);
498 h_res->Fill(phiResidual);
501 h_pull->Fill(phiResidualPull);
515 h_pull->Fill(phiResidualPull);
529 h_pull->Fill(phiResidualPull);
538 cout <<
"chi^2 = " << chi2 <<
", chi^2/ndof = " << chi2/(
gHitZprime.size() - nFitParams) << endl;
539 this->
fitBeam(beam, covMatrix, hitsAtTecPlus, nFitParams,
542 cout <<
"bsAngleParam = " << bsAngleParam << endl;
548 if(bsAngleParam != 0.0){
549 h_bsAngle->Fill(2.0*atan(0.5*bsAngleParam));
557 vector<const GeomDetUnit*> &gd, vector<GlobalPoint> &globHit,
558 unsigned int &hitsAtTecPlus)
565 globHit.push_back(globPtemp);
568 if(
abs(globPtemp.
z()) > 112.3){
570 else hitsAtTecPlus++ ;
582 return par[0] + par[1] *
z;
601 return par[0] + par[1] *
z;
619 return par[0] + par[1] *
z;
626 return par[0] + par[1] * z +
gTOBparam * (par[2] + par[4]);
630 return par[0] + par[1] * z -
gTIBparam * (par[2] - par[4]);
638 return par[0] + par[1] * z +
gTOBparam * (par[3] - par[4]);
642 return par[0] + par[1] * z -
gTIBparam * (par[3] + par[4]);
660 unsigned int &hitsAtTecPlus,
unsigned int &nFitParams,
661 vector<double> &hitPhi, vector<double> &hitPhiError, vector<double> &hitZprimeError,
662 double &zMin,
double &zMax,
double &bsAngleParam,
663 double &
offset,
double &offsetError,
double &
slope,
double &slopeError,
664 double &phiAtMinusParam,
double &phiAtPlusParam,
double &atThetaSplitParam)
666 TGraphErrors *lasData =
new TGraphErrors(
gHitZprime.size(),
668 &(hitZprimeError[0]), &(hitPhiError[0]));
673 tecPlus.SetParameter( 1, 0 );
674 tecPlus.SetParameter( nFitParams - 1, 0 );
675 lasData->Fit(
"tecPlus",
"R");
679 tecMinus.SetParameter( 1, 0 );
680 tecMinus.SetParameter( nFitParams - 1, 0 );
681 lasData->Fit(
"tecMinus",
"R");
685 at.SetParameter( 1, 0 );
686 at.SetParameter( nFitParams - 1, 0 );
687 lasData->Fit(
"at",
"R");
691 gMinuit->GetParameter(0, offset, offsetError);
692 gMinuit->GetParameter(1, slope, slopeError);
696 double bsAngleParamError(0.), phiAtMinusParamError(0.),
697 phiAtPlusParamError(0.), atThetaSplitParamError(0.);
700 gMinuit->GetParameter(2, phiAtMinusParam, phiAtMinusParamError);
701 gMinuit->GetParameter(3, phiAtPlusParam, phiAtPlusParamError);
702 gMinuit->GetParameter(4, atThetaSplitParam, atThetaSplitParamError);
710 gMinuit->GetParameter( nFitParams - 1 , bsAngleParam, bsAngleParamError);
718 vector<double> vec( covMatrix.num_col() * covMatrix.num_col() );
719 gMinuit->mnemat( &vec[0], covMatrix.num_col() );
720 for(
int col = 0; col < covMatrix.num_col(); col++){
721 for(
int row = 0; row < covMatrix.num_col(); row++){
722 covMatrix[col][row] = vec[row + covMatrix.num_col()*col];
734 double &
trackPhi,
double &trackPhiRef,
735 double &
offset,
double &
slope,
double &bsAngleParam,
736 double &phiAtMinusParam,
double &phiAtPlusParam,
737 double &atThetaSplitParam, vector<GlobalPoint> &globHit)
743 trackPhiRef = offset + slope * (gHitZprime[hit] + 1.0);
748 trackPhiRef = offset + slope * (
gHitZprime[hit] + 1.0)
756 trackPhiRef = offset + slope * (gHitZprime[hit] + 1.0);
761 trackPhiRef = offset + slope * (
gHitZprime[hit] + 1.0)
770 trackPhiRef = offset + slope * (gHitZprime[hit] + 1.0);
775 trackPhi = offset + slope *
gHitZprime[hit] +
gTOBparam * (phiAtMinusParam + atThetaSplitParam);
778 trackPhi = offset + slope *
gHitZprime[hit] -
gTIBparam * (phiAtMinusParam - atThetaSplitParam);
785 trackPhi = offset + slope *
gHitZprime[hit] +
gTOBparam * (phiAtPlusParam - atThetaSplitParam);
788 trackPhi = offset + slope *
gHitZprime[hit] -
gTIBparam * (phiAtPlusParam + atThetaSplitParam);
796 trackPhiRef = offset + slope * (
gHitZprime[hit] + 1.0)
805 unsigned int &
hit,
unsigned int &hitsAtTecPlus,
806 double &
trackPhi,
double &trackPhiRef,
807 vector<GlobalPoint> &globHit, vector<GlobalPoint> &globPtrack,
808 GlobalPoint &globPref, vector<double> &hitPhiError)
823 else if(hit >
gHitZprime.size() - hitsAtTecPlus - 1){
838 vector<const GeomDetUnit*> &gd, vector<GlobalPoint> &globPtrack,
839 vector<TrajectoryStateOnSurface> &tsosLas,
GlobalPoint &globPref)
846 trajectoryState =
GlobalVector(globPref-globPtrack[hit]);
850 trajectoryState =
GlobalVector(globPtrack[hit]-globPref);
856 trajectoryState =
GlobalVector(globPtrack[hit]-globPref);
860 trajectoryState =
GlobalVector(globPref-globPtrack[hit]);
864 trajectoryState =
GlobalVector(globPtrack[hit]-globPref);
876 unsigned int &hitsAtTecPlus,
unsigned int &nFitParams,
877 double &
offset,
double &
slope, vector<GlobalPoint> &globPtrack,
878 double &bsAngleParam,
double &chi2)
881 unsigned int paramType(0);
887 const unsigned int nPedeParams(nFitParams);
890 std::vector<TkFittedLasBeam::Scalar> params(nPedeParams);
901 derivatives[
hit][0] = 1.0;
906 derivatives[
hit][1] = globPtrack[
hit].z();
916 derivatives[
hit][1] = globPtrack[
hit].z();
928 derivatives[
hit][1] = globPtrack[
hit].z();
935 derivatives[
hit][1] = globPtrack[
hit].z();
950 unsigned int firstFixedParam(covMatrix.num_col());
955 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
const double par[8 *NPar][4]
void setParameters(unsigned int parametrisation, const std::vector< Scalar > ¶ms, const AlgebraicSymMatrix ¶mCovariance, const AlgebraicMatrix &derivatives, unsigned int firstFixedParam, float chi2)