CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Attributes
DTDigiToRaw Class Reference

#include <DTDigiToRaw.h>

Public Member Functions

FEDRawDatacreateFedBuffers (const DTDigiCollection &digis, edm::ESHandle< DTReadOutMapping > &mapping)
 Take a vector of digis and fill the FEDRawDataCollection. More...
 
 DTDigiToRaw (const edm::ParameterSet &ps)
 Constructor. More...
 
void SetdduID (int dduid)
 
virtual ~DTDigiToRaw ()
 Destructor. More...
 

Private Types

typedef unsigned int Word32
 
typedef long long Word64
 

Private Attributes

int dduID_
 
bool debug
 
const edm::ParameterSet pset
 

Detailed Description

Definition at line 14 of file DTDigiToRaw.h.

Member Typedef Documentation

◆ Word32

typedef unsigned int DTDigiToRaw::Word32
private

Definition at line 28 of file DTDigiToRaw.h.

◆ Word64

typedef long long DTDigiToRaw::Word64
private

Definition at line 29 of file DTDigiToRaw.h.

Constructor & Destructor Documentation

◆ DTDigiToRaw()

DTDigiToRaw::DTDigiToRaw ( const edm::ParameterSet ps)

Constructor.

Definition at line 10 of file DTDigiToRaw.cc.

References gather_cfg::cout, debug, edm::ParameterSet::getUntrackedParameter(), and pset.

10  : pset(ps) {
11  debug = pset.getUntrackedParameter<bool>("debugMode", false);
12  if (debug)
13  cout << "[DTDigiToRaw]: constructor" << endl;
14 }
T getUntrackedParameter(std::string const &, T const &) const
const edm::ParameterSet pset
Definition: DTDigiToRaw.h:30

◆ ~DTDigiToRaw()

DTDigiToRaw::~DTDigiToRaw ( )
virtual

Destructor.

Definition at line 16 of file DTDigiToRaw.cc.

References gather_cfg::cout, and debug.

16  {
17  if (debug)
18  cout << "[DTDigiToRaw]: destructor" << endl;
19 }

Member Function Documentation

◆ createFedBuffers()

FEDRawData * DTDigiToRaw::createFedBuffers ( const DTDigiCollection digis,
edm::ESHandle< DTReadOutMapping > &  mapping 
)

Take a vector of digis and fill the FEDRawDataCollection.

Definition at line 21 of file DTDigiToRaw.cc.

References CSCDigiToRawAccept::chamberID(), DTSuperLayerId::chamberId(), totem::nt2::vfat::channelId(), gather_cfg::cout, dduID_, debug, mps_fire::end, DTROSWordType::headerControlWord, mps_fire::i, DTLayerId::layer(), pixelTopology::layer, genParticles_cff::map, funct::pow(), l1tstage2_dqm_sourceclient-live_cfg::rawData, DTROSWordType::rosTypeWord, hgcalTBTopologyTester_cfi::sector, DTROBHeaderWord::set(), DTROBTrailerWord::set(), DTTDCMeasurementWord::set(), relativeConstraints::station, CSCDetId::station(), DTSuperLayerId::superlayer(), DTLayerId::superlayerId(), DTTDCMeasurementWord::tdcChannel(), DTTDCMeasurementWord::tdcID(), DTTDCMeasurementWord::tdcTime(), DTROSWordType::trailerControlWord, makeMuonMisalignmentScenario::wheel, WORDCONTROLSHIFT, and WORDTYPESHIFT.

