Changes in modules/IdentificationMap.cc [95aa610:cab38f6] in git
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/IdentificationMap.cc
r95aa610 rcab38f6 69 69 void IdentificationMap::Init() 70 70 { 71 // read efficiency formula 72 73 71 74 TMisIDMap::iterator itEfficiencyMap; 72 75 ExRootConfParam param; … … 84 87 formula->Compile(param[i*3 + 2].GetString()); 85 88 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 87 93 } 88 94 … … 94 100 formula->Compile("1.0"); 95 101 96 fEfficiencyMap.insert(make_pair(0, make_pair(0,formula)));102 fEfficiencyMap.insert(make_pair(0,make_pair(0,formula))); 97 103 } 98 104 … … 120 126 if(formula) delete formula; 121 127 } 128 122 129 } 123 130 … … 127 134 { 128 135 Candidate *candidate; 129 Double_t pt, eta, phi , e;136 Double_t pt, eta, phi; 130 137 TMisIDMap::iterator itEfficiencyMap; 131 138 pair <TMisIDMap::iterator, TMisIDMap::iterator> range; 132 139 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; 136 145 137 146 fItInputArray->Reset(); … … 143 152 phi = candidatePosition.Phi(); 144 153 pt = candidateMomentum.Pt(); 145 e = candidateMomentum.E(); 146 147 pdgCodeIn = candidate->PID; 154 pdgIn = candidate->PID; 148 155 charge = candidate->Charge; 149 156 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); 157 168 if(range.first == range.second) range = fEfficiencyMap.equal_range(0); 158 169 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) 164 172 { 173 165 174 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 171 184 { 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 } 176 196 } 177 197 178 total += p;179 198 } 180 } 181 } 182 183 //------------------------------------------------------------------------------ 199 200 } 201 202 } 203 204 //------------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.