Fork me on GitHub

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/IdentificationMap.cc

    r95aa610 rcab38f6  
    6969void IdentificationMap::Init()
    7070{
     71  // read efficiency formula
     72
     73
    7174  TMisIDMap::iterator itEfficiencyMap;
    7275  ExRootConfParam param;
     
    8487    formula->Compile(param[i*3 + 2].GetString());
    8588    pdg = param[i*3].GetInt();
    86     fEfficiencyMap.insert(make_pair(pdg, make_pair(param[i*3 + 1].GetInt(), formula)));
     89    fEfficiencyMap.insert(make_pair(pdg,make_pair(param[i*3 + 1].GetInt(),formula)));
     90
     91   // cout<<param[i*3].GetInt()<<","<<param[i*3+1].GetInt()<<","<<param[i*3 + 2].GetString()<<endl;
     92
    8793  }
    8894
     
    94100    formula->Compile("1.0");
    95101
    96     fEfficiencyMap.insert(make_pair(0, make_pair(0, formula)));
     102    fEfficiencyMap.insert(make_pair(0,make_pair(0,formula)));
    97103  }
    98104
     
    120126    if(formula) delete formula;
    121127  }
     128
    122129}
    123130
     
    127134{
    128135  Candidate *candidate;
    129   Double_t pt, eta, phi, e;
     136  Double_t pt, eta, phi;
    130137  TMisIDMap::iterator itEfficiencyMap;
    131138  pair <TMisIDMap::iterator, TMisIDMap::iterator> range;
    132139  DelphesFormula *formula;
    133   Int_t pdgCodeIn, pdgCodeOut, charge;
    134 
    135   Double_t p, r, total;
     140  Int_t pdgIn, pdgOut, charge;
     141
     142  Double_t P, Pi;
     143
     144 // cout<<"------------ New Event ------------"<<endl;
    136145
    137146  fItInputArray->Reset();
     
    143152    phi = candidatePosition.Phi();
    144153    pt = candidateMomentum.Pt();
    145     e = candidateMomentum.E();
    146    
    147     pdgCodeIn = candidate->PID;
     154    pdgIn = candidate->PID;
    148155    charge = candidate->Charge;
    149156
    150     // first check that PID of this particle is specified in the map
    151     // otherwise, look for PID = 0
    152 
    153     itEfficiencyMap = fEfficiencyMap.find(pdgCodeIn);
    154 
    155     range = fEfficiencyMap.equal_range(pdgCodeIn);
    156     if(range.first == range.second) range = fEfficiencyMap.equal_range(-pdgCodeIn);
     157   // cout<<"------------ New Candidate ------------"<<endl;
     158   // cout<<candidate->PID<<"   "<<pt<<","<<eta<<","<<phi<<endl;
     159
     160    P = 1.0;
     161
     162    //first check that PID of this particle is specified in cfg, if not set look for PID=0
     163
     164    itEfficiencyMap = fEfficiencyMap.find(pdgIn);
     165
     166    range = fEfficiencyMap.equal_range(pdgIn);
     167    if(range.first == range.second) range = fEfficiencyMap.equal_range(-pdgIn);
    157168    if(range.first == range.second) range = fEfficiencyMap.equal_range(0);
    158169
    159     r = gRandom->Uniform();
    160     total = 0.0;
    161 
    162     // loop over sub-map for this PID
    163     for(TMisIDMap::iterator it = range.first; it != range.second; ++it)
     170    //loop over submap for this pid
     171    for (TMisIDMap::iterator it=range.first; it!=range.second; ++it)
    164172    {
     173
    165174      formula = (it->second).second;
    166       pdgCodeOut = (it->second).first;
    167 
    168       p = formula->Eval(pt, eta, phi, e);
    169 
    170       if(total <= r && r < total + p)
     175      pdgOut = (it->second).first;
     176
     177      Pi = formula->Eval(pt, eta);
     178
     179      // check that sum of probabilities does not exceed 1.
     180      P = (P - Pi)/P;
     181
     182      if( P < 0.0 ) continue;
     183      else
    171184      {
    172         // change PID of particle
    173         if(pdgCodeOut != 0) candidate->PID = charge*pdgCodeOut;
    174         fOutputArray->Add(candidate);
    175         break;
     185
     186       //randomly assign a PID to particle according to map
     187       Double_t rndm = gRandom->Uniform();
     188
     189       if(rndm > P)
     190       {
     191         //change PID of particle
     192         if(pdgOut != 0) candidate->PID = charge*pdgOut;
     193         fOutputArray->Add(candidate);
     194         break;
     195       }
    176196      }
    177197
    178       total += p;
    179198    }
    180   }
    181 }
    182 
    183 //------------------------------------------------------------------------------
     199
     200   }
     201
     202}
     203
     204//------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.