61const int fgSNDetElemCh[
fgNCh + 1] = {0, 4, 8, 12, 16, 34, 52, 78, 104, 130, 156};
82 AlignRecordTask(std::shared_ptr<DataRequest> dataRequest, std::shared_ptr<base::GRPGeomRequest> ccdbRequest,
bool useMC =
true)
83 : mDataRequest(dataRequest), mCCDBRequest(ccdbRequest), mUseMC(useMC) {}
89 LOG(info) <<
"initializing align record maker";
95 auto grpFile = ic.
options().
get<std::string>(
"grp-file");
96 if (std::filesystem::exists(grpFile)) {
103 LOG(fatal) <<
"GRP file doesn't exist!";
118 trackFitter.
setChamberResolution(trackerParam.chamberResolutionX, trackerParam.chamberResolutionY);
121 mImproveCutChi2 = 2. * trackerParam.sigmaCutForImprovement * trackerParam.sigmaCutForImprovement;
124 auto input_fixchambers = ic.
options().
get<
string>(
"fix-chamber");
125 std::stringstream string_chambers(input_fixchambers);
126 string_chambers >> std::ws;
127 while (string_chambers.good()) {
129 std::getline(string_chambers, substr,
',');
130 LOG(info) << Form(
"%s%d",
"Fixing chamber: ", std::stoi(substr));
135 auto OutputRecFileName = ic.
options().
get<
string>(
"output-record-data");
136 auto OutputConsFileName = ic.
options().
get<
string>(
"output-record-constraint");
137 mAlign.
init(OutputRecFileName, OutputConsFileName);
140 LOG(info) <<
"Saving records into ROOT file";
141 LOG(info) <<
"Nb of records to be saved: " << mTrackCount;
142 LOG(info) <<
"Nb of matched MCH-MID tracks: " << mTrackMatched;
159 LOG(info) <<
"Loading reference geometry from CCDB";
161 for (
int i = 0;
i < 156;
i++) {
162 int iDEN = GetDetElemId(
i);
163 transform[iDEN] = transformation(iDEN);
182 mTrackMatched += mchmidMatches.size();
184 for (
auto const& mchmidMatch : mchmidMatches) {
186 int mchTrackID = mchmidMatch.getMCHRef().getIndex();
187 const auto& mchTrack = mchTracks[mchTrackID];
188 int first = mchTrack.getFirstClusterIdx();
189 int last = mchTrack.getLastClusterIdx();
190 int Ncluster = last -
first + 1;
198 for (
int i =
first;
i <= last;
i++) {
199 const auto& cluster = mchClusters[
i];
204 if (!RemoveTrack(convertedTrack)) {
205 mAlign.
ProcessTrack(convertedTrack, transformation,
false, weightRecord);
216 bool removeTrack =
false;
219 trackFitter.
fit(track,
false);
220 }
catch (exception
const& e) {
225 auto itStartingParam = std::prev(track.
rend());
229 trackFitter.
fit(track,
true,
false, (itStartingParam == track.
rbegin()) ?
nullptr : &itStartingParam);
230 }
catch (exception
const&) {
235 double worstLocalChi2 = -1.0;
238 auto itWorstParam = track.
end();
240 for (
auto itParam = track.
begin(); itParam != track.
end(); ++itParam) {
241 if (itParam->getLocalChi2() > worstLocalChi2) {
242 worstLocalChi2 = itParam->getLocalChi2();
243 itWorstParam = itParam;
247 if (worstLocalChi2 < mImproveCutChi2) {
251 if (!itWorstParam->isRemovable()) {
258 auto itNextToNextParam = (itNextParam == track.
end()) ? itNextParam :
std::next(itNextParam);
259 itStartingParam = track.
rbegin();
265 while (itNextToNextParam != track.
end()) {
266 if (itNextToNextParam->getClusterPtr()->getChamberId() != itNextParam->getClusterPtr()->getChamberId()) {
267 itStartingParam = std::make_reverse_iterator(++itNextParam);
276 for (
auto&
param : track) {
277 param.setParameters(
param.getSmoothParameters());
278 param.setCovariances(
param.getSmoothCovariances());
286 Int_t GetDetElemId(Int_t iDetElemNumber)
291 LOG(fatal) <<
"Invalid detector element number: " << iDetElemNumber;
307 LOG(fatal) <<
"Invalid detector element id: " << 100 * iCh + iDet;
311 return 100 * iCh + iDet;
314 std::shared_ptr<base::GRPGeomRequest> mCCDBRequest;
315 std::shared_ptr<DataRequest> mDataRequest;
322 double mImproveCutChi2{};
326 Double_t weightRecord{1.0};
327 std::vector<o2::fwdalign::MillePedeRecord> mRecords;
329 map<int, math_utils::Transform3D> transform;
336 auto dataRequest = std::make_shared<DataRequest>();
338 dataRequest->requestMCHClusters(
false);
339 dataRequest->requestTracks(
src, useMC);
341 vector<OutputSpec> outputSpecs{};
342 auto ccdbRequest = disableCCDB ? nullptr : std::make_shared<base::GRPGeomRequest>(
false,
351 outputSpecs.emplace_back(
"MUON",
"RECORD_MCHMID", 0, Lifetime::Sporadic);
357 AlgorithmSpec{adaptFromTask<AlignRecordTask>(dataRequest, ccdbRequest, useMC)},
360 {
"fix-chamber", VariantType::String,
"", {
"Chamber fixing, ex 1,2,3"}},
361 {
"output-record-data", VariantType::String,
"recDataFile.root", {
"Option for name of output record file for data"}},
362 {
"output-record-constraint", VariantType::String,
"recConsFile.root", {
"Option for name of output record file for constraint"}}}};
Definition of the base alignment parameters class.
const int fgSNDetElemCh[fgNCh+1]
const int fgNDetElemCh[fgNCh]
Definition of the process for creating alignment record during reconstruction.
General auxilliary methods.
Definition of the Names Generator class.
Definition of the GeometryManager class.
Header of the AggregatedRunInfo struct.
Helper for geometry and GRP related CCDB requests.
Header of the General Run Parameters object for B field values.
Header of the General Run Parameters object.
Global Forward Muon tracks.
Global index for barrel track: provides provenance (detectors combination), index in respective array...
Configurable parameters for MCH tracking.
Definition of a class to fit a track to a set of clusters.
Class to perform MFT MCH (and MID) matching.
Class to perform TOF matching to global tracks.
Class to store the data of single track processing.
Definition of the MUON track.
Definition of the MCH track.
Definition of the MCH track parameters for internal use.
Result of refitting TPC-ITS matched track.
void checkUpdates(o2::framework::ProcessingContext &pc)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
static std::string getAlignedGeomFileName(const std::string_view prefix="")
static std::string getGRPFileName(const std::string_view prefix=STANDARDSIMPREFIX)
static int initFieldFromGRP(const o2::parameters::GRPMagField *grp, bool verbose=false)
static const TrackerParam & Instance()
T get(const char *key) const
void snapshot(const Output &spec, T const &object)
ServiceRegistryRef services()
ConfigParamRegistry const & options()
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
void finaliseCCDB(framework::ConcreteDataMatcher &matcher, void *obj)
void run(framework::ProcessingContext &pc)
AlignRecordTask(std::shared_ptr< DataRequest > dataRequest, std::shared_ptr< base::GRPGeomRequest > ccdbRequest, bool useMC=true)
void init(framework::InitContext &ic)
void SetBFieldOn(bool value)
Set flag for Magnetic field On/Off.
void SetAllowedVariation(int iPar, double value)
o2::fwdalign::MillePedeRecord & GetRecord()
void SetDoEvaluation(bool value)
set to true to do refit evaluation
void init(TString DataRecFName="millerecords.root", TString ConsRecFName="milleconstraints.root")
void FixChamber(int iCh, unsigned int parameterMask=ParAll)
void ProcessTrack(Track &track, const o2::mch::geo::TransformationCreator &transformation, Bool_t doAlignment, Double_t weight=1)
void DisableRecordWriter()
Class to fit a track to a set of clusters.
void setChamberResolution(double ex, double ey)
void useChamberResolution()
Use the chamber resolution instead of cluster resolution during the fit.
void setBendingVertexDispersion(double ey)
Set the vertex dispersion in y direction used for the track covariance seed.
void smoothTracks(bool smooth)
Enable/disable the smoother (and the saving of related parameters)
void fit(Track &track, bool smooth=true, bool finalize=true, std::list< TrackParam >::reverse_iterator *itStartingParam=nullptr, bool skipLocalChi2Calculation=false)
TrackParam & createParamAtCluster(const Cluster &cluster)
void tagRemovableClusters(uint8_t requestedStationMask, bool request2ChInSameSt45)
int getNClusters() const
Return the number of attached clusters.
auto rend()
Return a reverse iterator passing the track parameters at first cluster.
auto end()
Return an iterator passing the track parameters at last cluster.
auto begin()
Return an iterator to the track parameters at clusters (point to the first one)
void removable(bool removable=true)
set the flag telling if this track should be deleted
auto rbegin()
Return a reverse iterator to the track parameters at clusters (point to the last one)
auto removeParamAtCluster(std::list< TrackParam >::iterator &itParam)
Remove the given track parameters from the internal list and return an iterator to the parameters tha...
static GRPObject * loadFrom(const std::string &grpFileName="")
Defining PrimaryVertex explicitly as messageable.
std::vector< ConfigParamSpec > Options
TransformationCreator transformationFromTGeoManager(const TGeoManager &geo)
std::function< o2::math_utils::Transform3D(int detElemId)> TransformationCreator
o2::framework::DataProcessorSpec getAlignRecordSpec(bool useMC, bool disableCCDB=false)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Defining DataPointCompositeObject explicitly as copiable.
auto getMCHMIDMatches() const
auto getMCHTrackClusters() const
void collectData(o2::framework::ProcessingContext &pc, const DataRequest &request)
auto getMCHTracks() const
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"