ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/kiesel/TreeWriter/treeWriter.cc
(Generate patch)

Comparing UserCode/kiesel/TreeWriter/treeWriter.cc (file contents):
Revision 1.17 by kiesel, Fri Apr 19 10:13:02 2013 UTC vs.
Revision 1.32 by kiesel, Tue May 7 19:41:48 2013 UTC

# Line 70 | Line 70 | std::vector<Type>* getVectorFromMap( map
70          return vec;
71   }
72  
73 + float deltaPhi( float phi1, float phi2) {
74 +        float result = phi1 - phi2;
75 +        while (result > M_PI) result -= 2*M_PI;
76 +        while (result <= -M_PI) result += 2*M_PI;
77 +        return result;
78 + }
79 +
80   // useful functions
81   float deltaR( const TLorentzVector& v1, const TLorentzVector& v2 ) {
82          // deltaR  = sqrt ( deltaEta^2 + deltaPhi^2 )
83 <        return sqrt(pow(v1.Eta() - v2.Eta(), 2) + pow(v1.Phi() - v2.Phi(), 2) );
83 >        return sqrt(pow(v1.Eta() - v2.Eta(), 2) + pow(deltaPhi(v1.Phi(),v2.Phi()), 2) );
84   }
85  
86   float effectiveAreaElectron( float eta ) {
# Line 252 | Line 259 | void TreeWriter::Loop() {
259          tree->Branch("type1metPhi", &type1met_phi, "type1metPhi/F");
260          tree->Branch("ht", &ht, "ht/F");
261          tree->Branch("nVertex", &nVertex, "nVertex/I");
262 <        tree->Branch("pu_weight", &pu_weight, "pu_weight/F");
262 >        tree->Branch("weight", &weight, "weight/D");
263 >        tree->Branch("genElectron", &genElectron);
264 >        tree->Branch("genPhoton", &genPhoton);
265  
266 <
258 <        for (unsigned long jentry=0; jentry < processNEvents; ++jentry) {
266 >        for (long jentry=0; jentry < processNEvents; ++jentry) {
267                  if ( loggingVerbosity>1 || jentry%reportEvery==0 )
268                          std::cout << jentry << " / " << processNEvents << std :: endl;
269                  inputTree->LoadTree( jentry );
# Line 265 | Line 273 | void TreeWriter::Loop() {
273                  jet.clear();
274                  electron.clear();
275                  muon.clear();
276 +                genElectron.clear();
277 +                genPhoton.clear();
278                  ht = 0;
279  
280                  // weights
281                  if (pileupHisto == 0) {
282 <                        pu_weight = 1.;
282 >                        weight = 1.;
283                  } else {
284                          float trueNumInteractions = -1;
285                          for( susy::PUSummaryInfoCollection::const_iterator iBX = event->pu.begin();
# Line 277 | Line 287 | void TreeWriter::Loop() {
287                                  if (iBX->BX == 0)
288                                          trueNumInteractions = iBX->trueNumInteractions;
289                          }
290 <                        pu_weight = pileupHisto->GetBinContent( pileupHisto->FindBin( trueNumInteractions ) );
290 >                        weight = pileupHisto->GetBinContent( pileupHisto->FindBin( trueNumInteractions ) );
291                  }
292  
293                  // get ak5 jets
# Line 288 | Line 298 | void TreeWriter::Loop() {
298  
299                  for(std::vector<susy::Photon>::iterator it = photonVector.begin();
300                                  it != photonVector.end(); ++it ) {
301 <                        if( !(it->isEB() || it->isEE()) && skim )
301 >                        if( !(it->isEE() || it->isEB()) && it->momentum.Pt()<20 && it->isEBEtaGap() && it->isEBPhiGap() && it->isEERingGap() && it->isEEDeeGap() && it->isEBEEGap() && skim )
302                                  continue;
303                          tree::Photon thisphoton;
294                        thisphoton.pt = getPtFromMatchedJet( *it, jetVector, loggingVerbosity );
304  
305                          thisphoton.chargedIso = chargedHadronIso_corrected(*it, event->rho25);
306                          thisphoton.neutralIso = neutralHadronIso_corrected(*it, event->rho25);
307                          thisphoton.photonIso = photonIso_corrected(*it, event->rho25);
308  
309 <                        bool loose_photon_barrel = thisphoton.pt>20
301 <                                && it->isEB()
302 <                                && it->passelectronveto
309 >                        bool loose_photon_barrel = it->isEB()
310                                  && it->hadTowOverEm<0.05
311                                  && it->sigmaIetaIeta<0.012
312                                  && thisphoton.chargedIso<2.6
313                                  && thisphoton.neutralIso<3.5+0.04*thisphoton.pt
314                                  && thisphoton.photonIso<1.3+0.005*thisphoton.pt;
315 <                        bool loose_photon_endcap = thisphoton.pt > 20
316 <                                && it->isEE()
310 <                                && it->passelectronveto
315 >
316 >                        bool loose_photon_endcap = it->isEE()
317                                  && it->hadTowOverEm<0.05
318                                  && it->sigmaIetaIeta<0.034
319                                  && thisphoton.chargedIso<2.3
320                                  && thisphoton.neutralIso<2.9+0.04*thisphoton.pt;
321 <                        if(!(loose_photon_endcap || loose_photon_barrel || thisphoton.pt > 75 ) && skim )
321 >
322 >                        thisphoton.ptJet = getPtFromMatchedJet( *it, jetVector, loggingVerbosity );
323 >                        if(!(loose_photon_endcap || loose_photon_barrel || thisphoton.ptJet > 75 ) && skim )
324                                  continue;
325 +                        thisphoton.pt = it->momentum.Pt();
326                          thisphoton.eta = it->momentum.Eta();
327                          thisphoton.phi = it->momentum.Phi();
328                          thisphoton.r9 = it->r9;
# Line 321 | Line 330 | void TreeWriter::Loop() {
330                          thisphoton.hadTowOverEm = it->hadTowOverEm;
331                          thisphoton.pixelseed = it->nPixelSeeds;
332                          thisphoton.conversionSafeVeto = it->passelectronveto;
333 +                        thisphoton.genInformation = 0;
334                          photon.push_back( thisphoton );
335                          if( loggingVerbosity > 2 )
336                                  std::cout << " p_T, gamma = " << thisphoton.pt << std::endl;
# Line 347 | Line 357 | void TreeWriter::Loop() {
357                                  scale = it->jecScaleFactors.find("L2L3")->second;
358                          TLorentzVector corrP4 = scale * it->momentum;
359  
360 <                        if(std::abs(corrP4.Eta()) > 3.0 && skim ) continue;
360 >                        // Calculate HT.
361 >                        // The definiton differs from the saved jet, since trigger is described better
362 >                        if( std::abs( corrP4.Eta() ) < 3 && corrP4.Pt() > 40 )
363 >                                ht += thisjet.pt;
364 >
365 >                        if(std::abs(corrP4.Eta()) > 2.6 && skim ) continue;
366                          if(corrP4.Pt() < 30 && skim ) continue;
367                          thisjet.pt = corrP4.Pt();
368                          thisjet.eta = corrP4.Eta();
# Line 369 | Line 384 | void TreeWriter::Loop() {
384                                  std::cout << " p_T, jet = " << thisjet.pt << std::endl;
385  
386                          jet.push_back( thisjet );
372                        ht += thisjet.pt;
387                  }// for jet
388                  if( jet.size() < 2 && skim )
389                          continue;
# Line 377 | Line 391 | void TreeWriter::Loop() {
391                  if( loggingVerbosity > 1 )
392                          std::cout << "Found " << jet.size() << " jets" << std::endl;
393  
394 +                if( ht < 450 && skim)
395 +                        continue;
396 +
397 +
398  
399                  // met
400                  std::map<TString, susy::MET>::iterator met_it = event->metMap.find("pfMet");
# Line 403 | Line 421 | void TreeWriter::Loop() {
421                          // use veto electrons
422                          if( it->momentum.Pt() < 20  || it->momentum.Pt() > 1e6 )
423                                  continue; // spike rejection
424 <                        float iso = ( it->chargedHadronIso + max(it->neutralHadronIso+it->photonIso
407 <                                                                                                                - effectiveAreaElectron(it->momentum.Eta())*event->rho25, (Float_t)0. )
424 >                        float iso = ( it->chargedHadronIso + max(it->neutralHadronIso+it->photonIso - effectiveAreaElectron(it->momentum.Eta())*event->rho25, (float)0. )
425                                                  ) / it->momentum.Pt();
426                          float d0 = d0correction( *it, *event );
427                          float dZ = std::abs( dZcorrection( *it, *event ) );
# Line 459 | Line 476 | void TreeWriter::Loop() {
476                  // vertices
477                  nVertex = event->vertices.size();
478  
479 <                if( ht < 450 && skim)
480 <                        continue;
481 <
479 >                tree::Particle thisGenParticle;
480 >                for( std::vector<susy::Particle>::iterator it = event->genParticles.begin(); it != event->genParticles.end(); ++it ) {
481 >                        if( it->momentum.Pt() < 20 ) continue;
482 >                        thisGenParticle.pt = it->momentum.Pt();
483 >                        thisGenParticle.eta = it->momentum.Eta();
484 >                        thisGenParticle.phi = it->momentum.Phi();
485 >                        switch( std::abs(it->pdgId) ) {
486 >                                case 22: // photon
487 >                                        genPhoton.push_back( thisGenParticle );
488 >                                        break;
489 >                                case 11: // electron
490 >                                        // Demand a W boson as mother particle of electron
491 >                                        if( abs(event->genParticles[it->motherIndex].pdgId) == 24 )
492 >                                                genElectron.push_back( thisGenParticle );
493 >                                        break;
494 >                        }
495 >                }
496  
497                  tree->Fill();
498          } // for jentry

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines