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//Add fixed gain digits
54void LArRodEncoder::add(const LArDigit* dg, const int gain)
55{
56 uint32_t FEB_ID = (m_onlineHelper.feb_Id(dg->hardwareID()).get_identifier32().get_compact());
57 m_mFEB[FEB_ID].vLArDigitFixed[gain].push_back(dg);
58}
59//Add calibration digits
60void LArRodEncoder::add(const LArCalibDigit* dg, const int gain)
61{
62 uint32_t FEB_ID = (m_onlineHelper.feb_Id(dg->hardwareID()).get_identifier32().get_compact());
63 m_mFEB[FEB_ID].vLArCalibDigit[gain].push_back(dg);
64}
65
66
68{
69 m_mFEB.clear();
70}
71
72
73// convert all LArRawChannels and LArDigits
74// in the current list to a vector of 32bit words
75void LArRodEncoder::fillROD(std::vector<uint32_t>& v, MsgStream& logstr, const CaloNoise& noise, double nsigma)
76{
77 if (!m_BlStruct)
78 {logstr << MSG::ERROR << "No LArRodBlockStructure defined! Can't encode fragment!" << endmsg;
79 return;
80 }
81 m_BlStruct->initializeFragment(v); //Makes new Fragment or splits v into existing Feb-Blocks
82 std::map<uint32_t,FebData_t>::iterator it=m_mFEB.begin();
83 std::map<uint32_t,FebData_t>::iterator it_end=m_mFEB.end();
84 // The sort alorithm for the vectors inside the data object of the map fails
85 // when I use const_iterator at this point. Don't ask me why
86 for(;it!=it_end;++it) {
87 m_BlStruct->initializeFEB(it->first); // Set FEB id
88 // ************* Energy Block *************
89 if (m_BlStruct->canSetEnergy() && it->second.vLArRC.size()>0) {
90 // compute Ex, Ey for this FEB : initialisation phase
91 {
92 double Ex=0;
93 double Ey=0;
94 double Ez=0;
95 double SumE=0;
96 Identifier myofflineID;
97
98 for (const LArRawChannel *theChannel : it->second.vLArRC) {
99 if ( theChannel != nullptr ){
100 int cId = m_onlineHelper.channel(theChannel->hardwareID());
101
102 int e=theChannel->energy();
103 uint32_t quality = theChannel->quality();
104 m_BlStruct->setNextEnergy(cId,e, theChannel->time(),
105 quality,theChannel->gain());
106
107 // you convert from hardwareID to offline channle ID hash (???)
108 myofflineID = m_onOffIdMapping.cnvToIdentifier(theChannel->hardwareID()) ;
109 const CaloDetDescrElement* caloDDE = m_CaloDetDescrManager.get_element(myofflineID);
110 // This is probably NOT what one wants. You want the cell gain!
111 double cellnoise = noise.getNoise(myofflineID,theChannel->gain());
112 if( e > (nsigma*cellnoise) && (quality != 65535 ) ){
113 double aux=caloDDE->sinTh();
114 double aux_z=tanh(caloDDE->eta());
115 Ex += e*aux*caloDDE->cosPhi();
116 Ey += e*aux*caloDDE->sinPhi();
117 Ez += e*aux_z;
118 SumE += e;
119 }
120 } // End of if to check for the LArRawChannel existence
121 } // end of chit loop
122 // Set after the loop finishes
123 m_BlStruct->setEx(Ex);
124 m_BlStruct->setEy(Ey);
125 m_BlStruct->setEz(Ez);
126 m_BlStruct->setSumE(SumE);
127 }
128 }//End canSetEnergy
129 // try to include samples together with data
130 if (m_BlStruct->canIncludeRawData() && it->second.vLArDigit.size()>0) {
131 // Order channels according to ROD numbering
132 m_BlStruct->sortDataVector(it->second.vLArDigit);
133 for (const LArDigit* digit : it->second.vLArDigit) {
134 int cId = m_onlineHelper.channel(digit->hardwareID());
135 m_BlStruct->setRawData(cId, digit->samples(), digit->gain());
136 } // end of for digits
137 } // End of can Include Raw Data check
138 // ************** Raw Data Block ***********
139 if (m_BlStruct->canSetRawData() && it->second.vLArDigit.size()>0) {
140 m_BlStruct->sortDataVector(it->second.vLArDigit);
141 std::vector<const LArDigit*>::const_iterator digit_it = it->second.vLArDigit.begin();
142 std::vector<const LArDigit*>::const_iterator digit_it_end=it->second.vLArDigit.end();
143 if(digit_it!=digit_it_end) { //Container not empty
144 m_BlStruct->setNumberOfSamples((*digit_it)->samples().size());
145 for (;digit_it!=digit_it_end;++digit_it) {
146 int cId = m_onlineHelper.channel((*digit_it)->hardwareID());
147 m_BlStruct->setRawData(cId, (*digit_it)->samples(), (*digit_it)->gain());
148 }
149 }// end container not empty
150 }// end if can set raw data
151
152 // ************** Fixed Gain Data Block ***********
153 if (m_BlStruct->canSetRawDataFixed()) {
154 for (int i=0;i<3;i++) { //Loop over three gains
155 m_BlStruct->sortDataVector(it->second.vLArDigitFixed[i]);
156 std::vector<const LArDigit*>::const_iterator digit_it = it->second.vLArDigitFixed[i].begin();
157 std::vector<const LArDigit*>::const_iterator digit_it_end=it->second.vLArDigitFixed[i].end();
158 if(digit_it!=digit_it_end) {//Container not empty
159 m_BlStruct->setNumberOfSamples((*digit_it)->samples().size());
160 for (;digit_it!=digit_it_end;++digit_it) {
161 int cId = m_onlineHelper.channel((*digit_it)->hardwareID());
162 m_BlStruct->setRawDataFixed(cId, (*digit_it)->samples(), (*digit_it)->gain());
163 }
164 } //end Container not empty
165 } // end loop over three gains
166 } // end can set raw data fixed
167
168 // ************** Calibration Digit Block ***********
169 if (m_BlStruct->canSetCalibration()) {
170 for (int i=0;i<3;i++) { //Loop over three gains
171 m_BlStruct->sortDataVector(it->second.vLArCalibDigit[i]);
172 std::vector<const LArCalibDigit*>::const_iterator digit_it = it->second.vLArCalibDigit[i].begin();
173 std::vector<const LArCalibDigit*>::const_iterator digit_it_end=it->second.vLArCalibDigit[i].end();
174 if(digit_it!=digit_it_end) {//Container not empty
175 m_BlStruct->setNumberOfSamples((*digit_it)->samples().size());
176 m_BlStruct->setDelay((*digit_it)->delay());
177 m_BlStruct->setDAC((*digit_it)->DAC());
178 for (;digit_it!=digit_it_end;++digit_it) {
179 int cId = m_onlineHelper.channel((*digit_it)->hardwareID());
180 m_BlStruct->setRawDataFixed(cId, (*digit_it)->samples(), (*digit_it)->gain());
181 if ((*digit_it)->isPulsed())
182 m_BlStruct->setPulsed(cId);
183 }
184 } //End Container not empty
185 }// end loop over three gains
186 } //end can set calibration
187
188 m_BlStruct->finalizeFEB();
189 }// end iterating over FEB-map
190 m_BlStruct->concatinateFEBs();
191 return;
192}
#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