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