CMS 3D CMS Logo

CosmicHitPairGeneratorFromLayerPair.cc

Go to the documentation of this file.
00001 #include "RecoTracker/TkHitPairs/interface/CosmicHitPairGeneratorFromLayerPair.h"
00002 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegion.h"
00003 #include "TrackingTools/DetLayers/interface/DetLayer.h"
00004 #include "RecoTracker/TkHitPairs/interface/OrderedHitPairs.h"
00005 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007 #include "TrackingTools/DetLayers/interface/BarrelDetLayer.h"
00008 
00009 using namespace std;
00010 typedef ctfseeding::SeedingHit TkHitPairsCachedHit;
00011 
00012 CosmicHitPairGeneratorFromLayerPair::CosmicHitPairGeneratorFromLayerPair(const LayerWithHits* inner, 
00013                                                              const LayerWithHits* outer, 
00014                                                                          //                                                          LayerCacheType* layerCache, 
00015                                                              const edm::EventSetup& iSetup)
00016   : TTRHbuilder(0),trackerGeometry(0),
00017     //theLayerCache(*layerCache), 
00018     theOuterLayer(outer), theInnerLayer(inner)
00019 {
00020 
00021   edm::ESHandle<TrackerGeometry> tracker;
00022   iSetup.get<TrackerDigiGeometryRecord>().get(tracker);
00023   trackerGeometry = tracker.product();
00024 }
00025 void CosmicHitPairGeneratorFromLayerPair::hitPairs(
00026   const TrackingRegion & region, OrderedHitPairs & result,
00027   const edm::EventSetup& iSetup)
00028 {
00029 //  static int NSee = 0; static int Ntry = 0; static int Nacc = 0;
00030 
00031 
00032   typedef OrderedHitPair::InnerHit InnerHit;
00033   typedef OrderedHitPair::OuterHit OuterHit;
00034 
00035 
00036   if (theInnerLayer->recHits().empty()) return;
00037 
00038   if (theOuterLayer->recHits().empty()) return;
00039   //  const DetLayer* innerlay=theOuterLayer->layer();
00040   // const BarrelDetLayer *pippo=dynamic_cast<const BarrelDetLayer*>(theOuterLayer->layer());
00041 
00042 
00043   // ************ Daniele
00044 
00045   const DetLayer* blay1;
00046   const DetLayer* blay2;
00047   blay1 = dynamic_cast<const BarrelDetLayer*>(theInnerLayer->layer());
00048   blay2 = dynamic_cast<const BarrelDetLayer*>(theOuterLayer->layer());
00049 
00050 
00051   bool seedfromoverlaps= false;
00052   bool InTheBarrel = false;
00053   bool InTheForward = false;
00054   if (blay1 && blay2) {
00055     InTheBarrel = true;
00056   }
00057   else  InTheForward = true;
00058 
00059   if (InTheBarrel){
00060     float radius1 =dynamic_cast<const BarrelDetLayer*>(theInnerLayer->layer())->specificSurface().radius();
00061     float radius2 =dynamic_cast<const BarrelDetLayer*>(theOuterLayer->layer())->specificSurface().radius();
00062      seedfromoverlaps=(abs(radius1-radius2)<0.1) ? true : false;
00063   }
00064 
00065  
00066   vector<OrderedHitPair> allthepairs;
00067   
00068 
00069 
00070   std::vector<const TrackingRecHit*>::const_iterator ohh;
00071   for(ohh=theOuterLayer->recHits().begin();ohh!=theOuterLayer->recHits().end();ohh++){
00072     const TkHitPairsCachedHit * oh=new TkHitPairsCachedHit(*ohh,iSetup);
00073     std::vector<const TrackingRecHit*>::const_iterator ihh;
00074     for(ihh=theInnerLayer->recHits().begin();ihh!=theInnerLayer->recHits().end();ihh++){
00075       const TkHitPairsCachedHit * ih=new TkHitPairsCachedHit(*ihh,iSetup);
00076       
00077       float z_diff =ih->z()-oh->z();
00078       float inny=ih->r()*sin(ih->phi());
00079       float outy=oh->r()*sin(oh->phi());
00080       float innx=ih->r()*cos(ih->phi());
00081       float outx=oh->r()*cos(oh->phi());
00082       float dxdy=abs((outx-innx)/(outy-inny));
00083       float DeltaR=oh->r()-ih->r();
00084       
00085       if( InTheBarrel && (abs(z_diff)<30) // && (outy > 0.) && (inny > 0.)
00086           //&&((abs(inny-outy))<30) 
00087           &&(dxdy<2)
00088           &&(inny*outy>0)
00089           && (abs(DeltaR)>0)) {
00090 
00091         //      cout << " ******** sono dentro inthebarrel *********** " << endl;
00092         if (seedfromoverlaps){
00093           //this part of code works for MTCC
00094           // for the other geometries must be verified
00095           //Overlaps in the difference in z is decreased and the difference in phi is
00096           //less than 0.05
00097           if ((DeltaR<0)&&(abs(z_diff)<18)&&(abs(ih->phi()-oh->phi())<0.05)&&(dxdy<2)) result.push_back( OrderedHitPair(*ih, *oh));
00098         }
00099         else  result.push_back( OrderedHitPair(*ih, *oh));
00100       
00101         
00102 
00103 
00104       }
00105       if( InTheForward &&  (abs(z_diff) > 1.)) {
00106         //      cout << " ******** sono dentro intheforward *********** " << endl;
00107         result.push_back( OrderedHitPair(*ih, *oh));
00108       }
00109 delete ih;
00110     }
00111 delete oh;
00112   }
00113 
00114  
00115 //   stable_sort(allthepairs.begin(),allthepairs.end(),CompareHitPairsY(iSetup));
00116 //   //Seed from overlaps are saved only if 
00117 //   //no others have been saved
00118 
00119 //   if (allthepairs.size()>0) {
00120 //     if (seedfromoverlaps) {
00121 //       if (result.size()==0) result.push_back(allthepairs[0]);
00122 //     }
00123 //     else result.push_back(allthepairs[0]);
00124 //   }
00125 
00126 }
00127 

Generated on Tue Jun 9 17:45:50 2009 for CMSSW by  doxygen 1.5.4