CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/RecoPixelVertexing/PixelTriplets/src/CosmicHitTripletGeneratorFromLayerTriplet.cc

Go to the documentation of this file.
00001 #include "RecoPixelVertexing/PixelTriplets/interface/CosmicHitTripletGeneratorFromLayerTriplet.h"
00002 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegion.h"
00003 #include "TrackingTools/DetLayers/interface/DetLayer.h"
00004 #include "RecoPixelVertexing/PixelTriplets/interface/OrderedHitTriplets.h"
00005 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007 #include "TrackingTools/DetLayers/interface/BarrelDetLayer.h"
00008 #include "FWCore/Framework/interface/ESHandle.h"
00009 #include "RecoTracker/TransientTrackingRecHit/interface/TkTransientTrackingRecHitBuilder.h"
00010 #include "TrackingTools/Records/interface/TransientRecHitRecord.h"
00011 
00012 #include <cmath>
00013 
00014 typedef TransientTrackingRecHit::ConstRecHitPointer TkHitPairsCachedHit;
00015 
00016 CosmicHitTripletGeneratorFromLayerTriplet::CosmicHitTripletGeneratorFromLayerTriplet
00017 (const LayerWithHits* inner, 
00018  const LayerWithHits* middle, 
00019  const LayerWithHits* outer,
00020  const edm::EventSetup& iSetup)
00021   : TTRHbuilder(0),trackerGeometry(0),
00022     //theLayerCache(*layerCache), 
00023     theOuterLayer(outer),theMiddleLayer(middle), theInnerLayer(inner)
00024 {
00025 
00026   edm::ESHandle<TrackerGeometry> tracker;
00027   iSetup.get<TrackerDigiGeometryRecord>().get(tracker);
00028   trackerGeometry = tracker.product();
00029 }
00030 void CosmicHitTripletGeneratorFromLayerTriplet::hitTriplets(
00031   const TrackingRegion & region, OrderedHitTriplets & result,
00032   const edm::EventSetup& iSetup)
00033 {
00034   
00035   if (theInnerLayer->recHits().empty()) return;
00036   if (theMiddleLayer->recHits().empty()) return;
00037   if (theOuterLayer->recHits().empty()) return;
00038   float radius1 =dynamic_cast<const BarrelDetLayer*>(theInnerLayer->layer())->specificSurface().radius();
00039   float radius2 =dynamic_cast<const BarrelDetLayer*>(theMiddleLayer->layer())->specificSurface().radius();
00040   float radius3 =dynamic_cast<const BarrelDetLayer*>(theOuterLayer->layer())->specificSurface().radius();
00041   bool seedfromoverlaps=((std::abs(radius1-radius2)<0.1)|| (std::abs(radius3-radius2)<0.1))? true : false;
00042   std::vector<const TrackingRecHit*>::const_iterator ohh;
00043   std::vector<const TrackingRecHit*>::const_iterator mhh;
00044   std::vector<const TrackingRecHit*>::const_iterator ihh;
00045 
00046   std::string builderName = "WithTrackAngle";
00047   edm::ESHandle<TransientTrackingRecHitBuilder> builder;
00048   iSetup.get<TransientRecHitRecord>().get(builderName, builder);
00049 
00050   if(!seedfromoverlaps){
00051     for(ohh=theOuterLayer->recHits().begin();ohh!=theOuterLayer->recHits().end();ohh++){
00052       TkHitPairsCachedHit oh= builder->build(*ohh);
00053       for(mhh=theMiddleLayer->recHits().begin();mhh!=theMiddleLayer->recHits().end();mhh++){
00054         TkHitPairsCachedHit mh=  builder->build(*mhh);
00055         float z_diff =mh->globalPosition().z()-oh->globalPosition().z();
00056         float midy=mh->globalPosition().y();
00057         float outy=oh->globalPosition().y();
00058         float midx=mh->globalPosition().x();
00059         float outx=oh->globalPosition().x();
00060         float dxdy=std::abs((outx-midx)/(outy-midy));
00061         if((std::abs(z_diff)<30) && (outy*midy>0) &&(dxdy<2))     
00062           {
00063             for(ihh=theInnerLayer->recHits().begin();ihh!=theInnerLayer->recHits().end();ihh++){
00064               TkHitPairsCachedHit ih= builder->build(*ihh);
00065               float z_diff =mh->globalPosition().z()-ih->globalPosition().z();
00066               float inny=ih->globalPosition().y();
00067               float innx=ih->globalPosition().x();
00068               float dxdy=std::abs((innx-midx)/(inny-midy));
00069               if ((std::abs(z_diff)<30) && (inny*midy>0) &&(dxdy<2)&&(!seedfromoverlaps))
00070                 {
00071                   result.push_back( OrderedHitTriplet(ih,mh,oh) );
00072                 }
00073             } 
00074           }
00075       }
00076     }
00077   } else {
00078     for(ohh=theOuterLayer->recHits().begin();ohh!=theOuterLayer->recHits().end();ohh++){
00079       TkHitPairsCachedHit oh= builder->build(*ohh);
00080       for(mhh=theMiddleLayer->recHits().begin();mhh!=theMiddleLayer->recHits().end();mhh++){
00081         TkHitPairsCachedHit mh= builder->build(*mhh);
00082         float z_diff =mh->globalPosition().z()-oh->globalPosition().z();
00083         float midy=mh->globalPosition().y();
00084         float outy=oh->globalPosition().y();
00085         float midx=mh->globalPosition().x();
00086         float outx=oh->globalPosition().x();
00087         float dxdy=std::abs((outx-midx)/(outy-midy));
00088         float DeltaR=oh->globalPosition().perp()-mh->globalPosition().perp();
00089         if((std::abs(z_diff)<18) && (std::abs(oh->globalPosition().phi()-mh->globalPosition().phi())<0.05) &&(DeltaR<0)&&(dxdy<2)){
00090           for(ihh=theInnerLayer->recHits().begin();ihh!=theInnerLayer->recHits().end();ihh++){
00091             TkHitPairsCachedHit ih= builder->build(*ihh);
00092             float z_diff =mh->globalPosition().z()-ih->globalPosition().z();
00093             float inny=ih->globalPosition().y();
00094             float innx=ih->globalPosition().x();
00095             float dxdy=std::abs((innx-midx)/(inny-midy));
00096             if ((std::abs(z_diff)<30) && (inny*midy>0) &&(dxdy<2))
00097               {
00098                 result.push_back( OrderedHitTriplet(ih,mh,oh));
00099               }
00100           }
00101         }
00102       }
00103     }
00104   }
00105 }
00106