CMS 3D CMS Logo

AlCaElectronsProducer Class Reference

class declaration More...

#include <Calibration/EcalAlCaRecoProducers/src/AlCaElectronsProducer.cc>

Inheritance diagram for AlCaElectronsProducer:

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

List of all members.

Public Member Functions

 AlCaElectronsProducer (const edm::ParameterSet &)
 ctor
virtual void produce (edm::Event &, const edm::EventSetup &)
 producer
 ~AlCaElectronsProducer ()

Private Attributes

std::string alcaBarrelHitsCollection_
std::string alcaEndcapHitsCollection_
edm::InputTag ebRecHitsLabel_
edm::InputTag eeRecHitsLabel_
edm::InputTag electronLabel_
int etaSize_
int phiSize_


Detailed Description

class declaration

Description: Example of a producer of AlCa electrons.

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

Definition at line 45 of file AlCaElectronsProducer.h.


Constructor & Destructor Documentation

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

ctor

Definition at line 15 of file AlCaElectronsProducer.cc.

References alcaBarrelHitsCollection_, alcaEndcapHitsCollection_, ebRecHitsLabel_, eeRecHitsLabel_, electronLabel_, etaSize_, edm::ParameterSet::getParameter(), and phiSize_.

00016 {
00017 
00018   ebRecHitsLabel_ = iConfig.getParameter< edm::InputTag > ("ebRecHitsLabel");
00019   eeRecHitsLabel_ = iConfig.getParameter< edm::InputTag > ("eeRecHitsLabel");
00020   electronLabel_ = iConfig.getParameter< edm::InputTag > ("electronLabel");
00021 
00022   alcaBarrelHitsCollection_ = iConfig.getParameter<std::string>("alcaBarrelHitCollection");
00023   alcaEndcapHitsCollection_ = iConfig.getParameter<std::string>("alcaEndcapHitCollection");
00024   
00025   etaSize_ = iConfig.getParameter<int> ("etaSize");
00026   phiSize_ = iConfig.getParameter<int> ("phiSize");
00027   if ( phiSize_ % 2 == 0 ||  etaSize_ % 2 == 0)
00028     edm::LogError("AlCaElectronsProducerError") << "Size of eta/phi should be odd numbers";
00029  
00030    //register your products
00031   produces< EBRecHitCollection > (alcaBarrelHitsCollection_) ;
00032   produces< EERecHitCollection > (alcaEndcapHitsCollection_) ;
00033   
00034 }

AlCaElectronsProducer::~AlCaElectronsProducer (  ) 

Definition at line 37 of file AlCaElectronsProducer.cc.

00038 {}


Member Function Documentation

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

producer

Implements edm::EDProducer.

Definition at line 43 of file AlCaElectronsProducer.cc.

References alcaBarrelHitsCollection_, alcaEndcapHitsCollection_, ebRecHitsLabel_, DetId::Ecal, EcalBarrel, EcalEndcap, eeRecHitsLabel_, electronLabel_, edm::SortedCollection< T, SORT >::end(), relval_parameters_module::energy, EBDetId::ETAPHIMODE, etaSize_, false, edm::SortedCollection< T, SORT >::find(), find(), edm::Event::getByLabel(), reco::SuperCluster::getHitsByDetId(), EBDetId::ieta(), EBDetId::iphi(), EEDetId::ix(), EEDetId::iy(), DetId::null(), phiSize_, edm::Event::put(), row, std, true, v1, and EEDetId::XYMODE.

