CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
MuonMillepedeAlgorithm Class Reference

#include <MuonMillepedeAlgorithm.h>

Inheritance diagram for MuonMillepedeAlgorithm:
AlignmentAlgorithmBase

Public Member Functions

void collect ()
 
void initialize (const edm::EventSetup &setup, AlignableTracker *tracker, AlignableMuon *muon, AlignableExtras *extras, AlignmentParameterStore *store) override
 Call at beginning of job. More...
 
 MuonMillepedeAlgorithm (const edm::ParameterSet &cfg)
 Constructor. More...
 
void run (const edm::EventSetup &setup, const EventInfo &eventInfo) override
 Run the algorithm. More...
 
void terminate (const edm::EventSetup &setup) override
 Call at end of job. More...
 
void toTMat (AlgebraicMatrix *, TMatrixD *)
 
void updateInfo (const AlgebraicMatrix &, const AlgebraicMatrix &, const AlgebraicMatrix &, std::string)
 
 ~MuonMillepedeAlgorithm () override
 Destructor. More...
 
- Public Member Functions inherited from AlignmentAlgorithmBase
virtual bool addCalibrations (const Calibrations &)
 
 AlignmentAlgorithmBase (const edm::ParameterSet &)
 Constructor. More...
 
virtual void beginLuminosityBlock (const edm::EventSetup &setup)
 called at begin of luminosity block (no lumi block info passed yet) More...
 
virtual void beginRun (const edm::Run &, const edm::EventSetup &, bool changed)
 called at begin of run More...
 
virtual void endLuminosityBlock (const edm::EventSetup &setup)
 called at end of luminosity block (no lumi block info passed yet) More...
 
virtual void endRun (const EndRunInfo &runInfo, const edm::EventSetup &setup)
 called at end of run - order of arguments like in EDProducer etc. More...
 
virtual bool processesEvents ()
 Returns whether algorithm proccesses events in current configuration. More...
 
virtual bool setParametersForRunRange (const RunRange &rr)
 
virtual void startNewLoop ()
 
virtual bool storeAlignments ()
 Returns whether algorithm produced results to be stored. More...
 
virtual bool supportsCalibrations ()
 
virtual void terminate ()
 Called at end of job (must be implemented in derived class) More...
 
virtual ~AlignmentAlgorithmBase ()
 Destructor. More...
 

Private Member Functions

void printM (const AlgebraicMatrix &)
 

Private Attributes

double chi2nCut
 
std::string collec_f
 
int collec_number
 
std::string collec_path
 
edm::Service< TFileServicefs
 
std::map< std::string, TH1D * > histoMap
 
bool isCollectionJob
 
std::map< std::string, AlgebraicMatrix * > map_invCov
 
std::map< std::string, AlgebraicMatrix * > map_N
 
std::map< std::string, AlgebraicMatrix * > map_weightRes
 
std::string outputCollName
 
double ptCut
 
AlignableNavigatortheAlignableDetAccessor
 
std::vector< Alignable * > theAlignables
 
AlignmentParameterStoretheAlignmentParameterStore
 
bool verbose
 

Additional Inherited Members

- Public Types inherited from AlignmentAlgorithmBase
typedef std::pair< const Trajectory *, const reco::Track * > ConstTrajTrackPair
 
typedef std::vector< ConstTrajTrackPairConstTrajTrackPairCollection
 
using RunNumber = align::RunNumber
 
using RunRange = align::RunRange
 

Detailed Description

Definition at line 20 of file MuonMillepedeAlgorithm.h.

Constructor & Destructor Documentation

MuonMillepedeAlgorithm::MuonMillepedeAlgorithm ( const edm::ParameterSet cfg)

Constructor.

Definition at line 36 of file MuonMillepedeAlgorithm.cc.

References chi2nCut, collec_f, collec_number, collec_path, edm::ParameterSet::getParameter(), isCollectionJob, outputCollName, ptCut, and AlCaHLTBitMon_QueryRunRegistry::string.

36  :
38  {
39 
40  // parse parameters
41 
42  edm::LogWarning("Alignment") << "[MuonMillepedeAlgorithm] constructed.";
43 
44 
45  collec_f = cfg.getParameter<std::string>( "CollectionFile" );
46 
47  isCollectionJob = cfg.getParameter<bool>( "isCollectionJob" );
48 
49  collec_path = cfg.getParameter<std::string>( "collectionPath" );
50 
51  collec_number = cfg.getParameter<int>( "collectionNumber" );
52 
53  outputCollName = cfg.getParameter<std::string>( "outputCollName" );
54 
55  ptCut = cfg.getParameter<double>( "ptCut" );
56 
57  chi2nCut = cfg.getParameter<double>( "chi2nCut" );
58 
59 
60  }
T getParameter(std::string const &) const
AlignmentAlgorithmBase(const edm::ParameterSet &)
Constructor.
MuonMillepedeAlgorithm::~MuonMillepedeAlgorithm ( )
inlineoverride

Member Function Documentation

void MuonMillepedeAlgorithm::collect ( )

Definition at line 84 of file MuonMillepedeAlgorithm.cc.

References collec_f, collec_number, collec_path, diffTreeTool::index, genParticles_cff::map, gen::n, summarizeEdmComparisonLogfiles::objectName, outputCollName, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by terminate(), and ~MuonMillepedeAlgorithm().

85  {
86 
87  std::map<std::string, TMatrixD *> map;
88 
89  for(int c_job = 0; c_job < collec_number; ++c_job)
90  {
91  char name_f[40];
92  snprintf(name_f, sizeof(name_f), "%s_%d/%s", collec_path.c_str(), c_job, collec_f.c_str());
93  TFile file_it(name_f);
94 
95  if(file_it.IsZombie())
96  continue;
97 
98  TList *m_list = file_it.GetListOfKeys();
99  if(m_list == nullptr) {
100  return;
101  }
102  TKey *index = (TKey *)m_list->First();
103  if(index == nullptr) {
104  }
105  if( index != nullptr )
106  {
107  do
108  {
109 
110  std::string objectName(index->GetName());
111  TMatrixD *mat = (TMatrixD *)index->ReadObj();
112  std::map<std::string, TMatrixD *>::iterator node = map.find(objectName);
113  if(node == map.end())
114  {
115  TMatrixD *n_mat = new TMatrixD(mat->GetNrows(), mat->GetNcols());
116  map.insert(make_pair(objectName, n_mat));
117  }
118  *(map[objectName]) += *mat;
119  index = (TKey*)m_list->After(index);
120  } while(index != nullptr);
121  }
122  file_it.Close();
123  }
124 
125 
126  TFile theFile2(outputCollName.c_str(), "recreate");
127  theFile2.cd();
128 
129  std::map<std::string, TMatrixD *>::iterator m_it = map.begin();
130  for(; m_it != map.end(); ++m_it)
131  {
132  if(m_it->first.find("_invCov") != std::string::npos)
133  {
134  std::string id_s = m_it->first.substr(0, m_it->first.find("_invCov"));
135  std::string id_w = id_s + "_weightRes";
136  std::string id_n = id_s + "_N";
137  std::string cov = id_s + "_cov";
138  std::string sol = id_s + "_sol";
139 
140  //Covariance calculation
141  TMatrixD invMat( m_it->second->GetNrows(), m_it->second->GetNcols());
142  invMat = *(m_it->second);
143  invMat.Invert();
144  //weighted residuals
145  TMatrixD weightMat( m_it->second->GetNcols(), 1);
146  weightMat = *(map[id_w]);
147  //Solution of the linear system
148  TMatrixD solution( m_it->second->GetNrows(), 1);
149  solution = invMat * weightMat;
150  //Number of Tracks
151  TMatrixD n(1,1);
152  n = *(map[id_n]);
153 
154  invMat.Write(cov.c_str());
155  n.Write(id_n.c_str());
156  solution.Write(sol.c_str());
157  }
158  }
159  theFile2.Write();
160  theFile2.Close();
161  }
void MuonMillepedeAlgorithm::initialize ( const edm::EventSetup setup,
AlignableTracker tracker,
AlignableMuon muon,
AlignableExtras extras,
AlignmentParameterStore store 
)
overridevirtual

