Fork me on GitHub

Changeset d870fc5 in git for modules/IdentificationMap.cc


Ignore:
Timestamp:
Dec 21, 2014, 4:03:35 PM (10 years ago)
Author:
Michele Selvaggi <michele.selvaggi@…>
Branches:
ImprovedOutputFile, Timing, dual_readout, llp, master
Children:
d77b51d
Parents:
7f12612 (diff), e5767b57 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge remote-tracking branch 'upstream/master'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/IdentificationMap.cc

    r7f12612 rd870fc5  
    22 *  Delphes: a framework for fast simulation of a generic collider experiment
    33 *  Copyright (C) 2012-2014  Universite catholique de Louvain (UCL), Belgium
    4  * 
     4 *
    55 *  This program is free software: you can redistribute it and/or modify
    66 *  it under the terms of the GNU General Public License as published by
    77 *  the Free Software Foundation, either version 3 of the License, or
    88 *  (at your option) any later version.
    9  * 
     9 *
    1010 *  This program is distributed in the hope that it will be useful,
    1111 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    1212 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1313 *  GNU General Public License for more details.
    14  * 
     14 *
    1515 *  You should have received a copy of the GNU General Public License
    1616 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    2020/** \class IdentificationMap
    2121 *
    22  *  Converts particles with some PDG code into another particle, according to parametrized probability as function of pt eta
    23  given by user.
    24  *
    25  *  $Date: 2014-08-07 14:57:44 +0100 (Thu, 07 Aug 2014) $
    26  *  $Revision: 905 $
    27  *
     22 *  Converts particles with some PDG code into another particle,
     23 *  according to parametrized probability.
    2824 *
    2925 *  \author M. Selvaggi - UCL, Louvain-la-Neuve
     
    4945#include "TLorentzVector.h"
    5046
    51 #include <algorithm> 
     47#include <algorithm>
    5248#include <stdexcept>
    5349#include <iostream>
     
    7571  // read efficiency formula
    7672
    77  
     73
    7874  TMisIDMap::iterator itEfficiencyMap;
    7975  ExRootConfParam param;
    8076  DelphesFormula *formula;
    8177  Int_t i, size, pdg;
    82  
     78
    8379  // read efficiency formulas
    8480  param = GetParam("EfficiencyFormula");
    8581  size = param.GetSize();
    86  
     82
    8783  fEfficiencyMap.clear();
    8884  for(i = 0; i < size/3; ++i)
     
    9288    pdg = param[i*3].GetInt();
    9389    fEfficiencyMap.insert(make_pair(pdg,make_pair(param[i*3 + 1].GetInt(),formula)));
    94  
     90
    9591   // cout<<param[i*3].GetInt()<<","<<param[i*3+1].GetInt()<<","<<param[i*3 + 2].GetString()<<endl;
    96  
     92
    9793  }
    9894
     
    106102    fEfficiencyMap.insert(make_pair(0,make_pair(0,formula)));
    107103  }
    108  
     104
    109105  // import input array
    110106
     
    122118{
    123119  if(fItInputArray) delete fItInputArray;
    124  
     120
    125121  TMisIDMap::iterator itEfficiencyMap;
    126122  DelphesFormula *formula;
     
    136132
    137133void IdentificationMap::Process()
    138 { 
     134{
    139135  Candidate *candidate;
    140136  Double_t pt, eta, phi;
     
    145141
    146142  Double_t P, Pi;
    147    
     143
    148144 // cout<<"------------ New Event ------------"<<endl;
    149    
     145
    150146  fItInputArray->Reset();
    151147  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     
    158154    pdgIn = candidate->PID;
    159155    charge = candidate->Charge;
    160    
     156
    161157   // cout<<"------------ New Candidate ------------"<<endl;
    162158   // cout<<candidate->PID<<"   "<<pt<<","<<eta<<","<<phi<<endl;
    163      
     159
    164160    P = 1.0;
    165    
     161
    166162    //first check that PID of this particle is specified in cfg, if not set look for PID=0
    167      
     163
    168164    itEfficiencyMap = fEfficiencyMap.find(pdgIn);
    169      
    170     range = fEfficiencyMap.equal_range(pdgIn); 
     165
     166    range = fEfficiencyMap.equal_range(pdgIn);
    171167    if(range.first == range.second) range = fEfficiencyMap.equal_range(-pdgIn);
    172168    if(range.first == range.second) range = fEfficiencyMap.equal_range(0);
    173    
     169
    174170    //loop over submap for this pid
    175171    for (TMisIDMap::iterator it=range.first; it!=range.second; ++it)
    176     { 
    177        
     172    {
     173
    178174      formula = (it->second).second;
    179175      pdgOut = (it->second).first;
    180176
    181177      Pi = formula->Eval(pt, eta);
    182    
     178
    183179      // check that sum of probabilities does not exceed 1.
    184180      P = (P - Pi)/P;
    185        
     181
    186182      if( P < 0.0 ) continue;
    187183      else
    188184      {
    189      
     185
    190186       //randomly assign a PID to particle according to map
    191187       Double_t rndm = gRandom->Uniform();
    192        
     188
    193189       if(rndm > P)
    194190       {
     
    198194         break;
    199195       }
    200       } 
    201        
     196      }
     197
    202198    }
    203      
     199
    204200   }
    205201
Note: See TracChangeset for help on using the changeset viewer.