00001
00009
00010
00011 #include "FastSimDataFormats/External/interface/FastTrackerCluster.h"
00012
00013
00014 #include "FastSimulation/TrackingRecHitProducer/interface/SiTrackerGaussianSmearingRecHitConverter.h"
00015
00016
00017 #include "FastSimulation/TrackingRecHitProducer/interface/SiPixelGaussianSmearingRecHitConverterAlgorithm.h"
00018
00019
00020 #include "FastSimulation/TrackingRecHitProducer/interface/SiStripGaussianSmearingRecHitConverterAlgorithm.h"
00021
00022
00023 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00024 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00025 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00026 #include "Geometry/TrackerGeometryBuilder/interface/GluedGeomDet.h"
00027 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
00028 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00029 #include "MagneticField/Engine/interface/MagneticField.h"
00030
00031
00032 #include "DataFormats/Common/interface/Handle.h"
00033 #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
00034
00035
00036 #include "FWCore/Framework/interface/ESHandle.h"
00037 #include "FWCore/Framework/interface/Event.h"
00038 #include "FWCore/Framework/interface/EventSetup.h"
00039 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00040 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00041 #include "FWCore/ServiceRegistry/interface/Service.h"
00042 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
00043 #include "FWCore/Utilities/interface/Exception.h"
00044
00045
00046 #include "DataFormats/SiPixelDetId/interface/PXBDetId.h"
00047 #include "DataFormats/SiPixelDetId/interface/PXFDetId.h"
00048 #include "DataFormats/SiStripDetId/interface/TIBDetId.h"
00049 #include "DataFormats/SiStripDetId/interface/TIDDetId.h"
00050 #include "DataFormats/SiStripDetId/interface/TOBDetId.h"
00051 #include "DataFormats/SiStripDetId/interface/TECDetId.h"
00052 #include "DataFormats/GeometryCommonDetAlgo/interface/ErrorFrameTransformer.h"
00053 #include "DataFormats/TrackingRecHit/interface/AlignmentPositionError.h"
00054
00055
00056 #include "SimDataFormats/EncodedEventId/interface/EncodedEventId.h"
00057
00058
00059 #include "FastSimulation/Utilities/interface/RandomEngine.h"
00060
00061
00062
00063
00064 #include "FastSimulation/TrackingRecHitProducer/interface/GSRecHitMatcher.h"
00065
00066
00067 #include <memory>
00068
00069
00070 #include <TFile.h>
00071 #include <TH1F.h>
00072
00073
00074
00075 SiTrackerGaussianSmearingRecHitConverter::SiTrackerGaussianSmearingRecHitConverter(
00076 edm::ParameterSet const& conf)
00077 : pset_(conf)
00078 {
00079 thePixelDataFile = 0;
00080 thePixelBarrelResolutionFile = 0;
00081 thePixelForwardResolutionFile = 0;
00082 thePixelBarrelParametrization = 0;
00083 thePixelEndcapParametrization = 0;
00084 theSiStripErrorParametrization = 0;
00085
00086 random = 0;
00087
00088
00089 #ifdef FAMOS_DEBUG
00090 std::cout << "SiTrackerGaussianSmearingRecHitConverter instantiated" << std::endl;
00091 #endif
00092
00093
00094 edm::Service<edm::RandomNumberGenerator> rng;
00095 if ( ! rng.isAvailable() ) {
00096 throw cms::Exception("Configuration")
00097 << "SiTrackerGaussianSmearingRecHitConverter requires the RandomGeneratorService\n"
00098 "which is not present in the configuration file.\n"
00099 "You must add the service in the configuration file\n"
00100 "or remove the module that requires it";
00101 }
00102
00103 random = new RandomEngine(&(*rng));
00104
00105 produces<FastTrackerClusterCollection>("TrackerClusters");
00106
00107 produces<SiTrackerGSRecHit2DCollection>("TrackerGSRecHits");
00108 produces<SiTrackerGSMatchedRecHit2DCollection>("TrackerGSMatchedRecHits");
00109
00110
00111 trackerContainers.clear();
00112 trackerContainers = conf.getParameter<std::vector<edm::InputTag> >("ROUList");
00113
00114 deltaRaysPCut = conf.getParameter<double>("DeltaRaysMomentumCut");
00115
00116
00117 trackingPSimHits = conf.getParameter<bool>("trackingPSimHits");
00118 if(trackingPSimHits) std::cout << "### trackingPSimHits chosen " << trackingPSimHits << std::endl;
00119
00120
00121 doMatching = conf.getParameter<bool>("doRecHitMatching");
00122
00123
00124 useCMSSWPixelParameterization = conf.getParameter<bool>("UseCMSSWPixelParametrization");
00125 #ifdef FAMOS_DEBUG
00126 std::cout << (useCMSSWPixelParameterization? "CMSSW" : "ORCA") << " pixel parametrization chosen in config file." << std::endl;
00127 #endif
00128
00129
00130 GevPerElectron = conf.getParameter<double>("GevPerElectron");
00131 ElectronsPerADC = conf.getParameter<double>("ElectronsPerADC");
00132
00133
00134
00135 localPositionResolution_TIB1x = conf.getParameter<double>("TIB1x");
00136 localPositionResolution_TIB1y = conf.getParameter<double>("TIB1y");
00137 localPositionResolution_TIB2x = conf.getParameter<double>("TIB2x");
00138 localPositionResolution_TIB2y = conf.getParameter<double>("TIB2y");
00139 localPositionResolution_TIB3x = conf.getParameter<double>("TIB3x");
00140 localPositionResolution_TIB3y = conf.getParameter<double>("TIB3y");
00141 localPositionResolution_TIB4x = conf.getParameter<double>("TIB4x");
00142 localPositionResolution_TIB4y = conf.getParameter<double>("TIB4y");
00143
00144
00145 localPositionResolution_TID1x = conf.getParameter<double>("TID1x");
00146 localPositionResolution_TID1y = conf.getParameter<double>("TID1y");
00147 localPositionResolution_TID2x = conf.getParameter<double>("TID2x");
00148 localPositionResolution_TID2y = conf.getParameter<double>("TID2y");
00149 localPositionResolution_TID3x = conf.getParameter<double>("TID3x");
00150 localPositionResolution_TID3y = conf.getParameter<double>("TID3y");
00151
00152
00153 localPositionResolution_TOB1x = conf.getParameter<double>("TOB1x");
00154 localPositionResolution_TOB1y = conf.getParameter<double>("TOB1y");
00155 localPositionResolution_TOB2x = conf.getParameter<double>("TOB2x");
00156 localPositionResolution_TOB2y = conf.getParameter<double>("TOB2y");
00157 localPositionResolution_TOB3x = conf.getParameter<double>("TOB3x");
00158 localPositionResolution_TOB3y = conf.getParameter<double>("TOB3y");
00159 localPositionResolution_TOB4x = conf.getParameter<double>("TOB4x");
00160 localPositionResolution_TOB4y = conf.getParameter<double>("TOB4y");
00161 localPositionResolution_TOB5x = conf.getParameter<double>("TOB5x");
00162 localPositionResolution_TOB5y = conf.getParameter<double>("TOB5y");
00163 localPositionResolution_TOB6x = conf.getParameter<double>("TOB6x");
00164 localPositionResolution_TOB6y = conf.getParameter<double>("TOB6y");
00165
00166
00167 localPositionResolution_TEC1x = conf.getParameter<double>("TEC1x");
00168 localPositionResolution_TEC1y = conf.getParameter<double>("TEC1y");
00169 localPositionResolution_TEC2x = conf.getParameter<double>("TEC2x");
00170 localPositionResolution_TEC2y = conf.getParameter<double>("TEC2y");
00171 localPositionResolution_TEC3x = conf.getParameter<double>("TEC3x");
00172 localPositionResolution_TEC3y = conf.getParameter<double>("TEC3y");
00173 localPositionResolution_TEC4x = conf.getParameter<double>("TEC4x");
00174 localPositionResolution_TEC4y = conf.getParameter<double>("TEC4y");
00175 localPositionResolution_TEC5x = conf.getParameter<double>("TEC5x");
00176 localPositionResolution_TEC5y = conf.getParameter<double>("TEC5y");
00177 localPositionResolution_TEC6x = conf.getParameter<double>("TEC6x");
00178 localPositionResolution_TEC6y = conf.getParameter<double>("TEC6y");
00179 localPositionResolution_TEC7x = conf.getParameter<double>("TEC7x");
00180 localPositionResolution_TEC7y = conf.getParameter<double>("TEC7y");
00181
00182 localPositionResolution_z = 0.0001;
00183
00184 #ifdef FAMOS_DEBUG
00185 std::cout << "RecHit local position error set to" << "\n"
00186 << "\tTIB1\tx = " << localPositionResolution_TIB1x
00187 << " cm\ty = " << localPositionResolution_TIB1y << " cm" << "\n"
00188 << "\tTIB2\tx = " << localPositionResolution_TIB2x
00189 << " cm\ty = " << localPositionResolution_TIB2y << " cm" << "\n"
00190 << "\tTIB3\tx = " << localPositionResolution_TIB3x
00191 << " cm\ty = " << localPositionResolution_TIB3y << " cm" << "\n"
00192 << "\tTIB4\tx = " << localPositionResolution_TIB4x
00193 << " cm\ty = " << localPositionResolution_TIB4y << " cm" << "\n"
00194 << "\tTID1\tx = " << localPositionResolution_TID1x
00195 << " cm\ty = " << localPositionResolution_TID1y << " cm" << "\n"
00196 << "\tTID2\tx = " << localPositionResolution_TID2x
00197 << " cm\ty = " << localPositionResolution_TID2y << " cm" << "\n"
00198 << "\tTID3\tx = " << localPositionResolution_TID3x
00199 << " cm\ty = " << localPositionResolution_TID3y << " cm" << "\n"
00200 << "\tTOB1\tx = " << localPositionResolution_TOB1x
00201 << " cm\ty = " << localPositionResolution_TOB1y << " cm" << "\n"
00202 << "\tTOB2\tx = " << localPositionResolution_TOB2x
00203 << " cm\ty = " << localPositionResolution_TOB2y << " cm" << "\n"
00204 << "\tTOB3\tx = " << localPositionResolution_TOB3x
00205 << " cm\ty = " << localPositionResolution_TOB3y << " cm" << "\n"
00206 << "\tTOB4\tx = " << localPositionResolution_TOB4x
00207 << " cm\ty = " << localPositionResolution_TOB4y << " cm" << "\n"
00208 << "\tTOB5\tx = " << localPositionResolution_TOB5x
00209 << " cm\ty = " << localPositionResolution_TOB5y << " cm" << "\n"
00210 << "\tTOB6\tx = " << localPositionResolution_TOB6x
00211 << " cm\ty = " << localPositionResolution_TOB6y << " cm" << "\n"
00212 << "\tTEC1\tx = " << localPositionResolution_TEC1x
00213 << " cm\ty = " << localPositionResolution_TEC1y << " cm" << "\n"
00214 << "\tTEC2\tx = " << localPositionResolution_TEC2x
00215 << " cm\ty = " << localPositionResolution_TEC2y << " cm" << "\n"
00216 << "\tTEC3\tx = " << localPositionResolution_TEC3x
00217 << " cm\ty = " << localPositionResolution_TEC3y << " cm" << "\n"
00218 << "\tTEC4\tx = " << localPositionResolution_TEC4x
00219 << " cm\ty = " << localPositionResolution_TEC4y << " cm" << "\n"
00220 << "\tTEC5\tx = " << localPositionResolution_TEC5x
00221 << " cm\ty = " << localPositionResolution_TEC5y << " cm" << "\n"
00222 << "\tTEC6\tx = " << localPositionResolution_TEC6x
00223 << " cm\ty = " << localPositionResolution_TEC6y << " cm" << "\n"
00224 << "\tTEC7\tx = " << localPositionResolution_TEC7x
00225 << " cm\ty = " << localPositionResolution_TEC7y << " cm" << "\n"
00226 << "\tAll:\tz = " << localPositionResolution_z << " cm"
00227 << std::endl;
00228 #endif
00229
00230
00231 if(useCMSSWPixelParameterization) {
00232 nAlphaBarrel = conf.getParameter<int>("AlphaBarrelMultiplicityNew");
00233 nBetaBarrel = conf.getParameter<int>("BetaBarrelMultiplicityNew");
00234 nAlphaForward = conf.getParameter<int>("AlphaForwardMultiplicityNew");
00235 nBetaForward = conf.getParameter<int>("BetaForwardMultiplicityNew");
00236 } else {
00237 nAlphaBarrel = conf.getParameter<int>("AlphaBarrelMultiplicity");
00238 nBetaBarrel = conf.getParameter<int>("BetaBarrelMultiplicity");
00239 nAlphaForward = conf.getParameter<int>("AlphaForwardMultiplicity");
00240 nBetaForward = conf.getParameter<int>("BetaForwardMultiplicity");
00241 }
00242 #ifdef FAMOS_DEBUG
00243 std::cout << "Pixel maximum multiplicity set to "
00244 << "\nBarrel" << "\talpha " << nAlphaBarrel
00245 << "\tbeta " << nBetaBarrel
00246 << "\nForward" << "\talpha " << nAlphaForward
00247 << "\tbeta " << nBetaForward
00248 << std::endl;
00249 #endif
00250
00251
00252 if(useCMSSWPixelParameterization) {
00253 resAlphaBarrel_binMin = conf.getParameter<double>("AlphaBarrel_BinMinNew" );
00254 resAlphaBarrel_binWidth = conf.getParameter<double>("AlphaBarrel_BinWidthNew");
00255 resAlphaBarrel_binN = conf.getParameter<int>( "AlphaBarrel_BinNNew" );
00256 resBetaBarrel_binMin = conf.getParameter<double>("BetaBarrel_BinMinNew" );
00257 resBetaBarrel_binWidth = conf.getParameter<double>("BetaBarrel_BinWidthNew" );
00258 resBetaBarrel_binN = conf.getParameter<int>( "BetaBarrel_BinNNew" );
00259 } else {
00260 resAlphaBarrel_binMin = conf.getParameter<double>("AlphaBarrel_BinMin" );
00261 resAlphaBarrel_binWidth = conf.getParameter<double>("AlphaBarrel_BinWidth");
00262 resAlphaBarrel_binN = conf.getParameter<int>( "AlphaBarrel_BinN" );
00263 resBetaBarrel_binMin = conf.getParameter<double>("BetaBarrel_BinMin" );
00264 resBetaBarrel_binWidth = conf.getParameter<double>("BetaBarrel_BinWidth" );
00265 resBetaBarrel_binN = conf.getParameter<int>( "BetaBarrel_BinN" );
00266 }
00267
00268
00269 if(useCMSSWPixelParameterization) {
00270 resAlphaForward_binMin = conf.getParameter<double>("AlphaForward_BinMinNew" );
00271 resAlphaForward_binWidth = conf.getParameter<double>("AlphaForward_BinWidthNew" );
00272 resAlphaForward_binN = conf.getParameter<int>( "AlphaForward_BinNNew" );
00273 resBetaForward_binMin = conf.getParameter<double>("BetaForward_BinMinNew" );
00274 resBetaForward_binWidth = conf.getParameter<double>("BetaForward_BinWidthNew" );
00275 resBetaForward_binN = conf.getParameter<int>( "BetaForward_BinNNew" );
00276 } else {
00277 resAlphaForward_binMin = conf.getParameter<double>("AlphaForward_BinMin" );
00278 resAlphaForward_binWidth = conf.getParameter<double>("AlphaForward_BinWidth" );
00279 resAlphaForward_binN = conf.getParameter<int>( "AlphaForward_BinN" );
00280 resBetaForward_binMin = conf.getParameter<double>("BetaForward_BinMin" );
00281 resBetaForward_binWidth = conf.getParameter<double>("BetaForward_BinWidth" );
00282 resBetaForward_binN = conf.getParameter<int>( "BetaForward_BinN" );
00283 }
00284
00285
00286 theHitFindingProbability_PXB = conf.getParameter<double>("HitFindingProbability_PXB" );
00287 theHitFindingProbability_PXF = conf.getParameter<double>("HitFindingProbability_PXF" );
00288 theHitFindingProbability_TIB1 = conf.getParameter<double>("HitFindingProbability_TIB1");
00289 theHitFindingProbability_TIB2 = conf.getParameter<double>("HitFindingProbability_TIB2");
00290 theHitFindingProbability_TIB3 = conf.getParameter<double>("HitFindingProbability_TIB3");
00291 theHitFindingProbability_TIB4 = conf.getParameter<double>("HitFindingProbability_TIB4");
00292 theHitFindingProbability_TID1 = conf.getParameter<double>("HitFindingProbability_TID1");
00293 theHitFindingProbability_TID2 = conf.getParameter<double>("HitFindingProbability_TID2");
00294 theHitFindingProbability_TID3 = conf.getParameter<double>("HitFindingProbability_TID3");
00295 theHitFindingProbability_TOB1 = conf.getParameter<double>("HitFindingProbability_TOB1");
00296 theHitFindingProbability_TOB2 = conf.getParameter<double>("HitFindingProbability_TOB2");
00297 theHitFindingProbability_TOB3 = conf.getParameter<double>("HitFindingProbability_TOB3");
00298 theHitFindingProbability_TOB4 = conf.getParameter<double>("HitFindingProbability_TOB4");
00299 theHitFindingProbability_TOB5 = conf.getParameter<double>("HitFindingProbability_TOB5");
00300 theHitFindingProbability_TOB6 = conf.getParameter<double>("HitFindingProbability_TOB6");
00301 theHitFindingProbability_TEC1 = conf.getParameter<double>("HitFindingProbability_TEC1");
00302 theHitFindingProbability_TEC2 = conf.getParameter<double>("HitFindingProbability_TEC2");
00303 theHitFindingProbability_TEC3 = conf.getParameter<double>("HitFindingProbability_TEC3");
00304 theHitFindingProbability_TEC4 = conf.getParameter<double>("HitFindingProbability_TEC4");
00305 theHitFindingProbability_TEC5 = conf.getParameter<double>("HitFindingProbability_TEC5");
00306 theHitFindingProbability_TEC6 = conf.getParameter<double>("HitFindingProbability_TEC6");
00307 theHitFindingProbability_TEC7 = conf.getParameter<double>("HitFindingProbability_TEC7");
00308
00309 #ifdef FAMOS_DEBUG
00310 std::cout << "RecHit finding probability set to" << "\n"
00311 << "\tPXB = " << theHitFindingProbability_PXB << "\n"
00312 << "\tPXF = " << theHitFindingProbability_PXF << "\n"
00313 << "\tTIB1 = " << theHitFindingProbability_TIB1 << "\n"
00314 << "\tTIB2 = " << theHitFindingProbability_TIB2 << "\n"
00315 << "\tTIB3 = " << theHitFindingProbability_TIB3 << "\n"
00316 << "\tTIB4 = " << theHitFindingProbability_TIB4 << "\n"
00317 << "\tTID1 = " << theHitFindingProbability_TID1 << "\n"
00318 << "\tTID2 = " << theHitFindingProbability_TID2 << "\n"
00319 << "\tTID3 = " << theHitFindingProbability_TID3 << "\n"
00320 << "\tTOB1 = " << theHitFindingProbability_TOB1 << "\n"
00321 << "\tTOB2 = " << theHitFindingProbability_TOB2 << "\n"
00322 << "\tTOB3 = " << theHitFindingProbability_TOB3 << "\n"
00323 << "\tTOB4 = " << theHitFindingProbability_TOB4 << "\n"
00324 << "\tTOB5 = " << theHitFindingProbability_TOB5 << "\n"
00325 << "\tTOB6 = " << theHitFindingProbability_TOB6 << "\n"
00326 << "\tTEC1 = " << theHitFindingProbability_TEC1 << "\n"
00327 << "\tTEC2 = " << theHitFindingProbability_TEC2 << "\n"
00328 << "\tTEC3 = " << theHitFindingProbability_TEC3 << "\n"
00329 << "\tTEC4 = " << theHitFindingProbability_TEC4 << "\n"
00330 << "\tTEC5 = " << theHitFindingProbability_TEC5 << "\n"
00331 << "\tTEC6 = " << theHitFindingProbability_TEC6 << "\n"
00332 << "\tTEC7 = " << theHitFindingProbability_TEC7 << "\n"
00333 << std::endl;
00334 #endif
00335
00336
00337 theSiStripErrorParametrization =
00338 new SiStripGaussianSmearingRecHitConverterAlgorithm(random);
00339
00340
00341
00342 }
00343
00344 void SiTrackerGaussianSmearingRecHitConverter::loadPixelData() {
00345
00346
00347 thePixelDataFile = new TFile ( edm::FileInPath( thePixelMultiplicityFileName ).fullPath().c_str() , "READ" );
00348 thePixelBarrelResolutionFile = new TFile ( edm::FileInPath( thePixelBarrelResolutionFileName ).fullPath().c_str() , "READ" );
00349 thePixelForwardResolutionFile = new TFile ( edm::FileInPath( thePixelForwardResolutionFileName ).fullPath().c_str() , "READ" );
00350
00351
00352
00353 loadPixelData( thePixelDataFile,
00354 nAlphaBarrel ,
00355 std::string("hist_alpha_barrel") ,
00356 theBarrelMultiplicityAlphaCumulativeProbabilities );
00357
00358
00359 loadPixelData( thePixelDataFile,
00360 nBetaBarrel ,
00361 std::string("hist_beta_barrel") ,
00362 theBarrelMultiplicityBetaCumulativeProbabilities );
00363
00364
00365 loadPixelData( thePixelDataFile,
00366 nAlphaForward ,
00367 std::string("hist_alpha_forward") ,
00368 theForwardMultiplicityAlphaCumulativeProbabilities );
00369
00370
00371 loadPixelData( thePixelDataFile,
00372 nBetaForward ,
00373 std::string("hist_beta_forward") ,
00374 theForwardMultiplicityBetaCumulativeProbabilities );
00375
00376
00377
00378
00379
00380 if(useCMSSWPixelParameterization) {
00381
00382 loadPixelData( thePixelDataFile,
00383 nAlphaBarrel ,
00384 std::string("hist_alpha_barrel_big") ,
00385 theBarrelMultiplicityAlphaCumulativeProbabilities,
00386 true );
00387
00388
00389 loadPixelData( thePixelDataFile,
00390 nBetaBarrel ,
00391 std::string("hist_beta_barrel_big") ,
00392 theBarrelMultiplicityBetaCumulativeProbabilities,
00393 true );
00394
00395
00396 loadPixelData( thePixelDataFile,
00397 nAlphaForward ,
00398 std::string("hist_alpha_forward_big") ,
00399 theForwardMultiplicityAlphaCumulativeProbabilities,
00400 true );
00401
00402
00403 loadPixelData( thePixelDataFile,
00404 nBetaForward ,
00405 std::string("hist_beta_forward_big") ,
00406 theForwardMultiplicityBetaCumulativeProbabilities,
00407 true );
00408 }
00409
00410 }
00411
00412 void SiTrackerGaussianSmearingRecHitConverter::loadPixelData(
00413 TFile* pixelDataFile,
00414 unsigned int nMultiplicity,
00415 std::string histName,
00416 std::vector<TH1F*>& theMultiplicityCumulativeProbabilities,
00417 bool bigPixels)
00418 {
00419
00420 std::string histName_i = histName + "_%u";
00421 if(!bigPixels)
00422 theMultiplicityCumulativeProbabilities.clear();
00423
00424
00425
00426 for(unsigned int i = 0; i<nMultiplicity; ++i) {
00427 TH1F addHist = *((TH1F*) pixelDataFile->Get( Form( histName_i.c_str() ,i+1 )));
00428 if(i==0) {
00429 theMultiplicityCumulativeProbabilities.push_back( new TH1F(addHist) );
00430 } else {
00431 TH1F sumHist;
00432 if(bigPixels)
00433 sumHist = *(theMultiplicityCumulativeProbabilities[nMultiplicity+i-1]);
00434 else
00435 sumHist = *(theMultiplicityCumulativeProbabilities[i-1]);
00436 sumHist.Add(&addHist);
00437 theMultiplicityCumulativeProbabilities.push_back( new TH1F(sumHist) );
00438 }
00439 }
00440
00441
00442 #ifdef FAMOS_DEBUG
00443 const unsigned int maxMult = theMultiplicityCumulativeProbabilities.size();
00444 unsigned int iMult, multSize;
00445 if(useCMSSWPixelParameterization) {
00446 if(bigPixels) {
00447 iMult = maxMult / 2;
00448 multSize = maxMult ;
00449 } else {
00450 iMult = 0;
00451 multSize = maxMult;
00452 }
00453 } else {
00454 iMult = 0;
00455 multSize = maxMult ;
00456 }
00457 std::cout << " Multiplicity cumulated probability " << histName << std::endl;
00458 for(; iMult<multSize; ++iMult) {
00459 for(int iBin = 1; iBin<=theMultiplicityCumulativeProbabilities[iMult]->GetNbinsX(); ++iBin) {
00460 std::cout
00461 << " Multiplicity " << iMult+1
00462 << " bin " << iBin
00463 << " low edge = "
00464 << theMultiplicityCumulativeProbabilities[iMult]->GetBinLowEdge(iBin)
00465 << " prob = "
00466 << (theMultiplicityCumulativeProbabilities[iMult])->GetBinContent(iBin)
00467
00468 << std::endl;
00469 }
00470 }
00471 #endif
00472
00473 }
00474
00475
00476 SiTrackerGaussianSmearingRecHitConverter::~SiTrackerGaussianSmearingRecHitConverter() {
00477 theBarrelMultiplicityAlphaCumulativeProbabilities.clear();
00478 theBarrelMultiplicityBetaCumulativeProbabilities.clear();
00479 theForwardMultiplicityAlphaCumulativeProbabilities.clear();
00480 theForwardMultiplicityBetaCumulativeProbabilities.clear();
00481
00482 if(thePixelDataFile) delete thePixelDataFile;
00483 if(thePixelBarrelResolutionFile) delete thePixelBarrelResolutionFile;
00484 if(thePixelForwardResolutionFile) delete thePixelForwardResolutionFile;
00485 if(thePixelBarrelParametrization) delete thePixelBarrelParametrization;
00486 if(thePixelEndcapParametrization) delete thePixelEndcapParametrization;
00487 if(theSiStripErrorParametrization) delete theSiStripErrorParametrization;
00488
00489 if(random) delete random;
00490
00491 }
00492
00493 void
00494 SiTrackerGaussianSmearingRecHitConverter::beginRun(edm::Run & run, const edm::EventSetup & es)
00495 {
00496
00497
00498 edm::ESHandle<TrackerGeometry> theGeometry;
00499 es.get<TrackerDigiGeometryRecord> ().get (theGeometry);
00500 geometry = &(*theGeometry);
00501
00502 edm::ESHandle<TrackerGeometry> theMisAlignedGeometry;
00503 es.get<TrackerDigiGeometryRecord>().get("MisAligned",theMisAlignedGeometry);
00504 misAlignedGeometry = &(*theMisAlignedGeometry);
00505
00506 const MagneticField* magfield;
00507 edm::ESHandle<MagneticField> magField;
00508 es.get<IdealMagneticFieldRecord>().get(magField);
00509 magfield=&(*magField);
00510 GlobalPoint center(0.0, 0.0, 0.0);
00511 double magFieldAtCenter = magfield->inTesla(center).mag();
00512
00513
00514 if(useCMSSWPixelParameterization) {
00515 if(magFieldAtCenter > 3.9) {
00516 thePixelMultiplicityFileName = pset_.getParameter<std::string>( "PixelMultiplicityFile40T");
00517 thePixelBarrelResolutionFileName = pset_.getParameter<std::string>( "PixelBarrelResolutionFile40T");
00518 thePixelForwardResolutionFileName = pset_.getParameter<std::string>( "PixelForwardResolutionFile40T");
00519 } else {
00520 thePixelMultiplicityFileName = pset_.getParameter<std::string>( "PixelMultiplicityFile38T");
00521 thePixelBarrelResolutionFileName = pset_.getParameter<std::string>( "PixelBarrelResolutionFile38T");
00522 thePixelForwardResolutionFileName = pset_.getParameter<std::string>( "PixelForwardResolutionFile38T");
00523 }
00524 } else {
00525 thePixelMultiplicityFileName = pset_.getParameter<std::string>( "PixelMultiplicityFile" );
00526 thePixelBarrelResolutionFileName = pset_.getParameter<std::string>( "PixelBarrelResolutionFile");
00527 thePixelForwardResolutionFileName = pset_.getParameter<std::string>( "PixelForwardResolutionFile");
00528 }
00529
00530
00531 #ifdef FAMOS_DEBUG
00532 std::cout << "Pixel multiplicity data are taken from file " << thePixelMultiplicityFileName << std::endl;
00533
00534 std::cout << "Pixel maximum multiplicity set to "
00535 << "\nBarrel" << "\talpha " << nAlphaBarrel
00536 << "\tbeta " << nBetaBarrel
00537 << "\nForward" << "\talpha " << nAlphaForward
00538 << "\tbeta " << nBetaForward
00539 << std::endl;
00540
00541 std::cout << "Barrel Pixel resolution data are taken from file "
00542 << thePixelBarrelResolutionFileName << "\n"
00543 << "Alpha bin min = " << resAlphaBarrel_binMin
00544 << "\twidth = " << resAlphaBarrel_binWidth
00545 << "\tbins = " << resAlphaBarrel_binN
00546 << "\n"
00547 << " Beta bin min = " << resBetaBarrel_binMin
00548 << "\twidth = " << resBetaBarrel_binWidth
00549 << "\tbins = " << resBetaBarrel_binN
00550 << std::endl;
00551
00552 std::cout << "Forward Pixel resolution data are taken from file "
00553 << thePixelForwardResolutionFileName << "\n"
00554 << "Alpha bin min = " << resAlphaForward_binMin
00555 << "\twidth = " << resAlphaForward_binWidth
00556 << "\tbins = " << resAlphaForward_binN
00557 << "\n"
00558 << " Beta bin min = " << resBetaForward_binMin
00559 << "\twidth = " << resBetaForward_binWidth
00560 << "\tbins = " << resBetaForward_binN
00561 << std::endl;
00562 #endif
00563
00564
00565
00566
00567 loadPixelData();
00568
00569
00570
00571 thePixelBarrelParametrization =
00572 new SiPixelGaussianSmearingRecHitConverterAlgorithm(
00573 pset_,
00574 GeomDetEnumerators::PixelBarrel,
00575 theBarrelMultiplicityAlphaCumulativeProbabilities,
00576 theBarrelMultiplicityBetaCumulativeProbabilities,
00577 thePixelBarrelResolutionFile,
00578 random);
00579
00580 thePixelEndcapParametrization =
00581 new SiPixelGaussianSmearingRecHitConverterAlgorithm(
00582 pset_,
00583 GeomDetEnumerators::PixelEndcap,
00584 theForwardMultiplicityAlphaCumulativeProbabilities,
00585 theForwardMultiplicityBetaCumulativeProbabilities,
00586 thePixelForwardResolutionFile,
00587 random);
00588 }
00589
00590 void SiTrackerGaussianSmearingRecHitConverter::produce(edm::Event& e, const edm::EventSetup& es)
00591 {
00592
00593
00594 FastTrackerClusterRefProd = e.getRefBeforePut<FastTrackerClusterCollection>("TrackerClusters");
00595
00596
00597 edm::Handle<CrossingFrame<PSimHit> > cf_simhit;
00598 std::vector<const CrossingFrame<PSimHit> *> cf_simhitvec;
00599 for(uint32_t i=0; i<trackerContainers.size(); i++){
00600 e.getByLabel(trackerContainers[i], cf_simhit);
00601 cf_simhitvec.push_back(cf_simhit.product());
00602 }
00603 std::auto_ptr<MixCollection<PSimHit> > allTrackerHits(new MixCollection<PSimHit>(cf_simhitvec));
00604
00605
00606
00607
00608 std::map<unsigned, edm::OwnVector<SiTrackerGSRecHit2D> > temporaryRecHits;
00609 std::map<unsigned, edm::OwnVector<FastTrackerCluster> > theClusters ;
00610 smearHits( *allTrackerHits, temporaryRecHits, theClusters);
00611
00612
00613 std::map<unsigned, edm::OwnVector<SiTrackerGSMatchedRecHit2D> > temporaryMatchedRecHits ;
00614 if(doMatching) matchHits( temporaryRecHits, temporaryMatchedRecHits, *allTrackerHits);
00615
00616
00617 std::auto_ptr<SiTrackerGSRecHit2DCollection> recHitCollection(new SiTrackerGSRecHit2DCollection);
00618 std::auto_ptr<SiTrackerGSMatchedRecHit2DCollection> recHitCollectionMatched(new SiTrackerGSMatchedRecHit2DCollection);
00619 if(doMatching){
00620 loadMatchedRecHits(temporaryMatchedRecHits, *recHitCollectionMatched);
00621 loadRecHits(temporaryRecHits, *recHitCollection);
00622 }
00623 else {
00624
00625 loadRecHits(temporaryRecHits, *recHitCollection);
00626 }
00627
00628
00629
00630
00631 e.put(recHitCollection,"TrackerGSRecHits");
00632 e.put(recHitCollectionMatched,"TrackerGSMatchedRecHits");
00633
00634
00635 std::auto_ptr<FastTrackerClusterCollection> clusterCollection(new FastTrackerClusterCollection);
00636 loadClusters(theClusters, *clusterCollection);
00637 e.put(clusterCollection,"TrackerClusters");
00638 }
00639
00640
00641
00642 void SiTrackerGaussianSmearingRecHitConverter::smearHits(
00643 MixCollection<PSimHit>& input,
00644 std::map<unsigned, edm::OwnVector<SiTrackerGSRecHit2D> >& temporaryRecHits,
00645 std::map<unsigned, edm::OwnVector<FastTrackerCluster> >& theClusters)
00646 {
00647
00648 int numberOfPSimHits = 0;
00649
00650
00651 MixCollection<PSimHit>::iterator isim = input.begin();
00652 MixCollection<PSimHit>::iterator lastSimHit = input.end();
00653 correspondingSimHit.resize(input.size());
00654 Local3DPoint position;
00655 LocalError error;
00656 LocalError inflatedError;
00657
00658 int simHitCounter = -1;
00659 int recHitCounter = 0;
00660
00661
00662 for ( ; isim != lastSimHit; ++isim ) {
00663 ++simHitCounter;
00664 DetId det((*isim).detUnitId());
00665 unsigned trackID = (*isim).trackId();
00666 uint32_t eeID = (*isim).eventId().rawId();
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681 ++numberOfPSimHits;
00682
00683 unsigned int alphaMult = 0;
00684 unsigned int betaMult = 0;
00685 bool isCreated = gaussianSmearing(*isim, position, error, alphaMult, betaMult);
00686
00687
00688 unsigned int subdet = det.subdetId();
00689
00690
00691 if(isCreated) {
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729 if(doMatching && (subdet>2)){
00730 StripSubdetector specDetId=StripSubdetector(det);
00731 if( !specDetId.glued() ){
00732 position = Local3DPoint(position.x(),0.,0.);
00733 }
00734 }
00735 else{ if(subdet>2) position = Local3DPoint(position.x(),0.,0.); }
00736
00737
00738 const GeomDet* theMADet = misAlignedGeometry->idToDet(det);
00739 if ( theMADet->alignmentPositionError() != 0 ) {
00740 LocalError lape =
00741 ErrorFrameTransformer().transform ( theMADet->alignmentPositionError()->globalError(),
00742 theMADet->surface() );
00743 error = LocalError ( error.xx()+lape.xx(),
00744 error.xy()+lape.xy(),
00745 error.yy()+lape.yy() );
00746 }
00747
00748 float chargeADC = (*isim).energyLoss()/(GevPerElectron * ElectronsPerADC);
00749
00750
00751 theClusters[trackID].push_back(
00752 new FastTrackerCluster(position, error, det,
00753 simHitCounter, trackID,
00754 eeID,
00755
00756 chargeADC)
00757 );
00758
00759
00760
00761
00762
00763
00764 temporaryRecHits[trackID].push_back(
00765 new SiTrackerGSRecHit2D(position, error, det,
00766 simHitCounter, trackID,
00767 eeID,
00768 ClusterRef(FastTrackerClusterRefProd, simHitCounter),
00769 alphaMult, betaMult)
00770 );
00771
00772
00773
00774 correspondingSimHit[recHitCounter++] = isim;
00775
00776 }
00777
00778 }
00779
00780 }
00781
00782 bool SiTrackerGaussianSmearingRecHitConverter::gaussianSmearing(const PSimHit& simHit,
00783 Local3DPoint& position ,
00784 LocalError& error,
00785 unsigned& alphaMult,
00786 unsigned& betaMult)
00787 {
00788
00789
00790 unsigned int subdet = DetId(simHit.detUnitId()).subdetId();
00791 unsigned int detid = DetId(simHit.detUnitId()).rawId();
00792 const GeomDetUnit* theDetUnit = geometry->idToDetUnit((DetId)simHit.detUnitId());
00793 const BoundPlane& theDetPlane = theDetUnit->surface();
00794 const Bounds& theBounds = theDetPlane.bounds();
00795 double boundX = theBounds.width()/2.;
00796 double boundY = theBounds.length()/2.;
00797
00798 #ifdef FAMOS_DEBUG
00799 std::cout << "\tSubdetector " << subdet
00800 << " rawid " << detid
00801 << std::endl;
00802 #endif
00803 if(trackingPSimHits) {
00804
00805
00806 error = LocalError( localPositionResolution_z * localPositionResolution_z ,
00807 0.0 ,
00808 localPositionResolution_z * localPositionResolution_z );
00809
00810
00811 position = simHit.localPosition();
00812 #ifdef FAMOS_DEBUG
00813 std::cout << " Tracking PSimHit position set to " << position;
00814 #endif
00815 return true;
00816 }
00817
00818
00819
00820 double hitFindingProbability = random->flatShoot();
00821 #ifdef FAMOS_DEBUG
00822 std::cout << " Hit finding probability draw: " << hitFindingProbability << std::endl;;
00823 #endif
00824
00825 switch (subdet) {
00826
00827 case 1:
00828 {
00829 #ifdef FAMOS_DEBUG
00830 PXBDetId module(detid);
00831 unsigned int theLayer = module.layer();
00832 std::cout << "\tPixel Barrel Layer " << theLayer << std::endl;
00833 #endif
00834 if( hitFindingProbability > theHitFindingProbability_PXB ) return false;
00835
00836 const PixelGeomDetUnit* pixelDetUnit = dynamic_cast<const PixelGeomDetUnit*>(theDetUnit);
00837 thePixelBarrelParametrization->smearHit(simHit, pixelDetUnit, boundX, boundY);
00838 position = thePixelBarrelParametrization->getPosition();
00839 error = thePixelBarrelParametrization->getError();
00840 alphaMult = thePixelBarrelParametrization->getPixelMultiplicityAlpha();
00841 betaMult = thePixelBarrelParametrization->getPixelMultiplicityBeta();
00842 return true;
00843 break;
00844 }
00845
00846 case 2:
00847 {
00848 #ifdef FAMOS_DEBUG
00849 PXFDetId module(detid);
00850 unsigned int theDisk = module.disk();
00851 std::cout << "\tPixel Forward Disk " << theDisk << std::endl;
00852 #endif
00853 if( hitFindingProbability > theHitFindingProbability_PXF ) return false;
00854
00855 const PixelGeomDetUnit* pixelDetUnit = dynamic_cast<const PixelGeomDetUnit*>(theDetUnit);
00856 thePixelEndcapParametrization->smearHit(simHit, pixelDetUnit, boundX, boundY);
00857 position = thePixelEndcapParametrization->getPosition();
00858 error = thePixelEndcapParametrization->getError();
00859 alphaMult = thePixelEndcapParametrization->getPixelMultiplicityAlpha();
00860 betaMult = thePixelEndcapParametrization->getPixelMultiplicityBeta();
00861 return true;
00862 break;
00863 }
00864
00865 case 3:
00866 {
00867 TIBDetId module(detid);
00868 unsigned int theLayer = module.layer();
00869 #ifdef FAMOS_DEBUG
00870 std::cout << "\tTIB Layer " << theLayer << std::endl;
00871 #endif
00872
00873 double resolutionX, resolutionY, resolutionZ;
00874 resolutionZ = localPositionResolution_z;
00875
00876 switch (theLayer) {
00877 case 1:
00878 {
00879 resolutionX = localPositionResolution_TIB1x;
00880 resolutionY = localPositionResolution_TIB1y;
00881 if( hitFindingProbability > theHitFindingProbability_TIB1 ) return false;
00882 break;
00883 }
00884 case 2:
00885 {
00886 resolutionX = localPositionResolution_TIB2x;
00887 resolutionY = localPositionResolution_TIB2y;
00888 if( hitFindingProbability > theHitFindingProbability_TIB2 ) return false;
00889 break;
00890 }
00891 case 3:
00892 {
00893 resolutionX = localPositionResolution_TIB3x;
00894 resolutionY = localPositionResolution_TIB3y;
00895 if( hitFindingProbability > theHitFindingProbability_TIB3 ) return false;
00896 break;
00897 }
00898 case 4:
00899 {
00900 resolutionX = localPositionResolution_TIB4x;
00901 resolutionY = localPositionResolution_TIB4y;
00902 if( hitFindingProbability > theHitFindingProbability_TIB4 ) return false;
00903 break;
00904 }
00905 default:
00906 {
00907 edm::LogError ("SiTrackerGaussianSmearingRecHits")
00908 << "\tTIB Layer not valid " << theLayer << std::endl;
00909 return false;
00910 break;
00911 }
00912 }
00913
00914
00915 theSiStripErrorParametrization->smearHit(simHit, resolutionX, resolutionY, resolutionZ, boundX, boundY);
00916 position = theSiStripErrorParametrization->getPosition();
00917 error = theSiStripErrorParametrization->getError();
00918 alphaMult = 0;
00919 betaMult = 0;
00920 return true;
00921 break;
00922 }
00923
00924
00925 case 4:
00926 {
00927 TIDDetId module(detid);
00928 unsigned int theRing = module.ring();
00929 double resolutionFactorY =
00930 1. - simHit.localPosition().y() / theDetPlane.position().perp();
00931
00932 #ifdef FAMOS_DEBUG
00933 std::cout << "\tTID Ring " << theRing << std::endl;
00934 #endif
00935 double resolutionX, resolutionY, resolutionZ;
00936 resolutionZ = localPositionResolution_z;
00937
00938 switch (theRing) {
00939 case 1:
00940 {
00941 resolutionX = localPositionResolution_TID1x * resolutionFactorY;
00942 resolutionY = localPositionResolution_TID1y;
00943 if( hitFindingProbability > theHitFindingProbability_TID1 ) return false;
00944 break;
00945 }
00946 case 2:
00947 {
00948 resolutionX = localPositionResolution_TID2x * resolutionFactorY;
00949 resolutionY = localPositionResolution_TID2y;
00950 if( hitFindingProbability > theHitFindingProbability_TID2 ) return false;
00951 break;
00952 }
00953 case 3:
00954 {
00955 resolutionX = localPositionResolution_TID3x * resolutionFactorY;
00956 resolutionY = localPositionResolution_TID3y;
00957 if( hitFindingProbability > theHitFindingProbability_TID3 ) return false;
00958 break;
00959 }
00960 default:
00961 {
00962 edm::LogError ("SiTrackerGaussianSmearingRecHits")
00963 << "\tTID Ring not valid " << theRing << std::endl;
00964 return false;
00965 break;
00966 }
00967 }
00968
00969 boundX *= resolutionFactorY;
00970
00971 theSiStripErrorParametrization->smearHit(simHit, resolutionX, resolutionY, resolutionZ, boundX, boundY);
00972 position = theSiStripErrorParametrization->getPosition();
00973 error = theSiStripErrorParametrization->getError();
00974 alphaMult = 0;
00975 betaMult = 0;
00976 return true;
00977 break;
00978 }
00979
00980
00981 case 5:
00982 {
00983 TOBDetId module(detid);
00984 unsigned int theLayer = module.layer();
00985 #ifdef FAMOS_DEBUG
00986 std::cout << "\tTOB Layer " << theLayer << std::endl;
00987 #endif
00988 double resolutionX, resolutionY, resolutionZ;
00989 resolutionZ = localPositionResolution_z;
00990
00991 switch (theLayer) {
00992 case 1:
00993 {
00994 resolutionX = localPositionResolution_TOB1x;
00995 resolutionY = localPositionResolution_TOB1y;
00996 if( hitFindingProbability > theHitFindingProbability_TOB1 ) return false;
00997 break;
00998 }
00999 case 2:
01000 {
01001 resolutionX = localPositionResolution_TOB2x;
01002 resolutionY = localPositionResolution_TOB2y;
01003 if( hitFindingProbability > theHitFindingProbability_TOB2 ) return false;
01004 break;
01005 }
01006 case 3:
01007 {
01008 resolutionX = localPositionResolution_TOB3x;
01009 resolutionY = localPositionResolution_TOB3y;
01010 if( hitFindingProbability > theHitFindingProbability_TOB3 ) return false;
01011 break;
01012 }
01013 case 4:
01014 {
01015 resolutionX = localPositionResolution_TOB4x;
01016 resolutionY = localPositionResolution_TOB4y;
01017 if( hitFindingProbability > theHitFindingProbability_TOB4 ) return false;
01018 break;
01019 }
01020 case 5:
01021 {
01022 resolutionX = localPositionResolution_TOB5x;
01023 resolutionY = localPositionResolution_TOB5y;
01024 if( hitFindingProbability > theHitFindingProbability_TOB5 ) return false;
01025 break;
01026 }
01027 case 6:
01028 {
01029 resolutionX = localPositionResolution_TOB6x;
01030 resolutionY = localPositionResolution_TOB6y;
01031 if( hitFindingProbability > theHitFindingProbability_TOB6 ) return false;
01032 break;
01033 }
01034 default:
01035 {
01036 edm::LogError ("SiTrackerGaussianSmearingRecHits")
01037 << "\tTOB Layer not valid " << theLayer << std::endl;
01038 return false;
01039 break;
01040 }
01041 }
01042 theSiStripErrorParametrization->smearHit(simHit, resolutionX, resolutionY, resolutionZ, boundX, boundY);
01043 position = theSiStripErrorParametrization->getPosition();
01044 error = theSiStripErrorParametrization->getError();
01045 alphaMult = 0;
01046 betaMult = 0;
01047 return true;
01048 break;
01049 }
01050
01051
01052 case 6:
01053 {
01054 TECDetId module(detid);
01055 unsigned int theRing = module.ring();
01056 double resolutionFactorY =
01057 1. - simHit.localPosition().y() / theDetPlane.position().perp();
01058
01059 #ifdef FAMOS_DEBUG
01060 std::cout << "\tTEC Ring " << theRing << std::endl;
01061 #endif
01062 double resolutionX, resolutionY, resolutionZ;
01063 resolutionZ = localPositionResolution_z * localPositionResolution_z;
01064
01065 switch (theRing) {
01066 case 1:
01067 {
01068 resolutionX = localPositionResolution_TEC1x * resolutionFactorY;
01069 resolutionY = localPositionResolution_TEC1y;
01070 if( hitFindingProbability > theHitFindingProbability_TEC1 ) return false;
01071 break;
01072 }
01073 case 2:
01074 {
01075 resolutionX = localPositionResolution_TEC2x * resolutionFactorY;
01076 resolutionY = localPositionResolution_TEC2y;
01077 if( hitFindingProbability > theHitFindingProbability_TEC2 ) return false;
01078 break;
01079 }
01080 case 3:
01081 {
01082 resolutionX = localPositionResolution_TEC3x * resolutionFactorY;
01083 resolutionY = localPositionResolution_TEC3y;
01084 if( hitFindingProbability > theHitFindingProbability_TEC3 ) return false;
01085 break;
01086 }
01087 case 4:
01088 {
01089 resolutionX = localPositionResolution_TEC4x * resolutionFactorY;
01090 resolutionY = localPositionResolution_TEC4y;
01091 if( hitFindingProbability > theHitFindingProbability_TEC4 ) return false;
01092 break;
01093 }
01094 case 5:
01095 {
01096 resolutionX = localPositionResolution_TEC5x * resolutionFactorY;
01097 resolutionY = localPositionResolution_TEC5y;
01098 if( hitFindingProbability > theHitFindingProbability_TEC5 ) return false;
01099 break;
01100 }
01101 case 6:
01102 {
01103 resolutionX = localPositionResolution_TEC6x * resolutionFactorY;
01104 resolutionY = localPositionResolution_TEC6y;
01105 if( hitFindingProbability > theHitFindingProbability_TEC6 ) return false;
01106 break;
01107 }
01108 case 7:
01109 {
01110 resolutionX = localPositionResolution_TEC7x * resolutionFactorY;
01111 resolutionY = localPositionResolution_TEC7y;
01112 if( hitFindingProbability > theHitFindingProbability_TEC7 ) return false;
01113 break;
01114 }
01115 default:
01116 {
01117 edm::LogError ("SiTrackerGaussianSmearingRecHits")
01118 << "\tTEC Ring not valid " << theRing << std::endl;
01119 return false;
01120 break;
01121 }
01122 }
01123
01124 boundX *= resolutionFactorY;
01125 theSiStripErrorParametrization->smearHit(simHit, resolutionX, resolutionY, resolutionZ, boundX, boundY);
01126 position = theSiStripErrorParametrization->getPosition();
01127 error = theSiStripErrorParametrization->getError();
01128 alphaMult = 0;
01129 betaMult = 0;
01130 return true;
01131 break;
01132 }
01133
01134 default:
01135 {
01136 edm::LogError ("SiTrackerGaussianSmearingRecHits") << "\tTracker subdetector not valid " << subdet << std::endl;
01137 return false;
01138 break;
01139 }
01140
01141 }
01142
01143 }
01144
01145
01146
01147 void
01148 SiTrackerGaussianSmearingRecHitConverter::loadClusters(
01149 std::map<unsigned,edm::OwnVector<FastTrackerCluster> >& theClusterMap,
01150 FastTrackerClusterCollection& theClusterCollection) const
01151 {
01152 std::map<unsigned,edm::OwnVector<FastTrackerCluster> >::const_iterator
01153 it = theClusterMap.begin();
01154 std::map<unsigned,edm::OwnVector<FastTrackerCluster> >::const_iterator
01155 lastCluster = theClusterMap.end();
01156
01157 for( ; it != lastCluster ; ++it ) {
01158 theClusterCollection.put(it->first,(it->second).begin(),(it->second).end());
01159 }
01160 }
01161
01162
01163
01164 void
01165 SiTrackerGaussianSmearingRecHitConverter::loadRecHits(
01166 std::map<unsigned,edm::OwnVector<SiTrackerGSRecHit2D> >& theRecHits,
01167 SiTrackerGSRecHit2DCollection& theRecHitCollection) const
01168 {
01169 std::map<unsigned,edm::OwnVector<SiTrackerGSRecHit2D> >::const_iterator
01170 it = theRecHits.begin();
01171 std::map<unsigned,edm::OwnVector<SiTrackerGSRecHit2D> >::const_iterator
01172 lastRecHit = theRecHits.end();
01173
01174 for( ; it != lastRecHit ; ++it ) {
01175 theRecHitCollection.put(it->first,(it->second).begin(),(it->second).end());
01176 }
01177
01178 }
01179
01180 void
01181 SiTrackerGaussianSmearingRecHitConverter::loadMatchedRecHits(
01182 std::map<unsigned,edm::OwnVector<SiTrackerGSMatchedRecHit2D> >& theRecHits,
01183 SiTrackerGSMatchedRecHit2DCollection& theRecHitCollection) const
01184 {
01185 std::map<unsigned,edm::OwnVector<SiTrackerGSMatchedRecHit2D> >::const_iterator
01186 it = theRecHits.begin();
01187 std::map<unsigned,edm::OwnVector<SiTrackerGSMatchedRecHit2D> >::const_iterator
01188 lastRecHit = theRecHits.end();
01189
01190 for( ; it != lastRecHit ; ++it ) {
01191 theRecHitCollection.put(it->first,(it->second).begin(),(it->second).end());
01192 }
01193
01194 }
01195
01196
01197 void
01198 SiTrackerGaussianSmearingRecHitConverter::matchHits(
01199 std::map<unsigned, edm::OwnVector<SiTrackerGSRecHit2D> >& theRecHits,
01200 std::map<unsigned, edm::OwnVector<SiTrackerGSMatchedRecHit2D> >& matchedMap,
01201 MixCollection<PSimHit>& simhits ) {
01202
01203 std::map<unsigned, edm::OwnVector<SiTrackerGSRecHit2D> >::iterator it = theRecHits.begin();
01204 std::map<unsigned, edm::OwnVector<SiTrackerGSRecHit2D> >::iterator lastTrack = theRecHits.end();
01205
01206
01207 int recHitCounter = 0;
01208
01209
01210 for( ; it != lastTrack; ++it ) {
01211
01212 edm::OwnVector<SiTrackerGSRecHit2D>::const_iterator rit = it->second.begin();
01213 edm::OwnVector<SiTrackerGSRecHit2D>::const_iterator firstRecHit = it->second.begin();
01214 edm::OwnVector<SiTrackerGSRecHit2D>::const_iterator lastRecHit = it->second.end();
01215
01216
01217 for ( ; rit != lastRecHit; ++rit,++recHitCounter){
01218
01219 DetId detid = rit->geographicalId();
01220 unsigned int subdet = detid.subdetId();
01221
01222 if(subdet>2){
01223
01224 StripSubdetector specDetId=StripSubdetector(detid);
01225
01226
01227 if(specDetId.glued()){
01228
01229
01230 LocalVector simtrackdir = correspondingSimHit[recHitCounter]->localDirection();
01231
01232 const GluedGeomDet* gluedDet = (const GluedGeomDet*)geometry->idToDet(DetId(specDetId.glued()));
01233 const StripGeomDetUnit* stripdet =(StripGeomDetUnit*) gluedDet->stereoDet();
01234
01235
01236 GlobalVector globaldir= stripdet->surface().toGlobal(simtrackdir);
01237 LocalVector gluedsimtrackdir=gluedDet->surface().toLocal(globaldir);
01238
01239
01240 edm::OwnVector<SiTrackerGSRecHit2D>::const_iterator partner = rit;
01241 edm::OwnVector<SiTrackerGSRecHit2D>::const_iterator partnerNext = rit;
01242 edm::OwnVector<SiTrackerGSRecHit2D>::const_iterator partnerPrev = rit;
01243 partnerNext++; partnerPrev--;
01244
01245
01246 if( specDetId.stereo() ) {
01247
01248 int partnersFound = 0;
01249
01250
01251 if(partnerNext != it->second.end() )
01252 if( StripSubdetector( partnerNext->geographicalId() ).partnerDetId() == detid.rawId() ) {
01253 partner= partnerNext;
01254 partnersFound++;
01255 }
01256
01257 if( rit != it->second.begin())
01258 if( StripSubdetector( partnerPrev->geographicalId() ).partnerDetId() == detid.rawId() ) {
01259 partnersFound++;
01260 partner= partnerPrev;
01261 }
01262
01263
01264
01265
01266 if(partnersFound==0){
01267 for(edm::OwnVector<SiTrackerGSRecHit2D>::const_iterator iter = firstRecHit; iter != lastRecHit; ++iter ){
01268 if( StripSubdetector( iter->geographicalId() ).partnerDetId() == detid.rawId()){
01269 partnersFound++;
01270 partner = iter;
01271 }
01272 }
01273 }
01274
01275 if(partnersFound == 1) {
01276 SiTrackerGSMatchedRecHit2D * theMatchedHit =GSRecHitMatcher().match( &(*partner), &(*rit), gluedDet , gluedsimtrackdir );
01277
01278
01279
01280
01281
01282 matchedMap[it->first].push_back( theMatchedHit );
01283 }
01284 else{
01285
01286 SiTrackerGSMatchedRecHit2D * theProjectedHit = GSRecHitMatcher().projectOnly( &(*rit), geometry->idToDet(detid),gluedDet, gluedsimtrackdir );
01287 matchedMap[it->first].push_back( theProjectedHit );
01288
01289 }
01290 }
01291 else {
01292
01293
01294 int partnersFound = 0;
01295
01296
01297 if(partnerNext != it->second.end() )
01298 if( StripSubdetector( partnerNext->geographicalId() ).partnerDetId() == detid.rawId() ) {
01299 partnersFound++;
01300 }
01301
01302 if( rit != it->second.begin())
01303 if( StripSubdetector( partnerPrev->geographicalId() ).partnerDetId() == detid.rawId() ) {
01304 partnersFound++;
01305 }
01306
01307 if(partnersFound==0){
01308 for(edm::OwnVector<SiTrackerGSRecHit2D>::const_iterator iter = firstRecHit; iter != lastRecHit; ++iter ){
01309 if( StripSubdetector( iter->geographicalId() ).partnerDetId() == detid.rawId()){
01310 partnersFound++;
01311 }
01312 }
01313 }
01314
01315
01316 if(partnersFound==0){
01317
01318 SiTrackerGSMatchedRecHit2D * theProjectedHit =
01319 GSRecHitMatcher().projectOnly( &(*rit), geometry->idToDet(detid),gluedDet, gluedsimtrackdir );
01320
01321
01322
01323
01324 matchedMap[it->first].push_back( theProjectedHit );
01325 }
01326 }
01327 }
01328
01329 else{
01330
01331 SiTrackerGSMatchedRecHit2D* rit_copy = new SiTrackerGSMatchedRecHit2D(rit->localPosition(), rit->localPositionError(),
01332 rit->geographicalId(),
01333 rit->simhitId(), rit->simtrackId(), rit->eeId(),
01334 rit->cluster(),
01335 rit->simMultX(), rit->simMultY());
01336
01337
01338
01339 matchedMap[it->first].push_back( rit_copy );
01340 }
01341
01342 }
01343
01344 else {
01345
01346 SiTrackerGSMatchedRecHit2D* rit_copy = new SiTrackerGSMatchedRecHit2D(rit->localPosition(), rit->localPositionError(),
01347 rit->geographicalId(),
01348 rit->simhitId(), rit->simtrackId(), rit->eeId(),
01349 rit->cluster(),
01350 rit->simMultX(), rit->simMultY());
01351
01352
01353
01354 matchedMap[it->first].push_back( rit_copy );
01355 }
01356
01357 }
01358
01359 }
01360
01361
01362 }