ATLAS Offline Software
Loading...
Searching...
No Matches
LArRodEncoder Class Reference

This class provides conversion from LArRawChannel and LArDigit to ROD format. More...

#include <LArRodEncoder.h>

Collaboration diagram for LArRodEncoder:

Classes

struct  FebData_t

Public Member Functions

 LArRodEncoder (const LArOnlineID &onlineHelper, const CaloDetDescrManager &calodd, const LArOnOffIdMapping &onOffIdMapping, LArRodBlockStructure *BlStruct)
 ~LArRodEncoder ()
void add (const LArRawChannel *rc)
void add (const LArDigit *digit)
void add (const LArDigit *dg, const int gain)
void add (const LArCalibDigit *dg, const int gain)
void clear ()
void fillROD (std::vector< uint32_t > &v, MsgStream &logstr, const CaloNoise &noise, double nsigma)

Private Attributes

std::map< uint32_t, FebData_tm_mFEB
const LArOnlineIDm_onlineHelper
const CaloDetDescrManagerm_CaloDetDescrManager
const LArOnOffIdMappingm_onOffIdMapping
LArRodBlockStructurem_BlStruct

Detailed Description

This class provides conversion from LArRawChannel and LArDigit to ROD format.

Author
H. Ma
Version
0-0-1 , Oct 7, 2002

Modified, Jan 02, 2003 Split from LArROD_Decoder.

Modified, Jul 08 2003 Walter Lampl Read ByteStream for LArDigits and LArRawChannel

Modified, Jul 17 2003 Remi Lafaye Split with LArRODBlockStructure

  • LArROD_Encoder = Athena world only
  • LArRODBlockStructure = ROD format only It might be less CPU efficient Althought it will be easier to update

Modified, Nov 10 2005 D.O. Damazio New LArRodBlockPhysics (Bertrand Laforge format).

Definition at line 54 of file LArRodEncoder.h.

Constructor & Destructor Documentation

◆ LArRodEncoder()

LArRodEncoder::LArRodEncoder ( const LArOnlineID & onlineHelper,
const CaloDetDescrManager & calodd,
const LArOnOffIdMapping & onOffIdMapping,
LArRodBlockStructure * BlStruct )

Definition at line 19 of file LArRodEncoder.cxx.

23 : m_onlineHelper (onlineHelper),
24 m_CaloDetDescrManager (calodd),
25 m_onOffIdMapping (onOffIdMapping),
26 m_BlStruct (BlStruct)
27{
28}
const LArOnlineID & m_onlineHelper
const CaloDetDescrManager & m_CaloDetDescrManager
LArRodBlockStructure * m_BlStruct
const LArOnOffIdMapping & m_onOffIdMapping

◆ ~LArRodEncoder()

LArRodEncoder::~LArRodEncoder ( )

Definition at line 31 of file LArRodEncoder.cxx.

32{
33 clear();
34}

Member Function Documentation

◆ add() [1/4]

void LArRodEncoder::add ( const LArCalibDigit * dg,
const int gain )

Definition at line 61 of file LArRodEncoder.cxx.

62{
63 uint32_t FEB_ID = (m_onlineHelper.feb_Id(dg->hardwareID()).get_identifier32().get_compact());
64 m_mFEB[FEB_ID].vLArCalibDigit[gain].push_back(dg);
65}
std::map< uint32_t, FebData_t > m_mFEB
setEventNumber uint32_t

◆ add() [2/4]

void LArRodEncoder::add ( const LArDigit * dg,
const int gain )

Definition at line 55 of file LArRodEncoder.cxx.

56{
57 uint32_t FEB_ID = (m_onlineHelper.feb_Id(dg->hardwareID()).get_identifier32().get_compact());
58 m_mFEB[FEB_ID].vLArDigitFixed[gain].push_back(dg);
59}

◆ add() [3/4]

void LArRodEncoder::add ( const LArDigit * digit)

Definition at line 49 of file LArRodEncoder.cxx.

50{
51 uint32_t FEB_ID = (m_onlineHelper.feb_Id(dg->hardwareID()).get_identifier32().get_compact());
52 m_mFEB[FEB_ID].vLArDigit.push_back(dg);
53}

◆ add() [4/4]

void LArRodEncoder::add ( const LArRawChannel * rc)

Definition at line 37 of file LArRodEncoder.cxx.

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 //for(int i=0;i<128;i++) m_mFEB[FEB_ID].vLArRC.push_back(0);
43 }
44 uint32_t chan = m_BlStruct->FebToRodChannel(m_onlineHelper.channel( rc->channelID() ) );
45 m_mFEB[FEB_ID].vLArRC[chan]=rc;
46}
static Double_t rc

◆ clear()

void LArRodEncoder::clear ( )

Definition at line 71 of file LArRodEncoder.cxx.

72{
73 m_mFEB.clear();
74}

◆ fillROD()

void LArRodEncoder::fillROD ( std::vector< uint32_t > & v,
MsgStream & logstr,
const CaloNoise & noise,
double nsigma )