Call at beginning of job.

Implements AlignmentAlgorithmBase.

Definition at line 65 of file MuonMillepedeAlgorithm.cc.

References AlignmentParameterStore::alignables(), theAlignableDetAccessor, theAlignables, and theAlignmentParameterStore.

Referenced by ~MuonMillepedeAlgorithm().

69  {
70 
71  edm::LogWarning("Alignment") << "[MuonMillepedeAlgorithm] Initializing...";
72 
73  // accessor Det->AlignableDet
74  theAlignableDetAccessor = new AlignableNavigator(tracker, muon);
75 
76  // set alignmentParameterStore
78 
79  // get alignables
81 
82  }
AlignableNavigator * theAlignableDetAccessor
AlignmentParameterStore * theAlignmentParameterStore
std::vector< Alignable * > theAlignables
const align::Alignables & alignables(void) const
get all alignables
void MuonMillepedeAlgorithm::printM ( const AlgebraicMatrix m)
private

Definition at line 484 of file MuonMillepedeAlgorithm.cc.

Referenced by ~MuonMillepedeAlgorithm().

485  {
486  //for(int i = 0; i < m.num_row(); ++i)
487  // {
488  // for(int j = 0; j < m.num_col(); ++j)
489  // {
490  // std::cout << m[i][j] << " ";
491  // }
492  // std::cout << std::endl;
493  //}
494  }
void MuonMillepedeAlgorithm::run ( const edm::EventSetup setup,
const EventInfo eventInfo 
)
overridevirtual

Run the algorithm.

Implements AlignmentAlgorithmBase.

Definition at line 232 of file MuonMillepedeAlgorithm.cc.

References CompositeAlignmentParameters::alignableFromAlignableDet(), AlignableNavigator::alignableFromGeomDet(), AlignableNavigator::alignablesFromHits(), Alignable::alignmentParameters(), chi2n, chi2nCut, AlignableNavigator::detAndSubdetInMap(), PVValHelper::eta, reco::TrackBase::eta(), TrajectoryMeasurement::forwardPredictedState(), GeomDet::geographicalId(), TrackingRecHit::geographicalId(), isCollectionJob, TrajectoryStateOnSurface::isValid(), TrackingRecHit::isValid(), LogDebug, Trajectory::measurements(), dataset::name, reco::TrackBase::normalizedChi2(), reco::TrackBase::numberOfValidHits(), phi, reco::TrackBase::phi(), EnergyCorrector::pt, reco::TrackBase::pt(), ptCut, TrajectoryMeasurement::recHit(), AlignmentParameters::selectedDerivatives(), corrVsCorr::selection, AlignmentParameterStore::selectParameters(), AlCaHLTBitMon_QueryRunRegistry::string, theAlignableDetAccessor, theAlignmentParameterStore, HiIsolationCommonParameters_cff::track, l1t::tracks, AlignmentAlgorithmBase::EventInfo::trajTrackPairs(), and updateInfo().

Referenced by Types.EventID::cppID(), Types.LuminosityBlockID::cppID(), o2olib.O2OTool::execute(), and ~MuonMillepedeAlgorithm().

233  {
234 
235  if( isCollectionJob )
236  {
237  return;
238  }
239 
240 
241  // loop over tracks
242  //int t_counter = 0;
244  for( ConstTrajTrackPairCollection::const_iterator it=tracks.begin();
245  it!=tracks.end();it++) {
246 
247  const Trajectory* traj = (*it).first;
248  const reco::Track* track = (*it).second;
249 
250  float pt = track->pt();
251  float chi2n = track->normalizedChi2();
252 #ifdef EDM_ML_DEBUG
253  float eta = track->eta();
254  float phi = track->phi();
255  //int ndof = track->ndof();
256  int nhit = track->numberOfValidHits();
257 
258  LogDebug("Alignment")
259  << "New track pt,eta,phi,chi2n,hits: "
260  << pt << "," << eta << "," << phi << "," << chi2n << "," << nhit;
261 #endif
262 
263  //Accept or not accept the track
264  if( pt > ptCut && chi2n < chi2nCut )
265  {
266 
267 
268  std::vector<const TransientTrackingRecHit*> hitvec;
269  std::vector<TrajectoryStateOnSurface> tsosvec;
270 
271  std::vector<TrajectoryMeasurement> measurements = traj->measurements();
272 
273  //In this loop the measurements and hits are extracted and put on two vectors
274  for (std::vector<TrajectoryMeasurement>::iterator im=measurements.begin();
275  im!=measurements.end(); im++)
276  {
277  TrajectoryMeasurement meas = *im;
278  const TransientTrackingRecHit* hit = &(*meas.recHit());
279  //We are not very strict at this point
281  {
282  //***Forward
283  const TrajectoryStateOnSurface& tsos = meas.forwardPredictedState();
284  if (tsos.isValid())
285  {
286  hitvec.push_back(hit);
287  tsosvec.push_back(tsos);
288  }
289  }
290  }
291 
292  // transform RecHit vector to AlignableDet vector
293  std::vector <AlignableDetOrUnitPtr> alidetvec =
295 
296  // get concatenated alignment parameters for list of alignables
299 
300  std::vector<TrajectoryStateOnSurface>::const_iterator itsos=tsosvec.begin();
301  std::vector<const TransientTrackingRecHit*>::const_iterator ihit=hitvec.begin();
302 
303 
304  //int ch_counter = 0;
305 
306  while (itsos != tsosvec.end())
307  {
308  // get AlignableDet for this hit
309  const GeomDet* det=(*ihit)->det();
310  AlignableDetOrUnitPtr alidet =
312 
313  // get relevant Alignable
314  Alignable* ali=aap.alignableFromAlignableDet(alidet);
315 
316  //To be sure that the ali is not null and that it's a DT segment
317  if ( ali!=nullptr && (*ihit)->geographicalId().subdetId() == 1)
318  {
319  DTChamberId m_Chamber(det->geographicalId());
320  //Station 4 does not contain Theta SL
321  if((*ihit)->dimension() == 4 || ((*ihit)->dimension() == 2 && m_Chamber.station() == 4))
322  //if((*ihit)->dimension() == 4)
323  {
324  edm::LogInfo("Alignment") << "Entrando";
325 
326  AlignmentParameters* params = ali->alignmentParameters();
327 
328  edm::LogInfo("Alignment") << "Entrando";
329  //(dx/dz,dy/dz,x,y) for a 4DSegment
330  AlgebraicVector ihit4D = (*ihit)->parameters();
331 
332  //The innerMostState always contains the Z
333  //(q/pt,dx/dz,dy/dz,x,y)
334  AlgebraicVector5 alivec = (*itsos).localParameters().mixedFormatVector();
335 
336  //The covariance matrix follows the sequence
337  //(q/pt,dx/dz,dy/dz,x,y) but we reorder to
338  //(x,y,dx/dz,dy/dz)
339  AlgebraicSymMatrix55 rawCovMat = (*itsos).localError().matrix();
340  AlgebraicMatrix CovMat(4,4);
341  int m_index[] = {2,3,0,1};
342  for(int c_ei = 0; c_ei < 4; ++c_ei)
343  {
344  for(int c_ej = 0; c_ej < 4; ++c_ej)
345  {
346  CovMat[m_index[c_ei]][m_index[c_ej]] = rawCovMat(c_ei+1,c_ej+1);
347  }
348  }
349 
350  int inv_check;
351  //printM(CovMat);
352  CovMat.invert(inv_check);
353  if (inv_check != 0) {
354  edm::LogError("Alignment") << "Covariance Matrix inversion failed";
355  return;
356  }
357 
358 
359 
360  //The order is changed to:
361  // (x,0,dx/dz,0) MB4 Chamber
362  // (x,y,dx/dz,dy/dz) Not MB4 Chamber
363  AlgebraicMatrix residuals(4,1);
364  if(m_Chamber.station() == 4)
365  {
366  //Filling Residuals
367  residuals[0][0] = ihit4D[2]-alivec[3];
368  residuals[1][0] = 0.0;
369  residuals[2][0] = ihit4D[0]-alivec[1];
370  residuals[3][0] = 0.0;
371  //The error in the Theta coord is set to infinite
372  CovMat[1][0] = 0.0; CovMat[1][1] = 0.0; CovMat[1][2] = 0.0;
373  CovMat[1][3] = 0.0; CovMat[0][1] = 0.0; CovMat[2][1] = 0.0;
374  CovMat[3][1] = 0.0; CovMat[3][0] = 0.0; CovMat[3][2] = 0.0;
375  CovMat[3][3] = 0.0; CovMat[0][3] = 0.0; CovMat[2][3] = 0.0;
376  }
377  else
378  {
379  //Filling Residuals
380  residuals[0][0] = ihit4D[2]-alivec[3];
381  residuals[1][0] = ihit4D[3]-alivec[4];
382  residuals[2][0] = ihit4D[0]-alivec[1];
383  residuals[3][0] = ihit4D[1]-alivec[2];
384  }
385 
386  // Derivatives
387  AlgebraicMatrix derivsAux = params->selectedDerivatives(*itsos,alidet);
388 
389  std::vector<bool> mb4_mask;
390  std::vector<bool> selection;
391  //To be checked
392  mb4_mask.push_back(true); mb4_mask.push_back(false); mb4_mask.push_back(true);
393  mb4_mask.push_back(true); mb4_mask.push_back(true); mb4_mask.push_back(false);
394  selection.push_back(true); selection.push_back(true); selection.push_back(false);
395  selection.push_back(false); selection.push_back(false); selection.push_back(false);
396  int nAlignParam = 0;
397  if(m_Chamber.station() == 4)
398  {
399  for(int icor = 0; icor < 6; ++icor)
400  {
401  if(mb4_mask[icor] && selection[icor]) nAlignParam++;
402  }
403  }
404  else
405  {
406  nAlignParam = derivsAux.num_row();
407  }
408 
409  AlgebraicMatrix derivs(nAlignParam, 4);
410  if(m_Chamber.station() == 4)
411  {
412  int der_c = 0;
413  for(int icor = 0; icor < 6; ++icor)
414  {
415  if(mb4_mask[icor] && selection[icor])
416  {
417  for(int ccor = 0; ccor < 4; ++ccor)
418  {
419  derivs[der_c][ccor] = derivsAux[icor][ccor];
420  ++der_c;
421  }
422  }
423  }
424  }
425  else
426  {
427  derivs = derivsAux;
428  }
429 
430 
431  //for(int co = 0; co < derivs.num_row(); ++co)
432  //{
433  // for(int ci = 0; ci < derivs.num_col(); ++ci)
434  // {
435  // edm::LogInfo("Alignment") << "Derivatives: " << co << " " << ci << " " << derivs[co][ci] << " ";
436  // }
437  //}
438 
439  AlgebraicMatrix derivsT = derivs.T();
440  AlgebraicMatrix invCov = derivs*CovMat*derivsT;
441  AlgebraicMatrix weightRes = derivs*CovMat*residuals;
442 
443  //this->printM(derivs);
444  //this->printM(CovMat);
445  //this->printM(residuals);
446 
447  char name[40];
448  snprintf(name, sizeof(name),
449  "Chamber_%d_%d_%d", m_Chamber.wheel(), m_Chamber.station(), m_Chamber.sector());
450  std::string chamId(name);
451  //MB4 need a special treatment
452  /*AlgebraicMatrix invCovMB4(2,2);
453  AlgebraicMatrix weightResMB4(2,1);
454  if( m_Chamber.station() == 4 )
455  {
456  int m_index_2[] = {0,2};
457  for(int c_i = 0; c_i < 2; ++c_i)
458  {
459  weightResMB4[c_i][0] = weightRes[m_index_2[c_i]][0];
460  for(int c_j = 0; c_j < 2; ++c_j)
461  {
462  invCovMB4[c_i][c_j] = invCov[m_index_2[c_i]][m_index_2[c_j]];
463  }
464  }
465  this->updateInfo(invCovMB4, weightResMB4, residuals, chamId);
466  }
467  else
468  {
469  this->updateInfo(invCov, weightRes, residuals, chamId);
470  }*/
471  this->updateInfo(invCov, weightRes, residuals, chamId);
472  }
473  }
474  itsos++;
475  ihit++;
476  }
477  }
478  } // end of track loop
479 
480  }
#define LogDebug(id)
AlignableNavigator * theAlignableDetAccessor
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)
Definition: TrackBase.h:561
selection
main part
Definition: corrVsCorr.py:98
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:645
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
Alignable * alignableFromAlignableDet(const AlignableDetOrUnitPtr &adet) const
Get relevant Alignable from AlignableDet.
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:61
const ConstTrajTrackPairCollection & trajTrackPairs() const
DataContainer const & measurements() const
Definition: Trajectory.h:196
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:651
CLHEP::HepMatrix AlgebraicMatrix
double pt() const
track transverse momentum
Definition: TrackBase.h:621
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:79
void updateInfo(const AlgebraicMatrix &, const AlgebraicMatrix &, const AlgebraicMatrix &, std::string)
unsigned short numberOfValidHits() const
number of valid hits found
Definition: TrackBase.h:820
TrajectoryStateOnSurface const & forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
CLHEP::HepVector AlgebraicVector
ROOT::Math::SVector< double, 5 > AlgebraicVector5
AlignmentParameterStore * theAlignmentParameterStore
CompositeAlignmentParameters selectParameters(const std::vector< AlignableDet * > &alignabledets) const
bool isValid() const
std::vector< AlignableDetOrUnitPtr > alignablesFromHits(const std::vector< const TransientTrackingRecHit * > &hitvec)
Returns vector AlignableDetOrUnitPtr for given vector of Hits.
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< ConstTrajTrackPair > ConstTrajTrackPairCollection
virtual AlgebraicMatrix selectedDerivatives(const TrajectoryStateOnSurface &tsos, const AlignableDetOrUnitPtr &alidet) const
void MuonMillepedeAlgorithm::terminate ( const edm::EventSetup setup)
overridevirtual

