Skip to content

Commit

Permalink
MCH standalone alignment module (AliceO2Group#12583)
Browse files Browse the repository at this point in the history
* MCH standalone alignment module

with a common part(for both MCH and MTF) of mathematics basic codes moved to a common path under O2/Detectors/ForwardAlign

Co-Authored-By: javierecc <javier.castillo.castellanos@cern.ch>

* Please consider the following formatting changes (#4)

* Removed from PR

* Fixing formatting issue

* Add missing header for filesystem

* Fix warning with dereferenced iterator

* Remove re-initialisation of magfield for trackfitter and move residual QA plots to O2Physics task

* Update comment for track selection

* Remove unused function

* Remove re-definition of magfield which is set already with CCDB finalisation

* Fixing CI build errors

---------

Co-authored-by: javierecc <javier.castillo.castellanos@cern.ch>
Co-authored-by: ALICE Builder <alibuild@users.noreply.github.com>
  • Loading branch information
3 people authored and andreasmolander committed Apr 12, 2024
1 parent 394da04 commit d14a7c6
Show file tree
Hide file tree
Showing 41 changed files with 3,645 additions and 187 deletions.
2 changes: 2 additions & 0 deletions Detectors/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ add_subdirectory(Calibration)
add_subdirectory(DCS)

add_subdirectory(Align)
add_subdirectory(ForwardAlign)


if(BUILD_SIMULATION)
add_subdirectory(gconfig)
Expand Down
40 changes: 40 additions & 0 deletions Detectors/ForwardAlign/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2019-2020 CERN and copyright holders of ALICE O2.
# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
# All rights not expressly granted are reserved.
#
# This software is distributed under the terms of the GNU General Public
# License v3 (GPL Version 3), copied verbatim in the file "COPYING".
#
# In applying this license CERN does not waive the privileges and immunities
# granted to it by virtue of its status as an Intergovernmental Organization
# or submit itself to any jurisdiction.

o2_add_library(ForwardAlign
SOURCES src/MatrixSparse.cxx
src/MatrixSq.cxx
src/MillePede2.cxx
src/MillePedeRecord.cxx
src/MilleRecordReader.cxx
src/MilleRecordWriter.cxx
src/MinResSolve.cxx
src/RectMatrix.cxx
src/SymBDMatrix.cxx
src/SymMatrix.cxx
src/VectorSparse.cxx
PUBLIC_LINK_LIBRARIES O2::CCDB
O2::Steer
ROOT::TreePlayer)

o2_target_root_dictionary(ForwardAlign
HEADERS include/ForwardAlign/MatrixSparse.h
include/ForwardAlign/MatrixSq.h
include/ForwardAlign/MillePede2.h
include/ForwardAlign/MillePedeRecord.h
include/ForwardAlign/MilleRecordReader.h
include/ForwardAlign/MilleRecordWriter.h
include/ForwardAlign/MinResSolve.h
include/ForwardAlign/RectMatrix.h
include/ForwardAlign/SymBDMatrix.h
include/ForwardAlign/SymMatrix.h
include/ForwardAlign/VectorSparse.h
LINKDEF src/ForwardAlignLinkDef.h)
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
/// \brief Sparse matrix class (from AliROOT), used as a global matrix for MillePede2
/// \author ruben.shahoyan@cern.ch

#ifndef ALICEO2_MFT_MATRIXSPARSE_H
#define ALICEO2_MFT_MATRIXSPARSE_H
#ifndef ALICEO2_FWDALIGN_MATRIXSPARSE_H
#define ALICEO2_FWDALIGN_MATRIXSPARSE_H

#include "MFTAlignment/MatrixSq.h"
#include "MFTAlignment/VectorSparse.h"
#include "ForwardAlign/MatrixSq.h"
#include "ForwardAlign/VectorSparse.h"

namespace o2
{
namespace mft
namespace fwdalign
{

/// \class MatrixSparse
Expand Down Expand Up @@ -157,7 +157,7 @@ inline Double_t& MatrixSparse::DiagElem(Int_t row)
}
}

} // namespace mft
} // namespace fwdalign
} // namespace o2

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
/// \brief Abstract class (from AliROOT) for square matrix used for millepede2 operation
/// \author ruben.shahoyan@cern.ch

#ifndef ALICEO2_MFT_MATRIXSQ_H
#define ALICEO2_MFT_MATRIXSQ_H
#ifndef ALICEO2_FWDALIGN_MATRIXSQ_H
#define ALICEO2_FWDALIGN_MATRIXSQ_H

