CMS 3D CMS Logo

Public Types | Public Member Functions | Static Public Attributes | Private Attributes

EcalDigiToRaw Class Reference

#include <EventFilter/EcalDigiToRaw/src/EcalDigiToRaw.cc>

Inheritance diagram for EcalDigiToRaw:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Types

typedef unsigned int Word32
typedef long long Word64

Public Member Functions

void beginJob ()
 EcalDigiToRaw (const edm::ParameterSet &pset)
void endJob ()
int * GetBX ()
int * GetCounter ()
bool GetDebug ()
bool GetDoBarrel ()
bool GetDoEndCap ()
bool GetDoSR ()
bool GetDoTCC ()
bool GetDoTower ()
std::vector< int32_t > * GetListDCCId ()
int * GetLV1 ()
int * GetOrbit ()
int * GetRunNumber ()
void produce (edm::Event &e, const edm::EventSetup &c)
virtual ~EcalDigiToRaw ()

Static Public Attributes

static const int BXMAX = 2808

Private Attributes

int bx_
int counter_
bool debug_
bool doBarrel_
bool doEndCap_
bool doSR_
bool doTCC_
bool doTower_
BlockFormatterHeaderblockformatter_
std::string instanceNameEB_
std::string instanceNameEE_
std::string label_
edm::InputTag labelEBSR_
edm::InputTag labelEESR_
edm::InputTag labelTT_
std::vector< int32_t > listDCCId_
int lv1_
int orbit_number_
int runnumber_
SRBlockFormatterSRblockformatter_
TCCBlockFormatterTCCblockformatter_
TowerBlockFormatterTowerblockformatter_

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 49 of file EcalDigiToRaw.h.


Member Typedef Documentation

typedef unsigned int EcalDigiToRaw::Word32

Definition at line 59 of file EcalDigiToRaw.h.

typedef long long EcalDigiToRaw::Word64

Definition at line 58 of file EcalDigiToRaw.h.


Constructor & Destructor Documentation

EcalDigiToRaw::EcalDigiToRaw ( const edm::ParameterSet pset)

Definition at line 50 of file EcalDigiToRaw.cc.

References edm::ParameterSet::getParameter(), and edm::ParameterSet::getUntrackedParameter().

{

   doTCC_    = iConfig.getUntrackedParameter<bool>("WriteTCCBlock");
   doSR_     = iConfig.getUntrackedParameter<bool>("WriteSRFlags");
   doTower_  = iConfig.getUntrackedParameter<bool>("WriteTowerBlock");

   doBarrel_ = iConfig.getUntrackedParameter<bool>("DoBarrel");
   doEndCap_ = iConfig.getUntrackedParameter<bool>("DoEndCap");

   listDCCId_ = iConfig.getUntrackedParameter< std::vector<int32_t> >("listDCCId");
   label_= iConfig.getParameter<string>("Label");
   instanceNameEB_ = iConfig.getParameter<string>("InstanceEB");
   instanceNameEE_ = iConfig.getParameter<string>("InstanceEE");

   labelTT_ = iConfig.getParameter<edm::InputTag>("labelTT");

   labelEBSR_ = iConfig.getParameter<edm::InputTag>("labelEBSRFlags");
   labelEESR_ = iConfig.getParameter<edm::InputTag>("labelEESRFlags");

   counter_ = 0;
   debug_ = iConfig.getUntrackedParameter<bool>("debug");


   Towerblockformatter_ = new TowerBlockFormatter;
   TCCblockformatter_   = new TCCBlockFormatter();
   SRblockformatter_    = new SRBlockFormatter();
   Headerblockformatter_= new BlockFormatter;

   produces<FEDRawDataCollection>();


}
EcalDigiToRaw::~EcalDigiToRaw ( ) [virtual]

Definition at line 85 of file EcalDigiToRaw.cc.

{
 
   // do anything here that needs to be done at desctruction time
   // (e.g. close files, deallocate resources etc.)

 delete Towerblockformatter_;
 delete TCCblockformatter_;
 delete SRblockformatter_;
 delete Headerblockformatter_;

}

Member Function Documentation

void EcalDigiToRaw::beginJob ( void  ) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 291 of file EcalDigiToRaw.cc.

