ALICE Project Task

Exercise 1:  I'm going to compare data from two diffrent events from the ALICE detector in LHC, CERN. One being the offline ESD event and the other online HLT event.

I will compare these two by reading from the ESD and HLTESD Trees, and printing them out in the same plot.
The track properties i'm going to plot are the following:

-> Momentum.
-> Transverse Momentum.
-> Theta angle.
-> Phi angle.
-> The number of Time Projection Chamber clusters per track.
-> Charged track multiplicity per event.



Programming code and Files.txt

The program main.C can be found as a .tar file here.

The Files.txt can be found here
.

(If The main link doesn't work then the coding can be found further down this site.)


Conclusion:

I was not able to compile the code properly, and therfore not able to produce any images of plots.
But having looked into the different plots by using the TBrowser I can explain what the plots should have looked like and the differance between ESD and HLTESD.




Momentum:
The visible differance of esd and hlt esd momentum is that there is more particles in hlt just above 0 GeV in the hlt tree.
While there seems to be more particles in the offline tree (esd) at higher energies. The plot has many particles with low energy and rapidly
changes to fewer particles in the higher energies.


Transverse Momentum:
The differance here is pretty much the same as in the momentum above. But it seems as if there are fewer particles overall with transverse momentum. 

Theta angle:
Again, there are more particles in the oflline tree. This plot has a shape simmilar to a cone, with center at 1.6 radians. The biggest
differance between the two trees is that the offline tree has more much more particles around 0.8 and 2.4 radians.


Phi angle:
This angle describes the particles in the transverse plane. The offline ESD tree contains more particles than the HLT ESD tree. Also the
plot curve of the offline tree should be more even in the particle direction than the hlt tree.


Number of Time Projection Clusters:
Shouldn't be much of a differance here.

Charged Track Multiplicity:
No differance between the oflline and HLT tree here as far as I can tell.





Coding of main.C:


/*

This program takes raw data from ALICE ESD and HLTESD Trees, and compares them
by using plots.

    -Void comaparetrees(): Takes data from the ESD and HLTESD histograms and compares them
    by using plots, and printing out a .png file.

    -int main(): First reads from a file to locate the addresses for the Trees. Then
    it uses these values to fill histograms for later plotting. 



!!! I was not able to compile my code and therfore not able to produce any .png files by
    the time it was Final Deadline.
     Instead I am going to show you the coding I've got so far and use TBrowser to make
    an assumption of what the different .png should have looked like.

*/



//Used headers.
#include <iostream>
#include <TChain.h>
#include <TH1D.h>
#include <TCanvas.h>
#include <TGraph.h>
#include <TStyle.h>
#include <fstream.h>
#include <TLegend.h>




//Making a subfunction to program the ploting to take less coding space.
void comparetrees(TCanvas * canv1, TH1D * esd_values, const char file, TH1D * hlt_values){

    //Naming and coloring the two histograms.
    esd_values->SetName("ESD Tree");
    esd_values->SetLineColor(2);
    hlt_values->SetName("HLT ESD Tree");
    hlt_values->SetLineColor(1);
 
    //Creating and drawing a legend.
    TLegend * legend = new TLegend (0.3, 0.9, 0.6, 0.8);
    legend->AddEntry(esd_values, "ESD Tree");
    legend->AddEntry(hlt_values, "HLT ESD Tree");
    legend->Draw();

  
    if(esd_values->GetMinimum() < hlt_values->GetMinimum()){
        hlt_values->SetMinimum(esd_values->GetMinimum());
    } else {
   esd_values->SetMinimum(hlt_values->GetMinimum());
   }

    //Drawing histogram in canvas. The point of the is/else is to draw the one with the highest value first.
    if(esd_values->GetMaximum() > hlt_values->GetMaximum){
        esd_values->Draw();
        hlt_values->Draw("same");
    } else {
        hlt_values->Draw();
        esd_values->Draw("same");
   }


    gPad->Update();

    //Saving the canvas as a .png
    canv1->Print(file);

    //Deleting the legend.
    delete legend;

}






// The main function that reads the trees and uses the subfunction above.
int main(){

//Creating Tchain and AliESDEvent for both esdTree and HLTesdTree.
    TChain * chain = new TChain("esdTree");              
    TChain * chainhlt = new TChain("HLTesdTree");  

    //Reading the file "Files.txt" to know where to look for Trees.
    TString * rootfiles = new TString[200];
    ifstream fin("./Files.txt");
    while(1){
        fin >> rootfiles;
        if(!fin.good()) break;
        chain->Add(rootfiles);
        chainhlt->Add(rootfiles);
    }    

    //Creating the events that reads from the trees.
    AliESDEvent * event = new AliESDEvent();
    AliESDEvent * eventhlt = new AliESDEvent();

    event->ReadFromTree(chain);
    eventhlt->ReadFromTree(chainhlt);


//Creating histograms for both esdTree and HLTesdTree.
   // Histogram of momentum.
    TH1D * h_momentum = new TH1D("esd_P", "momentum", 100, 0, 5e0);
    h_momentum->GetXaxis()->SetTitle("GigaeV");
    TH1D * HLT_h_momentum = new TH1D("HLT_P", "hlt momentum", 100, 0, 5e0);
    HLT_h_momentum->GetXaxis()->SetTitle("GigaeV");

   // Histogram of transverse momentum.
    TH1D * transverse_momentum = new TH1D("esd_Pt", "Transverse momentum", 100, 0, 5e0);
    transverse_momentum->GetXaxis()->SetTitle("GigaeV");
    TH1D * HLT_transverse_momentum = new TH1D("HLT_Pt", "hlt Transverse momentum", 100, 0, 5e0);
    HLT_transverse_momentum->GetXaxis()->SetTitle("GigaeV");

   // Rest of the histograms.
   TH1D * theta = new TH1D("esd_theta", "Theta angle", 100, 0, 4);
    theta->GetXaxis()->SetTitle("Radians");
   TH1D * phi = new TH1D("esd_Phi", "Phi angle", 100, 0, 7);
    phi->GetXaxis()->SetTitle("Radians");
   TH1D * tpc = new TH1D("esd_tpc", "TPC", 100, 0, 170);                                            
   TH1D * ctm = new TH1D("esd_ctm", "CTM", 100, 0, 20);                                                           
    TH1D * HLT_theta = new TH1D("HLT_theta", "hlt Theta angle", 100, 0, 4);
    HLT_theta->GetXaxis()->SetTitle("Radians");
   TH1D * HLT_phi = new TH1D("HLT_Phi", "hlt Phi angle", 100, 0, 7);
    HLT_phi->GetXaxis()->SetTitle("Radians");
   TH1D * HLT_tpc = new TH1D("HLT_tpc", "hlt TPC clusters per track", 100, 0, 170);               
   TH1D * HLT_ctm = new TH1D("HLT_ctm", "hlt CTM", 100, 0, 20);                                          

//Filling the histograms from esdTree.
    Int_t nevent = chain->GetEntries();
    for(Int_t i = 0; i < nevent; i++){
        chain->GetEntry(i);

        //Filling the charged track multiplicity for ESD.
        Int_t ntracks = event->GetNumberOfTracks();
        ctm->Fill(ntracks);

        for(Int_t j = 0; j < ntracks; j++) {

            AliESDTrack *aliesd = event->GetTrack(j);

            //Filling the rest of the ESD tracks.
            h_momentum->Fill(aliesd->P());                   
            transverse_momentum->Fill(aliesd->Pt());
            theta->Fill(aliesd->Theta());
            phi->Fill(aliesd->Phi());
            tpc->Fill(aliesd->GetTPCNcls());
      }
   }

//Filling histograms from HLTesdTree.
    Int_t HLT_nevent = chainhlt->GetEntries();         
    for(Int_t k = 0; k < HLT_nevent; k++){
        chainhlt->GetEntry(k);

        //Filling the charged track multiplicity for HLTESD.
        Int_t HLT_ntracks = eventhlt->GetNumberOfTracks(); 
        HLT_ctm->Fill(HLT_ntracks);

        for(Int_t l = 0; l < HLT_ntracks; l++) {

            AliESDTrack *aliHLTesd = eventhlt->GetTrack(l);

            //Filling the rest of the HLTESD tracks.
            HLT_h_momentum->Fill(aliHLTesd->P());             
            HLT_transverse_momentum->Fill(aliHLTesd->Pt());
            HLT_theta->Fill(aliHLTesd->Theta());
            HLT_phi->Fill(aliHLTesd->Phi());
            HLT_tpc->Fill(aliHLTesd->GetTPCNcls());
      }
   }
   
    //Deleting current chains and events for memory.
    delete chain;
    delete chainhlt;
    delete event;
    delete eventhlt;



//Begining to plot the difference in the histograms and produce .png pictures.
   
    //Creating canvas and histogram statistics.
    TCanvas * canv1 = new TCanvas("canv1","canv1", 900, 700);
    gStyle->SetOptStat("oiunemr");

    //Plotting Momentum by a subfunction.
    comparetrees(canv1, h_momentum,"Momentum.png",HLT_h_momentum);

    //Plotting Transverse momentum.
    comparetrees(canv1, transverse_momentum,"Transverse Momentum.png",HLT_transverse_momentum);

    //Plotting Theta.
    comparetrees(canv1, theta,"Theta.png",HLT_theta);

    //Plotting Phi.
    comparetrees(canv1, phi,"Phi.png",HLT_phi);

    //Plotting TPC.
    comparetrees(canv1, tpc,"TPC.png",HLT_tpc);

    //Plotting CTM.
    comparetrees(canv1, ctm,"CTM.png",HLT_ctm);

    //Deleting the active canvas.
    delete canv1;

    return 0;
}



Trond Espen Lågeide