Call at end of job.

Implements AlignmentAlgorithmBase.

Definition at line 166 of file MuonMillepedeAlgorithm.cc.

References Alignable::alignmentParameters(), AlignmentParameterStore::applyParameters(), collec_f, collect(), isCollectionJob, map_invCov, map_N, map_weightRes, AlignmentParameters::setValid(), theAlignables, theAlignmentParameterStore, interactiveExample::theFile, and toTMat().

167  {
168 
169  if( isCollectionJob )
170  {
171  this->collect();
172  return;
173  }
174 
175 
176  edm::LogWarning("Alignment") << "[MuonMillepedeAlgorithm] Terminating";
177 
178  // iterate over alignment parameters
179  for(std::vector<Alignable*>::const_iterator
180  it=theAlignables.begin(); it!=theAlignables.end(); it++) {
181  Alignable* ali=(*it);
182  // Alignment parameters
183  // AlignmentParameters* par = ali->alignmentParameters();
184  edm::LogInfo("Alignment") << "now apply params";
186  // set these parameters 'valid'
187  ali->alignmentParameters()->setValid(true);
188 
189  }
190 
191  edm::LogWarning("Alignment") << "[MuonMillepedeAlgorithm] Writing aligned parameters to file: " << theAlignables.size();
192 
193  TFile *theFile = new TFile(collec_f.c_str(), "recreate");
194  theFile->cd();
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)
199  {
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);
206 
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());
210  }
211 
212  theFile->Write();
213  theFile->Close();
214 
215  }
std::map< std::string, AlgebraicMatrix * > map_weightRes
void applyParameters(void)
Obsolete: Use AlignableNavigator::alignableDetFromDetId and alignableFromAlignableDet.
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:61
void toTMat(AlgebraicMatrix *, TMatrixD *)
void setValid(bool v)
Set validity flag.
AlignmentParameterStore * theAlignmentParameterStore
std::map< std::string, AlgebraicMatrix * > map_N
std::vector< Alignable * > theAlignables
std::map< std::string, AlgebraicMatrix * > map_invCov
void MuonMillepedeAlgorithm::toTMat ( AlgebraicMatrix am_mat,
TMatrixD *  tmat_mat 
)