00045 {
00046    using namespace edm;
00047    using namespace std;
00048 
00049   // Get GSFElectrons
00050   Handle<reco::GsfElectronCollection> pElectrons;
00051   iEvent.getByLabel(electronLabel_, pElectrons);
00052   if (!pElectrons.isValid()) {
00053       edm::LogError ("reading") << electronLabel_ << " not found" ; 
00054 //      std::cerr << "[AlCaElectronsProducer]" << electronLabel_ << " not found" ; 
00055       return ;
00056   }
00057 
00058   const reco::GsfElectronCollection * electronCollection = 
00059      pElectrons.product();
00060   
00061   // get RecHits
00062   Handle<EBRecHitCollection> barrelRecHitsHandle;
00063   bool barrelIsFull = true ;
00064 
00065   iEvent.getByLabel(ebRecHitsLabel_,barrelRecHitsHandle);
00066   if (!barrelRecHitsHandle.isValid()) {
00067       edm::LogError ("reading") << ebRecHitsLabel_ << " not found" ; 
00068       barrelIsFull = false ;
00069   }
00070 
00071   const EBRecHitCollection * barrelHitsCollection = 0 ;
00072   if (barrelIsFull)  
00073     barrelHitsCollection = barrelRecHitsHandle.product () ;
00074 
00075   // get RecHits
00076   Handle<EERecHitCollection> endcapRecHitsHandle;
00077   bool endcapIsFull = true ;
00078 
00079   iEvent.getByLabel(eeRecHitsLabel_,endcapRecHitsHandle);
00080   if (!endcapRecHitsHandle.isValid()) {
00081       edm::LogError ("reading") << eeRecHitsLabel_ << " not found" ; 
00082       endcapIsFull = false ;
00083     }
00084 
00085   const EERecHitCollection * endcapHitsCollection = 0 ;
00086   if (endcapIsFull)  
00087     endcapHitsCollection = endcapRecHitsHandle.product () ;
00088 //  const EERecHitCollection * endcapHitsCollection = endcapRecHitsHandle.product();
00089 
00090   //Create empty output collections
00091   std::auto_ptr< EBRecHitCollection > miniEBRecHitCollection (new EBRecHitCollection) ;
00092   std::auto_ptr< EERecHitCollection > miniEERecHitCollection (new EERecHitCollection) ;
00093 
00094 //  loop on SiStrip Electrons
00095   
00096   reco::GsfElectronCollection::const_iterator eleIt;
00097   int ii=0;
00098   
00099   for (eleIt=electronCollection->begin(); eleIt!=electronCollection->end(); eleIt++) {
00100     //PG barrel
00101     if (fabs(eleIt->eta()) <= 1.479) 
00102       {
00103     
00104     ii++;         
00105     const reco::SuperCluster& sc = *(eleIt->superCluster()) ;
00106     
00107     int yy = 0;
00108     double currEnergy = 0.;
00109     EBDetId maxHit(0);
00110     vector<EBDetId> scXtals;
00111     scXtals.clear();
00112     const std::vector<DetId> & v1 = sc.getHitsByDetId();
00113     
00114     for(std::vector<DetId>::const_iterator idsIt = v1.begin(); 
00115         idsIt != v1.end(); ++idsIt) 
00116       {
00117         yy++;
00118         
00119         //PG discard hits not belonging to the Ecal Barrel
00120         if((*idsIt).subdetId()!=EcalBarrel || (*idsIt).det()!= DetId::Ecal) continue;
00121         
00122         if((barrelHitsCollection->find(*idsIt))->energy() > currEnergy) {
00123             currEnergy=(barrelHitsCollection->find(*idsIt))->energy();
00124             maxHit=*idsIt;
00125           }
00126         miniEBRecHitCollection->push_back(*(barrelHitsCollection->find(*idsIt)));
00127         scXtals.push_back(*idsIt);
00128       }
00129     
00130     if (!maxHit.null())
00131       for (unsigned int icry=0;icry< etaSize_*phiSize_;icry++)
00132         {
00133           
00134           unsigned int row = icry / etaSize_;
00135           unsigned int column= icry % etaSize_;
00136           int curr_eta=maxHit.ieta() + column - (etaSize_/2);
00137           int curr_phi=maxHit.iphi() + row - (phiSize_/2);
00138           
00139           if (curr_eta * maxHit.ieta() <= 0) {if (maxHit.ieta() > 0) curr_eta--; else curr_eta++; }  // JUMP over 0
00140           if (curr_phi < 1) curr_phi += 360;
00141           if (curr_phi > 360) curr_phi -= 360;
00142           
00143           try
00144         {
00145           EBDetId det = EBDetId(curr_eta,curr_phi,EBDetId::ETAPHIMODE);
00146           std::vector<EBDetId>::const_iterator usedIds;
00147           
00148           bool HitAlreadyUsed=false;
00149           for(usedIds=scXtals.begin(); usedIds!=scXtals.end(); usedIds++)
00150             if(*usedIds==det)
00151               {
00152             HitAlreadyUsed=true;
00153             break;
00154               }
00155           
00156           if(!HitAlreadyUsed)
00157             if (barrelHitsCollection->find(det) != barrelHitsCollection->end())
00158               miniEBRecHitCollection->push_back(*(barrelHitsCollection->find(det)));
00159         }
00160           catch (...)
00161         {edm::LogWarning ("shape") << "In Barrel DetId not built Eta "<<curr_eta<<" Phi "<<curr_phi ;}
00162         }
00163       } //PG barrel
00164     else //PG endcap
00165       {
00166     
00167     ii++;         
00168     const reco::SuperCluster& sc = *(eleIt->superCluster()) ;
00169     
00170     int yy = 0;
00171     double currEnergy = 0.;
00172     EEDetId maxHit(0);
00173     vector<EEDetId> scXtals;
00174     scXtals.clear();
00175     const std::vector<DetId> & v1 = sc.getHitsByDetId();
00176     
00177     for(std::vector<DetId>::const_iterator idsIt = v1.begin(); 
00178         idsIt != v1.end(); ++idsIt) 
00179       {
00180         yy++;
00181         
00182         //PG discard hits belonging to the Ecal Barrel
00183         if((*idsIt).subdetId()!=EcalEndcap || 
00184            (*idsIt).det()!= DetId::Ecal) continue;
00185         
00186         if((endcapHitsCollection->find(*idsIt))->energy() > currEnergy) 
00187           {
00188             currEnergy=(endcapHitsCollection->find(*idsIt))->energy();
00189             maxHit=*idsIt;
00190           }
00191         miniEERecHitCollection->push_back (
00192             *(endcapHitsCollection->find (*idsIt))
00193           );
00194         scXtals.push_back (*idsIt) ; 
00195     }  
00196 
00197     int side = phiSize_ ;
00198     if (phiSize_ < etaSize_) side = etaSize_ ;
00199     int iz = 1 ;
00200     if (eleIt->eta () < 0)  iz = -1 ;
00201     if (!maxHit.null())
00202       //PG loop over the local array of xtals
00203       for (unsigned int icry = 0 ; icry < side*side ; icry++)
00204         {          
00205           unsigned int row = icry / side ;
00206           unsigned int column = icry % side ;
00207           int curr_eta = maxHit.ix () + column - (side/2);
00208           int curr_phi = maxHit.iy () + row - (side/2);
00209           if (   curr_eta <= 0 || curr_phi <= 0
00210               || curr_eta > 100 || curr_phi > 100 ) continue ;
00211           
00212           
00213           try
00214             {
00215               EEDetId det = EEDetId (curr_eta,curr_phi,iz,EEDetId::XYMODE) ; 
00216               if (find (scXtals.begin (), scXtals.end (), det) != scXtals.end ())
00217                 if (endcapHitsCollection->find (det) != endcapHitsCollection->end ())
00218                   miniEERecHitCollection->push_back (*(endcapHitsCollection->find (det))) ;
00219             }
00220           catch (...)
00221             {
00222               edm::LogWarning ("shape") << "DetId (" 
00223                                         << curr_eta << "," << curr_phi 
00224                                         << ") not built" ;
00225 //PG              m_failMap->Fill (curr_eta,curr_phi) ;
00226             }
00227         }
00228       } //PG endcap
00229       
00230   } //PG loop on Si strip electrons
00231     
00232   //Put selected information in the event
00233   iEvent.put( miniEBRecHitCollection,alcaBarrelHitsCollection_ );
00234   iEvent.put( miniEERecHitCollection,alcaEndcapHitsCollection_ );     
00235 }