{
        Headerblockformatter_ -> SetParam(this);
        Towerblockformatter_  -> SetParam(this);
        TCCblockformatter_  -> SetParam(this);
        SRblockformatter_   -> SetParam(this);
}
void EcalDigiToRaw::endJob ( void  ) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 301 of file EcalDigiToRaw.cc.

                      {
}
int* EcalDigiToRaw::GetBX ( ) [inline]

Definition at line 64 of file EcalDigiToRaw.h.

References bx_.

{return &bx_ ;}
int* EcalDigiToRaw::GetCounter ( ) [inline]

Definition at line 61 of file EcalDigiToRaw.h.

References counter_.

{return &counter_ ;}
bool EcalDigiToRaw::GetDebug ( ) [inline]

Definition at line 62 of file EcalDigiToRaw.h.

References debug_.

{return debug_ ;}
bool EcalDigiToRaw::GetDoBarrel ( ) [inline]

Definition at line 67 of file EcalDigiToRaw.h.

References doBarrel_.

{return doBarrel_ ;}
bool EcalDigiToRaw::GetDoEndCap ( ) [inline]

Definition at line 68 of file EcalDigiToRaw.h.

References doEndCap_.

{return doEndCap_ ;}
bool EcalDigiToRaw::GetDoSR ( ) [inline]

Definition at line 69 of file EcalDigiToRaw.h.

References doSR_.

{return doSR_ ;}
bool EcalDigiToRaw::GetDoTCC ( ) [inline]

Definition at line 71 of file EcalDigiToRaw.h.

References doTCC_.

{return doTCC_ ;}
bool EcalDigiToRaw::GetDoTower ( ) [inline]

Definition at line 70 of file EcalDigiToRaw.h.

References doTower_.

{return doTower_ ;}
std::vector<int32_t>* EcalDigiToRaw::GetListDCCId ( ) [inline]

Definition at line 73 of file EcalDigiToRaw.h.

References listDCCId_.

{return &listDCCId_ ;}
int* EcalDigiToRaw::GetLV1 ( ) [inline]

Definition at line 65 of file EcalDigiToRaw.h.

References lv1_.

{return &lv1_ ;}
int* EcalDigiToRaw::GetOrbit ( ) [inline]

Definition at line 63 of file EcalDigiToRaw.h.

References orbit_number_.

{return &orbit_number_ ;}
int* EcalDigiToRaw::GetRunNumber ( ) [inline]

Definition at line 66 of file EcalDigiToRaw.h.

References runnumber_.

{return &runnumber_ ;}
void EcalDigiToRaw::produce ( edm::Event e,
const edm::EventSetup c 
) [virtual]

Implements edm::EDProducer.

Definition at line 105 of file EcalDigiToRaw.cc.

References begin, edm::EventBase::bunchCrossing(), gather_cfg::cout, EcalElectronicsId::dccId(), cond::rpcobgas::detid, DigiToRaw_cff::DigiToRaw, EcalBarrel, EcalEndcap, end, edm::EventID::event(), L1Comparator_cfi::FEDid, edm::EventSetup::get(), edm::Event::getByLabel(), EcalSrFlag::id(), edm::EventBase::id(), errorMatrix2Lands_multiChannel::id, FEDNumbering::MINECALFEDID, edm::EventBase::orbitNumber(), edm::print(), edm::ESHandle< T >::product(), edm::Event::put(), lumiPlot::rawdata, edm::EventID::run(), EcalTrigTowerDetId::subDet(), and EcalSrFlag::value().

