CMS 3D CMS Logo

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