ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Morgan/src/TotoAnalyzer.cc
Revision: 1.29
Committed: Fri Apr 17 15:17:38 2009 UTC (16 years ago) by lethuill
Content type: text/plain
Branch: MAIN
Changes since 1.28: +1 -0 lines
Log Message:
Add significance of the 3D impact parameter for leptons.
Calculation done in new LeptonAnalyzer class (Base for MuonAnalyzer and ElectronAnalyzer)

File Contents

# User Rev Content
1 lethuill 1.14 #include "../interface/TotoAnalyzer.h"
2 mlethuil 1.1
3     using namespace std;
4     using namespace reco;
5     using namespace edm;
6    
7    
8     TotoAnalyzer::TotoAnalyzer(const edm::ParameterSet& iConfig)
9     {
10 lethuill 1.11 myConfig_ = iConfig.getParameter<ParameterSet>("myConfig");
11 lethuill 1.14 dataType_ = myConfig_.getUntrackedParameter<string>("dataType","unknown");
12     cout << "dataType: " << dataType_ << endl;
13     if( dataType_=="RECO" ) producersNames_ = iConfig.getParameter<ParameterSet>("producersNamesRECO");
14     else if( dataType_=="AOD" ) producersNames_ = iConfig.getParameter<ParameterSet>("producersNamesAOD");
15     else if( dataType_=="PATAOD" ) producersNames_ = iConfig.getParameter<ParameterSet>("producersNamesPATAOD");
16     else if( dataType_=="PAT" ) producersNames_ = iConfig.getParameter<ParameterSet>("producersNamesPAT");
17     else { cout << "TotoAnalyzer::TotoAnalyzer... dataType is unknown... exiting..." << endl; exit(1); }
18 lethuill 1.24
19     runInfos_ = 0;
20     rootEvent = 0;
21 lethuill 1.28 hltAnalyzer_ = 0;
22 lethuill 1.24 mcParticles = 0;
23     genJets = 0;
24     genMETs = 0;
25 lethuill 1.28 rootMuMuGammaEvent = 0;
26     rootMCTopTop = 0;
27 lethuill 1.24 mcPhotons = 0;
28 lethuill 1.25 vertices = 0;
29 lethuill 1.24 tracks = 0;
30     jets = 0;
31     muons = 0;
32     electrons = 0;
33     photons = 0;
34     clusters = 0;
35     superClusters = 0;
36     conversionTracks = 0;
37     met = 0;
38 mlethuil 1.1 }
39    
40    
41     TotoAnalyzer::~TotoAnalyzer()
42 lethuill 1.11 {
43     }
44 mlethuil 1.1
45    
46    
47     // ------------ method called once each job just before starting event loop ------------
48     void TotoAnalyzer::beginJob(const edm::EventSetup&)
49     {
50    
51     // Load Config parameters
52 lethuill 1.11 verbosity = myConfig_.getUntrackedParameter<int>("verbosity", 0);
53     rootFileName_ = myConfig_.getUntrackedParameter<string>("RootFileName","noname.root");
54     isCSA07Soup = myConfig_.getUntrackedParameter<bool>("isCSA07Soup",false);
55     doHLT = myConfig_.getUntrackedParameter<bool>("doHLT",false);
56     doMC = myConfig_.getUntrackedParameter<bool>("doMC",false);
57 lethuill 1.24 doJetMC = myConfig_.getUntrackedParameter<bool>("doJetMC",false);
58     doMETMC = myConfig_.getUntrackedParameter<bool>("doMETMC",false);
59 lethuill 1.17 doPDFInfo = myConfig_.getUntrackedParameter<bool>("doPDFInfo",false);
60 lethuill 1.16 doSignalMuMuGamma = myConfig_.getUntrackedParameter<bool>("doSignalMuMuGamma",false);
61     doSignalTopTop = myConfig_.getUntrackedParameter<bool>("doSignalTopTop",false);
62 lethuill 1.28 doPhotonConversionMC = myConfig_.getUntrackedParameter<bool>("doPhotonConversionMC",false);
63     drawMCTree = myConfig_.getUntrackedParameter<bool>("drawMCTree",false);
64 lethuill 1.15 doPrimaryVertex = myConfig_.getUntrackedParameter<bool>("doPrimaryVertex",false);
65 lethuill 1.11 doTrack = myConfig_.getUntrackedParameter<bool>("doTrack",false);
66     doJet = myConfig_.getUntrackedParameter<bool>("doJet",false);
67     doMuon = myConfig_.getUntrackedParameter<bool>("doMuon",false);
68     doElectron = myConfig_.getUntrackedParameter<bool>("doElectron",false);
69     doPhoton = myConfig_.getUntrackedParameter<bool>("doPhoton",false);
70     doCluster = myConfig_.getUntrackedParameter<bool>("doCluster",false);
71 lethuill 1.28 doPhotonConversion = myConfig_.getUntrackedParameter<bool>("doPhotonConversion",false);
72     doPhotonIsolation = myConfig_.getUntrackedParameter<bool>("doPhotonIsolation",false);
73 lethuill 1.13 doMET = myConfig_.getUntrackedParameter<bool>("doMET",false);
74 mlethuil 1.7
75 mlethuil 1.1 nTotEvt_ = 0;
76    
77     // initialize root output file
78     if(verbosity>0) cout << "New RootFile " << rootFileName_.c_str() << " is created" << endl;
79     rootFile_ = new TFile(rootFileName_.c_str(), "recreate");
80     rootFile_->cd();
81 mlethuil 1.5
82     runInfos_ = new TRootRun();
83     runTree_ = new TTree("runTree", "Global Run Infos");
84     runTree_->Branch ("runInfos", "TRootRun", &runInfos_);
85    
86 mlethuil 1.1 rootEvent = 0;
87 mlethuil 1.5 eventTree_ = new TTree("eventTree", "Event Infos");
88     eventTree_->Branch ("Event", "TRootEvent", &rootEvent);
89    
90     if(doHLT)
91     {
92 lethuill 1.13 hltAnalyzer_ = new HLTAnalyzer(producersNames_);
93 mlethuil 1.5 hltAnalyzer_->setVerbosity(verbosity);
94     }
95    
96 mlethuil 1.1 if(doMC)
97     {
98 lethuill 1.12 if(verbosity>0) cout << "MC Particles info will be added to rootuple" << endl;
99 lethuill 1.18 mcParticles = new TClonesArray("TRootMCParticle", 1000);
100 mlethuil 1.5 eventTree_->Branch ("MCParticles", "TClonesArray", &mcParticles);
101 mlethuil 1.1 }
102    
103 lethuill 1.24 if(doJetMC)
104     {
105     if(verbosity>0) cout << "genJets info will be added to rootuple" << endl;
106     genJets = new TClonesArray("TRootParticle", 1000);
107     eventTree_->Branch ("genJets", "TClonesArray", &genJets);
108     }
109    
110     if(doMETMC)
111     {
112     if(verbosity>0) cout << "genMETs info will be added to rootuple" << endl;
113     genMETs = new TClonesArray("TRootParticle", 1000);
114     eventTree_->Branch ("genMETs", "TClonesArray", &genMETs);
115     }
116    
117 lethuill 1.16 if(doSignalMuMuGamma)
118     {
119     if(verbosity>0) cout << "MC info for Z -> mu mu gamma will be added to rootuple" << endl;
120     rootMuMuGammaEvent = 0;
121     cout << "Create MuMuGamma Branch" << endl;
122     eventTree_->Branch ("MuMuGamma", "TRootSignalEvent", &rootMuMuGammaEvent);
123     }
124    
125     if(doSignalTopTop)
126     {
127     if(verbosity>0) cout << "MC info for Top Top will be added to rootuple" << endl;
128     rootMCTopTop = new TClonesArray("TRootTopTop", 1000);
129     eventTree_->Branch ("rootMCTopTop", "TClonesArray", &rootMCTopTop);
130     }
131    
132 mlethuil 1.7 if(doPhotonConversionMC)
133     {
134     if(verbosity>0) cout << "Converted MC Photons info will be added to rootuple" << endl;
135     mcPhotons = new TClonesArray("TRootMCPhoton", 1000);
136     eventTree_->Branch ("MCPhotons", "TClonesArray", &mcPhotons);
137     }
138    
139 lethuill 1.25 if(doPrimaryVertex)
140     {
141     if(verbosity>0) cout << "Vertices info will be added to rootuple" << endl;
142     vertices = new TClonesArray("TRootVertex", 1000);
143     eventTree_->Branch ("Vertices", "TClonesArray", &vertices);
144     }
145    
146 mlethuil 1.1 if(doTrack)
147     {
148     if(verbosity>0) cout << "Tracks info will be added to rootuple" << endl;
149 mlethuil 1.4 tracks = new TClonesArray("TRootTrack", 1000);
150 mlethuil 1.5 eventTree_->Branch ("Tracks", "TClonesArray", &tracks);
151 mlethuil 1.1 }
152    
153     if(doJet)
154     {
155     if(verbosity>0) cout << "Jets info will be added to rootuple" << endl;
156     jets = new TClonesArray("TRootJet", 1000);
157 mlethuil 1.5 eventTree_->Branch ("Jets", "TClonesArray", &jets);
158 mlethuil 1.1 }
159    
160     if(doMuon)
161     {
162     if(verbosity>0) cout << "Muons info will be added to rootuple" << endl;
163     muons = new TClonesArray("TRootMuon", 1000);
164 mlethuil 1.5 eventTree_->Branch ("Muons", "TClonesArray", &muons);
165 mlethuil 1.1 }
166    
167     if(doElectron)
168     {
169     if(verbosity>0) cout << "Electrons info will be added to rootuple" << endl;
170     electrons = new TClonesArray("TRootElectron", 1000);
171 mlethuil 1.5 eventTree_->Branch ("Electrons", "TClonesArray", &electrons);
172 mlethuil 1.1 }
173    
174     if(doPhoton)
175     {
176     if(verbosity>0) cout << "Photons info will be added to rootuple" << endl;
177 lethuill 1.11 photons = new TClonesArray("TRootPhoton", 1000);
178     eventTree_->Branch ("Photons", "TClonesArray", &photons);
179 mlethuil 1.1 }
180    
181     if(doCluster)
182     {
183     if(verbosity>0) cout << "ECAL Clusters info will be added to rootuple" << endl;
184     clusters = new TClonesArray("TRootCluster", 1000);
185 mlethuil 1.5 eventTree_->Branch ("BasicClusters", "TClonesArray", &clusters);
186 mlethuil 1.1 superClusters = new TClonesArray("TRootSuperCluster", 1000);
187 mlethuil 1.5 eventTree_->Branch ("SuperClusters", "TClonesArray", &superClusters);
188 mlethuil 1.1 }
189 mlethuil 1.3
190     if(doPhotonConversion)
191     {
192     if(verbosity>0) cout << "Conversion Tracks info will be added to rootuple" << endl;
193 mlethuil 1.8 conversionTracks = new TClonesArray("TRootTrack", 1000);
194 mlethuil 1.5 eventTree_->Branch ("ConversionTracks", "TClonesArray", &conversionTracks);
195 mlethuil 1.9
196     conversionLikelihoodCalculator_ = new ConversionLikelihoodCalculator();
197 lethuill 1.11 std::string weightsString = myConfig_.getUntrackedParameter<string>("conversionLikelihoodWeightsFile","RecoEgamma/EgammaTools/data/TMVAnalysis_Likelihood.weights.txt");
198 mlethuil 1.9 edm::FileInPath weightsFile(weightsString.c_str() );
199     conversionLikelihoodCalculator_->setWeightsFile(weightsFile.fullPath().c_str());
200 lethuill 1.14 }
201 mlethuil 1.9
202 lethuill 1.14 if(doMET)
203     {
204     if(verbosity>0) cout << "MET info will be added to rootuple" << endl;
205     met = new TClonesArray("TRootMET", 1000);
206     eventTree_->Branch ("MET", "TClonesArray", &met);
207 mlethuil 1.3 }
208 lethuill 1.14
209 mlethuil 1.1 }
210    
211    
212     // ------------ method called once each job just after ending the event loop ------------
213     void TotoAnalyzer::endJob()
214     {
215 lethuill 1.23 // Trigger Summary Tables
216     if(doHLT)
217     {
218     cout << "Trigger Summary Tables" << endl;
219     hltAnalyzer_ ->copySummary(runInfos_);
220     hltAnalyzer_->printStats();
221     }
222    
223 mlethuil 1.5 runTree_->Fill();
224    
225 mlethuil 1.1 std::cout << "Total number of events: " << nTotEvt_ << std::endl;
226     std::cout << "Closing rootfile " << rootFile_->GetName() << std::endl;
227     rootFile_->Write();
228     rootFile_->Close();
229 mlethuil 1.5
230 mlethuil 1.9 if(doPhotonConversion) delete conversionLikelihoodCalculator_;
231 lethuill 1.28 if(doHLT) delete hltAnalyzer_;
232 mlethuil 1.1 }
233    
234    
235    
236     // ------------ method called to for each event ------------
237     void TotoAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
238     {
239    
240     rootFile_->cd();
241     nTotEvt_++;
242     if( (verbosity>1) || (verbosity>0 && nTotEvt_%10==0 && nTotEvt_<=100) || (verbosity>0 && nTotEvt_%100==0 && nTotEvt_>100) )
243 lethuill 1.10 cout << endl << endl
244     << "####### TotoAnalyzer - Cumulated Events " << nTotEvt_
245     << " - Run " << iEvent.id().run()
246     << " - Event " << iEvent.id().event()
247     << " #######" << endl;
248    
249 mlethuil 1.1 // Global Event Infos
250     rootEvent = new TRootEvent();
251     rootEvent->setNb(nTotEvt_);
252 lethuill 1.20 rootEvent->setEventId(iEvent.id().event());
253     rootEvent->setRunId(iEvent.id().run());
254 mlethuil 1.1
255 lethuill 1.11 /*
256 mlethuil 1.6 // CSA07 Process Id and Event Weight
257     if(isCSA07Soup)
258     {
259     edm::Handle< double> weightHandle;
260     iEvent.getByLabel ("csaweightproducer","weight", weightHandle);
261     double weight = * weightHandle;
262     int processId = csa07::csa07ProcessId(iEvent, 1000., "csaweightproducer");
263     char * pname= csa07::csa07ProcessName(processId);
264     if(verbosity>1) cout << "CSA07 Soup - id=" << processId << " - "<< pname << " - weight=" << weight << endl;
265     rootEvent->setCsa07id(processId);
266     rootEvent->setCsa07weight(weight);
267     rootEvent->setCsa07process(pname);
268     }
269 lethuill 1.13 */
270 mlethuil 1.5
271 mlethuil 1.6
272 mlethuil 1.5 // Trigger
273 lethuill 1.13 rootEvent->setGlobalHLT(true);
274 mlethuil 1.5 if(doHLT)
275     {
276 lethuill 1.13 cout << endl << "Get TriggerResults..." << endl;
277 mlethuil 1.5 if (nTotEvt_==1) hltAnalyzer_->init(iEvent, rootEvent);
278     hltAnalyzer_->process(iEvent, rootEvent);
279     }
280 lethuill 1.10 //if ( ! rootEvent->passGlobalHLT() ) return;
281 mlethuil 1.5
282    
283 mlethuil 1.1 // MC Info
284     if(doMC)
285     {
286 lethuill 1.13 if(verbosity>1) cout << endl << "Analysing MC info..." << endl;
287     MCAnalyzer* myMCAnalyzer = new MCAnalyzer(myConfig_, producersNames_);
288     myMCAnalyzer->SetVerbosity(verbosity);
289     if (drawMCTree) myMCAnalyzer->DrawMCTree(iEvent, iSetup, myConfig_, producersNames_);
290 lethuill 1.17 if ( dataType_=="RECO" && doPDFInfo ) myMCAnalyzer->PDFInfo(iEvent, rootEvent);
291 lethuill 1.16 myMCAnalyzer->ProcessMCParticle(iEvent, mcParticles);
292 lethuill 1.24 if(doJetMC) myMCAnalyzer->ProcessGenJets(iEvent, genJets);
293     if(doMETMC) myMCAnalyzer->ProcessGenMETs(iEvent, genMETs);
294 lethuill 1.16 if (doSignalMuMuGamma)
295 lethuill 1.14 {
296 lethuill 1.16 rootMuMuGammaEvent = new TRootSignalEvent();
297     myMCAnalyzer->ProcessMuMuGammaEvent(iEvent, rootMuMuGammaEvent);
298 lethuill 1.14 }
299 lethuill 1.16 if (doSignalTopTop) myMCAnalyzer->ProcessTopTopEvent(iEvent, rootMCTopTop);
300 lethuill 1.13 if (doPhotonConversionMC) myMCAnalyzer->ProcessConvertedPhoton(iEvent, mcPhotons);
301 mlethuil 1.1 delete myMCAnalyzer;
302     }
303 lethuill 1.12
304 mlethuil 1.1
305     // Get Primary Vertices
306 lethuill 1.15 if(doPrimaryVertex)
307     {
308     if(verbosity>1) cout << endl << "Analysing primary vertices collection..." << endl;
309     VertexAnalyzer* myVertexAnalyzer = new VertexAnalyzer(producersNames_, verbosity);
310 lethuill 1.27 myVertexAnalyzer->Process(iEvent, vertices);
311     myVertexAnalyzer->SelectPrimary(rootEvent, vertices);
312 lethuill 1.15 delete myVertexAnalyzer;
313     }
314 lethuill 1.11
315 mlethuil 1.1 // Tracks
316     if(doTrack)
317     {
318 lethuill 1.11 if(verbosity>1) cout << endl << "Analysing tracks collection..." << endl;
319 lethuill 1.13 TrackAnalyzer* myTrackAnalyzer = new TrackAnalyzer(producersNames_, verbosity);
320     myTrackAnalyzer->Process(iEvent, tracks);
321     delete myTrackAnalyzer;
322 mlethuil 1.1 }
323    
324 lethuill 1.11
325 mlethuil 1.1 // Calo Jet
326     if(doJet)
327     {
328 lethuill 1.11 if(verbosity>1) cout << endl << "Analysing jets collection..." << endl;
329 lethuill 1.16 JetAnalyzer* myJetAnalyzer = new JetAnalyzer(producersNames_, myConfig_, verbosity);
330 lethuill 1.13 myJetAnalyzer->Process(iEvent, jets);
331     delete myJetAnalyzer;
332 mlethuil 1.1 }
333    
334    
335     // Muons
336     if(doMuon)
337     {
338 lethuill 1.11 if(verbosity>1) cout << endl << "Analysing muons collection..." << endl;
339 lethuill 1.16 MuonAnalyzer* myMuonAnalyzer = new MuonAnalyzer(producersNames_, myConfig_, verbosity);
340 lethuill 1.29 if(doPrimaryVertex) myMuonAnalyzer->initIPCalculator(iEvent, iSetup, rootEvent);
341 lethuill 1.13 myMuonAnalyzer->Process(iEvent, muons);
342     delete myMuonAnalyzer;
343 mlethuil 1.1 }
344 lethuill 1.14
345 mlethuil 1.1
346 lethuill 1.14 // Lazy Tools to calculate Cluster shape variables
347     EcalClusterLazyTools* lazyTools = 0;
348 lethuill 1.16 if( (dataType_=="RECO" || dataType_=="AOD" || dataType_=="PATAOD") && ( doElectron || doPhoton || doCluster) )
349 lethuill 1.14 {
350     if(verbosity>1) cout << endl << "Loading egamma LazyTools..." << endl;
351     edm::InputTag reducedBarrelEcalRecHitCollection_ = producersNames_.getParameter<edm::InputTag>("reducedBarrelEcalRecHitCollection");
352     edm::InputTag reducedEndcapEcalRecHitCollection_ = producersNames_.getParameter<edm::InputTag>("reducedEndcapEcalRecHitCollection");
353 lethuill 1.16 // FIXME - Test availability of reducedEcalRecHits...
354 lethuill 1.14 lazyTools = new EcalClusterLazyTools( iEvent, iSetup, reducedBarrelEcalRecHitCollection_, reducedEndcapEcalRecHitCollection_ );
355     }
356 lethuill 1.16
357 mlethuil 1.1 // Electrons
358     if(doElectron)
359     {
360 lethuill 1.11 if(verbosity>1) cout << endl << "Analysing electrons collection..." << endl;
361 lethuill 1.16 ElectronAnalyzer* myElectronAnalyzer = new ElectronAnalyzer(producersNames_, myConfig_, verbosity);
362 lethuill 1.14 myElectronAnalyzer->Process(iEvent, electrons, *lazyTools);
363 lethuill 1.13 delete myElectronAnalyzer;
364 mlethuil 1.1 }
365 lethuill 1.22
366 lethuill 1.11
367 mlethuil 1.1 // Photons
368     if(doPhoton)
369     {
370 lethuill 1.11 if(verbosity>1) cout << endl << "Analysing photons collection..." << endl;
371 lethuill 1.21 PhotonAnalyzer* myPhotonAnalyzer = new PhotonAnalyzer(producersNames_, myConfig_, verbosity);
372     // FIXME - conversionTracks may not be present...
373 lethuill 1.22 myPhotonAnalyzer->Process(iEvent, iSetup, rootEvent, photons, conversionTracks, conversionLikelihoodCalculator_, *lazyTools);
374 mlethuil 1.1 delete myPhotonAnalyzer;
375     }
376 lethuill 1.11
377    
378 mlethuil 1.1 // Ecal Clusters
379     if(doCluster)
380     {
381 lethuill 1.11 if(verbosity>1) cout << endl << "Analysing BasicClusters collection..." << endl;
382 lethuill 1.24 ClusterAnalyzer* myClusterAnalyzer = new ClusterAnalyzer(producersNames_, verbosity);
383     //myClusterAnalyzer->SetVerbosity(verbosity);
384 lethuill 1.14 myClusterAnalyzer->Process(iEvent, rootEvent, *lazyTools, clusters, "hybridSuperClusters","hybridBarrelBasicClusters", 110);
385     myClusterAnalyzer->Process(iEvent, rootEvent, *lazyTools, clusters, "multi5x5BasicClusters", "multi5x5EndcapBasicClusters", 320);
386 mlethuil 1.1 delete myClusterAnalyzer;
387 lethuill 1.11
388     if(verbosity>1) cout << endl << "Analysing SuperClusters collection..." << endl;
389 lethuill 1.24 SuperClusterAnalyzer* mySClusterAnalyzer = new SuperClusterAnalyzer(producersNames_, verbosity);
390     //mySClusterAnalyzer->SetVerbosity(verbosity);
391 mlethuil 1.1 mySClusterAnalyzer->Process(iEvent, rootEvent, superClusters, "hybridSuperClusters","",210);
392     mySClusterAnalyzer->Process(iEvent, rootEvent, superClusters, "correctedHybridSuperClusters","",211);
393 lethuill 1.11 mySClusterAnalyzer->Process(iEvent, rootEvent, superClusters, "multi5x5SuperClusters","multi5x5EndcapSuperClusters",320);
394     mySClusterAnalyzer->Process(iEvent, rootEvent, superClusters, "multi5x5SuperClustersWithPreshower","",323);
395     mySClusterAnalyzer->Process(iEvent, rootEvent, superClusters, "correctedMulti5x5SuperClustersWithPreshower","",322);
396 mlethuil 1.1 delete mySClusterAnalyzer;
397     }
398    
399    
400     if(doCluster)
401     {
402     ClusterAssociator* myClusterAssociator = new ClusterAssociator();
403     myClusterAssociator->SetVerbosity(verbosity);
404     myClusterAssociator->Process(superClusters, clusters);
405     //myClusterAssociator->PrintSuperClusters(superClusters, clusters,0); // 0 to print all types SC
406     delete myClusterAssociator;
407     }
408 lethuill 1.11
409    
410 mlethuil 1.1 if(doPhoton && doCluster)
411     {
412     PhotonAssociator* myPhotonAssociator = new PhotonAssociator();
413     myPhotonAssociator->SetVerbosity(verbosity);
414 lethuill 1.11 myPhotonAssociator->AssociateSuperCluster(photons, superClusters);
415 mlethuil 1.1 delete myPhotonAssociator;
416     }
417    
418    
419 lethuill 1.11 if(doPhoton && doPhotonIsolation)
420 mlethuil 1.1 {
421 lethuill 1.11 if(verbosity>1) cout << endl << "Calculating Photon isolation..." << endl;
422 mlethuil 1.1
423     Float_t ecalIslandIsolation;
424     Float_t ecalDoubleConeIsolation;
425     Float_t hcalRecHitIsolation;
426 mlethuil 1.4 Float_t isoTracks;
427     Int_t isoNTracks;
428     TRootPhoton* localPhoton;
429    
430 lethuill 1.11 PhotonIsolator* myPhotonIsolator = new PhotonIsolator(&myConfig_, &producersNames_);
431     for (int iphoton=0; iphoton<photons->GetEntriesFast(); iphoton++)
432 mlethuil 1.1 {
433 lethuill 1.11 localPhoton = (TRootPhoton*)photons->At(iphoton);
434 mlethuil 1.4
435 mlethuil 1.1 ecalIslandIsolation=-1.;
436 mlethuil 1.4 if (doCluster) ecalIslandIsolation = myPhotonIsolator->EcalIslandIsolation(localPhoton, superClusters, clusters);
437    
438 mlethuil 1.1 ecalDoubleConeIsolation=-1.;
439 mlethuil 1.4 if (doCluster) ecalDoubleConeIsolation = myPhotonIsolator->EcalDoubleConeIsolation(localPhoton, superClusters, clusters);
440    
441     hcalRecHitIsolation=-1.;
442 lethuill 1.11 //FIXME - Test HCAL rechits availability - LoadHcalRecHits() returning bool
443     myPhotonIsolator->LoadHcalRecHits(iEvent, iSetup);
444     hcalRecHitIsolation = myPhotonIsolator->HcalRecHitIsolation(localPhoton);
445 mlethuil 1.4
446     isoTracks=-1.;
447     isoNTracks=-1;
448     if(doTrack) isoTracks = myPhotonIsolator->TrackerIsolation(localPhoton, tracks, isoNTracks);
449    
450     localPhoton->setIsolation(ecalIslandIsolation, ecalDoubleConeIsolation, hcalRecHitIsolation, isoTracks, isoNTracks);
451 lethuill 1.11 if(verbosity>4) cout << " After isolation - ["<< setw(3) << iphoton << "] " << *localPhoton << endl;
452 mlethuil 1.1 }
453     delete myPhotonIsolator;
454     }
455 lethuill 1.24
456    
457 lethuill 1.11 // Print Photons / SuperClusters / BasicClusters arborescence
458     if(doPhoton)
459     {
460     PhotonAssociator* myPhotonAssociator = new PhotonAssociator();
461     if(verbosity>2) myPhotonAssociator->FullPrintPhotons(photons,superClusters,clusters,0);
462     delete myPhotonAssociator;
463     }
464 lethuill 1.13
465    
466     // MET
467     if(doMET)
468     {
469     if(verbosity>1) cout << endl << "Analysing Missing Et..." << endl;
470 lethuill 1.16 METAnalyzer* myMETAnalyzer = new METAnalyzer(producersNames_, myConfig_, verbosity);
471 lethuill 1.14 myMETAnalyzer->Process(iEvent, met);
472 lethuill 1.13 delete myMETAnalyzer;
473     }
474 lethuill 1.24
475    
476 lethuill 1.18 // Associate recoParticles to mcParticles
477     if(doMC)
478     {
479 lethuill 1.19 MCAssociator* myMCAssociator = new MCAssociator(producersNames_, verbosity);
480     myMCAssociator->init(iEvent, mcParticles);
481 lethuill 1.24 if(doPhoton) myMCAssociator->matchGenParticlesTo(photons);
482     if(doElectron) myMCAssociator->matchGenParticlesTo(electrons);
483     if(doMuon) myMCAssociator->matchGenParticlesTo(muons);
484     if(doMET) myMCAssociator->matchGenParticlesTo(met);
485     if(doJet) myMCAssociator->matchGenParticlesTo(jets);
486     if(doJet && doJetMC) myMCAssociator->processGenJets(genJets, jets);
487     if(verbosity>4) cout << endl << "Printing recoParticles / mcParticles associations... " << endl;
488     if(verbosity>4 && doPhoton) myMCAssociator->printParticleAssociation(photons);
489     if(verbosity>4 && doElectron) myMCAssociator->printParticleAssociation(electrons);
490     if(verbosity>4 && doMuon) myMCAssociator->printParticleAssociation(muons);
491     if(verbosity>4 && doMET) myMCAssociator->printParticleAssociation(met);
492     if(verbosity>4 && doJet) myMCAssociator->printJetAssociation(jets);
493 lethuill 1.19 delete myMCAssociator;
494 lethuill 1.18 }
495    
496    
497 lethuill 1.11 if(verbosity>1) cout << endl << "Filling rootuple..." << endl;
498 mlethuil 1.5 eventTree_->Fill();
499 lethuill 1.11 if(verbosity>1) cout << endl << "Deleting objects..." << endl;
500 mlethuil 1.1 delete rootEvent;
501 lethuill 1.12 if(doMC) (*mcParticles).Delete();
502 lethuill 1.28 if(doJetMC) (*genJets).Delete();
503     if(doMETMC) (*genMETs).Delete();
504 lethuill 1.16 if(doSignalMuMuGamma) delete rootMuMuGammaEvent;
505     if(doSignalTopTop) (*rootMCTopTop).Delete();
506 lethuill 1.14 if(doPhotonConversionMC) (*mcPhotons).Delete();
507 lethuill 1.25 if(doPrimaryVertex) (*vertices).Delete();
508 mlethuil 1.1 if(doTrack) (*tracks).Delete();
509     if(doJet) (*jets).Delete();
510     if(doMuon) (*muons).Delete();
511     if(doElectron) (*electrons).Delete();
512 lethuill 1.11 if(doPhoton) (*photons).Delete();
513 mlethuil 1.1 if(doCluster) (*clusters).Delete();
514     if(doCluster) (*superClusters).Delete();
515 lethuill 1.14 if(doPhotonConversion) (*conversionTracks).Delete();
516     if(doMET) (*met).Delete();
517 lethuill 1.11 if(verbosity>0) cout << endl;
518 mlethuil 1.1 }
519