![]() |
![]() |
#include <L1Trigger/TextToDigi/src/SourceCardTextToRctDigi.h>
Public Member Functions | |
SourceCardTextToRctDigi (const edm::ParameterSet &) | |
~SourceCardTextToRctDigi () | |
Private Member Functions | |
virtual void | produce (edm::Event &, const edm::EventSetup &) |
void | putEmptyDigi (edm::Event &) |
Create empty digi collection. | |
Private Attributes | |
std::ifstream | m_file |
file handle | |
int | m_fileEventOffset |
Number of events to skip at the start of the file. | |
int | m_nevt |
Event counter. | |
SourceCardRouting | m_scRouting |
source card router | |
std::string | m_textFileName |
Name out input file. |
Implementation: <Notes on="" implementation>="">
Definition at line 44 of file SourceCardTextToRctDigi.h.
SourceCardTextToRctDigi::SourceCardTextToRctDigi | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 29 of file SourceCardTextToRctDigi.cc.
References lat::endl(), Exception, in, m_file, m_scRouting, and m_textFileName.
00029 : 00030 m_textFileName(iConfig.getParameter<std::string>("TextFileName")), 00031 m_fileEventOffset(iConfig.getParameter<int>("fileEventOffset")), 00032 m_nevt(0) 00033 { 00034 // Produces collections 00035 produces<L1CaloEmCollection>(); 00036 produces<L1CaloRegionCollection>(); 00037 00038 // Open the input file 00039 m_file.open(m_textFileName.c_str(),ios::in); 00040 00041 if(!m_file.good()) 00042 { 00043 throw cms::Exception("SourceCardTextToRctDigiTextFileOpenError") 00044 << "SourceCardTextToRctDigi::SourceCardTextToRctDigi : " 00045 << " couldn't open the file " << m_textFileName << " for reading" << endl; 00046 } 00047 00048 // Make a SC routing object 00049 SourceCardRouting m_scRouting; 00050 00051 }
SourceCardTextToRctDigi::~SourceCardTextToRctDigi | ( | ) |
Definition at line 53 of file SourceCardTextToRctDigi.cc.
References m_file.
00054 { 00055 // Close the input file 00056 m_file.close(); 00057 }
void SourceCardTextToRctDigi::produce | ( | edm::Event & | iEvent, | |
const edm::EventSetup & | iSetup | |||
) | [private, virtual] |
Implements edm::EDProducer.
Definition at line 78 of file SourceCardTextToRctDigi.cc.
References funct::abs(), em, lat::endl(), Exception, i, j, parsecf::pyparsing::line(), LogDebug, SourceCardRouting::LogicalCardIDtoRoutingMode(), m_file, m_fileEventOffset, m_nevt, m_scRouting, m_textFileName, NUM_LINES_PER_EVENT, NUM_RCT_CRATES, edm::Event::put(), putEmptyDigi(), rgn, SourceCardRouting::STRINGtoVHDCI(), tmp, SourceCardRouting::VHDCItoEMU(), SourceCardRouting::VHDCItoRC012(), SourceCardRouting::VHDCItoRC234(), and SourceCardRouting::VHDCItoRC56HF().
00079 { 00080 // Skip event if required 00081 if (m_nevt < m_fileEventOffset){ 00082 // string tmp; 00083 // for (unsigned i=0;i<NUM_LINES_PER_EVENT;i++){ 00084 //getline(m_file,tmp); 00085 //} 00086 putEmptyDigi(iEvent); 00087 m_nevt++; 00088 return; 00089 } else if (m_nevt==0 && m_fileEventOffset<0) { 00090 //skip first fileEventOffset input events 00091 string tmp; 00092 for(int i=0;i<abs(m_fileEventOffset); i++) 00093 for (unsigned line=0; line<NUM_LINES_PER_EVENT; line++) 00094 if(!getline(m_file,tmp)) 00095 { 00096 throw cms::Exception("SourceCardTextToRctDigiTextFileReadError") 00097 << "SourceCardTextToRctDigi::produce() : " 00098 << " couldn't read from the file " << m_textFileName << endl; 00099 } 00100 } 00101 00102 00103 // New collections 00104 auto_ptr<L1CaloEmCollection> em (new L1CaloEmCollection); 00105 auto_ptr<L1CaloRegionCollection> rgn (new L1CaloRegionCollection); 00106 00107 // General variables 00108 unsigned long VHDCI[2][2]; 00109 int routingMode; 00110 int crate; 00111 string dataString; 00112 unsigned short eventNumber; 00113 unsigned short logicalCardID; 00114 00115 // Arrays to hold electron variables 00116 unsigned short eIsoRank[18][4]; 00117 unsigned short eIsoCardId[18][4]; 00118 unsigned short eIsoRegionId[18][4]; 00119 unsigned short eNonIsoRank[18][4]; 00120 unsigned short eNonIsoCardId[18][4]; 00121 unsigned short eNonIsoRegionId[18][4]; 00122 00123 // Arrays to hold region variables 00124 unsigned short RC[18][7][2]; 00125 unsigned short RCof[18][7][2]; 00126 unsigned short RCtau[18][7][2]; 00127 unsigned short MIPbits[18][7][2]; 00128 unsigned short Qbits[18][7][2]; 00129 unsigned short HF[18][4][2]; 00130 unsigned short HFQ[18][4][2]; 00131 00132 // Check we're not at the end of the file 00133 if(m_file.eof()) 00134 { 00135 throw cms::Exception("SourceCardTextToRctDigiTextFileReadError") 00136 << "SourceCardTextToRctDigi::produce : " 00137 << " unexpected end of file " << m_textFileName << endl; 00138 } 00139 00140 int thisEventNumber; 00141 // Read in file one line at a time 00142 for (unsigned line=0; line<NUM_LINES_PER_EVENT; line++){ 00143 00144 if(!getline(m_file,dataString)) 00145 { 00146 throw cms::Exception("SourceCardTextToRctDigiTextFileReadError") 00147 << "SourceCardTextToRctDigi::SourceCardTextToRctDigi : " 00148 << " couldn't read from the file " << m_textFileName << endl; 00149 } 00150 00151 // Convert the string to useful info 00152 m_scRouting.STRINGtoVHDCI(logicalCardID,eventNumber,dataString,VHDCI); 00153 00154 // Check crossing number 00155 if(line!=0) assert(eventNumber==thisEventNumber); 00156 thisEventNumber = eventNumber; 00157 00158 // Are we looking at electrons or regions 00159 m_scRouting.LogicalCardIDtoRoutingMode(logicalCardID,routingMode,crate); 00160 00161 if (routingMode==0){ 00162 00163 // Electrons 00164 m_scRouting.VHDCItoEMU(eIsoRank[crate],eIsoCardId[crate],eIsoRegionId[crate], 00165 eNonIsoRank[crate],eNonIsoCardId[crate],eNonIsoRegionId[crate], 00166 MIPbits[crate],Qbits[crate],VHDCI); 00167 00168 } else if (routingMode==1) { 00169 00170 // Regions 00171 m_scRouting.VHDCItoRC56HF(RC[crate],RCof[crate],RCtau[crate],HF[crate],HFQ[crate],VHDCI); 00172 00173 } else if (routingMode==2) { 00174 00175 // Regions 00176 m_scRouting.VHDCItoRC012(RC[crate],RCof[crate],RCtau[crate],VHDCI); 00177 00178 } else if (routingMode==3) { 00179 00180 // Regions 00181 m_scRouting.VHDCItoRC234(RC[crate],RCof[crate],RCtau[crate],RC[crate+9],RCof[crate+9],RCtau[crate+9],VHDCI); 00182 00183 } else { 00184 // Something went wrong 00185 throw cms::Exception("SourceCardtextToRctDigiError") 00186 << "SourceCardTextToRctDigi::produce : " 00187 << " unknown routing mode=" << routingMode << endl; 00188 } 00189 } 00190 00191 // Make RCT digis 00192 for (crate=0; crate<NUM_RCT_CRATES; crate++){ 00193 00194 // Make EM collections 00195 for (int i=0; i<4; i++){ 00196 em->push_back(L1CaloEmCand(eIsoRank[crate][i],eIsoRegionId[crate][i],eIsoCardId[crate][i],crate,true,i,0)); 00197 em->push_back(L1CaloEmCand(eNonIsoRank[crate][i],eNonIsoRegionId[crate][i],eNonIsoCardId[crate][i],crate,false,i,0)); 00198 } 00199 00200 // Make region collections 00201 for (int i=0; i<7; i++){// Receiver card 00202 for (int j=0; j<2; j++){// Region 00203 rgn->push_back(L1CaloRegion(RC[crate][i][j],RCof[crate][i][j],RCtau[crate][i][j],MIPbits[crate][i][j],Qbits[crate][i][j],crate,i,j)); 00204 } 00205 } 00206 00207 // Make HF region collections 00208 for (int i=0; i<4; i++){// Eta bin 00209 for (int j=0; j<2; j++){// HF0, HF1 00210 rgn->push_back(L1CaloRegion(HF[crate][i][j],HFQ[crate][i][j],crate,i+(4*j)));// region=eta+4*phi for eta 0-3 00211 } 00212 } 00213 } 00214 00215 // Debug info 00216 for (L1CaloEmCollection::const_iterator iem=em->begin(); iem!=em->end(); iem++){ 00217 LogDebug("Electrons") << "Rank=" << iem->rank() 00218 << " Card=" << iem->rctCard() 00219 << " Region=" << iem->rctRegion() 00220 << " Crate=" << iem->rctCrate() 00221 << " Isolated=" << iem->isolated() << endl; 00222 } 00223 00224 for (L1CaloRegionCollection::const_iterator irgn=rgn->begin(); irgn!=rgn->end(); irgn++){ 00225 if (irgn->id().isHf()){ 00226 LogDebug("HFRegions") << "Et=" << irgn->et() 00227 << " FineGrain=" << irgn->fineGrain() 00228 << " Eta=" << irgn->id().rctEta() 00229 << " Phi=" << irgn->id().rctPhi() 00230 << " Crate=" << irgn->rctCrate(); 00231 } else { 00232 LogDebug("Regions") << "Et=" << irgn->et() 00233 << " OverFlow=" << irgn->overFlow() 00234 << " tauVeto=" << irgn->tauVeto() 00235 << " mip=" << irgn->mip() 00236 << " quiet=" << irgn->quiet() 00237 << " Card=" << irgn->rctCard() 00238 << " Region=" << irgn->rctRegionIndex() 00239 << " Crate=" << irgn->rctCrate(); 00240 } 00241 } 00242 00243 iEvent.put(em); 00244 iEvent.put(rgn); 00245 00246 m_nevt++; 00247 }
void SourceCardTextToRctDigi::putEmptyDigi | ( | edm::Event & | iEvent | ) | [private] |
Create empty digi collection.
Append empty digi collection.
Definition at line 60 of file SourceCardTextToRctDigi.cc.
References em, i, j, NUM_RCT_CRATES, edm::Event::put(), and rgn.
Referenced by produce().
00060 { 00061 auto_ptr<L1CaloEmCollection> em (new L1CaloEmCollection); 00062 auto_ptr<L1CaloRegionCollection> rgn (new L1CaloRegionCollection); 00063 for (unsigned i=0; i<NUM_RCT_CRATES; i++){ 00064 for (unsigned j=0; j<4; j++) { 00065 em->push_back(L1CaloEmCand(0, i, true)); 00066 em->push_back(L1CaloEmCand(0, i, false)); 00067 } 00068 for (unsigned j=0; j<14; j++) 00069 rgn->push_back(L1CaloRegion(0,false,false,false,false,i,j/2,j%2)); 00070 for (unsigned j=0; j<8; j++) 00071 rgn->push_back(L1CaloRegion(0,true,i,j)); 00072 } 00073 iEvent.put(em); 00074 iEvent.put(rgn); 00075 }
std::ifstream SourceCardTextToRctDigi::m_file [private] |
file handle
Definition at line 65 of file SourceCardTextToRctDigi.h.
Referenced by produce(), SourceCardTextToRctDigi(), and ~SourceCardTextToRctDigi().
Number of events to skip at the start of the file.
Definition at line 59 of file SourceCardTextToRctDigi.h.
Referenced by produce().
int SourceCardTextToRctDigi::m_nevt [private] |
source card router
Definition at line 68 of file SourceCardTextToRctDigi.h.
Referenced by produce(), and SourceCardTextToRctDigi().
std::string SourceCardTextToRctDigi::m_textFileName [private] |
Name out input file.
Definition at line 56 of file SourceCardTextToRctDigi.h.
Referenced by produce(), and SourceCardTextToRctDigi().