Update tracking class and macros, and pid class to read correctly the ESDs
authorgconesab <gconesab@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 7 Jul 2009 15:49:40 +0000 (15:49 +0000)
committergconesab <gconesab@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 7 Jul 2009 15:49:40 +0000 (15:49 +0000)
EMCAL/AliEMCALPID.cxx
EMCAL/AliEMCALTracker.cxx
EMCAL/macros/trackMatching/DrawComparison.C
EMCAL/macros/trackMatching/FindMatches.C
EMCAL/macros/trackMatching/MatchComparison.C
EMCAL/macros/trackMatching/SaveTrueMatchesSimple.C

index 60be817782690760f6fd187a3eef0cdee310a585..a98382558394ca0803c16e3099e2f39a27fb8f48 100644 (file)
@@ -167,12 +167,13 @@ void AliEMCALPID::RunPID(AliESDEvent *esd)
     return ;
   }
 
-  Int_t nClusters = esd->GetNumberOfEMCALClusters();
-  Int_t firstCluster = esd->GetFirstEMCALCluster();
+  Int_t nClusters = esd->GetNumberOfCaloClusters();
+  Int_t firstCluster = 0;
   Double_t energy, lambda0;
   for (Int_t iCluster = firstCluster; iCluster < (nClusters + firstCluster); iCluster++) {
 
     AliESDCaloCluster *clust = esd->GetCaloCluster(iCluster);
+       if (!clust->IsEMCAL()) continue ; 
     energy = clust->E();
     lambda0 = clust->GetM02();
     // verify cluster type
index 4ccd4f18efb092c21abc2468d7d4ad6e38979d82..99ec18eb52316efdcb324839f7c2b13da0b0b86f 100644 (file)
@@ -155,7 +155,8 @@ void AliEMCALTracker::InitParameters()
        //
        
   // Check if the instance of AliEMCALRecParam exists, 
-  const AliEMCALRecParam* recParam = AliEMCALReconstructor::GetRecParam();
+  const AliEMCALRecParam* recParam = new AliEMCALRecParam();
+
   if(!recParam){
     AliFatal("Reconstruction parameters for EMCAL not set!");
   }
@@ -305,8 +306,8 @@ Int_t AliEMCALTracker::LoadClusters(AliESDEvent *esd)
        // make sure that tracks/clusters collections are empty
        Clear("CLUSTERS");
        
-       Int_t start = esd->GetFirstEMCALCluster();
-       Int_t nClustersEMC = esd->GetNumberOfEMCALClusters();
+       Int_t start = 0;
+       Int_t nClustersEMC = esd->GetNumberOfCaloClusters();
        Int_t end = start + nClustersEMC;
        
        fClusters = new TObjArray(0);
@@ -315,7 +316,7 @@ Int_t AliEMCALTracker::LoadClusters(AliESDEvent *esd)
        for (i = start; i < end; i++) {
                AliESDCaloCluster *cluster = esd->GetCaloCluster(i);
                if (!cluster) continue;
-               if (cluster->GetClusterType() != AliESDCaloCluster::kEMCALClusterv1) continue;
+        if (!cluster->IsEMCAL()) continue ; 
                AliEMCALMatchCluster *matchCluster = new AliEMCALMatchCluster(i, cluster);
                fClusters->AddLast(matchCluster);
        }
index 5b6db4e873a6ffd794d407d27b50aab8f3541a0d..6873e5f4622d625d2a24d0fd3446d74b78e5bdc0 100755 (executable)
@@ -2,41 +2,46 @@
 // This macro reads comparison files and makes plots.
 //
 
-void DrawComparison
-(const char *fileName = "match-comparison.root")
+void DrawComparison(const char *fileName = "match-comparison.root")
 {
-       TH1D *hg = new TH1D("hg", "Good matches / true matches", 20, 0.0,  10.0);
-       TH1D *hf = new TH1D("hf", "Fake matches / found matches", 20, 0.0,  10.0);
        
+       gROOT->SetStyle("Plain");
+       gStyle->SetOptStat(0);
        // 
        // Open file
        //
        TFile *file = TFile::Open(fileName);
        if (!file) return;
        
-       TH1D *hgood = (TH1D*)file->Get("hgood");
-       TH1D *hfake = (TH1D*)file->Get("hfake");
-       TH1D *htrue = (TH1D*)file->Get("htrue");
+       TH1D *hgood  = (TH1D*)file->Get("hgood");
+       TH1D *hfake  = (TH1D*)file->Get("hfake");
+       TH1D *htrue  = (TH1D*)file->Get("htrue");
        TH1D *hfound = (TH1D*)file->Get("hfound");
 
-       gROOT->SetStyle("Plain");
-       gStyle->SetOptStat(0);
-       
-       hg->Divide(hgood, htrue, 100.0, 1.0, "b");
-       hf->Divide(hfake, hfound, 100.0, 1.0, "b");
-       
-       TCanvas *c = new TCanvas("c", "", 0, 0, 800, 600);
+        TH1D *hg = (TH1D*)hgood->Clone("hg");
+        TH1D *hf = (TH1D*)hfake->Clone("hf");
        
+       hg->Divide( htrue );
+       hf->Divide( hfound);
+       hg->Scale(100);
+       hf->Scale(100);
        hg->SetMarkerStyle(21);
        hf->SetMarkerStyle(25);
        
-       hg->SetXTitle("p_{T} (GeV/c)");
+       TCanvas *c = new TCanvas("c", "", 0, 0, 800, 600);
 
-       hg->GetXaxis()->SetRangeUser(0.0, 6.0);
-       hf->GetXaxis()->SetRangeUser(0.0, 6.0);
-       
+       TLegend* leg = new TLegend(0.6,0.8,0.88,0.88);
+       leg->SetFillColor(10);
+       leg->AddEntry(hg,"Good/True","p");
+       leg->AddEntry(hf,"Fake/Found","p");
+                       
+       hg->SetXTitle("p_{T} (GeV/c)");
+       hg->SetYTitle("efficiency (%)");
+       hg->SetTitle("Track-EMCAL Cluster Matching");
        hg->SetMaximum(120.0);
        hg->SetMinimum(0.0);
        hg->Draw("PE1");
        hf->Draw("PE1same");
+       leg->Draw();
+       
 }      
index 366ac224b387845bab051af4e9f677fe6af15698..547c93fb4af9d5d0b2276ed7735be29b358d564f 100755 (executable)
@@ -25,17 +25,19 @@ void FindMatches(const char *fileOut = "matchESD.root")
        if (!rl) return;
        rl->LoadgAlice();
        gAlice = rl->GetAliRun();
-       AliMagF *magf = gAlice->Field();
-       Bool_t constField = (magf->Type() == 1);
-       AliTracker::SetFieldMap(magf, constField);
        
+       //AliMagF *magf = new AliMagF("Maps","Maps", 2, 1., 1., 10., AliMagF::k5kG);
+       AliMagF *magf = new AliMagF("Maps","Maps", 2, 1., 1.);
+       
        //
        // Open ESD file and recoveries TTree of ESD objects.
        //
        TFile *esdFile = new TFile("AliESDs.root");
        TTree *esdTree = (TTree*)esdFile->Get("esdTree");
-       AliESD *esd = 0;
-       esdTree->SetBranchAddress("ESD", &esd);
+       AliESDEvent* esd = new AliESDEvent();
+       esd->ReadFromTree(esdTree);
+       if (!esd) {cerr<<"no AliESDEvent"; return 1;};
+       
        Long64_t nEvents = esdTree->GetEntries();
        
        //
@@ -79,7 +81,8 @@ void FindMatches(const char *fileOut = "matchESD.root")
        //
        TFile *outFile = TFile::Open(fileOut, "RECREATE");
        TTree *outTree = new TTree("esdTree", "ESD with matched clusters");
-       outTree->Branch("ESD", "AliESD", &esd);
+       //outTree->Branch("ESD", "AliESD", &esd);
+       esd->WriteToTree(outTree);
        
        //
        // Loop on events.
index c768f591ab73f108e3a296c9b37d3e00ef8036c4..a65284f8946c5bfae909761e4938fa672092660c 100755 (executable)
@@ -25,10 +25,6 @@ void MatchComparison()
        //
        // Initialize AliRun manager
        //
-       if (gAlice) {
-               delete gAlice;
-               gAlice = 0;
-       }
        
        //
        // Initialize run loader and load Kinematics
@@ -42,10 +38,10 @@ void MatchComparison()
        //
        // Initialize histograms with their error computation
        //
-       TH1D *hgood = new TH1D("hgood", "Well matched tracks", 20, 0.0,  10.0);
-       TH1D *hfake = new TH1D("hfake", "Fake matched tracks", 20, 0.0,  10.0);
-       TH1D *htrue = new TH1D("htrue", "True matches", 20, 0.0,  10.0);
-       TH1D *hfound = new TH1D("hfound", "Found matches", 20, 0.0,  10.0);
+       TH1D *hgood  = new TH1D("hgood", "Well matched tracks", 40, 0.0,  40.0);
+       TH1D *hfake  = new TH1D("hfake", "Fake matched tracks", 40, 0.0,  40.0);
+       TH1D *htrue  = new TH1D("htrue", "True matches"       , 40, 0.0,  40.0);
+       TH1D *hfound = new TH1D("hfound","Found matches"      , 40, 0.0,  40.0);
        hgood->Sumw2();
        hfake->Sumw2();
        htrue->Sumw2();
@@ -64,8 +60,8 @@ void MatchComparison()
        //
        TFile *fileFound = TFile::Open("matchESD.root");
        TTree *treeFound = (TTree*)fileFound->Get("esdTree");
-       AliESD *esd = 0;
-       treeFound->SetBranchAddress("ESD", &esd);
+       AliESDEvent* esd = new AliESDEvent();
+       esd->ReadFromTree(treeFound);
        Long64_t nEvents = treeFound->GetEntries();
        
        //
@@ -90,9 +86,12 @@ void MatchComparison()
                for (im = 0; im < nTrueMatches; im++) {
                        treeTrue->GetEntry(im);
                        AliESDtrack *track = esd->GetTrack(trueMatch.indexT);
+                       if (!track) continue;
+                       
                        label = TMath::Abs(track->GetLabel());
                        TParticle *p = stack->Particle(label);
                        htrue->Fill(p->Pt());
+                       cout <<"filling true"<< endl;
                }
                
                // compare found matches
@@ -103,17 +102,20 @@ void MatchComparison()
                        ic = TMath::Abs(ic);
                        AliESDCaloCluster *cl = esd->GetCaloCluster(ic);
                        if (!cl) continue;
+                       if (!cl->IsEMCAL()) continue ;
                        trkLabel = TMath::Abs(track->GetLabel());
-                       cluLabel = cl->GetPrimaryIndex();
+                       cluLabel = cl->GetLabel();
                        if (trkLabel == cluLabel && trkLabel >= 0) {
                                TParticle *p = stack->Particle(TMath::Abs(trkLabel));
                                hgood->Fill(p->Pt());
                                hfound->Fill(p->Pt());
+                               cout <<"filling GOOD, pt:" << p->Pt()<< endl;
                        }
                        else  {
                                TParticle *p = stack->Particle(TMath::Abs(trkLabel));
                                hfake->Fill(p->Pt());
                                hfound->Fill(p->Pt());
+                               cout <<"filling FAKE" << endl;
                        }
                }
        }
