-
Notifications
You must be signed in to change notification settings - Fork 485
Adding TRD t0 fitting procedure #11695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
77aa39a
Adding TRD t0 fitting procedure
luisabergmann 4dcda76
cleanup/documentation
luisabergmann 6ab5139
Please consider the following formatting changes
alibuild 1e88028
Merge pull request #4 from alibuild/alibot-cleanup-11695
luisabergmann 43c5cc0
Merge branch 'AliceO2Group:dev' into dev
luisabergmann f0d1ac9
replaced entries-variable with direct instance of calibration parameters
luisabergmann 8dbf74a
removed reset() from calibration container
luisabergmann f937ba9
Please consider the following formatting changes
alibuild 12b3ec1
Merge pull request #5 from alibuild/alibot-cleanup-11695
luisabergmann 44942ef
Update DataFormats/Detectors/TRD/src/T0FitHistos.cxx
luisabergmann 2382abc
Update DataFormats/Detectors/TRD/src/T0FitHistos.cxx
luisabergmann e563022
Update Detectors/TRD/calibration/src/T0Fit.cxx
luisabergmann 2629e2d
Updated DataFormats/Detectors/TRD/include/DataFormatsTRD/T0FitHistos.h
luisabergmann 1109afb
Merge branch 'dev' of github.com:luisabergmann/AliceO2 into dev
luisabergmann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |
| #define ALICEO2_TRD_PHDATA_H_ | ||
|
|
||
| #include <cstdint> | ||
| #include "Rtypes.h" | ||
|
|
||
| namespace o2::trd | ||
| { | ||
|
|
||
58 changes: 58 additions & 0 deletions
58
DataFormats/Detectors/TRD/include/DataFormatsTRD/T0FitHistos.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // 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. | ||
|
|
||
| /// \file T0FitHistos.h | ||
| /// \brief Class to store the TRD PH values for each TRD chamber | ||
|
|
||
| #ifndef ALICEO2_T0FITHISTOS_H | ||
| #define ALICEO2_T0FITHISTOS_H | ||
|
|
||
| #include "DataFormatsTRD/Constants.h" | ||
| #include "DataFormatsTRD/PHData.h" | ||
| #include "Framework/InputRecord.h" | ||
| #include "Rtypes.h" | ||
| #include <vector> | ||
| #include <memory> | ||
| #include <gsl/span> | ||
|
|
||
| namespace o2 | ||
| { | ||
| namespace trd | ||
| { | ||
|
|
||
| class T0FitHistos | ||
| { | ||
| public: | ||
| T0FitHistos() = default; | ||
| T0FitHistos(const T0FitHistos&) = default; | ||
| ~T0FitHistos() = default; | ||
| auto getDetector(int index) const { return mDet[index]; } | ||
| auto getTimeBin(int index) const { return mTB[index]; } | ||
| auto getADC(int index) const { return mADC[index]; } | ||
| auto getNEntries() const { return mNEntriesTot; } | ||
|
|
||
| void fill(const std::vector<o2::trd::PHData>& data); | ||
| void merge(const T0FitHistos* prev); | ||
| void print(); | ||
|
|
||
| private: | ||
| std::vector<int> mDet{}; | ||
| std::vector<int> mTB{}; | ||
| std::vector<int> mADC{}; | ||
| size_t mNEntriesTot{0}; | ||
|
|
||
| ClassDefNV(T0FitHistos, 1); | ||
| }; | ||
|
|
||
| } // namespace trd | ||
| } // namespace o2 | ||
|
|
||
| #endif // ALICEO2_T0FITHISTOS_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| // 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. | ||
|
|
||
| /// \file T0FitHistos.cxx | ||
| /// \brief Class to store the TRD PH values for each chamber | ||
|
|
||
| #include "DataFormatsTRD/T0FitHistos.h" | ||
| #include <fairlogger/Logger.h> | ||
| #include <algorithm> | ||
|
|
||
| using namespace o2::trd; | ||
| using namespace o2::trd::constants; | ||
|
|
||
| void T0FitHistos::fill(const std::vector<o2::trd::PHData>& data) | ||
| { | ||
| for (const auto& ph : data) { | ||
| int det = ph.getDetector(); | ||
| int tb = ph.getTimebin(); | ||
| int adc = ph.getADC(); | ||
|
|
||
| if (ph.getNneighbours() != 2) { | ||
| continue; | ||
| } | ||
|
|
||
| mDet.push_back(det); | ||
| mTB.push_back(tb); | ||
| mADC.push_back(adc); | ||
| ++mNEntriesTot; | ||
| } | ||
| } | ||
|
|
||
| void T0FitHistos::merge(const T0FitHistos* prev) | ||
| { | ||
| auto sizePrev = (int)prev->getNEntries(); | ||
|
|
||
| for (int i = 0; i < sizePrev; ++i) { | ||
| mDet.push_back(prev->getDetector(i)); | ||
| mTB.push_back(prev->getTimeBin(i)); | ||
| mADC.push_back(prev->getADC(i)); | ||
| } | ||
| } | ||
|
|
||
| void T0FitHistos::print() | ||
| { | ||
| LOG(info) << "There are " << mNEntriesTot << " entries in the container"; | ||
| } | ||
f3sch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
Detectors/TRD/calibration/include/TRDCalibration/T0Fit.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| // 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. | ||
|
|
||
| /// \file T0Fit.h | ||
| /// \brief Fits the TRD PH distributions to extract the t0 value | ||
| /// \author Luisa Bergmann | ||
|
|
||
| #ifndef O2_TRD_T0FIT_H | ||
| #define O2_TRD_T0FIT_H | ||
|
|
||
| #include "DataFormatsTRD/T0FitHistos.h" | ||
| #include "DetectorsCalibration/TimeSlotCalibration.h" | ||
| #include "DetectorsCalibration/TimeSlot.h" | ||
| #include "DataFormatsTRD/Constants.h" | ||
| #include "CCDB/CcdbObjectInfo.h" | ||
| #include "DataFormatsTRD/CalT0.h" | ||
| #include "TRDCalibration/CalibrationParams.h" | ||
|
|
||
| #include "Rtypes.h" | ||
| #include "TProfile.h" | ||
| #include "TF1.h" | ||
| #include "Fit/Fitter.h" | ||
| #include "TFile.h" | ||
| #include "TTree.h" | ||
|
|
||
| #include <array> | ||
| #include <cstdlib> | ||
| #include <memory> | ||
|
|
||
| namespace o2 | ||
| { | ||
| namespace trd | ||
| { | ||
| //______________________________________________________________________________________________ | ||
| struct ErfLandauChi2Functor { | ||
| double operator()(const double* par) const; | ||
| std::vector<float> x; ///< x-value (time-bin) of adc profile | ||
| std::vector<float> y; ///< y-value (av. adc) for corresp. time-bin | ||
| float lowerBoundFit; ///< lower bound for fit | ||
| float upperBoundFit; ///< upper bound for fit | ||
| }; | ||
|
|
||
| //______________________________________________________________________________________________ | ||
| class T0Fit final : public o2::calibration::TimeSlotCalibration<o2::trd::T0FitHistos> | ||
| { | ||
| using Slot = o2::calibration::TimeSlot<o2::trd::T0FitHistos>; | ||
|
|
||
| public: | ||
| T0Fit() = default; | ||
| ~T0Fit() final = default; | ||
|
|
||
| bool hasEnoughData(const Slot& slot) const final { return slot.getContainer()->getNEntries() >= mParams.minEntriesTotalT0Fit; } | ||
| void initOutput() final; | ||
| void finalizeSlot(Slot& slot) final; | ||
| Slot& emplaceNewSlot(bool front, TFType tStart, TFType tEnd) final; | ||
|
|
||
| /// (Re-)Creates a file "trd_t0fit.root". This lets continually fill | ||
| /// a tree with the fit results. | ||
| void createOutputFile(); | ||
|
|
||
| /// Close the output file. E.g. First write the tree to the file and let the | ||
| /// smart pointers take care of closing the file. | ||
| void closeOutputFile(); | ||
|
|
||
| const std::vector<o2::trd::CalT0>& getCcdbObjectVector() const { return mObjectVector; } | ||
| std::vector<o2::ccdb::CcdbObjectInfo>& getCcdbObjectInfoVector() { return mInfoVector; } | ||
|
|
||
| void initProcessing(); | ||
|
|
||
| private: | ||
| bool mInitDone{false}; ///< flag to avoid creating output etc multiple times | ||
| const TRDCalibParams& mParams{TRDCalibParams::Instance()}; ///< reference to calibration parameters | ||
| bool mEnableOutput{false}; ///< enable output in a root file instead of the ccdb | ||
| std::unique_ptr<TFile> mOutFile{nullptr}; ///< output file | ||
| std::unique_ptr<TTree> mOutTree{nullptr}; ///< output tree | ||
| ErfLandauChi2Functor mFitFunctor; ///< used for minimization process, provides chi2 estimate | ||
| ROOT::Fit::Fitter mFitter; ///< instance of the ROOT fitter | ||
| std::array<double, 4> mParamsStart; ///< Starting parameters for fit | ||
| std::unique_ptr<TF1> mFuncErfLandau; ///< helper function to calculate the t0 value after the fitting procedure | ||
| float mDummyT0{-5}; ///< dummy value for t0, to be used if fit fails or not enough statistics | ||
| std::array<float, o2::trd::constants::MAXCHAMBER> t0_chambers; ///< t0 values of the individual chambers | ||
| float t0_average{-5}; ///< average t0 value across all chambers | ||
|
|
||
| std::vector<o2::ccdb::CcdbObjectInfo> mInfoVector; ///< vector of CCDB infos; each element is filled with CCDB description of accompanying CCDB calibration object | ||
| std::vector<o2::trd::CalT0> mObjectVector; ///< vector of CCDB calibration objects; the extracted t0 per chamber and average for given slot | ||
|
|
||
| std::unique_ptr<TProfile> adcProfIncl; ///< profile that holds inclusive PH spectrum | ||
| std::array<std::unique_ptr<TProfile>, o2::trd::constants::MAXCHAMBER> adcProfDet; ///< array of profiles for PH spectrum of each chamber | ||
|
|
||
| ClassDefNV(T0Fit, 1); | ||
| }; | ||
|
|
||
| } // namespace trd | ||
| } // namespace o2 | ||
|
|
||
| #endif // O2_TRD_T0FIT_H |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.