CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

EcalTPSkimmer Class Reference

#include <EcalTPSkimmer.h>

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

List of all members.

Public Member Functions

 EcalTPSkimmer (const edm::ParameterSet &ps)
virtual void produce (edm::Event &evt, const edm::EventSetup &es)
 ~EcalTPSkimmer ()

Private Member Functions

bool alreadyInserted (EcalTrigTowerDetId ttId)
void insertTP (EcalTrigTowerDetId ttId, edm::Handle< EcalTrigPrimDigiCollection > &in, EcalTrigPrimDigiCollection &out)

Private Attributes

std::vector< uint32_t > chStatusToSelectTP_
bool doBarrel_
bool doEndcap_
std::set< EcalTrigTowerDetIdinsertedTP_
bool skipModule_
std::string tpCollection_
edm::InputTag tpInputCollection_
std::string tpOutputCollection_
edm::ESHandle
< EcalTrigTowerConstituentsMap
ttMap_

Detailed Description

produce a subset of TP information

Id:
EcalTPSkimmer.cc,v 1.2 2010/10/02 16:13:54 ferriff Exp
Date:
2010/10/02 16:13:54
Revision:
1.2
Author:
Federico Ferri, CEA/Saclay Irfu/SPP

produce a subset of TP information

Id:
EcalTPSkimmer.h,v 1.1 2010/10/01 16:27:13 ferriff Exp
Date:
2010/10/01 16:27:13
Revision:
1.1
Author:
Federico Ferri, CEA/Saclay Irfu/SPP

Definition at line 25 of file EcalTPSkimmer.h.


Constructor & Destructor Documentation

EcalTPSkimmer::EcalTPSkimmer ( const edm::ParameterSet ps) [explicit]

Definition at line 27 of file EcalTPSkimmer.cc.

References chStatusToSelectTP_, doBarrel_, doEndcap_, edm::ParameterSet::getParameter(), skipModule_, tpInputCollection_, and tpOutputCollection_.

{
        skipModule_         = ps.getParameter<bool>("skipModule");

        doBarrel_           = ps.getParameter<bool>("doBarrel");
        doEndcap_           = ps.getParameter<bool>("doEndcap");

        chStatusToSelectTP_ = ps.getParameter<std::vector<uint32_t> >("chStatusToSelectTP");

        tpOutputCollection_ = ps.getParameter<std::string>("tpOutputCollection");
        tpInputCollection_  = ps.getParameter<edm::InputTag>("tpInputCollection");

        produces< EcalTrigPrimDigiCollection >(tpOutputCollection_);
}
EcalTPSkimmer::~EcalTPSkimmer ( )

Definition at line 42 of file EcalTPSkimmer.cc.

{
}

Member Function Documentation

bool EcalTPSkimmer::alreadyInserted ( EcalTrigTowerDetId  ttId) [private]

Definition at line 132 of file EcalTPSkimmer.cc.

References insertedTP_.

Referenced by produce().

{
        return ( insertedTP_.find( ttId ) != insertedTP_.end() );
}
void EcalTPSkimmer::insertTP ( EcalTrigTowerDetId  ttId,
edm::Handle< EcalTrigPrimDigiCollection > &  in,
EcalTrigPrimDigiCollection out 
) [private]

Definition at line 138 of file EcalTPSkimmer.cc.

References insertedTP_, and edm::SortedCollection< T, SORT >::push_back().

Referenced by produce().

{
        EcalTrigPrimDigiCollection::const_iterator tpIt = tpIn->find( ttId );
        if ( tpIt != tpIn->end() ) {
                tpOut.push_back( *tpIt );
                insertedTP_.insert( ttId );
        }
}
void EcalTPSkimmer::produce ( edm::Event evt,
const edm::EventSetup es 
) [virtual]

Implements edm::EDProducer.

Definition at line 47 of file EcalTPSkimmer.cc.

References alreadyInserted(), chStatusToSelectTP_, EBDetId::detIdFromDenseIndex(), EEDetId::detIdFromDenseIndex(), doBarrel_, doEndcap_, spr::find(), edm::EventSetup::get(), edm::Event::getByLabel(), i, insertedTP_, insertTP(), edm::InputTag::instance(), EBDetId::kSizeForDenseIndexing, EEDetId::kSizeForDenseIndexing, edm::InputTag::label(), edm::Event::put(), skipModule_, tpInputCollection_, tpOutputCollection_, ttMap_, EBDetId::validDenseIndex(), and EEDetId::validDenseIndex().