Definition at line 218 of file MuonMillepedeAlgorithm.cc.

Referenced by terminate(), and ~MuonMillepedeAlgorithm().

219  {
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];
224  }
225  }
226  }
void MuonMillepedeAlgorithm::updateInfo ( const AlgebraicMatrix m_invCov,
const AlgebraicMatrix m_weightRes,
const AlgebraicMatrix m_res,
std::string  id 
)

Definition at line 496 of file MuonMillepedeAlgorithm.cc.

References DEFINE_EDM_PLUGIN, fs, trackerHits::histo, histoMap, trivialCutFlow_cff::idName, TFileService::make(), map_invCov, map_N, map_weightRes, dataset::name, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by run(), and ~MuonMillepedeAlgorithm().

500  {
501 
502 
503 
504  std::string id_invCov = id + "_invCov";
505  std::string id_weightRes = id + "_weightRes";
506  std::string id_n = id + "_N";
507 
508  edm::LogInfo("Alignment") << "Entrando";
509 
510  std::map<std::string, AlgebraicMatrix *>::iterator node = map_invCov.find(id_invCov);
511  if(node == map_invCov.end())
512  {
513  AlgebraicMatrix *f_invCov = new AlgebraicMatrix(m_invCov.num_row(), m_invCov.num_col());
514  AlgebraicMatrix *f_weightRes = new AlgebraicMatrix(m_weightRes.num_row(), m_weightRes.num_col());
515  AlgebraicMatrix *f_n = new AlgebraicMatrix(1,1);
516 
517  map_invCov.insert(make_pair(id_invCov, f_invCov));
518  map_weightRes.insert(make_pair(id_weightRes, f_weightRes));
519  map_N.insert(make_pair(id_n, f_n));
520 
521  for(int iCount = 0; iCount < 4; ++iCount)
522  {
523  char name[40];
524  snprintf(name, sizeof(name), "%s_var_%d", id.c_str(), iCount);
525  std::string idName(name);
526  float range = 5.0;
527  //if( iCount == 0 || iCount == 1 ) {
528  // range = 0.01;
529  //}
530  TH1D *histo = fs->make<TH1D>(idName.c_str(), idName.c_str(), 200, -range, range );
531  histoMap.insert(make_pair(idName, histo));
532  }
533  }
534 
535  *map_invCov[id_invCov] = *map_invCov[id_invCov] + m_invCov;
536  *map_weightRes[id_weightRes] = *map_weightRes[id_weightRes] + m_weightRes;
537  (*map_N[id_n])[0][0]++;
538 
539  for(int iCount = 0; iCount < 4; ++iCount)
540  {
541  char name[40];
542  snprintf(name, sizeof(name), "%s_var_%d", id.c_str(), iCount);
543  std::string idName(name);
544  histoMap[idName]->Fill(m_res[iCount][0]);
545  }
546  }
std::map< std::string, AlgebraicMatrix * > map_weightRes
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
edm::Service< TFileService > fs
CLHEP::HepMatrix AlgebraicMatrix
std::map< std::string, AlgebraicMatrix * > map_N
std::map< std::string, TH1D * > histoMap
std::map< std::string, AlgebraicMatrix * > map_invCov