#include <TMatrixDBase.h>
#include <TVectorD.h>

namespace o2
{
namespace mft
namespace fwdalign
{

/// \class MatrixSq
Expand Down Expand Up @@ -153,7 +153,7 @@ inline void MatrixSq::MultiplyByVec(const TVectorD& vecIn, TVectorD& vecOut) con
MultiplyByVec(vecIn.GetMatrixArray(), vecOut.GetMatrixArray());
}

} // namespace mft
} // namespace fwdalign
} // namespace o2

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@
/// Based on the original milliped2 by Volker Blobel
/// http://www.desy.de/~blobel/mptalks.html

#ifndef ALICEO2_MFT_MILLEPEDE2_H
#define ALICEO2_MFT_MILLEPEDE2_H
#ifndef ALICEO2_FWDALIGN_MILLEPEDE2_H
#define ALICEO2_FWDALIGN_MILLEPEDE2_H

#include <vector>
#include <TString.h>
#include <TTree.h>
#include "MFTAlignment/MinResSolve.h"
#include "MFTAlignment/MillePedeRecord.h"
#include "MFTAlignment/SymMatrix.h"
#include "MFTAlignment/RectMatrix.h"
#include "MFTAlignment/MatrixSparse.h"
#include "MFTAlignment/MatrixSq.h"
#include "MFTAlignment/MilleRecordWriter.h"
#include "MFTAlignment/MilleRecordReader.h"
#include "ForwardAlign/MinResSolve.h"
#include "ForwardAlign/MillePedeRecord.h"
#include "ForwardAlign/SymMatrix.h"
#include "ForwardAlign/RectMatrix.h"
#include "ForwardAlign/MatrixSparse.h"
#include "ForwardAlign/MatrixSq.h"
#include "ForwardAlign/MilleRecordWriter.h"
#include "ForwardAlign/MilleRecordReader.h"

class TFile;
class TStopwatch;
Expand All @@ -38,7 +38,7 @@ class TArrayF;

namespace o2
{
namespace mft
namespace fwdalign
{

class MillePede2
Expand Down Expand Up @@ -256,17 +256,17 @@ class MillePede2
/// \brief write tree and close file where are stored chi2 from LocalFit()
void EndChi2Storage();

o2::mft::MillePedeRecord* GetRecord() const { return fRecord; }
o2::fwdalign::MillePedeRecord* GetRecord() const { return fRecord; }
long GetSelFirst() const { return fSelFirst; }
long GetSelLast() const { return fSelLast; }
void SetSelFirst(long v) { fSelFirst = v; }
void SetSelLast(long v) { fSelLast = v; }

void SetRecord(o2::mft::MillePedeRecord* aRecord) { fRecord = aRecord; }
void SetRecordWriter(o2::mft::MilleRecordWriter* myP) { fRecordWriter = myP; }
void SetConstraintsRecWriter(o2::mft::MilleRecordWriter* myP) { fConstraintsRecWriter = myP; }
void SetRecordReader(o2::mft::MilleRecordReader* myP) { fRecordReader = myP; }
void SetConstraintsRecReader(o2::mft::MilleRecordReader* myP) { fConstraintsRecReader = myP; }
void SetRecord(o2::fwdalign::MillePedeRecord* aRecord) { fRecord = aRecord; }
void SetRecordWriter(o2::fwdalign::MilleRecordWriter* myP) { fRecordWriter = myP; }
void SetConstraintsRecWriter(o2::fwdalign::MilleRecordWriter* myP) { fConstraintsRecWriter = myP; }
void SetRecordReader(o2::fwdalign::MilleRecordReader* myP) { fRecordReader = myP; }
void SetConstraintsRecReader(o2::fwdalign::MilleRecordReader* myP) { fConstraintsRecReader = myP; }

/// \brief return the limit in chi^2/nd for n sigmas stdev authorized
///
Expand Down Expand Up @@ -340,11 +340,11 @@ class MillePede2
std::vector<int> fCGlo2Glo; ///< [fNGloPar] compressed ID to global ID buffer

// Matrices
o2::mft::SymMatrix* fMatCLoc; ///< Matrix C local
o2::mft::MatrixSq* fMatCGlo; ///< Matrix C global
o2::mft::RectMatrix* fMatCGloLoc; ///< Rectangular matrix C g*l
std::vector<int> fFillIndex; ///< [fNGloPar] auxilary index array for fast matrix fill
std::vector<double> fFillValue; ///< [fNGloPar] auxilary value array for fast matrix fill
o2::fwdalign::SymMatrix* fMatCLoc; ///< Matrix C local
o2::fwdalign::MatrixSq* fMatCGlo; ///< Matrix C global
o2::fwdalign::RectMatrix* fMatCGloLoc; ///< Rectangular matrix C g*l
std::vector<int> fFillIndex; ///< [fNGloPar] auxilary index array for fast matrix fill
std::vector<double> fFillValue; ///< [fNGloPar] auxilary value array for fast matrix fill

TFile* fRecChi2File;
TString fRecChi2FName;
Expand All @@ -354,7 +354,7 @@ class MillePede2
bool fIsChi2BelowLimit;
int fRecNDoF;

o2::mft::MillePedeRecord* fRecord; ///< Buffer of measurements records
o2::fwdalign::MillePedeRecord* fRecord; ///< Buffer of measurements records

long fCurrRecDataID; ///< ID of the current data record
long fCurrRecConstrID; ///< ID of the current constraint record
Expand All @@ -380,15 +380,15 @@ class MillePede2
static int fgNKrylovV; ///< size of Krylov vectors buffer in FGMRES

// processed data record bufferization
o2::mft::MilleRecordWriter* fRecordWriter; ///< data record writer
o2::mft::MilleRecordWriter* fConstraintsRecWriter; ///< constraints record writer
o2::mft::MilleRecordReader* fRecordReader; ///< data record reader
o2::mft::MilleRecordReader* fConstraintsRecReader; ///< constraints record reader
o2::fwdalign::MilleRecordWriter* fRecordWriter; ///< data record writer
o2::fwdalign::MilleRecordWriter* fConstraintsRecWriter; ///< constraints record writer
o2::fwdalign::MilleRecordReader* fRecordReader; ///< data record reader
o2::fwdalign::MilleRecordReader* fConstraintsRecReader; ///< constraints record reader

ClassDef(MillePede2, 0);
};

} // namespace mft
} // namespace fwdalign
} // namespace o2

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
/// The records for all processed tracks are stored in the temporary tree in orgder to be
/// reused for multiple iterations of MillePede

