Changeset d77b51d in git for modules/PileUpJetID.cc
- Timestamp:
- Sep 29, 2015, 2:08:10 PM (9 years ago)
- Branches:
- ImprovedOutputFile, Timing, dual_readout, llp, master
- Children:
- a98c7ef
- Parents:
- d870fc5 (diff), 06ec139 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/PileUpJetID.cc
rd870fc5 rd77b51d 1 /*2 * Delphes: a framework for fast simulation of a generic collider experiment3 * Copyright (C) 2012-2014 Universite catholique de Louvain (UCL), Belgium4 *5 * This program is free software: you can redistribute it and/or modify6 * it under the terms of the GNU General Public License as published by7 * the Free Software Foundation, either version 3 of the License, or8 * (at your option) any later version.9 *10 * This program is distributed in the hope that it will be useful,11 * but WITHOUT ANY WARRANTY; without even the implied warranty of12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * GNU General Public License for more details.14 *15 * You should have received a copy of the GNU General Public License16 * along with this program. If not, see <http://www.gnu.org/licenses/>.17 */18 19 1 20 2 /** \class PileUpJetID 21 3 * 22 * CMS PileUp Jet ID Variables , based on http://cds.cern.ch/record/15815834 * CMS PileUp Jet ID Variables 23 5 * 24 * \author S. Zenz , December 20136 * \author S. Zenz 25 7 * 26 8 */ … … 41 23 #include "TRandom3.h" 42 24 #include "TObjArray.h" 43 #include "TDatabasePDG.h"25 //#include "TDatabasePDG.h" 44 26 #include "TLorentzVector.h" 45 27 … … 54 36 55 37 PileUpJetID::PileUpJetID() : 56 fItJetInputArray(0),fTrackInputArray(0),fNeutralInputArray(0) ,fItVertexInputArray(0)38 fItJetInputArray(0),fTrackInputArray(0),fNeutralInputArray(0) 57 39 { 58 40 … … 70 52 void PileUpJetID::Init() 71 53 { 54 72 55 fJetPTMin = GetDouble("JetPTMin", 20.0); 73 56 fParameterR = GetDouble("ParameterR", 0.5); 74 57 fUseConstituents = GetInt("UseConstituents", 0); 75 58 59 fMeanSqDeltaRMaxBarrel = GetDouble("MeanSqDeltaRMaxBarrel",0.1); 60 fBetaMinBarrel = GetDouble("BetaMinBarrel",0.1); 61 fMeanSqDeltaRMaxEndcap = GetDouble("MeanSqDeltaRMaxEndcap",0.1); 62 fBetaMinEndcap = GetDouble("BetaMinEndcap",0.1); 63 fMeanSqDeltaRMaxForward = GetDouble("MeanSqDeltaRMaxForward",0.1); 64 fJetPTMinForNeutrals = GetDouble("JetPTMinForNeutrals", 20.0); 65 fNeutralPTMin = GetDouble("NeutralPTMin", 2.0); 66 76 67 fAverageEachTower = false; // for timing 77 68 … … 81 72 fItJetInputArray = fJetInputArray->MakeIterator(); 82 73 83 fTrackInputArray = ImportArray(GetString("TrackInputArray", " Calorimeter/eflowTracks"));74 fTrackInputArray = ImportArray(GetString("TrackInputArray", "ParticlePropagator/tracks")); 84 75 fItTrackInputArray = fTrackInputArray->MakeIterator(); 85 76 86 fNeutralInputArray = ImportArray(GetString("NeutralInputArray", " Calorimeter/eflowTowers"));77 fNeutralInputArray = ImportArray(GetString("NeutralInputArray", "ParticlePropagator/tracks")); 87 78 fItNeutralInputArray = fNeutralInputArray->MakeIterator(); 88 79 89 fVertexInputArray = ImportArray(GetString("VertexInputArray", "PileUpMerger/vertices"));90 fItVertexInputArray = fVertexInputArray->MakeIterator();91 92 fZVertexResolution = GetDouble("ZVertexResolution", 0.005)*1.0E3;93 94 80 // create output array(s) 95 81 96 82 fOutputArray = ExportArray(GetString("OutputArray", "jets")); 83 84 fNeutralsInPassingJets = ExportArray(GetString("NeutralsInPassingJets","eflowtowers")); 85 97 86 } 98 87 … … 101 90 void PileUpJetID::Finish() 102 91 { 92 // cout << "In finish" << endl; 93 103 94 if(fItJetInputArray) delete fItJetInputArray; 104 95 if(fItTrackInputArray) delete fItTrackInputArray; 105 96 if(fItNeutralInputArray) delete fItNeutralInputArray; 106 if(fItVertexInputArray) delete fItVertexInputArray; 97 107 98 } 108 99 … … 113 104 Candidate *candidate, *constituent; 114 105 TLorentzVector momentum, area; 115 Int_t i, nc, nn; 116 Double_t sumpt, sumptch, sumptchpv, sumptchpu, sumdrsqptsq, sumptsq; 117 Double_t dr, pt, pt_ann[5]; 118 Double_t zvtx = 0.0; 119 120 Candidate *track; 121 122 // find z position of primary vertex 123 124 fItVertexInputArray->Reset(); 125 while((candidate = static_cast<Candidate*>(fItVertexInputArray->Next()))) 126 { 127 if(!candidate->IsPU) 128 { 129 zvtx = candidate->Position.Z(); 130 break; 131 } 132 } 106 107 Candidate *trk; 133 108 134 109 // loop over all input candidates … … 139 114 area = candidate->Area; 140 115 141 sumpt = 0.0; 142 sumptch = 0.0; 143 sumptchpv = 0.0; 144 sumptchpu = 0.0; 145 sumdrsqptsq = 0.0; 146 sumptsq = 0.0; 147 nc = 0; 148 nn = 0; 149 150 for(i = 0; i < 5; ++i) 151 { 152 pt_ann[i] = 0.0; 153 } 154 155 if(fUseConstituents) 156 { 116 float sumT0 = 0.; 117 float sumT1 = 0.; 118 float sumT10 = 0.; 119 float sumT20 = 0.; 120 float sumT30 = 0.; 121 float sumT40 = 0.; 122 float sumWeightsForT = 0.; 123 candidate->NTimeHits = 0; 124 125 float sumpt = 0.; 126 float sumptch = 0.; 127 float sumptchpv = 0.; 128 float sumptchpu = 0.; 129 float sumdrsqptsq = 0.; 130 float sumptsq = 0.; 131 int nc = 0; 132 int nn = 0; 133 float pt_ann[5]; 134 135 for (int i = 0 ; i < 5 ; i++) { 136 pt_ann[i] = 0.; 137 } 138 139 if (fUseConstituents) { 157 140 TIter itConstituents(candidate->GetCandidates()); 158 while((constituent = static_cast<Candidate*>(itConstituents.Next()))) 159 { 160 pt = constituent->Momentum.Pt(); 161 dr = candidate->Momentum.DeltaR(constituent->Momentum); 162 sumpt += pt; 163 sumdrsqptsq += dr*dr*pt*pt; 164 sumptsq += pt*pt; 165 if(constituent->Charge == 0) 166 { 167 // neutrals 168 ++nn; 169 } 170 else 171 { 172 // charged 173 if(constituent->IsPU && TMath::Abs(constituent->Position.Z()-zvtx) > fZVertexResolution) 174 { 175 sumptchpu += pt; 176 } 177 else 178 { 179 sumptchpv += pt; 180 } 181 sumptch += pt; 182 ++nc; 183 } 184 for(i = 0; i < 5; ++i) 185 { 186 if(dr > 0.1*i && dr < 0.1*(i + 1)) 187 { 188 pt_ann[i] += pt; 189 } 190 } 191 } 192 } 193 else 194 { 141 while((constituent = static_cast<Candidate*>(itConstituents.Next()))) { 142 float pt = constituent->Momentum.Pt(); 143 float dr = candidate->Momentum.DeltaR(constituent->Momentum); 144 // cout << " There exists a constituent with dr=" << dr << endl; 145 sumpt += pt; 146 sumdrsqptsq += dr*dr*pt*pt; 147 sumptsq += pt*pt; 148 if (constituent->Charge == 0) { 149 nn++; 150 } else { 151 if (constituent->IsRecoPU) { 152 sumptchpu += pt; 153 } else { 154 sumptchpv += pt; 155 } 156 sumptch += pt; 157 nc++; 158 } 159 for (int i = 0 ; i < 5 ; i++) { 160 if (dr > 0.1*i && dr < 0.1*(i+1)) { 161 pt_ann[i] += pt; 162 } 163 } 164 float tow_sumT = 0; 165 float tow_sumW = 0; 166 for (int i = 0 ; i < constituent->ECalEnergyTimePairs.size() ; i++) { 167 float w = TMath::Sqrt(constituent->ECalEnergyTimePairs[i].first); 168 if (fAverageEachTower) { 169 tow_sumT += w*constituent->ECalEnergyTimePairs[i].second; 170 tow_sumW += w; 171 } else { 172 sumT0 += w*constituent->ECalEnergyTimePairs[i].second; 173 sumT1 += w*gRandom->Gaus(constituent->ECalEnergyTimePairs[i].second,0.001); 174 sumT10 += w*gRandom->Gaus(constituent->ECalEnergyTimePairs[i].second,0.010); 175 sumT20 += w*gRandom->Gaus(constituent->ECalEnergyTimePairs[i].second,0.020); 176 sumT30 += w*gRandom->Gaus(constituent->ECalEnergyTimePairs[i].second,0.030); 177 sumT40 += w*gRandom->Gaus(constituent->ECalEnergyTimePairs[i].second,0.040); 178 sumWeightsForT += w; 179 candidate->NTimeHits++; 180 } 181 } 182 if (fAverageEachTower && tow_sumW > 0.) { 183 sumT0 += tow_sumT; 184 sumT1 += tow_sumW*gRandom->Gaus(tow_sumT/tow_sumW,0.001); 185 sumT10 += tow_sumW*gRandom->Gaus(tow_sumT/tow_sumW,0.0010); 186 sumT20 += tow_sumW*gRandom->Gaus(tow_sumT/tow_sumW,0.0020); 187 sumT30 += tow_sumW*gRandom->Gaus(tow_sumT/tow_sumW,0.0030); 188 sumT40 += tow_sumW*gRandom->Gaus(tow_sumT/tow_sumW,0.0040); 189 sumWeightsForT += tow_sumW; 190 candidate->NTimeHits++; 191 } 192 } 193 } else { 195 194 // Not using constituents, using dr 196 195 fItTrackInputArray->Reset(); 197 while((track = static_cast<Candidate*>(fItTrackInputArray->Next()))) 198 { 199 if(track->Momentum.DeltaR(candidate->Momentum) < fParameterR) 200 { 201 pt = track->Momentum.Pt(); 202 sumpt += pt; 203 sumptch += pt; 204 if(track->IsPU && TMath::Abs(track->Position.Z()-zvtx) > fZVertexResolution) 205 { 206 sumptchpu += pt; 207 } 208 else 209 { 210 sumptchpv += pt; 211 } 212 dr = candidate->Momentum.DeltaR(track->Momentum); 213 sumdrsqptsq += dr*dr*pt*pt; 214 sumptsq += pt*pt; 215 nc++; 216 for(i = 0; i < 5; ++i) 217 { 218 if(dr > 0.1*i && dr < 0.1*(i + 1)) 219 { 220 pt_ann[i] += pt; 221 } 222 } 223 } 224 } 225 196 while ((trk = static_cast<Candidate*>(fItTrackInputArray->Next()))) { 197 if (trk->Momentum.DeltaR(candidate->Momentum) < fParameterR) { 198 float pt = trk->Momentum.Pt(); 199 sumpt += pt; 200 sumptch += pt; 201 if (trk->IsRecoPU) { 202 sumptchpu += pt; 203 } else { 204 sumptchpv += pt; 205 } 206 float dr = candidate->Momentum.DeltaR(trk->Momentum); 207 sumdrsqptsq += dr*dr*pt*pt; 208 sumptsq += pt*pt; 209 nc++; 210 for (int i = 0 ; i < 5 ; i++) { 211 if (dr > 0.1*i && dr < 0.1*(i+1)) { 212 pt_ann[i] += pt; 213 } 214 } 215 } 216 } 226 217 fItNeutralInputArray->Reset(); 227 while ((constituent = static_cast<Candidate*>(fItNeutralInputArray->Next()))) 228 { 229 if(constituent->Momentum.DeltaR(candidate->Momentum) < fParameterR) 230 { 231 pt = constituent->Momentum.Pt(); 232 sumpt += pt; 233 dr = candidate->Momentum.DeltaR(constituent->Momentum); 234 sumdrsqptsq += dr*dr*pt*pt; 235 sumptsq += pt*pt; 236 nn++; 237 for(i = 0; i < 5; ++i) 238 { 239 if(dr > 0.1*i && dr < 0.1*(i + 1)) 240 { 241 pt_ann[i] += pt; 242 } 243 } 244 } 245 } 246 } 247 248 if(sumptch > 0.0) 249 { 250 candidate->Beta = sumptchpu/sumptch; 251 candidate->BetaStar = sumptchpv/sumptch; 252 } 253 else 254 { 255 candidate->Beta = -999.0; 256 candidate->BetaStar = -999.0; 257 } 258 if(sumptsq > 0.0) 259 { 218 while ((constituent = static_cast<Candidate*>(fItNeutralInputArray->Next()))) { 219 if (constituent->Momentum.DeltaR(candidate->Momentum) < fParameterR) { 220 float pt = constituent->Momentum.Pt(); 221 sumpt += pt; 222 float dr = candidate->Momentum.DeltaR(constituent->Momentum); 223 sumdrsqptsq += dr*dr*pt*pt; 224 sumptsq += pt*pt; 225 nn++; 226 for (int i = 0 ; i < 5 ; i++) { 227 if (dr > 0.1*i && dr < 0.1*(i+1)) { 228 pt_ann[i] += pt; 229 } 230 } 231 } 232 } 233 } 234 235 if (sumptch > 0.) { 236 candidate->Beta = sumptchpv/sumptch; 237 candidate->BetaStar = sumptchpu/sumptch; 238 } else { 239 candidate->Beta = -999.; 240 candidate->BetaStar = -999.; 241 } 242 if (sumptsq > 0.) { 260 243 candidate->MeanSqDeltaR = sumdrsqptsq/sumptsq; 261 } 262 else 263 { 264 candidate->MeanSqDeltaR = -999.0; 244 } else { 245 candidate->MeanSqDeltaR = -999.; 265 246 } 266 247 candidate->NCharged = nc; 267 248 candidate->NNeutrals = nn; 268 if(sumpt > 0.0) 269 { 249 if (sumpt > 0.) { 270 250 candidate->PTD = TMath::Sqrt(sumptsq) / sumpt; 271 for(i = 0; i < 5; ++i) 272 { 251 for (int i = 0 ; i < 5 ; i++) { 273 252 candidate->FracPt[i] = pt_ann[i]/sumpt; 274 253 } 275 } 276 else 277 { 278 candidate->PTD = -999.0; 279 for(i = 0; i < 5; ++i) 280 { 281 candidate->FracPt[i] = -999.0; 254 } else { 255 candidate->PTD = -999.; 256 for (int i = 0 ; i < 5 ; i++) { 257 candidate->FracPt[i] = -999.; 282 258 } 283 259 } 284 260 285 261 fOutputArray->Add(candidate); 262 263 // New stuff 264 /* 265 fMeanSqDeltaRMaxBarrel = GetDouble("MeanSqDeltaRMaxBarrel",0.1); 266 fBetaMinBarrel = GetDouble("BetaMinBarrel",0.1); 267 fMeanSqDeltaRMaxEndcap = GetDouble("MeanSqDeltaRMaxEndcap",0.1); 268 fBetaMinEndcap = GetDouble("BetaMinEndcap",0.1); 269 fMeanSqDeltaRMaxForward = GetDouble("MeanSqDeltaRMaxForward",0.1); 270 */ 271 272 bool passId = false; 273 if (candidate->Momentum.Pt() > fJetPTMinForNeutrals && candidate->MeanSqDeltaR > -0.1) { 274 if (fabs(candidate->Momentum.Eta())<1.5) { 275 passId = ((candidate->Beta > fBetaMinBarrel) && (candidate->MeanSqDeltaR < fMeanSqDeltaRMaxBarrel)); 276 } else if (fabs(candidate->Momentum.Eta())<4.0) { 277 passId = ((candidate->Beta > fBetaMinEndcap) && (candidate->MeanSqDeltaR < fMeanSqDeltaRMaxEndcap)); 278 } else { 279 passId = (candidate->MeanSqDeltaR < fMeanSqDeltaRMaxForward); 280 } 281 } 282 283 // cout << " Pt Eta MeanSqDeltaR Beta PassId " << candidate->Momentum.Pt() 284 // << " " << candidate->Momentum.Eta() << " " << candidate->MeanSqDeltaR << " " << candidate->Beta << " " << passId << endl; 285 286 if (passId) { 287 if (fUseConstituents) { 288 TIter itConstituents(candidate->GetCandidates()); 289 while((constituent = static_cast<Candidate*>(itConstituents.Next()))) { 290 if (constituent->Charge == 0 && constituent->Momentum.Pt() > fNeutralPTMin) { 291 fNeutralsInPassingJets->Add(constituent); 292 // cout << " Constitutent added Pt Eta Charge " << constituent->Momentum.Pt() << " " << constituent->Momentum.Eta() << " " << constituent->Charge << endl; 293 } 294 } 295 } else { // use DeltaR 296 fItNeutralInputArray->Reset(); 297 while ((constituent = static_cast<Candidate*>(fItNeutralInputArray->Next()))) { 298 if (constituent->Momentum.DeltaR(candidate->Momentum) < fParameterR && constituent->Momentum.Pt() > fNeutralPTMin) { 299 fNeutralsInPassingJets->Add(constituent); 300 // cout << " Constitutent added Pt Eta Charge " << constituent->Momentum.Pt() << " " << constituent->Momentum.Eta() << " " << constituent->Charge << endl; 301 } 302 } 303 } 304 } 305 306 286 307 } 287 308 } 288 309 289 310 //------------------------------------------------------------------------------ 290
Note:
See TracChangeset
for help on using the changeset viewer.