#include <Alignment/OfflineValidation/plugins/EopTreeWriter.cc>
Public Member Functions | |
EopTreeWriter (const edm::ParameterSet &) | |
~EopTreeWriter () | |
Private Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) |
virtual void | beginJob () |
virtual void | endJob () |
double | getDistInCM (double eta1, double phi1, double eta2, double phi2) |
Private Attributes | |
edm::Service< TFileService > | fs_ |
TrackAssociatorParameters | parameters_ |
edm::InputTag | src_ |
TrackDetectorAssociator | trackAssociator_ |
TTree * | tree_ |
EopVariables * | treeMemPtr_ |
Description: <one line="" class="" summary>="">
Implementation: <Notes on="" implementation>="">
Definition at line 68 of file EopTreeWriter.cc.
EopTreeWriter::EopTreeWriter | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 102 of file EopTreeWriter.cc.
References fs_, edm::ParameterSet::getParameter(), TrackAssociatorParameters::loadParameters(), Parameters::parameters, parameters_, tree_, and treeMemPtr_.
: src_(iConfig.getParameter<edm::InputTag>("src")) { //now do what ever initialization is needed // TrackAssociator parameters edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters"); parameters_.loadParameters( parameters ); tree_ = fs_->make<TTree>("EopTree","EopTree"); treeMemPtr_ = new EopVariables; tree_->Branch("EopVariables", &treeMemPtr_); // address of pointer! }
EopTreeWriter::~EopTreeWriter | ( | ) |
Definition at line 117 of file EopTreeWriter.cc.
{ // do anything here that needs to be done at destruction time // (e.g. close files, deallocate resources etc.) }
void EopTreeWriter::analyze | ( | const edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Implements edm::EDAnalyzer.
Definition at line 132 of file EopTreeWriter.cc.
References TrackDetectorAssociator::associate(), TrackDetMatchInfo::EcalRecHits, PV3DBase< T, PVType, FrameType >::eta(), Exception, EopVariables::fillVariables(), geometry, edm::EventSetup::get(), edm::Event::getByLabel(), getDistInCM(), TrackDetectorAssociator::getFreeTrajectoryState(), TrackDetMatchInfo::HcalRecHits, i, info, TrackDetMatchInfo::nXnEnergy(), parameters_, PV3DBase< T, PVType, FrameType >::phi(), edm::ESHandle< T >::product(), src_, trackAssociator_, testEve_cfg::tracks, tree_, treeMemPtr_, TrackDetMatchInfo::trkGlobPosAtEcal, TrackDetectorAssociator::useDefaultPropagator(), and TrackAssociatorParameters::useMuon.
{ using namespace edm; // get geometry edm::ESHandle<CaloGeometry> geometry; iSetup.get<CaloGeometryRecord>().get(geometry); const CaloGeometry* geo = geometry.product(); // const CaloSubdetectorGeometry* towerGeometry = // geo->getSubdetectorGeometry(DetId::Calo, CaloTowerDetId::SubdetId); // temporary collection of EB+EE recHits std::auto_ptr<EcalRecHitCollection> tmpEcalRecHitCollection(new EcalRecHitCollection); std::vector<edm::InputTag> ecalLabels_; edm::Handle<EcalRecHitCollection> tmpEc; bool ecalInAlca = iEvent.getByLabel(edm::InputTag("IsoProd","IsoTrackEcalRecHitCollection"),tmpEc); bool ecalInReco = iEvent.getByLabel(edm::InputTag("ecalRecHit","EcalRecHitsEB"),tmpEc)&& iEvent.getByLabel(edm::InputTag("ecalRecHit","EcalRecHitsEE"),tmpEc); if(ecalInAlca)ecalLabels_.push_back(edm::InputTag("IsoProd","IsoTrackEcalRecHitCollection")); else if(ecalInReco){ ecalLabels_.push_back(edm::InputTag("ecalRecHit","EcalRecHitsEB")); ecalLabels_.push_back(edm::InputTag("ecalRecHit","EcalRecHitsEE")); } else throw cms::Exception("MissingProduct","can not find EcalRecHits"); std::vector<edm::InputTag>::const_iterator i; for (i=ecalLabels_.begin(); i!=ecalLabels_.end(); i++) { edm::Handle<EcalRecHitCollection> ec; iEvent.getByLabel(*i,ec); for(EcalRecHitCollection::const_iterator recHit = (*ec).begin(); recHit != (*ec).end(); ++recHit) { tmpEcalRecHitCollection->push_back(*recHit); } } edm::Handle<reco::TrackCollection> tracks; iEvent.getByLabel(src_, tracks); edm::Handle<reco::IsolatedPixelTrackCandidateCollection> isoPixelTracks; edm::Handle<reco::IsolatedPixelTrackCandidateCollection> tmpPix; bool pixelInAlca = iEvent.getByLabel(edm::InputTag("IsoProd","HcalIsolatedTrackCollection"),tmpPix); if(pixelInAlca)iEvent.getByLabel(edm::InputTag("IsoProd","HcalIsolatedTrackCollection"),isoPixelTracks); Double_t trackemc1; Double_t trackemc3; Double_t trackemc5; Double_t trackhac1; Double_t trackhac3; Double_t trackhac5; Double_t maxPNearby; Double_t dist; Double_t EnergyIn; Double_t EnergyOut; parameters_.useMuon = false; if(pixelInAlca) if(isoPixelTracks->size()==0) return; for(reco::TrackCollection::const_iterator track = tracks->begin();track!=tracks->end();++track){ bool noChargedTracks = true; if(track->p()<9.) continue; trackAssociator_.useDefaultPropagator(); TrackDetMatchInfo info = trackAssociator_.associate(iEvent, iSetup, trackAssociator_.getFreeTrajectoryState(iSetup, *track), parameters_); trackemc1 = 0; trackemc3 = 0; trackemc5 = 0; trackhac1 = 0; trackhac3 = 0; trackhac5 = 0; trackemc1 = info.nXnEnergy(TrackDetMatchInfo::EcalRecHits, 0); trackemc3 = info.nXnEnergy(TrackDetMatchInfo::EcalRecHits, 1); trackemc5 = info.nXnEnergy(TrackDetMatchInfo::EcalRecHits, 2); trackhac1 = info.nXnEnergy(TrackDetMatchInfo::HcalRecHits, 0); trackhac3 = info.nXnEnergy(TrackDetMatchInfo::HcalRecHits, 1); trackhac5 = info.nXnEnergy(TrackDetMatchInfo::HcalRecHits, 2); if(trackhac3<5.) continue; double etaecal=info.trkGlobPosAtEcal.eta(); double phiecal=info.trkGlobPosAtEcal.phi(); maxPNearby=-10; dist=50; for (reco::TrackCollection::const_iterator track1 = tracks->begin(); track1!=tracks->end(); track1++) { if (track == track1) continue; TrackDetMatchInfo info1 = trackAssociator_.associate(iEvent, iSetup, *track1, parameters_); double etaecal1=info1.trkGlobPosAtEcal.eta(); double phiecal1=info1.trkGlobPosAtEcal.phi(); if (etaecal1==0&&phiecal1==0) continue; double ecDist=getDistInCM(etaecal,phiecal,etaecal1,phiecal1); if( ecDist < 40. ) { //calculate maximum P and sum P near seed track if (track1->p()>maxPNearby) { maxPNearby=track1->p(); dist = ecDist; } //apply loose isolation criteria if (track1->p()>5.) { noChargedTracks = false; break; } } } EnergyIn=0; EnergyOut=0; if(noChargedTracks){ for (std::vector<EcalRecHit>::const_iterator ehit=tmpEcalRecHitCollection->begin(); ehit!=tmpEcalRecHitCollection->end(); ehit++) { // R-scheme of ECAL CLUSTERIZATION GlobalPoint posH = geo->getPosition((*ehit).detid()); double phihit = posH.phi(); double etahit = posH.eta(); double dHitCM=getDistInCM(etaecal,phiecal,etahit,phihit); if (dHitCM<9.0) { EnergyIn+=ehit->energy(); } if (dHitCM>15.0&&dHitCM<35.0) { EnergyOut+=ehit->energy(); } } treeMemPtr_->fillVariables(track->charge(), track->innerOk(), track->outerRadius(), track->numberOfValidHits(), track->numberOfLostHits(), track->chi2(), track->normalizedChi2(), track->p(), track->pt(), track->ptError(), track->theta(), track->eta(), track->phi(), trackemc1, trackemc3, trackemc5, trackhac1, trackhac3, trackhac5, maxPNearby, dist, EnergyIn, EnergyOut); tree_->Fill(); } } }
void EopTreeWriter::beginJob | ( | void | ) | [private, virtual] |
void EopTreeWriter::endJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 298 of file EopTreeWriter.cc.
References treeMemPtr_.
{ delete treeMemPtr_; treeMemPtr_ = 0; }
double EopTreeWriter::getDistInCM | ( | double | eta1, |
double | phi1, | ||
double | eta2, | ||
double | phi2 | ||
) | [private] |
Definition at line 305 of file EopTreeWriter.cc.
References funct::cos(), SiPixelRawToDigiRegional_cfi::deltaPhi, funct::exp(), Pi, mathSSE::sqrt(), and funct::tan().
Referenced by analyze().
{ double deltaPhi=phi1-phi2; while(deltaPhi > TMath::Pi())deltaPhi-=2*TMath::Pi(); while(deltaPhi <= -TMath::Pi())deltaPhi+=2*TMath::Pi(); double dR; // double Rec; double theta1=2*atan(exp(-eta1)); double theta2=2*atan(exp(-eta2)); double cotantheta1; if(cos(theta1)==0)cotantheta1=0; else cotantheta1=1/tan(theta1); double cotantheta2; if(cos(theta2)==0)cotantheta2=0; else cotantheta2=1/tan(theta2); // if (fabs(eta1)<1.479) Rec=129; //radius of ECAL barrel // else Rec=317; //distance from IP to ECAL endcap //|vect| times tg of acos(scalar product) // dR=fabs((Rec/sin(theta1))*tan(acos(sin(theta1)*sin(theta2)*(sin(phi1)*sin(phi2)+cos(phi1)*cos(phi2))+cos(theta1)*cos(theta2)))); if(fabs(eta1)<1.479)dR=129*sqrt((cotantheta1-cotantheta2)*(cotantheta1-cotantheta2)+deltaPhi*deltaPhi); else dR=317*sqrt(tan(theta1)*tan(theta1)+tan(theta2)*tan(theta2)-2*tan(theta1)*tan(theta2)*cos(deltaPhi)); return dR; }
edm::Service<TFileService> EopTreeWriter::fs_ [private] |
Definition at line 84 of file EopTreeWriter.cc.
Referenced by EopTreeWriter().
Definition at line 88 of file EopTreeWriter.cc.
Referenced by analyze(), and EopTreeWriter().
edm::InputTag EopTreeWriter::src_ [private] |
Definition at line 82 of file EopTreeWriter.cc.
Referenced by analyze().
Definition at line 87 of file EopTreeWriter.cc.
Referenced by analyze().
TTree* EopTreeWriter::tree_ [private] |
Definition at line 85 of file EopTreeWriter.cc.
Referenced by analyze(), and EopTreeWriter().
EopVariables* EopTreeWriter::treeMemPtr_ [private] |
Definition at line 86 of file EopTreeWriter.cc.
Referenced by analyze(), endJob(), and EopTreeWriter().