{

   if (debug_) cout << "Enter in EcalDigiToRaw::produce ... " << endl;

   ESHandle< EcalElectronicsMapping > ecalmapping;
   iSetup.get< EcalMappingRcd >().get(ecalmapping);
   const EcalElectronicsMapping* TheMapping = ecalmapping.product();

   Towerblockformatter_ -> StartEvent();
   SRblockformatter_ -> StartEvent();

  runnumber_ = iEvent.id().run();

  // bx_ = (counter_ % BXMAX);
  // orbit_number_ = counter_ / BXMAX;
  // counter_ ++;

  counter_ = iEvent.id().event();
  bx_ = iEvent.bunchCrossing();
  orbit_number_ = iEvent.orbitNumber();

  lv1_ = counter_ % (0x1<<24);

  auto_ptr<FEDRawDataCollection> productRawData(new FEDRawDataCollection);


  Headerblockformatter_ -> DigiToRaw(productRawData.get());


// ---------   Now the Trigger Block part

  Handle<EcalTrigPrimDigiCollection> ecalTrigPrim;
  
  Handle<EBSrFlagCollection> ebSrFlags;
  Handle<EESrFlagCollection> eeSrFlags;


  if (doTCC_) {

     if (debug_) cout << "Creation of the TCC block  " << endl;
     // iEvent.getByType(ecalTrigPrim);
        iEvent.getByLabel(labelTT_, ecalTrigPrim);

     // loop on TP's and add one by one to the block
     for (EcalTrigPrimDigiCollection::const_iterator it = ecalTrigPrim -> begin();
                           it != ecalTrigPrim -> end(); it++) {

           const EcalTriggerPrimitiveDigi& trigprim = *it;
           const EcalTrigTowerDetId& detid = it -> id();

           if ( (detid.subDet() == EcalBarrel) && (! doBarrel_) ) continue;
           if ( (detid.subDet() == EcalEndcap) && (! doEndCap_) ) continue;

           int iDCC = TheMapping -> DCCid(detid);
           int FEDid = FEDNumbering::MINECALFEDID + iDCC;

           FEDRawData& rawdata = productRawData.get() -> FEDData(FEDid);
           
           // adding the primitive to the block
           TCCblockformatter_ -> DigiToRaw(trigprim, rawdata, TheMapping);

     }   // end loop on ecalTrigPrim

   }  // endif doTCC


   if (doSR_) { 
        if (debug_) cout << " Process the SR flags " << endl;

        if (doBarrel_) {

        // iEvent.getByType(ebSrFlags);
           iEvent.getByLabel(labelEBSR_, ebSrFlags);
                                                                                                                                                
           for (EBSrFlagCollection::const_iterator it = ebSrFlags -> begin();
                        it != ebSrFlags -> end(); it++) {
                const EcalSrFlag& srflag = *it;
                int flag = srflag.value();

                EcalTrigTowerDetId id = srflag.id();
                int Dccid = TheMapping -> DCCid(id);
                int DCC_Channel = TheMapping -> iTT(id);
                int FEDid = FEDNumbering::MINECALFEDID + Dccid;
                // if (Dccid == 10) cout << "Dcc " << Dccid << " DCC_Channel " << DCC_Channel << " flag " << flag << endl;
                if (debug_) cout << "will process SRblockformatter_ for FEDid " << dec << FEDid << endl;
                FEDRawData& rawdata = productRawData.get() -> FEDData(FEDid);
                if (debug_) Headerblockformatter_ -> print(rawdata);
                SRblockformatter_ -> DigiToRaw(Dccid,DCC_Channel,flag, rawdata);

           }
        }  // end DoBarrel


        if (doEndCap_) {
        // iEvent.getByType(eeSrFlags);
        iEvent.getByLabel(labelEESR_, eeSrFlags);

           for (EESrFlagCollection::const_iterator it = eeSrFlags -> begin();
                        it != eeSrFlags -> end(); it++) {
                const EcalSrFlag& srflag = *it;
                int flag = srflag.value();
                EcalScDetId id = srflag.id();
                pair<int, int> ind = TheMapping -> getDCCandSC(id);
                int Dccid = ind.first;
                int DCC_Channel = ind.second;

                int FEDid = FEDNumbering::MINECALFEDID + Dccid;
                FEDRawData& rawdata = productRawData.get() -> FEDData(FEDid);
                SRblockformatter_ -> DigiToRaw(Dccid,DCC_Channel,flag, rawdata);
           }
        }  // end doEndCap

   }   // endif doSR


// ---------  Now the Tower Block part

  Handle<EBDigiCollection> ebDigis;
  Handle<EEDigiCollection> eeDigis;

  if (doTower_) {

        if (doBarrel_) {
        if (debug_) cout << "Creation of the TowerBlock ... Barrel case " << endl;
        iEvent.getByLabel(label_,instanceNameEB_,ebDigis);
        for (EBDigiCollection::const_iterator it=ebDigis -> begin();
                                it != ebDigis->end(); it++) {
                const EBDataFrame& dataframe = *it;
                const EBDetId& ebdetid = it -> id();
                int DCCid = TheMapping -> DCCid(ebdetid);
                int FEDid = FEDNumbering::MINECALFEDID + DCCid ;
                FEDRawData& rawdata = productRawData.get() -> FEDData(FEDid);
                Towerblockformatter_ -> DigiToRaw(dataframe, rawdata, TheMapping);
        }

        }

        if (doEndCap_) {
        if (debug_) cout << "Creation of the TowerBlock ... EndCap case " << endl;
        iEvent.getByLabel(label_,instanceNameEE_,eeDigis);
        for (EEDigiCollection::const_iterator it=eeDigis -> begin();
                                it != eeDigis->end(); it++) {
                const EEDataFrame& dataframe = *it;
                const EEDetId& eedetid = it -> id();
                EcalElectronicsId elid = TheMapping -> getElectronicsId(eedetid);
                int DCCid = elid.dccId() ;   
                int FEDid = FEDNumbering::MINECALFEDID + DCCid;
                FEDRawData& rawdata = productRawData.get() -> FEDData(FEDid);
                Towerblockformatter_ -> DigiToRaw(dataframe, rawdata, TheMapping);
        }
        }

  }  // endif doTower_



// -------- Clean up things ...

  map<int, map<int,int> >* FEDorder = Towerblockformatter_ -> GetFEDorder();

  Headerblockformatter_ -> CleanUp(productRawData.get(), FEDorder);


/*
   cout << "For FED 633 " << endl;
         FEDRawData& rawdata = productRawData -> FEDData(633);
         Headerblockformatter_ -> print(rawdata);
*/

 // Headerblockformatter_ -> PrintSizes(productRawData.get());



 Towerblockformatter_ -> EndEvent(productRawData.get());

 iEvent.put(productRawData);


 return;

}

