CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ESDigiToRaw.cc
Go to the documentation of this file.
4 
7 
11 
12 using namespace std;
13 using namespace edm;
14 
15 ESDigiToRaw::ESDigiToRaw(const edm::ParameterSet& ps) : ESDataFormatter_(0)
16 {
17 
18  label_ = ps.getParameter<string>("Label");
19  instanceName_ = ps.getParameter<string>("InstanceES");
20  debug_ = ps.getUntrackedParameter<bool>("debugMode", false);
21  formatMajor_ = ps.getUntrackedParameter<int>("formatMajor", 4);
22  formatMinor_ = ps.getUntrackedParameter<int>("formatMinor", 1);
23  lookup_ = ps.getUntrackedParameter<FileInPath>("LookupTable");
24 
25  counter_ = 0;
26  kchip_ec_ = 0;
27  kchip_bc_ = 0;
28 
29  produces<FEDRawDataCollection>();
30 
31  if (formatMajor_ == 4)
33  else
35 
36  // initialize look-up table
37  for (int i=0; i<2; ++i)
38  for (int j=0; j<2; ++j)
39  for (int k=0 ;k<40; ++k)
40  for (int m=0; m<40; m++)
41  fedId_[i][j][k][m] = -1;
42 
43  // read in look-up table
44  int nLines, iz, ip, ix, iy, fed, kchip, pace, bundle, fiber, optorx;
45  ifstream file;
46  file.open(lookup_.fullPath().c_str());
47  if( file.is_open() ) {
48 
49  file >> nLines;
50  for (int i=0; i<nLines; ++i) {
51  file >> iz >> ip >> ix >> iy >> fed >> kchip >> pace >> bundle >> fiber >> optorx ;
52  fedId_[(3-iz)/2-1][ip-1][ix-1][iy-1] = fed;
53  }
54  } else {
55  cout<<"[ESDigiToRaw] Look up table file can not be found in "<<lookup_.fullPath().c_str() <<endl;
56  }
57 
58  file.close();
59 }
60 
63 }
64 
66 }
67 
69 
70  run_number_ = ev.id().run();
73 
74  lv1_ = ev.id().event();
77  counter_++;
78 
85 
87  ev.getByLabel(label_, instanceName_, digis);
88 
89  int ifed;
91  Digis.clear();
92 
93  for (ESDigiCollection::const_iterator it=digis->begin(); it!=digis->end(); ++it) {
94 
95  const ESDataFrame& df = *it;
96  const ESDetId& detId = it->id();
97 
98  ifed = fedId_[(3-detId.zside())/2-1][detId.plane()-1][detId.six()-1][detId.siy()-1];
99  if (ifed < 0) continue;
100 
101  Digis[ifed].push_back(df);
102  }
103 
104  auto_ptr<FEDRawDataCollection> productRawData( new FEDRawDataCollection );
105 
106  ESDataFormatter::Digis::const_iterator itfed;
107  for (itfed = Digis.begin(); itfed != Digis.end(); ++itfed) {
108  int fId = (*itfed).first ;
109 
110  FEDRawData& fedRawData = productRawData->FEDData(fId);
111  ESDataFormatter_->DigiToRaw(fId, Digis, fedRawData);
112 
113  if (debug_) cout<<"FED : "<<fId<<" Data size : "<<fedRawData.size()<<" (Bytes)"<<endl;
114  }
115 
116  ev.put(productRawData);
117 
118  return;
119 }
120 
122 }
RunNumber_t run() const
Definition: EventID.h:42
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:44
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
static const int KCHIP_EC_RANGE
Definition: ESDigiToRaw.h:42
void produce(edm::Event &e, const edm::EventSetup &es)
Definition: ESDigiToRaw.cc:68
virtual void DigiToRaw(int fedId, Digis &digis, FEDRawData &fedRawData)=0
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
virtual ~ESDigiToRaw()
Definition: ESDigiToRaw.cc:61
virtual void setRunNumber(int i)
int orbit_number_
Definition: ESDigiToRaw.h:47
int six() const
Definition: ESDetId.h:48
virtual void setKchipEC(int i)
std::string label_
Definition: ESDigiToRaw.h:55
std::map< int, DetDigis > Digis
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
int formatMinor_
Definition: ESDigiToRaw.h:60
ESDataFormatter * ESDataFormatter_
Definition: ESDigiToRaw.h:62
virtual void setKchipBC(int i)
int siy() const
Definition: ESDetId.h:50
edm::FileInPath lookup_
Definition: ESDigiToRaw.h:57
virtual void setBX(int i)
int formatMajor_
Definition: ESDigiToRaw.h:59
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
int fedId_[2][2][40][40]
Definition: ESDigiToRaw.h:53
std::string instanceName_
Definition: ESDigiToRaw.h:56
int j
Definition: DBlmapReader.cc:9
virtual void setOrbitNumber(int i)
int run_number_
Definition: ESDigiToRaw.h:48
int zside() const
Definition: ESDetId.h:44
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
int k[5][pyjets_maxn]
virtual void setLV1(int i)
void beginJob()
Definition: ESDigiToRaw.cc:65
ESDigiToRaw(const edm::ParameterSet &ps)
Definition: ESDigiToRaw.cc:15
edm::EventID id() const
Definition: EventBase.h:56
static const int KCHIP_BC_RANGE
Definition: ESDigiToRaw.h:41
int plane() const
Definition: ESDetId.h:46
tuple cout
Definition: gather_cfg.py:121
void endJob()
Definition: ESDigiToRaw.cc:121
static const int LHC_BX_RANGE
Definition: ESDigiToRaw.h:40