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

Author
A. Tumanov - Rice

Definition at line 23 of file CSCDigiToRaw.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 87 of file CSCDigiToRaw.cc.

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

Member Function Documentation

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

Definition at line 121 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().

123 { //iterate over chambers with strip digis in them
124  for (CSCStripDigiCollection::DigiRangeIterator j=stripDigis.begin(); j!=stripDigis.end(); ++j)
125  {
126  CSCDetId cscDetId=(*j).first;
127  // only digitize if there are pre-triggers
128  if(cscd2r::accept(cscDetId, preTriggers, preTriggerWindowMin_, preTriggerWindowMax_))
129  {
130  bool me1a = (cscDetId.station()==1) && (cscDetId.ring()==4);
131  bool zplus = (cscDetId.endcap() == 1);
132  bool me1b = (cscDetId.station()==1) && (cscDetId.ring()==1);
133 
134  CSCEventData & cscData = findEventData(cscDetId);
135 
136  std::vector<CSCStripDigi>::const_iterator digiItr = (*j).second.first;
137  std::vector<CSCStripDigi>::const_iterator last = (*j).second.second;
138  for( ; digiItr != last; ++digiItr)
139  {
140  CSCStripDigi digi = *digiItr;
141  int strip = digi.getStrip();
142  if ( me1a && zplus ) { digi.setStrip(17-strip); } // 1-16 -> 16-1
143  if ( me1b && !zplus) { digi.setStrip(65-strip);} // 1-64 -> 64-1
144  if ( me1a ) { strip = digi.getStrip(); digi.setStrip(strip+64);} // reset back 1-16 to 65-80 digi
145  cscData.add(digi, cscDetId.layer() );
146  }
147  }
148  }
149 }
int layer() const
Definition: CSCDetId.h:74
int getStrip() const
Definition: CSCStripDigi.h:51
int endcap() const
Definition: CSCDetId.h:106
void setStrip(int istrip)
Definition: CSCStripDigi.h:75
int j
Definition: DBlmapReader.cc:9
int preTriggerWindowMin_
Definition: CSCDigiToRaw.h:63
int preTriggerWindowMax_
Definition: CSCDigiToRaw.h:64
int ring() const
Definition: CSCDetId.h:88
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:40
int station() const
Definition: CSCDetId.h:99
void CSCDigiToRaw::add ( const CSCWireDigiCollection wireDigis,
const CSCALCTDigiCollection alctDigis 
)
private

Definition at line 152 of file CSCDigiToRaw.cc.

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

154 {
155  add(alctDigis);
156  for (CSCWireDigiCollection::DigiRangeIterator j=wireDigis.begin(); j!=wireDigis.end(); ++j)
157  {
158  CSCDetId cscDetId=(*j).first;
159  if(cscd2r::accept(cscDetId, alctDigis, alctWindowMin_, alctWindowMax_))
160  {
161  CSCEventData & cscData = findEventData(cscDetId);
162  std::vector<CSCWireDigi>::const_iterator digiItr = (*j).second.first;
163  std::vector<CSCWireDigi>::const_iterator last = (*j).second.second;
164  for( ; digiItr != last; ++digiItr)
165  {
166  cscData.add(*digiItr, cscDetId.layer() );
167  }
168  }
169  }
170 
171 }
void add(const CSCStripDigiCollection &stripDigis, const CSCCLCTPreTriggerCollection &preTriggers)
int layer() const
Definition: CSCDetId.h:74
int alctWindowMax_
Definition: CSCDigiToRaw.h:60
int alctWindowMin_
Definition: CSCDigiToRaw.h:59
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:40
void CSCDigiToRaw::add ( const CSCComparatorDigiCollection comparatorDigis,
const CSCCLCTDigiCollection clctDigis 
)
private

Definition at line 173 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().

175 {
176  add(clctDigis);
177  for (CSCComparatorDigiCollection::DigiRangeIterator j=comparatorDigis.begin(); j!=comparatorDigis.end(); ++j)
178  {
179  CSCDetId cscDetId=(*j).first;
180  CSCEventData & cscData = findEventData(cscDetId);
181  if(cscd2r::accept(cscDetId, clctDigis, clctWindowMin_, clctWindowMax_))
182  {
183  bool me1a = (cscDetId.station()==1) && (cscDetId.ring()==4);
184 
185  BOOST_FOREACH(CSCComparatorDigi digi, (*j).second)
186  {
187  // Move ME1/A comparators from CFEB=0 to CFEB=4 if this has not
188  // been done already.
189  if (me1a && digi.getStrip() <= 16) {
190  CSCComparatorDigi digi_corr(64+digi.getStrip(),
191  digi.getComparator(),
192  digi.getTimeBinWord());
193  cscData.add(digi_corr, cscDetId.layer());
194  }
195  else {
196  cscData.add(digi, cscDetId.layer());
197  }
198  }
199  }
200  }
201 }
void add(const CSCStripDigiCollection &stripDigis, const CSCCLCTPreTriggerCollection &preTriggers)
int getStrip() const
Get the strip number.
int clctWindowMin_
Definition: CSCDigiToRaw.h:61
int getComparator() const
Get Comparator readings.
int layer() const
Definition: CSCDetId.h:74
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:62
int ring() const
Definition: CSCDetId.h:88
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:40
int station() const
Definition: CSCDetId.h:99
void CSCDigiToRaw::add ( const CSCALCTDigiCollection alctDigis)
private

