ATLAS Offline Software
Loading...
Searching...
No Matches
LArRodEncoder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Implementation of LArRodEncoder class
7#include "CaloDetDescr/CaloDetDescrElement.h"
8#include "GaudiKernel/Bootstrap.h"
9#include "GaudiKernel/ISvcLocator.h"
10#include "GaudiKernel/IToolSvc.h"
12#include "eformat/Version.h"
13#include <cstdio>
14#include <stdio.h>
16
17
18// constructor
20 const CaloDetDescrManager& calodd,
21 const LArOnOffIdMapping& onOffIdMapping,
22 LArRodBlockStructure* BlStruct)
23 : m_onlineHelper (onlineHelper),
24 m_CaloDetDescrManager (calodd),
25 m_onOffIdMapping (onOffIdMapping),
26 m_BlStruct (BlStruct)
27{
28}
29
30// destructor
35
36// Add LArRawChannel
38{
39 uint32_t FEB_ID = (m_onlineHelper.feb_Id(rc->channelID()).get_identifier32().get_compact());
40 if ( m_mFEB[FEB_ID].vLArRC.empty() ){
41 m_mFEB[FEB_ID].vLArRC.resize(128,0);
42 }
43 uint32_t chan = m_BlStruct->FebToRodChannel(m_onlineHelper.channel( rc->channelID() ) );
44 m_mFEB[FEB_ID].vLArRC[chan]=rc;
45}
46
47// Add free gain digits
49{
50 uint32_t FEB_ID = (m_onlineHelper.feb_Id(dg->hardwareID()).get_identifier32().get_compact());
51 m_mFEB[FEB_ID].vLArDigit.push_back(dg);
52}
53
54
55//Add fixed gain digits
56void LArRodEncoder::add(const LArDigit* dg, const int gain)
57{
58 uint32_t FEB_ID = (m_onlineHelper.feb_Id(dg->hardwareID()).get_identifier32().get_compact());
59 m_mFEB[FEB_ID].vLArDigitFixed[gain].push_back(dg);
60}
61
62
63//Add calibration digits
64void LArRodEncoder::add(const LArCalibDigit* dg, const int gain)
65{
66 uint32_t FEB_ID = (m_onlineHelper.feb_Id(dg->hardwareID()).get_identifier32().get_compact());
67 m_mFEB[FEB_ID].vLArCalibDigit[gain].push_back(dg);
68}
69
70
72{
73 m_mFEB.clear();
74}
75
76
77// convert all LArRawChannels and LArDigits
78// in the current list to a vector of 32bit words
79void LArRodEncoder::fillROD(std::vector<uint32_t>& v, MsgStream& logstr, const CaloNoise& noise, double nsigma)
80{
81 if (!m_BlStruct)
82 {
83 logstr << MSG::ERROR << "No LArRodBlockStructure defined! Can't encode fragment!" << endmsg;
84 return;
85 }
86 m_BlStruct->initializeFragment(v); //Makes new Fragment or splits v into existing Feb-Blocks
87 std::map<uint32_t,FebData_t>::iterator it=m_mFEB.begin();
88 std::map<uint32_t,FebData_t>::iterator it_end=m_mFEB.end();
89 // The sort alorithm for the vectors inside the data object of the map fails
90 // when I use const_iterator at this point. Don't ask me why
91 for(;it!=it_end;++it) {
92 m_BlStruct->initializeFEB(it->first); // Set FEB id
93 // ************* Energy Block *************
94 if (m_BlStruct->canSetEnergy() && it->second.vLArRC.size()>0) {
95 // compute Ex, Ey for this FEB : initialisation phase
96 {
97 double Ex=0;
98 double Ey=0;
99 double Ez=0;
100 double SumE=0;
101 Identifier myofflineID;
102
103 for (const LArRawChannel *theChannel : it->second.vLArRC) {
104 if ( theChannel != nullptr ){
105 int cId = m_onlineHelper.channel(theChannel->hardwareID());
106
107 int e=theChannel->energy();
108 uint32_t quality = theChannel->quality();
109 m_BlStruct->setNextEnergy(cId,e, theChannel->time(),
110 quality,theChannel->gain());
111
112 // you convert from hardwareID to offline channle ID hash (???)
113 myofflineID = m_onOffIdMapping.cnvToIdentifier(theChannel->hardwareID()) ;
114 const CaloDetDescrElement* caloDDE = m_CaloDetDescrManager.get_element(myofflineID);
115 // This is probably NOT what one wants. You want the cell gain!
116 double cellnoise = noise.getNoise(myofflineID,theChannel->gain());
117 if( e > (nsigma*cellnoise) && (quality != 65535 ) ){
118 double aux=caloDDE->sinTh();
119 double aux_z=tanh(caloDDE->eta());
120 Ex += e*aux*caloDDE->cosPhi();
121 Ey += e*aux*caloDDE->sinPhi();
122 Ez += e*aux_z;
123 SumE += e;
124 }
125 } // End of if to check for the LArRawChannel existence
126 } // end of chit loop
127 // Set after the loop finishes
128 m_BlStruct->setEx(Ex);
129 m_BlStruct->setEy(Ey);
130 m_BlStruct->setEz(Ez);
131 m_BlStruct->setSumE(SumE);
132 }
133 }//End canSetEnergy
134 // try to include samples together with data
135 if (m_BlStruct->canIncludeRawData() && it->second.vLArDigit.size()>0) {
136 // Order channels according to ROD numbering
137 m_BlStruct->sortDataVector(it->second.vLArDigit);
138 for (const LArDigit* digit : it->second.vLArDigit) {
139 int cId = m_onlineHelper.channel(digit->hardwareID());
140 m_BlStruct->setRawData(cId, digit->samples(), digit->gain());
141 } // end of for digits
142 } // End of can Include Raw Data check
143 // ************** Raw Data Block ***********
144 if (m_BlStruct->canSetRawData() && it->second.vLArDigit.size()>0) {
145 m_BlStruct->sortDataVector(it->second.vLArDigit);
146 std::vector<const LArDigit*>::const_iterator digit_it = it->second.vLArDigit.begin();
147 std::vector<const LArDigit*>::const_iterator digit_it_end=it->second.vLArDigit.end();
148 if(digit_it!=digit_it_end) { //Container not empty
149 m_BlStruct->setNumberOfSamples((*digit_it)->samples().size());
150 for (;digit_it!=digit_it_end;++digit_it) {
151 int cId = m_onlineHelper.channel((*digit_it)->hardwareID());
152 m_BlStruct->setRawData(cId, (*digit_it)->samples(), (*digit_it)->gain());
153 }
154 }// end container not empty
155 }// end if can set raw data
156
157 // ************** Fixed Gain Data Block ***********
158 if (m_BlStruct->canSetRawDataFixed()) {
159 for (int i=0;i<3;i++) { //Loop over three gains
160 m_BlStruct->sortDataVector(it->second.vLArDigitFixed[i]);
161 std::vector<const LArDigit*>::const_iterator digit_it = it->second.vLArDigitFixed[i].begin();
162 std::vector<const LArDigit*>::const_iterator digit_it_end=it->second.vLArDigitFixed[i].end();
163 if(digit_it!=digit_it_end) {//Container not empty
164 m_BlStruct->setNumberOfSamples((*digit_it)->samples().size());
165 for (;digit_it!=digit_it_end;++digit_it) {
166 int cId = m_onlineHelper.channel((*digit_it)->hardwareID());
167 m_BlStruct->setRawDataFixed(cId, (*digit_it)->samples(), (*digit_it)->gain());
168 }
169 } //end Container not empty
170 } // end loop over three gains
171 } // end can set raw data fixed
172
173 // ************** Calibration Digit Block ***********
174 if (m_BlStruct->canSetCalibration()) {
175 for (int i=0;i<3;i++) { //Loop over three gains
176 m_BlStruct->sortDataVector(it->second.vLArCalibDigit[i]);
177 std::vector<const LArCalibDigit*>::const_iterator digit_it = it->second.vLArCalibDigit[i].begin();
178 std::vector<const LArCalibDigit*>::const_iterator digit_it_end=it->second.vLArCalibDigit[i].end();
179 if(digit_it!=digit_it_end) {//Container not empty
180 m_BlStruct->setNumberOfSamples((*digit_it)->samples().size());
181 m_BlStruct->setDelay((*digit_it)->delay());
182 m_BlStruct->setDAC((*digit_it)->DAC());
183 for (;digit_it!=digit_it_end;++digit_it) {
184 int cId = m_onlineHelper.channel((*digit_it)->hardwareID());
185 m_BlStruct->setRawDataFixed(cId, (*digit_it)->samples(), (*digit_it)->gain());
186 if ((*digit_it)->isPulsed())
187 m_BlStruct->setPulsed(cId);
188 }
189 } //End Container not empty
190 }// end loop over three gains
191 } //end can set calibration
192
193 m_BlStruct->finalizeFEB();
194 }// end iterating over FEB-map
195 m_BlStruct->concatinateFEBs();
196}
#define endmsg
static Double_t rc
This class groups all DetDescr information related to a CaloCell.
float cosPhi() const
for fast px py pz computation
float sinTh() const
for algorithm working in transverse Energy
float sinPhi() const
for fast px py pz computation
This class provides the client interface for accessing the detector description information common to...
Base class for LArDigits taken during calibration runs.
Liquid Argon digit base class.
Definition LArDigit.h:25
Liquid Argon ROD output object base class.
const HWIdentifier & hardwareID() const
CaloGain::CaloGain gain() const
int time() const
uint16_t quality() const
int energy() const
void add(const LArRawChannel *rc)
const LArOnlineID & m_onlineHelper
void fillROD(std::vector< uint32_t > &v, MsgStream &logstr, const CaloNoise &noise, double nsigma)
const CaloDetDescrManager & m_CaloDetDescrManager
std::map< uint32_t, FebData_t > m_mFEB
LArRodEncoder(const LArOnlineID &onlineHelper, const CaloDetDescrManager &calodd, const LArOnOffIdMapping &onOffIdMapping, LArRodBlockStructure *BlStruct)
LArRodBlockStructure * m_BlStruct
const LArOnOffIdMapping & m_onOffIdMapping