CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/Validation/RecoTrack/plugins/MultiTrackValidator.cc

Go to the documentation of this file.
00001 #include "Validation/RecoTrack/interface/MultiTrackValidator.h"
00002 #include "DQMServices/ClientConfig/interface/FitSlicesYTool.h"
00003 
00004 #include "FWCore/Framework/interface/MakerMacros.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 
00007 #include "DataFormats/TrackReco/interface/Track.h"
00008 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00009 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
00010 #include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h"
00011 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
00012 #include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
00013 #include "SimTracker/TrackAssociation/interface/TrackAssociatorByChi2.h"
00014 #include "SimTracker/TrackAssociation/interface/QuickTrackAssociatorByHits.h"
00015 #include "SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h"
00016 #include "SimTracker/Records/interface/TrackAssociatorRecord.h"
00017 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
00018 #include "SimDataFormats/TrackingAnalysis/interface/TrackingVertex.h"
00019 #include "SimDataFormats/TrackingAnalysis/interface/TrackingVertexContainer.h"
00020 #include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h"
00021 #include "SimDataFormats/EncodedEventId/interface/EncodedEventId.h"
00022 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
00023 #include "TrackingTools/PatternTools/interface/TSCBLBuilderNoMaterial.h"
00024 #include "SimTracker/TrackAssociation/plugins/ParametersDefinerForTPESProducer.h"
00025 #include "SimTracker/TrackAssociation/plugins/CosmicParametersDefinerForTPESProducer.h"
00026 #include "Validation/RecoTrack/interface/MTVHistoProducerAlgoFactory.h"
00027 
00028 #include "DataFormats/TrackReco/interface/DeDxData.h"
00029 #include "DataFormats/Common/interface/ValueMap.h"
00030 #include "DataFormats/Common/interface/Ref.h"
00031 
00032 #include "TMath.h"
00033 #include <TF1.h>
00034 
00035 //#include <iostream>
00036 
00037 using namespace std;
00038 using namespace edm;
00039 
00040 typedef edm::Ref<edm::HepMCProduct, HepMC::GenParticle > GenParticleRef;
00041 
00042 MultiTrackValidator::MultiTrackValidator(const edm::ParameterSet& pset):MultiTrackValidatorBase(pset){
00043   //theExtractor = IsoDepositExtractorFactory::get()->create( extractorName, extractorPSet);
00044 
00045   ParameterSet psetForHistoProducerAlgo = pset.getParameter<ParameterSet>("histoProducerAlgoBlock");
00046   string histoProducerAlgoName = psetForHistoProducerAlgo.getParameter<string>("ComponentName");
00047   histoProducerAlgo_ = MTVHistoProducerAlgoFactory::get()->create(histoProducerAlgoName ,psetForHistoProducerAlgo);
00048   histoProducerAlgo_->setDQMStore(dbe_);
00049 
00050   dirName_ = pset.getParameter<std::string>("dirName");
00051   associatormap = pset.getParameter< edm::InputTag >("associatormap");
00052   UseAssociators = pset.getParameter< bool >("UseAssociators");
00053 
00054   m_dEdx1Tag = pset.getParameter< edm::InputTag >("dEdx1Tag");
00055   m_dEdx2Tag = pset.getParameter< edm::InputTag >("dEdx2Tag");
00056 
00057   tpSelector = TrackingParticleSelector(pset.getParameter<double>("ptMinTP"),
00058                                         pset.getParameter<double>("minRapidityTP"),
00059                                         pset.getParameter<double>("maxRapidityTP"),
00060                                         pset.getParameter<double>("tipTP"),
00061                                         pset.getParameter<double>("lipTP"),
00062                                         pset.getParameter<int>("minHitTP"),
00063                                         pset.getParameter<bool>("signalOnlyTP"),
00064                                         pset.getParameter<bool>("chargedOnlyTP"),
00065                                         pset.getParameter<bool>("stableOnlyTP"),
00066                                         pset.getParameter<std::vector<int> >("pdgIdTP"));
00067 
00068   cosmictpSelector = CosmicTrackingParticleSelector(pset.getParameter<double>("ptMinTP"),
00069                                                     pset.getParameter<double>("minRapidityTP"),
00070                                                     pset.getParameter<double>("maxRapidityTP"),
00071                                                     pset.getParameter<double>("tipTP"),
00072                                                     pset.getParameter<double>("lipTP"),
00073                                                     pset.getParameter<int>("minHitTP"),
00074                                                     pset.getParameter<bool>("chargedOnlyTP"),
00075                                                     pset.getParameter<std::vector<int> >("pdgIdTP"));
00076 
00077   useGsf = pset.getParameter<bool>("useGsf");
00078   runStandalone = pset.getParameter<bool>("runStandalone");
00079 
00080   _simHitTpMapTag = pset.getParameter<edm::InputTag>("simHitTpMapTag");
00081     
00082   if (!UseAssociators) {
00083     associators.clear();
00084     associators.push_back(associatormap.label());
00085   }
00086 
00087 }
00088 
00089 
00090 MultiTrackValidator::~MultiTrackValidator(){delete histoProducerAlgo_;}
00091 
00092 void MultiTrackValidator::beginRun(Run const&, EventSetup const& setup) {
00093   //  dbe_->showDirStructure();
00094 
00095   //int j=0;  //is This Necessary ???
00096   for (unsigned int ww=0;ww<associators.size();ww++){
00097     for (unsigned int www=0;www<label.size();www++){
00098       dbe_->cd();
00099       InputTag algo = label[www];
00100       string dirName=dirName_;
00101       if (algo.process()!="")
00102         dirName+=algo.process()+"_";
00103       if(algo.label()!="")
00104         dirName+=algo.label()+"_";
00105       if(algo.instance()!="")
00106         dirName+=algo.instance()+"_";      
00107       if (dirName.find("Tracks")<dirName.length()){
00108         dirName.replace(dirName.find("Tracks"),6,"");
00109       }
00110       string assoc= associators[ww];
00111       if (assoc.find("Track")<assoc.length()){
00112         assoc.replace(assoc.find("Track"),5,"");
00113       }
00114       dirName+=assoc;
00115       std::replace(dirName.begin(), dirName.end(), ':', '_');
00116 
00117       dbe_->setCurrentFolder(dirName.c_str());
00118       
00119       // vector of vector initialization
00120       histoProducerAlgo_->initialize(); //TO BE FIXED. I'D LIKE TO AVOID THIS CALL
00121 
00122       dbe_->goUp(); //Is this really necessary ???
00123       string subDirName = dirName + "/simulation";
00124       dbe_->setCurrentFolder(subDirName.c_str());
00125 
00126       //Booking histograms concerning with simulated tracks
00127       histoProducerAlgo_->bookSimHistos();
00128 
00129       dbe_->cd();
00130       dbe_->setCurrentFolder(dirName.c_str());
00131 
00132       //Booking histograms concerning with reconstructed tracks
00133       histoProducerAlgo_->bookRecoHistos();
00134       if (runStandalone) histoProducerAlgo_->bookRecoHistosForStandaloneRunning();
00135 
00136       if (UseAssociators) {
00137         edm::ESHandle<TrackAssociatorBase> theAssociator;
00138         for (unsigned int w=0;w<associators.size();w++) {
00139           setup.get<TrackAssociatorRecord>().get(associators[w],theAssociator);
00140           associator.push_back( theAssociator.product() );
00141         }//end loop w
00142       }
00143     }//end loop www
00144   }// end loop ww
00145 }
00146 
00147 void MultiTrackValidator::analyze(const edm::Event& event, const edm::EventSetup& setup){
00148   using namespace reco;
00149   
00150   edm::LogInfo("TrackValidator") << "\n====================================================" << "\n"
00151                                  << "Analyzing new event" << "\n"
00152                                  << "====================================================\n" << "\n";
00153   edm::ESHandle<ParametersDefinerForTP> parametersDefinerTP; 
00154   setup.get<TrackAssociatorRecord>().get(parametersDefiner,parametersDefinerTP);    
00155   
00156   edm::Handle<TrackingParticleCollection>  TPCollectionHeff ;
00157   event.getByLabel(label_tp_effic,TPCollectionHeff);
00158   const TrackingParticleCollection tPCeff = *(TPCollectionHeff.product());
00159   
00160   edm::Handle<TrackingParticleCollection>  TPCollectionHfake ;
00161   event.getByLabel(label_tp_fake,TPCollectionHfake);
00162   const TrackingParticleCollection tPCfake = *(TPCollectionHfake.product());
00163   
00164   if(parametersDefiner=="CosmicParametersDefinerForTP") {
00165     edm::Handle<SimHitTPAssociationProducer::SimHitTPAssociationList> simHitsTPAssoc;
00166     //warning: make sure the TP collection used in the map is the same used in the MTV!
00167     event.getByLabel(_simHitTpMapTag,simHitsTPAssoc);
00168     parametersDefinerTP->initEvent(simHitsTPAssoc);
00169     cosmictpSelector.initEvent(simHitsTPAssoc);
00170   }
00171 
00172   //if (tPCeff.size()==0) {edm::LogInfo("TrackValidator") 
00173   //<< "TP Collection for efficiency studies has size = 0! Skipping Event." ; return;}
00174   //if (tPCfake.size()==0) {edm::LogInfo("TrackValidator") 
00175   //<< "TP Collection for fake rate studies has size = 0! Skipping Event." ; return;}
00176   
00177   edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
00178   event.getByLabel(bsSrc,recoBeamSpotHandle);
00179   reco::BeamSpot bs = *recoBeamSpotHandle;      
00180   
00181   edm::Handle< vector<PileupSummaryInfo> > puinfoH;
00182   event.getByLabel(label_pileupinfo,puinfoH);
00183   PileupSummaryInfo puinfo;      
00184   
00185   for (unsigned int puinfo_ite=0;puinfo_ite<(*puinfoH).size();++puinfo_ite){ 
00186     if ((*puinfoH)[puinfo_ite].getBunchCrossing()==0){
00187       puinfo=(*puinfoH)[puinfo_ite];
00188       break;
00189     }
00190   }
00191 
00192   edm::Handle<TrackingVertexCollection> tvH;
00193   event.getByLabel(label_tv,tvH);
00194   TrackingVertexCollection tv = *tvH;      
00195   
00196   int w=0; //counter counting the number of sets of histograms
00197   for (unsigned int ww=0;ww<associators.size();ww++){
00198     for (unsigned int www=0;www<label.size();www++){
00199       //
00200       //get collections from the event
00201       //
00202       edm::Handle<View<Track> >  trackCollection;
00203       if(!event.getByLabel(label[www], trackCollection)&&ignoremissingtkcollection_)continue;
00204       //if (trackCollection->size()==0) 
00205       //edm::LogInfo("TrackValidator") << "TrackCollection size = 0!" ; 
00206       //continue;
00207       //}
00208       reco::RecoToSimCollection recSimColl;
00209       reco::SimToRecoCollection simRecColl;
00210       //associate tracks
00211       if(UseAssociators){
00212         edm::LogVerbatim("TrackValidator") << "Analyzing " 
00213                                            << label[www].process()<<":"
00214                                            << label[www].label()<<":"
00215                                            << label[www].instance()<<" with "
00216                                            << associators[ww].c_str() <<"\n";
00217         
00218         LogTrace("TrackValidator") << "Calling associateRecoToSim method" << "\n";
00219         recSimColl=associator[ww]->associateRecoToSim(trackCollection,
00220                                                       TPCollectionHfake,
00221                                                       &event,&setup);
00222         LogTrace("TrackValidator") << "Calling associateSimToReco method" << "\n";
00223         simRecColl=associator[ww]->associateSimToReco(trackCollection,
00224                                                       TPCollectionHeff, 
00225                                                       &event,&setup);
00226       }
00227       else{
00228         edm::LogVerbatim("TrackValidator") << "Analyzing " 
00229                                            << label[www].process()<<":"
00230                                            << label[www].label()<<":"
00231                                            << label[www].instance()<<" with "
00232                                            << associatormap.process()<<":"
00233                                            << associatormap.label()<<":"
00234                                            << associatormap.instance()<<"\n";
00235         
00236         Handle<reco::SimToRecoCollection > simtorecoCollectionH;
00237         event.getByLabel(associatormap,simtorecoCollectionH);
00238         simRecColl= *(simtorecoCollectionH.product()); 
00239         
00240         Handle<reco::RecoToSimCollection > recotosimCollectionH;
00241         event.getByLabel(associatormap,recotosimCollectionH);
00242         recSimColl= *(recotosimCollectionH.product()); 
00243       }
00244 
00245 
00246 
00247       // ########################################################
00248       // fill simulation histograms (LOOP OVER TRACKINGPARTICLES)
00249       // ########################################################
00250 
00251       //compute number of tracks per eta interval
00252       //
00253       edm::LogVerbatim("TrackValidator") << "\n# of TrackingParticles: " << tPCeff.size() << "\n";
00254       int ats(0);         //This counter counts the number of simTracks that are "associated" to recoTracks
00255       int st(0);          //This counter counts the number of simulated tracks passing the MTV selection (i.e. tpSelector(tp) )
00256       unsigned sts(0);   //This counter counts the number of simTracks surviving the bunchcrossing cut 
00257       unsigned asts(0);  //This counter counts the number of simTracks that are "associated" to recoTracks surviving the bunchcrossing cut
00258       for (TrackingParticleCollection::size_type i=0; i<tPCeff.size(); i++){ //loop over TPs collection for tracking efficiency
00259         TrackingParticleRef tpr(TPCollectionHeff, i);
00260         TrackingParticle* tp=const_cast<TrackingParticle*>(tpr.get());
00261         TrackingParticle::Vector momentumTP; 
00262         TrackingParticle::Point vertexTP;
00263         double dxySim(0);
00264         double dzSim(0);
00265         
00266         //---------- THIS PART HAS TO BE CLEANED UP. THE PARAMETER DEFINER WAS NOT MEANT TO BE USED IN THIS WAY ----------
00267         //If the TrackingParticle is collison like, get the momentum and vertex at production state
00268         if(parametersDefiner=="LhcParametersDefinerForTP")
00269           {
00270             if(! tpSelector(*tp)) continue;
00271             momentumTP = tp->momentum();
00272             vertexTP = tp->vertex();
00273             //Calcualte the impact parameters w.r.t. PCA
00274             TrackingParticle::Vector momentum = parametersDefinerTP->momentum(event,setup,tpr);
00275             TrackingParticle::Point vertex = parametersDefinerTP->vertex(event,setup,tpr);
00276             dxySim = (-vertex.x()*sin(momentum.phi())+vertex.y()*cos(momentum.phi()));
00277             dzSim = vertex.z() - (vertex.x()*momentum.x()+vertex.y()*momentum.y())/sqrt(momentum.perp2()) 
00278               * momentum.z()/sqrt(momentum.perp2());
00279           }
00280         //If the TrackingParticle is comics, get the momentum and vertex at PCA
00281         if(parametersDefiner=="CosmicParametersDefinerForTP")
00282           {
00283             if(! cosmictpSelector(tpr,&bs,event,setup)) continue;       
00284             momentumTP = parametersDefinerTP->momentum(event,setup,tpr);
00285             vertexTP = parametersDefinerTP->vertex(event,setup,tpr);
00286             dxySim = (-vertexTP.x()*sin(momentumTP.phi())+vertexTP.y()*cos(momentumTP.phi()));
00287             dzSim = vertexTP.z() - (vertexTP.x()*momentumTP.x()+vertexTP.y()*momentumTP.y())/sqrt(momentumTP.perp2()) 
00288               * momentumTP.z()/sqrt(momentumTP.perp2());
00289           }
00290         //---------- THE PART ABOVE HAS TO BE CLEANED UP. THE PARAMETER DEFINER WAS NOT MEANT TO BE USED IN THIS WAY ----------
00291 
00292         st++;   //This counter counts the number of simulated tracks passing the MTV selection (i.e. tpSelector(tp) )
00293 
00294         // in the coming lines, histos are filled using as input
00295         // - momentumTP 
00296         // - vertexTP 
00297         // - dxySim
00298         // - dzSim
00299 
00300         histoProducerAlgo_->fill_generic_simTrack_histos(w,momentumTP,vertexTP, tp->eventId().bunchCrossing());
00301 
00302 
00303         // ##############################################
00304         // fill RecoAssociated SimTracks' histograms
00305         // ##############################################
00306         // bool isRecoMatched(false); // UNUSED
00307         const reco::Track* matchedTrackPointer=0;
00308         std::vector<std::pair<RefToBase<Track>, double> > rt;
00309         if(simRecColl.find(tpr) != simRecColl.end()){
00310           rt = (std::vector<std::pair<RefToBase<Track>, double> >) simRecColl[tpr];
00311           if (rt.size()!=0) {
00312             ats++; //This counter counts the number of simTracks that have a recoTrack associated
00313             // isRecoMatched = true; // UNUSED
00314             matchedTrackPointer = rt.begin()->first.get();
00315             edm::LogVerbatim("TrackValidator") << "TrackingParticle #" << st 
00316                                                << " with pt=" << sqrt(momentumTP.perp2()) 
00317                                                << " associated with quality:" << rt.begin()->second <<"\n";
00318           }
00319         }else{
00320           edm::LogVerbatim("TrackValidator") 
00321             << "TrackingParticle #" << st
00322             << " with pt,eta,phi: " 
00323             << sqrt(momentumTP.perp2()) << " , "
00324             << momentumTP.eta() << " , "
00325             << momentumTP.phi() << " , "
00326             << " NOT associated to any reco::Track" << "\n";
00327         }
00328         
00329 
00330         
00331 
00332         int nSimHits = tp->numberOfTrackerHits();
00333 
00334         double vtx_z_PU = vertexTP.z();
00335         for (size_t j = 0; j < tv.size(); j++) {
00336             if (tp->eventId().event() == tv[j].eventId().event()) {
00337                 vtx_z_PU = tv[j].position().z();
00338                 break;
00339             }
00340         }
00341 
00342           histoProducerAlgo_->fill_recoAssociated_simTrack_histos(w,*tp,momentumTP,vertexTP,dxySim,dzSim,nSimHits,matchedTrackPointer,puinfo.getPU_NumInteractions(), vtx_z_PU);
00343           sts++;
00344           if (matchedTrackPointer) asts++;
00345 
00346 
00347 
00348 
00349       } // End  for (TrackingParticleCollection::size_type i=0; i<tPCeff.size(); i++){
00350 
00351       //if (st!=0) h_tracksSIM[w]->Fill(st);  // TO BE FIXED
00352       
00353       
00354       // ##############################################
00355       // fill recoTracks histograms (LOOP OVER TRACKS)
00356       // ##############################################
00357       edm::LogVerbatim("TrackValidator") << "\n# of reco::Tracks with "
00358                                          << label[www].process()<<":"
00359                                          << label[www].label()<<":"
00360                                          << label[www].instance()
00361                                          << ": " << trackCollection->size() << "\n";
00362 
00363       int sat(0); //This counter counts the number of recoTracks that are associated to SimTracks from Signal only
00364       int at(0); //This counter counts the number of recoTracks that are associated to SimTracks
00365       int rT(0); //This counter counts the number of recoTracks in general
00366 
00367 
00368       // dE/dx
00369       // at some point this could be generalized, with a vector of tags and a corresponding vector of Handles
00370       // I'm writing the interface such to take vectors of ValueMaps
00371       edm::Handle<edm::ValueMap<reco::DeDxData> > dEdx1Handle;
00372       edm::Handle<edm::ValueMap<reco::DeDxData> > dEdx2Handle;
00373       std::vector<edm::ValueMap<reco::DeDxData> > v_dEdx;
00374       v_dEdx.clear();
00375       //std::cout << "PIPPO: label is " << label[www] << std::endl;
00376       if (label[www].label()=="generalTracks") {
00377         try {
00378           event.getByLabel(m_dEdx1Tag, dEdx1Handle);
00379           const edm::ValueMap<reco::DeDxData> dEdx1 = *dEdx1Handle.product();
00380           event.getByLabel(m_dEdx2Tag, dEdx2Handle);
00381           const edm::ValueMap<reco::DeDxData> dEdx2 = *dEdx2Handle.product();
00382           v_dEdx.push_back(dEdx1);
00383           v_dEdx.push_back(dEdx2);
00384         } catch (cms::Exception e){
00385           LogTrace("TrackValidator") << "exception found: " << e.what() << "\n";
00386         }
00387       }
00388       //end dE/dx
00389 
00390       for(View<Track>::size_type i=0; i<trackCollection->size(); ++i){
00391 
00392         RefToBase<Track> track(trackCollection, i);
00393         rT++;
00394         
00395         bool isSigSimMatched(false);
00396         bool isSimMatched(false);
00397     bool isChargeMatched(true);
00398     int numAssocRecoTracks = 0;
00399         int tpbx = 0;
00400         int nSimHits = 0;
00401         double sharedFraction = 0.;
00402         std::vector<std::pair<TrackingParticleRef, double> > tp;
00403         if(recSimColl.find(track) != recSimColl.end()){
00404           tp = recSimColl[track];
00405           if (tp.size()!=0) {
00406             nSimHits = tp[0].first->numberOfTrackerHits();
00407             sharedFraction = tp[0].second;
00408             isSimMatched = true;
00409         if (tp[0].first->charge() != track->charge()) isChargeMatched = false;
00410         if(simRecColl.find(tp[0].first) != simRecColl.end()) numAssocRecoTracks = simRecColl[tp[0].first].size();
00411         //std::cout << numAssocRecoTracks << std::endl;
00412             tpbx = tp[0].first->eventId().bunchCrossing();
00413             at++;
00414             for (unsigned int tp_ite=0;tp_ite<tp.size();++tp_ite){ 
00415               TrackingParticle trackpart = *(tp[tp_ite].first);
00416               if ((trackpart.eventId().event() == 0) && (trackpart.eventId().bunchCrossing() == 0)){
00417                 isSigSimMatched = true;
00418                 sat++;
00419                 break;
00420               }
00421             }
00422             edm::LogVerbatim("TrackValidator") << "reco::Track #" << rT << " with pt=" << track->pt() 
00423                                                << " associated with quality:" << tp.begin()->second <<"\n";
00424           }
00425         } else {
00426           edm::LogVerbatim("TrackValidator") << "reco::Track #" << rT << " with pt=" << track->pt()
00427                                              << " NOT associated to any TrackingParticle" << "\n";                
00428         }
00429         
00430 
00431         histoProducerAlgo_->fill_generic_recoTrack_histos(w,*track,bs.position(),isSimMatched,isSigSimMatched, isChargeMatched, numAssocRecoTracks, puinfo.getPU_NumInteractions(), tpbx, nSimHits, sharedFraction);
00432 
00433         // dE/dx
00434         //      reco::TrackRef track2  = reco::TrackRef( trackCollection, i );
00435         if (v_dEdx.size() > 0) histoProducerAlgo_->fill_dedx_recoTrack_histos(w,track, v_dEdx);
00436         //if (v_dEdx.size() > 0) histoProducerAlgo_->fill_dedx_recoTrack_histos(track2, v_dEdx);
00437 
00438 
00439         //Fill other histos
00440         //try{ //Is this really necessary ????
00441 
00442         if (tp.size()==0) continue;     
00443 
00444         histoProducerAlgo_->fill_simAssociated_recoTrack_histos(w,*track);
00445 
00446         TrackingParticleRef tpr = tp.begin()->first;
00447         
00448         /* TO BE FIXED LATER
00449         if (associators[ww]=="TrackAssociatorByChi2"){
00450           //association chi2
00451           double assocChi2 = -tp.begin()->second;//in association map is stored -chi2
00452           h_assochi2[www]->Fill(assocChi2);
00453           h_assochi2_prob[www]->Fill(TMath::Prob((assocChi2)*5,5));
00454         }
00455         else if (associators[ww]=="quickTrackAssociatorByHits"){
00456           double fraction = tp.begin()->second;
00457           h_assocFraction[www]->Fill(fraction);
00458           h_assocSharedHit[www]->Fill(fraction*track->numberOfValidHits());
00459         }
00460         */
00461 
00462           
00463         //Get tracking particle parameters at point of closest approach to the beamline
00464         TrackingParticle::Vector momentumTP = parametersDefinerTP->momentum(event,setup,tpr);
00465         TrackingParticle::Point vertexTP = parametersDefinerTP->vertex(event,setup,tpr);                         
00466         int chargeTP = tpr->charge();
00467 
00468         histoProducerAlgo_->fill_ResoAndPull_recoTrack_histos(w,momentumTP,vertexTP,chargeTP,
00469                                                              *track,bs.position());
00470         
00471         
00472         //TO BE FIXED
00473         //std::vector<PSimHit> simhits=tpr.get()->trackPSimHit(DetId::Tracker);
00474         //nrecHit_vs_nsimHit_rec2sim[w]->Fill(track->numberOfValidHits(), (int)(simhits.end()-simhits.begin() ));
00475         
00476         /*
00477           } // End of try{
00478           catch (cms::Exception e){
00479           LogTrace("TrackValidator") << "exception found: " << e.what() << "\n";
00480           }
00481         */
00482         
00483       } // End of for(View<Track>::size_type i=0; i<trackCollection->size(); ++i){
00484 
00485       histoProducerAlgo_->fill_trackBased_histos(w,at,rT,st);
00486 
00487       edm::LogVerbatim("TrackValidator") << "Total Simulated: " << st << "\n"
00488                                          << "Total Associated (simToReco): " << ats << "\n"
00489                                          << "Total Reconstructed: " << rT << "\n"
00490                                          << "Total Associated (recoToSim): " << at << "\n"
00491                                          << "Total Fakes: " << rT-at << "\n";
00492 
00493       w++;
00494     } // End of  for (unsigned int www=0;www<label.size();www++){
00495   } //END of for (unsigned int ww=0;ww<associators.size();ww++){
00496 
00497 }
00498 
00499 void MultiTrackValidator::endRun(Run const&, EventSetup const&) {
00500   int w=0;
00501   for (unsigned int ww=0;ww<associators.size();ww++){
00502     for (unsigned int www=0;www<label.size();www++){
00503       if(!skipHistoFit && runStandalone)        histoProducerAlgo_->finalHistoFits(w);
00504       if (runStandalone) histoProducerAlgo_->fillProfileHistosFromVectors(w);
00505       histoProducerAlgo_->fillHistosFromVectors(w);
00506       w++;
00507     }    
00508   }
00509   if ( out.size() != 0 && dbe_ ) dbe_->save(out);
00510 }
00511 
00512 
00513