#ifndef ALICEO2_MFT_MILLEPEDERECORD_H
#define ALICEO2_MFT_MILLEPEDERECORD_H
#ifndef ALICEO2_FWDALIGN_MILLEPEDERECORD_H
#define ALICEO2_FWDALIGN_MILLEPEDERECORD_H

#include <TObject.h>

namespace o2
{
namespace mft
namespace fwdalign
{
/// \brief Store residuals and local/global deriavtives from a single track processing
///
Expand Down Expand Up @@ -152,7 +152,7 @@ inline Bool_t MillePedeRecord::IsGroupPresent(Int_t id) const
return kFALSE;
}

} // namespace mft
} // namespace fwdalign
} // namespace o2

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@
/// \author arakotoz@cern.ch
/// \brief Class dedicated to read MillePedeRecords from ROOT files

#ifndef ALICEO2_MFT_MILLERECORD_READER_H
#define ALICEO2_MFT_MILLERECORD_READER_H
#ifndef ALICEO2_FWDALIGN_MILLERECORD_READER_H
#define ALICEO2_FWDALIGN_MILLERECORD_READER_H

#include <Rtypes.h>
#include <TString.h>
#include <TChain.h>
#include <TFile.h>
#include <TTree.h>

#include "MFTAlignment/MillePedeRecord.h"
#include "ForwardAlign/MillePedeRecord.h"

