forked from AliceO2Group/O2Physics
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/creetz16/O2Physics
- Loading branch information
Showing
313 changed files
with
26,837 additions
and
10,389 deletions.
There are no files selected for viewing
This file contains 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 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,137 @@ | ||
// 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. | ||
|
||
#include "ctpRateFetcher.h" | ||
|
||
#include <map> | ||
#include <vector> | ||
|
||
#include "CommonConstants/LHCConstants.h" | ||
#include "DataFormatsCTP/Configuration.h" | ||
#include "DataFormatsCTP/Scalers.h" | ||
#include "DataFormatsParameters/GRPLHCIFData.h" | ||
#include "CCDB/BasicCCDBManager.h" | ||
|
||
namespace o2 | ||
{ | ||
|
||
using framework::Service; | ||
|
||
double ctpRateFetcher::fetch(Service<o2::ccdb::BasicCCDBManager>& ccdb, uint64_t timeStamp, int runNumber, std::string sourceName) | ||
{ | ||
if (sourceName.find("ZNC") != std::string::npos) { | ||
if (runNumber < 544448) { | ||
return fetchCTPratesInputs(ccdb, timeStamp, runNumber, 26) / (sourceName.find("hadronic") != std::string::npos ? 28. : 1.); | ||
} else { | ||
return fetchCTPratesClasses(ccdb, timeStamp, runNumber, "C1ZNC-B-NOPF-CRU", 6) / (sourceName.find("hadronic") != std::string::npos ? 28. : 1.); | ||
} | ||
} else if (sourceName == "T0CE") { | ||
return fetchCTPratesClasses(ccdb, timeStamp, runNumber, "CMTVXTCE-B-NOPF-CRU"); | ||
} else if (sourceName == "T0SC") { | ||
return fetchCTPratesClasses(ccdb, timeStamp, runNumber, "CMTVXTSC-B-NOPF-CRU"); | ||
} else if (sourceName == "T0VTX") { | ||
if (runNumber < 534202) { | ||
return fetchCTPratesClasses(ccdb, timeStamp, runNumber, "minbias_TVX_L0"); // 2022 | ||
} else { | ||
return fetchCTPratesClasses(ccdb, timeStamp, runNumber, "CMTVX-B-NOPF-CRU"); | ||
} | ||
} | ||
LOG(error) << "CTP rate for " << sourceName << " not available"; | ||
return -1.; | ||
} | ||
|
||
double ctpRateFetcher::fetchCTPratesClasses(Service<o2::ccdb::BasicCCDBManager>& ccdb, uint64_t timeStamp, int runNumber, std::string className, int inputType) | ||
{ | ||
getCTPscalers(ccdb, timeStamp, runNumber); | ||
getCTPconfig(ccdb, timeStamp, runNumber); | ||
|
||
std::vector<ctp::CTPClass> ctpcls = mConfig->getCTPClasses(); | ||
std::vector<int> clslist = mConfig->getTriggerClassList(); | ||
int classIndex = -1; | ||
for (size_t i = 0; i < clslist.size(); i++) { | ||
if (ctpcls[i].name == className) { | ||
classIndex = i; | ||
break; | ||
} | ||
} | ||
if (classIndex == -1) { | ||
LOG(fatal) << "Trigger class " << className << " not found in CTPConfiguration"; | ||
} | ||
|
||
auto rate{mScalers->getRateGivenT(timeStamp, classIndex, inputType)}; | ||
|
||
return pileUpCorrection(rate.second); | ||
} | ||
|
||
double ctpRateFetcher::fetchCTPratesInputs(Service<o2::ccdb::BasicCCDBManager>& ccdb, uint64_t timeStamp, int runNumber, int input) | ||
{ | ||
getCTPscalers(ccdb, timeStamp, runNumber); | ||
getLHCIFdata(ccdb, timeStamp, runNumber); | ||
|
||
std::vector<ctp::CTPScalerRecordO2> recs = mScalers->getScalerRecordO2(); | ||
if (recs[0].scalersInps.size() == 48) { | ||
return pileUpCorrection(mScalers->getRateGivenT(timeStamp, input, 7).second); | ||
} else { | ||
LOG(error) << "Inputs not available"; | ||
return -1.; | ||
} | ||
} | ||
|
||
void ctpRateFetcher::getCTPscalers(Service<o2::ccdb::BasicCCDBManager>& ccdb, uint64_t timeStamp, int runNumber) | ||
{ | ||
if (runNumber == mRunNumber && mScalers != nullptr) { | ||
return; | ||
} | ||
std::map<string, string> metadata; | ||
metadata["runNumber"] = std::to_string(runNumber); | ||
mScalers = ccdb->getSpecific<ctp::CTPRunScalers>("CTP/Calib/Scalers", timeStamp, metadata); | ||
if (mScalers == nullptr) { | ||
LOG(fatal) << "CTPRunScalers not in database, timestamp:" << timeStamp; | ||
} | ||
mScalers->convertRawToO2(); | ||
} | ||
|
||
void ctpRateFetcher::getLHCIFdata(Service<o2::ccdb::BasicCCDBManager>& ccdb, uint64_t timeStamp, int runNumber) | ||
{ | ||
if (runNumber == mRunNumber && mLHCIFdata != nullptr) { | ||
return; | ||
} | ||
std::map<string, string> metadata; | ||
mLHCIFdata = ccdb->getSpecific<parameters::GRPLHCIFData>("GLO/Config/GRPLHCIF", timeStamp, metadata); | ||
if (mLHCIFdata == nullptr) { | ||
LOG(fatal) << "GRPLHCIFData not in database, timestamp:" << timeStamp; | ||
} | ||
} | ||
|
||
void ctpRateFetcher::getCTPconfig(Service<o2::ccdb::BasicCCDBManager>& ccdb, uint64_t timeStamp, int runNumber) | ||
{ | ||
if (runNumber == mRunNumber && mConfig != nullptr) { | ||
return; | ||
} | ||
std::map<string, string> metadata; | ||
metadata["runNumber"] = std::to_string(runNumber); | ||
mConfig = ccdb->getSpecific<ctp::CTPConfiguration>("CTP/Config/Config", timeStamp, metadata); | ||
if (mConfig == nullptr) { | ||
LOG(fatal) << "CTPRunConfig not in database, timestamp:" << timeStamp; | ||
} | ||
} | ||
|
||
double ctpRateFetcher::pileUpCorrection(double triggerRate) | ||
{ | ||
auto bfilling = mLHCIFdata->getBunchFilling(); | ||
std::vector<int> bcs = bfilling.getFilledBCs(); | ||
double nbc = bcs.size(); | ||
double nTriggersPerFilledBC = triggerRate / nbc / constants::lhc::LHCRevFreq; | ||
double mu = -std::log(1 - nTriggersPerFilledBC); | ||
return mu * nbc * constants::lhc::LHCRevFreq; | ||
} | ||
|
||
} // namespace o2 |
This file contains 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,55 @@ | ||
// 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. | ||
|
||
#ifndef COMMON_CCDB_CTPRATEFETCHER_H_ | ||
#define COMMON_CCDB_CTPRATEFETCHER_H_ | ||
|
||
#include <string> | ||
|
||
#include "CCDB/BasicCCDBManager.h" | ||
#include "Framework/AnalysisHelpers.h" | ||
|
||
namespace o2 | ||
{ | ||
|
||
namespace ctp | ||
{ | ||
class CTPRunScalers; | ||
class CTPConfiguration; | ||
} // namespace ctp | ||
|
||
namespace parameters | ||
{ | ||
class GRPLHCIFData; | ||
} | ||
|
||
class ctpRateFetcher | ||
{ | ||
public: | ||
ctpRateFetcher() = default; | ||
double fetch(framework::Service<o2::ccdb::BasicCCDBManager>& ccdb, uint64_t timeStamp, int runNumber, std::string sourceName); | ||
|
||
private: | ||
void getCTPconfig(framework::Service<o2::ccdb::BasicCCDBManager>& ccdb, uint64_t timeStamp, int runNumber); | ||
void getCTPscalers(framework::Service<o2::ccdb::BasicCCDBManager>& ccdb, uint64_t timeStamp, int runNumber); | ||
void getLHCIFdata(framework::Service<o2::ccdb::BasicCCDBManager>& ccdb, uint64_t timeStamp, int runNumber); | ||
double fetchCTPratesInputs(framework::Service<o2::ccdb::BasicCCDBManager>& ccdb, uint64_t timeStamp, int runNumber, int input); | ||
double fetchCTPratesClasses(framework::Service<o2::ccdb::BasicCCDBManager>& ccdb, uint64_t timeStamp, int runNumber, std::string className, int inputType = 1); | ||
double pileUpCorrection(double rate); | ||
|
||
int mRunNumber = -1; | ||
ctp::CTPConfiguration* mConfig = nullptr; | ||
ctp::CTPRunScalers* mScalers = nullptr; | ||
parameters::GRPLHCIFData* mLHCIFdata = nullptr; | ||
}; | ||
} // namespace o2 | ||
|
||
#endif // COMMON_CCDB_CTPRATEFETCHER_H_ |
This file contains 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 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 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 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 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
Oops, something went wrong.