Member Data Documentation

std::string AlCaElectronsProducer::alcaBarrelHitsCollection_ [private]

Definition at line 82 of file AlCaElectronsProducer.h.

Referenced by AlCaElectronsProducer(), and produce().

std::string AlCaElectronsProducer::alcaEndcapHitsCollection_ [private]

Definition at line 83 of file AlCaElectronsProducer.h.

Referenced by AlCaElectronsProducer(), and produce().

edm::InputTag AlCaElectronsProducer::ebRecHitsLabel_ [private]

Definition at line 79 of file AlCaElectronsProducer.h.

Referenced by AlCaElectronsProducer(), and produce().

edm::InputTag AlCaElectronsProducer::eeRecHitsLabel_ [private]

Definition at line 80 of file AlCaElectronsProducer.h.

Referenced by AlCaElectronsProducer(), and produce().

edm::InputTag AlCaElectronsProducer::electronLabel_ [private]

Definition at line 81 of file AlCaElectronsProducer.h.

Referenced by AlCaElectronsProducer(), and produce().

int AlCaElectronsProducer::etaSize_ [private]

Definition at line 84 of file AlCaElectronsProducer.h.

Referenced by AlCaElectronsProducer(), and produce().

int AlCaElectronsProducer::phiSize_ [private]

Definition at line 85 of file AlCaElectronsProducer.h.

Referenced by AlCaElectronsProducer(), and produce().


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