CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

PreshowerClusterShapeProducer Class Reference

#include <PreshowerClusterShapeProducer.h>

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

List of all members.

Public Types

typedef math::XYZPoint Point

Public Member Functions

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

Private Attributes

edm::InputTag endcapSClusterProducer_
int nEvt_
EndcapPiZeroDiscriminatorAlgopresh_pi0_algo
edm::InputTag preshHitProducer_
std::string PreshowerClusterShapeCollectionX_
std::string PreshowerClusterShapeCollectionY_

Detailed Description

Definition at line 24 of file PreshowerClusterShapeProducer.h.


Member Typedef Documentation

Definition at line 28 of file PreshowerClusterShapeProducer.h.


Constructor & Destructor Documentation

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

----

Definition at line 40 of file PreshowerClusterShapeProducer.cc.

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

                                                                                   {
  // use configuration file to setup input/output collection names
  // Parameters to identify the hit collections
  preshHitProducer_   = ps.getParameter<edm::InputTag>("preshRecHitProducer");
  endcapSClusterProducer_   = ps.getParameter<edm::InputTag>("endcapSClusterProducer");

  PreshowerClusterShapeCollectionX_ = ps.getParameter<string>("PreshowerClusterShapeCollectionX");
  PreshowerClusterShapeCollectionY_ = ps.getParameter<string>("PreshowerClusterShapeCollectionY");

  produces< reco::PreshowerClusterShapeCollection >(PreshowerClusterShapeCollectionX_);
  produces< reco::PreshowerClusterShapeCollection >(PreshowerClusterShapeCollectionY_);
  
  float preshStripECut = ps.getParameter<double>("preshStripEnergyCut");
  int preshNst = ps.getParameter<int>("preshPi0Nstrip");
  
  string debugString = ps.getParameter<string>("debugLevel");


  string tmpPath = ps.getUntrackedParameter<string>("pathToWeightFiles","RecoEcal/EgammaClusterProducers/data/");
  
  presh_pi0_algo = new EndcapPiZeroDiscriminatorAlgo(preshStripECut, preshNst, tmpPath.c_str()); 

  LogTrace("EcalClusters") << "PreshowerClusterShapeProducer:presh_pi0_algo class instantiated " ;
  
  
  nEvt_ = 0;

}
PreshowerClusterShapeProducer::~PreshowerClusterShapeProducer ( )

Definition at line 70 of file PreshowerClusterShapeProducer.cc.

                                                              {
   delete presh_pi0_algo;
}

Member Function Documentation

void PreshowerClusterShapeProducer::produce ( edm::Event evt,
const edm::EventSetup es 
) [virtual]

Implements edm::EDProducer.

Definition at line 75 of file PreshowerClusterShapeProducer.cc.

