ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/rootEWKanalyzer/src/baseClass.C
(Generate patch)

Comparing UserCode/rootEWKanalyzer/src/baseClass.C (file contents):
Revision 1.2 by jueugste, Tue Jul 20 15:32:43 2010 UTC vs.
Revision 1.5 by jueugste, Mon Nov 15 09:51:22 2010 UTC

# Line 40 | Line 40 | double baseClass::multiply(double a, dou
40    return c;
41   }
42  
43 + void baseClass::scaleHisto(TH1D* histo, double factor) {
44 +  int binnumber=histo->GetNbinsX();
45 +  for(int i=0;i<=binnumber+1;i++) {
46 +    double bincontent=histo->GetBinContent(i);
47 +    double newbincontent=bincontent*factor;
48 +    histo->SetBinContent(i,newbincontent);
49 +    double binerror=histo->GetBinError(i);
50 +    double newbinerror=binerror*factor;
51 +    histo->SetBinError(i,newbinerror);
52 +  }
53 + }
54 +
55 +
56 +
57 + string baseClass::getFileName() {
58 +  if(tree_ == NULL){
59 +    std::cout << "baseClass::init(): ERROR: tree_ = NULL " << std::endl;
60 + //     return 'NIL';
61 +  }
62 +
63 +  tree_->GetEntry();
64 +  TFile *f = tree_->GetCurrentFile();
65 + //   cout<<"-----------------------------"<<endl;
66 + //   cout<<f->GetName()<<endl;
67 +  string filename = f->GetName();
68 +  cout<<filename<<endl;
69 +  return filename;
70 + }
71 +
72 +
73   void baseClass::getHLTtable() {
74    bool printTriggerTable=true;
75    if(tree_ == NULL){
# Line 50 | Line 80 | void baseClass::getHLTtable() {
80    tree_->GetEntry();
81    TFile *f = tree_->GetCurrentFile();
82  
83 <  cout<<f->GetName()<<endl;;
83 >  cout<<f->GetName()<<endl;
84    TH1I *hlt_stats = (TH1I*)f->Get("analyze/HLTTriggerStats");
55  cout<<"here 3"<<endl;
85  
86    // clear the map
87    if(!HLTmap.empty()) {
# Line 65 | Line 94 | void baseClass::getHLTtable() {
94    }
95   }
96  
97 + void baseClass::GetHLTNames(Int_t& run){
98 +
99 +  TFile *f = tree_->GetCurrentFile();
100 +  TTree* runTree = (TTree*)f->Get("analyze/RunInfo");
101 +  cout<<"here"<<endl;
102 +  std::vector<std::string>* HLTNames;
103 +  if ( !runTree ) {
104 +    std::cerr << "!!! UserAnalysisBase::GetHLTNames "
105 +              << "Couldn't get analyze/RunInfo tree" << std::endl;
106 +    return;
107 +  }
108 +  //TH1I *hlt_stats = (TH1I*)f->Get("analyze/HLTTriggerStats");
109 +  
110 +  /*if ( fVerbose>0 ) */std::cout << "Retrieving HLTNames for run " << run << std::endl;
111 +  runTree->SetBranchAddress("HLTNames",&HLTNames);
112 +  runTree->GetEntryWithIndex(run);
113 +  
114 +  cout<<HLTNames->size()<<endl;
115 +
116 +  for( int i=0; i < HLTNames->size(); i++ ) {
117 +    HLTmap[(*HLTNames)[i]] = i;
118 +    cout<<i<<": "<<(*HLTNames)[i]<<endl;
119 +  }
120 + }
121 +
122 +
123   int baseClass::getHLTtriggerBit(string triggerName) {
124    if(HLTmap.empty()) {
125 <    cerr<<"HLTtrigger: no HLTmap available!"<<endl;
125 >    bool verbose = true;
126 >    if(verbose) cerr<<"HLTtrigger: no HLTmap available!"<<endl;
127      return -1;
128    }
129 +
130    map<string, int>::iterator iter = HLTmap.find(triggerName);
131    //cout<<"HLT bit: "<<iter->second<<endl;  // iter->second is the HLT trigger bit
132    if(iter==HLTmap.end()) {
133 <    cerr<<"HLTtrigger: trigger name "<<triggerName<< " not found!"<<endl;
133 >    //cerr<<"HLTtrigger: trigger name "<<triggerName<< " not found!"<<endl;
134      return -1;
135    }
136    else {
# Line 403 | Line 460 | int baseClass::ElectronPreselection(int
460  
461    //double etaMax_B=1.44;
462    double etaMax_E=2.5;
463 <  double ptMin=20;
463 >  double ptMin=10;
464    double HoverEMin=0.15;
465    double deltaPhiMax=0.15;
466    double deltaEtaMax=0.02;
# Line 443 | Line 500 | int baseClass::ElectronPreselection(int
500    return 0;
501   }
502  
503 + int baseClass::ETHElectronID(int i, NminusOneCutLabel c) {
504 +  // ETH ID
505 +  // returns integer values corresponding
506 +  // to the passed ID cuts
507 +  // 0 fully IDed and isolated
508 +  // 1 delta phi cut not passed
509 +  // 2 delta eta cut not passed
510 +  // 3 |1/E-1/p| cut not passed
511 +  // 4 isolation not passed
512 +  // 5 is electron from conversion
513 +  
514 +  double etaMax_B  = 1.4442;
515 +  double etaMin_E  = 1.5660;
516 +  double etaMax_E  = 2.5000;
517 +  double dPhiMax_B = 0.02;
518 +  double dPhiMax_E = 0.02;
519 +  double dEtaMax_B = 0.004;
520 +  double dEtaMax_E = 0.006;
521 +  double oEoPMax_B = 0.005;
522 +  double oEoPMax_E = 0.007;
523 +  double isoMax_B  = 0.1;
524 +  double isoMax_E  = 0.1;
525 +
526 +  bool cutOn_dPhi = true;
527 +  bool cutOn_dEta = true;
528 +  bool cutOn_oEoP = true;
529 +  bool cutOn_iso  = true;
530 +  bool cutOn_conversion = true;
531 +
532 +  double eta      = ElSCEta[i];
533 +  //double pt       = ElPt[i];
534 +  double dPhiCorr = dphiCorrections(eta, ElPhi[i]);
535 +  double dEtaCorr = detaCorrections(eta, ElPhi[i]);
536 +  double dPhi     = fabs(ElDeltaPhiSuperClusterAtVtx[i]-dPhiCorr);
537 +  double dEta     = fabs(ElDeltaEtaSuperClusterAtVtx[i]-dEtaCorr);
538 +
539 +  double p        = ElTrkMomAtVtx[i];
540 +  double e        = ElCaloEnergy[i];
541 +  double oEoP     = fabs( 1/e - 1/p );
542 +
543 +  double trkIso   = ElDR03TkSumPt[i];
544 +  double scEt     = e * sin(ElTheta[i]);
545 +  double iso      = trkIso / scEt;
546 +
547 +  int hits=1;
548 +  double dist=0.02;
549 +  double cot=0.02;
550 +  bool isConversion;
551 +  if((fabs(ElConvPartnerTrkDist[i])<dist && fabs(ElConvPartnerTrkDCot[i])<cot) /*|| ElNumberOfMissingInnerHits[i]>hits*/) isConversion=true;
552 +  else isConversion=false;
553 +
554 +  if(c==dphi)       cutOn_dPhi       = false;
555 +  if(c==deta)       cutOn_dEta       = false;
556 +  if(c==oeop)       cutOn_oEoP       = false;
557 +  if(c==combiso)    cutOn_iso        = false;
558 +  if(c==conversion) cutOn_conversion = false;
559 +
560 +  if(fabs(eta)<=etaMax_B) {
561 +    if(cutOn_dPhi)       if(dPhi > dPhiMax_B)   return 1;
562 +    if(cutOn_dEta)       if(dEta > dEtaMax_B)   return 2;
563 +    if(cutOn_oEoP)       if(oEoP > oEoPMax_B)   return 3;
564 +    if(cutOn_iso)        if(iso  > isoMax_B)    return 4;
565 +    if(cutOn_conversion) if(isConversion==true) return 5;
566 +    return 0;
567 +  }
568 +  if(fabs(eta)>etaMin_E && fabs(eta)<etaMax_E) {
569 +    if(cutOn_dPhi)       if(dPhi > dPhiMax_E)   return 1;
570 +    if(cutOn_dEta)       if(dEta > dEtaMax_E)   return 2;
571 +    if(cutOn_oEoP)       if(oEoP > oEoPMax_E)   return 3;
572 +    if(cutOn_iso)        if(iso  > isoMax_E)    return 4;
573 +    if(cutOn_conversion) if(isConversion==true) return 5;
574 +    return 0;
575 +  }
576 +  else {
577 +    cout<<"WPelectronID: electron not in ECAL acceptance region!!"<<endl;
578 +    return -1;
579 +  }
580 +  
581 + }
582 +
583   int baseClass::WPElectronID(int i, NminusOneCutLabel c, vector<double> cuts) {
584    // function to ID and isolate electrons
585    // return values (int):
# Line 454 | Line 591 | int baseClass::WPElectronID(int i, Nminu
591    // 5 combIso
592    // 6 conversion
593    
594 <  double etaMax_B=1.44;
595 <  double etaMin_E=1.56;
596 <  double etaMax_E=2.5;
594 >  double etaMax_B=1.4442;
595 >  double etaMin_E=1.5660;
596 >  double etaMax_E=2.5000;
597    double SeeMax_B=cuts[0];
598    double dPhiMax_B=cuts[1];
599    double dEtaMax_B=cuts[2];
# Line 504 | Line 641 | int baseClass::WPElectronID(int i, Nminu
641    double combIso_B = (trkIso + max(0., ecalIso - 1.) + hcalIso) / ElPt[i];
642    double combIso_E = (trkIso + ecalIso + hcalIso) / ElPt[i];
643    bool isConversion;
644 <  if((fabs(ElConvPartnerTrkDist[i])<dist && fabs(ElConvPartnerTrkDCot[i])<cot) || ElNumberOfMissingInnerHits[i]>hits) isConversion=true;
644 >  if((fabs(ElConvPartnerTrkDist[i])<dist && fabs(ElConvPartnerTrkDCot[i])<cot) /*|| ElNumberOfMissingInnerHits[i]>hits*/) isConversion=true;
645    else isConversion=false;
646  
647    if(c==see)  cutOn_See  = false;
# Line 514 | Line 651 | int baseClass::WPElectronID(int i, Nminu
651    if(c==combiso)    cutOn_combIso    = false;
652    if(c==conversion) cutOn_conversion = false;
653  
517
518 //   if(Event==27837545 || Event==73939173 || Event==15512525 || Event==191815699 || Event==29377895 || Event==29377895 || Event==74868952 || Event==76643965 || Event==62016483 || Event==4352136) {
519 //     cout<<eta<<endl;
520 //     cout<<combIso_B<<"/"<<combIso_E<<endl;
521 //     cout<<combIsoMax_B<<"/"<<combIsoMax_E<<endl;
522 //     cout<<"See: "<<See<<endl;
523 //     cout<<"dPhi: "<<dPhi<<endl;
524 //     cout<<"dEta: "<<dEta<<endl;
525 //     cout<<"HoE: "<<HoE<<endl;
526 //     cout<<"pt: "<<ElPt[i]<<endl;
527 //   }
528
654    if(fabs(eta)<=etaMax_B) {
655      if(cutOn_See)  if(See  > SeeMax_B)  return 1;
656      if(cutOn_dPhi) if(dPhi > dPhiMax_B) return 2;
# Line 545 | Line 670 | int baseClass::WPElectronID(int i, Nminu
670      return 0;
671    }
672    else {
673 <    cout<<"WPelectronID: electron not in ECAL acceptance region!!"<<endl;
673 > //     cout<<"WPelectronID: electron not in ECAL acceptance region!!"<<endl;
674      return -1;
675    }
676   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines