CMS 3D CMS Logo

RctInputTextToDigi Class Reference

Description: Creates an EcalTrigPrimDigiCollection and an HcalTrigPrimDigiCollection from a text file (formatted as read out from saveRCTInput module), for input to the L1Trigger/RegionalCaloTrigger module. More...

#include <L1Trigger/TextToDigi/plugins/RctInputTextToDigi.h>

Inheritance diagram for RctInputTextToDigi:

edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 RctInputTextToDigi (const edm::ParameterSet &)
 ~RctInputTextToDigi ()

Private Member Functions

virtual void beginJob (const edm::EventSetup &)
virtual void endJob ()
virtual void produce (edm::Event &, const edm::EventSetup &)

Private Attributes

edm::FileInPath inputFile_
ifstream inputStream_
L1RCTLookupTableslookupTables_
int nEvent_
bool oldVersion_


Detailed Description

Description: Creates an EcalTrigPrimDigiCollection and an HcalTrigPrimDigiCollection from a text file (formatted as read out from saveRCTInput module), for input to the L1Trigger/RegionalCaloTrigger module.

Definition at line 51 of file RctInputTextToDigi.h.


Constructor & Destructor Documentation

RctInputTextToDigi::RctInputTextToDigi ( const edm::ParameterSet iConfig  )  [explicit]

Definition at line 7 of file RctInputTextToDigi.cc.

References TestMuL1L2Filter_cff::cerr, lat::endl(), and inputStream_.

00007                                                                      :
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   //register your products
00015   /* Examples
00016      produces<ExampleData2>();
00017      
00018      //if do put with a label
00019      produces<ExampleData2>("label");
00020   */
00021   
00022   produces<EcalTrigPrimDigiCollection>();
00023   produces<HcalTrigPrimDigiCollection>();
00024 
00025   //now do what ever other initialization is needed
00026 
00027   if ((!inputStream_.is_open())||(!inputStream_))
00028     {
00029       // not good!!
00030       std::cerr << "Input file didn't open!!" << std::endl;
00031     }
00032   //if (inputStream_.eof()) {std::cout << "Real zeroth eof! " << std::endl;}
00033 
00034 }

RctInputTextToDigi::~RctInputTextToDigi (  ) 

Definition at line 37 of file RctInputTextToDigi.cc.

References inputStream_.

00038 {
00039  
00040    // do anything here that needs to be done at desctruction time
00041    // (e.g. close files, deallocate resources etc.)
00042 
00043   inputStream_.close();
00044 
00045 }


Member Function Documentation

