Introducing a new AOD class: AliAODcascade (A.Maire)
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / macros / AliLambdaStarAnalysis.C
1 void AliLambdaStarAnalysis
2 (
3         Int_t nevents = 650,
4         const char *path_in = "myselection",
5         const char *file_out = "lambda.invmass.root"
6 )
7 {
8         gSystem->Load("libANALYSIS.so");
9         
10         TChain *tree = new TChain("selection");
11         
12         if (nevents <= 0) {
13                 // Open the working directory
14                 void *dirp = gSystem->OpenDirectory(Form("$HOME/lambda/%s", path_in));
15                 const char *name = 0x0;
16                 while((name = gSystem->GetDirEntry(dirp))) {
17                         if (strstr(name, ".root")) {
18                                 tree->Add(Form("$HOME/lambda/%s/%s", path_in, name));
19                         }
20                 }
21                 gSystem->FreeDirectory(dirp);
22         }
23         else {
24                 for (Int_t iev = 0; iev <= nevents; iev++) {
25                         tree->Add(Form("$HOME/lambda/%s/%d.root", path_in, iev));
26                 }
27         }
28         cout << "# events: " << tree->GetEntries() << endl;
29         
30         //AliRsnDaughterCutPtSingle *cutproton = new AliRsnDaughterCutPtSingle(0, 1);
31         //AliRsnDaughterCutPtSingle *cutkaon = new AliRsnDaughterCutPtSingle(0, 1);
32         
33         // assign working parameters
34         AliRsnAnalysis *analysis = new AliRsnAnalysis;
35         analysis->SetEventsTree(tree);
36         
37         //analysis->AddCutSingle(AliPID::kProton, cutproton);
38         //analysis->AddCutSingle(AliPID::kKaon, cutkaon);
39         
40         // set histogram bins
41         analysis->SetBins(800, 1.3, 2.1);   // 700 bins of 1 MeV each
42         analysis->SetTrueMotherPDG(3124);   // PDG code of Lambda*
43                 
44         // import all useful combinations
45         
46         analysis->AddPairDef(AliPID::kProton, '+', AliPID::kKaon, '-');
47         analysis->AddPairDef(AliPID::kProton, '-', AliPID::kKaon, '+');
48         analysis->AddPairDef(AliPID::kProton, '+', AliPID::kKaon, '-', kTRUE);
49         analysis->AddPairDef(AliPID::kProton, '-', AliPID::kKaon, '+', kTRUE);
50         
51         analysis->AddMixPairDef(AliPID::kProton, '+', AliPID::kKaon, '-');
52         analysis->AddMixPairDef(AliPID::kProton, '-', AliPID::kKaon, '+');
53         analysis->AddMixPairDef(AliPID::kKaon, '-', AliPID::kProton, '+');
54         analysis->AddMixPairDef(AliPID::kKaon, '+', AliPID::kProton, '-');
55         
56         
57
58         // process data for signal event in same event
59         analysis->Process();
60         analysis->EventMix(5, 5, 0.02, kFALSE);
61         // open output file
62         TFile *outFile = 0;
63         outFile = TFile::Open(file_out, "RECREATE");
64         
65         // write histograms
66         analysis->WriteHistograms();
67         
68         outFile->Close();
69 }