CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoTracker/SpecialSeedGenerators/src/SeedGeneratorForCRack.cc

Go to the documentation of this file.
00001 #include "RecoTracker/SpecialSeedGenerators/interface/SeedGeneratorForCRack.h"
00002 #include "RecoTracker/TkHitPairs/interface/CosmicLayerPairs.h"
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 #include "TrackingTools/Records/interface/TransientRecHitRecord.h" 
00005 void 
00006 SeedGeneratorForCRack::init(const SiStripRecHit2DCollection &collstereo,
00007                               const SiStripRecHit2DCollection &collrphi ,
00008                               const SiStripMatchedRecHit2DCollection &collmatched,
00009                               const edm::EventSetup& iSetup)
00010 {
00011   iSetup.get<IdealMagneticFieldRecord>().get(magfield);
00012   iSetup.get<TrackerDigiGeometryRecord>().get(tracker);
00013   thePropagatorAl=    new PropagatorWithMaterial(alongMomentum,0.1057,&(*magfield) );
00014   thePropagatorOp=    new PropagatorWithMaterial(oppositeToMomentum,0.1057,&(*magfield) );
00015   theUpdator=         new KFUpdator();
00016   
00017   // get the transient builder
00018 
00019   edm::ESHandle<TransientTrackingRecHitBuilder> theBuilder;
00020 
00021   iSetup.get<TransientRecHitRecord>().get(builderName,theBuilder);
00022   TTTRHBuilder = theBuilder.product();
00023   CosmicLayerPairs cosmiclayers(geometry);
00024   cosmiclayers.init(collstereo,collrphi,collmatched,iSetup);
00025   thePairGenerator=new CosmicHitPairGenerator(cosmiclayers,iSetup);
00026   HitPairs.clear();
00027   thePairGenerator->hitPairs(region,HitPairs,iSetup);
00028   LogDebug("CosmicSeedFinder") <<"Initialized with " << HitPairs.size() << " hit pairs" << std::endl;
00029 }
00030 
00031 SeedGeneratorForCRack::SeedGeneratorForCRack(edm::ParameterSet const& conf):
00032   conf_(conf)
00033 {  
00034   float ptmin=conf_.getParameter<double>("ptMin");
00035   float originradius=conf_.getParameter<double>("originRadius");
00036   float halflength=conf_.getParameter<double>("originHalfLength");
00037   float originz=conf_.getParameter<double>("originZPosition");
00038   seedpt = conf_.getParameter<double>("SeedPt");
00039 
00040   builderName = conf_.getParameter<std::string>("TTRHBuilder");   
00041   geometry=conf_.getUntrackedParameter<std::string>("GeometricStructure","STANDARD");
00042   region=GlobalTrackingRegion(ptmin,originradius,
00043                               halflength,originz);
00044   multipleScatteringFactor=conf_.getUntrackedParameter<double>("multipleScatteringFactor", 1.0);
00045   seedMomentum =conf_.getUntrackedParameter<double>("SeedMomentum",1);
00046   edm::LogInfo("SeedGeneratorForCRack")<<" PtMin of track is "<<ptmin<< 
00047     " The Radius of the cylinder for seeds is "<<originradius <<"cm"  << " The set Seed Momentum" <<  seedpt;
00048 }
00049 
00050 void SeedGeneratorForCRack::run(TrajectorySeedCollection &output,const edm::EventSetup& iSetup){
00051   seeds(output,iSetup,region);
00052   delete thePairGenerator;
00053   delete thePropagatorAl;
00054   delete thePropagatorOp;
00055   delete theUpdator; 
00056 }
00057 
00058 void SeedGeneratorForCRack::seeds(TrajectorySeedCollection &output,
00059                                     const edm::EventSetup& iSetup,
00060                                     const TrackingRegion& region){
00061   for(unsigned int is=0;is<HitPairs.size();is++){
00062 
00063     GlobalPoint inner = tracker->idToDet((*(HitPairs[is].inner())).geographicalId())->surface().toGlobal((*(HitPairs[is].inner())).localPosition());
00064     GlobalPoint outer = tracker->idToDet((*(HitPairs[is].outer())).geographicalId())->surface().toGlobal((*(HitPairs[is].outer())).localPosition());
00065     
00066     LogDebug("CosmicSeedFinder") <<"inner point of the seed "<<inner <<" outer point of the seed "<<outer; 
00067     TransientTrackingRecHit::ConstRecHitPointer inrhit=TTTRHBuilder->build(HitPairs[is].inner()->hit());
00068     TransientTrackingRecHit::ConstRecHitPointer outrhit = TTTRHBuilder->build(HitPairs[is].outer()->hit());
00069 
00070     edm::OwnVector<TrackingRecHit> hits;
00071     hits.push_back(HitPairs[is].outer()->hit()->clone());
00072 
00073     for (int i=0;i<2;i++){
00074       //FIRST STATE IS CALCULATED CONSIDERING THAT THE CHARGE CAN BE POSITIVE OR NEGATIVE
00075       int predsign=(2*i)-1;
00076       if((outer.y()-inner.y())>0){
00077         GlobalVector momentum = GlobalVector(inner-outer);
00078         momentum = momentum.unit()*seedMomentum;
00079         GlobalTrajectoryParameters Gtp(inner,
00080                                        momentum,
00081                                        predsign, 
00082                                        &(*magfield));
00083         AlgebraicSymMatrix55 errMatrix = ROOT::Math::SMatrixIdentity();
00084         TSOS innerState = TSOS(Gtp, CurvilinearTrajectoryError(errMatrix), tracker->idToDet((HitPairs[is].inner()->hit())->geographicalId())->surface());
00085         const TSOS innerUpdated = theUpdator->update(innerState, *inrhit);
00086         //Cosmic Seed update inner...
00087         LogDebug("CosmicSeedFinder") << " FirstTSOS " << innerUpdated;
00088         
00089         //First propagation
00090         const TSOS outerState =
00091           thePropagatorOp->propagate(innerUpdated,
00092                                      tracker->idToDet((*(HitPairs[is].outer())).geographicalId())->surface());
00093         if ( outerState.isValid()) {
00094           LogDebug("CosmicSeedFinder") <<"outerState "<<outerState;
00095           TSOS outerUpdated= theUpdator->update( outerState,*outrhit);
00096           //fudge factor for multiple scattering
00097           outerUpdated.rescaleError( multipleScatteringFactor);
00098           if ( outerUpdated.isValid()) {
00099             LogDebug("CosmicSeedFinder") <<"outerUpdated "<<outerUpdated;
00100             
00101             PTrajectoryStateOnDet *PTraj=  
00102               transformer.persistentState(outerUpdated, (*(HitPairs[is].outer())).geographicalId().rawId());
00103             output.push_back(TrajectorySeed(*PTraj,hits,alongMomentum));
00104             delete PTraj;
00105             
00106           }else      edm::LogWarning("CosmicSeedFinder") << " SeedForCosmics first update failed ";
00107         }else      edm::LogWarning("CosmicSeedFinder") << " SeedForCosmics first propagation failed ";
00108       
00109       
00110       }
00111       else{
00112         GlobalVector momentum= GlobalVector(outer-inner);
00113         momentum=momentum.unit()*seedMomentum;
00114         GlobalTrajectoryParameters Gtp(inner,
00115                                        momentum,
00116                                        predsign, 
00117                                        &(*magfield));
00118         AlgebraicSymMatrix55 errMatrix = ROOT::Math::SMatrixIdentity();
00119         TSOS innerState = TSOS(Gtp, CurvilinearTrajectoryError(errMatrix), tracker->idToDet((HitPairs[is].inner()->hit())->geographicalId())->surface());
00120         const TSOS innerUpdated = theUpdator->update(innerState, *inrhit);
00121         LogDebug("CosmicSeedFinder") << " FirstTSOS "<< innerState;
00122         
00123         //First propagation
00124         const TSOS outerState =
00125           thePropagatorOp->propagate(innerUpdated,
00126                                      tracker->idToDet((*(HitPairs[is].outer())).geographicalId())->surface());
00127         if ( outerState.isValid()) {
00128           
00129           LogDebug("CosmicSeedFinder") <<"outerState "<<outerState;
00130           TSOS outerUpdated = theUpdator->update( outerState,*outrhit);
00131           //fudge factor for multiple scattering
00132           outerUpdated.rescaleError( multipleScatteringFactor);
00133           if ( outerUpdated.isValid()) {
00134           LogDebug("CosmicSeedFinder") <<"outerUpdated "<<outerUpdated;
00135           PTrajectoryStateOnDet *PTraj=  
00136             transformer.persistentState(outerUpdated,(*(HitPairs[is].outer())).geographicalId().rawId());
00137           output.push_back(TrajectorySeed(*PTraj,hits,oppositeToMomentum));
00138           delete PTraj;
00139         
00140           }else      edm::LogWarning("CosmicSeedFinder") << " SeedForCosmics first update failed ";
00141         }else      edm::LogWarning("CosmicSeedFinder") << " SeedForCosmics first propagation failed ";
00142       }
00143     }
00144   }
00145 }
00146