index fec167e21749e6c87c0644cd4214db3de30af438..d5963bbe0e58e9300b1edff566c3914f766ed72a 100755 (executable)
@@ -31,7 +31,7 @@ class match_t
 //
 // Read AliESDs.root file and saves all true pairs of trak-cluster.
 //
-void SaveTrueMatchesSimple_compiled(const char *outFileName)
+void SaveTrueMatchesSimple(const char *outFileName="true-matches.root")
 {
        //
        // open ESD file, retrieve tree and link to branch cursor
@@ -40,8 +40,9 @@ void SaveTrueMatchesSimple_compiled(const char *outFileName)
        if (!srcFile) return;
        TTree *srcTree = (TTree*)srcFile->Get("esdTree");
        if (!srcTree) return;
-       AliESD *esd = 0;
-       srcTree->SetBranchAddress("ESD", &esd);
+       
+       AliESDEvent* esd = new AliESDEvent();
+       esd->ReadFromTree(srcTree);     
        Long64_t nEvents = srcTree->GetEntries();
        
        //
@@ -61,8 +62,8 @@ void SaveTrueMatchesSimple_compiled(const char *outFileName)
                cout << "Event " << iev + 1 << " of " << nEvents << ": " << endl;
                
                nTracks = esd->GetNumberOfTracks();
-               firstCluster = esd->GetFirstEMCALCluster();
-               lastCluster = esd->GetFirstEMCALCluster() + esd->GetNumberOfEMCALClusters();
+               firstCluster = 0;
+               lastCluster  = esd->GetNumberOfCaloClusters();
                cout << "Tracks found      : " << nTracks << endl;
                cout << "EMC clusters found: " << lastCluster - firstCluster << endl;
                
@@ -101,9 +102,8 @@ void SaveTrueMatchesSimple_compiled(const char *outFileName)
                        count = 0;
                        for (Int_t ic = firstCluster; ic < lastCluster; ic++) {
                                AliESDCaloCluster *cl = esd->GetCaloCluster(ic);
-                               // reject pseudo-clusters & unmatched clusters
-                               if (cl->GetClusterType() != AliESDCaloCluster::kClusterv1) continue;
-                               if (cl->GetPrimaryIndex() != label) continue;
+                               if (!cl->IsEMCAL()) continue;
+                               if (cl->GetLabel() != label) continue;
                                // if the method reaches this point, we
                                // have found a match to be stored
                                match.label = label;