42 edm::LogWarning(
"Alignment") <<
"[MuonMillepedeAlgorithm] constructed.";
71 edm::LogWarning(
"Alignment") <<
"[MuonMillepedeAlgorithm] Initializing...";
87 std::map<std::string, TMatrixD *>
map;
93 TFile file_it(name_f);
95 if(file_it.IsZombie())
98 TList *m_list = file_it.GetListOfKeys();
102 TKey *
index = (TKey *)m_list->First();
111 TMatrixD *mat = (TMatrixD *)index->ReadObj();
112 std::map<std::string, TMatrixD *>::iterator
node = map.find(
objectName);
113 if(node == map.end())
115 TMatrixD *n_mat =
new TMatrixD(mat->GetNrows(), mat->GetNcols());
119 index = (TKey*)m_list->After(index);
129 std::map<std::string, TMatrixD *>::iterator m_it = map.begin();
130 for(; m_it != map.end(); ++m_it)
132 if(m_it->first.find(
"_invCov") != std::string::npos)
134 std::string id_s = m_it->first.substr(0, m_it->first.find(
"_invCov"));
141 TMatrixD invMat( m_it->second->GetNrows(), m_it->second->GetNcols());
142 invMat = *(m_it->second);
145 TMatrixD weightMat( m_it->second->GetNcols(), 1);
146 weightMat = *(map[id_w]);
148 TMatrixD solution( m_it->second->GetNrows(), 1);
149 solution = invMat * weightMat;
154 invMat.Write(cov.c_str());
155 n.Write(id_n.c_str());
156 solution.Write(sol.c_str());
176 edm::LogWarning(
"Alignment") <<
"[MuonMillepedeAlgorithm] Terminating";
179 for(std::vector<Alignable*>::const_iterator
195 std::map<std::string, AlgebraicMatrix *>::iterator invCov_it =
map_invCov.begin();
196 std::map<std::string, AlgebraicMatrix *>::iterator weightRes_it =
map_weightRes.begin();
197 std::map<std::string, AlgebraicMatrix *>::iterator n_it =
map_N.begin();
198 for(; n_it !=
map_N.end(); ++invCov_it, ++weightRes_it, ++n_it)
200 TMatrixD tmat_invcov(0,0);
201 this->
toTMat(invCov_it->second, &tmat_invcov);
202 TMatrixD tmat_weightres(0,0);
203 this->
toTMat(weightRes_it->second, &tmat_weightres);
204 TMatrixD tmat_n(0,0);
205 this->
toTMat(n_it->second, &tmat_n);
207 tmat_invcov.Write(invCov_it->first.c_str());
208 tmat_weightres.Write(weightRes_it->first.c_str());
209 tmat_n.Write(n_it->first.c_str());
220 tmat_mat->ResizeTo(am_mat->num_row(), am_mat->num_col());
221 for(
int c_i = 0; c_i < am_mat->num_row(); ++c_i) {
222 for(
int c_j = 0; c_j < am_mat->num_col(); ++c_j) {
223 (*tmat_mat)(c_i, c_j) = (*am_mat)[c_i][c_j];
244 for( ConstTrajTrackPairCollection::const_iterator it=tracks.begin();
245 it!=tracks.end();it++) {
250 float pt = track->
pt();
257 if (0)
edm::LogInfo(
"Alignment") <<
"New track pt,eta,phi,chi2n,hits: " << pt <<
","<< eta <<
","<< phi <<
","<< chi2n <<
","<<nhit;
264 std::vector<const TransientTrackingRecHit*> hitvec;
265 std::vector<TrajectoryStateOnSurface> tsosvec;
267 std::vector<TrajectoryMeasurement> measurements = traj->
measurements();
270 for (std::vector<TrajectoryMeasurement>::iterator im=measurements.begin();
271 im!=measurements.end(); im++)
282 hitvec.push_back(hit);
283 tsosvec.push_back(tsos);
289 std::vector <AlignableDetOrUnitPtr> alidetvec =
296 std::vector<TrajectoryStateOnSurface>::const_iterator itsos=tsosvec.begin();
297 std::vector<const TransientTrackingRecHit*>::const_iterator ihit=hitvec.begin();
302 while (itsos != tsosvec.end())
305 const GeomDet* det=(*ihit)->det();
313 if ( ali!=0 && (*ihit)->geographicalId().subdetId() == 1)
317 if((*ihit)->dimension() == 4 || ((*ihit)->dimension() == 2 && m_Chamber.station() == 4))
337 int m_index[] = {2,3,0,1};
338 for(
int c_ei = 0; c_ei < 4; ++c_ei)
340 for(
int c_ej = 0; c_ej < 4; ++c_ej)
342 CovMat[m_index[c_ei]][m_index[c_ej]] = rawCovMat(c_ei+1,c_ej+1);
348 CovMat.invert(inv_check);
349 if (inv_check != 0) {
350 edm::LogError(
"Alignment") <<
"Covariance Matrix inversion failed";
360 if(m_Chamber.station() == 4)
363 residuals[0][0] = ihit4D[2]-alivec[3];
364 residuals[1][0] = 0.0;
365 residuals[2][0] = ihit4D[0]-alivec[1];
366 residuals[3][0] = 0.0;
368 CovMat[1][0] = 0.0; CovMat[1][1] = 0.0; CovMat[1][2] = 0.0;
369 CovMat[1][3] = 0.0; CovMat[0][1] = 0.0; CovMat[2][1] = 0.0;
370 CovMat[3][1] = 0.0; CovMat[3][0] = 0.0; CovMat[3][2] = 0.0;
371 CovMat[3][3] = 0.0; CovMat[0][3] = 0.0; CovMat[2][3] = 0.0;
376 residuals[0][0] = ihit4D[2]-alivec[3];
377 residuals[1][0] = ihit4D[3]-alivec[4];
378 residuals[2][0] = ihit4D[0]-alivec[1];
379 residuals[3][0] = ihit4D[1]-alivec[2];
385 std::vector<bool> mb4_mask;
388 mb4_mask.push_back(
true); mb4_mask.push_back(
false); mb4_mask.push_back(
true);
389 mb4_mask.push_back(
true); mb4_mask.push_back(
true); mb4_mask.push_back(
false);
390 selection.push_back(
true); selection.push_back(
true); selection.push_back(
false);
391 selection.push_back(
false); selection.push_back(
false); selection.push_back(
false);
393 if(m_Chamber.station() == 4)
395 for(
int icor = 0; icor < 6; ++icor)
397 if(mb4_mask[icor] && selection[icor]) nAlignParam++;
402 nAlignParam = derivsAux.num_row();
406 if(m_Chamber.station() == 4)
409 for(
int icor = 0; icor < 6; ++icor)
411 if(mb4_mask[icor] && selection[icor])
413 for(
int ccor = 0; ccor < 4; ++ccor)
415 derivs[der_c][ccor] = derivsAux[icor][ccor];
444 snprintf(name,
sizeof(name),
445 "Chamber_%d_%d_%d", m_Chamber.wheel(), m_Chamber.station(), m_Chamber.sector());
467 this->
updateInfo(invCov, weightRes, residuals, chamId);
506 std::map<std::string, AlgebraicMatrix *>::iterator
node =
map_invCov.find(id_invCov);
513 map_invCov.insert(make_pair(id_invCov, f_invCov));
515 map_N.insert(make_pair(id_n, f_n));
517 for(
int iCount = 0; iCount < 4; ++iCount)
520 snprintf(name,
sizeof(name),
"%s_var_%d",
id.c_str(), iCount);
526 TH1D *
histo =
fs->
make<TH1D>(idName.c_str(), idName.c_str(), 200, -range, range );
527 histoMap.insert(make_pair(idName, histo));
533 (*
map_N[id_n])[0][0]++;
535 for(
int iCount = 0; iCount < 4; ++iCount)
538 snprintf(name,
sizeof(name),
"%s_var_%d",
id.c_str(), iCount);
540 histoMap[idName]->Fill(m_res[iCount][0]);
T getParameter(std::string const &) const
std::map< std::string, AlgebraicMatrix * > map_weightRes
void terminate(const edm::EventSetup &setup)
Call at end of job.
AlignableNavigator * theAlignableDetAccessor
void run(const edm::EventSetup &setup, const EventInfo &eventInfo)
Run the algorithm.
ConstRecHitPointer const & recHit() const
AlignableDetOrUnitPtr alignableFromGeomDet(const GeomDet *geomDet)
Returns AlignableDetOrUnitPtr corresponding to given GeomDet.
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
double phi() const
azimuthal angle of momentum vector
T * make(const Args &...args) const
make new ROOT object
void applyParameters(void)
Obsolete: Use AlignableNavigator::alignableDetFromDetId and alignableFromAlignableDet.
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
const ConstTrajTrackPairCollection & trajTrackPairs_
Alignable * alignableFromAlignableDet(const AlignableDetOrUnitPtr &adet) const
Get relevant Alignable from AlignableDet.
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
edm::Service< TFileService > fs
void toTMat(AlgebraicMatrix *, TMatrixD *)
DataContainer const & measurements() const
double eta() const
pseudorapidity of momentum vector
CLHEP::HepMatrix AlgebraicMatrix
void setValid(bool v)
Set validity flag.
double pt() const
track transverse momentum
MuonMillepedeAlgorithm(const edm::ParameterSet &cfg)
Constructor.
DetId geographicalId() const
The label of this GeomDet.
void updateInfo(const AlgebraicMatrix &, const AlgebraicMatrix &, const AlgebraicMatrix &, std::string)
unsigned short numberOfValidHits() const
number of valid hits found
TrajectoryStateOnSurface const & forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
CLHEP::HepVector AlgebraicVector
void printM(const AlgebraicMatrix &)
ROOT::Math::SVector< double, 5 > AlgebraicVector5
std::string outputCollName
AlignmentParameterStore * theAlignmentParameterStore
CompositeAlignmentParameters selectParameters(const std::vector< AlignableDet * > &alignabledets) const
void initialize(const edm::EventSetup &setup, AlignableTracker *tracker, AlignableMuon *muon, AlignableExtras *extras, AlignmentParameterStore *store)
Call at beginning of job.
std::map< std::string, AlgebraicMatrix * > map_N
std::vector< AlignableDetOrUnitPtr > alignablesFromHits(const std::vector< const TransientTrackingRecHit * > &hitvec)
Returns vector AlignableDetOrUnitPtr for given vector of Hits.
std::map< std::string, TH1D * > histoMap
#define DEFINE_EDM_PLUGIN(factory, type, name)
DetId geographicalId() const
bool detAndSubdetInMap(const DetId &detid) const
Given a DetId, returns true if DetIds with this detector and subdetector id are in the map (not neces...
std::vector< Alignable * > theAlignables
Constructor of the full muon geometry.
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
const align::Alignables & alignables(void) const
get all alignables
std::vector< ConstTrajTrackPair > ConstTrajTrackPairCollection
std::map< std::string, AlgebraicMatrix * > map_invCov
define event information passed to algorithms
virtual AlgebraicMatrix selectedDerivatives(const TrajectoryStateOnSurface &tsos, const AlignableDetOrUnitPtr &alidet) const