{
        insertedTP_.clear();
        
        using namespace edm;

        es.get<IdealGeometryRecord>().get(ttMap_);

        // collection of rechits to put in the event
        std::auto_ptr< EcalTrigPrimDigiCollection > tpOut( new EcalTrigPrimDigiCollection );
        
        if ( skipModule_ ) {
                evt.put( tpOut, tpOutputCollection_ );
                return;
        }

        edm::ESHandle<EcalChannelStatus> chStatus;
        es.get<EcalChannelStatusRcd>().get(chStatus);

        edm::Handle<EcalTrigPrimDigiCollection> tpIn;
        evt.getByLabel(tpInputCollection_, tpIn);

        if ( ! tpIn.isValid() ) {
                edm::LogError("EcalTPSkimmer") << "Can't get the product " << tpInputCollection_.instance()
                        << " with label " << tpInputCollection_.label();
                return;
        }

        if ( doBarrel_ ) {
                EcalChannelStatusMap::const_iterator chit;
                uint16_t code = 0;
                for ( int i = 0; i < EBDetId::kSizeForDenseIndexing; ++i )
                {
                        if ( ! EBDetId::validDenseIndex( i ) ) continue;
                        EBDetId id = EBDetId::detIdFromDenseIndex( i );
                        chit = chStatus->find( id );
                        // check if the channel status means TP to be kept
                        if ( chit != chStatus->end() ) {
                                code = (*chit).getStatusCode() & 0x001F;
                                if ( std::find( chStatusToSelectTP_.begin(), chStatusToSelectTP_.end(), code ) != chStatusToSelectTP_.end() ) {
                                        // retrieve the TP DetId
                                        EcalTrigTowerDetId ttDetId( ((EBDetId)id).tower() );
                                        // insert the TP if not done already
                                        if ( ! alreadyInserted( ttDetId ) ) insertTP( ttDetId, tpIn, *tpOut );
                                }
                        } else {
                                edm::LogError("EcalDetIdToBeRecoveredProducer") << "No channel status found for xtal "
                                        << id.rawId()
                                        << "! something wrong with EcalChannelStatus in your DB? ";
                        }
                }
        }

        if ( doEndcap_ ) {
                EcalChannelStatusMap::const_iterator chit;
                uint16_t code = 0;
                for ( int i = 0; i < EEDetId::kSizeForDenseIndexing; ++i )
                {
                        if ( ! EEDetId::validDenseIndex( i ) ) continue;
                        EEDetId id = EEDetId::detIdFromDenseIndex( i );
                        chit = chStatus->find( id );
                        // check if the channel status means TP to be kept
                        if ( chit != chStatus->end() ) {
                                code = (*chit).getStatusCode() & 0x001F;
                                if ( std::find( chStatusToSelectTP_.begin(), chStatusToSelectTP_.end(), code ) != chStatusToSelectTP_.end() ) {
                                        // retrieve the TP DetId
                                        EcalTrigTowerDetId ttDetId = ttMap_->towerOf( id );
                                        // insert the TP if not done already
                                        if ( ! alreadyInserted( ttDetId ) ) insertTP( ttDetId, tpIn, *tpOut );
                                }
                        } else {
                                edm::LogError("EcalDetIdToBeRecoveredProducer") << "No channel status found for xtal "
                                        << id.rawId()
                                        << "! something wrong with EcalChannelStatus in your DB? ";
                        }
                }
        }

        // put the collection of reconstructed hits in the event   
        LogInfo("EcalTPSkimmer") << "total # of TP inserted: " << tpOut->size();

        evt.put( tpOut, tpOutputCollection_ );
}

Member Data Documentation

std::vector<uint32_t> EcalTPSkimmer::chStatusToSelectTP_ [private]

Definition at line 43 of file EcalTPSkimmer.h.

Referenced by EcalTPSkimmer(), and produce().

bool EcalTPSkimmer::doBarrel_ [private]

Definition at line 40 of file EcalTPSkimmer.h.

Referenced by EcalTPSkimmer(), and produce().

bool EcalTPSkimmer::doEndcap_ [private]

Definition at line 41 of file EcalTPSkimmer.h.

Referenced by EcalTPSkimmer(), and produce().

Definition at line 46 of file EcalTPSkimmer.h.

Referenced by alreadyInserted(), insertTP(), and produce().

Definition at line 39 of file EcalTPSkimmer.h.

Referenced by EcalTPSkimmer(), and produce().

std::string EcalTPSkimmer::tpCollection_ [private]

Definition at line 37 of file EcalTPSkimmer.h.

Definition at line 48 of file EcalTPSkimmer.h.

Referenced by EcalTPSkimmer(), and produce().

std::string EcalTPSkimmer::tpOutputCollection_ [private]

Definition at line 50 of file EcalTPSkimmer.h.

Referenced by EcalTPSkimmer(), and produce().

Definition at line 44 of file EcalTPSkimmer.h.

Referenced by produce().