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 Member Functions | Private Attributes
CSCDigiToRaw Class Reference

#include <CSCDigiToRaw.h>

Public Member Functions

void createFedBuffers (const CSCStripDigiCollection &stripDigis, const CSCWireDigiCollection &wireDigis, const CSCComparatorDigiCollection &comparatorDigis, const CSCALCTDigiCollection &alctDigis, const CSCCLCTDigiCollection &clctDigis, const CSCCLCTPreTriggerCollection &preTriggers, const CSCCorrelatedLCTDigiCollection &correlatedLCTDigis, FEDRawDataCollection &fed_buffers, const CSCChamberMap *theMapping, edm::Event &e)
 Take a vector of digis and fill the FEDRawDataCollection. More...
 
 CSCDigiToRaw (const edm::ParameterSet &pset)
 Constructor. More...
 

Private Member Functions

void add (const CSCStripDigiCollection &stripDigis, const CSCCLCTPreTriggerCollection &preTriggers)
 
void add (const CSCWireDigiCollection &wireDigis, const CSCALCTDigiCollection &alctDigis)
 
void add (const CSCComparatorDigiCollection &comparatorDigis, const CSCCLCTDigiCollection &clctDigis)
 
void add (const CSCALCTDigiCollection &alctDigis)
 
void add (const CSCCLCTDigiCollection &clctDigis)
 
void add (const CSCCorrelatedLCTDigiCollection &corrLCTDigis)
 
void beginEvent (const CSCChamberMap *electronicsMap)
 
CSCEventDatafindEventData (const CSCDetId &cscDetId)
 pick out the correct data object for this chamber More...
 

Private Attributes

int alctWindowMax_
 
int alctWindowMin_
 
int clctWindowMax_
 
int clctWindowMin_
 
int preTriggerWindowMax_
 
int preTriggerWindowMin_
 
std::map< CSCDetId, CSCEventDatatheChamberDataMap
 
const CSCChamberMaptheElectronicsMap
 

Detailed Description

Date:
2011/06/11 05:56:10
Revision:
1.12
Author
A. Tumanov - Rice

Definition at line 25 of file CSCDigiToRaw.h.

Constructor & Destructor Documentation

CSCDigiToRaw::CSCDigiToRaw ( const edm::ParameterSet pset)
explicit

Constructor.

Definition at line 89 of file CSCDigiToRaw.cc.

90 : alctWindowMin_(pset.getParameter<int>("alctWindowMin")),
91  alctWindowMax_(pset.getParameter<int>("alctWindowMax")),
92  clctWindowMin_(pset.getParameter<int>("clctWindowMin")),
93  clctWindowMax_(pset.getParameter<int>("clctWindowMax")),
94  preTriggerWindowMin_(pset.getParameter<int>("preTriggerWindowMin")),
95  preTriggerWindowMax_(pset.getParameter<int>("preTriggerWindowMax"))
96 {}
T getParameter(std::string const &) const
int clctWindowMin_
Definition: CSCDigiToRaw.h:63
int alctWindowMax_
Definition: CSCDigiToRaw.h:62
int alctWindowMin_
Definition: CSCDigiToRaw.h:61
int clctWindowMax_
Definition: CSCDigiToRaw.h:64
int preTriggerWindowMin_
Definition: CSCDigiToRaw.h:65
int preTriggerWindowMax_
Definition: CSCDigiToRaw.h:66

Member Function Documentation

void CSCDigiToRaw::add ( const CSCStripDigiCollection stripDigis,
const CSCCLCTPreTriggerCollection preTriggers 
)
private

Definition at line 123 of file CSCDigiToRaw.cc.

References cscd2r::accept(), CSCEventData::add(), CSCDetId::endcap(), findEventData(), CSCStripDigi::getStrip(), j, prof2calltree::last, CSCDetId::layer(), preTriggerWindowMax_, preTriggerWindowMin_, CSCDetId::ring(), CSCStripDigi::setStrip(), CSCDetId::station(), and SurfaceOrientation::zplus.

Referenced by add(), and createFedBuffers().

125 { //iterate over chambers with strip digis in them
126  for (CSCStripDigiCollection::DigiRangeIterator j=stripDigis.begin(); j!=stripDigis.end(); ++j)
127  {
128  CSCDetId cscDetId=(*j).first;
129  // only digitize if there are pre-triggers
130  if(cscd2r::accept(cscDetId, preTriggers, preTriggerWindowMin_, preTriggerWindowMax_))
131  {
132  bool me1a = (cscDetId.station()==1) && (cscDetId.ring()==4);
133  bool zplus = (cscDetId.endcap() == 1);
134  bool me1b = (cscDetId.station()==1) && (cscDetId.ring()==1);
135 
136  CSCEventData & cscData = findEventData(cscDetId);
137 
138  std::vector<CSCStripDigi>::const_iterator digiItr = (*j).second.first;
139  std::vector<CSCStripDigi>::const_iterator last = (*j).second.second;
140  for( ; digiItr != last; ++digiItr)
141  {
142  CSCStripDigi digi = *digiItr;
143  int strip = digi.getStrip();
144  if ( me1a && zplus ) { digi.setStrip(17-strip); } // 1-16 -> 16-1
145  if ( me1b && !zplus) { digi.setStrip(65-strip);} // 1-64 -> 64-1
146  if ( me1a ) { strip = digi.getStrip(); digi.setStrip(strip+64);} // reset back 1-16 to 65-80 digi
147  cscData.add(digi, cscDetId.layer() );
148  }
149  }
150  }
151 }
int layer() const
Definition: CSCDetId.h:63
int getStrip() const
Definition: CSCStripDigi.h:39
int endcap() const
Definition: CSCDetId.h:95
void setStrip(int istrip)
Definition: CSCStripDigi.h:53
int j
Definition: DBlmapReader.cc:9
int preTriggerWindowMin_
Definition: CSCDigiToRaw.h:65
int preTriggerWindowMax_
Definition: CSCDigiToRaw.h:66
int ring() const
Definition: CSCDetId.h:77
CSCEventData & findEventData(const CSCDetId &cscDetId)
pick out the correct data object for this chamber
void add(const CSCStripDigi &, int layer)
routines to add digis to the data
bool accept(const CSCDetId &cscId, const LCTCollection &lcts, int bxMin, int bxMax)
Definition: CSCDigiToRaw.cc:42
int station() const
Definition: CSCDetId.h:88
void CSCDigiToRaw::add ( const CSCWireDigiCollection wireDigis,
const CSCALCTDigiCollection alctDigis 
)
private

Definition at line 154 of file CSCDigiToRaw.cc.

References cscd2r::accept(), add(), CSCEventData::add(), alctWindowMax_, alctWindowMin_, findEventData(), j, prof2calltree::last, and CSCDetId::layer().

156 {
157  add(alctDigis);
158  for (CSCWireDigiCollection::DigiRangeIterator j=wireDigis.begin(); j!=wireDigis.end(); ++j)
159  {
160  CSCDetId cscDetId=(*j).first;
161  if(cscd2r::accept(cscDetId, alctDigis, alctWindowMin_, alctWindowMax_))
162  {
163  CSCEventData & cscData = findEventData(cscDetId);
164  std::vector<CSCWireDigi>::const_iterator digiItr = (*j).second.first;
165  std::vector<CSCWireDigi>::const_iterator last = (*j).second.second;
166  for( ; digiItr != last; ++digiItr)
167  {
168  cscData.add(*digiItr, cscDetId.layer() );
169  }
170  }
171  }
172 
173 }
void add(const CSCStripDigiCollection &stripDigis, const CSCCLCTPreTriggerCollection &preTriggers)
int layer() const
Definition: CSCDetId.h:63
int alctWindowMax_
Definition: CSCDigiToRaw.h:62
int alctWindowMin_
Definition: CSCDigiToRaw.h:61
int j
Definition: DBlmapReader.cc:9
CSCEventData & findEventData(const CSCDetId &cscDetId)
pick out the correct data object for this chamber
void add(const CSCStripDigi &, int layer)
routines to add digis to the data
bool accept(const CSCDetId &cscId, const LCTCollection &lcts, int bxMin, int bxMax)
Definition: CSCDigiToRaw.cc:42
void CSCDigiToRaw::add ( const CSCComparatorDigiCollection comparatorDigis,
const CSCCLCTDigiCollection clctDigis 
)
private

Definition at line 175 of file CSCDigiToRaw.cc.

References cscd2r::accept(), add(), CSCEventData::add(), clctWindowMax_, clctWindowMin_, findEventData(), CSCComparatorDigi::getComparator(), CSCComparatorDigi::getStrip(), CSCComparatorDigi::getTimeBinWord(), j, CSCDetId::layer(), CSCDetId::ring(), and CSCDetId::station().

177 {
178  add(clctDigis);
179  for (CSCComparatorDigiCollection::DigiRangeIterator j=comparatorDigis.begin(); j!=comparatorDigis.end(); ++j)
180  {
181  CSCDetId cscDetId=(*j).first;
182  CSCEventData & cscData = findEventData(cscDetId);
183  if(cscd2r::accept(cscDetId, clctDigis, clctWindowMin_, clctWindowMax_))
184  {
185  bool me1a = (cscDetId.station()==1) && (cscDetId.ring()==4);
186 
187  BOOST_FOREACH(CSCComparatorDigi digi, (*j).second)
188  {
189  // Move ME1/A comparators from CFEB=0 to CFEB=4 if this has not
190  // been done already.
191  if (me1a && digi.getStrip() <= 16) {
192  CSCComparatorDigi digi_corr(64+digi.getStrip(),
193  digi.getComparator(),
194  digi.getTimeBinWord());
195  cscData.add(digi_corr, cscDetId.layer());
196  }
197  else {
198  cscData.add(digi, cscDetId.layer());
199  }
200  }
201  }
202  }
203 }
void add(const CSCStripDigiCollection &stripDigis, const CSCCLCTPreTriggerCollection &preTriggers)
int getStrip() const
Get the strip number.
int clctWindowMin_
Definition: CSCDigiToRaw.h:63
int getComparator() const
Get Comparator readings.
int layer() const
Definition: CSCDetId.h:63
int j
Definition: DBlmapReader.cc:9
int getTimeBinWord() const
Return the word with each bit corresponding to a time bin.
int clctWindowMax_
Definition: CSCDigiToRaw.h:64
int ring() const
Definition: CSCDetId.h:77
CSCEventData & findEventData(const CSCDetId &cscDetId)
pick out the correct data object for this chamber
void add(const CSCStripDigi &, int layer)
routines to add digis to the data
bool accept(const CSCDetId &cscId, const LCTCollection &lcts, int bxMin, int bxMax)
Definition: CSCDigiToRaw.cc:42
int station() const
Definition: CSCDetId.h:88
void CSCDigiToRaw::add ( const CSCALCTDigiCollection alctDigis)
private

Definition at line 205 of file CSCDigiToRaw.cc.

References CSCEventData::add(), findEventData(), and j.

206 {
207  for (CSCALCTDigiCollection::DigiRangeIterator j=alctDigis.begin(); j!=alctDigis.end(); ++j)
208  {
209  CSCDetId cscDetId=(*j).first;
210  CSCEventData & cscData = findEventData(cscDetId);
211 
212  cscData.add(std::vector<CSCALCTDigi>((*j).second.first, (*j).second.second));
213  }
214 }
int j
Definition: DBlmapReader.cc:9
CSCEventData & findEventData(const CSCDetId &cscDetId)
pick out the correct data object for this chamber
void add(const CSCStripDigi &, int layer)
routines to add digis to the data
void CSCDigiToRaw::add ( const CSCCLCTDigiCollection clctDigis)
private

Definition at line 216 of file CSCDigiToRaw.cc.

References CSCEventData::add(), findEventData(), and j.

217 {
218  for (CSCCLCTDigiCollection::DigiRangeIterator j=clctDigis.begin(); j!=clctDigis.end(); ++j)
219  {
220  CSCDetId cscDetId=(*j).first;
221  CSCEventData & cscData = findEventData(cscDetId);
222 
223  cscData.add(std::vector<CSCCLCTDigi>((*j).second.first, (*j).second.second));
224  }
225 }
int j
Definition: DBlmapReader.cc:9
CSCEventData & findEventData(const CSCDetId &cscDetId)
pick out the correct data object for this chamber
void add(const CSCStripDigi &, int layer)
routines to add digis to the data
void CSCDigiToRaw::add ( const CSCCorrelatedLCTDigiCollection corrLCTDigis)
private

Definition at line 227 of file CSCDigiToRaw.cc.

References CSCEventData::add(), findEventData(), and j.

228 {
229  for (CSCCorrelatedLCTDigiCollection::DigiRangeIterator j=corrLCTDigis.begin(); j!=corrLCTDigis.end(); ++j)
230  {
231  CSCDetId cscDetId=(*j).first;
232  CSCEventData & cscData = findEventData(cscDetId);
233 
234  cscData.add(std::vector<CSCCorrelatedLCTDigi>((*j).second.first, (*j).second.second));
235  }
236 
237 }
int j
Definition: DBlmapReader.cc:9
CSCEventData & findEventData(const CSCDetId &cscDetId)
pick out the correct data object for this chamber
void add(const CSCStripDigi &, int layer)
routines to add digis to the data
void CSCDigiToRaw::beginEvent ( const CSCChamberMap electronicsMap)
private

Definition at line 98 of file CSCDigiToRaw.cc.

References ecaldqm::electronicsMap, theChamberDataMap, and theElectronicsMap.

Referenced by createFedBuffers().

99 {
100  theChamberDataMap.clear();
102 }
const EcalElectronicsMapping * electronicsMap
const CSCChamberMap * theElectronicsMap
Definition: CSCDigiToRaw.h:60
std::map< CSCDetId, CSCEventData > theChamberDataMap
Definition: CSCDigiToRaw.h:59
void CSCDigiToRaw::createFedBuffers ( const CSCStripDigiCollection stripDigis,
const CSCWireDigiCollection wireDigis,
const CSCComparatorDigiCollection comparatorDigis,
const CSCALCTDigiCollection alctDigis,
const CSCCLCTDigiCollection clctDigis,
const CSCCLCTPreTriggerCollection preTriggers,
const CSCCorrelatedLCTDigiCollection correlatedLCTDigis,
FEDRawDataCollection fed_buffers,
const CSCChamberMap theMapping,
edm::Event e 
)

Take a vector of digis and fill the FEDRawDataCollection.

Definition at line 240 of file CSCDigiToRaw.cc.

References add(), beginEvent(), bitset_utilities::bitsetToChar(), evf::compute_crc(), FEDRawData::data(), CSCChamberMap::ddu(), CSCChamberMap::dduInput(), CSCChamberMap::dduSlot(), CSCChamberMap::dmb(), edm::EventID::event(), edm::hlt::Exception, FEDRawDataCollection::FEDData(), edm::EventBase::id(), FEDNumbering::MAXCSCFEDID, FEDNumbering::MINCSCFEDID, FEDRawData::resize(), FEDRawData::size(), CSCChamberMap::slink(), and theChamberDataMap.

Referenced by CSCDigiToRawModule::produce().

250 {
251 
252  //bits of code from ORCA/Muon/METBFormatter - thanks, Rick:)!
253 
254  //get fed object from fed_buffers
255  // make a map from the index of a chamber to the event data from it
256  beginEvent(mapping);
257  add(stripDigis, preTriggers);
258  add(wireDigis, alctDigis);
259  add(comparatorDigis, clctDigis);
260  add(correlatedLCTDigis);
261 
262  int l1a=e.id().event(); //need to add increments or get it from lct digis
263  int bx = 0;//same as above
264  //int startingFED = FEDNumbering::MINCSCFEDID;
265 
266  std::map<int, CSCDCCEventData> dccMap;
267  for (int idcc=FEDNumbering::MINCSCFEDID;
268  idcc<=FEDNumbering::MAXCSCFEDID;++idcc)
269  {
270  //idcc goes from startingFed to startingFED+7
271  // @@ if ReadoutMapping changes, this'll have to change
272  // DCCs 1,2,4,5 have 5 DDUs. Otherwise, 4
273  //int nDDUs = (idcc < 2) || (idcc ==4) || (idcc ==5)
274  // ? 5 : 4;
275  //@@ WARNING some DCCs only have 4 DDUs, but I'm giving them all 5, for now
276  int nDDUs = 5;
277  dccMap.insert(std::pair<int, CSCDCCEventData>(idcc, CSCDCCEventData(idcc, nDDUs, bx, l1a) ) );
278 
279  // for every chamber with data, add to a DDU in this DCC Event
280  for(map<CSCDetId, CSCEventData>::iterator chamberItr = theChamberDataMap.begin();
281  chamberItr != theChamberDataMap.end(); ++chamberItr)
282  {
283  //std::cout<<"inside the pack loop" <<std::endl;
284  int indexDCC = mapping->slink(chamberItr->first);
285  if(indexDCC == idcc)
286  {
287  //FIXME (What does this mean? Is something wrong?)
288  std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.find(indexDCC);
289  if(dccMapItr == dccMap.end())
290  {
291  throw cms::Exception("CSCDigiToRaw") << "Bad DCC number:" << indexDCC;
292  }
293  // get id's based on ChamberId from mapping
294 
295  int dduId = mapping->ddu(chamberItr->first);
296  int dduSlot = mapping->dduSlot(chamberItr->first);
297  int dduInput = mapping->dduInput(chamberItr->first);
298  int dmbId = mapping->dmb(chamberItr->first);
299  dccMapItr->second.addChamber(chamberItr->second, dduId, dduSlot, dduInput, dmbId);
300  }
301  }
302  }
303 
304  // FIXME: FEDRawData size set to 2*64 to add FED header and trailer
305  for(std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.begin();
306  dccMapItr != dccMap.end(); ++dccMapItr)
307  {
308  boost::dynamic_bitset<> dccBits = dccMapItr->second.pack();
309  FEDRawData & fedRawData = fed_buffers.FEDData(dccMapItr->first);
310  fedRawData.resize(dccBits.size());
311  //fill data with dccEvent
312  bitset_utilities::bitsetToChar(dccBits, fedRawData.data());
313  FEDTrailer cscFEDTrailer(fedRawData.data()+(fedRawData.size()-8));
314  cscFEDTrailer.set(fedRawData.data()+(fedRawData.size()-8),
315  fedRawData.size()/8,
316  evf::compute_crc(fedRawData.data(),fedRawData.size()), 0, 0);
317  }
318 }
01/20/05 A.Tumanov
EventNumber_t event() const
Definition: EventID.h:44
void add(const CSCStripDigiCollection &stripDigis, const CSCCLCTPreTriggerCollection &preTriggers)
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:49
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void resize(size_t newsize)
Definition: FEDRawData.cc:33
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
Definition: CRC16.h:67
void beginEvent(const CSCChamberMap *electronicsMap)
Definition: CSCDigiToRaw.cc:98
std::map< CSCDetId, CSCEventData > theChamberDataMap
Definition: CSCDigiToRaw.h:59
void bitsetToChar(const boost::dynamic_bitset<> &bs, unsigned char *result)
this method takes bitset obj and returns char * array
edm::EventID id() const
Definition: EventBase.h:56
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:29
CSCEventData & CSCDigiToRaw::findEventData ( const CSCDetId cscDetId)
private