void RctInputTextToDigi::beginJob ( const edm::EventSetup  )  [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 217 of file RctInputTextToDigi.cc.

00218 {
00219   // open input file to read all events
00220   //inputStream_.open(inputFile_.fullPath().c_str());
00221   //std::cout << "beginJob entered" << std::endl;
00222 }

void RctInputTextToDigi::endJob ( void   )  [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 226 of file RctInputTextToDigi.cc.

00227 {
00228   // close input file
00229   //inputStream_.close();
00230 }

void RctInputTextToDigi::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 54 of file RctInputTextToDigi.cc.

References funct::abs(), L1RCTParameters::calcIEta(), L1RCTParameters::calcIPhi(), GenMuonPlsPt100GeV_cfg::cout, EcalTriggerTower, lat::endl(), edm::EventSetup::get(), i, inputStream_, int, j, lookupTables_, nEvent_, oldVersion_, edm::Event::put(), r, L1RCTLookupTables::rctParameters(), L1RCTLookupTables::setRCTParameters(), EcalTriggerPrimitiveDigi::setSample(), HcalTriggerPrimitiveDigi::setSample(), EcalTriggerPrimitiveDigi::setSize(), and HcalTriggerPrimitiveDigi::setSize().

00055 {
00056   using namespace edm;
00057 
00058   //std::cout << std::endl << std::endl << "Event number " << nEvent_ << std::endl;
00059 
00060   // This next section taken directly from 
00061   // L1Trigger/RegionalCaloTrigger/plugins/L1RCTProducer.cc rev. 1.6
00062   // Refresh configuration information every event
00063   // Hopefully doesn't take too much time
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);  // includes HF
00075   const int nEcalSamples = 1;   // we only use 1 sample for each
00076   const int nHcalSamples = 1;
00077   
00078   int fileEventNumber; 
00079   
00080   // check to see if need to skip file header and do so before
00081   // looping through entire event
00082   
00083   std::string junk;
00084   //bool old_version = false;
00085   if (nEvent_ == 0)
00086     {
00087       //std::string junk;
00088       unsigned short junk_counter = 0;
00089       //bool old_version = false;
00090       do
00091         {
00092           if(inputStream_ >> junk) {/*std::cout << "Good: ";*/}
00093           //std::cout << "header junk was input: \"" << junk << "\"."
00094           //                 << std::endl;
00095           // for oldest version, which is same as newest version
00096           //      if((junk_counter == 11) && (junk.compare("0-32") == 0))
00097           //        {
00098           //          oldVersion_ = true;
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   // can't actually read in phi and eta, file has crate card tower instead
00113   // do a while loop for event number instead??  dunno
00114   for (int i = 0; i < 72; i++)
00115     {
00116       // negative eta, iEta -28 to -1
00117       for (int j = 0; j < 56; j++)
00118         {
00119           // calc ieta, iphi coords of tower 
00120           // ieta -28 to -1 or 1 to 28, iphi 1 to 72
00121           // methods in CondFormats/L1TObjects/src/L1RCTParameters.cc
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);  // mip bit
00141           
00142           //std::cout << "Eventnumber " << fileEventNumber << "\tCrate " 
00143           //    << crate << "\tCard " << card << "\tTower " 
00144           //    << tower << " \teAddr " << eAddr <<"\thAddr "
00145           //    << hAddr << "\tjunk " << junk << std::endl;
00146           
00147           int iEta = lookupTables_->rctParameters()->calcIEta(crate,card,tower);
00148           int iPhi = lookupTables_->rctParameters()->calcIPhi(crate,card,tower);
00149           // transform rct iphi coords into global coords
00150           iPhi = ((72 + 18 - iPhi) % 72);
00151           if (iPhi == 0) {iPhi = 72;}
00152           int zSide = (iEta/abs(iEta));
00153           
00154           /*std::cout << "iEta " << iEta << "\tabsiEta " << abs(iEta) 
00155             << "\tiPhi " << iPhi << "\tzSide " 
00156             << zSide << std::endl;
00157           */
00158           
00159           // args to detid are zside, type of tower, absieta, iphi
00160           // absieta and iphi must be between 1 and 127 inclusive
00161           EcalTriggerPrimitiveDigi 
00162             ecalDigi(EcalTrigTowerDetId(zSide, EcalTriggerTower, abs(iEta),
00163                                         iPhi));
00164           ecalDigi.setSize(nEcalSamples);
00165           
00166           // last arg is 3-bit trigger tower flag, which we don't use
00167           // we only use 8-bit encoded et and 1-bit fg
00168           ecalDigi.setSample(0, EcalTriggerPrimitiveSample(encodedEtEcal, 
00169                                                            fineGrainEcal, 0));
00170           //std::cout << ecalDigi << std::endl;
00171           ecalTPs->push_back(ecalDigi);
00172           
00173           HcalTriggerPrimitiveDigi
00174             hcalDigi(HcalTrigTowerDetId(iEta, iPhi));
00175           
00176           hcalDigi.setSize(nHcalSamples);
00177           
00178           // last two arg's are slb and slb channel, which we don't need
00179           hcalDigi.setSample(0, HcalTriggerPrimitiveSample(encodedEtHcal,
00180                                                            fineGrainHcal,
00181                                                            0, 0));
00182           //std::cout << hcalDigi << std::endl;
00183           hcalTPs->push_back(hcalDigi);
00184         }
00185       
00186       // also need to push_back HF digis!  
00187       // file input doesn't include HF, so need empty digis
00188       for (int i = 0; i < 18; i++)
00189         {
00190           for (int j = 0; j < 8; j++)
00191             {
00192               // HF ieta: +- 29 through 32.  HF iphi: 1,5,9,13,etc.
00193               int hfIEta = (j%4)+29;
00194               if (i < 9)
00195                 {
00196                   hfIEta = hfIEta*(-1);
00197                 }
00198               int hfIPhi = (i%9 + j/4)*4 + 1;
00199               
00200               HcalTriggerPrimitiveDigi
00201                 hfDigi(HcalTrigTowerDetId(hfIEta, hfIPhi));
00202               hfDigi.setSize(1);
00203               hfDigi.setSample(0, HcalTriggerPrimitiveSample(0,0,0,0));
00204               hcalTPs->push_back(hfDigi);
00205             }
00206         }
00207     }
00208   iEvent.put(ecalTPs);
00209   iEvent.put(hcalTPs);
00210   
00211   nEvent_++;
00212   //std::cout << "Produce done" << std::endl;
00213 }


Member Data Documentation

edm::FileInPath RctInputTextToDigi::inputFile_ [private]

Definition at line 63 of file RctInputTextToDigi.h.

ifstream RctInputTextToDigi::inputStream_ [private]

Definition at line 64 of file RctInputTextToDigi.h.

Referenced by produce(), RctInputTextToDigi(), and ~RctInputTextToDigi().

L1RCTLookupTables* RctInputTextToDigi::lookupTables_ [private]

Definition at line 67 of file RctInputTextToDigi.h.

Referenced by produce().

int RctInputTextToDigi::nEvent_ [private]

Definition at line 65 of file RctInputTextToDigi.h.

Referenced by produce().

bool RctInputTextToDigi::oldVersion_ [private]

Definition at line 66 of file RctInputTextToDigi.h.

Referenced by produce().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:30:39 2009 for CMSSW by  doxygen 1.5.4