namespace o2
{
namespace mft
namespace fwdalign
{

class MilleRecordReader
Expand All @@ -51,7 +51,7 @@ class MilleRecordReader
bool isReadEntryOk() const { return mIsReadEntryOk; }

/// \brief return the record
o2::mft::MillePedeRecord* getRecord() { return mRecord; };
o2::fwdalign::MillePedeRecord* getRecord() { return mRecord; };

/// \brief return the ID of the current record in the TTree
long getCurrentDataID() const { return mCurrentDataID; }
Expand All @@ -65,20 +65,23 @@ class MilleRecordReader
/// \brief return the number of entries
Long64_t getNEntries() const { return mNEntries; }

/// \brief return the name of record data tree
TString getDataTreeName() const { return mDataTreeName; }

protected:
TChain* mDataTree; ///< TChain container that stores the records
bool mIsSuccessfulInit; ///< boolean to monitor the success of the initialization
bool mIsConstraintsRec; ///< boolean to know if these are data records or constraints records
bool mIsReadEntryOk; ///< boolean to know if the last operation readNextEntry() was ok
TString mDataTreeName; ///< name of the record TTree/TChain
TString mDataBranchName; ///< name of the branch where records will be stored
o2::mft::MillePedeRecord* mRecord; ///< the running record
Long64_t mCurrentDataID; ///< counter indicating the ID of the current record in the tree
Long64_t mNEntries; ///< number of entries in the read TChain
TChain* mDataTree; ///< TChain container that stores the records
bool mIsSuccessfulInit; ///< boolean to monitor the success of the initialization
bool mIsConstraintsRec; ///< boolean to know if these are data records or constraints records
bool mIsReadEntryOk; ///< boolean to know if the last operation readNextEntry() was ok
TString mDataTreeName; ///< name of the record TTree/TChain
TString mDataBranchName; ///< name of the branch where records will be stored
o2::fwdalign::MillePedeRecord* mRecord; ///< the running record
Long64_t mCurrentDataID; ///< counter indicating the ID of the current record in the tree
Long64_t mNEntries; ///< number of entries in the read TChain

ClassDef(MilleRecordReader, 0);
};
} // namespace mft
} // namespace fwdalign
} // namespace o2

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@

/// \file MilleRecordWriter.h
/// \author arakotoz@cern.ch
/// \brief Class dedicated to write MillePedeRecords to output file for MFT
/// \brief Class dedicated to write MillePedeRecords to output file for FWDALIGN

#ifndef ALICEO2_MFT_MILLERECORD_WRITER_H
#define ALICEO2_MFT_MILLERECORD_WRITER_H
#ifndef ALICEO2_FWDALIGN_MILLERECORD_WRITER_H
#define ALICEO2_FWDALIGN_MILLERECORD_WRITER_H

#include <Rtypes.h>
#include <TString.h>

#include "MFTAlignment/MillePedeRecord.h"
#include "ForwardAlign/MillePedeRecord.h"

class TFile;
class TTree;
namespace o2
{
namespace mft
namespace fwdalign
{

class MilleRecordWriter
Expand Down Expand Up @@ -53,7 +53,7 @@ class MilleRecordWriter
bool isInitOk() const { return mIsSuccessfulInit; }

/// \brief return the record
o2::mft::MillePedeRecord* getRecord() { return mRecord; };
o2::fwdalign::MillePedeRecord* getRecord() { return mRecord; };

/// \brief return the ID of the current record in the TTree
Long64_t getCurrentDataID() const { return mCurrentDataID; }
Expand All @@ -71,20 +71,20 @@ class MilleRecordWriter
void setRecordWeight(double wgh);

protected:
TTree* mDataTree; ///< TTree container that stores the records
TFile* mDataFile; ///< output file where the records are written
bool mIsSuccessfulInit; ///< boolean to monitor the success of the initialization
bool mIsConstraintsRec; ///< boolean to know if these are data records or constraints records
long mNEntriesAutoSave; ///< max entries in the buffer after which TTree::AutoSave() is automatically used
TString mDataFileName; ///< name of the output file that will store the record TTree
TString mDataTreeName; ///< name of the record TTree
TString mDataBranchName; ///< name of the branch where records will be stored
o2::mft::MillePedeRecord* mRecord; ///< the running record
Long64_t mCurrentDataID; ///< counter increasing when adding a record to the tree
TTree* mDataTree; ///< TTree container that stores the records
TFile* mDataFile; ///< output file where the records are written
bool mIsSuccessfulInit; ///< boolean to monitor the success of the initialization
bool mIsConstraintsRec; ///< boolean to know if these are data records or constraints records
long mNEntriesAutoSave; ///< max entries in the buffer after which TTree::AutoSave() is automatically used
TString mDataFileName; ///< name of the output file that will store the record TTree
TString mDataTreeName; ///< name of the record TTree
TString mDataBranchName; ///< name of the branch where records will be stored
o2::fwdalign::MillePedeRecord* mRecord; ///< the running record
Long64_t mCurrentDataID; ///< counter increasing when adding a record to the tree

ClassDef(MilleRecordWriter, 0);
};
} // namespace mft
} // namespace fwdalign
} // namespace o2

#endif
Loading

0 comments on commit d14a7c6

Please sign in to comment.