90 pMin =
pset.getUntrackedParameter<
double>(
"pMin", 3.);
91 zLengthMin =
pset.getUntrackedParameter<
double>(
"zLengthMin", 200.);
93 zInnerMax =
pset.getUntrackedParameter<
double>(
"zInnerMax", 9000.);
96 rExtMax =
pset.getUntrackedParameter<
double>(
"rExtMax", 3000.);
100 LogInfo(
"[CSCSkim] Setup") <<
"\n\t===== CSCSkim =====\n" 101 <<
"\t\ttype of skim ...............................\t" <<
typeOfSkim 104 <<
"\n\t\tminimum number of segments ...............\t" <<
minimumSegments 106 <<
"\n\t\tmake histograms...........................\t" <<
makeHistograms 108 <<
"\n\t===================\n\n";
141 hxnRecHits =
new TH1F(
"hxnRecHits",
"n RecHits", 61, -0.5, 60.5);
142 hxnSegments =
new TH1F(
"hxnSegments",
"n Segments", 11, -0.5, 10.5);
143 hxnHitChambers =
new TH1F(
"hxnHitsChambers",
"n chambers with hits", 11, -0.5, 10.5);
144 hxnRecHitsSel =
new TH1F(
"hxnRecHitsSel",
"n RecHits selected", 61, -0.5, 60.5);
146 xxP =
new TH1F(
"xxP",
"P global", 100, 0., 200.);
147 xxnValidHits =
new TH1F(
"xxnValidHits",
"n valid hits global", 61, -0.5, 60.5);
148 xxnTrackerHits =
new TH1F(
"xxnTrackerHits",
"n tracker hits global", 61, -0.5, 60.5);
149 xxnCSCHits =
new TH1F(
"xxnCSCHits",
"n CSC hits global", 41, -0.5, 40.5);
150 xxredChiSq =
new TH1F(
"xxredChiSq",
"red chisq global", 100, 0., 100.);
154 mevnRecHits0 =
new TH1F(
"mevnRecHits0",
"n RecHits", 121, -0.5, 120.5);
155 mevnChambers0 =
new TH1F(
"mevnChambers0",
"n chambers with hits", 21, -0.5, 20.5);
156 mevnSegments0 =
new TH1F(
"mevnSegments0",
"n Segments", 21, -0.5, 20.5);
157 mevnRecHits1 =
new TH1F(
"mevnRecHits1",
"n RecHits", 100, 0., 300.);
158 mevnChambers1 =
new TH1F(
"mevnChambers1",
"n chambers with hits", 50, 0., 50.);
159 mevnSegments1 =
new TH1F(
"mevnSegments1",
"n Segments", 30, 0., 30.);
175 LogInfo(
"[CSCSkim] Summary") <<
"\n\n\t====== CSCSkim ==========================================================\n" 176 <<
"\t\ttype of skim ...............................\t" <<
typeOfSkim <<
"\n" 179 <<
"\tfraction= " <<
fraction << std::endl
182 <<
"\t\tevents lots of hit chambers . \t" <<
nEventsMessy <<
"\n" 188 <<
"\t=========================================================================\n\n";
192 LogDebug(
"[CSCSkim]") <<
"======= write out my histograms ====\n";
219 iRun =
event.id().run();
220 iEvent =
event.id().event();
231 if (
event.eventAuxiliary().isRealData()) {
241 event.getByToken(
rh_token, cscRecHits);
267 bool basicEvent =
false;
273 bool goodOverlapEvent =
false;
276 if (goodOverlapEvent) {
282 bool messyEvent =
false;
291 bool hasChamber =
false;
300 bool DTOverlapCandidate =
false;
303 if (DTOverlapCandidate) {
309 bool HaloLike =
false;
318 bool LongSATrack =
false;
327 bool GoodForBFieldStudy =
false;
330 if (GoodForBFieldStudy) {
336 bool selectThisEvent =
false;
338 selectThisEvent = basicEvent;
341 selectThisEvent = goodOverlapEvent;
344 selectThisEvent = messyEvent;
347 selectThisEvent = hasChamber;
350 selectThisEvent = DTOverlapCandidate;
353 selectThisEvent = HaloLike;
356 selectThisEvent = LongSATrack;
359 selectThisEvent = GoodForBFieldStudy;
362 if (selectThisEvent) {
366 return selectThisEvent;
378 int nRecHits = cscRecHits->size();
382 for (
int i = 0;
i < 600;
i++) {
391 for (recIt = cscRecHits->begin(); recIt != cscRecHits->end(); recIt++) {
394 int kEndcap = idrec.
endcap();
395 int kRing = idrec.
ring();
396 int kStation = idrec.
station();
397 int kChamber = idrec.
chamber();
401 int kSerial =
chamberSerial(kEndcap, kStation, kRing, kChamber);
406 cntRecHit[kSerial] += kDigit;
414 int nChambersWithMinimalHits = 0;
415 int nChambersWithMinimalHitsPOS = 0;
416 int nChambersWithMinimalHitsNEG = 0;
418 for (
int i = 0;
i < 600;
i++) {
419 if (cntRecHit[
i] > 0) {
420 int nLayersWithHits = 0;
422 for (
int j = 5;
j > -1;
j--) {
423 float digit =
dummy /
pow((
float)10., (
float)
j);
424 int kCount = (
int)digit;
431 nChambersWithMinimalHitsPOS++;
433 nChambersWithMinimalHitsNEG++;
438 nChambersWithMinimalHits = nChambersWithMinimalHitsPOS + nChambersWithMinimalHitsNEG;
454 if (nChambersWithMinimalHits > 0) {
464 bool chambersOnBothSides =
467 if (chambersOnBothSides) {
471 bool selectEvent =
false;
473 selectEvent = basicEvent;
476 selectEvent = chambersOnBothSides;
480 LogDebug(
"[CSCSkim]") <<
"----- nRecHits = " << nRecHits
481 <<
"\tnChambersWithMinimalHits = " << nChambersWithMinimalHits <<
"\tnSegments = " << nSegments
482 <<
"\tselect? " << selectEvent << std::endl;
511 const int nhitsMinimum = 4;
512 const float chisqMaximum = 100.;
513 const int nAllMaximum = 3;
521 for (
int i = 0;
i < 600;
i++) {
532 int kEndcap =
id.
endcap();
533 int kStation =
id.station();
534 int kRing =
id.ring();
535 int kChamber =
id.chamber();
536 int kSerial =
chamberSerial(kEndcap, kStation, kRing, kChamber);
539 float chisq = (*it).chi2();
540 int nhits = (*it).nRecHits();
543 bool goodSegment = (
nhits >= nhitsMinimum) && (chisq < chisqMaximum);
567 bool messyChamber =
false;
568 for (
int i = 0;
i < 600;
i++) {
569 if (nAll[
i] > nAllMaximum)
575 bool consecutiveChambers =
false;
576 for (
int i = 0;
i < 599;
i++) {
577 if ((nGood[
i] > 0) && (nGood[
i + 1] > 0))
578 consecutiveChambers =
true;
581 bool selectThisEvent = !messyChamber && consecutiveChambers;
583 return selectThisEvent;
595 int nRecHits = cscRecHits->size();
599 for (
int i = 0;
i < 600;
i++) {
608 for (recIt = cscRecHits->begin(); recIt != cscRecHits->end(); recIt++) {
611 int kEndcap = idrec.
endcap();
612 int kRing = idrec.
ring();
613 int kStation = idrec.
station();
614 int kChamber = idrec.
chamber();
618 int kSerial =
chamberSerial(kEndcap, kStation, kRing, kChamber);
623 cntRecHit[kSerial] += kDigit;
631 int nChambersWithMinimalHits = 0;
632 int nChambersWithMinimalHitsPOS = 0;
633 int nChambersWithMinimalHitsNEG = 0;
635 for (
int i = 0;
i < 600;
i++) {
636 if (cntRecHit[
i] > 0) {
637 int nLayersWithHits = 0;
639 for (
int j = 5;
j > -1;
j--) {
640 float digit =
dummy /
pow((
float)10., (
float)
j);
641 int kCount = (
int)digit;
648 nChambersWithMinimalHitsPOS++;
650 nChambersWithMinimalHitsNEG++;
655 nChambersWithMinimalHits = nChambersWithMinimalHitsPOS + nChambersWithMinimalHitsNEG;
672 double dummy = (double)nRecHits;
676 dummy = (double)nChambersWithMinimalHits;
680 dummy = (double)nSegments;
691 bool selectEvent =
false;
692 if ((nRecHits > 54) && (nChambersWithMinimalHits > 5)) {
697 LogDebug(
"[CSCSkim]") <<
"----- nRecHits = " << nRecHits
698 <<
"\tnChambersWithMinimalHits = " << nChambersWithMinimalHits <<
"\tnSegments = " << nSegments
699 <<
"\tselect? " << selectEvent << std::endl;
731 bool certainChamberIsPresentInWires =
false;
734 int kEndcap =
id.
endcap();
735 int kRing =
id.ring();
736 int kStation =
id.station();
737 int kChamber =
id.chamber();
739 certainChamberIsPresentInWires =
true;
744 bool certainChamberIsPresentInStrips =
false;
747 int kEndcap =
id.
endcap();
748 int kRing =
id.ring();
749 int kStation =
id.station();
750 int kChamber =
id.chamber();
752 certainChamberIsPresentInStrips =
true;
756 bool certainChamberIsPresent = certainChamberIsPresentInWires || certainChamberIsPresentInStrips;
758 return certainChamberIsPresent;
767 const float chisqMax = 100.;
768 const int nhitsMin = 5;
769 const int maxNSegments = 3;
772 bool DTOverlapCandidate =
false;
779 for (
int i = 0;
i < 36; ++
i) {
794 return DTOverlapCandidate;
799 int kEndcap =
id.
endcap();
800 int kStation =
id.station();
801 int kRing =
id.ring();
802 int kChamber =
id.chamber();
804 float chisq = (*it).chi2();
805 int nhits = (*it).nRecHits();
806 bool goodSegment = (chisq < chisqMax) && (nhits >= nhitsMin);
808 if ((kStation == 1) && (kRing == 3)) {
810 cntMEP13[kChamber - 1]++;
813 cntMEN13[kChamber - 1]++;
816 if ((kStation == 2) && (kRing == 2)) {
818 cntMEP22[kChamber - 1]++;
821 cntMEN22[kChamber - 1]++;
824 if ((kStation == 3) && (kRing == 2)) {
826 cntMEP32[kChamber - 1]++;
829 cntMEN32[kChamber - 1]++;
838 bool tooManySegments =
false;
839 for (
int i = 0;
i < 36; ++
i) {
840 if ((cntMEP13[
i] > maxNSegments) || (cntMEN13[
i] > maxNSegments) || (cntMEP22[
i] > maxNSegments) ||
841 (cntMEN22[
i] > maxNSegments) || (cntMEP32[
i] > maxNSegments) || (cntMEN32[
i] > maxNSegments))
842 tooManySegments =
true;
844 if (tooManySegments) {
845 return DTOverlapCandidate;
851 bool matchup =
false;
852 for (
int i = 0;
i < 36; ++
i) {
853 if ((cntMEP13[
i] > 0) && (cntMEP22[
i] + cntMEP32[
i] > 0)) {
856 if ((cntMEN13[
i] > 0) && (cntMEN22[
i] + cntMEN32[
i] > 0)) {
875 DTOverlapCandidate = matchup;
876 return DTOverlapCandidate;
886 const float chisqMax = 100.;
887 const int nhitsMin = 5;
888 const int maxNSegments = 3;
891 bool HaloLike =
false;
902 for (
int i = 0;
i < 36; ++
i) {
925 int kEndcap =
id.
endcap();
926 int kStation =
id.station();
927 int kRing =
id.ring();
928 int kChamber =
id.chamber();
930 float chisq = (*it).chi2();
931 int nhits = (*it).nRecHits();
932 bool goodSegment = (chisq < chisqMax) && (nhits >= nhitsMin);
934 if ((kStation == 1) && (kRing == 1)) {
936 cntMEP11[kChamber - 1]++;
939 cntMEN11[kChamber - 1]++;
942 if ((kStation == 1) && (kRing == 2)) {
944 cntMEP12[kChamber - 1]++;
947 cntMEN12[kChamber - 1]++;
950 if ((kStation == 2) && (kRing == 1)) {
952 cntMEP21[kChamber - 1]++;
955 cntMEN21[kChamber - 1]++;
958 if ((kStation == 3) && (kRing == 1)) {
960 cntMEP31[kChamber - 1]++;
963 cntMEN31[kChamber - 1]++;
966 if ((kStation == 4) && (kRing == 1)) {
968 cntMEP41[kChamber - 1]++;
971 cntMEN41[kChamber - 1]++;
980 bool tooManySegments =
false;
981 for (
int i = 0;
i < 36; ++
i) {
982 if ((cntMEP11[
i] > 3 * maxNSegments) || (cntMEN11[
i] > 3 * maxNSegments) || (cntMEP12[
i] > maxNSegments) ||
983 (cntMEN12[
i] > maxNSegments) || (cntMEP21[
i] > maxNSegments) || (cntMEN21[
i] > maxNSegments) ||
984 (cntMEP31[
i] > maxNSegments) || (cntMEN31[
i] > maxNSegments) || (cntMEP41[
i] > maxNSegments) ||
985 (cntMEN41[
i] > maxNSegments))
986 tooManySegments =
true;
988 if (tooManySegments) {
995 bool matchup =
false;
996 for (
int i = 0;
i < 36; ++
i) {
997 if ((cntMEP11[
i] + cntMEP12[
i] > 0) && (cntMEP21[
i] > 0) && (cntMEP31[
i] > 0) && (cntMEP41[
i] > 0)) {
1000 if ((cntMEN11[
i] + cntMEN12[
i] > 0) && (cntMEN21[
i] > 0) && (cntMEN31[
i] > 0) && (cntMEN41[
i] > 0)) {
1044 const float zDistanceMax = 2500.;
1045 const float zDistanceMin = 700.;
1047 const int nCSCHitsMax = 50;
1050 const int nNiceMuonsMin = 1;
1058 for (reco::TrackCollection::const_iterator
muon = saMuons->begin();
muon != saMuons->end(); ++
muon) {
1061 GlobalVector im(innerMo.x(), innerMo.y(), innerMo.z());
1063 GlobalPoint ip(innerPo.x(), innerPo.y(), innerPo.z());
1065 GlobalPoint op(outerPo.x(), outerPo.y(), outerPo.z());
1066 float zInner = ip.
z();
1067 float zOuter = op.z();
1068 float zDistance = fabs(zOuter - zInner);
1074 const DetId detId((*hit)->geographicalId());
1089 if ((zDistance < zDistanceMax) && (zDistance > zDistanceMin) && (nCSCHits >
nCSCHitsMin) &&
1090 (nCSCHits < nCSCHitsMax) && (
min(fabs(zInner), fabs(zOuter)) <
zInnerMax) &&
1091 (fabs(innerMo.z()) > 0.000000001)) {
1096 bool select = (nNiceMuons >= nNiceMuonsMin);
1112 bool acceptThisEvent =
false;
1117 int nGoodSAMuons = 0;
1118 for (reco::TrackCollection::const_iterator
muon = saMuons->begin();
muon != saMuons->end(); ++
muon) {
1119 float preco =
muon->p();
1122 GlobalPoint iPnt(innerPo.x(), innerPo.y(), innerPo.z());
1124 GlobalPoint oPnt(outerPo.x(), outerPo.y(), outerPo.z());
1125 float zLength =
abs(iPnt.z() - oPnt.z());
1128 GlobalVector iP(innerMom.x(), innerMom.y(), innerMom.z());
1130 GlobalVector oP(outerMom.x(), outerMom.y(), outerMom.z());
1132 const float zRef = 300.;
1133 float xExt = 10000.;
1134 float yExt = 10000.;
1135 if (
abs(oPnt.z()) <
abs(iPnt.z())) {
1138 deltaZ = zRef - oPnt.z();
1140 deltaZ = -zRef - oPnt.z();
1142 xExt = oPnt.x() +
deltaZ * oP.x() / oP.z();
1143 yExt = oPnt.y() +
deltaZ * oP.y() / oP.z();
1147 deltaZ = zRef - iPnt.z();
1149 deltaZ = -zRef - iPnt.z();
1151 xExt = iPnt.x() +
deltaZ * iP.x() / iP.z();
1152 yExt = iPnt.y() +
deltaZ * iP.y() / iP.z();
1154 float rExt =
sqrt(xExt * xExt + yExt * yExt);
1161 const DetId detId((*hit)->geographicalId());
1173 if (
abs(iPnt.z()) <
abs(iPnt.z())) {
1192 int nGoodTracks = 0;
1194 float preco =
track->p();
1195 int n =
track->recHitsSize();
1198 GlobalPoint iPnt(innerPo.x(), innerPo.y(), innerPo.z());
1200 GlobalPoint oPnt(outerPo.x(), outerPo.y(), outerPo.z());
1201 float zLength =
abs(iPnt.z() - oPnt.z());
1204 GlobalVector iP(innerMom.x(), innerMom.y(), innerMom.z());
1206 GlobalVector oP(outerMom.x(), outerMom.y(), outerMom.z());
1208 const float zRef = 300.;
1209 float xExt = 10000.;
1210 float yExt = 10000.;
1211 if (
abs(oPnt.z()) >
abs(iPnt.z())) {
1214 deltaZ = zRef - oPnt.z();
1216 deltaZ = -zRef - oPnt.z();
1218 xExt = oPnt.x() +
deltaZ * oP.x() / oP.z();
1219 yExt = oPnt.y() +
deltaZ * oP.y() / oP.z();
1223 deltaZ = zRef - iPnt.z();
1225 deltaZ = -zRef - iPnt.z();
1227 xExt = iPnt.x() +
deltaZ * iP.x() / iP.z();
1228 yExt = iPnt.y() +
deltaZ * iP.y() / iP.z();
1230 float rExt =
sqrt(xExt * xExt + yExt * yExt);
1243 int nGoodGlobalMuons = 0;
1244 for (reco::MuonCollection::const_iterator global = gMuons->begin(); global != gMuons->end(); ++global) {
1245 if (global->isGlobalMuon()) {
1246 float pDef = global->p();
1247 float redChiSq = global->globalTrack()->normalizedChi2();
1251 int nTrackerHits =
hp.numberOfValidTrackerHits();
1258 hit != (global->globalTrack())->recHitsEnd();
1260 const DetId detId((*hit)->geographicalId());
1270 bool goodGlobalMuon =
1273 if (goodGlobalMuon) {
1284 acceptThisEvent = ((nGoodSAMuons > 0) && (nGoodTracks > 0)) || (nGoodGlobalMuons > 0);
1286 return acceptThisEvent;
1294 int kSerial = kChamber;
1295 if (kStation == 1 && kRing == 1) {
1298 if (kStation == 1 && kRing == 2) {
1299 kSerial = kChamber + 36;
1301 if (kStation == 1 && kRing == 3) {
1302 kSerial = kChamber + 72;
1304 if (kStation == 1 && kRing == 4) {
1307 if (kStation == 2 && kRing == 1) {
1308 kSerial = kChamber + 108;
1310 if (kStation == 2 && kRing == 2) {
1311 kSerial = kChamber + 126;
1313 if (kStation == 3 && kRing == 1) {
1314 kSerial = kChamber + 162;
1316 if (kStation == 3 && kRing == 2) {
1317 kSerial = kChamber + 180;
1319 if (kStation == 4 && kRing == 1) {
1320 kSerial = kChamber + 216;
1322 if (kStation == 4 && kRing == 2) {
1323 kSerial = kChamber + 234;
1326 kSerial = kSerial + 300;
edm::EDGetTokenT< CSCSegmentCollection > seg_token
edm::EDGetTokenT< reco::TrackCollection > sam_token
bool makeHistogramsForMessyEvents
int nEventsForBFieldStudies
int nLayersWithHitsMinimum
bool filter(edm::Event &event, const edm::EventSetup &eventSetup) override
int nEventsChambersBothSides
edm::EDGetTokenT< CSCWireDigiCollection > wds_token
bool doLongSATrack(edm::Handle< reco::TrackCollection > saTracks)
std::string outputFileName
bool doOverlapSkimming(edm::Handle< CSCSegmentCollection > cscSegments)
bool doDTOverlap(edm::Handle< CSCSegmentCollection > cscSegments)
int nEventsOverlappingChambers
C::const_iterator const_iterator
constant access iterator type
edm::EDGetTokenT< reco::TrackCollection > trk_token
bool goodTrack(const reco::Track *pTrack, math::XYZPoint leadPV, trackSelectionParameters parameters, bool debug=false)
edm::EDGetTokenT< reco::MuonCollection > glm_token
std::string histogramFileName
Abs< T >::type abs(const T &t)
edm::EDGetTokenT< CSCStripDigiCollection > sds_token
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< CSCRecHit2DCollection > rh_token
static const std::string kLayer("layer")
bool doCSCSkimming(edm::Handle< CSCRecHit2DCollection > cscRecHits, edm::Handle< CSCSegmentCollection > cscSegments)
bool doCertainChamberSelection(edm::Handle< CSCWireDigiCollection > wires, edm::Handle< CSCStripDigiCollection > strips)
bool doBFieldStudySelection(edm::Handle< reco::TrackCollection > saTracks, edm::Handle< reco::TrackCollection > Tracks, edm::Handle< reco::MuonCollection > gMuons)
Log< level::Info, false > LogInfo
int nEventsCertainChamber
auto const & tracks
cannot be loose
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
bool doMessyEventSkimming(edm::Handle< CSCRecHit2DCollection > cscRecHits, edm::Handle< CSCSegmentCollection > cscSegments)
const edm::ESGetToken< CSCGeometry, MuonGeometryRecord > m_CSCGeomToken
strips
#turn off noise in all subdetectors simHcalUnsuppressedDigis.doNoise = False mix.digitizers.hcal.doNoise = False simEcalUnsuppressedDigis.doNoise = False mix.digitizers.ecal.doNoise = False simEcalUnsuppressedDigis.doESNoise = False simSiPixelDigis.AddNoise = False mix.digitizers.pixel.AddNoise = False simSiStripDigis.Noise = False mix.digitizers.strip.AddNoise = False
int chamberSerial(int kE, int kS, int kR, int kCh)
CSCSkim(const edm::ParameterSet &pset)
edm::EDGetTokenT< CSCWireDigiCollection > wdr_token
edm::EDGetTokenT< CSCStripDigiCollection > sdr_token
Power< A, B >::type pow(const A &a, const B &b)
bool demandChambersBothSides
bool doHaloLike(edm::Handle< CSCSegmentCollection > cscSegments)