21  {
22  int NROS = 12;
23  int NROB = 25;
24 
25  vector<uint32_t> words;
26 
28  << WORDTYPESHIFT;
29 
31  << WORDTYPESHIFT;
32 
33  int NWords = 2;
34  words.push_back(0);
35  words.push_back(0);
36 
37  int NTDCMeaWords = 0;
38 
39  int NLayers = 0;
40  int NDigis = 0;
41 
43  detUnitIt = digis.begin();
44 
45  bool b_ros[12] = {false, false, false, false, false, false, false, false, false, false, false, false};
46  vector<uint32_t> w_ROBROS[12][25];
47 
48  for (detUnitIt = digis.begin(); detUnitIt != digis.end(); ++detUnitIt) {
49  NLayers++;
50 
51  const DTLayerId layerId = (*detUnitIt).first;
52  const DTDigiCollection::Range& digiRange = (*detUnitIt).second;
53  // Loop over all digis in the given range
54 
55  for (DTDigiCollection::const_iterator digi = digiRange.first; digi != digiRange.second; digi++) {
56  NDigis++;
57  int dduId = -1, rosId = -1, robId = -1, tdcId = -1, channelId = -1;
58 
59  int layer = layerId.layer();
60  DTSuperLayerId superlayerID = layerId.superlayerId();
61  int superlayer = superlayerID.superlayer();
62  DTChamberId chamberID = superlayerID.chamberId();
63  int station = chamberID.station();
64  int wheel = chamberID.wheel();
65  int sector = chamberID.sector();
66 
67  int searchstatus = map->geometryToReadOut(wheel,
68  station,
69  sector,
70  superlayer,
71  layer,
72  (*digi).wire(), //"input"
73  dduId,
74  rosId,
75  robId,
76  tdcId,
77  channelId); //"output"
78 
79  if (searchstatus == 1 && debug)
80  cout << "[DTDigiToRaw]: warning, geometryToReadOut status = 1" << endl;
81 
82  //create FED corresponding to current ddu
83  if (dduID_ != dduId)
84  continue;
85 
86  DTTDCMeasurementWord dttdc_mw;
87  uint32_t word;
88  int ntdc = (*digi).countsTDC();
89  dttdc_mw.set(word, 0, 0, 0, tdcId, channelId, ntdc * 4); //FIXME
90 
91  //provisional fix
92  DTTDCMeasurementWord tdcMeasurementWord(word);
93  int tdcIDCheck = tdcMeasurementWord.tdcID();
94  int tdcChannelCheck = tdcMeasurementWord.tdcChannel();
95  int tdcCountsCheck = tdcMeasurementWord.tdcTime();
96  if (tdcIDCheck == tdcId && channelId == tdcChannelCheck && ntdc == tdcCountsCheck) {
97  if (rosId <= NROS && rosId > 0)
98  b_ros[rosId - 1] = true;
99  else if (debug) {
100  cout << "[DTDigiToRaw]: invalid value for rosId" << endl;
101  }
102 
103  NTDCMeaWords++;
104  w_ROBROS[rosId - 1][robId].push_back(word);
105  }
106  }
107  }
108 
109  uint32_t therosList = 0;
110  for (int i_ros = 0; i_ros < NROS; i_ros++) {
111  if (b_ros[i_ros])
112  therosList += uint32_t(pow(2.0, i_ros));
113  }
114 
115  if (debug)
116  cout << "[DTDigiToRaw]: therosList = " << therosList << endl;
117 
118  for (int i_ros = 0; i_ros < NROS; i_ros++) {
119  if (b_ros[i_ros]) {
120  words.push_back(fakeROSHeaderWord);
121  NWords++;
122  }
123 
124  for (int i_rob = 0; i_rob < NROB; i_rob++) {
125  vector<uint32_t>::const_iterator i_robros;
126  if (w_ROBROS[i_ros][i_rob].begin() != w_ROBROS[i_ros][i_rob].end()) {
127  uint32_t word = 0;
128  DTROBHeaderWord rob_header;
129  rob_header.set(word, i_rob, 0, 0);
130  //static void set(uint32_t &word, int rob_id, int event_id, int bunch_id)
131  words.push_back(word);
132  NWords++;
133 
134  int n_robros = 0;
135  for (i_robros = w_ROBROS[i_ros][i_rob].begin(); i_robros != w_ROBROS[i_ros][i_rob].end(); i_robros++) {
136  NWords++;
137  words.push_back((*i_robros));
138  n_robros++;
139  }
140 
141  NWords++;
142  DTROBTrailerWord rob_trailer;
143  rob_trailer.set(word, i_rob, 0, n_robros + 2);
144  //static void set(uint32_t &word, int rob_id, int event_id, int word_count)
145  words.push_back(word);
146  }
147  }
148 
149  if (b_ros[i_ros]) {
150  words.push_back(fakeROSTrailerWord);
151  NWords++;
152  }
153  }
154 
155  if (NWords % 2 == 1) {
156  words.push_back(0);
157  NWords++;
158  }
159 
160  words.push_back(0);
161  words.push_back(0);
162  //include rosList in raw data information
163  uint32_t secondstatusword = therosList << 16;
164  words.push_back(secondstatusword);
165 
166  words.push_back(0);
167  words.push_back(0);
168  words.push_back(0);
169 
170  // Write Raw Data
171  int dataSize = words.size() * sizeof(Word32);
172  FEDRawData* rawData = new FEDRawData(dataSize);
173  Word64* word64 = reinterpret_cast<Word64*>(rawData->data());
174  for (unsigned int i = 0; i < words.size(); i += 2) {
175  *word64 = (Word64(words[i]) << 32) | words[i + 1];
176  word64++;
177  }
178 
179  return rawData;
180 }
#define WORDCONTROLSHIFT
Definition: DTDDUWords.h:11
static void set(uint32_t &word, int rob_id, int event_id, int bunch_id)
Definition: DTDDUWords.h:357
static const uint32_t trailerControlWord
Definition: DTDDUWords.h:180
static void set(uint32_t &word, int rob_id, int event_id, int word_count)
Definition: DTDDUWords.h:389
unsigned int Word32
Definition: DTDigiToRaw.h:28
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
uint64_t word
DTChamberId chamberId() const
Return the corresponding ChamberId.
CSCDetId chamberID(const CSCDetId &cscDetId)
#define WORDTYPESHIFT
Definition: DTDDUWords.h:13
long long Word64
Definition: DTDigiToRaw.h:29
int superlayer() const
Return the superlayer number (deprecated method name)
int station() const
Definition: CSCDetId.h:79
uint8_t channelId(const VFATFrame &frame)
retrieve this channel identifier
std::pair< const_iterator, const_iterator > Range
static const uint32_t rosTypeWord
Word Type bits definitions.
Definition: DTDDUWords.h:188
std::vector< DigiType >::const_iterator const_iterator
static void set(uint32_t &word, int pc, int paf, int hu, int tdc_id, int tdc_channel, int tdc_time)
Definition: DTDDUWords.h:494
int layer() const
Return the layer number.
Definition: DTLayerId.h:42
static const uint32_t headerControlWord
Control bits definitions.
Definition: DTDDUWords.h:179
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:45
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
cms_uint64_t Word64

◆ SetdduID()

void DTDigiToRaw::SetdduID ( int  dduid)

Definition at line 182 of file DTDigiToRaw.cc.

References dduID_, and x.

182 { dduID_ = x; }

Member Data Documentation

◆ dduID_

int DTDigiToRaw::dduID_
private

Definition at line 32 of file DTDigiToRaw.h.

Referenced by createFedBuffers(), and SetdduID().

◆ debug

bool DTDigiToRaw::debug
private

◆ pset

const edm::ParameterSet DTDigiToRaw::pset
private