Definition at line 203 of file CSCDigiToRaw.cc.

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

204 {
205  for (CSCALCTDigiCollection::DigiRangeIterator j=alctDigis.begin(); j!=alctDigis.end(); ++j)
206  {
207  CSCDetId cscDetId=(*j).first;
208  CSCEventData & cscData = findEventData(cscDetId);
209 
210  cscData.add(std::vector<CSCALCTDigi>((*j).second.first, (*j).second.second));
211  }
212 }
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 214 of file CSCDigiToRaw.cc.

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

215 {
216  for (CSCCLCTDigiCollection::DigiRangeIterator j=clctDigis.begin(); j!=clctDigis.end(); ++j)
217  {
218  CSCDetId cscDetId=(*j).first;
219  CSCEventData & cscData = findEventData(cscDetId);
220 
221  cscData.add(std::vector<CSCCLCTDigi>((*j).second.first, (*j).second.second));
222  }
223 }
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 225 of file CSCDigiToRaw.cc.

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

226 {
227  for (CSCCorrelatedLCTDigiCollection::DigiRangeIterator j=corrLCTDigis.begin(); j!=corrLCTDigis.end(); ++j)
228  {
229  CSCDetId cscDetId=(*j).first;
230  CSCEventData & cscData = findEventData(cscDetId);
231 
232  cscData.add(std::vector<CSCCorrelatedLCTDigi>((*j).second.first, (*j).second.second));
233  }
234 
235 }
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 96 of file CSCDigiToRaw.cc.

References ecaldqm::electronicsMap(), theChamberDataMap, and theElectronicsMap.

Referenced by createFedBuffers().

97 {
98  theChamberDataMap.clear();
100 }
const CSCChamberMap * theElectronicsMap
Definition: CSCDigiToRaw.h:58
std::map< CSCDetId, CSCEventData > theChamberDataMap
Definition: CSCDigiToRaw.h:57
EcalElectronicsMapping const * electronicsMap(0)
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 238 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().

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

pick out the correct data object for this chamber

Definition at line 103 of file CSCDigiToRaw.cc.

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

Referenced by add().

104 {
105  CSCDetId chamberId = cscd2r::chamberID(cscDetId);
106  // find the entry into the map
107  map<CSCDetId, CSCEventData>::iterator chamberMapItr = theChamberDataMap.find(chamberId);
108  if(chamberMapItr == theChamberDataMap.end())
109  {
110  // make an entry, telling it the correct chamberType
111  int chamberType = chamberId.iChamberType();
112  chamberMapItr = theChamberDataMap.insert(pair<CSCDetId, CSCEventData>(chamberId, CSCEventData(chamberType))).first;
113  }
114  CSCEventData & cscData = chamberMapItr->second;
115  cscData.dmbHeader()->setCrateAddress(theElectronicsMap->crate(cscDetId), theElectronicsMap->dmb(cscDetId));
116  return cscData;
117 }
int dmb(const CSCDetId &) const
dmb id for given DetId
const CSCChamberMap * theElectronicsMap
Definition: CSCDigiToRaw.h:58
CSCDetId chamberID(const CSCDetId &cscDetId)
takes layer ID, converts to chamber ID, switching ME1A to ME11
Definition: CSCDigiToRaw.cc:30
void setCrateAddress(int crate, int dmbId)
Definition: CSCDMBHeader.cc:91
unsigned short iChamberType()
Definition: CSCDetId.h:120
std::map< CSCDetId, CSCEventData > theChamberDataMap
Definition: CSCDigiToRaw.h:57
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 60 of file CSCDigiToRaw.h.

Referenced by add().

int CSCDigiToRaw::alctWindowMin_
private

Definition at line 59 of file CSCDigiToRaw.h.

Referenced by add().

int CSCDigiToRaw::clctWindowMax_
private

Definition at line 62 of file CSCDigiToRaw.h.

Referenced by add().

int CSCDigiToRaw::clctWindowMin_
private

Definition at line 61 of file CSCDigiToRaw.h.

Referenced by add().

int CSCDigiToRaw::preTriggerWindowMax_
private

Definition at line 64 of file CSCDigiToRaw.h.

Referenced by add().

int CSCDigiToRaw::preTriggerWindowMin_
private

Definition at line 63 of file CSCDigiToRaw.h.

Referenced by add().

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

Definition at line 57 of file CSCDigiToRaw.h.

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

const CSCChamberMap* CSCDigiToRaw::theElectronicsMap
private

Definition at line 58 of file CSCDigiToRaw.h.

Referenced by beginEvent(), and findEventData().