References edm::SortedCollection< T, SORT >::begin(), DetId::Ecal, EcalPreshower, edm::SortedCollection< T, SORT >::end(), funct::exp(), geometry, edm::EventSetup::get(), edm::Event::getByLabel(), edm::EventBase::id(), LogDebug, LogTrace, edm::Handle< T >::product(), edm::Event::put(), HI_PhotonSkim_cff::rechits, reco::PreshowerClusterShape::setSCRef(), funct::sin(), and edm::SortedCollection< T, SORT >::size().

                                                                            {

  ostringstream ostr; // use this stream for all messages in produce

  LogTrace("EcalClusters") << "\n .......  Event " << evt.id() << " with Number = " <<  nEvt_+1 << " is analyzing ....... " ;


  Handle< EcalRecHitCollection >   pRecHits;
  Handle< SuperClusterCollection > pSuperClusters;

  // get the ECAL -> Preshower geometry and topology:
  ESHandle<CaloGeometry> geoHandle;
  es.get<CaloGeometryRecord>().get(geoHandle);
  const CaloSubdetectorGeometry *geometry = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
  const CaloSubdetectorGeometry *& geometry_p = geometry;


  // create an auto_ptr to a PreshowerClusterShapeCollection
  std::auto_ptr< reco::PreshowerClusterShapeCollection > ps_cl_for_pi0_disc_x(new reco::PreshowerClusterShapeCollection);
  std::auto_ptr< reco::PreshowerClusterShapeCollection > ps_cl_for_pi0_disc_y(new reco::PreshowerClusterShapeCollection);


  CaloSubdetectorTopology* topology_p=0;
  if (geometry)
      topology_p = new EcalPreshowerTopology(geoHandle);

  
  // fetch the Preshower product (RecHits)
  evt.getByLabel( preshHitProducer_, pRecHits);
  // pointer to the object in the product
  const EcalRecHitCollection* rechits = pRecHits.product(); 
  
  LogTrace("EcalClusters") << "PreshowerClusterShapeProducer: ### Total # of preshower RecHits: " << rechits->size() ;
  
  //  if ( rechits->size() <= 0 ) return;
  
  // make the map of Preshower rechits:
  map<DetId, EcalRecHit> rechits_map;
  EcalRecHitCollection::const_iterator it;
  for (it = rechits->begin(); it != rechits->end(); it++) {
     rechits_map.insert(make_pair(it->id(), *it));
  }
  
  LogTrace("EcalClusters") << "PreshowerClusterShapeProducer: ### Preshower RecHits_map of size " << rechits_map.size() <<" was created!" ;
  
  reco::PreshowerClusterShapeCollection ps_cl_x, ps_cl_y;

  //make cycle over Photon Collection
  int SC_index  = 0;
//  Handle<PhotonCollection> correctedPhotonHandle; 
//  evt.getByLabel(photonCorrCollectionProducer_, correctedPhotonCollection_ , correctedPhotonHandle);
//  const PhotonCollection corrPhoCollection = *(correctedPhotonHandle.product());
//  cout << " Photon Collection size : " << corrPhoCollection.size() << endl;

  evt.getByLabel(endcapSClusterProducer_, pSuperClusters);
  const reco::SuperClusterCollection* SClusts = pSuperClusters.product();
  LogTrace("EcalClusters") << "### Total # Endcap Superclusters: " << SClusts->size() ;

  SuperClusterCollection::const_iterator it_s;
  for ( it_s=SClusts->begin();  it_s!=SClusts->end(); it_s++ ) {

      SuperClusterRef it_super(reco::SuperClusterRef(pSuperClusters,SC_index));
      
      float SC_Et   = it_super->energy()*sin(2*atan(exp(-it_super->eta())));
      float SC_eta  = it_super->eta();
      float SC_phi  = it_super->phi();

      LogTrace("EcalClusters") << "PreshowerClusterShapeProducer: superCl_E = " << it_super->energy() << " superCl_Et = " << SC_Et << " superCl_Eta = " << SC_eta << " superCl_Phi = " << SC_phi ;

      
      if(fabs(SC_eta) >= 1.65 && fabs(SC_eta) <= 2.5) 
        {  //  Use Preshower region only
          if (geometry)
            {
              const GlobalPoint pointSC(it_super->x(),it_super->y(),it_super->z()); // get the centroid of the SC
              LogTrace("EcalClusters") << "SC centroind = " << pointSC ;
              
              // Get the Preshower 2-planes RecHit vectors associated with the given SC
              
              DetId tmp_stripX = (dynamic_cast<const EcalPreshowerGeometry*>(geometry_p))->getClosestCellInPlane(pointSC, 1);
              DetId tmp_stripY = (dynamic_cast<const EcalPreshowerGeometry*>(geometry_p))->getClosestCellInPlane(pointSC, 2);
              ESDetId stripX = (tmp_stripX == DetId(0)) ? ESDetId(0) : ESDetId(tmp_stripX);
              ESDetId stripY = (tmp_stripY == DetId(0)) ? ESDetId(0) : ESDetId(tmp_stripY);
              
              vector<float> vout_stripE1 = presh_pi0_algo->findPreshVector(stripX, &rechits_map, topology_p);
              vector<float> vout_stripE2 = presh_pi0_algo->findPreshVector(stripY, &rechits_map, topology_p);
              
              LogTrace("EcalClusters") << "PreshowerClusterShapeProducer : ES Energy vector associated to the given SC = " ;
              for(int k1=0;k1<11;k1++) {
                LogTrace("EcalClusters") << vout_stripE1[k1] << " " ;
              }
              
              for(int k1=0;k1<11;k1++) {
                LogTrace("EcalClusters")  << vout_stripE2[k1] << " " ;
              } 
              
              reco::PreshowerClusterShape ps1 = reco::PreshowerClusterShape(vout_stripE1,1);
              ps1.setSCRef(it_super);
              ps_cl_x.push_back(ps1);
              
              reco::PreshowerClusterShape ps2 = reco::PreshowerClusterShape(vout_stripE2,2);
              ps2.setSCRef(it_super);
              ps_cl_y.push_back(ps2);
              
            }
          SC_index++;
        } // end of cycle over Endcap SC       
  } 
  // put collection of PreshowerClusterShape in the Event:
  ps_cl_for_pi0_disc_x->assign(ps_cl_x.begin(), ps_cl_x.end());
  ps_cl_for_pi0_disc_y->assign(ps_cl_y.begin(), ps_cl_y.end());
  
  evt.put(ps_cl_for_pi0_disc_x, PreshowerClusterShapeCollectionX_);
  evt.put(ps_cl_for_pi0_disc_y, PreshowerClusterShapeCollectionY_);  
  LogTrace("EcalClusters") << "PreshowerClusterShapeCollection added to the event" ;
  
  if (topology_p)
    delete topology_p;

  nEvt_++;

  LogDebug("PiZeroDiscriminatorDebug") << ostr.str();
}

Member Data Documentation

Definition at line 43 of file PreshowerClusterShapeProducer.h.

Definition at line 38 of file PreshowerClusterShapeProducer.h.

Definition at line 51 of file PreshowerClusterShapeProducer.h.

Definition at line 42 of file PreshowerClusterShapeProducer.h.

Definition at line 48 of file PreshowerClusterShapeProducer.h.

Definition at line 49 of file PreshowerClusterShapeProducer.h.