1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
19 //_________________________________________________________________________
20 // Class for JetFinder Input preparation from simulated data
22 //*-- Author: Mark Horner (LBL/UCT)
27 #include "AliEMCALJetFinderInputSimPrep.h"
29 #include <TParticle.h>
30 #include <TParticlePDG.h>
34 #include <TObjectTable.h>
40 #include "AliEMCALFast.h"
42 #include "AliEMCALHit.h"
43 #include "AliEMCALGeometry.h"
44 #include "AliEMCALGetter.h"
45 #include "AliGenEventHeader.h"
46 #include "AliGenPythiaEventHeader.h"
47 #include "AliGenerator.h"
48 #include "AliHeader.h"
51 ClassImp(AliEMCALJetFinderInputSimPrep)
53 AliEMCALJetFinderInputSimPrep::AliEMCALJetFinderInputSimPrep()
55 if (fDebug > 0) Info("AliEMCALJetFinderInputSimPrep","Beginning Constructor");
58 fSmearType = kSmearEffic;
60 fTrackType = kCharged;
64 AliEMCALJetFinderInputSimPrep::~AliEMCALJetFinderInputSimPrep()
66 if (fDebug > 0) Info("~AliEMCALJetFinderInputSimPrep","Beginning Destructor");
70 void AliEMCALJetFinderInputSimPrep::Reset(AliEMCALJetFinderResetType_t resettype)
72 if (fDebug > 1) Info("Reset","Beginning Reset");
76 fInputObject.Reset(resettype);
79 fInputObject.Reset(resettype);
82 fInputObject.Reset(resettype);
84 case kResetParameters:
85 fSmearType = kSmearEffic;
87 fTrackType = kCharged;
90 fSmearType = kSmearEffic;
92 fTrackType = kCharged;
93 fInputObject.Reset(resettype);
96 Warning("FillFromFile", "kResetPartons not implemented") ;
99 Warning("FillFromFile", "kResetParticles not implemented") ;
102 Warning("FillFromFile", "kResetJets not implemented") ;
108 Int_t AliEMCALJetFinderInputSimPrep::FillFromFile(TString *filename, AliEMCALJetFinderFileType_t filetype,Int_t EventNumber)
110 // gObjectTable->Print();
111 // Test that file exists - Getter doesn't like bogus filenames
112 if (fDebug > 1) Info("FillFromFile","Beginning FillFromFile");
113 fFileType = filetype;
114 TFile file(filename->Data());
116 Error("FillFromFile","Could not open file in FillFromFile");
121 gAlice = static_cast<AliRun *>(file.Get("gAlice"));
122 AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL");
123 if (gAlice->GetEvent(EventNumber) < 0){
124 Error("FillFromFile","Could not open event in FillFromFile");
128 AliEMCALGetter *gime = AliEMCALGetter::Instance(filename->Data());
129 gime->Event(EventNumber) ;
131 if ( fEMCALType == kHits ||
132 fEMCALType == kTimeCut ) FillHits();
133 if ( fTrackType != kNoTracks ) FillTracks();
134 if ( fFileType != kData){
139 // gObjectTable->Print();
144 void AliEMCALJetFinderInputSimPrep::FillHits() // Fill from the hits to input object from simulation
146 if (fDebug > 1) Info("FillHits","Beginning FillHits");
148 // Access hit information
150 AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL");
151 Info("AliEMCALJetFinderInputSimPrep","Title of the geometry is %s",pEMCAL->GetTitle());
152 AliEMCALGeometry* geom = AliEMCALGetter::Instance()->EMCALGeometry();
153 // Float_t samplingF = geom->GetSampling();
154 Float_t samplingF = 11.6;
155 Info("AliEMCALJetFinderInputSimPrep","Sampling fraction is %f",samplingF);
156 TTree *treeH = AliEMCALGetter::Instance()->TreeH();
157 Int_t ntracks = (Int_t) treeH->GetEntries();
164 for (Int_t track=0; track<ntracks;track++) {
166 nbytes += treeH->GetEvent(track);
170 for(mHit=(AliEMCALHit*) pEMCAL->FirstHit(-1);
172 mHit=(AliEMCALHit*) pEMCAL->NextHit())
174 if (fEMCALType == kTimeCut &&
175 (mHit->GetTime()>fTimeCut) ) continue;
176 Float_t x = mHit->X(); // x-pos of hit
177 Float_t y = mHit->Y(); // y-pos
178 Float_t z = mHit->Z(); // z-pos
179 Float_t eloss = mHit->GetEnergy(); // deposited energy
181 Float_t r = TMath::Sqrt(x*x+y*y);
182 Float_t theta = TMath::ATan2(r,z);
183 Float_t eta = -TMath::Log(TMath::Tan(theta/2.));
184 Float_t phi = TMath::ATan2(y,x);
185 etH = samplingF*eloss*TMath::Sin(theta);
186 if (fDebug > 10) Info("FillHits","Values of hit energy %i",Int_t(1e7*etH));
187 if (geom->TowerIndexFromEtaPhi(eta,180.0/TMath::Pi()*phi) == -1)
191 Error("FillHits","Hit not inside EMCAL!");
196 fInputObject.AddEnergyToDigit(geom->TowerIndexFromEtaPhi(eta,180.0/TMath::Pi()*phi)-1,Int_t(1e7*etH));
202 void AliEMCALJetFinderInputSimPrep::FillTracks() // Fill from particles simulating a TPC to input object from simulation
205 if (fDebug > 1) Info("FillTracks","Beginning FillTracks");
207 TParticlePDG* pdgP = 0;
209 Int_t npart = (gAlice->GetHeader())->GetNprimary();
210 Float_t bfield,rEMCAL;
212 if (fDebug > 1) Info("FillTracks","Defining the geometry");
214 AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL");
215 AliEMCALGeometry* geom = AliEMCALGeometry::GetInstance(pEMCAL->GetTitle(), "");
216 fEtaMax = geom->GetArm1EtaMax();
217 fEtaMin = geom->GetArm1EtaMin();
218 fPhiMax = TMath::Pi()/180.0*geom->GetArm1PhiMax();
219 fPhiMin = TMath::Pi()/180.0*geom->GetArm1PhiMin();
221 if (fDebug > 1) Info("FillTracks","Starting particle loop");
223 for (Int_t part = 0; part < npart; part++) {
224 MPart = gAlice->Particle(part);
225 //if (part%10) gObjectTable->Print();
226 pdgP = MPart->GetPDG();
228 if (fDebug > 5) Info("FillTracks","Checking if track is a primary");
230 if (fFileType == kPythia) {
231 if (MPart->GetStatusCode() != 1) continue;
232 } else if (fFileType == kHijing) {
233 if (MPart->GetFirstDaughter() >= 0 && MPart->GetFirstDaughter() < npart) continue;
236 if (fDebug > 15) Info("FillTracks","Checking if track (eta - %f, phi - %f) is in acceptance",MPart->Eta(),MPart->Phi());
237 if (fDebug > 10) Info("FillTracks","Checking if EMCAL acceptance ( %f < eta < %f, %f < phi < %f) is in acceptance",fEtaMin,fEtaMax,fPhiMin,fPhiMax);
239 if (MPart->Eta() > fEtaMax || MPart->Eta() < fEtaMin) continue;
240 if (MPart->Phi() > fPhiMax || MPart->Phi() < fPhiMin ) continue;
243 {kProton, kProtonBar, kElectron, kPositron,
244 kNuE, kNuEBar, kGamma, kNeutron, kNeutronBar,
245 kMuonPlus, kMuonMinus, kK0Long , kPiPlus, kPiMinus,
246 kKPlus, kKMinus, kLambda0, kLambda0Bar, kK0Short,
247 kSigmaMinus, kSigmaPlus, kSigma0, kPi0, kK0, kK0Bar,
251 if (fDebug > 15) Info("FillTracks","Checking if track is rejected");
253 if ((fSmearType == kEfficiency ||
254 fSmearType == kSmearEffic) &&
256 if (AliEMCALFast::RandomReject(fEfficiency)) {
261 bfield = gAlice->Field()->SolenoidField();
262 rEMCAL = AliEMCALGeometry::GetInstance()->GetIPDistance();
263 Float_t rB = 3335.6 * MPart->Pt() / bfield; // [cm] (case of |charge|=1)
264 if (2.*rB < rEMCAL) continue; // track curls away
266 //if (part%10) gObjectTable->Print();
270 case kAll: // All Stable particles to be included
271 if (fDebug > 5) Info("FillTracks","Storing track");
272 if (fSmearType == kSmear ||
273 fSmearType == kSmearEffic ){
275 TParticle *tmp = Smear(MPart);
276 fInputObject.AddTrack(Smear(MPart));
279 fInputObject.AddTrack(*MPart);
282 case kEM: // All Electromagnetic particles
283 if (MPart->GetPdgCode() == kElectron ||
284 MPart->GetPdgCode() == kPositron ){
285 if (fDebug > 5) Info("FillTracks","Storing electron or positron");
286 if (fSmearType == kSmear ||
287 fSmearType == kSmearEffic ){
289 TParticle *tmp = Smear(MPart);
290 fInputObject.AddTrack(tmp);
293 fInputObject.AddTrack(*MPart);
296 if ( MPart->GetPdgCode() == kGamma ){
297 fInputObject.AddTrack(*MPart);
298 if (fDebug > 5) Info("FillTracks","Storing gamma");
302 case kCharged: // All Particles with non-zero charge
303 if (pdgP->Charge() != 0) {
304 if (fDebug > 5) Info("FillTracks","Storing charged track");
305 if (fSmearType == kSmear ||
306 fSmearType == kSmearEffic ){
308 TParticle *tmp = Smear(MPart);
309 fInputObject.AddTrack(tmp);
312 fInputObject.AddTrack(*MPart);
316 case kNeutral: // All particles with no charge
317 if (pdgP->Charge() == 0){
318 fInputObject.AddTrack(*MPart);
319 if (fDebug > 5) Info("FillTracks","Storing neutral");
322 case kHadron: //All hadrons
323 if (MPart->GetPdgCode() != kElectron &&
324 MPart->GetPdgCode() != kPositron &&
325 MPart->GetPdgCode() != kGamma )
327 if (fDebug > 5) Info("FillTracks","Storing hadron");
328 if (pdgP->Charge() == 0){
329 fInputObject.AddTrack(*MPart);
331 if (fSmearType == kSmear ||
332 fSmearType == kSmearEffic ){
334 TParticle *tmp = Smear(MPart);
335 fInputObject.AddTrack(tmp);
338 fInputObject.AddTrack(*MPart);
343 case kChargedHadron: // only charged hadrons
344 if (MPart->GetPdgCode() != kElectron &&
345 MPart->GetPdgCode() != kPositron &&
346 MPart->GetPdgCode() != kGamma &&
347 pdgP->Charge() != 0 ){
348 if (fDebug > 5) Info("FillTracks","Storing charged hadron");
349 if (fSmearType == kSmear ||
350 fSmearType == kSmearEffic ){
352 TParticle *tmp = Smear(MPart);
353 fInputObject.AddTrack(tmp);
356 fInputObject.AddTrack(*MPart);
366 // Info("FillTracks","After Particle Storage");
367 //if (part%10) gObjectTable->Print();
369 } //end of particle loop
370 //gObjectTable->Print();
373 void AliEMCALJetFinderInputSimPrep::FillPartons() // Fill partons to input object from simulation
375 if (fDebug > 1) Info("FillPartons","Beginning FillPartons");
377 AliGenEventHeader* evHeader = ((AliHeader*)(gAlice->GetHeader()))->GenEventHeader();
378 Float_t triggerJetValues[4];
379 AliEMCALParton tempParton;
381 if (fFileType == kPythia)
383 Int_t ntriggerjets = ((AliGenPythiaEventHeader*)evHeader)->NTriggerJets();
384 if (fDebug > 1) Info("FillPartons","Number of trigger jets --> %i",ntriggerjets);
385 for (Int_t jetcounter = 0 ; jetcounter < ntriggerjets; jetcounter++){
386 ((AliGenPythiaEventHeader*)evHeader)->TriggerJet(jetcounter,triggerJetValues);
387 TLorentzVector tempLParton;
388 tempLParton.SetPxPyPzE(triggerJetValues[0],triggerJetValues[1],triggerJetValues[2],triggerJetValues[3]);
389 tempParton.SetEnergy(tempLParton.Energy());
390 tempParton.SetEta(tempLParton.Eta());
391 tempParton.SetPhi(tempLParton.Phi());
392 FillPartonTracks(&tempParton);
393 fInputObject.AddParton(&tempParton);
399 void AliEMCALJetFinderInputSimPrep::FillParticles() // Fill particles to input object from simulation
401 if (fDebug > 1) Info("FillParticles","Beginning FillParticles");
403 Int_t npart = (gAlice->GetHeader())->GetNprimary();
404 TParticlePDG* pdgP = 0;
406 for (Int_t part = 0; part < npart; part++) {
407 TParticle *MPart = gAlice->Particle(part);
408 pdgP = MPart->GetPDG();
410 if (fDebug > 10) Info("FillParticles","Checking if particle is a primary");
412 if (fFileType == kPythia) {
413 if (MPart->GetStatusCode() != 1) continue;
414 } else if (fFileType == kHijing) {
415 if (MPart->GetFirstDaughter() >= 0 && MPart->GetFirstDaughter() < npart) continue;
418 if (fDebug > 10) Info("FillParticles","Checking if particle is in acceptance");
420 if (MPart->Eta() > fEtaMax || MPart->Eta() < fEtaMin) continue;
421 if (MPart->Phi() > fPhiMax || MPart->Phi() < fPhiMin ) continue;
425 {kProton, kProtonBar, kElectron, kPositron,
426 kNuE, kNuEBar, kGamma, kNeutron, kNeutronBar,
427 kMuonPlus, kMuonMinus, kK0Long , kPiPlus, kPiMinus,
428 kKPlus, kKMinus, kLambda0, kLambda0Bar, kK0Short,
429 kSigmaMinus, kSigmaPlus, kSigma0, kPi0, kK0, kK0Bar,
435 case kAll: // All Stable particles to be included
436 if (fDebug > 5) Info("FillParticles","Storing particle");
437 fInputObject.AddParticle(MPart);
439 case kEM: // All Electromagnetic particles
440 if (MPart->GetPdgCode() == kElectron ||
441 MPart->GetPdgCode() == kPositron ||
442 MPart->GetPdgCode() == kGamma){
443 if (fDebug > 5) Info("FillParticles","Storing electromagnetic particle");
444 fInputObject.AddParticle(MPart);
447 case kCharged: // All Particles with non-zero charge
448 if (pdgP->Charge() != 0) {
449 if (fDebug > 5) Info("FillParticles","Storing charged particle");
450 fInputObject.AddParticle(MPart);
453 case kNeutral: // All particles with no charge
454 if (pdgP->Charge() == 0){
455 if (fDebug > 5) Info("FillParticles","Storing neutral particle");
456 fInputObject.AddParticle(MPart);
459 case kHadron: //All hadrons
460 if (MPart->GetPdgCode() != kElectron &&
461 MPart->GetPdgCode() != kPositron &&
462 MPart->GetPdgCode() != kGamma )
465 if (fDebug > 5) Info("FillParticles","Storing hadron");
466 fInputObject.AddParticle(MPart);
469 case kChargedHadron: // only charged hadrons
470 if (MPart->GetPdgCode() != kElectron &&
471 MPart->GetPdgCode() != kPositron &&
472 MPart->GetPdgCode() != kGamma &&
473 pdgP->Charge() != 0 ){
474 if (fDebug > 5) Info("FillParticles","Storing charged hadron");
475 fInputObject.AddParticle(MPart);
483 }// end of loop over particles
486 void AliEMCALJetFinderInputSimPrep::FillDigits() // Fill digits to input object
491 void AliEMCALJetFinderInputSimPrep::Smear(TParticle *particle)
493 if (fDebug > 5) Info("Smear","Beginning Smear");
495 Float_t tmp = AliEMCALFast::SmearMomentum(1,particle->P());
496 Float_t tmpt = (tmp/particle->P()) * particle->Pt();
497 if (fDebug > 10) Info("Smear","Smearing changed P from %f to %f",particle->Pt(),tmpt);
498 TLorentzVector tmpvector;
499 tmpvector.SetPtEtaPhiM(tmpt,particle->Eta(), particle->Phi(), particle->GetMass());
500 // create a new particle with smearing momentum - and no daughter or parent information and the same
503 TParticle tmparticle(particle->GetPdgCode(), 1, 0, 0,0,0,
504 tmpvector.Px() , tmpvector.Py(), tmpvector.Pz(), tmpvector.Energy(),
505 particle->Vx(), particle->Vy(), particle->Vz(), particle->T());
506 fInputObject.AddTrack(tmparticle);
510 void AliEMCALJetFinderInputSimPrep::FillPartonTracks(AliEMCALParton *parton)
513 if (fDebug>1) Info("FillPartonTracks","Beginning FillPartonTracks");
514 Int_t npart = (gAlice->GetHeader())->GetNprimary();
516 TParticlePDG *getpdg;
518 for (Int_t part = 0; part < npart; part++)
520 tempPart = gAlice->Particle(part);
521 if (tempPart->GetStatusCode() != 1) continue;
522 if (tempPart->Eta() > fEtaMax || tempPart->Eta() < fEtaMin ||
523 tempPart->Phi() > fPhiMax || tempPart->Phi() < fPhiMin ){
524 if (fDebug>10) Info("FillPartonTracks","Excluding particle not pointing at the EMCAL");
527 getpdg = tempPart->GetPDG();
528 if (getpdg->Charge() == 0.0 ) {
529 if (fDebug>10) Info("FillPartonTracks","Excluding a neutral particle");
532 if ( (parton->Eta() - tempPart->Eta())*(parton->Eta() - tempPart->Eta()) +
533 (parton->Phi() - tempPart->Phi())*(parton->Phi() - tempPart->Phi()) < 1.0 ) ntracks++;
535 Float_t *Energy = new Float_t[ntracks];
536 Float_t *Eta = new Float_t[ntracks];
537 Float_t *Phi = new Float_t[ntracks];
538 Int_t *Pdg = new Int_t[ntracks];
540 for (Int_t part = 0; part < npart; part++)
542 tempPart = gAlice->Particle(part);
543 if (tempPart->GetStatusCode() != 1) continue;
544 if (tempPart->Eta() > fEtaMax || tempPart->Eta() < fEtaMin ||
545 tempPart->Phi() > fPhiMax || tempPart->Phi() < fPhiMin ){
546 if (fDebug>10) Info("FillPartonTracks","Excluding particle not pointing at the EMCAL");
549 if (tempPart->GetStatusCode() != 1) continue;
550 getpdg = tempPart->GetPDG();
551 if (getpdg->Charge() == 0.0 ) {
552 if (fDebug>10) Info("FillPartonTracks","Excluding a neutral particle");
555 if ( (parton->Eta() - tempPart->Eta())*(parton->Eta() - tempPart->Eta()) +
556 (parton->Phi() - tempPart->Phi())*(parton->Phi() - tempPart->Phi()) < 1.0 )
558 Energy[ntracks] = tempPart->Pt();
559 Eta[ntracks] = tempPart->Eta();
560 Phi[ntracks] = tempPart->Phi();
561 Pdg[ntracks] = tempPart->GetPdgCode();
565 parton->SetTrackList(ntracks,Energy,Eta,Phi,Pdg);