CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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(), gather_cfg::cout, dduID_, debug, mps_fire::end, DTROSWordType::headerControlWord, mps_fire::i, nano_mu_digi_cff::layer, DTLayerId::layer(), genParticles_cff::map, funct::pow(), l1tstage2_dqm_sourceclient-live_cfg::rawData, DTROSWordType::rosTypeWord, nano_mu_digi_cff::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 
38  detUnitIt = digis.begin();
39 
40  bool b_ros[12] = {false, false, false, false, false, false, false, false, false, false, false, false};
41  vector<uint32_t> w_ROBROS[12][25];
42 
43  for (detUnitIt = digis.begin(); detUnitIt != digis.end(); ++detUnitIt) {
44  const DTLayerId layerId = (*detUnitIt).first;
45  const DTDigiCollection::Range& digiRange = (*detUnitIt).second;
46  // Loop over all digis in the given range
47 
48  for (DTDigiCollection::const_iterator digi = digiRange.first; digi != digiRange.second; digi++) {
49  int dduId = -1, rosId = -1, robId = -1, tdcId = -1, channelId = -1;
50 
51  int layer = layerId.layer();
52  DTSuperLayerId superlayerID = layerId.superlayerId();
53  int superlayer = superlayerID.superlayer();
54  DTChamberId chamberID = superlayerID.chamberId();
55  int station = chamberID.station();
56  int wheel = chamberID.wheel();
57  int sector = chamberID.sector();
58 
59  int searchstatus = map->geometryToReadOut(wheel,
60  station,
61  sector,
62  superlayer,
63  layer,
64  (*digi).wire(), //"input"
65  dduId,
66  rosId,
67  robId,
68  tdcId,
69  channelId); //"output"
70 
71  if (searchstatus == 1 && debug)
72  cout << "[DTDigiToRaw]: warning, geometryToReadOut status = 1" << endl;
73 
74  //create FED corresponding to current ddu
75  if (dduID_ != dduId)
76  continue;
77 
78  DTTDCMeasurementWord dttdc_mw;
79  uint32_t word;
80  int ntdc = (*digi).countsTDC();
81  dttdc_mw.set(word, 0, 0, 0, tdcId, channelId, ntdc * 4); //FIXME
82 
83  //provisional fix
84  DTTDCMeasurementWord tdcMeasurementWord(word);
85  int tdcIDCheck = tdcMeasurementWord.tdcID();
86  int tdcChannelCheck = tdcMeasurementWord.tdcChannel();
87  int tdcCountsCheck = tdcMeasurementWord.tdcTime();
88  if (tdcIDCheck == tdcId && channelId == tdcChannelCheck && ntdc == tdcCountsCheck) {
89  if (rosId <= NROS && rosId > 0)
90  b_ros[rosId - 1] = true;
91  else if (debug) {
92  cout << "[DTDigiToRaw]: invalid value for rosId" << endl;
93  }
94 
95  w_ROBROS[rosId - 1][robId].push_back(word);
96  }
97  }
98  }
99 
100  uint32_t therosList = 0;
101  for (int i_ros = 0; i_ros < NROS; i_ros++) {
102  if (b_ros[i_ros])
103  therosList += uint32_t(pow(2.0, i_ros));
104  }
105 
106  if (debug)
107  cout << "[DTDigiToRaw]: therosList = " << therosList << endl;
108 
109  for (int i_ros = 0; i_ros < NROS; i_ros++) {
110  if (b_ros[i_ros]) {
111  words.push_back(fakeROSHeaderWord);
112  NWords++;
113  }
114 
115  for (int i_rob = 0; i_rob < NROB; i_rob++) {
116  vector<uint32_t>::const_iterator i_robros;
117  if (w_ROBROS[i_ros][i_rob].begin() != w_ROBROS[i_ros][i_rob].end()) {
118  uint32_t word = 0;
119  DTROBHeaderWord rob_header;
120  rob_header.set(word, i_rob, 0, 0);
121  //static void set(uint32_t &word, int rob_id, int event_id, int bunch_id)
122  words.push_back(word);
123  NWords++;
124 
125  int n_robros = 0;
126  for (i_robros = w_ROBROS[i_ros][i_rob].begin(); i_robros != w_ROBROS[i_ros][i_rob].end(); i_robros++) {
127  NWords++;
128  words.push_back((*i_robros));
129  n_robros++;
130  }
131 
132  NWords++;
133  DTROBTrailerWord rob_trailer;
134  rob_trailer.set(word, i_rob, 0, n_robros + 2);
135  //static void set(uint32_t &word, int rob_id, int event_id, int word_count)
136  words.push_back(word);
137  }
138  }
139 
140  if (b_ros[i_ros]) {
141  words.push_back(fakeROSTrailerWord);
142  NWords++;
143  }
144  }
145 
146  if (NWords % 2 == 1) {
147  words.push_back(0);
148  NWords++;
149  }
150 
151  words.push_back(0);
152  words.push_back(0);
153  //include rosList in raw data information
154  uint32_t secondstatusword = therosList << 16;
155  words.push_back(secondstatusword);
156 
157  words.push_back(0);
158  words.push_back(0);
159  words.push_back(0);
160 
161  // Write Raw Data
162  int dataSize = words.size() * sizeof(Word32);
163  FEDRawData* rawData = new FEDRawData(dataSize);
164  Word64* word64 = reinterpret_cast<Word64*>(rawData->data());
165  for (unsigned int i = 0; i < words.size(); i += 2) {
166  *word64 = (Word64(words[i]) << 32) | words[i + 1];
167  word64++;
168  }
169 
170  return rawData;
171 }
#define WORDCONTROLSHIFT
Definition: DTDDUWords.h:11
static void set(uint32_t &word, int rob_id, int event_id, int bunch_id)
Definition: DTDDUWords.h:345
static const uint32_t trailerControlWord
Definition: DTDDUWords.h:178
static void set(uint32_t &word, int rob_id, int event_id, int word_count)
Definition: DTDDUWords.h:375
unsigned int Word32
Definition: DTDigiToRaw.h:28
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
std::pair< const_iterator, const_iterator > Range
static const uint32_t rosTypeWord
Word Type bits definitions.
Definition: DTDDUWords.h:186
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:474
int layer() const
Return the layer number.
Definition: DTLayerId.h:45
static const uint32_t headerControlWord
Control bits definitions.
Definition: DTDDUWords.h:177
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:48
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 173 of file DTDigiToRaw.cc.

References dduID_, and x.

173 { 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