55 #define myMaxHits 1000 65 void endJob(
void)
override;
215 numCand_ =
new TH1F(
"numCandidates",
"Number of candidates found", 10, -0.5, 9.5);
216 numElectrons_ =
new TH1F(
"numElectrons",
"Number of Electrons found", 10, -0.5, 9.5);
217 numSuperClusters_ =
new TH1F(
"numSuperClusters",
"Number of Ecal SuperClusters", 50, 0, 50);
219 energySuperClusters_ =
new TH1F(
"energySuperClusters",
"Super Cluster Energy - all ", 200, 0, 2000.);
220 energySuperClustersEl_ =
new TH1F(
"energySuperClustersEl",
"Super Cluster Energy - Electron Cands ", 200, 0., 2000.);
222 sizeSuperClusters_ =
new TH1F(
"sizeSuperClusters",
"Super Cluster Size - all ", 20, 0, 19);
223 sizeSuperClustersEl_ =
new TH1F(
"sizeSuperClustersEl",
"Super Cluster Size - Electron Cands ", 20, 0, 19);
225 emaxSuperClusters_ =
new TH1F(
"emaxSuperClusters",
"Super Cluster Emax - all ", 200, 0, 2000.);
226 emaxSuperClustersEl_ =
new TH1F(
"emaxSuperClustersEl",
"Super Cluster Emax - Electron Cands ", 200, 0, 2000.);
229 phiWidthSuperClustersEl_ =
new TH1F(
"phiWidthSuperClustersEl",
"Super Cluster Width - Electron Cands ", 20, 0., 0.05);
231 ptDiff =
new TH1F(
"ptDiff",
" ptDiff ", 20, -10., 10.);
232 pDiff =
new TH1F(
"pDiff",
" pDiff ", 100, -50., 50.);
234 pElectronFailed =
new TH1F(
"pElectronFailed",
" pElectronFailed ", 55, 0., 110.);
235 ptElectronFailed =
new TH1F(
"ptElectronFailed",
" ptElectronFailed ", 55, 0., 110.);
237 pElectronPassed =
new TH1F(
"pElectronPassed",
" pElectronPassed ", 55, 0., 110.);
238 ptElectronPassed =
new TH1F(
"ptElectronPassed",
" ptElectronPassed ", 55, 0., 110.);
246 eOverPFailed =
new TH1F(
"eOverPFailed",
" E over P - Failed ", 50, 0, 10.);
247 eOverPPassed =
new TH1F(
"eOverPPassed",
" E over P - Passed ", 50, 0, 10.);
249 numSiStereoHits_ =
new TH1F(
"numSiStereoHits",
"Number of Si StereoHits", 100, 0, 1000);
250 numSiMonoHits_ =
new TH1F(
"numSiMonoHits",
"Number of Si MonoHits", 100, 0, 1000);
251 numSiMatchedHits_ =
new TH1F(
"numSiMatchedHits",
"Number of Si MatchedHits", 100, 0, 1000);
306 myTree_ =
new TTree(
"myTree",
"my first Tree example");
479 LogDebug(
"") <<
" Start loop over " << clusterHandle->end() - clusterHandle->begin() <<
" superClusters ";
481 for (reco::SuperClusterCollection::const_iterator clusterIter = clusterHandle->begin();
482 clusterIter != clusterHandle->end();
484 double energy = clusterIter->energy();
486 std::ostringstream
str;
497 str <<
"About to loop over basicClusters" 500 double emaxSuperCluster = 0.;
503 double eTotSuperCluster = 0.;
506 basicClusterIter != clusterIter->clustersEnd();
507 ++basicClusterIter) {
510 str <<
" basicCluster Energy " << (*basicClusterIter)->energy() <<
" Position " << (*basicClusterIter)->position()
512 <<
" Position phi " << (*basicClusterIter)->position().phi() <<
" recHits " 513 << (*basicClusterIter)->size() <<
" \n";
515 double eCluster = (*basicClusterIter)->energy();
516 if (eCluster > emaxSuperCluster) {
517 emaxSuperCluster = eCluster;
519 eTotSuperCluster += eCluster;
520 double phiCluster = (*basicClusterIter)->position().phi();
521 phibar += eCluster * phiCluster;
522 phi2bar += eCluster * phiCluster * phiCluster;
526 phibar = phibar / eTotSuperCluster;
527 phi2bar = phi2bar / eTotSuperCluster;
528 double phiWidth = phi2bar - phibar * phibar;
534 str <<
" SuperCluster stats " 536 str <<
"phibar " << phibar <<
" phi2bar " << phi2bar <<
" eTotSuperCluster " << eTotSuperCluster <<
" phiWidth " 543 str <<
" Done with this SuperCluster " << std::endl;
549 LogDebug(
"") <<
" End loop over superClusters ";
574 LogDebug(
"") <<
" Dumping Algo's guess of SiStripElectron Candidate Info ";
575 int numberOfElectrons = 0;
577 LogDebug(
"") <<
" Number of SiStripElectrons " << siStripElectronHandle->size();
579 for (reco::SiStripElectronCollection::const_iterator electronIter = siStripElectronHandle->begin();
580 electronIter != siStripElectronHandle->end();
582 LogDebug(
"") <<
"about to get stuff from electroncandidate " << numberOfElectrons <<
"\n" 583 <<
"supercluster energy = " << electronIter->superCluster()->energy() <<
"\n" 584 <<
"fit results are phi(r) = " << electronIter->phiAtOrigin() <<
" + " << electronIter->phiVsRSlope()
587 <<
" chi2 " << electronIter->chi2() <<
" ndof " << electronIter->ndof() <<
"\n" 588 <<
" Pt " << electronIter->pt() <<
"\n" 589 <<
"P, Px, Py, Pz " << electronIter->p() <<
" " << electronIter->px() <<
" " << electronIter->py()
590 <<
" " << electronIter->pz() <<
"\n" 591 <<
"you get the idea...";
598 double emaxSuperCluster = 0.;
601 double eTotSuperCluster = 0.;
604 basicClusterIter != electronIter->superCluster()->clustersEnd();
605 ++basicClusterIter) {
608 double eCluster = (*basicClusterIter)->energy();
609 if (eCluster > emaxSuperCluster) {
610 emaxSuperCluster = eCluster;
612 eTotSuperCluster += eCluster;
613 double phiCluster = (*basicClusterIter)->position().phi();
614 phibar += eCluster * phiCluster;
615 phi2bar += eCluster * phiCluster * phiCluster;
618 phibar = phibar / eTotSuperCluster;
619 phi2bar = phi2bar / eTotSuperCluster;
620 double phiWidth = phi2bar - phibar * phibar;
634 numCand_->Fill(siStripElectronHandle->size());
640 LogDebug(
"") <<
" About to check Electrons";
650 bool* hasElectron_ =
new bool[siStripElectronHandle->end() - siStripElectronHandle->begin()];
651 for (
int icount = 0; icount < siStripElectronHandle->end() - siStripElectronHandle->begin(); ++icount) {
652 hasElectron_[icount] =
false;
658 unsigned int* Electron_to_strippy =
new unsigned int[
electrons->end() -
electrons->begin()];
660 Electron_to_strippy[icount] = 0;
663 unsigned int ecount = 0;
664 for (reco::ElectronCollection::const_iterator electronIter =
electrons->begin(); electronIter !=
electrons->end();
666 LogDebug(
"") <<
" Associating Electrons to Strippies ";
667 LogDebug(
"") <<
" PT is " << electronIter->track()->pt();
670 uint32_t
id = (*electronIter->track()->recHitsBegin())->geographicalId().rawId();
671 LocalPoint pos = (*electronIter->track()->recHitsBegin())->localPosition();
673 unsigned int icount = 0;
674 LogDebug(
"") <<
" About to loop over Strippies " 676 <<
" icount " << icount <<
" max " << siStripElectronHandle->end() - siStripElectronHandle->begin();
678 for (reco::SiStripElectronCollection::const_iterator strippyiter = siStripElectronHandle->begin();
679 strippyiter != siStripElectronHandle->end();
681 bool hitInCommon =
false;
683 for (std::vector<SiStripRecHit2D>::const_iterator hiter = strippyiter->rphiRecHits().begin();
684 hiter != strippyiter->rphiRecHits().end();
686 if (hiter->geographicalId().rawId() ==
id && (hiter->localPosition() -
pos).
mag() < 1
e-10) {
692 for (std::vector<SiStripRecHit2D>::const_iterator hiter = strippyiter->stereoRecHits().begin();
693 hiter != strippyiter->stereoRecHits().end();
695 if (hiter->geographicalId().rawId() ==
id && (hiter->localPosition() -
pos).
mag() < 1
e-10) {
701 hasElectron_[icount] =
true;
702 Electron_to_strippy[ecount] = icount;
711 LogDebug(
"") <<
" Done looping over Electrons ";
714 for (reco::SiStripElectronCollection::const_iterator strippyIter = siStripElectronHandle->begin();
715 strippyIter != siStripElectronHandle->end();
721 LogDebug(
"") <<
" SiStrip Failed Electron " 723 <<
" p " << strippyIter->p() <<
" \n " 724 <<
" pt " << strippyIter->pt() <<
" \n " 725 <<
" SuperClust size " << strippyIter->superCluster()->clustersSize();
730 LogDebug(
"") <<
" done filling Failed histos ";
739 LogDebug(
"") <<
" SiStrip Passed Electron " 741 <<
" p " << strippyIter->p() <<
" \n " 742 <<
" pt " << strippyIter->pt() <<
" \n " 743 <<
" SuperClust size " << strippyIter->superCluster()->clustersSize();
747 LogDebug(
"") <<
" done filling passed histos ";
759 LogDebug(
"") <<
"Dump info for all electrons ";
761 for (reco::ElectronCollection::const_iterator electronIter1 =
electrons->begin(); electronIter1 !=
electrons->end();
765 unsigned int ecount1 = electronIter1 -
electrons->begin();
766 unsigned int stripCount1 = 0;
767 reco::SiStripElectronCollection::const_iterator strippyIter1;
768 for (reco::SiStripElectronCollection::const_iterator strippyIter = siStripElectronHandle->begin();
769 strippyIter != siStripElectronHandle->end();
771 if (Electron_to_strippy[ecount1] == stripCount1) {
772 strippyIter1 = strippyIter;
779 std::ostringstream
str;
781 str <<
" SiStripElect p , px, py, pz " << strippyIter1->p() <<
" " << strippyIter1->px() <<
" " 782 << strippyIter1->py() <<
" " << strippyIter1->pz() <<
"\n " << std::endl;
784 str <<
" Electron p px, py, pz, = " << tr1->p() <<
" " << tr1->px() <<
" " << tr1->py() <<
" " << tr1->pz()
788 double EClust1 = strippyIter1->superCluster()->energy();
789 double XClust1 = strippyIter1->superCluster()->x();
790 double YClust1 = strippyIter1->superCluster()->y();
791 double ZClust1 = strippyIter1->superCluster()->z();
793 double rho1 =
sqrt(XClust1 * XClust1 + YClust1 * YClust1 + ZClust1 * ZClust1);
794 double costheta1 = ZClust1 / rho1;
795 double sintheta1 =
sqrt(1 - costheta1 * costheta1);
797 sintheta1 = -sintheta1;
799 double cosphi1 = XClust1 /
sqrt(XClust1 * XClust1 + YClust1 * YClust1);
800 double sinphi1 = YClust1 /
sqrt(XClust1 * XClust1 + YClust1 * YClust1);
802 str <<
" Ecal for electron E, px, py, pz " << EClust1 <<
" " << EClust1 * sintheta1 * cosphi1 <<
" " 803 << EClust1 * sintheta1 * sinphi1 <<
" " << EClust1 * costheta1 <<
"\n" 809 LogDebug(
"") <<
"Done Dumping info for all electrons ";
817 edm::LogInfo(
"") <<
" Two electrons in this event " << std::endl;
818 for (reco::ElectronCollection::const_iterator electronIter1 =
electrons->begin();
825 unsigned int ecount1 = electronIter1 -
electrons->begin();
827 unsigned int stripCount1 = 0;
828 reco::SiStripElectronCollection::const_iterator strippyIter1;
829 for (reco::SiStripElectronCollection::const_iterator strippyIter = siStripElectronHandle->begin();
830 strippyIter != siStripElectronHandle->end();
832 if (Electron_to_strippy[ecount1] == stripCount1) {
833 strippyIter1 = strippyIter;
839 double EClust1 = strippyIter1->superCluster()->energy();
840 double XClust1 = strippyIter1->superCluster()->x();
841 double YClust1 = strippyIter1->superCluster()->y();
842 double ZClust1 = strippyIter1->superCluster()->z();
844 for (reco::ElectronCollection::const_iterator electronIter2 = electronIter1 + 1;
849 unsigned int ecount2 = electronIter2 -
electrons->begin();
850 unsigned int stripCount2 = 0;
851 reco::SiStripElectronCollection::const_iterator strippyIter2;
852 for (reco::SiStripElectronCollection::const_iterator strippyIter = siStripElectronHandle->begin();
853 strippyIter != siStripElectronHandle->end();
855 if (Electron_to_strippy[ecount2] == stripCount2) {
856 strippyIter2 = strippyIter;
862 double EClust2 = strippyIter2->superCluster()->energy();
863 double XClust2 = strippyIter2->superCluster()->x();
864 double YClust2 = strippyIter2->superCluster()->y();
865 double ZClust2 = strippyIter2->superCluster()->z();
869 edm::LogInfo(
"") <<
" Electron p1 = " << tr1->p() <<
" p1x " << tr1->px() <<
" p1y " << tr1->py() <<
" p1z " 870 << tr1->pz() << std::endl;
872 edm::LogInfo(
"") <<
" Electron p2 = " << tr2->p() <<
" p2x " << tr2->px() <<
" p2y " << tr2->py() <<
" p2z " 873 << tr2->pz() << std::endl;
876 double Zpx = tr1->px() + tr2->px();
877 double Zpy = tr1->py() + tr2->py();
878 double Zpz = tr1->pz() + tr2->pz();
880 edm::LogInfo(
"") <<
" Z mass " <<
sqrt(Ze * Ze - Zpx * Zpx - Zpy * Zpy - Zpz * Zpz) << std::endl;
883 double rho1 =
sqrt(XClust1 * XClust1 + YClust1 * YClust1 + ZClust1 * ZClust1);
884 double costheta1 = ZClust1 / rho1;
885 double sintheta1 =
sqrt(1 - costheta1 * costheta1);
887 sintheta1 = -sintheta1;
889 double cosphi1 = XClust1 /
sqrt(XClust1 * XClust1 + YClust1 * YClust1);
890 double sinphi1 = YClust1 /
sqrt(XClust1 * XClust1 + YClust1 * YClust1);
892 double rho2 =
sqrt(XClust2 * XClust2 + YClust2 * YClust2 + ZClust2 * ZClust2);
893 double costheta2 = ZClust2 / rho2;
894 double sintheta2 =
sqrt(1 - costheta2 * costheta2);
896 sintheta2 = -sintheta2;
898 double cosphi2 = XClust2 /
sqrt(XClust2 * XClust2 + YClust2 * YClust2);
899 double sinphi2 = YClust2 /
sqrt(XClust2 * XClust2 + YClust2 * YClust2);
901 edm::LogInfo(
"") <<
"Energy of supercluster for 1st electron " << EClust1 <<
" " 902 << EClust1 * sintheta1 * cosphi1 <<
" " << EClust1 * sintheta1 * sinphi1 <<
" " 903 << EClust1 * costheta1 <<
" " << std::endl;
905 edm::LogInfo(
"") <<
"Energy of supercluster for 2nd electron " << EClust2 <<
" " 906 << EClust2 * sintheta2 * cosphi2 <<
" " << EClust2 * sintheta2 * sinphi2 <<
" " 907 << EClust2 * costheta2 <<
" " << std::endl;
910 double Zgpx = EClust1 * sintheta1 * cosphi1 + EClust2 * sintheta2 * cosphi2;
911 double Zgpy = EClust1 * sintheta1 * sinphi1 + EClust2 * sintheta2 * sinphi2;
912 double Zgpz = EClust1 * costheta1 + EClust2 * costheta2;
913 double ZgE = EClust1 + EClust2;
915 edm::LogInfo(
"") <<
" Z mass from ECAL " <<
sqrt(ZgE * ZgE - Zgpx * Zgpx - Zgpy * Zgpy - Zgpz * Zgpz)
922 delete[] hasElectron_;
923 delete[] Electron_to_strippy;
928 LogDebug(
"") <<
" About to dump tracker info ";
945 for (reco::SuperClusterCollection::const_iterator clusterIter = clusterHandle->begin();
946 clusterIter != clusterHandle->end();
948 double energy = clusterIter->energy();
964 LogDebug(
"") <<
" Looping over stereo hits ";
969 hitend = stereoHitsHandle->
data().end();
984 Int_t siLayerNum = 0;
986 string siDetName =
"";
1020 const auto& amplitudes = clust->amplitudes();
1021 for (
size_t i = 0;
i < amplitudes.size();
i++) {
1072 LogDebug(
"") <<
" Looping over Mono Hits ";
1076 hitend = rphiHitsHandle->
data().end();
1092 Int_t siLayerNum = 0;
1094 string siDetName =
"";
1128 const auto& amplitudes = clust->amplitudes();
1129 for (
size_t i = 0;
i < amplitudes.size();
i++) {
1184 LogDebug(
"") <<
" Loop over Matched Hits ";
1189 hitend = matchedHitsHandle->
data().end();
1202 Int_t siLayerNum = 0;
1204 string siDetName =
"";
1296 LogDebug(
"") <<
"Entering endJob ";
1330 LogDebug(
"") <<
" Writing out ntuple is disabled for now ";
TH1F * sizeSuperClustersEl_
float MatchedHitTheta_[1000]
std::string superClusterCollection_
T getParameter(std::string const &) const
unsigned int tobLayer(const DetId &id) const
~SiStripElectronAnalyzer() override
float StereoHitSigX_[1000]
TH1F * emaxSuperClusters_
float MonoHitTheta_[1000]
#define DEFINE_FWK_MODULE(type)
float MatchedHitSigY_[1000]
SiStripElectronAnalyzer(const edm::ParameterSet &)
int StereoDetector_[1000]
std::string siElectronCollection_
data_type const * data(size_t cell) const
bool isNonnull() const
Checks for non-null.
virtual void initNtuple(void)
int MatchedDetector_[1000]
TH1F * energySuperClustersEl_
float MonoHitSignal_[1000]
ClusterRef cluster() const
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerToken_
TH1F * sizeSuperClustersPassed
std::string eBRecHitProducer_
float StereoHitSignal_[1000]
TH1F * energySuperClusters_
std::string mctruthCollection_
TH1F * emaxSuperClustersEl_
std::string superClusterProducer_
Abs< T >::type abs(const T &t)
std::string eBRecHitCollection_
float StereoHitNoise_[1000]
std::string mctruthProducer_
std::string siMatchedHitCollection_
static constexpr auto TOB
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
float StereoHitSigY_[1000]
const TrackerGeomDet * idToDet(DetId) const override
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
TH1F * sizeSuperClusters_
std::string siRphiHitCollection_
float StereoHitTheta_[1000]
std::string siStereoHitCollection_
Log< level::Info, false > LogInfo
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
TH1F * phiWidthSuperClusters_
LocalError localPositionError() const override
void endJob(void) override
TH1F * sizeSuperClustersFailed
static constexpr auto TIB
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
int StereoHitWidth_[1000]
XYZPointD XYZPoint
point in space with cartesian internal representation
float MatchedHitNoise_[1000]
float MonoHitNoise_[1000]
float MatchedHitSignal_[1000]
TH1F * energySuperClustersFailed
float StereoHitCorr_[1000]
std::string basicClusterProducer_
std::string electronProducer_
std::string electronCollection_
std::string basicClusterCollection_
static std::atomic< unsigned int > counter
static int position[264][3]
int MatchedHitWidth_[1000]
TH1F * phiWidthSuperClustersEl_
float MatchedHitSigX_[1000]
float MatchedHitCorr_[1000]
void analyze(const edm::Event &, const edm::EventSetup &) override
double unwrapPhi(double phi) const
unsigned int tibLayer(const DetId &id) const
float StereoHitPhi_[1000]
std::string siHitProducer_
Power< A, B >::type pow(const A &a, const B &b)
std::string siElectronProducer_
TH1F * energySuperClustersPassed
float MatchedHitPhi_[1000]