Member Data Documentation

double MuonMillepedeAlgorithm::chi2nCut
private

Definition at line 71 of file MuonMillepedeAlgorithm.h.

Referenced by MuonMillepedeAlgorithm(), and run().

std::string MuonMillepedeAlgorithm::collec_f
private

Definition at line 78 of file MuonMillepedeAlgorithm.h.

Referenced by collect(), MuonMillepedeAlgorithm(), and terminate().

int MuonMillepedeAlgorithm::collec_number
private

Definition at line 82 of file MuonMillepedeAlgorithm.h.

Referenced by collect(), and MuonMillepedeAlgorithm().

std::string MuonMillepedeAlgorithm::collec_path
private

Definition at line 81 of file MuonMillepedeAlgorithm.h.

Referenced by collect(), and MuonMillepedeAlgorithm().

edm::Service<TFileService> MuonMillepedeAlgorithm::fs
private

Definition at line 75 of file MuonMillepedeAlgorithm.h.

Referenced by updateInfo().

std::map<std::string, TH1D *> MuonMillepedeAlgorithm::histoMap
private

Definition at line 65 of file MuonMillepedeAlgorithm.h.

Referenced by updateInfo().

bool MuonMillepedeAlgorithm::isCollectionJob
private

Definition at line 80 of file MuonMillepedeAlgorithm.h.