Definition at line 78 of file LArRodEncoder.cxx.

79{
80 if (!m_BlStruct)
81 {logstr << MSG::ERROR << "No LArRodBlockStructure defined! Can't encode fragment!" << endmsg;
82 return;
83 }
84 //int febcounter=0;
85 //std::cout << "Going to init Fragment..." << std::endl;
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 //std::cout << "Have " << m_mFEB.size() << " FEBs in this ROD" << std::endl;
92 for(;it!=it_end;++it) {
93 //std::cout << "Setting values for feb # " << febcounter << " ID=" << it->first << std::endl;
94 m_BlStruct->initializeFEB(it->first); // Set FEB id
95 //std::cout << "Setting Energy" << std::endl;
96 // ************* Energy Block *************
97 if (m_BlStruct->canSetEnergy() && it->second.vLArRC.size()>0) {
98 //int j=0;
99// m_BlStruct->sortDataVector(it->second.vLArRC);
100 // compute Ex, Ey for this FEB : initialisation phase
101
102 {
103 double Ex=0;
104 double Ey=0;
105 double Ez=0;
106 double SumE=0;
107 Identifier myofflineID;
108
109 for (const LArRawChannel *theChannel : it->second.vLArRC) {
110 if ( theChannel != nullptr ){
111 int cId = m_onlineHelper.channel(theChannel->hardwareID());
112
113 int e=theChannel->energy();
114 uint32_t quality = theChannel->quality();
115 m_BlStruct->setNextEnergy(cId,e, theChannel->time(),
116 quality,theChannel->gain());
117
118 // you convert from hardwareID to offline channle ID hash (???)
119 myofflineID = m_onOffIdMapping.cnvToIdentifier(theChannel->hardwareID()) ;
120 //std::cout << "Got Offile id 0x" << std::hex << myofflineID.get_compact() << std::dec << std::endl;
121 const CaloDetDescrElement* caloDDE = m_CaloDetDescrManager.get_element(myofflineID);
122 // This is probably NOT what one wants. You want the cell gain!
123 double cellnoise = noise.getNoise(myofflineID,theChannel->gain());
124 if( e > (nsigma*cellnoise) && (quality != 65535 ) ){
125 double aux=caloDDE->sinTh();
126 double aux_z=tanh(caloDDE->eta());
127 Ex += e*aux*caloDDE->cosPhi();
128 Ey += e*aux*caloDDE->sinPhi();
129 Ez += e*aux_z;
130 SumE += e;
131 }
132 } // End of if to check for the LArRawChannel existence
133 } // end of chit loop
134 // Set after the loop finishes
135 m_BlStruct->setEx(Ex);
136 m_BlStruct->setEy(Ey);
137 m_BlStruct->setEz(Ez);
138 m_BlStruct->setSumE(SumE);
139 }
140 }//End canSetEnergy
141 // try to include samples together with data
142 if (m_BlStruct->canIncludeRawData() && it->second.vLArDigit.size()>0) {
143 // Order channels according to ROD numbering
144 m_BlStruct->sortDataVector(it->second.vLArDigit);
145 for (const LArDigit* digit : it->second.vLArDigit) {
146 int cId = m_onlineHelper.channel(digit->hardwareID());
147 m_BlStruct->setRawData(cId, digit->samples(), digit->gain());
148 } // end of for digits
149 } // End of can Include Raw Data check
150 //std::cout << "Setting Raw Data" << std::endl;
151 // ************** Raw Data Block ***********
152 if (m_BlStruct->canSetRawData() && it->second.vLArDigit.size()>0) {
153 //sort(it->second.vLArDigit.begin(), it->second.vLArDigit.end(), *m_BlStruct); // Order channels according to ROD numbering
154 m_BlStruct->sortDataVector(it->second.vLArDigit);
155 std::vector<const LArDigit*>::const_iterator digit_it = it->second.vLArDigit.begin();
156 std::vector<const LArDigit*>::const_iterator digit_it_end=it->second.vLArDigit.end();
157 if(digit_it!=digit_it_end) { //Container not empty
158 m_BlStruct->setNumberOfSamples((*digit_it)->samples().size());
159 for (;digit_it!=digit_it_end;++digit_it) {
160 int cId = m_onlineHelper.channel((*digit_it)->hardwareID());
161 //cId = m_BlStruct->FebToRodChannel(cId);
162 m_BlStruct->setRawData(cId, (*digit_it)->samples(), (*digit_it)->gain());
163 }
164 }// end container not empty
165 }// end if can set raw data
166
167 //std::cout << "Setting fixed gain data" << std::endl;
168 // ************** Fixed Gain Data Block ***********
169 if (m_BlStruct->canSetRawDataFixed()) {
170 for (int i=0;i<3;i++) { //Loop over three gains
171 //sort(it->second.vLArDigitFixed[i].begin(), it->second.vLArDigitFixed[i].end(), *m_BlStruct);
172 m_BlStruct->sortDataVector(it->second.vLArDigitFixed[i]);
173 std::vector<const LArDigit*>::const_iterator digit_it = it->second.vLArDigitFixed[i].begin();
174 std::vector<const LArDigit*>::const_iterator digit_it_end=it->second.vLArDigitFixed[i].end();
175 if(digit_it!=digit_it_end) {//Container not empty
176 m_BlStruct->setNumberOfSamples((*digit_it)->samples().size());
177 for (;digit_it!=digit_it_end;++digit_it) {
178 int cId = m_onlineHelper.channel((*digit_it)->hardwareID());
179 //cId = m_BlStruct->FebToRodChannel(cId);
180 m_BlStruct->setRawDataFixed(cId, (*digit_it)->samples(), (*digit_it)->gain());
181 }
182 } //end Container not empty
183 } // end loop over three gains
184 } // end can set raw data fixed
185
186 // ************** Calibration Digit Block ***********
187 if (m_BlStruct->canSetCalibration()) {
188 for (int i=0;i<3;i++) { //Loop over three gains
189 //sort(it->second.vLArCalibDigit[i].begin(), it->second.vLArCalibDigit[i].end(), *m_BlStruct);
190 m_BlStruct->sortDataVector(it->second.vLArCalibDigit[i]);
191 std::vector<const LArCalibDigit*>::const_iterator digit_it = it->second.vLArCalibDigit[i].begin();
192 std::vector<const LArCalibDigit*>::const_iterator digit_it_end=it->second.vLArCalibDigit[i].end();
193 if(digit_it!=digit_it_end) {//Container not empty
194 m_BlStruct->setNumberOfSamples((*digit_it)->samples().size());
195 m_BlStruct->setDelay((*digit_it)->delay());
196 m_BlStruct->setDAC((*digit_it)->DAC());
197 for (;digit_it!=digit_it_end;++digit_it) {
198 int cId = m_onlineHelper.channel((*digit_it)->hardwareID());
199 //cId = m_BlStruct->FebToRodChannel(cId);
200 m_BlStruct->setRawDataFixed(cId, (*digit_it)->samples(), (*digit_it)->gain());
201 if ((*digit_it)->isPulsed())
202 m_BlStruct->setPulsed(cId);
203 }
204 } //End Container not empty
205 }// end loop over three gains
206 } //end can set calibration
207
208 /*
209 // ************** Averaged Calibration Digit Block ***********
210 if (m_BlStruct->canSetAverages()) {
211 for (int i=0;i<3;i++) { //Loop over three gains
212 sort(it->second.vLArCalibDigit[i].begin(), it->second.vLArCalibDigit[i].end(), *m_BlStruct);
213 std::vector<const LArAverageDigit*>::const_iterator digit_it = it->second.vLArAverageDigit.begin();
214 std::vector<const LArAverageDigit*>::const_iterator digit_it_end=it->second.vLArAverageDigit.end();
215 if(digit_it!=digit_it_end) {//Container not empty
216 m_BlStruct->setNumberOfSamples((*digit_it)->samples().size());
217 m_BlStruct->setDAC((*digit_it)->DAC());
218 m_BlStruct->setDelay((*digit_it)->delay());
219 for (;digit_it!=digit_it_end;digit_it++) {
220 int cId = m_onOffIdMapping.channel((*digit_it)->channelID());
221 cId = m_BlStruct->FebToRodChannel(cId);
222 m_BlStruct->setRawData(cId, (*digit_it)->samples(), (*digit_it)->gain());
223 m_BlStruct->setIsPulsed(cId);
224 }
225 } //End Container not empty
226 }// end loop over three gains
227 }// can set averages
228 */
229 //std::cout << "Going to finalize FEB" << std::endl;
230 m_BlStruct->finalizeFEB();
231 }// end iterating over FEB-map
232 //std::cout << "Going to finalize ROD" << std::endl;
233 m_BlStruct->concatinateFEBs();
234 //std::cout << "final size of fragment " << v.size() << std::endl;
235 //m_BlStruct->dumpFragment(); // For testing purpose
236 return;
237}
#define endmsg
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
const HWIdentifier & hardwareID() const
CaloGain::CaloGain gain() const
int time() const
uint16_t quality() const
int energy() const

Member Data Documentation

◆ m_BlStruct

LArRodBlockStructure* LArRodEncoder::m_BlStruct
private

Definition at line 118 of file LArRodEncoder.h.

◆ m_CaloDetDescrManager

const CaloDetDescrManager& LArRodEncoder::m_CaloDetDescrManager
private

Definition at line 116 of file LArRodEncoder.h.

◆ m_mFEB

std::map<uint32_t,FebData_t> LArRodEncoder::m_mFEB
private

Definition at line 113 of file LArRodEncoder.h.

◆ m_onlineHelper

const LArOnlineID& LArRodEncoder::m_onlineHelper
private

Definition at line 115 of file LArRodEncoder.h.

◆ m_onOffIdMapping

const LArOnOffIdMapping& LArRodEncoder::m_onOffIdMapping
private

Definition at line 117 of file LArRodEncoder.h.


The documentation for this class was generated from the following files: