Changeset 316 in svn for trunk/src/LHCOConverter.cc
- Timestamp:
- Mar 10, 2009, 11:49:31 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/LHCOConverter.cc
r313 r316 34 34 #include "ExRootTreeReader.h" 35 35 #include "BlockClasses.h" 36 #include "SmearUtil.h" 36 37 37 38 // root includes … … 148 149 149 150 // 2 muon data 150 BranchReader (branchMuon,line,lhcoMuonID);151 BranchReaderMuon(branchMuon,branchJet,line); 151 152 152 153 // 3 tau-jets … … 173 174 unsigned int branch_size = branch->GetEntries(); 174 175 TRootParticle * particle = 0; 175 for (unsigned int i=0; i< branch_size; i++) { 176 177 // parsing the branch 178 for (unsigned int i=0; i< branch_size; i++) { 176 179 particle = (TRootParticle*) branch->At(i); 177 180 TLorentzVector pmu; 178 181 pmu.SetPtEtaPhiE(particle->PT, particle->Eta, particle->Phi, particle->E); 179 182 float jmass = pmu.M(); 183 //if(jmass < 0) cout << "jmass negatif" << particle->PT << " " << particle->Eta << " " << particle->Phi << " " << particle->E << " " << jmass << endl; 180 184 float ntrk = 0.0; 181 185 float btag =0; 182 186 double ratioE = 0; 183 187 184 if(lhcoID == lhcoPhotonID){TRootPhoton gam(*((TRootPhoton*) branch->At(i))); jmass=0; ratioE = gam.EHoverEE;} 185 if(lhcoID == lhcoElectronID) { TRootElectron elec(*((TRootElectron*) branch->At(i))); ntrk = elec.Charge; ratioE = elec.EHoverEE;} 186 else if (lhcoID == lhcoMuonID) { TRootMuon muon(*((TRootMuon*) branch->At(i))); ntrk = muon.Charge; ratioE = muon.EHoverEE;} 187 else if (lhcoID == lhcoTauJetID) { TRootTauJet taujet(*((TRootTauJet*) branch->At(i))); ntrk = taujet.Charge; } 188 else if (lhcoID == lhcoJetID) { TRootJet jet(*((TRootJet*) branch->At(i))); ntrk = jet.NTracks; btag = jet.Btag; ratioE = jet.EHoverEE;} 188 switch(lhcoID) { 189 case lhcoPhotonID: { 190 TRootPhoton gam(*((TRootPhoton*) branch->At(i))); 191 jmass=0; ratioE = gam.EHoverEE; 192 } break; 193 case lhcoElectronID: { 194 TRootElectron elec(*((TRootElectron*) branch->At(i))); 195 ntrk = elec.Charge; ratioE = elec.EHoverEE; 196 } break; 197 case lhcoTauJetID: { 198 TRootTauJet taujet(*((TRootTauJet*) branch->At(i))); 199 ntrk = taujet.Charge; ratioE = taujet.EHoverEE; 200 } break; 201 case lhcoJetID: { 202 TRootJet jet(*((TRootJet*) branch->At(i))); 203 ntrk = jet.NTracks; btag = jet.Btag; ratioE = jet.EHoverEE; 204 } break; 205 case lhcoMuonID: { 206 cout << "ERROR: LHCOConverter: for muons use LHCOConverter::BranchReaderMuon!\n"; 207 TRootMuon muon(*((TRootMuon*) branch->At(i))); 208 ntrk = muon.Charge; ratioE = muon.EHoverEE; 209 } break; 210 case lhcoETmisID: { 211 cout << "ERROR: LHCOConverter: for ETmis use LHCOConverter::BranchReaderETmis!\n"; 212 TRootMuon muon(*((TRootMuon*) branch->At(i))); 213 ntrk = muon.Charge; ratioE = muon.EHoverEE; 214 } break; 215 216 default: break; 217 } // switch 218 189 219 if(lhcoID != lhcoETmisID) { 190 220 outfile << fixed << setprecision(3) … … 200 230 << setw(7) << 0.0 << setw(7) << 0.0 // dummy/dummy 201 231 << endl; 202 } else {203 outfile << fixed << setprecision(3)204 << setw(3) << line++ // line counter205 << setw(4) << lhcoID << " " // object ID in lhco format206 << setw(7) << 0.000 <<" "207 << setw(7) << particle->Phi <<" "208 << setw(7) << particle->PT <<" "209 << setw(7) << 0. <<" " // invariant mass210 << setw(7) << 0 <<" " // number of tracks211 << setw(7) << 0. <<" "212 << setw(7) << 0. <<" " // E_had/E_em213 << setw(7) << 0.0 << setw(7) << 0.0 // dummy/dummy214 << endl;215 232 } 216 } 233 } // branch parsing 234 217 235 outfile.close(); 218 236 // return outfile; … … 232 250 << setw(7) << particle->ET <<" " 233 251 << setw(7) << 0. <<" " // invariant mass 234 << setw(7) << 0 235 << setw(7) << 0. 252 << setw(7) << 0. <<" " // number of tracks 253 << setw(7) << 0. <<" " 236 254 << setw(7) << 0. <<" " // E_had/E_em 237 255 << setw(7) << 0.0 << setw(7) << 0.0 // dummy/dummy … … 243 261 244 262 263 void LHCOConverter::BranchReaderMuon(const TClonesArray* branchMuon, const TClonesArray* branchJet, unsigned int& line) const { 264 265 ofstream outfile( outputfilename_.c_str(),ios_base::app); 266 unsigned int branch_size = branchMuon->GetEntries(); 267 TRootMuon * muon = 0; 268 for (unsigned int i=0; i< branch_size; i++) { 269 muon = (TRootMuon*) branchMuon->At(i); 270 271 TLorentzVector pmu; pmu.SetPtEtaPhiE(muon->PT, muon->Eta, muon->Phi, muon->E); 272 float jmass = pmu.M(); if(jmass <0) jmass =0; // small negative values are possible due to smearing. < 0.1 GeV 273 274 // loop on jets, for muon isolation 275 unsigned int closest_jet_ID = 0; 276 float closest_jet_dR = 1E99; // initialisation value, should be high. No further impact 277 for (unsigned int j=0; j< (unsigned int) branchJet->GetEntries(); j++) { 278 TRootJet jet(*((TRootJet*)branchJet->At(j))); 279 float dr_ij = DeltaR(muon->Phi, muon->Eta, jet.Phi, jet.Eta); 280 if( dr_ij < closest_jet_dR ) { 281 closest_jet_ID = j; 282 closest_jet_dR = dr_ij; 283 } 284 } // loop on jets 285 286 // output 287 outfile << fixed << setprecision(3) 288 << setw(3) << line++ // line counter 289 << setw(4) << lhcoMuonID << " " // object ID in lhco format 290 << setw(7) << muon->Eta <<" " 291 << setw(7) << muon->Phi <<" " 292 << setw(7) << muon->PT <<" " 293 << setw(7) << jmass <<" " // invariant mass 294 << setw(7) << (float)muon->Charge <<" " // -1 for mu-, +1 for mu+ 295 << setw(7) << (float)closest_jet_ID << " " 296 << setw(7) << muon->EHoverEE <<" " // E_had/E_em 297 << setw(7) << 0.0 << setw(7) << 0.0 // dummy/dummy 298 << endl; 299 } // muon branch loop 300 301 outfile.close(); 302 }
Note:
See TracChangeset
for help on using the changeset viewer.