|
ATLAS Offline Software
|
Go to the documentation of this file.
10 #include <unordered_map>
43 #include <MuonMomentumCorrections/CalibContainer.h>
55 using namespace msgMMC;
58 bool useCorrectedCopy =
true;
64 Error(
APP_NAME,
"==============================================");
69 Error(
APP_NAME,
" $> %s [xAOD file name] -event X | X = specific number of the event to run on - for debugging",
APP_NAME);
70 Error(
APP_NAME,
"==============================================");
82 if (
options.find(
"-event") != std::string::npos) {
83 for (
int ipos = 0; ipos <
argc; ipos++) {
84 if (std::string(
argv[ipos]).compare(
"-event") == 0) {
86 Info(
APP_NAME,
"Argument (-event) : Running only on event # %i", Ievent);
93 if (
options.find(
"-n") != std::string::npos) {
94 for (
int ipos = 0; ipos <
argc; ipos++) {
103 TString limitSys =
"";
104 if (
options.find(
"-s") != std::string::npos) {
105 for (
int ipos = 0; ipos <
argc; ipos++) {
107 limitSys = TString(
argv[ipos + 1]);
114 if (
options.find(
"-doSys") != std::string::npos) {
125 std::unique_ptr<TFile>
ifile(TFile::Open(
fileName.c_str(),
"READ"));
128 std::unique_ptr<TChain>
chain = std::make_unique<TChain>(
"CollectionTree",
"CollectionTree");
139 Long64_t
entries =
event.getEntries();
152 bool isRun3Geo =
false;
153 if(
fileName.find(
"mc21") != std::string::npos) isRun3Geo =
true;
154 if(
fileName.find(
"data22") != std::string::npos) isRun3Geo =
true;
158 corrTool.
setProperty(
"IsRun3Geo", isRun3Geo).ignore();
166 bool isDebug =
false;
167 if (
nEvents >= 0 || Ievent >= 0) isDebug =
true;
172 if (
sc.isFailure()) {
179 if (
sc.isFailure()) {
192 selTool.
setTypeAndName(
"CP::MuonSelectionTool/MuonSelectionTool");
195 selTool.
setProperty(
"IsRun3Geo", isRun3Geo).ignore();
200 if (selTool.
retrieve().isFailure() ||
sc.isFailure()) {
208 std::vector<CP::SystematicSet> sysList;
216 if(!TString(sysItr->name()).Contains(limitSys) && limitSys.Length() > 0)
continue;
218 sysList.back().insert(*sysItr);
222 std::vector<CP::SystematicSet>::const_iterator sysListItr;
225 for (sysListItr = sysList.begin(); sysListItr != sysList.end(); ++sysListItr)
msgMMC::ANA_MSG_INFO(sysListItr->name());
228 Float_t InitPtCB(0.), InitPtID(0.), InitPtMS(0.);
229 Float_t CorrPtCB(0.), CorrPtID(0.), CorrPtMS(0.);
230 Float_t
Eta(0.),
Phi(0.), Charge(0.);
231 Float_t ExpResoCB(0.), ExpResoID(0.), ExpResoMS(0.);
232 long long unsigned int eventNum(0);
235 TFile*
outputFile = TFile::Open(
"output.root",
"recreate");
238 std::unordered_map<CP::SystematicSet, TTree*> sysTreeMap;
239 for (sysListItr = sysList.begin(); sysListItr != sysList.end(); ++sysListItr) {
241 std::string
treeName =
"test_tree_" + (sysListItr->name().size() == 0 ?
"NOMINAL" : sysListItr->name());
242 TTree* sysTree =
new TTree(
treeName.c_str(),
"test tree for MCAST");
245 sysTree->Branch(
"InitPtCB", &InitPtCB,
"InitPtCB/F");
246 sysTree->Branch(
"InitPtID", &InitPtID,
"InitPtID/F");
247 sysTree->Branch(
"InitPtMS", &InitPtMS,
"InitPtMS/F");
248 sysTree->Branch(
"CorrPtCB", &CorrPtCB,
"CorrPtCB/F");
249 sysTree->Branch(
"CorrPtID", &CorrPtID,
"CorrPtID/F");
250 sysTree->Branch(
"CorrPtMS", &CorrPtMS,
"CorrPtMS/F");
251 sysTree->Branch(
"Eta", &
Eta,
"Eta/F");
252 sysTree->Branch(
"Phi", &
Phi,
"Phi/F");
253 sysTree->Branch(
"Charge", &Charge,
"Charge/F");
254 sysTree->Branch(
"ExpResoCB", &ExpResoCB,
"ExpResoCB/F");
255 sysTree->Branch(
"ExpResoID", &ExpResoID,
"ExpResoID/F");
256 sysTree->Branch(
"ExpResoMS", &ExpResoMS,
"ExpResoMS/F");
257 sysTree->Branch(
"eventNum", &eventNum);
259 sysTreeMap[*sysListItr] = sysTree;
268 event.getEntry(
entry);
273 if (Ievent != -1 &&
static_cast<int>(evtInfo->
eventNumber()) != Ievent) {
continue; }
282 for (sysListItr = sysList.begin(); sysListItr != sysList.end(); ++sysListItr) {
289 Info(
APP_NAME,
"-----------------------------------------------------------");
290 Info(
APP_NAME,
"Looking at %s systematic", (sysListItr->name()).c_str());
294 Error(
APP_NAME,
"Cannot configure muon calibration tool for systematic");
298 for (
auto muon : *muonsCorr) {
301 if (isDebug) Info(
APP_NAME,
"This muon doesn't pass the ID hits quality cuts");
306 InitPtCB =
muon->pt();
308 if (
muon->inDetTrackParticleLink().isValid()) {
310 InitPtID = (!id_track) ? 0 : (*id_track)->pt();
313 if (
muon->extrapolatedMuonSpectrometerTrackParticleLink().isValid()) {
315 InitPtMS = (!ms_track) ? 0 : (*ms_track)->pt();
320 Charge =
muon->charge();
323 if (isDebug) Info(
APP_NAME,
"Selected muon: eta = %g, phi = %g, pt = %g",
muon->eta(),
muon->phi(),
muon->pt() / 1
e3);
326 if (
muon->primaryTrackParticleLink().isValid()) {
328 ptCB = (!cb_track) ? 0 : (*cb_track)->pt();
331 Info(
APP_NAME,
"Missing primary track particle link for --> CB %g, author: %d, type: %d", ptCB,
muon->author(),
335 if (
muon->inDetTrackParticleLink().isValid()) {
337 ptID = (!id_track) ? 0 : (*id_track)->pt();
340 if (
muon->extrapolatedMuonSpectrometerTrackParticleLink().isValid()) {
342 ptME = (!ms_track) ? 0 : (*ms_track)->pt();
346 Info(
APP_NAME,
"--> CB %g, ID %g, ME %g, author: %d, type: %d", ptCB / 1
e3, ptID / 1
e3, ptME / 1
e3,
muon->author(),
352 if (useCorrectedCopy) {
356 Error(
APP_NAME,
"Cannot really apply calibration nor smearing");
360 CorrPtID = InnerDetectorPtAcc (*
mu);
361 CorrPtMS = MuonSpectrometerPtAcc (*
mu);
364 sysTreeMap[*sysListItr]->Fill();
370 Error(
APP_NAME,
"Cannot really apply calibration nor smearing");
373 CorrPtCB =
muon->pt();
374 CorrPtID = InnerDetectorPtAcc (*
muon);
375 CorrPtMS = MuonSpectrometerPtAcc (*
muon);
380 Info(
APP_NAME,
"Calibrated muon: eta = %g, phi = %g, pt(CB) = %g, pt(ID) = %g, pt(MS) = %g",
muon->eta(),
383 Info(
APP_NAME,
" expReso : ExpResoCB = %g , ExpResoID = %g , ExpResoMS = %g", ExpResoCB, ExpResoID, ExpResoMS);
384 sysTreeMap[*sysListItr]->Fill();
387 if (isDebug) Info(
APP_NAME,
"-----------------------------------------------------------");
389 delete muons_shallowCopy.first;
390 delete muons_shallowCopy.second;
395 "===>>> done processing event #%i, run #%i %i events processed so far <<<===",
static_cast<int>(evtInfo->
eventNumber()),
396 static_cast<int>(evtInfo->
runNumber()),
static_cast<int>(
entry + 1));
399 for (sysListItr = sysList.begin(); sysListItr != sysList.end(); ++sysListItr) { sysTreeMap[*sysListItr]->Write(); }
std::pair< int, int > compare(const AmgSymMatrix(N) &m1, const AmgSymMatrix(N) &m2, double precision=1e-9, bool relative=false)
compare two matrices, returns the indices of the first element that fails the condition,...
uint64_t eventNumber() const
The current event's event number.
ReadStats & stats()
Access the object belonging to the current thread.
@ kAthenaAccess
Access containers/objects like Athena does.
std::set< SystematicVariation >::const_iterator const_iterator
Class to wrap a set of SystematicVariations.
int main(int argc, char *argv[])
uint32_t runNumber() const
The current event's run number.
POOL::TEvent event(POOL::TEvent::kClassAccess)
::StatusCode StatusCode
StatusCode definition for legacy code.
const_iterator end() const
description: const iterator to the end of the set
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
static IOStats & instance()
Singleton object accessor.
void printSmartSlimmingBranchList(bool autoIncludeLinks=false) const
Print the accessed variables, formatted for smart slimming.
std::pair< std::unique_ptr< T >, std::unique_ptr< ShallowAuxContainer > > shallowCopyContainer(const T &cont, [[maybe_unused]] const EventContext &ctx)
Function making a shallow copy of a constant container.
Class describing the basic event information.
A relatively simple transient store for objects created in analysis.
This module implements the central registry for handling systematic uncertainties with CP tools.
StatusCode retrieve(const T *&obj)
const_iterator begin() const
description: const iterator to the beginning of the set
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Error
The different types of error that can be flagged in the L1TopoRDO.
Helper class to provide constant type-safe access to aux data.
Define macros for attributes used to control the static checker.
Tool for accessing xAOD files outside of Athena.
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.