Member Data Documentation

int EcalDigiToRaw::bx_ [private]

Definition at line 87 of file EcalDigiToRaw.h.

Referenced by GetBX().

const int EcalDigiToRaw::BXMAX = 2808 [static]

Definition at line 75 of file EcalDigiToRaw.h.

int EcalDigiToRaw::counter_ [private]

Definition at line 83 of file EcalDigiToRaw.h.

Referenced by GetCounter().

bool EcalDigiToRaw::debug_ [private]

Definition at line 85 of file EcalDigiToRaw.h.

Referenced by GetDebug().

bool EcalDigiToRaw::doBarrel_ [private]

Definition at line 98 of file EcalDigiToRaw.h.

Referenced by GetDoBarrel().

bool EcalDigiToRaw::doEndCap_ [private]

Definition at line 99 of file EcalDigiToRaw.h.

Referenced by GetDoEndCap().

bool EcalDigiToRaw::doSR_ [private]

Definition at line 91 of file EcalDigiToRaw.h.

Referenced by GetDoSR().

bool EcalDigiToRaw::doTCC_ [private]

Definition at line 90 of file EcalDigiToRaw.h.

Referenced by GetDoTCC().

bool EcalDigiToRaw::doTower_ [private]

Definition at line 92 of file EcalDigiToRaw.h.

Referenced by GetDoTower().

Definition at line 109 of file EcalDigiToRaw.h.

std::string EcalDigiToRaw::instanceNameEB_ [private]

Definition at line 104 of file EcalDigiToRaw.h.

std::string EcalDigiToRaw::instanceNameEE_ [private]

Definition at line 105 of file EcalDigiToRaw.h.

std::string EcalDigiToRaw::label_ [private]

Definition at line 103 of file EcalDigiToRaw.h.

Definition at line 95 of file EcalDigiToRaw.h.

Definition at line 96 of file EcalDigiToRaw.h.

Definition at line 94 of file EcalDigiToRaw.h.

std::vector<int32_t> EcalDigiToRaw::listDCCId_ [private]

Definition at line 101 of file EcalDigiToRaw.h.

Referenced by GetListDCCId().

int EcalDigiToRaw::lv1_ [private]

Definition at line 88 of file EcalDigiToRaw.h.

Referenced by GetLV1().

Definition at line 84 of file EcalDigiToRaw.h.

Referenced by GetOrbit().

Definition at line 86 of file EcalDigiToRaw.h.

Referenced by GetRunNumber().

Definition at line 110 of file EcalDigiToRaw.h.

Definition at line 108 of file EcalDigiToRaw.h.

Definition at line 107 of file EcalDigiToRaw.h.