Referenced by MuonMillepedeAlgorithm(), run(), and terminate().

std::map<std::string, AlgebraicMatrix *> MuonMillepedeAlgorithm::map_invCov
private

Definition at line 67 of file MuonMillepedeAlgorithm.h.

Referenced by terminate(), and updateInfo().

std::map<std::string, AlgebraicMatrix *> MuonMillepedeAlgorithm::map_N
private

Definition at line 69 of file MuonMillepedeAlgorithm.h.

Referenced by terminate(), and updateInfo().

std::map<std::string, AlgebraicMatrix *> MuonMillepedeAlgorithm::map_weightRes
private

Definition at line 68 of file MuonMillepedeAlgorithm.h.

Referenced by terminate(), and updateInfo().

std::string MuonMillepedeAlgorithm::outputCollName
private

Definition at line 79 of file MuonMillepedeAlgorithm.h.

Referenced by collect(), and MuonMillepedeAlgorithm().

double MuonMillepedeAlgorithm::ptCut
private

Definition at line 71 of file MuonMillepedeAlgorithm.h.

Referenced by MuonMillepedeAlgorithm(), and run().

AlignableNavigator* MuonMillepedeAlgorithm::theAlignableDetAccessor
private

Definition at line 59 of file MuonMillepedeAlgorithm.h.

Referenced by initialize(), and run().

std::vector<Alignable*> MuonMillepedeAlgorithm::theAlignables
private

Definition at line 58 of file MuonMillepedeAlgorithm.h.

Referenced by initialize(), and terminate().

AlignmentParameterStore* MuonMillepedeAlgorithm::theAlignmentParameterStore
private

Definition at line 57 of file MuonMillepedeAlgorithm.h.

Referenced by initialize(), run(), and terminate().

bool MuonMillepedeAlgorithm::verbose
private