CMS 3D CMS Logo

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

L1RingSubtractionProducer Class Reference

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

List of all members.

Public Member Functions

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

Private Types

enum  { constant, mean, median }

Private Member Functions

virtual void endJob ()
double getEcalConstant (int &iEta)
double getHcalConstant (int &iEta)
virtual void produce (edm::Event &, const edm::EventSetup &)

Private Attributes

edm::ESHandle< L1CaloTriggerSetupmCaloTriggerSetup
edm::Handle
< l1slhc::L1CaloTowerCollection
mInputCollection
edm::InputTag mInputCollectionTag
std::auto_ptr
< l1slhc::L1CaloTowerCollection
mOutputCollection
enum
L1RingSubtractionProducer:: { ... }  
mRingSubtractionType

Detailed Description

Definition at line 29 of file L1RingSubtractionProducer.cc.


Member Enumeration Documentation

anonymous enum [private]
Enumerator:
constant 
mean 
median 

Definition at line 51 of file L1RingSubtractionProducer.cc.


Constructor & Destructor Documentation

L1RingSubtractionProducer::L1RingSubtractionProducer ( const edm::ParameterSet aConfig) [explicit]

Definition at line 64 of file L1RingSubtractionProducer.cc.

References constant, edm::ParameterSet::getParameter(), mean, median, mRingSubtractionType, and AlCaHLTBitMon_QueryRunRegistry::string.

                                                                                     :
mInputCollectionTag( aConfig.getParameter < edm::InputTag > ( "src" ) ),
mOutputCollection( NULL )
{
        
        std::string lRingSubtractionType = aConfig.getParameter< std::string >("RingSubtractionType");
        std::transform( lRingSubtractionType.begin() , lRingSubtractionType.end() , lRingSubtractionType.begin() , ::toupper ); //do the comparison in upper case so config file can read "Mean", "mean", "MEAN", "mEaN", etc. and give the same result.

        if( lRingSubtractionType == "MEAN" ){
                mRingSubtractionType = mean;
        }else if( lRingSubtractionType == "MEDIAN" ){ 
                mRingSubtractionType = median;
        }else{
                mRingSubtractionType = constant;
        }

        // Register Product
        produces < l1slhc::L1CaloTowerCollection > (  );
}
L1RingSubtractionProducer::~L1RingSubtractionProducer ( )

Definition at line 85 of file L1RingSubtractionProducer.cc.

{}

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 242 of file L1RingSubtractionProducer.cc.

{
}
double L1RingSubtractionProducer::getEcalConstant ( int &  iEta) [private]

Definition at line 224 of file L1RingSubtractionProducer.cc.

Referenced by produce().

                                                            {
        //can use mCaloTriggerSetup member object to retrieve a look-up table from EventSetup
        //std::cout << "Function " << __PRETTY_FUNCTION__ << " not implemented. Returning 0 for subtraction." << std::endl;
        return 0;
}
double L1RingSubtractionProducer::getHcalConstant ( int &  iEta) [private]

Definition at line 231 of file L1RingSubtractionProducer.cc.

Referenced by produce().

                                                            {
        //can use mCaloTriggerSetup member object to retrieve a look-up table from EventSetup
        //std::cout << "Function " << __PRETTY_FUNCTION__ << " not implemented. Returning 0 for subtraction." << std::endl;
        return 0;
}
void L1RingSubtractionProducer::produce ( edm::Event aEvent,
const edm::EventSetup aSetup 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 92 of file L1RingSubtractionProducer.cc.

References constant, gather_cfg::cout, edm::EventSetup::get(), edm::Event::getByLabel(), getEcalConstant(), getHcalConstant(), Association::map, mCaloTriggerSetup, mean, median, mInputCollection, mInputCollectionTag, mOutputCollection, mRingSubtractionType, edm::Event::put(), l1slhc::L1CaloTower::setEcal(), l1slhc::L1CaloTower::setHcal(), and python::multivaluedict::sort().

{

        if( mRingSubtractionType == constant ){
                std::cout << "!!! WARNING !!! Constant ring subtraction is yet not implemented. A constant of 0 will be assumed !!! WARNING !!!\n" << std::endl;
        }

        aSetup.get < L1CaloTriggerSetupRcd > (  ).get( mCaloTriggerSetup );

        aEvent.getByLabel( mInputCollectionTag, mInputCollection );

        // create a new l1slhc::L1CaloTowerCollection (auto_ptr should handle deletion of the last one correctly)
        mOutputCollection = std::auto_ptr < l1slhc::L1CaloTowerCollection > ( new l1slhc::L1CaloTowerCollection );

        if( mRingSubtractionType  == mean ){

                std::map< int , double > lMeanEcal , lMeanHcal;

                for( l1slhc::L1CaloTowerCollection::const_iterator lInputIt = mInputCollection->begin() ; lInputIt != mInputCollection->end() ; ++lInputIt ){
                        lMeanEcal[ lInputIt->iEta() ] += double(lInputIt->E());
                        lMeanHcal[ lInputIt->iEta() ] += double(lInputIt->H());
                }

                //Empty towers are assumed to have zero energy contribution, so we divide by all towers
                for( std::map< int , double >::iterator lIt = lMeanEcal.begin() ; lIt != lMeanEcal.end() ; ++lIt ){
                        lIt->second /= 72;
                }

                //Empty towers are assumed to have zero energy contribution, so we divide by all towers
                for( std::map< int , double >::iterator lIt = lMeanHcal.begin() ; lIt != lMeanHcal.end() ; ++lIt ){
                        lIt->second /= 72;
                }

                for( l1slhc::L1CaloTowerCollection::const_iterator lInputIt = mInputCollection->begin() ; lInputIt != mInputCollection->end() ; ++lInputIt ){
                        int lEta =      lInputIt->iEta();               
                        int lPhi =      lInputIt->iPhi();               

                        int lEcal = int( double(lInputIt->E()) - lMeanEcal[ lEta ] );
                        int lHcal = int( double(lInputIt->H()) - lMeanHcal[ lEta ] );

                        l1slhc::L1CaloTower lCaloTower( lEta , lPhi );
                        lCaloTower.setEcal( lEcal , lInputIt->EcalFG() );
                        lCaloTower.setHcal( lHcal , lInputIt->HcalFG() );
        
                        mOutputCollection->insert( lEta , lPhi , lCaloTower );
                }


        } else if( mRingSubtractionType  == median ){

                std::map< int , std::deque<int> > lEcals , lHcals;

                for( l1slhc::L1CaloTowerCollection::const_iterator lInputIt = mInputCollection->begin() ; lInputIt != mInputCollection->end() ; ++lInputIt ){
                        lEcals[ lInputIt->iEta() ].push_back( lInputIt->E() );
                        lHcals[ lInputIt->iEta() ].push_back( lInputIt->H() );

                        //std::cout<<"ECal energy: "<<lInputIt->E()<<std::endl;
                        //std::cout<<"HCal energy: "<<lInputIt->H()<<std::endl;
                }

                std::map< int , double > lMedianEcal , lMedianHcal;

                //Empty towers are assumed to have zero energy contribution
                for( std::map< int , std::deque<int> >::iterator lIt = lEcals.begin() ; lIt != lEcals.end() ; ++lIt ){
                        lIt->second.resize( 72 , 0 );
                        std::sort( lIt->second.begin() , lIt->second.end() );
                        lMedianEcal[ lIt->first ] = (lIt->second.at( 35 ) + lIt->second.at( 36 )) / 2.0;                
        }


                //Empty towers are assumed to have zero energy contribution
                for( std::map< int , std::deque<int> >::iterator lIt = lHcals.begin() ; lIt != lHcals.end() ; ++lIt ){
                        lIt->second.resize( 72 , 0 );
                        std::sort( lIt->second.begin() , lIt->second.end() );
                        lMedianHcal[ lIt->first ] = (lIt->second.at( 35 ) + lIt->second.at( 36 )) / 2.0;
        
        }


                for( l1slhc::L1CaloTowerCollection::const_iterator lInputIt = mInputCollection->begin() ; lInputIt != mInputCollection->end() ; ++lInputIt ){
                        int lEta =      lInputIt->iEta();               
                        int lPhi =      lInputIt->iPhi();               

                        int lEcal = int( double(lInputIt->E()) - lMedianEcal[ lEta ] );
                        int lHcal = int( double(lInputIt->H()) - lMedianHcal[ lEta ] );

                        l1slhc::L1CaloTower lCaloTower( lEta , lPhi );
                        lCaloTower.setEcal( lEcal , lInputIt->EcalFG() );
                        lCaloTower.setHcal( lHcal , lInputIt->HcalFG() );
        
                        mOutputCollection->insert( lEta , lPhi , lCaloTower );
                }

        }else{


                for( l1slhc::L1CaloTowerCollection::const_iterator lInputIt = mInputCollection->begin() ; lInputIt != mInputCollection->end() ; ++lInputIt ){
                        int lEta =      lInputIt->iEta();               
                        int lPhi =      lInputIt->iPhi();               

                        int lEcal = int( double(lInputIt->E()) - getEcalConstant( lEta ) );
                        int lHcal = int( double(lInputIt->H()) - getHcalConstant( lEta ) );

                        l1slhc::L1CaloTower lCaloTower( lEta , lPhi );
                        lCaloTower.setEcal( lEcal , lInputIt->EcalFG() );
                        lCaloTower.setHcal( lHcal , lInputIt->HcalFG() );
        
                        mOutputCollection->insert( lEta , lPhi , lCaloTower );
                }


        }
        
        
        
        

        
        aEvent.put( mOutputCollection );
}

Member Data Documentation

Definition at line 40 of file L1RingSubtractionProducer.cc.

Referenced by produce().

Definition at line 43 of file L1RingSubtractionProducer.cc.

Referenced by produce().

Definition at line 42 of file L1RingSubtractionProducer.cc.

Referenced by produce().

Definition at line 44 of file L1RingSubtractionProducer.cc.

Referenced by produce().