CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 18 of file DTDigiToRaw.h.

Member Typedef Documentation

typedef unsigned int DTDigiToRaw::Word32
private

Definition at line 34 of file DTDigiToRaw.h.

typedef long long DTDigiToRaw::Word64
private

Definition at line 35 of file DTDigiToRaw.h.

Constructor & Destructor Documentation

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 {
12 
13  debug = pset.getUntrackedParameter<bool>("debugMode", false);
14  if (debug) cout << "[DTDigiToRaw]: constructor" << endl;
15 }
T getUntrackedParameter(std::string const &, T const &) const
const edm::ParameterSet pset
Definition: DTDigiToRaw.h:36
tuple cout
Definition: gather_cfg.py:121
DTDigiToRaw::~DTDigiToRaw ( )
virtual

Destructor.

Definition at line 18 of file DTDigiToRaw.cc.

References gather_cfg::cout, and debug.

18  {
19  if (debug) cout << "[DTDigiToRaw]: destructor" << endl;
20 }
tuple cout
Definition: gather_cfg.py:121

Member Function Documentation

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

Take a vector of digis and fill the FEDRawDataCollection.

Definition at line 23 of file DTDigiToRaw.cc.

References begin, cscd2r::chamberID(), DTSuperLayerId::chamberId(), gather_cfg::cout, FEDRawData::data(), dduID_, debug, end, DTROSWordType::headerControlWord, i, DTLayerId::layer(), funct::pow(), DTROSWordType::rosTypeWord, DTChamberId::sector(), DTROBHeaderWord::set(), DTROBTrailerWord::set(), DTTDCMeasurementWord::set(), DTChamberId::station(), relativeConstraints::station, DTSuperLayerId::superlayer(), DTLayerId::superlayerId(), DTTDCMeasurementWord::tdcChannel(), DTTDCMeasurementWord::tdcID(), DTTDCMeasurementWord::tdcTime(), DTROSWordType::trailerControlWord, DTChamberId::wheel(), WORDCONTROLSHIFT, and WORDTYPESHIFT.

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

Definition at line 203 of file DTDigiToRaw.cc.

References dduID_, and vdt::x.

203  {
204  dduID_ = x;
205 }
x
Definition: VDTMath.h:216

Member Data Documentation

int DTDigiToRaw::dduID_
private

Definition at line 38 of file DTDigiToRaw.h.

Referenced by createFedBuffers(), and SetdduID().

bool DTDigiToRaw::debug
private

Definition at line 39 of file DTDigiToRaw.h.

Referenced by createFedBuffers(), DTDigiToRaw(), and ~DTDigiToRaw().

const edm::ParameterSet DTDigiToRaw::pset
private

Definition at line 36 of file DTDigiToRaw.h.

Referenced by DTDigiToRaw().