55 #define myMaxHits 1000
65 void endJob(
void)
override;
211 numCand_ =
new TH1F(
"numCandidates",
"Number of candidates found", 10, -0.5, 9.5);
212 numElectrons_ =
new TH1F(
"numElectrons",
"Number of Electrons found", 10, -0.5, 9.5);
213 numSuperClusters_ =
new TH1F(
"numSuperClusters",
"Number of Ecal SuperClusters", 50, 0, 50);
215 energySuperClusters_ =
new TH1F(
"energySuperClusters",
"Super Cluster Energy - all ", 200, 0, 2000.);
216 energySuperClustersEl_ =
new TH1F(
"energySuperClustersEl",
"Super Cluster Energy - Electron Cands ", 200, 0., 2000.);
218 sizeSuperClusters_ =
new TH1F(
"sizeSuperClusters",
"Super Cluster Size - all ", 20, 0, 19);
219 sizeSuperClustersEl_ =
new TH1F(
"sizeSuperClustersEl",
"Super Cluster Size - Electron Cands ", 20, 0, 19);
221 emaxSuperClusters_ =
new TH1F(
"emaxSuperClusters",
"Super Cluster Emax - all ", 200, 0, 2000.);
222 emaxSuperClustersEl_ =
new TH1F(
"emaxSuperClustersEl",
"Super Cluster Emax - Electron Cands ", 200, 0, 2000.);
225 phiWidthSuperClustersEl_ =
new TH1F(
"phiWidthSuperClustersEl",
"Super Cluster Width - Electron Cands ", 20, 0., 0.05);
227 ptDiff =
new TH1F(
"ptDiff",
" ptDiff ", 20, -10., 10.);
228 pDiff =
new TH1F(
"pDiff",
" pDiff ", 100, -50., 50.);
230 pElectronFailed =
new TH1F(
"pElectronFailed",
" pElectronFailed ", 55, 0., 110.);
231 ptElectronFailed =
new TH1F(
"ptElectronFailed",
" ptElectronFailed ", 55, 0., 110.);
233 pElectronPassed =
new TH1F(
"pElectronPassed",
" pElectronPassed ", 55, 0., 110.);
234 ptElectronPassed =
new TH1F(
"ptElectronPassed",
" ptElectronPassed ", 55, 0., 110.);
242 eOverPFailed =
new TH1F(
"eOverPFailed",
" E over P - Failed ", 50, 0, 10.);
243 eOverPPassed =
new TH1F(
"eOverPPassed",
" E over P - Passed ", 50, 0, 10.);
245 numSiStereoHits_ =
new TH1F(
"numSiStereoHits",
"Number of Si StereoHits", 100, 0, 1000);
246 numSiMonoHits_ =
new TH1F(
"numSiMonoHits",
"Number of Si MonoHits", 100, 0, 1000);
247 numSiMatchedHits_ =
new TH1F(
"numSiMatchedHits",
"Number of Si MatchedHits", 100, 0, 1000);
302 myTree_ =
new TTree(
"myTree",
"my first Tree example");
476 LogDebug(
"") <<
" Start loop over " << clusterHandle->end() - clusterHandle->begin() <<
" superClusters ";
478 for (reco::SuperClusterCollection::const_iterator clusterIter = clusterHandle->begin();
479 clusterIter != clusterHandle->end();
481 double energy = clusterIter->energy();
483 std::ostringstream
str;
485 str <<
" SuperCluster " << energy <<
" GeV, position " << position <<
" cm"
494 str <<
"About to loop over basicClusters"
497 double emaxSuperCluster = 0.;
500 double eTotSuperCluster = 0.;
503 basicClusterIter != clusterIter->clustersEnd();
504 ++basicClusterIter) {
507 str <<
" basicCluster Energy " << (*basicClusterIter)->energy() <<
" Position " << (*basicClusterIter)->position()
509 <<
" Position phi " << (*basicClusterIter)->position().phi() <<
" recHits "
510 << (*basicClusterIter)->size() <<
" \n";
512 double eCluster = (*basicClusterIter)->energy();
513 if (eCluster > emaxSuperCluster) {
514 emaxSuperCluster = eCluster;
516 eTotSuperCluster += eCluster;
517 double phiCluster = (*basicClusterIter)->position().phi();
518 phibar += eCluster * phiCluster;
519 phi2bar += eCluster * phiCluster * phiCluster;
523 phibar = phibar / eTotSuperCluster;
524 phi2bar = phi2bar / eTotSuperCluster;
525 double phiWidth = phi2bar - phibar * phibar;
531 str <<
" SuperCluster stats "
533 str <<
"phibar " << phibar <<
" phi2bar " << phi2bar <<
" eTotSuperCluster " << eTotSuperCluster <<
" phiWidth "
534 << phiWidth << std::endl;
540 str <<
" Done with this SuperCluster " << std::endl;
546 LogDebug(
"") <<
" End loop over superClusters ";
571 LogDebug(
"") <<
" Dumping Algo's guess of SiStripElectron Candidate Info ";
572 int numberOfElectrons = 0;
574 LogDebug(
"") <<
" Number of SiStripElectrons " << siStripElectronHandle->size();
576 for (reco::SiStripElectronCollection::const_iterator electronIter = siStripElectronHandle->begin();
577 electronIter != siStripElectronHandle->end();
579 LogDebug(
"") <<
"about to get stuff from electroncandidate " << numberOfElectrons <<
"\n"
580 <<
"supercluster energy = " << electronIter->superCluster()->energy() <<
"\n"
581 <<
"fit results are phi(r) = " << electronIter->phiAtOrigin() <<
" + " << electronIter->phiVsRSlope()
584 <<
" chi2 " << electronIter->chi2() <<
" ndof " << electronIter->ndof() <<
"\n"
585 <<
" Pt " << electronIter->pt() <<
"\n"
586 <<
"P, Px, Py, Pz " << electronIter->p() <<
" " << electronIter->px() <<
" " << electronIter->py()
587 <<
" " << electronIter->pz() <<
"\n"
588 <<
"you get the idea...";
595 double emaxSuperCluster = 0.;
598 double eTotSuperCluster = 0.;
601 basicClusterIter != electronIter->superCluster()->clustersEnd();
602 ++basicClusterIter) {
605 double eCluster = (*basicClusterIter)->energy();
606 if (eCluster > emaxSuperCluster) {
607 emaxSuperCluster = eCluster;
609 eTotSuperCluster += eCluster;
610 double phiCluster = (*basicClusterIter)->position().phi();
611 phibar += eCluster * phiCluster;
612 phi2bar += eCluster * phiCluster * phiCluster;
615 phibar = phibar / eTotSuperCluster;
616 phi2bar = phi2bar / eTotSuperCluster;
617 double phiWidth = phi2bar - phibar * phibar;
631 numCand_->Fill(siStripElectronHandle->size());
637 LogDebug(
"") <<
" About to check Electrons";
647 bool* hasElectron_ =
new bool[siStripElectronHandle->end() - siStripElectronHandle->begin()];
648 for (
int icount = 0; icount < siStripElectronHandle->end() - siStripElectronHandle->begin(); ++icount) {
649 hasElectron_[icount] =
false;
655 unsigned int* Electron_to_strippy =
new unsigned int[
electrons->end() -
electrons->begin()];
657 Electron_to_strippy[icount] = 0;
660 unsigned int ecount = 0;
661 for (reco::ElectronCollection::const_iterator electronIter =
electrons->begin(); electronIter !=
electrons->end();
663 LogDebug(
"") <<
" Associating Electrons to Strippies ";
664 LogDebug(
"") <<
" PT is " << electronIter->track()->pt();
667 uint32_t
id = (*electronIter->track()->recHitsBegin())->geographicalId().rawId();
668 LocalPoint pos = (*electronIter->track()->recHitsBegin())->localPosition();
670 unsigned int icount = 0;
671 LogDebug(
"") <<
" About to loop over Strippies "
673 <<
" icount " << icount <<
" max " << siStripElectronHandle->end() - siStripElectronHandle->begin();
675 for (reco::SiStripElectronCollection::const_iterator strippyiter = siStripElectronHandle->begin();
676 strippyiter != siStripElectronHandle->end();
678 bool hitInCommon =
false;
680 for (std::vector<SiStripRecHit2D>::const_iterator hiter = strippyiter->rphiRecHits().begin();
681 hiter != strippyiter->rphiRecHits().end();
683 if (hiter->geographicalId().rawId() ==
id && (hiter->localPosition() - pos).
mag() < 1
e-10) {
689 for (std::vector<SiStripRecHit2D>::const_iterator hiter = strippyiter->stereoRecHits().begin();
690 hiter != strippyiter->stereoRecHits().end();
692 if (hiter->geographicalId().rawId() ==
id && (hiter->localPosition() - pos).
mag() < 1
e-10) {
698 hasElectron_[icount] =
true;
699 Electron_to_strippy[ecount] = icount;
708 LogDebug(
"") <<
" Done looping over Electrons ";
711 for (reco::SiStripElectronCollection::const_iterator strippyIter = siStripElectronHandle->begin();
712 strippyIter != siStripElectronHandle->end();
718 LogDebug(
"") <<
" SiStrip Failed Electron "
720 <<
" p " << strippyIter->p() <<
" \n "
721 <<
" pt " << strippyIter->pt() <<
" \n "
722 <<
" SuperClust size " << strippyIter->superCluster()->clustersSize();
727 LogDebug(
"") <<
" done filling Failed histos ";
736 LogDebug(
"") <<
" SiStrip Passed Electron "
738 <<
" p " << strippyIter->p() <<
" \n "
739 <<
" pt " << strippyIter->pt() <<
" \n "
740 <<
" SuperClust size " << strippyIter->superCluster()->clustersSize();
744 LogDebug(
"") <<
" done filling passed histos ";
756 LogDebug(
"") <<
"Dump info for all electrons ";
758 for (reco::ElectronCollection::const_iterator electronIter1 =
electrons->begin(); electronIter1 !=
electrons->end();
762 unsigned int ecount1 = electronIter1 -
electrons->begin();
763 unsigned int stripCount1 = 0;
764 reco::SiStripElectronCollection::const_iterator strippyIter1;
765 for (reco::SiStripElectronCollection::const_iterator strippyIter = siStripElectronHandle->begin();
766 strippyIter != siStripElectronHandle->end();
768 if (Electron_to_strippy[ecount1] == stripCount1) {
769 strippyIter1 = strippyIter;
776 std::ostringstream
str;
778 str <<
" SiStripElect p , px, py, pz " << strippyIter1->p() <<
" " << strippyIter1->px() <<
" "
779 << strippyIter1->py() <<
" " << strippyIter1->pz() <<
"\n " << std::endl;
781 str <<
" Electron p px, py, pz, = " << tr1->p() <<
" " << tr1->px() <<
" " << tr1->py() <<
" " << tr1->pz()
785 double EClust1 = strippyIter1->superCluster()->energy();
786 double XClust1 = strippyIter1->superCluster()->x();
787 double YClust1 = strippyIter1->superCluster()->y();
788 double ZClust1 = strippyIter1->superCluster()->z();
790 double rho1 =
sqrt(XClust1 * XClust1 + YClust1 * YClust1 + ZClust1 * ZClust1);
791 double costheta1 = ZClust1 / rho1;
792 double sintheta1 =
sqrt(1 - costheta1 * costheta1);
794 sintheta1 = -sintheta1;
796 double cosphi1 = XClust1 /
sqrt(XClust1 * XClust1 + YClust1 * YClust1);
797 double sinphi1 = YClust1 /
sqrt(XClust1 * XClust1 + YClust1 * YClust1);
799 str <<
" Ecal for electron E, px, py, pz " << EClust1 <<
" " << EClust1 * sintheta1 * cosphi1 <<
" "
800 << EClust1 * sintheta1 * sinphi1 <<
" " << EClust1 * costheta1 <<
"\n"
806 LogDebug(
"") <<
"Done Dumping info for all electrons ";
814 edm::LogInfo(
"") <<
" Two electrons in this event " << std::endl;
815 for (reco::ElectronCollection::const_iterator electronIter1 =
electrons->begin();
822 unsigned int ecount1 = electronIter1 -
electrons->begin();
824 unsigned int stripCount1 = 0;
825 reco::SiStripElectronCollection::const_iterator strippyIter1;
826 for (reco::SiStripElectronCollection::const_iterator strippyIter = siStripElectronHandle->begin();
827 strippyIter != siStripElectronHandle->end();
829 if (Electron_to_strippy[ecount1] == stripCount1) {
830 strippyIter1 = strippyIter;
836 double EClust1 = strippyIter1->superCluster()->energy();
837 double XClust1 = strippyIter1->superCluster()->x();
838 double YClust1 = strippyIter1->superCluster()->y();
839 double ZClust1 = strippyIter1->superCluster()->z();
841 for (reco::ElectronCollection::const_iterator electronIter2 = electronIter1 + 1;
846 unsigned int ecount2 = electronIter2 -
electrons->begin();
847 unsigned int stripCount2 = 0;
848 reco::SiStripElectronCollection::const_iterator strippyIter2;
849 for (reco::SiStripElectronCollection::const_iterator strippyIter = siStripElectronHandle->begin();
850 strippyIter != siStripElectronHandle->end();
852 if (Electron_to_strippy[ecount2] == stripCount2) {
853 strippyIter2 = strippyIter;
859 double EClust2 = strippyIter2->superCluster()->energy();
860 double XClust2 = strippyIter2->superCluster()->x();
861 double YClust2 = strippyIter2->superCluster()->y();
862 double ZClust2 = strippyIter2->superCluster()->z();
866 edm::LogInfo(
"") <<
" Electron p1 = " << tr1->p() <<
" p1x " << tr1->px() <<
" p1y " << tr1->py() <<
" p1z "
867 << tr1->pz() << std::endl;
869 edm::LogInfo(
"") <<
" Electron p2 = " << tr2->p() <<
" p2x " << tr2->px() <<
" p2y " << tr2->py() <<
" p2z "
870 << tr2->pz() << std::endl;
873 double Zpx = tr1->px() + tr2->px();
874 double Zpy = tr1->py() + tr2->py();
875 double Zpz = tr1->pz() + tr2->pz();
877 edm::LogInfo(
"") <<
" Z mass " <<
sqrt(Ze * Ze - Zpx * Zpx - Zpy * Zpy - Zpz * Zpz) << std::endl;
880 double rho1 =
sqrt(XClust1 * XClust1 + YClust1 * YClust1 + ZClust1 * ZClust1);
881 double costheta1 = ZClust1 / rho1;
882 double sintheta1 =
sqrt(1 - costheta1 * costheta1);
884 sintheta1 = -sintheta1;
886 double cosphi1 = XClust1 /
sqrt(XClust1 * XClust1 + YClust1 * YClust1);
887 double sinphi1 = YClust1 /
sqrt(XClust1 * XClust1 + YClust1 * YClust1);
889 double rho2 =
sqrt(XClust2 * XClust2 + YClust2 * YClust2 + ZClust2 * ZClust2);
890 double costheta2 = ZClust2 / rho2;
891 double sintheta2 =
sqrt(1 - costheta2 * costheta2);
893 sintheta2 = -sintheta2;
895 double cosphi2 = XClust2 /
sqrt(XClust2 * XClust2 + YClust2 * YClust2);
896 double sinphi2 = YClust2 /
sqrt(XClust2 * XClust2 + YClust2 * YClust2);
898 edm::LogInfo(
"") <<
"Energy of supercluster for 1st electron " << EClust1 <<
" "
899 << EClust1 * sintheta1 * cosphi1 <<
" " << EClust1 * sintheta1 * sinphi1 <<
" "
900 << EClust1 * costheta1 <<
" " << std::endl;
902 edm::LogInfo(
"") <<
"Energy of supercluster for 2nd electron " << EClust2 <<
" "
903 << EClust2 * sintheta2 * cosphi2 <<
" " << EClust2 * sintheta2 * sinphi2 <<
" "
904 << EClust2 * costheta2 <<
" " << std::endl;
907 double Zgpx = EClust1 * sintheta1 * cosphi1 + EClust2 * sintheta2 * cosphi2;
908 double Zgpy = EClust1 * sintheta1 * sinphi1 + EClust2 * sintheta2 * sinphi2;
909 double Zgpz = EClust1 * costheta1 + EClust2 * costheta2;
910 double ZgE = EClust1 + EClust2;
912 edm::LogInfo(
"") <<
" Z mass from ECAL " <<
sqrt(ZgE * ZgE - Zgpx * Zgpx - Zgpy * Zgpy - Zgpz * Zgpz)
919 delete[] hasElectron_;
920 delete[] Electron_to_strippy;
925 LogDebug(
"") <<
" About to dump tracker info ";
943 for (reco::SuperClusterCollection::const_iterator clusterIter = clusterHandle->begin();
944 clusterIter != clusterHandle->end();
946 double energy = clusterIter->energy();
962 LogDebug(
"") <<
" Looping over stereo hits ";
967 hitend = stereoHitsHandle->data().end();
982 Int_t siLayerNum = 0;
984 string siDetName =
"";
987 siLayerNum = tTopo->tibLayer(
id);
991 siLayerNum = tTopo->tobLayer(
id);
1018 const auto& amplitudes = clust->amplitudes();
1019 for (
size_t i = 0;
i < amplitudes.size();
i++) {
1020 Signal += amplitudes[
i];
1070 LogDebug(
"") <<
" Looping over Mono Hits ";
1074 hitend = rphiHitsHandle->data().end();
1090 Int_t siLayerNum = 0;
1092 string siDetName =
"";
1095 siLayerNum = tTopo->tibLayer(
id);
1099 siLayerNum = tTopo->tobLayer(
id);
1126 const auto& amplitudes = clust->amplitudes();
1127 for (
size_t i = 0;
i < amplitudes.size();
i++) {
1128 Signal += amplitudes[
i];
1182 LogDebug(
"") <<
" Loop over Matched Hits ";
1187 hitend = matchedHitsHandle->data().end();
1200 Int_t siLayerNum = 0;
1202 string siDetName =
"";
1204 siLayerNum = tTopo->tibLayer(
id);
1208 siLayerNum = tTopo->tobLayer(
id);
1294 LogDebug(
"") <<
"Entering endJob ";
1328 LogDebug(
"") <<
" Writing out ntuple is disabled for now ";
TH1F * sizeSuperClustersEl_
float MatchedHitTheta_[1000]
std::string superClusterCollection_
~SiStripElectronAnalyzer() override
bool isNonnull() const
Checks for non-null.
float StereoHitSigX_[1000]
uint16_t *__restrict__ id
double unwrapPhi(double phi) const
TH1F * emaxSuperClusters_
float MonoHitTheta_[1000]
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
#define DEFINE_FWK_MODULE(type)
float MatchedHitSigY_[1000]
SiStripElectronAnalyzer(const edm::ParameterSet &)
int StereoDetector_[1000]
std::string siElectronCollection_
Geom::Phi< T > phi() const
virtual void initNtuple(void)
int MatchedDetector_[1000]
TH1F * energySuperClustersEl_
float MonoHitSignal_[1000]
TH1F * sizeSuperClustersPassed
Geom::Theta< T > theta() const
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]
ClusterRef cluster() const
std::string mctruthProducer_
std::string siMatchedHitCollection_
static constexpr auto TOB
float StereoHitSigY_[1000]
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
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
int StereoHitWidth_[1000]
XYZPointD XYZPoint
point in space with cartesian internal representation
float MatchedHitNoise_[1000]
T getParameter(std::string const &) const
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
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]