ATLAS Offline Software
Loading...
Searching...
No Matches
LArMphysOverMcalFromTuple.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
6
11
12#include "TFile.h"
13#include "TBranch.h"
14#include "TTree.h"
15#include "TChain.h"
16
17#include <vector>
18#include <iostream>
19#include <fstream>
20#include <string>
21
22
23LArMphysOverMcalFromTuple::LArMphysOverMcalFromTuple (const std::string& name, ISvcLocator* pSvcLocator) : AthAlgorithm(name, pSvcLocator)
24{
26 declareProperty("StoreKey", m_store_key="FROMTUPLE");
27}
28
30= default;
31
33{
34 return StatusCode::SUCCESS ;
35}
36
37
39{
40 ATH_MSG_INFO ( "... in finalize()" );
41
42 // get LArOnlineID helper
43 const LArOnlineID* onlineHelper = nullptr;
44 ATH_CHECK( detStore()->retrieve(onlineHelper, "LArOnlineID") );
45
46 TChain* outfit = new TChain("outfit");
47 for (const std::string& s : m_root_file_names) {
48 outfit->Add(s.c_str());
49 }
50
51 // variable names as in the Ntuple
52 Int_t BarAC; // 0 = barrel C 1 = barrel A
53 Int_t FT; // feedthrough 0 - 31
54 Int_t Channel; // 0 - 14
55 Int_t Slot; // 1 -14
56 Double_t PhysOCal; // Mphys/Mcal
57 int gain = 0; // LARHIGHGAIN = 0, LARMEDIUMGAIN = 1, LARLOWGAIN = 2,
58
59 outfit->SetBranchAddress("Channel", &Channel);
60 outfit->SetBranchAddress("Slot", &Slot);
61 outfit->SetBranchAddress("FT", &FT);
62 outfit->SetBranchAddress("BarAC", &BarAC);
63 outfit->SetBranchAddress("PhysOCal", &PhysOCal);
64
65
66 // Create new LArMphysOverMcalComplete
68// container->setGroupingType(LArConditionsContainerBase::FeedThroughGrouping);
70 ATH_CHECK( container->initialize() );
71
72
73
74
75 // loop over entries in the Tuple, one entry = one channel
76 Long64_t nentries = outfit->GetEntries();
77 for ( Int_t i = 0; i < nentries; i++ )
78 {
79 outfit->GetEntry(i);
80 HWIdentifier id = onlineHelper->channel_Id(0, BarAC, FT, Slot, Channel);
81 container->set(id,gain,PhysOCal);
82 }
83
84
85 // store
87 // Symlink LArMphysOverMcalComplete to ILArMphysOverMcal for further use
88 ILArMphysOverMcal *larMphysOverMcal = nullptr;
89 ATH_CHECK( detStore()->symLink(container,larMphysOverMcal) );
90
91 ATH_MSG_INFO ( "LArMphysOverMcalyFromTuple finalized!" );
92
93 return StatusCode::SUCCESS;
94}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
This class implements the ILArMphysOverMcal interface.
LArMphysOverMcalFromTuple(const std::string &name, ISvcLocator *pSvcLocator)
std::string m_store_key
key of the PhysWave collection in StoreGate
std::vector< std::string > m_root_file_names
list of input ntuple file names
StatusCode initialize()
implements IAlgorithm::initialize()
HWIdentifier channel_Id(int barrel_ec, int pos_neg, int feedthrough, int slot, int channel) const
create channel identifier from fields