Changeset 2862770 in git
- Timestamp:
- Jan 27, 2015, 5:46:49 PM (10 years ago)
- Branches:
- ImprovedOutputFile, Timing, dual_readout, llp, master
- Children:
- ba1f1ee
- Parents:
- 3db5282
- Location:
- modules
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/PileUpJetID.cc
r3db5282 r2862770 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 60 /* 61 Double_t fMeanSqDeltaRMaxBarrel; // |eta| < 1.5 62 Double_t fBetaMinBarrel; // |eta| < 2.5 63 Double_t fMeanSqDeltaRMaxEndcap; // 1.5 < |eta| < 4.0 64 Double_t fBetaMinEndcap; // 1.5 < |eta| < 4.0 65 Double_t fMeanSqDeltaRMaxForward; // |eta| > 4.0 66 */ 67 68 fMeanSqDeltaRMaxBarrel = GetDouble("MeanSqDeltaRMaxBarrel",0.1); 69 fBetaMinBarrel = GetDouble("BetaMinBarrel",0.1); 70 fMeanSqDeltaRMaxEndcap = GetDouble("MeanSqDeltaRMaxEndcap",0.1); 71 fBetaMinEndcap = GetDouble("BetaMinEndcap",0.1); 72 fMeanSqDeltaRMaxForward = GetDouble("MeanSqDeltaRMaxForward",0.1); 73 fJetPTMinForNeutrals = GetDouble("JetPTMinForNeutrals", 20.0); 74 fNeutralPTMin = GetDouble("NeutralPTMin", 2.0); 75 76 77 78 cout << " set MeanSqDeltaRMaxBarrel " << fMeanSqDeltaRMaxBarrel << endl; 79 cout << " set BetaMinBarrel " << fBetaMinBarrel << endl; 80 cout << " set MeanSqDeltaRMaxEndcap " << fMeanSqDeltaRMaxEndcap << endl; 81 cout << " set BetaMinEndcap " << fBetaMinEndcap << endl; 82 cout << " set MeanSqDeltaRMaxForward " << fMeanSqDeltaRMaxForward << endl; 83 84 85 76 86 fAverageEachTower = false; // for timing 77 87 … … 81 91 fItJetInputArray = fJetInputArray->MakeIterator(); 82 92 83 fTrackInputArray = ImportArray(GetString("TrackInputArray", "Calorimeter/eflowTracks")); 93 94 // cout << "BeforE SCZ additions in init" << endl; 95 // cout << GetString("TrackInputArray", "ParticlePropagator/tracks") << endl; 96 // cout << GetString("EFlowTrackInputArray", "ParticlePropagator/tracks") << endl; 97 98 fTrackInputArray = ImportArray(GetString("TrackInputArray", "ParticlePropagator/tracks")); 84 99 fItTrackInputArray = fTrackInputArray->MakeIterator(); 85 100 86 fNeutralInputArray = ImportArray(GetString("NeutralInputArray", " Calorimeter/eflowTowers"));101 fNeutralInputArray = ImportArray(GetString("NeutralInputArray", "ParticlePropagator/tracks")); 87 102 fItNeutralInputArray = fNeutralInputArray->MakeIterator(); 88 103 89 fVertexInputArray = ImportArray(GetString("VertexInputArray", "PileUpMerger/vertices"));90 fItVertexInputArray = fVertexInputArray->MakeIterator();91 92 fZVertexResolution = GetDouble("ZVertexResolution", 0.005)*1.0E3;93 104 94 105 // create output array(s) 95 106 96 107 fOutputArray = ExportArray(GetString("OutputArray", "jets")); 108 109 fNeutralsInPassingJets = ExportArray(GetString("NeutralsInPassingJets","eflowtowers")); 110 111 112 // cout << " end of INIT " << endl; 113 97 114 } 98 115 … … 101 118 void PileUpJetID::Finish() 102 119 { 120 // cout << "In finish" << endl; 121 103 122 if(fItJetInputArray) delete fItJetInputArray; 104 123 if(fItTrackInputArray) delete fItTrackInputArray; 105 124 if(fItNeutralInputArray) delete fItNeutralInputArray; 106 if(fItVertexInputArray) delete fItVertexInputArray; 125 107 126 } 108 127 … … 111 130 void PileUpJetID::Process() 112 131 { 132 // cout << "start of process" << endl; 133 113 134 Candidate *candidate, *constituent; 114 135 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 } 136 137 // cout << "BeforE SCZ additions in process" << endl; 138 139 // SCZ 140 Candidate *trk; 133 141 134 142 // loop over all input candidates … … 139 147 area = candidate->Area; 140 148 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 { 149 float sumT0 = 0.; 150 float sumT1 = 0.; 151 float sumT10 = 0.; 152 float sumT20 = 0.; 153 float sumT30 = 0.; 154 float sumT40 = 0.; 155 float sumWeightsForT = 0.; 156 candidate->Ntimes = 0; 157 158 float sumpt = 0.; 159 float sumptch = 0.; 160 float sumptchpv = 0.; 161 float sumptchpu = 0.; 162 float sumdrsqptsq = 0.; 163 float sumptsq = 0.; 164 int nc = 0; 165 int nn = 0; 166 float pt_ann[5]; 167 168 for (int i = 0 ; i < 5 ; i++) { 169 pt_ann[i] = 0.; 170 } 171 172 if (fUseConstituents) { 157 173 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 { 174 while((constituent = static_cast<Candidate*>(itConstituents.Next()))) { 175 float pt = constituent->Momentum.Pt(); 176 float dr = candidate->Momentum.DeltaR(constituent->Momentum); 177 // cout << " There exists a constituent with dr=" << dr << endl; 178 sumpt += pt; 179 sumdrsqptsq += dr*dr*pt*pt; 180 sumptsq += pt*pt; 181 if (constituent->Charge == 0) { 182 nn++; 183 } else { 184 if (constituent->IsRecoPU) { 185 sumptchpu += pt; 186 } else { 187 sumptchpv += pt; 188 } 189 sumptch += pt; 190 nc++; 191 } 192 for (int i = 0 ; i < 5 ; i++) { 193 if (dr > 0.1*i && dr < 0.1*(i+1)) { 194 pt_ann[i] += pt; 195 } 196 } 197 float tow_sumT = 0; 198 float tow_sumW = 0; 199 for (int i = 0 ; i < constituent->Ecal_E_t.size() ; i++) { 200 float w = TMath::Sqrt(constituent->Ecal_E_t[i].first); 201 if (fAverageEachTower) { 202 tow_sumT += w*constituent->Ecal_E_t[i].second; 203 tow_sumW += w; 204 } else { 205 sumT0 += w*constituent->Ecal_E_t[i].second; 206 sumT1 += w*gRandom->Gaus(constituent->Ecal_E_t[i].second,0.001); 207 sumT10 += w*gRandom->Gaus(constituent->Ecal_E_t[i].second,0.010); 208 sumT20 += w*gRandom->Gaus(constituent->Ecal_E_t[i].second,0.020); 209 sumT30 += w*gRandom->Gaus(constituent->Ecal_E_t[i].second,0.030); 210 sumT40 += w*gRandom->Gaus(constituent->Ecal_E_t[i].second,0.040); 211 sumWeightsForT += w; 212 candidate->Ntimes++; 213 } 214 } 215 if (fAverageEachTower && tow_sumW > 0.) { 216 sumT0 += tow_sumT; 217 sumT1 += tow_sumW*gRandom->Gaus(tow_sumT/tow_sumW,0.001); 218 sumT10 += tow_sumW*gRandom->Gaus(tow_sumT/tow_sumW,0.0010); 219 sumT20 += tow_sumW*gRandom->Gaus(tow_sumT/tow_sumW,0.0020); 220 sumT30 += tow_sumW*gRandom->Gaus(tow_sumT/tow_sumW,0.0030); 221 sumT40 += tow_sumW*gRandom->Gaus(tow_sumT/tow_sumW,0.0040); 222 sumWeightsForT += tow_sumW; 223 candidate->Ntimes++; 224 } 225 } 226 } else { 195 227 // Not using constituents, using dr 196 228 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 229 while ((trk = static_cast<Candidate*>(fItTrackInputArray->Next()))) { 230 if (trk->Momentum.DeltaR(candidate->Momentum) < fParameterR) { 231 float pt = trk->Momentum.Pt(); 232 sumpt += pt; 233 sumptch += pt; 234 if (trk->IsRecoPU) { 235 sumptchpu += pt; 236 } else { 237 sumptchpv += pt; 238 } 239 float dr = candidate->Momentum.DeltaR(trk->Momentum); 240 sumdrsqptsq += dr*dr*pt*pt; 241 sumptsq += pt*pt; 242 nc++; 243 for (int i = 0 ; i < 5 ; i++) { 244 if (dr > 0.1*i && dr < 0.1*(i+1)) { 245 pt_ann[i] += pt; 246 } 247 } 248 } 249 } 226 250 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 { 251 while ((constituent = static_cast<Candidate*>(fItNeutralInputArray->Next()))) { 252 if (constituent->Momentum.DeltaR(candidate->Momentum) < fParameterR) { 253 float pt = constituent->Momentum.Pt(); 254 sumpt += pt; 255 float dr = candidate->Momentum.DeltaR(constituent->Momentum); 256 sumdrsqptsq += dr*dr*pt*pt; 257 sumptsq += pt*pt; 258 nn++; 259 for (int i = 0 ; i < 5 ; i++) { 260 if (dr > 0.1*i && dr < 0.1*(i+1)) { 261 pt_ann[i] += pt; 262 } 263 } 264 } 265 } 266 } 267 268 if (sumptch > 0.) { 269 candidate->Beta = sumptchpv/sumptch; 270 candidate->BetaStar = sumptchpu/sumptch; 271 } else { 272 candidate->Beta = -999.; 273 candidate->BetaStar = -999.; 274 } 275 if (sumptsq > 0.) { 260 276 candidate->MeanSqDeltaR = sumdrsqptsq/sumptsq; 261 } 262 else 263 { 264 candidate->MeanSqDeltaR = -999.0; 277 } else { 278 candidate->MeanSqDeltaR = -999.; 265 279 } 266 280 candidate->NCharged = nc; 267 281 candidate->NNeutrals = nn; 268 if(sumpt > 0.0) 269 { 282 if (sumpt > 0.) { 270 283 candidate->PTD = TMath::Sqrt(sumptsq) / sumpt; 271 for(i = 0; i < 5; ++i) 272 { 284 for (int i = 0 ; i < 5 ; i++) { 273 285 candidate->FracPt[i] = pt_ann[i]/sumpt; 274 286 } 275 } 276 else 277 { 278 candidate->PTD = -999.0; 279 for(i = 0; i < 5; ++i) 280 { 281 candidate->FracPt[i] = -999.0; 287 } else { 288 candidate->PTD = -999.; 289 for (int i = 0 ; i < 5 ; i++) { 290 candidate->FracPt[i] = -999.; 282 291 } 283 292 } 284 293 285 294 fOutputArray->Add(candidate); 295 296 // New stuff 297 /* 298 fMeanSqDeltaRMaxBarrel = GetDouble("MeanSqDeltaRMaxBarrel",0.1); 299 fBetaMinBarrel = GetDouble("BetaMinBarrel",0.1); 300 fMeanSqDeltaRMaxEndcap = GetDouble("MeanSqDeltaRMaxEndcap",0.1); 301 fBetaMinEndcap = GetDouble("BetaMinEndcap",0.1); 302 fMeanSqDeltaRMaxForward = GetDouble("MeanSqDeltaRMaxForward",0.1); 303 */ 304 305 bool passId = false; 306 if (candidate->Momentum.Pt() > fJetPTMinForNeutrals && candidate->MeanSqDeltaR > -0.1) { 307 if (fabs(candidate->Momentum.Eta())<1.5) { 308 passId = ((candidate->Beta > fBetaMinBarrel) && (candidate->MeanSqDeltaR < fMeanSqDeltaRMaxBarrel)); 309 } else if (fabs(candidate->Momentum.Eta())<4.0) { 310 passId = ((candidate->Beta > fBetaMinEndcap) && (candidate->MeanSqDeltaR < fMeanSqDeltaRMaxEndcap)); 311 } else { 312 passId = (candidate->MeanSqDeltaR < fMeanSqDeltaRMaxForward); 313 } 314 } 315 316 // cout << " Pt Eta MeanSqDeltaR Beta PassId " << candidate->Momentum.Pt() 317 // << " " << candidate->Momentum.Eta() << " " << candidate->MeanSqDeltaR << " " << candidate->Beta << " " << passId << endl; 318 319 if (passId) { 320 if (fUseConstituents) { 321 TIter itConstituents(candidate->GetCandidates()); 322 while((constituent = static_cast<Candidate*>(itConstituents.Next()))) { 323 if (constituent->Charge == 0 && constituent->Momentum.Pt() > fNeutralPTMin) { 324 fNeutralsInPassingJets->Add(constituent); 325 // cout << " Constitutent added Pt Eta Charge " << constituent->Momentum.Pt() << " " << constituent->Momentum.Eta() << " " << constituent->Charge << endl; 326 } 327 } 328 } else { // use DeltaR 329 fItNeutralInputArray->Reset(); 330 while ((constituent = static_cast<Candidate*>(fItNeutralInputArray->Next()))) { 331 if (constituent->Momentum.DeltaR(candidate->Momentum) < fParameterR && constituent->Momentum.Pt() > fNeutralPTMin) { 332 fNeutralsInPassingJets->Add(constituent); 333 // cout << " Constitutent added Pt Eta Charge " << constituent->Momentum.Pt() << " " << constituent->Momentum.Eta() << " " << constituent->Charge << endl; 334 } 335 } 336 } 337 } 338 339 286 340 } 287 341 } 288 342 289 343 //------------------------------------------------------------------------------ 290 -
modules/PileUpJetID.h
r3db5282 r2862770 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 #ifndef PileUpJetID_h 20 2 #define PileUpJetID_h … … 22 4 /** \class PileUpJetID 23 5 * 24 * CMS PileUp Jet ID Variables , based on http://cds.cern.ch/record/15815836 * CMS PileUp Jet ID Variables 25 7 * 26 * \author S. Zenz , December 20138 * \author S. Zenz 27 9 * 28 10 */ … … 34 16 35 17 class TObjArray; 18 class DelphesFormula; 36 19 37 20 class PileUpJetID: public DelphesModule … … 51 34 Double_t fParameterR; 52 35 36 Double_t fMeanSqDeltaRMaxBarrel; // |eta| < 1.5 37 Double_t fBetaMinBarrel; // |eta| < 2.5 38 Double_t fMeanSqDeltaRMaxEndcap; // 1.5 < |eta| < 4.0 39 Double_t fBetaMinEndcap; // 1.5 < |eta| < 4.0 40 Double_t fMeanSqDeltaRMaxForward; // |eta| > 4.0 41 42 Double_t fNeutralPTMin; 43 Double_t fJetPTMinForNeutrals; 44 45 /* 46 JAY 47 --- 48 49 |Eta|<1.5 50 51 meanSqDeltaR betaStar SigEff BgdEff 52 0.13 0.92 96% 8% 53 0.13 0.95 97% 16% 54 0.13 0.97 98% 27% 55 56 |Eta|>1.5 57 58 meanSqDeltaR betaStar SigEff BgdEff 59 0.14 0.91 95% 15% 60 0.14 0.94 97% 19% 61 0.14 0.97 98% 29% 62 63 BRYAN 64 ----- 65 66 Barrel (MeanSqDR, Beta, sig eff, bg eff): 67 0.10, 0.08, 90%, 8% 68 0.11, 0.12, 90%, 6% 69 0.13, 0.16, 89%, 5% 70 71 Endcap (MeanSqDR, Beta, sig eff, bg eff): 72 0.07, 0.06, 89%, 4% 73 0.08, 0.08, 92%, 6% 74 0.09, 0.08, 95%, 10% 75 0.10, 0.08, 97%, 13% 76 77 SETH GUESSES FOR |eta| > 4.0 78 ---------------------------- 79 80 MeanSqDeltaR 81 0.07 82 0.10 83 0.14 84 0.2 85 */ 86 53 87 // If set to true, may have weird results for PFCHS 54 88 // If set to false, uses everything within dR < fParameterR even if in other jets &c. 55 89 // Results should be very similar for PF 56 Int_t fUseConstituents; 90 Int_t fUseConstituents; 57 91 58 92 Bool_t fAverageEachTower; … … 62 96 const TObjArray *fJetInputArray; //! 63 97 64 const TObjArray *fTrackInputArray; // !65 const TObjArray *fNeutralInputArray; //!98 const TObjArray *fTrackInputArray; // SCZ 99 const TObjArray *fNeutralInputArray; 66 100 67 TIterator *fItTrackInputArray; // !68 TIterator *fItNeutralInputArray; // !101 TIterator *fItTrackInputArray; // SCZ 102 TIterator *fItNeutralInputArray; // SCZ 69 103 70 104 TObjArray *fOutputArray; //! 105 TObjArray *fNeutralsInPassingJets; // SCZ 71 106 72 TIterator *fItVertexInputArray; //!73 const TObjArray *fVertexInputArray; //!74 107 75 Double_t fZVertexResolution; 76 77 ClassDef(PileUpJetID, 1) 108 ClassDef(PileUpJetID, 2) 78 109 }; 79 110 80 111 #endif 81
Note:
See TracChangeset
for help on using the changeset viewer.