pick out the correct data object for this chamber

Definition at line 105 of file CSCDigiToRaw.cc.

References cscd2r::chamberID(), CSCChamberMap::crate(), CSCChamberMap::dmb(), CSCEventData::dmbHeader(), CSCDetId::iChamberType(), CSCDMBHeader::setCrateAddress(), theChamberDataMap, and theElectronicsMap.

Referenced by add().

106 {
107  CSCDetId chamberId = cscd2r::chamberID(cscDetId);
108  // find the entry into the map
109  map<CSCDetId, CSCEventData>::iterator chamberMapItr = theChamberDataMap.find(chamberId);
110  if(chamberMapItr == theChamberDataMap.end())
111  {
112  // make an entry, telling it the correct chamberType
113  int chamberType = chamberId.iChamberType();
114  chamberMapItr = theChamberDataMap.insert(pair<CSCDetId, CSCEventData>(chamberId, CSCEventData(chamberType))).first;
115  }
116  CSCEventData & cscData = chamberMapItr->second;
117  cscData.dmbHeader()->setCrateAddress(theElectronicsMap->crate(cscDetId), theElectronicsMap->dmb(cscDetId));
118  return cscData;
119 }
int dmb(const CSCDetId &) const
dmb id for given DetId
const CSCChamberMap * theElectronicsMap
Definition: CSCDigiToRaw.h:60
CSCDetId chamberID(const CSCDetId &cscDetId)
takes layer ID, converts to chamber ID, switching ME1A to ME11
Definition: CSCDigiToRaw.cc:32
void setCrateAddress(int crate, int dmbId)
Definition: CSCDMBHeader.cc:91
unsigned short iChamberType()
Definition: CSCDetId.h:109
std::map< CSCDetId, CSCEventData > theChamberDataMap
Definition: CSCDigiToRaw.h:59
int crate(const CSCDetId &) const
Interface required use in digi-to-raw.
const CSCDMBHeader * dmbHeader() const
the DAQ motherboard header. A good place for event and chamber info
Definition: CSCEventData.h:90

Member Data Documentation

int CSCDigiToRaw::alctWindowMax_
private

Definition at line 62 of file CSCDigiToRaw.h.

Referenced by add().

int CSCDigiToRaw::alctWindowMin_
private

Definition at line 61 of file CSCDigiToRaw.h.

Referenced by add().

int CSCDigiToRaw::clctWindowMax_
private

Definition at line 64 of file CSCDigiToRaw.h.

Referenced by add().

int CSCDigiToRaw::clctWindowMin_
private

Definition at line 63 of file CSCDigiToRaw.h.

Referenced by add().

int CSCDigiToRaw::preTriggerWindowMax_
private

Definition at line 66 of file CSCDigiToRaw.h.

Referenced by add().

int CSCDigiToRaw::preTriggerWindowMin_
private

Definition at line 65 of file CSCDigiToRaw.h.

Referenced by add().

std::map<CSCDetId, CSCEventData> CSCDigiToRaw::theChamberDataMap
private

Definition at line 59 of file CSCDigiToRaw.h.

Referenced by beginEvent(), createFedBuffers(), and findEventData().

const CSCChamberMap* CSCDigiToRaw::theElectronicsMap
private

Definition at line 60 of file CSCDigiToRaw.h.

Referenced by beginEvent(), and findEventData().