39 outputFileName_ ( cfg.getUntrackedParameter<
std::
string>(
"histoutputFile") ),
40 PropagatorSource_ ( cfg.getParameter<
std::
string>(
"propagator")),
41 muons_ ( cfg.getParameter<
edm::InputTag>(
"muons" ) ),
42 muonsRemake_ ( cfg.getParameter<
edm::InputTag>(
"muonsRemake" ) ),
43 muonsNoStation1_ ( cfg.getParameter<
edm::InputTag>(
"muonsNoStation1") ),
44 muonsNoStation2_ ( cfg.getParameter<
edm::InputTag>(
"muonsNoStation2") ),
45 muonsNoStation3_ ( cfg.getParameter<
edm::InputTag>(
"muonsNoStation3") ),
46 muonsNoStation4_ ( cfg.getParameter<
edm::InputTag>(
"muonsNoStation4") ),
64 debug_ ( cfg.getUntrackedParameter<
bool>(
"doDebug" ) ),
83 if(
debug_) printf(
"STARTING EVENT\n");
100 event.getByLabel(
muons_ , muons );
179 if (
debug_) printf(
"Data Dump:: Rebuilt GMR Muon Track With TeV refitter default\n");
181 for ( reco::TrackCollection::const_iterator
muon = muonTracks->begin();
muon!=muonTracks->end();
muon++, iGmrRemake++) {
194 if (
debug_) printf(
"muons Remake");
195 if (
debug_) printf(
"-----------------------------------------\n");
200 printf(
"muons No Station 1");
201 printf(
"-----------------------------------------\n");
206 printf(
"muons No Station 2");
207 printf(
"-----------------------------------------\n");
212 printf(
"muons No Station 3");
213 printf(
"-----------------------------------------\n");
218 printf(
"muons No Station 4");
219 printf(
"-----------------------------------------\n");
237 for (reco::MuonCollection::const_iterator
muon = muons->begin();
muon != muons->end();
muon++, iGmrCyl++) {
251 if (iGmrRemake > 0 || iGmrCyl > 0) {
253 std::cout <<
"FILLING NTUPLE!" << std::endl;
255 }
else std::cout<<
"no tracks -- no fill!\n"<<std::endl<<std::endl;
288 for ( reco::TrackCollection::const_iterator
muon = trackColl->begin();
muon!=trackColl->end();
muon++) {
290 int iTrack =
muon - trackColl->begin();
297 for(
auto const& rec :
muon->recHits()) {
299 DetId detid = rec->geographicalId();
302 if (
debug_) printf(
"Rec Hit not from muon system or tracker... continuing...\n");
317 float gpRecX = gp.
x();
318 float gpRecY = gp.
y();
319 float gpRecZ = gp.
z();
320 float gpRecEta = gp.
eta();
321 float gpRecPhi = gp.
phi();
331 int superLayer = -999;
336 endcap =
id.endcap();
337 station =
id.station();
339 chamber =
id.chamber();
341 if (
debug_)printf(
"CSC\t[endcap][station][ringN][chamber][layer]:[%d][%d][%d][%d][%d]\t",
342 endcap, station, ring, chamber, layer);
347 station =
id.station();
349 superLayer =
id.superLayer();
351 sector =
id.sector();
352 if (
debug_) printf(
"DT \t[station][layer][superlayer]:[%d][%d][%d]\n", station,layer,superLayer);
357 station =
id.station();
358 if (
debug_) printf(
"RPC\t[station]:[%d]\n", station);
386 if (
debug_) printf(
"Tracker\n");
400 else printf(
"THIS CAN NOT HAPPEN\n");
402 trkExtrap(detid, numTracks, iTrack, iRec, recoStart, lp, trackExtrap);
405 if (
debug_) printf(
"\tLocal Positon: \tx = %2.2f\ty = %2.2f\tz = %2.2f\n",lpX, lpY, lpZ);
406 if (
debug_) printf(
"\tGlobal Position: \tx = %6.2f\ty = %6.2f\tz = %6.2f\teta = %4.2f\tphi = %3.2f\n",
407 gpRecX,gpRecY,gpRecZ,gpRecEta,gpRecPhi);
417 trackExtrap .
n_ = numTracks;
434 for ( reco::TrackCollection::const_iterator
muon = trackColl->begin();
muon!=trackColl->end();
muon++) {
436 int iTrack =
muon - trackColl->begin();
444 for(
auto const& rec1 : ref->recHits()) {
446 bool unbiasedRec =
true;
448 for(
auto const& rec2 :
muon->recHits()) {
455 if (!unbiasedRec)
continue;
457 DetId detid = rec1->geographicalId();
462 trkExtrap(detid, numTracks, iTrackLink, recCounter, recoStart, rec1->localPosition(), trackExtrap);
469 trackExtrap.
n_ = numTracks;
478 if (
debug_) printf(
"Matching a re-fitted track to the original track.\n");
482 for(
auto const& rec : trackIt->recHits()) {
484 bool foundMatch =
false;
485 for (reco::TrackCollection::const_iterator refIt = ref->begin(); refIt!=ref->end(); refIt++) {
487 int iTrackMatch = refIt - ref->begin();
488 if (foundMatch && TrackMatch !=iTrackMatch)
break;
489 for(
auto const& recRef : refIt->recHits()) {
494 TrackMatch = iTrackMatch;
500 printf(
"SOMETHING WENT WRONG! Could not match Track with original track!");
505 if (
debug_) printf(
"Rec hit match for original track %d\n", TrackMatch);
553 if ( fabs( lpx1 - lpx2) > 1
e-3)
return false;
555 if ( fabs( lpy1 - lpy2) > 1
e-3)
return false;
557 if ( fabs( lpz1 - lpz2) > 1
e-3)
return false;
584 detector = detid.
det();
588 std::cout<<
"OMFG NOT THE TRACKER\n"<<std::endl;
598 <<
"\tlayer = " << layer
599 <<
"\tladder = " << ladder
600 <<
"\tmodule = " << module;
610 <<
"\tside = " << side
611 <<
"\tdisk = " << disk
612 <<
"\tblade = " << blade
613 <<
"\tpanel = " << panel
614 <<
"\tmodule = " << module;
621 <<
"\tlayer = " << layer
622 <<
"\tmodule = "<< module;
629 <<
"\tside = " << side
630 <<
"\twheel = " << wheel
631 <<
"\tring = " <<
ring;
638 <<
"\tlayer = " << layer
639 <<
"\tmodule = " << module;
646 <<
"\tring = " << ring
647 <<
"\tmodule = "<< module;
674 storeMuon.
pt_ [
val] = muon->pt();
675 storeMuon.
p_ [
val] = muon->p();
676 storeMuon.
eta_[
val] = muon->eta();
677 storeMuon.
phi_[
val] = muon->phi();
681 storeMuon.
ndf_[
val] = muon->ndof();
695 if (dump_)
std::cout<<
"In the trkExtrap function"<<std::endl;
697 float gpExtrapX = -99999;
698 float gpExtrapY = -99999;
699 float gpExtrapZ = -99999;
700 float gpExtrapEta = -99999;
701 float gpExtrapPhi = -99999;
711 float recLpX = recPoint.
x();
712 float recLpY = recPoint.
y();
713 float recLpZ = recPoint.
z();
727 gpExtrapX = globTest.
x();
728 gpExtrapY = globTest.
y();
729 gpExtrapZ = globTest.
z();
730 gpExtrapEta = globTest.
eta();
731 gpExtrapPhi = globTest.
phi();
747 storeTemp.
gpX_ [iTrk] = gpExtrapX ;
748 storeTemp.
gpY_ [iTrk] = gpExtrapY ;
749 storeTemp.
gpZ_ [iTrk] = gpExtrapZ ;
750 storeTemp.
gpEta_ [iTrk] = gpExtrapEta;
751 storeTemp.
gpPhi_ [iTrk] = gpExtrapPhi;
752 storeTemp.
lpX_ [iTrk] = lpX ;
753 storeTemp.
lpY_ [iTrk] = lpY ;
754 storeTemp.
lpZ_ [iTrk] = lpZ ;
755 storeTemp.
resX_ [iTrk] = resX ;
756 storeTemp.
resY_ [iTrk] = resY ;
757 storeTemp.
resZ_ [iTrk] = resZ ;
774 station =
id.station();
779 station =
id.station();
784 station =
id.station();
803 sector =
id.sector();
830 double phiVal = -9999;
831 double etaVal = -9999;
835 xVal = recoPoint.
x();
836 yVal = recoPoint.
y();
837 zVal = recoPoint.
z();
838 phiVal = recoPoint.
phi();
839 etaVal = recoPoint.
eta();
842 storage.
gpX_ [recNum] = xVal;
843 storage.
gpY_ [recNum] = yVal;
844 storage.
gpZ_ [recNum] = zVal;
845 storage.
gpEta_ [recNum] = etaVal;
846 storage.
gpPhi_ [recNum] = phiVal;
848 float rhoVal =
sqrt( xVal*xVal + yVal*yVal);
850 printf(
"Cylinder: rho = %4.2f\tphi = %4.2f\teta = %4.2f\n", rhoVal, phiVal, etaVal);
851 if (
debug_) printf(
"Cylinder: rho = %4.2f\tphi = %4.2f\teta = %4.2f\n", rhoVal, phiVal, etaVal);
863 if (
debug_) printf(
"zero_storage\n");
968 str->
pt_ [
i] = -9999;
969 str->
eta_ [
i] = -9999;
971 str->
phi_ [
i] = -9999;
974 str->
ndf_ [
i] = -9999;
989 str->
gpX_ [
i] = -9999;
990 str->
gpY_ [
i] = -9999;
991 str->
gpZ_ [
i] = -9999;
994 str->
lpX_ [
i] = -9999;
995 str->
lpY_ [
i] = -9999;
996 str->
lpZ_ [
i] = -9999;
1012 outputTree_ =
new TTree(
"outputTree",
"outputTree");
1071 "muonLink_[1000]/I:" 1079 "superLayer_[1000]/I:" 1099 "muonLink_[1000]/I:" 1100 "detector_[1000]/I:" 1101 "subdetector_[1000]/I:" 1163 "numRecHits_[10]/I:" 1166 "chiSqOvrNdf_[10]/F" 1178 "muonLink_[1000]/I:" 1214 <<
"\tx = " << innerPos.X()
1215 <<
"\ty = " << innerPos.Y()
1216 <<
"\tz = " << innerPos.Z()
1219 GlobalPoint innerPoint( innerPos.X(), innerPos.Y(), innerPos.Z());
1220 GlobalVector innerVec ( innerMom.X(), innerMom.Y(), innerMom.Z());
1236 for (
unsigned int i = 0;
i < (
unsigned int)track.
n_;
i++) {
1240 printf (
"%d\tmuonLink= %d",
i, (
int)track.
muonLink_[
i]);
1241 printf (
"\trecLink = %d", (
int)track.
recLink_[i] );
1248 printf (
"\t\tLocal\tx = %0.3f" , (
float)track.
lpX_[i] );
1249 printf (
"\ty = %0.3f" , (
float)track.
lpY_[i] );
1250 printf (
"\tz = %0.3f\n" , (
float)track.
lpZ_[i] );
1260 for (
unsigned int i = 0;
i < (
unsigned int)hit.
n_;
i++) {
1264 printf (
"%d\tsubdetector = %d\t superLayer =%d" ,
i, (
int)hit.
system_[
i], (
int)hit.
superLayer_[i] );
1271 printf (
"\t\tLocal\tx = %0.3f" , (
float)hit.
lpX_[i] );
1272 printf (
"\ty = %0.3f" , (
float)hit.
lpY_[i] );
1273 printf (
"\tz = %0.3f\n" , (
float)hit.
lpZ_[i] );
1283 for (
unsigned int i = 0;
i < (
unsigned int)hit.
n_;
i++) {
1288 printf (
"\tlayer = %d" , (
int)hit.
layer_[i] );
1295 printf (
"\t\tLocal\tx = %0.3f" , (
float)hit.
lpX_[i] );
1296 printf (
"\ty = %0.3f" , (
float)hit.
lpY_[i] );
1297 printf (
"\tz = %0.3f\n" , (
float)hit.
lpZ_[i] );
1307 float pt = muon->pt();
1308 float p = muon->p ();
1309 float eta = muon->eta();
1310 float phi = muon->phi();
1311 printf(
"\t%s: \tp = %4.2f \t pt = %4.2f \t eta = %4.2f \t phi = %4.2f\n",str.c_str(),
p,
pt,
eta,
phi);
void update(const edm::EventSetup &setup)
update the services each event
void CollectTrackHits(edm::Handle< reco::TrackCollection > trackColl, ResidualRefitting::storage_trackExtrap &trackExtrap, const edm::EventSetup &eventSetup)
int numRecHits_[N_MAX_STORED]
ResidualRefitting::storage_muon storageGmrNoTIBLayer4
int endcap_[N_MAX_STORED_HIT]
T getParameter(std::string const &) const
EventNumber_t event() const
ResidualRefitting::storage_muon storageTrkNoTOBLayer4
int ring_[N_MAX_STORED_HIT]
void zero_muon(ResidualRefitting::storage_muon *str)
static const int N_MAX_STORED
unsigned int tibLayer(const DetId &id) const
int muonLink_[N_MAX_STORED_HIT]
int ReturnStation(DetId detid)
unsigned int tidRing(const DetId &id) const
void dumpTrackRef(reco::TrackRef muon, std::string str)
ResidualRefitting::storage_muon storageGmrNoTOBLayer1
void dumpMuonRecHits(const ResidualRefitting::storage_hit &hit)
ResidualRefitting::storage_trackExtrap storageTrackNoTEC
ResidualRefitting::storage_muon storageGmrNoPXBLayer1
float lpZ_[N_MAX_STORED_HIT]
bool IsSameHit(TrackingRecHit const &hit1, TrackingRecHit const &hit2)
ResidualRefitting::storage_trackExtrap storageTrackNoPXBLayer1
int detector_[N_MAX_STORED_HIT]
ResidualRefitting::storage_muon storageGmrNoTID
ResidualRefitting::storage_muon storageTrkNoTOBLayer6
unsigned int pxfDisk(const DetId &id) const
LocalPoint localPosition() const
int ReturnSector(DetId detid)
ResidualRefitting::storage_muon storageGmrNoTIBLayer1
unsigned int tecRing(const DetId &id) const
ring id
ResidualRefitting::storage_trackHit storageTrackHit_
std::string PropagatorSource_
const MagneticField * theField
void zero_trackExtrap(ResidualRefitting::storage_trackExtrap *str)
Geom::Phi< T > phi() const
int disk_[N_MAX_STORED_HIT]
unsigned int pxbLadder(const DetId &id) const
constexpr uint32_t rawId() const
get the raw id
void analyze(const edm::Event &, const edm::EventSetup &) override
ResidualRefitting::storage_trackExtrap storageTrackExtrapRecNoSt3_
ResidualRefitting::storage_muon storageTrkNoTOBLayer5
GlobalPoint globalPosition() const
unsigned int tidWheel(const DetId &id) const
unsigned int pxbModule(const DetId &id) const
ResidualRefitting::storage_trackExtrap storageTrackNoTIBLayer2
static const int N_MAX_STORED_HIT
ResidualRefitting::storage_trackExtrap storageTrackNoTIBLayer4
int layer_[N_MAX_STORED_HIT]
ResidualRefitting::storage_muon storageTrkNoTIBLayer2
int sector_[N_MAX_STORED_HIT]
ResidualRefitting::storage_muon storageGmrNoTOBLayer2
void NewTrackMeasurements(edm::Handle< reco::TrackCollection > trackCollOrig, edm::Handle< reco::TrackCollection > trackColl, ResidualRefitting::storage_trackExtrap &trackExtrap)
ResidualRefitting::storage_muon storageGmrNoSt1_
int layer_[N_MAX_STORED_HIT]
int chamber_[N_MAX_STORED_HIT]
ResidualRefitting::storage_trackExtrap storageTrackNoTOBLayer6
float lpY_[N_MAX_STORED_HIT]
ResidualRefitting::storage_trackExtrap storageTrackExtrapRecNoSt1_
void trkExtrap(const DetId &detid, int iTrkLink, int iTrk, int iRec, const FreeTrajectoryState &freeTrajState, const LocalPoint &recPoint, storage_trackExtrap &storeTemp)
ResidualRefitting::storage_muon storageGmrNoTOBLayer6
const Plane & surface() const
The nominal surface of the GeomDet.
int module_[N_MAX_STORED_HIT]
int muonLink_[N_MAX_STORED_HIT]
ResidualRefitting::storage_muon storageSamNew_
int charge_[N_MAX_STORED]
ResidualRefitting::storage_trackExtrap storageTrackNoTOBLayer4
float gpEta_[N_MAX_STORED_HIT]
float gpPhi_[N_MAX_STORED_HIT]
ResidualRefitting::storage_muon storageTrkNoTID
ResidualRefitting::storage_trackExtrap storageTrackExtrapTracker_
float gpZ_[N_MAX_STORED_HIT]
ResidualRefitting::storage_trackExtrap storageTrackExtrapRec_
ResidualRefitting::storage_muon storageGmrNoTOBLayer4
ResidualRefitting::storage_muon storageGmrNoSt4_
edm::InputTag muonsNoStation2_
static CylinderPointer build(const PositionType &pos, const RotationType &rot, Scalar radius, Bounds *bounds=0)
ResidualRefitting::storage_trackExtrap storageTrackExtrapRecNoSt4_
ResidualRefitting::storage_trackExtrap storageTrackNoTOBLayer2
void branchMuon(ResidualRefitting::storage_muon &storageTmp, std::string branchName)
#define DEFINE_FWK_MODULE(type)
int MatchTrackWithRecHits(reco::TrackCollection::const_iterator trackIt, edm::Handle< reco::TrackCollection > ref)
unsigned int tidSide(const DetId &id) const
float lpX_[N_MAX_STORED_HIT]
ResidualRefitting::storage_muon storageSamNoSt4_
int wheel_[N_MAX_STORED_HIT]
void muonInfo(ResidualRefitting::storage_muon &storeMuon, reco::TrackRef muon, int val)
ResidualRefitting::storage_trackExtrap storageTrackExtrapRecNoSt2_
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
ResidualRefitting::storage_muon storageTrkNoPXBLayer2
edm::InputTag muonsNoStation1_
int subdetector_[N_MAX_STORED_HIT]
ResidualRefitting::storage_muon storageGmrNoSt2_
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
float gpY_[N_MAX_STORED_HIT]
ResidualRefitting::storage_muon storageGmrNoSt3_
float gpY_[N_MAX_STORED_HIT]
float lpX_[N_MAX_STORED_HIT]
MuonServiceProxy * theService
ResidualRefitting::storage_muon storageGmrNoPXBLayer2
void dumpTrackExtrap(const ResidualRefitting::storage_trackExtrap &track)
ResidualRefitting(const edm::ParameterSet &)
FreeTrajectoryState freeTrajStateMuon(reco::TrackRef muon)
virtual LocalPoint localPosition() const =0
~ResidualRefitting() override
ResidualRefitting::storage_muon storageGmrOld_
int side_[N_MAX_STORED_HIT]
ResidualRefitting::storage_muon storageTrkNoPXF
ResidualRefitting::storage_muon storageGmrNoTEC
ResidualRefitting::storage_trackExtrap trackExtrap120_
unsigned int tibModule(const DetId &id) const
unsigned int pxfModule(const DetId &id) const
unsigned int pxbLayer(const DetId &id) const
unsigned int tecModule(const DetId &id) const
edm::InputTag muonsNoStation3_
ResidualRefitting::storage_muon storageGmrNoTIBLayer3
ResidualRefitting::storage_muon storageGmrNew_
float gpX_[N_MAX_STORED_HIT]
std::string outputFileName_
int panel_[N_MAX_STORED_HIT]
ResidualRefitting::storage_muon storageGmrNoTIBLayer2
int station_[N_MAX_STORED_HIT]
edm::InputTag muonsRemake_
void cylExtrapTrkSam(int recNum, reco::TrackRef track, ResidualRefitting::storage_trackExtrap &storage, double rho)
float lpY_[N_MAX_STORED_HIT]
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
float gpPhi_[N_MAX_STORED_HIT]
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
ResidualRefitting::storage_muon storageTrkNoTIBLayer3
int ring_[N_MAX_STORED_HIT]
ResidualRefitting::storage_trackExtrap storageTrackNoTID
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
ResidualRefitting::storage_muon storageTrkNoTOBLayer2
unsigned int tobModule(const DetId &id) const
ResidualRefitting::storage_trackExtrap storageTrackNoPXBLayer3
ResidualRefitting::storage_trackExtrap storageTrackNoTOBLayer5
edm::ESHandle< GlobalTrackingGeometry > trackingGeometry() const
get the tracking geometry
ResidualRefitting::storage_muon storageSamNoSt2_
void dumpTrackHits(const ResidualRefitting::storage_trackHit &hit)
ResidualRefitting::storage_trackExtrap storageTrackNoTOBLayer3
int wheel_[N_MAX_STORED_HIT]
float lpZ_[N_MAX_STORED_HIT]
ResidualRefitting::storage_muon storageTrkNoTOBLayer1
float chiSqOvrNdf_[N_MAX_STORED]
ResidualRefitting::storage_muon storageGmrNoPXBLayer3
ResidualRefitting::storage_muon storageTrkNoTEC
ResidualRefitting::storage_muon storageSamNoSt3_
const GeomDet * idToDet(DetId) const override
ResidualRefitting::storage_muon storageTrkNoPXBLayer1
float gpZ_[N_MAX_STORED_HIT]
ResidualRefitting::storage_muon storageTrkNoTIBLayer1
ResidualRefitting::storage_muon storageGmrNoTOBLayer3
ResidualRefitting::storage_trackExtrap storageTrackNoTIBLayer1
unsigned int pxfSide(const DetId &id) const
int superLayer_[N_MAX_STORED_HIT]
ResidualRefitting::storage_event eventInfo_
ResidualRefitting::storage_hit storageRecMuon_
int blade_[N_MAX_STORED_HIT]
ResidualRefitting::storage_muon storageTrkNoTOBLayer3
edm::ESHandle< Propagator > thePropagator
float chiSq_[N_MAX_STORED]
void StoreTrackerRecHits(DetId detid, const TrackerTopology *tTopo, int iTrack, int iRec)
ResidualRefitting::storage_muon storageTrkNew_
ResidualRefitting::storage_trackExtrap storageTrackNoPXF
ResidualRefitting::storage_muon storageSamNoSt1_
float gpEta_[N_MAX_STORED_HIT]
ResidualRefitting::storage_muon storageGmrNoTOBLayer5
ResidualRefitting::storage_trackExtrap storageTrackNoTIBLayer3
T const * product() const
static MuonRecHitPointer specificBuild(const GeomDet *geom, const TrackingRecHit *rh)
edm::InputTag muonsNoStation4_
int system_[N_MAX_STORED_HIT]
unsigned int pxfPanel(const DetId &id) const
unsigned int pxfBlade(const DetId &id) const
ResidualRefitting::storage_trackExtrap storageTrackNoTOBLayer1
int ladder_[N_MAX_STORED_HIT]
float gpX_[N_MAX_STORED_HIT]
void branchTrackExtrap(ResidualRefitting::storage_trackExtrap &storageTmp, std::string branchName)
ResidualRefitting::storage_muon storageGmrNoPXF
ResidualRefitting::storage_trackExtrap storageTrackNoPXBLayer2
unsigned int tobLayer(const DetId &id) const
ResidualRefitting::storage_muon storageTrkNoPXBLayer3
ResidualRefitting::storage_muon storageTrkNoTIBLayer4
constexpr Detector det() const
get the detector field from this detid
ResidualRefitting::storage_trackExtrap samExtrap120_