* full copyright notice. *
**************************************************************************/
+#include <memory>
#include "AliEveVSDCreator.h"
-#include <TEveTreeTools.h>
+#include "AliEveEventManager.h"
#include <AliStack.h>
#include <AliITSLoader.h>
#include <AliTPCTrackHitsV2.h>
#include <AliPDG.h>
#include <AliHit.h>
-#include <AliSimDigits.h>
-#include <AliKalmanTrack.h>
#include <AliESDEvent.h>
#include <AliESDv0.h>
#include <AliTPCclusterMI.h>
#include <AliTPCClustersRow.h>
-#include <AliITS.h>
#include <AliITSclusterV2.h>
-#include <AliTrackReference.h>
#include <AliESDkink.h>
#include <AliESDtrack.h>
#include <AliRun.h>
+#include <AliRunLoader.h>
#include <AliTPCParam.h>
+#include <TDatabasePDG.h>
#include <TSystem.h>
#include <TFile.h>
-#include <TError.h>
-
-
-using namespace std;
//______________________________________________________________________________
-// AliEveVSDCreator
//
+// Create VSD file from ALICE data.
ClassImp(AliEveVSDCreator)
AliEveVSDCreator::AliEveVSDCreator(const Text_t* name, const Text_t* title) :
TEveVSD(name, title),
- mKineType (KT_Standard),
- mDataDir ("."),
- mEvent (0),
-
- mTPCHitRes (2),
- mTRDHitRes (2),
-
- mDebugLevel (0),
- mGenInfoMap (),
+ fTPCHitRes (2),
+ fTRDHitRes (1),
- pRunLoader (0)
+ fDebugLevel (0),
+ fRunLoader (0),
+ fGenInfoMap ()
{
+ // Constructor.
+
// Particles not in ROOT's PDG database occuring in ALICE
AliPDG::AddParticlesToPdgDataBase();
- {
- TDatabasePDG *pdgDB = TDatabasePDG::Instance();
- // const Int_t kspe=50000000;
- const Int_t kion=10000000;
-
- const Double_t kAu2Gev=0.9314943228;
- const Double_t khSlash = 1.0545726663e-27;
- const Double_t kErg2Gev = 1/1.6021773349e-3;
- const Double_t khShGev = khSlash*kErg2Gev;
- const Double_t kYear2Sec = 3600*24*365.25;
-
- pdgDB->AddParticle("Deuteron","Deuteron",2*kAu2Gev+8.071e-3,kTRUE,
- 0,1,"Ion",kion+10020);
- pdgDB->AddParticle("Triton","Triton",3*kAu2Gev+14.931e-3,kFALSE,
- khShGev/(12.33*kYear2Sec),1,"Ion",kion+10030);
- pdgDB->AddParticle("Alpha","Alpha",4*kAu2Gev+2.424e-3,kTRUE,
- khShGev/(12.33*kYear2Sec),2,"Ion",kion+20040);
- pdgDB->AddParticle("HE3","HE3",3*kAu2Gev+14.931e-3,kFALSE,
- 0,2,"Ion",kion+20030);
- }
-
- // AliKalmanTrack::SetConvConst(1);
}
/******************************************************************************/
-void AliEveVSDCreator::CreateVSD(const Text_t* data_dir, Int_t event,
- const Text_t* vsd_file)
+void AliEveVSDCreator::CreateVSD(const Text_t* vsdFile)
{
- static const TEveException eH("AliEveVSDCreator::CreateVSD ");
+ // Create the VSD for current event in AliEveEventManager.
+ // Result is stored in directory "Event%04d".
- mDataDir = data_dir;
- mEvent = event;
+ static const TEveException kEH("AliEveVSDCreator::CreateVSD ");
- string galice_file (Form("%s/galice.root", mDataDir.Data()));
+ AliEveEventManager::AssertGeometry();
- if(mDebugLevel > 0)
- printf("%s opening %s \n", eH.Data(), galice_file.c_str());
+ fRunLoader = AliEveEventManager::AssertRunLoader();
- if(gSystem->AccessPathName(galice_file.c_str(), kReadPermission)) {
- throw(eH + "Can not read file '" + galice_file + "'.");
- }
- pRunLoader = AliRunLoader::Open(galice_file.c_str());
- if(pRunLoader == 0)
- throw(eH + "AliRunLoader::Open failed.");
+ if (fDebugLevel > 0)
+ printf("%s open seems ok. Now loading sim data.\n", kEH.Data());
- pRunLoader->LoadgAlice();
- Int_t status = pRunLoader->GetEvent(mEvent);
- if(status)
- throw(eH + Form("GetEvent(%d) failed, exit code %s.", mEvent, status));
+ fRunLoader->LoadHeader();
+ fRunLoader->LoadKinematics();
+ fRunLoader->LoadTrackRefs();
+ fRunLoader->LoadHits();
- if(mDebugLevel > 0)
- printf("%s open seems ok. Now loading sim data.\n", eH.Data());
+ if (fDebugLevel > 0)
+ printf("%s opening output TEveVSD.\n", kEH.Data());
- pRunLoader->LoadHeader();
- pRunLoader->LoadKinematics();
- pRunLoader->LoadTrackRefs();
- pRunLoader->LoadHits();
+ TFile* file = TFile::Open(vsdFile, "UPDATE", "ALICE Visualization Summary Data");
- // GledNS::PushFD();
+ Int_t curEvent = AliEveEventManager::CurrentEventId();
- if(mDebugLevel > 0)
- printf("%s opening output TEveVSD.\n", eH.Data());
+ TString eventDir; eventDir.Form("Event%04d", curEvent);
- TFile* file = TFile::Open(vsd_file, "RECREATE", "ALICE VisualizationDataSummary");
- fDirectory = new TDirectoryFile("Event0", "");
+ if (file->Get(eventDir))
+ {
+ Warning(kEH, "Event-dir '%s' existed -- replacing.", eventDir.Data());
+ file->Delete(eventDir + ";*");
+ }
- if(mDebugLevel > 0)
- printf("%s creating trees now ...\n", eH.Data());
+ fDirectory = new TDirectoryFile(eventDir, Form("Data for event %d", curEvent));
+
+ if (fDebugLevel > 0)
+ printf("%s creating trees now ...\n", kEH.Data());
CreateTrees();
- if(mDebugLevel > 0)
- printf("%s trees created, closing files.\n", eH.Data());
+ if (fDebugLevel > 0)
+ printf("%s trees created, closing files.\n", kEH.Data());
file->Write();
file->Close();
delete file;
- fDirectory =0;
-
- //GledNS::PopFD();
+ fDirectory = 0;
// clean after the TEveVSD data was sucessfuly written
fTreeK = 0;
fTreeR = 0;
fTreeGI = 0;
- pRunLoader->UnloadAll();
- delete pRunLoader;
- if(gAlice) {
- delete gAlice; gAlice = 0;
- }
- pRunLoader = 0;
+ fRunLoader = 0;
- if(mDebugLevel > 0)
- printf("%s all done.\n", eH.Data());
+ if (fDebugLevel > 0)
+ printf("%s all done.\n", kEH.Data());
}
void AliEveVSDCreator::CreateTrees()
{
- static const TEveException eH("AliEveVSDCreator::CreateTrees ");
+ // Create and fill the output trees by calling all the
+ // ConvertXyzz() functions.
+ // Exceptions from individual functions are displayed as warnings.
- if(fDirectory == 0)
- throw(eH + "output directory not set.");
+ static const TEveException kEH("AliEveVSDCreator::CreateTrees ");
- try {
- if(mDebugLevel > 1)
- printf("%sConvertKinematics.\n", eH.Data());
+ if (fDirectory == 0)
+ throw kEH + "output directory not set.";
+
+ try
+ {
+ if (fDebugLevel > 1)
+ printf("%sConvertKinematics.\n", kEH.Data());
ConvertKinematics();
- } catch(TEveException& exc) { Warning(eH, exc); }
+ }
+ catch(TEveException& exc)
+ {
+ Warning(kEH, exc);
+ }
- try {
- if(mDebugLevel > 1)
- printf("%sConvertHits.\n", eH.Data());
+ try
+ {
+ if (fDebugLevel > 1)
+ printf("%sConvertHits.\n", kEH.Data());
ConvertHits();
- } catch(TEveException& exc) { Warning(eH, exc); }
+ }
+ catch(TEveException& exc)
+ {
+ Warning(kEH, exc);
+ }
- try {
- if(mDebugLevel > 1)
- printf("%sConvertClusters.\n", eH.Data());
+ try
+ {
+ if (fDebugLevel > 1)
+ printf("%sConvertClusters.\n", kEH.Data());
ConvertClusters();
- } catch(TEveException& exc) { Warning(eH, exc); }
+ }
+ catch(TEveException& exc)
+ {
+ Warning(kEH, exc);
+ }
- try {
- if(mDebugLevel > 1)
- printf("%sConvertRecTracks.\n", eH.Data());
+ try
+ {
+ if (fDebugLevel > 1)
+ printf("%sConvertRecTracks.\n", kEH.Data());
ConvertRecTracks();
- } catch(TEveException& exc) {
+ }
+ catch(TEveException& exc)
+ {
Warning(exc, "skipping AliEveV0 extraction.");
goto end_esd_processing;
}
- try {
- if(mDebugLevel > 1)
- printf("%sConvertV0.\n", eH.Data());
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+ Warning(kEH, "Explicitly abandoning further conversion.");
+ return;
+
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+ try
+ {
+ if (fDebugLevel > 1)
+ printf("%sConvertV0.\n", kEH.Data());
ConvertV0();
- } catch(TEveException& exc) { Warning(eH, exc); }
+ }
+ catch(TEveException& exc)
+ {
+ Warning(kEH, exc);
+ }
- try {
- if(mDebugLevel > 1)
- printf("%sConvertKinks.\n", eH.Data());
+ try
+ {
+ if (fDebugLevel > 1)
+ printf("%sConvertKinks.\n", kEH.Data());
ConvertKinks();
- } catch(TEveException& exc) { Warning(eH, exc); }
+ }
+ catch(TEveException& exc)
+ {
+ Warning(kEH, exc);
+ }
end_esd_processing:
- try {
- if(mDebugLevel > 1)
- printf("%sConvertGenInfo.\n", eH.Data());
+ try
+ {
+ if (fDebugLevel > 1)
+ printf("%sConvertGenInfo.\n", kEH.Data());
ConvertGenInfo();
- } catch(TEveException& exc) { Warning(eH, exc); }
+ }
+ catch(TEveException& exc)
+ {
+ Warning(kEH, exc);
+ }
return;
}
void AliEveVSDCreator::ConvertKinematics()
{
- static const TEveException eH("AliEveVSDCreator::ConvertKinematics ");
+ // Convert kinematics.
+ // Track references are not stored, they should be.
+
+ static const TEveException kEH("AliEveVSDCreator::ConvertKinematics ");
- if(fTreeK != 0)
- throw (eH + "kinematics already converted");
+ if (fTreeK != 0)
+ throw kEH + "kinematics already converted";
- AliStack* stack = pRunLoader->Stack();
- if(stack == 0)
- throw(eH + "stack is null.");
+ AliStack* stack = fRunLoader->Stack();
+ if (stack == 0)
+ throw kEH + "stack is null.";
fDirectory->cd();
- fTreeK = new TTree("Kinematics", "TParticles sorted by Label");
+ fTreeK = new TTree("Kinematics", "Particles created during simulation.");
Int_t nentries = stack->GetNtrack();
- vector<TEveMCTrack> vmc(nentries);
- for (Int_t idx=0; idx<nentries; idx++) {
- TParticle* tp = stack->Particle(idx);
+ std::vector<TEveMCTrack> vmc(nentries);
+ for (Int_t idx = 0; idx < nentries; ++idx)
+ {
+ TParticle* tp = stack->Particle(idx);
vmc[idx] = *tp;
vmc[idx].fLabel = idx;
}
// read track refrences
// functionality now in AliEveKineTools.
/*
- TTree* fTreeTR = pRunLoader->TreeTR();
+ TTree* fTreeTR = fRunLoader->TreeTR();
if(fTreeTR == 0) {
- Warning(eH, "no TrackRefs; some data will not be available.");
+ Warning(kEH, "no TrackRefs; some data will not be available.");
} else {
TClonesArray* RunArrayTR = 0;
fTreeTR->SetBranchAddress("AliRun", &RunArrayTR);
fTreeK->Branch("K", "TEveMCTrack", &fpK, fBuffSize);
- printf("sizeofvmc = %d\n", vmc.size());
- for(vector<TEveMCTrack>::iterator k=vmc.begin(); k!=vmc.end(); ++k) {
+ printf("sizeofvmc = %d\n", (Int_t) vmc.size());
+ for(std::vector<TEveMCTrack>::iterator k = vmc.begin(); k != vmc.end(); ++k)
+ {
TEveMCTrack& mct = *k;
fK = mct;
TParticle* m = &mct;
Int_t mi = mct.fLabel;
int cnt = 0;
- while(m->GetMother(0) != -1) {
- if(cnt > 100) {
+ while (m->GetMother(0) != -1)
+ {
+ if (cnt > 100)
printf("cnt %d mi=%d, mo=%d\n", cnt, mi, m->GetMother(0));
- }
+
mi = m->GetMother(0);
m = &vmc[mi];
++cnt;
fTreeK->Fill();
}
- fTreeK->BuildIndex("label");
+ fTreeK->BuildIndex("fLabel");
}
-/******************************************************************************/
+
+//==============================================================================
// Hits
-/******************************************************************************/
+//==============================================================================
-namespace {
+void AliEveVSDCreator::ConvertHits()
+{
+ // Convert MC hits.
+ // TPC hits are handled specially as they are compressed - only mayor
+ // hits are stored
- struct Detector
- {
- const char* name;
- const char* hitbranch;
- unsigned char detidx;
- };
+ static const TEveException kEH("AliEveVSDCreator::ConvertHits ");
+
+ if (fTreeH != 0)
+ throw kEH + "hits already converted.";
- Detector detects[] = {
- { "ITS", "AliITShit", 0 },
- { "TPC", "AliTPCTrackHitsV2", 1 },
- { "TRD", "AliTRDhit", 2 },
- { "TOF", "AliTOFhit", 3 }
- // { "HMPID", "AliHMPIDhit", 4 },
- };
+ fDirectory->cd();
+ fTreeH = new TTree("Hits", "Simulated energy depositions in detector.");
+ fTreeH->Branch("H", "TEveHit", &fpH, fBuffSize);
+ try
+ {
+ ConvertAnyHits("ITS", "AliITShit", 0, 0);
+ ConvertTPCHits( 1, fTPCHitRes*fTPCHitRes);
+ ConvertAnyHits("TRD", "AliTRDhit", 2, fTRDHitRes*fTRDHitRes);
+ ConvertAnyHits("TOF", "AliTOFhit", 3, 0);
+
+ }
+ catch(TEveException& exc)
+ {
+ Warning(kEH, exc);
+ }
}
-/******************************************************************************/
+//------------------------------------------------------------------------------
-void AliEveVSDCreator::ConvertHits()
+void AliEveVSDCreator::ConvertAnyHits(const TString& detector,
+ const TString& clones_class,
+ Int_t det_id, Float_t minDistSqr)
{
- static const TEveException eH("AliEveVSDCreator::ConvertHits ");
+ // Convert hits for detector.
- if(fTreeH != 0)
- throw(eH + "hits already converted.");
+ static const TEveException kEH("AliEveVSDCreator::ConvertAnyHits ");
- fDirectory->cd();
- fTreeH = new TTree("Hits", "Combined detector hits.");
- fTreeH->Branch("H", "TEveHit", &fpH, fBuffSize);
-
- map<Int_t, Int_t> hmap;
- // parameters for ITS, TPC hits filtering
Float_t x,y,z, x1,y1,z1;
- Float_t tpc_sqr_res = mTPCHitRes*mTPCHitRes;
- Float_t trd_sqr_res = mTRDHitRes*mTRDHitRes;
-
- int l=0;
- // load hits from the rest of detectors
- while(detects[l].name != 0) {
- Detector& det = detects[l++];
-
- switch(det.detidx) {
- case 1: {
- Int_t count = 0;
- TTree* treeh = pRunLoader->GetTreeH(det.name, false);
- if(treeh == 0) {
- Warning(eH, Form("no hits for %s.", det.name));
- continue;
- }
- AliTPCTrackHitsV2 hv2, *_hv2=&hv2;
- treeh->SetBranchAddress("TPC2", &_hv2);
- Int_t np = treeh->GetEntries();
- for(Int_t i=0; i<np; i++){
- treeh->GetEntry(i);
- Int_t eva_idx = np -i -1;
- if (hv2.First() == 0) continue;
- x = y = z = 0;
- do {
- AliHit* ah = hv2.GetHit();
- x1 = ah->X(); y1 = ah->Y(); z1 = ah->Z();
- if ((x-x1)*(x-x1) + (y-y1)*(y-y1) + (z-z1)*(z-z1) > tpc_sqr_res)
- {
- fH.fDetId = det.detidx;
- fH.fSubdetId = 0;
- fH.fLabel = ah->Track();
- fH.fEvaLabel = eva_idx;
- fH.fV.fX = x1; fH.fV.fY = y1; fH.fV.fZ = z1;
- fTreeH->Fill();
- hmap[fH.fLabel]++;
- x = x1; y = y1; z = z1;
- count++;
- }
- } while (hv2.Next());
+
+ TTree* treeh = fRunLoader->GetTreeH(detector, kFALSE);
+ if (treeh == 0)
+ {
+ Warning(kEH, Form("no hits for %s.", detector.Data()));
+ return;
+ }
+
+ TClonesArray *arr = new TClonesArray(clones_class);
+ treeh->SetBranchAddress(detector, &arr);
+ Int_t np = treeh->GetEntries();
+
+ // In TreeH files hits are grouped in clones arrays
+ // each eva particle has its own clone array.
+
+ std::map<Int_t, Int_t> hmap;
+
+ for (Int_t i = 0; i < np; ++i)
+ {
+ treeh->GetEntry(i);
+ Int_t evaIdx = np - i - 1;
+ Int_t nh = arr->GetEntriesFast();
+ x = y = z = 0;
+ // printf("%d entry %d hits for primary %d \n", i, nh, evaIdx);
+ for (Int_t j = 0; j < nh; ++j)
+ {
+ AliHit* aliHit = (AliHit*)arr->UncheckedAt(j);
+
+ x1 = aliHit->X(); y1 = aliHit->Y(); z1 = aliHit->Z();
+ if (minDistSqr == 0 || (x-x1)*(x-x1) + (y-y1)*(y-y1) + (z-z1)*(z-z1) > minDistSqr)
+ {
+ fH.fDetId = det_id;
+ fH.fSubdetId = 0;
+ fH.fLabel = aliHit->GetTrack();
+ fH.fEvaLabel = evaIdx;
+ fH.fV.Set(aliHit->X(), aliHit->Y(), aliHit->Z());
+
+ fTreeH->Fill();
+
+ hmap[fH.fLabel]++;
+
+ x=x1; y=y1; z=z1;
}
- // printf("%d entries in TPChits \n",count);
- break;
}
- default: {
- TTree* treeh = pRunLoader->GetTreeH(det.name, false);
- if(treeh == 0) {
- Warning(eH, Form("no hits for %s.", det.name));
- continue;
- }
- TClonesArray *arr = new TClonesArray(det.hitbranch);
- treeh->SetBranchAddress(det.name, &arr);
- Int_t np = treeh->GetEntries();
- // in TreeH files hits are grouped in clones arrays
- // each eva particle has its own clone array
- for (Int_t i=0; i<np; i++) {
- treeh->GetEntry(i);
- Int_t eva_idx = np -i -1;
- Int_t nh=arr->GetEntriesFast();
- x = y = z = 0;
- // printf("%d entry %d hits for primary %d \n", i, nh, eva_idx);
- for (Int_t j=0; j<nh; j++) {
- AliHit* ali_hit = (AliHit*)arr->UncheckedAt(j);
- fH.fDetId = det.detidx;
- fH.fSubdetId = 0;
- fH.fLabel = ali_hit->GetTrack();
- fH.fEvaLabel = eva_idx;
- fH.fV.Set(ali_hit->X(), ali_hit->Y(), ali_hit->Z());
- if(det.detidx == 2) {
- x1=ali_hit->X();y1=ali_hit->Y();z1=ali_hit->Z();
- if((x-x1)*(x-x1)+(y-y1)*(y-y1)+(z-z1)*(z-z1) < trd_sqr_res) continue;
- x=x1; y=y1; z=z1;
- }
- hmap[fH.fLabel]++;
- fTreeH->Fill();
- }
- }
- delete arr;
- break;
- } // end default
- } // end switch
- } // end while
+ }
+ delete arr;
+ // Set geninfo.
+ for (std::map<Int_t, Int_t>::iterator j = hmap.begin(); j != hmap.end(); ++j)
+ {
+ GetGeninfo(j->first)->fNHits += j->second;
+ }
+}
- //set geninfo
- for(map<Int_t, Int_t>::iterator j=hmap.begin(); j!=hmap.end(); ++j) {
+//------------------------------------------------------------------------------
+
+void AliEveVSDCreator::ConvertTPCHits(Int_t det_id, Float_t minDistSqr)
+{
+ // Convert hits for TPC.
+
+ static const TEveException kEH("AliEveVSDCreator::ConvertTPCHits ");
+
+ Float_t x,y,z, x1,y1,z1;
+
+ TTree* treeh = fRunLoader->GetTreeH("TPC", false);
+ if (treeh == 0)
+ {
+ Warning(kEH, Form("no hits for %s.", "TPC"));
+ return;
+ }
+
+ AliTPCTrackHitsV2 hv2, *hv2p = &hv2;
+ treeh->SetBranchAddress("TPC2", &hv2p);
+ Int_t np = treeh->GetEntries();
+
+ std::map<Int_t, Int_t> hmap;
+
+ for (Int_t i = 0; i < np; ++i)
+ {
+ treeh->GetEntry(i);
+ Int_t evaIdx = np -i -1;
+ if (hv2.First() == 0) continue;
+ x = y = z = 0;
+ do
+ {
+ AliHit* ah = hv2.GetHit();
+ x1 = ah->X(); y1 = ah->Y(); z1 = ah->Z();
+ if (minDistSqr == 0 || (x-x1)*(x-x1) + (y-y1)*(y-y1) + (z-z1)*(z-z1) > minDistSqr)
+ {
+ fH.fDetId = det_id;
+ fH.fSubdetId = 0;
+ fH.fLabel = ah->Track();
+ fH.fEvaLabel = evaIdx;
+ fH.fV.fX = x1; fH.fV.fY = y1; fH.fV.fZ = z1;
+
+ fTreeH->Fill();
+
+ hmap[fH.fLabel]++;
+
+ x = x1; y = y1; z = z1;
+ }
+ } while (hv2.Next());
+ }
+
+ // Set geninfo.
+ for (std::map<Int_t, Int_t>::iterator j = hmap.begin(); j != hmap.end(); ++j)
+ {
GetGeninfo(j->first)->fNHits += j->second;
}
}
-/******************************************************************************/
+
+//==============================================================================
// Clusters
-/******************************************************************************/
+//==============================================================================
void AliEveVSDCreator::ConvertClusters()
{
- static const TEveException eH("AliEveVSDCreator::ConvertClusters ");
+ // Convert clusters.
+ //
+ // Only supported for ITS and TPC at the moment, see dedicated
+ // functions ConvertITSClusters() and ConvertTPCClusters().
+ //
+ // It should be possible now to do this in a general manner (with
+ // the alignment framework).
- if(fTreeC != 0)
- throw(eH + "clusters already converted.");
+ static const TEveException kEH("AliEveVSDCreator::ConvertClusters ");
+
+ if (fTreeC != 0)
+ throw kEH + "clusters already converted.";
fDirectory->cd();
- fTreeC = new TTree("Clusters", "rec clusters");
+ fTreeC = new TTree("Clusters", "Reconstructed points of particle passage.");
fTreeC->Branch("C", "TEveCluster", &fpC, fBuffSize);
- try {
- ConvertITSClusters();
- } catch(TEveException& exc) { Warning(eH, exc); }
+ try
+ {
+ ConvertAnyClusters("ITS", "ITSRecPoints", 0);
+ ConvertTPCClusters( 1);
+ ConvertAnyClusters("TRD", "TRDcluster", 2);
+ ConvertAnyClusters("TOF", "TOF", 3);
- try {
- ConvertTPCClusters();
- } catch(TEveException& exc) { Warning(eH, exc); }
+ }
+ catch(TEveException& exc)
+ {
+ Warning(kEH, exc);
+ }
}
-/******************************************************************************/
+//------------------------------------------------------------------------------
-void AliEveVSDCreator::ConvertTPCClusters()
+void AliEveVSDCreator::ConvertAnyClusters(const TString& detector,
+ const TString& branch_name,
+ Int_t det_id)
{
- static const TEveException eH("AliEveVSDCreator::ConvertTPCClusters ");
-
- auto_ptr<TFile> f
- ( TFile::Open(Form("%s/TPC.RecPoints.root", mDataDir.Data())) );
- if(!f.get())
- throw(eH + "can not open 'TPC.RecPoints.root' file.");
-
- auto_ptr<TDirectory> d
- ( (TDirectory*) f->Get(Form("AliEveEventManager%d", mEvent)) );
- if(!d.get())
- throw(eH + Form("event directory '%d' not found.", 0));
-
- auto_ptr<TTree> tree( (TTree*) d->Get("TreeR") );
- if(!tree.get())
- throw(eH + "'TreeR' not found.");
-
- auto_ptr<AliTPCParam> par( GetTpcParam(eH) );
-
- AliTPCClustersRow clrow, *_clrow=&clrow;
- AliTPCclusterMI *cl;
- _clrow->SetClass("AliTPCclusterMI");
- tree->SetBranchAddress("Segment", &_clrow);
-
- // count clusters
- Int_t nClusters = 0;
- Int_t n_ent = tree->GetEntries();
- for (Int_t n=0; n<n_ent; n++) {
- tree->GetEntry(n);
- nClusters += _clrow->GetArray()->GetEntriesFast();
- }
-
- // calculate xyz for a cluster and add it to container
- Double_t x,y,z;
- Float_t cs, sn, tmp;
- map<Int_t, Int_t> cmap;
-
- for (Int_t n=0; n<tree->GetEntries(); n++) {
- tree->GetEntry(n);
- Int_t ncl = _clrow->GetArray()->GetEntriesFast();
- if(ncl > 0) {
- Int_t sec,row;
- par->AdjustSectorRow(_clrow->GetID(),sec,row);
- while (ncl--) {
- if(_clrow->GetArray()) {
- // cl = new AliTPCclusterMI(*(AliTPCclusterMI*)_clrow->GetArray()->UncheckedAt(ncl));
- cl = (AliTPCclusterMI*)_clrow->GetArray()->UncheckedAt(ncl);
- if(cl->GetLabel(0) >= 0)
- {
- x = par->GetPadRowRadii(sec,row); y = cl->GetY(); z = cl->GetZ();
- par->AdjustCosSin(sec,cs,sn);
- tmp = x*cs-y*sn; y= x*sn+y*cs; x=tmp;
-
- fC.fDetId = 1;
- fC.fSubdetId = 0;
- fC.fLabel[0] = cl->GetLabel(0);
- fC.fLabel[1] = cl->GetLabel(1);
- fC.fLabel[2] = cl->GetLabel(2);
- fC.fV.Set(x, y, z);
-
- fTreeC->Fill();
- {
- int i = 0;
- while(i < 3 && fC.fLabel[i])
- cmap[fC.fLabel[i++]]++;
- }
- }
- }
+ // Convert clusters for detector and transform them to global coordinates.
+
+ static const TEveException kEH("AliEveVSDCreator::ConvertITSClusters ");
+
+ fRunLoader->LoadRecPoints(detector);
+ TTree* tree = fRunLoader->GetTreeR(detector, false);
+ if (!tree)
+ throw kEH + "'TreeR' not found.";
+
+ TClonesArray *cl = 0;
+ TBranch *branch = tree->GetBranch(branch_name);
+ branch->SetAddress(&cl);
+
+ Int_t nmods = branch->GetEntries();
+
+ std::map<Int_t, Int_t> cmap;
+
+ for (Int_t mod = 0; mod < nmods; ++mod)
+ {
+ branch->GetEntry(mod);
+ Int_t nc = cl->GetEntriesFast();
+ for (Int_t j = 0; j < nc; ++j)
+ {
+ AliCluster *c = (AliCluster*) cl->UncheckedAt(j);
+
+ fC.fDetId = det_id;
+ fC.fSubdetId = mod;
+ fC.fLabel[0] = c->GetLabel(0);
+ fC.fLabel[1] = c->GetLabel(1);
+ fC.fLabel[2] = c->GetLabel(2);
+
+ c->GetGlobalXYZ(fC.fV.Arr());
+
+ fTreeC->Fill();
+
+ {
+ int i = 0;
+ while (i < 3 && fC.fLabel[i])
+ cmap[fC.fLabel[i++]]++;
}
}
}
- //set geninfo
- for(map<Int_t, Int_t>::iterator j=cmap.begin(); j!=cmap.end(); ++j) {
+ delete cl;
+
+ for (std::map<Int_t, Int_t>::iterator j=cmap.begin(); j!=cmap.end(); ++j)
+ {
GetGeninfo(j->first)->fNClus += j->second;
}
}
-/******************************************************************************/
+//------------------------------------------------------------------------------
-void AliEveVSDCreator::ConvertITSClusters()
+void AliEveVSDCreator::ConvertTPCClusters(Int_t det_id)
{
- static const TEveException eH("AliEveVSDCreator::ConvertITSClusters ");
-
- auto_ptr<TFile> f
- ( TFile::Open(Form("%s/ITS.RecPoints.root", mDataDir.Data())) );
- if(!f.get())
- throw(eH + "can not open 'ITS.RecPoints.root' file.");
-
- auto_ptr<TDirectory> d
- ( (TDirectory*) f->Get(Form("AliEveEventManager%d", mEvent)) );
- if(!d.get())
- throw(eH + Form("event directory '%d' not found.", 0));
-
- auto_ptr<TTree> tree( (TTree*) d->Get("TreeR") );
- if(!tree.get())
- throw(eH + "'TreeR' not found.");
-
- AliITSLoader* ITSld = (AliITSLoader*) pRunLoader->GetLoader("ITSLoader");
- //AliITS* pITS = ITSld->GetITS();
- AliITSgeom* geom = ITSld->GetITSgeom();
- //AliITSgeom* geom = new AliITSgeom();
- //geom->ReadNewFile("/home/aljam/ITSgeometry.det");
-
- //printf("alice ITS geom %p \n",geom );
-
- if(!geom)
- throw(eH + "can not find ITS geometry");
-
- TClonesArray *arr = new TClonesArray("AliITSclusterV2");
- tree->SetBranchAddress("Clusters", &arr);
- Int_t nmods = tree->GetEntries();
- Float_t gc[3];
- map<Int_t, Int_t> cmap;
-
- for (Int_t mod=0; mod<nmods; mod++) {
- tree->GetEntry(mod);
- Int_t nc=arr->GetEntriesFast();
- for (Int_t j=0; j<nc; j++) {
- AliITSclusterV2* recp = (AliITSclusterV2*)arr->UncheckedAt(j);
-
- Double_t rot[9];
- geom->GetRotMatrix(mod,rot);
- Int_t lay,lad,det;
- geom->GetModuleId(mod,lay,lad,det);
- Float_t tx,ty,tz;
- geom->GetTrans(lay,lad,det,tx,ty,tz);
-
- Double_t alpha=TMath::ATan2(rot[1],rot[0])+TMath::Pi();
- Double_t phi1=TMath::Pi()/2+alpha;
- if(lay==1) phi1+=TMath::Pi();
-
- Float_t cp=TMath::Cos(phi1), sp=TMath::Sin(phi1);
- Float_t r=tx*cp+ty*sp;
- gc[0] = r*cp - recp->GetY()*sp;
- gc[1] = r*sp + recp->GetY()*cp;
- gc[2] = recp->GetZ();
-
- fC.fDetId = 0;
- fC.fSubdetId = 0;
- fC.fLabel[0] = recp->GetLabel(0);
- fC.fLabel[1] = recp->GetLabel(1);
- fC.fLabel[2] = recp->GetLabel(2);
- fC.fV.fX = r*cp - recp->GetY()*sp;
- fC.fV.fY = r*sp + recp->GetY()*cp;
- fC.fV.fZ = recp->GetZ();
+ // Convert TPC clusters and transform them to global coordinates.
+
+ static const TEveException kEH("AliEveVSDCreator::ConvertTPCClusters ");
+
+ const Int_t kMaxCl = 100*160;
+
+ fRunLoader->LoadRecPoints("TPC");
+ TTree* tree = fRunLoader->GetTreeR("TPC", false);
+ if (!tree)
+ throw kEH + "'TreeR' not found.";
+
+ AliTPCClustersRow *clrow = new AliTPCClustersRow;
+ clrow->SetClass("AliTPCclusterMI");
+ clrow->SetArray(kMaxCl);
+ tree->SetBranchAddress("Segment", &clrow);
+
+ Int_t nEnt = tree->GetEntries();
+
+ std::map<Int_t, Int_t> cmap;
+
+ for (Int_t j = 0; j < nEnt; ++j)
+ {
+ if (!tree->GetEvent(j)) continue;
+
+ TClonesArray *cl = clrow->GetArray();
+ Int_t ncl = cl->GetEntriesFast();
+
+ while (ncl--)
+ {
+ AliCluster *c = (AliCluster*) cl->UncheckedAt(ncl);
+
+ fC.fDetId = det_id;
+ fC.fSubdetId = j;
+ fC.fLabel[0] = c->GetLabel(0);
+ fC.fLabel[1] = c->GetLabel(1);
+ fC.fLabel[2] = c->GetLabel(2);
+
+ c->GetGlobalXYZ(fC.fV.Arr());
+
fTreeC->Fill();
- { int i = 0;
- while(i < 3 && fC.fLabel[i])
+
+ {
+ int i = 0;
+ while (i < 3 && fC.fLabel[i])
cmap[fC.fLabel[i++]]++;
}
}
- for(map<Int_t, Int_t>::iterator j=cmap.begin(); j!=cmap.end(); ++j) {
- GetGeninfo(j->first)->fNClus += j->second;
- }
+ cl->Clear();
+ }
+ delete clrow;
+
+ //set geninfo
+ for (std::map<Int_t, Int_t>::iterator j=cmap.begin(); j!=cmap.end(); ++j)
+ {
+ GetGeninfo(j->first)->fNClus += j->second;
}
- delete arr;
}
+
/******************************************************************************/
// ESD
/******************************************************************************/
void AliEveVSDCreator::ConvertRecTracks()
{
- static const TEveException eH("AliEveVSDCreator::ConvertRecTracks ");
-
- if(fTreeR != 0)
- throw(eH + "tracks already converted.");
+ // Convert reconstructed tracks.
- fDirectory->cd();
- fTreeR = new TTree("RecTracks", "rec tracks");
+ static const TEveException kEH("AliEveVSDCreator::ConvertRecTracks ");
- fTreeR->Branch("R", "TEveRecTrack", &fpR, 512*1024,1);
+ if (fTreeR != 0)
+ throw kEH + "tracks already converted.";
- TFile f(Form("%s/AliESDs.root", mDataDir.Data()));
- if(!f.IsOpen())
- throw(eH + "no AliESDs.root file.");
-
- TTree* tree = (TTree*) f.Get("esdTree");
- if (tree == 0)
- throw(eH + "no esdTree.");
-
-
- AliESDEvent *fEvent= new AliESDEvent();
- fEvent->ReadFromTree(tree);
- tree->GetEntry(mEvent);
- if(fEvent->GetAliESDOld())fEvent->CopyFromOldESD();
+ AliESDEvent* esdEvent = AliEveEventManager::AssertESD();
+ fDirectory->cd();
+ fTreeR = new TTree("RecTracks", "Reconstructed particle trajectories.");
+ fTreeR->Branch("R", "TEveRecTrack", &fpR, 512*1024);
// reconstructed tracks
- AliESDtrack* esd_t;
+ AliESDtrack* esdTrack;
Double_t dbuf[3];
- for (Int_t n=0; n<fEvent->GetNumberOfTracks(); n++) {
- esd_t = fEvent->GetTrack(n);
-
- fR.fLabel = esd_t->GetLabel();
- fR.fStatus = (Int_t) esd_t->GetStatus();
- fR.fSign = (Int_t) esd_t->GetSign();
- esd_t->GetXYZ(dbuf); fR.fV.Set(dbuf);
- esd_t->GetPxPyPz(dbuf); fR.fP.Set(dbuf);
- Double_t ep = esd_t->GetP();
- fR.fBeta = ep/TMath::Sqrt(ep*ep + TMath::C()*TMath::C()*esd_t->GetMass()*esd_t->GetMass());
+ for (Int_t n = 0; n < esdEvent->GetNumberOfTracks(); ++n)
+ {
+ esdTrack = esdEvent->GetTrack(n);
+
+ fR.fLabel = esdTrack->GetLabel();
+ fR.fStatus = (Int_t) esdTrack->GetStatus();
+ fR.fSign = (Int_t) esdTrack->GetSign();
+ esdTrack->GetXYZ(dbuf); fR.fV.Set(dbuf);
+ esdTrack->GetPxPyPz(dbuf); fR.fP.Set(dbuf);
+ Double_t ep = esdTrack->GetP();
+ fR.fBeta = ep/TMath::Sqrt(ep*ep + TMath::C()*TMath::C()*esdTrack->GetMass()*esdTrack->GetMass());
fTreeR->Fill();
}
- fTreeR->BuildIndex("label");
- delete fEvent;
+
+ fTreeR->BuildIndex("fLabel");
}
/******************************************************************************/
void AliEveVSDCreator::ConvertV0()
{
- static const TEveException eH("AliEveVSDCreator::ConvertV0 ");
+ // Convert reconstructed V0s.
- if(fTreeV0 != 0)
- throw(eH + "AliEveV0 already converted.");
+ static const TEveException kEH("AliEveVSDCreator::ConvertV0 ");
+
+ if (fTreeV0 != 0)
+ throw kEH + "AliEveV0 already converted.";
+
+ AliESDEvent* esdEvent = AliEveEventManager::AssertESD();
fDirectory->cd();
fTreeV0 = new TTree("AliEveV0", "AliEveV0 points");
fTreeV0->Branch("AliEveV0", "TEveRecV0", &fpV0, 512*1024,1);
- TFile f(Form("%s/AliESDs.root", mDataDir.Data()));
- if(!f.IsOpen()){
- throw(eH + "no AliESDs.root file.");
- }
-
- TTree* tree = (TTree*) f.Get("esdTree");
- if (tree == 0)
- throw(eH + "no esdTree.");
-
- AliESDEvent *fEvent= new AliESDEvent();
- fEvent->ReadFromTree(tree);
- tree->GetEntry(mEvent);
- if(fEvent->GetAliESDOld())fEvent->CopyFromOldESD();
-
- for (Int_t n =0; n< fEvent->GetNumberOfV0s(); n++)
+ for (Int_t n = 0; n < esdEvent->GetNumberOfV0s(); ++n)
{
- AliESDv0 *av = fEvent->GetV0(n);
- AliESDtrack *trackN = fEvent->GetTrack(av->GetNindex()); // negative daughter
- AliESDtrack *trackP = fEvent->GetTrack(av->GetPindex()); // positive daughter
+ AliESDv0 *av = esdEvent->GetV0(n);
+ AliESDtrack *trackN = esdEvent->GetTrack(av->GetNindex()); // negative daughter
+ AliESDtrack *trackP = esdEvent->GetTrack(av->GetPindex()); // positive daughter
Double_t pos[3];
fTreeV0->Fill();
}
- // if(fEvent->GetNumberOfV0s()) fTreeV0->BuildIndex("label");
- delete fEvent;
+ // if (esdEvent->GetNumberOfV0s()) fTreeV0->BuildIndex("label");
+ delete esdEvent;
}
/******************************************************************************/
void AliEveVSDCreator::ConvertKinks()
{
- static const TEveException eH("AliEveVSDCreator::ConvertKinks ");
+ // Convert reconstructed kinks.
- if(fTreeKK != 0)
- throw(eH + "Kinks already converted.");
+ static const TEveException kEH("AliEveVSDCreator::ConvertKinks ");
- fDirectory->cd();
- fTreeKK = new TTree("Kinks", "ESD Kinks");
-
- fTreeKK->Branch("KK", "TEveRecKink", &fpKK, fBuffSize);
-
- TFile f(Form("%s/AliESDs.root", mDataDir.Data()));
- if(!f.IsOpen()){
- throw(eH + "no AliESDs.root file.");
- }
+ if (fTreeKK != 0)
+ throw kEH + "Kinks already converted.";
- TTree* tree = (TTree*) f.Get("esdTree");
- if (tree == 0)
- throw(eH + "no esdTree.");
+ throw kEH + "Currently non-supported - TEveRecKink being updated.";
+ /*
+ AliESDEvent* esdEvent = AliEveEventManager::AssertESD();
- AliESDEvent *fEvent= new AliESDEvent();
- fEvent->ReadFromTree(tree);
- tree->GetEntry(mEvent);
- if(fEvent->GetAliESDOld())fEvent->CopyFromOldESD();
+ fDirectory->cd();
+ fTreeKK = new TTree("Kinks", "ESD Kinks");
+ fTreeKK->Branch("KK", "TEveRecKink", &fpKK, fBuffSize);
- // printf("CONVERT KINK Read %d entries in tree kinks \n", fEvent->GetNumberOfKinks());
- for (Int_t n =0; n< fEvent->GetNumberOfKinks(); n++) {
- AliESDkink* kk = fEvent->GetKink(n);
+ // printf("CONVERT KINK Read %d entries in tree kinks \n", esdEvent->GetNumberOfKinks());
+ for (Int_t n = 0; n < esdEvent->GetNumberOfKinks(); ++n)
+ {
+ AliESDkink* kk = esdEvent->GetKink(n);
Double_t pos[3];
fKK.fLabel = kk->GetLabel(0);
- fKK.fStatus = Int_t(kk->GetStatus(1) << 8 + kk->GetStatus(2));
+ fKK.fStatus = 0; // status is Char_t[12] ... have no idea how/what to extract.
// reconstructed kink position
fKK.fLabelSec = kk->GetLabel(1);
fKK.fVKink.Set(kk->GetPosition());
- const AliExternalTrackParam& tp_mother = kk->RefParamMother();
+ const AliExternalTrackParam& tpMother = kk->RefParamMother();
// momentum and position of mother
- tp_mother.GetPxPyPz(pos);
+ tpMother.GetPxPyPz(pos);
fKK.fP.Set(pos);
- tp_mother.GetXYZ(pos);
+ tpMother.GetXYZ(pos);
fKK.fV.Set(pos);
- const Double_t* par = tp_mother.GetParameter();
- // printf("KINK Pt %f, %f \n",1/tp_mother.Pt(),par[4] );
+ const Double_t* par = tpMother.GetParameter();
+ // printf("KINK Pt %f, %f \n",1/tpMother.Pt(),par[4] );
fKK.fSign = (par[4] < 0) ? -1 : 1;
- const AliExternalTrackParam& tp_daughter = kk->RefParamDaughter();
+ const AliExternalTrackParam& tpDaughter = kk->RefParamDaughter();
// momentum and position of daughter
- tp_daughter.GetPxPyPz(pos);
+ tpDaughter.GetPxPyPz(pos);
fKK.fPSec.Set(pos);
- tp_daughter.GetXYZ(pos);
+ tpDaughter.GetXYZ(pos);
fKK.fVEnd.Set(pos);
fTreeKK->Fill();
}
- if(fEvent->GetNumberOfKinks()) fTreeKK->BuildIndex("label");
- delete fEvent;
+ if (esdEvent->GetNumberOfKinks()) fTreeKK->BuildIndex("label");
+ delete esdEvent;
+ */
}
/******************************************************************************/
// TEveMCRecCrossRef
void AliEveVSDCreator::ConvertGenInfo()
{
- static const TEveException eH("AliEveVSDCreator::ConvertGenInfo ");
+ // Build simulation-reconstruction cross-reference table.
+ // In a rather poor state at the moment.
- if(fTreeGI != 0)
- throw(eH + "GI already converted.");
+ static const TEveException kEH("AliEveVSDCreator::ConvertGenInfo ");
+
+ if (fTreeGI != 0)
+ throw kEH + "GI already converted.";
fDirectory->cd();
fTreeGI = new TTree("TEveMCRecCrossRef", "Objects prepared for cross querry");
fTreeGI->Branch("K.", "TEveMCTrack", &fpK);
fTreeGI->Branch("R.", "TEveRecTrack", &fpR);
- for (map<Int_t, TEveMCRecCrossRef*>::iterator j=mGenInfoMap.begin(); j!=mGenInfoMap.end(); ++j) {
+ for (std::map<Int_t, TEveMCRecCrossRef*>::iterator j=fGenInfoMap.begin(); j!=fGenInfoMap.end(); ++j)
+ {
fGI = *(j->second);
fGI.fLabel = j->first;
fTreeK->GetEntry(j->first);
if(re != -1)
fGI.fIsRec = true;
}
- // Int_t has_v0 = fTreeV0->GetEntryNumberWithIndex(j->first);
- //if (has_v0 != -1)
+ // Int_t hasV0 = fTreeV0->GetEntryNumberWithIndex(j->first);
+ //if (hasV0 != -1)
// fGI.has_AliEveV0 = true;
- if (fTreeKK) {
- Int_t has_kk = fTreeKK->GetEntryNumberWithIndex(j->first);
- if (has_kk != -1)
+ if (fTreeKK)
+ {
+ Int_t hasKk = fTreeKK->GetEntryNumberWithIndex(j->first);
+ if (hasKk != -1)
fGI.fHasKink = true;
}
fTreeGI->Fill();
}
- mGenInfoMap.clear();
+ fGenInfoMap.clear();
}
/******************************************************************************/
/******************************************************************************/
/******************************************************************************/
-AliTPCParam* AliEveVSDCreator::GetTpcParam(const TEveException& eh)
-{
- auto_ptr<TFile> fp( TFile::Open(Form("%s/galice.root", mDataDir.Data())) );
- if(!fp.get())
- throw(eh + "can not open 'galice.root' file.");
- AliTPCParam* par = (AliTPCParam *) fp->Get("75x40_100x60_150x60");
- if(!par)
- throw(eh + "TPC data not found.");
- return par;
-}
-
-
-
TEveMCRecCrossRef* AliEveVSDCreator::GetGeninfo(Int_t label)
{
+ // Return the cross-reference structure for given label.
+ // If the object does not exist it is created.
+
// printf("get_geninfo %d\n", label);
TEveMCRecCrossRef* gi;
- map<Int_t, TEveMCRecCrossRef*>::iterator i = mGenInfoMap.find(label);
- if(i == mGenInfoMap.end()) {
+ std::map<Int_t, TEveMCRecCrossRef*>::iterator i = fGenInfoMap.find(label);
+ if (i == fGenInfoMap.end())
+ {
gi = new TEveMCRecCrossRef();
- mGenInfoMap[label] = gi;
- } else {
+ fGenInfoMap[label] = gi;
+ }
+ else
+ {
gi = i->second;
}
return gi;