Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-27 04:04:53

0001 #include "RecoTracker/SpecialSeedGenerators/interface/SeedGeneratorForCRack.h"
0002 #include "RecoTracker/TkHitPairs/interface/CosmicLayerPairs.h"
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 #include "TrackingTools/Records/interface/TransientRecHitRecord.h"
0005 #include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h"
0006 void SeedGeneratorForCRack::init(const SiStripRecHit2DCollection& collstereo,
0007                                  const SiStripRecHit2DCollection& collrphi,
0008                                  const SiStripMatchedRecHit2DCollection& collmatched,
0009                                  const edm::EventSetup& iSetup) {
0010   magfield = iSetup.getHandle(theMagfieldToken);
0011   tracker = iSetup.getHandle(theTrackerToken);
0012   thePropagatorAl = new PropagatorWithMaterial(alongMomentum, 0.1057, &(*magfield));
0013   thePropagatorOp = new PropagatorWithMaterial(oppositeToMomentum, 0.1057, &(*magfield));
0014   theUpdator = new KFUpdator();
0015 
0016   // get the transient builder
0017   TTTRHBuilder = &iSetup.getData(theTTRHToken);
0018 
0019   GeometricSearchTracker const& track = iSetup.getData(theSearchTrackerToken);
0020   TrackerTopology const& ttopo = iSetup.getData(theTTopoToken);
0021 
0022   CosmicLayerPairs cosmiclayers(geometry, collrphi, collmatched, track, ttopo);
0023   thePairGenerator = new CosmicHitPairGenerator(cosmiclayers, *tracker);
0024   HitPairs.clear();
0025   thePairGenerator->hitPairs(region, HitPairs);
0026   LogDebug("CosmicSeedFinder") << "Initialized with " << HitPairs.size() << " hit pairs" << std::endl;
0027 }
0028 
0029 SeedGeneratorForCRack::SeedGeneratorForCRack(edm::ParameterSet const& conf, edm::ConsumesCollector iCC)
0030     : theMagfieldToken(iCC.esConsumes()),
0031       theTrackerToken(iCC.esConsumes()),
0032       theSearchTrackerToken(iCC.esConsumes()),
0033       theTTopoToken(iCC.esConsumes()),
0034       theTTRHToken(iCC.esConsumes(edm::ESInputTag("", conf.getParameter<std::string>("TTRHBuilder")))),
0035       region(conf.getParameter<double>("ptMin"),
0036              conf.getParameter<double>("originRadius"),
0037              conf.getParameter<double>("originHalfLength"),
0038              conf.getParameter<double>("originZPosition")) {
0039   seedpt = conf.getParameter<double>("SeedPt");
0040   geometry = conf.getUntrackedParameter<std::string>("GeometricStructure", "STANDARD");
0041   multipleScatteringFactor = conf.getUntrackedParameter<double>("multipleScatteringFactor", 1.0);
0042   seedMomentum = conf.getUntrackedParameter<double>("SeedMomentum", 1);
0043 }
0044 
0045 void SeedGeneratorForCRack::run(TrajectorySeedCollection& output, const edm::EventSetup& iSetup) {
0046   seeds(output, iSetup, region);
0047   delete thePairGenerator;
0048   delete thePropagatorAl;
0049   delete thePropagatorOp;
0050   delete theUpdator;
0051 }
0052 
0053 void SeedGeneratorForCRack::seeds(TrajectorySeedCollection& output,
0054                                   const edm::EventSetup& iSetup,
0055                                   const TrackingRegion& region) {
0056   for (unsigned int is = 0; is < HitPairs.size(); is++) {
0057     GlobalPoint inner = tracker->idToDet((*(HitPairs[is].inner())).geographicalId())
0058                             ->surface()
0059                             .toGlobal((*(HitPairs[is].inner())).localPosition());
0060     GlobalPoint outer = tracker->idToDet((*(HitPairs[is].outer())).geographicalId())
0061                             ->surface()
0062                             .toGlobal((*(HitPairs[is].outer())).localPosition());
0063 
0064     LogDebug("CosmicSeedFinder") << "inner point of the seed " << inner << " outer point of the seed " << outer;
0065     SeedingHitSet::ConstRecHitPointer inrhit = HitPairs[is].inner();
0066     SeedingHitSet::ConstRecHitPointer outrhit = HitPairs[is].outer();
0067 
0068     edm::OwnVector<TrackingRecHit> hits;
0069     hits.push_back(HitPairs[is].outer()->hit()->clone());
0070 
0071     for (int i = 0; i < 2; i++) {
0072       //FIRST STATE IS CALCULATED CONSIDERING THAT THE CHARGE CAN BE POSITIVE OR NEGATIVE
0073       int predsign = (2 * i) - 1;
0074       if ((outer.y() - inner.y()) > 0) {
0075         GlobalVector momentum = GlobalVector(inner - outer);
0076         momentum = momentum.unit() * seedMomentum;
0077         GlobalTrajectoryParameters Gtp(inner, momentum, predsign, &(*magfield));
0078         AlgebraicSymMatrix55 errMatrix = ROOT::Math::SMatrixIdentity();
0079         TSOS innerState = TSOS(Gtp,
0080                                CurvilinearTrajectoryError(errMatrix),
0081                                tracker->idToDet((HitPairs[is].inner()->hit())->geographicalId())->surface());
0082         const TSOS innerUpdated = theUpdator->update(innerState, *inrhit);
0083         //Cosmic Seed update inner...
0084         LogDebug("CosmicSeedFinder") << " FirstTSOS " << innerUpdated;
0085 
0086         //First propagation
0087         const TSOS outerState = thePropagatorOp->propagate(
0088             innerUpdated, tracker->idToDet((*(HitPairs[is].outer())).geographicalId())->surface());
0089         if (outerState.isValid()) {
0090           LogDebug("CosmicSeedFinder") << "outerState " << outerState;
0091           TSOS outerUpdated = theUpdator->update(outerState, *outrhit);
0092           //fudge factor for multiple scattering
0093           outerUpdated.rescaleError(multipleScatteringFactor);
0094           if (outerUpdated.isValid()) {
0095             LogDebug("CosmicSeedFinder") << "outerUpdated " << outerUpdated;
0096 
0097             PTrajectoryStateOnDet PTraj = trajectoryStateTransform::persistentState(
0098                 outerUpdated, (*(HitPairs[is].outer())).geographicalId().rawId());
0099             output.push_back(TrajectorySeed(PTraj, hits, alongMomentum));
0100 
0101           } else
0102             edm::LogWarning("CosmicSeedFinder") << " SeedForCosmics first update failed ";
0103         } else
0104           edm::LogWarning("CosmicSeedFinder") << " SeedForCosmics first propagation failed ";
0105 
0106       } else {
0107         GlobalVector momentum = GlobalVector(outer - inner);
0108         momentum = momentum.unit() * seedMomentum;
0109         GlobalTrajectoryParameters Gtp(inner, momentum, predsign, &(*magfield));
0110         AlgebraicSymMatrix55 errMatrix = ROOT::Math::SMatrixIdentity();
0111         TSOS innerState = TSOS(Gtp,
0112                                CurvilinearTrajectoryError(errMatrix),
0113                                tracker->idToDet((HitPairs[is].inner()->hit())->geographicalId())->surface());
0114         const TSOS innerUpdated = theUpdator->update(innerState, *inrhit);
0115         LogDebug("CosmicSeedFinder") << " FirstTSOS " << innerState;
0116 
0117         //First propagation
0118         const TSOS outerState = thePropagatorOp->propagate(
0119             innerUpdated, tracker->idToDet((*(HitPairs[is].outer())).geographicalId())->surface());
0120         if (outerState.isValid()) {
0121           LogDebug("CosmicSeedFinder") << "outerState " << outerState;
0122           TSOS outerUpdated = theUpdator->update(outerState, *outrhit);
0123           //fudge factor for multiple scattering
0124           outerUpdated.rescaleError(multipleScatteringFactor);
0125           if (outerUpdated.isValid()) {
0126             LogDebug("CosmicSeedFinder") << "outerUpdated " << outerUpdated;
0127             PTrajectoryStateOnDet PTraj = trajectoryStateTransform::persistentState(
0128                 outerUpdated, (*(HitPairs[is].outer())).geographicalId().rawId());
0129             output.push_back(TrajectorySeed(PTraj, hits, oppositeToMomentum));
0130 
0131           } else
0132             edm::LogWarning("CosmicSeedFinder") << " SeedForCosmics first update failed ";
0133         } else
0134           edm::LogWarning("CosmicSeedFinder") << " SeedForCosmics first propagation failed ";
0135       }
0136     }
0137   }
0138 }