ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Morgan/src/MuonAnalyzer.cc
(Generate patch)

Comparing UserCode/Morgan/src/MuonAnalyzer.cc (file contents):
Revision 1.2 by lethuill, Mon Dec 1 15:58:05 2008 UTC vs.
Revision 1.4 by lethuill, Mon Dec 15 19:08:52 2008 UTC

# Line 4 | Line 4 | using namespace std;
4   using namespace reco;
5   using namespace edm;
6  
7 < MuonAnalyzer::MuonAnalyzer(const edm::ParameterSet& producersNames):verbosity_(0)
7 > MuonAnalyzer::MuonAnalyzer(const edm::ParameterSet& producersNames):verbosity_(0),useMC_(false)
8   {
9          dataType_ = producersNames.getUntrackedParameter<string>("dataType","unknown");
10          muonProducer_ = producersNames.getParameter<edm::InputTag>("muonProducer");
11   }
12  
13 < MuonAnalyzer::MuonAnalyzer(const edm::ParameterSet& producersNames, int verbosity):verbosity_(verbosity)
13 > MuonAnalyzer::MuonAnalyzer(const edm::ParameterSet& producersNames, const edm::ParameterSet& myConfig, int verbosity):verbosity_(verbosity)
14   {
15          dataType_ = producersNames.getUntrackedParameter<string>("dataType","unknown");
16          muonProducer_ = producersNames.getParameter<edm::InputTag>("muonProducer");
17 +        useMC_ = myConfig.getUntrackedParameter<bool>("doMuonMC");
18   }
19  
20   MuonAnalyzer::~MuonAnalyzer()
# Line 44 | Line 45 | void MuonAnalyzer::Process(const edm::Ev
45  
46          for (unsigned int j=0; j<nMuons; j++)
47          {
48 <                const reco::Candidate* muon = 0;        
49 <                if( dataType_=="RECO" || dataType_=="AOD" ) muon = (const reco::Candidate*) ( & ((*recoMuons)[j]) );
50 <                if( dataType_=="PAT" || dataType_=="PATAOD" ) muon = (const reco::Candidate*) ( & ((*patMuons)[j]) );
48 >                const reco::Muon* muon = 0;    
49 >                if( dataType_=="RECO" || dataType_=="AOD" ) muon =  &((*recoMuons)[j]);
50 >                if( dataType_=="PAT" || dataType_=="PATAOD" ) muon = (const reco::Muon*) ( & ((*patMuons)[j]) );
51  
52                  TRootMuon localMuon(
53 <                                muon->px()
54 <                                ,muon->py()
55 <                                ,muon->pz()
56 <                                ,muon->energy()
57 <                                ,muon->vx()
58 <                                ,muon->vy()
59 <                                ,muon->vz()
60 <                                ,13
61 <                                ,muon->charge()
53 >                        muon->px()
54 >                        ,muon->py()
55 >                        ,muon->pz()
56 >                        ,muon->energy()
57 >                        ,muon->vx()
58 >                        ,muon->vy()
59 >                        ,muon->vz()
60 >                        ,13
61 >                        ,muon->charge()
62                  );
63  
64 +                // Variables from reco::Muon
65                  sintheta = sin( localMuon.Theta() );
66  
67 <                if( dataType_=="RECO" || dataType_=="AOD" || dataType_=="PATAOD")
68 <                {
69 <                        // Some specific methods to reco::Muon
70 <                        const reco::Muon *recoMuon = dynamic_cast<const reco::Muon*>(&*muon);
71 <                        localMuon.setCaloEnergy(
72 <                                recoMuon->calEnergy().em * sintheta
73 <                                ,recoMuon->calEnergy().emS9 * sintheta
74 <                                ,recoMuon->calEnergy().had * sintheta
75 <                                ,recoMuon->calEnergy().hadS9 * sintheta
76 <                                ,recoMuon->calEnergy().ho * sintheta
77 <                                ,recoMuon->calEnergy().hoS9 * sintheta
78 <                                ,recoMuon->caloCompatibility()
79 <                        );
80 <
81 <                        localMuon.setIsoR03(
82 <                                recoMuon->isolationR03().emEt
83 <                                ,recoMuon->isolationR03().hadEt
84 <                                ,recoMuon->isolationR03().hoEt
85 <                                ,recoMuon->isolationR03().sumPt
86 <                                ,recoMuon->isolationR03().nTracks
87 <                                ,recoMuon->isolationR03().nJets
88 <                        );
89 <
90 <                        localMuon.setIsoR05(
91 <                                recoMuon->isolationR05().emEt
92 <                                ,recoMuon->isolationR05().hadEt
93 <                                ,recoMuon->isolationR05().hoEt
94 <                                ,recoMuon->isolationR05().sumPt
95 <                                ,recoMuon->isolationR05().nTracks
96 <                                ,recoMuon->isolationR05().nJets
97 <                        );
98 <
99 <                        //localMuon.setTime( recoMuon->time() );
67 >                localMuon.setCaloEnergy(
68 >                        muon->calEnergy().em * sintheta
69 >                        ,muon->calEnergy().emS9 * sintheta
70 >                        ,muon->calEnergy().had * sintheta
71 >                        ,muon->calEnergy().hadS9 * sintheta
72 >                        ,muon->calEnergy().ho * sintheta
73 >                        ,muon->calEnergy().hoS9 * sintheta
74 >                        ,muon->caloCompatibility()
75 >                );
76 >
77 >                localMuon.setIsoR03(
78 >                        muon->isolationR03().emEt
79 >                        ,muon->isolationR03().hadEt
80 >                        ,muon->isolationR03().hoEt
81 >                        ,muon->isolationR03().sumPt
82 >                        ,muon->isolationR03().nTracks
83 >                        ,muon->isolationR03().nJets
84 >                );
85 >
86 >                localMuon.setIsoR05(
87 >                        muon->isolationR05().emEt
88 >                        ,muon->isolationR05().hadEt
89 >                        ,muon->isolationR05().hoEt
90 >                        ,muon->isolationR05().sumPt
91 >                        ,muon->isolationR05().nTracks
92 >                        ,muon->isolationR05().nJets
93 >                );
94 >
95 >                localMuon.setValidity(
96 >                        muon->isEnergyValid()
97 >                        ,muon->isMatchesValid()
98 >                        ,muon->isIsolationValid()
99 >                );
100 >
101 >                localMuon.setDirection( muon->time().direction() );
102 >                localMuon.setAlgo( muon->type() );
103 >                localMuon.setID(
104 >                        int(muon->isGood(reco::Muon::TrackerMuonArbitrated))
105 >                        ,int(muon->isGood(reco::Muon::AllArbitrated))
106 >                        ,int(muon->isGood(reco::Muon::GlobalMuonPromptTight))
107 >                        ,int(muon->isGood(reco::Muon::TMLastStationLoose))
108 >                        ,int(muon->isGood(reco::Muon::TMLastStationTight))
109 >                        ,int(muon->isGood(reco::Muon::TM2DCompatibilityLoose))
110 >                        ,int(muon->isGood(reco::Muon::TM2DCompatibilityTight))
111 >                );
112  
113 +                if( dataType_=="RECO" || dataType_=="AOD" )
114 +                {
115 +                        // Some specific methods requiring  RECO / AOD format
116 +                        // Do association to genParticle ?
117 +                        // Add InnerTrack, OuterTrack, GlobalTrack infos ?
118                  }
119  
120 <                if( dataType_=="PAT"  )
120 >                if( dataType_=="PATAOD" || dataType_=="PAT" )
121                  {
122                          // Some specific methods to pat::Muon
123                          const pat::Muon *patMuon = dynamic_cast<const pat::Muon*>(&*muon);
124 +                        // Use existing reference to genParticle [ pat::PATObject::genParticleRef() ] ?
125 +                        // Alternative methode for isolation (isoDeposit) ?
126 +                        //
127 +                        // leptonID apparently not initialised in PAT...
128 +                        // cout << "Valeur pourrie du leptonID=" << patMuon->leptonID() << endl;
129 +
130 +                        if(useMC_)
131 +                        {
132 +                                // MC truth associator index
133 +                                if ((patMuon->genParticleRef()).isNonnull()) {
134 +                                        localMuon.setMuonMCIndex((patMuon->genParticleRef()).index());
135 +                                } else {
136 +                                        localMuon.setMuonMCIndex(-1);
137 +                                }
138 +
139 +                                if ( patMuon->genLepton() != NULL ) {
140 +                                        localMuon.setMomentumMCMuon(patMuon->genLepton()->px(),patMuon->genLepton()->py(),patMuon->genLepton()->pz(),patMuon->genLepton()->energy());
141 +                                        localMuon.setVertexMCMuon(TVector3(patMuon->genLepton()->vx(),patMuon->genLepton()->vy(),patMuon->genLepton()->vz()));
142 +                                        localMuon.setPdgIdMCMuon(patMuon->genLepton()->pdgId());
143 +                                }
144 +                        }
145                  }
146 <
107 <
146 >                
147                  new( (*rootMuons)[j] ) TRootMuon(localMuon);
148                  if(verbosity_>2) cout << "   ["<< setw(3) << j << "] " << localMuon << endl;
149          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines