Go to the documentation of this file.00001 #include "RctInputTextToDigi.h"
00002
00003
00004
00005
00006
00007 RctInputTextToDigi::RctInputTextToDigi(const edm::ParameterSet& iConfig) :
00008 inputFile_(iConfig.getParameter<edm::FileInPath>("inputFile")),
00009 inputStream_(inputFile_.fullPath().c_str()),
00010 nEvent_(0),
00011 oldVersion_(false),
00012 lookupTables_(new L1RCTLookupTables)
00013 {
00014
00015
00016
00017
00018
00019
00020
00021
00022 produces<EcalTrigPrimDigiCollection>();
00023 produces<HcalTrigPrimDigiCollection>();
00024
00025
00026
00027 if ((!inputStream_.is_open())||(!inputStream_))
00028 {
00029
00030 std::cerr << "Input file didn't open!!" << std::endl;
00031 }
00032
00033
00034 }
00035
00036
00037 RctInputTextToDigi::~RctInputTextToDigi()
00038 {
00039
00040
00041
00042
00043 inputStream_.close();
00044
00045 }
00046
00047
00048
00049
00050
00051
00052
00053 void
00054 RctInputTextToDigi::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00055 {
00056 using namespace edm;
00057
00058
00059
00060
00061
00062
00063
00064 ESHandle<L1RCTParameters> rctParameters;
00065 iSetup.get<L1RCTParametersRcd>().get(rctParameters);
00066 const L1RCTParameters* r = rctParameters.product();
00067 lookupTables_->setRCTParameters(r);
00068
00069 std::auto_ptr<EcalTrigPrimDigiCollection>
00070 ecalTPs(new EcalTrigPrimDigiCollection());
00071 std::auto_ptr<HcalTrigPrimDigiCollection>
00072 hcalTPs(new HcalTrigPrimDigiCollection());
00073 ecalTPs->reserve(56*72);
00074 hcalTPs->reserve(56*72+18*8);
00075 const int nEcalSamples = 1;
00076 const int nHcalSamples = 1;
00077
00078 int fileEventNumber;
00079
00080
00081
00082
00083 std::string junk;
00084
00085 if (nEvent_ == 0)
00086 {
00087
00088 unsigned short junk_counter = 0;
00089
00090 do
00091 {
00092 if(inputStream_ >> junk) {}
00093
00094
00095
00096
00097
00098
00099
00100 if((junk_counter == 11) && (junk.compare("1-32") == 0))
00101 {
00102 oldVersion_ = true;
00103 }
00104 junk_counter++;
00105 }
00106 while (junk.compare("LUTOut") != 0);
00107 std::cout << "Skipped file header" << std::endl;
00108 if (oldVersion_) {std::cout << "oldVersion_ TRUE (tower 1-32)" << std::endl;}
00109 else {std::cout << "oldVersion_ FALSE (tower 0-31)" << std::endl;}
00110 }
00111
00112
00113
00114 for (int i = 0; i < 72; i++)
00115 {
00116
00117 for (int j = 0; j < 56; j++)
00118 {
00119
00120
00121
00122
00123 unsigned short crate;
00124 unsigned short card;
00125 unsigned short tower;
00126 unsigned eAddr;
00127 unsigned hAddr;
00128
00129 inputStream_ >> std::hex >> fileEventNumber >> crate >> card
00130 >> tower
00131 >> eAddr >> hAddr >> junk >> std::dec;
00132
00133 if (oldVersion_)
00134 {
00135 tower = tower - 1;
00136 }
00137 int encodedEtEcal = (int) (eAddr>>1);
00138 bool fineGrainEcal = (bool) (eAddr&1);
00139 int encodedEtHcal = (int) (hAddr>>1);
00140 bool fineGrainHcal = (bool) (hAddr&1);
00141
00142
00143
00144
00145
00146
00147 int iEta = lookupTables_->rctParameters()->calcIEta(crate,card,tower);
00148 int iPhi = lookupTables_->rctParameters()->calcIPhi(crate,card,tower);
00149
00150 iPhi = ((72 + 18 - iPhi) % 72);
00151 if (iPhi == 0) {iPhi = 72;}
00152 unsigned absIeta = abs(iEta);
00153 int zSide = (iEta/absIeta);
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163 EcalTriggerPrimitiveDigi
00164 ecalDigi(EcalTrigTowerDetId(zSide, EcalTriggerTower, absIeta,
00165 iPhi));
00166 ecalDigi.setSize(nEcalSamples);
00167
00168
00169
00170 ecalDigi.setSample(0, EcalTriggerPrimitiveSample(encodedEtEcal,
00171 fineGrainEcal, 0));
00172
00173 ecalTPs->push_back(ecalDigi);
00174
00175 HcalTriggerPrimitiveDigi
00176 hcalDigi(HcalTrigTowerDetId(iEta, iPhi));
00177
00178 hcalDigi.setSize(nHcalSamples);
00179
00180
00181 hcalDigi.setSample(0, HcalTriggerPrimitiveSample(encodedEtHcal,
00182 fineGrainHcal,
00183 0, 0));
00184
00185 hcalTPs->push_back(hcalDigi);
00186 }
00187
00188
00189
00190 for (int i = 0; i < 18; i++)
00191 {
00192 for (int j = 0; j < 8; j++)
00193 {
00194
00195 int hfIEta = (j%4)+29;
00196 if (i < 9)
00197 {
00198 hfIEta = hfIEta*(-1);
00199 }
00200
00201
00202 int hfIPhi = (i%9)*8 + (j/4)*4 + 1;
00203
00204 HcalTriggerPrimitiveDigi
00205 hfDigi(HcalTrigTowerDetId(hfIEta, hfIPhi));
00206 hfDigi.setSize(1);
00207 hfDigi.setSample(0, HcalTriggerPrimitiveSample(0,0,0,0));
00208 hcalTPs->push_back(hfDigi);
00209 }
00210 }
00211 }
00212 iEvent.put(ecalTPs);
00213 iEvent.put(hcalTPs);
00214
00215 nEvent_++;
00216
00217 }
00218
00219
00220 void
00221 RctInputTextToDigi::beginJob()
00222 {
00223
00224
00225
00226 }
00227
00228
00229 void
00230 RctInputTextToDigi::endJob()
00231 {
00232
00233
00234 }
00235
00236
00237 DEFINE_FWK_MODULE(RctInputTextToDigi);