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 **************************************************************************/
16 //-------------------------------------------------------------------------
17 // Class AliRsnAnalysisSimple
18 //-------------------------------------------------------------------------
19 // This class is a manager to process one or more pair analysis with a
20 // given event sample, specified as a TTree passed to this object.
21 // Each single pair analysis must be defined with its specifications, like
22 // histogram binning, cuts and everything else.
23 // This class utiliy consists in defining a unique event sample which is
24 // used for all pairs analysis, and all kinds of event mixing (if required).
25 // All histograms computed in a single execution, are then saved into a file.
26 // This object contains a two TObjArray's:
27 // - one to contain single event pair analysis objects (signal, like-sign)
28 // - one to contain all event-mixing pair analysis objects
29 // When a new pair is added, it must be then specified in what container it
30 // must be placed, in order to avoid meaningless results.
32 // author: A. Pulvirenti
33 // email : alberto.pulvirenti@ct.infn.it
34 //-------------------------------------------------------------------------
40 #include <TClonesArray.h>
43 #include "AliRsnPID.h"
44 #include "AliRsnDaughter.h"
45 #include "AliRsnEvent.h"
46 #include "AliRsnEventBuffer.h"
47 #include "AliRsnPairSimple.h"
48 #include "AliRsnAnalyzerSimple.h"
49 #include "AliRsnAnalysisSimple.h"
51 ClassImp(AliRsnAnalysisSimple)
53 //_____________________________________________________________________________
54 AliRsnAnalysisSimple::AliRsnAnalysisSimple(AliRsnAnalyzerSimple *ana, AliRsnPID *pid) :
64 // Initializes all pointers and collections to NULL.
67 strcpy(fFileName, "default.root");
71 //_____________________________________________________________________________
72 void AliRsnAnalysisSimple::Clear(Option_t* /*option*/)
79 //_____________________________________________________________________________
80 void AliRsnAnalysisSimple::SetEventsTree(TTree *tree)
83 // Set the tree containing the events to be processed.
84 // Counts also the number of events and stores it in a private datamember.
85 // This can avoid the time-wasting entries count in a long TChain.
88 AliInfo(Form("Total number of events to be processed: %d", fTree->GetEntries()));
91 //_____________________________________________________________________________
92 Bool_t AliRsnAnalysisSimple::Initialize()
95 // Various initialization processes
97 // check process objects
99 AliError("PID not initialized");
103 AliError("Analyzer not initialized");
107 // set reference to PID method to all pairs
108 AliRsnPairSimple *pair = 0;
109 TObjArrayIter pairIterator(fAnalyzer->GetPairs());
110 while ( (pair = (AliRsnPairSimple*)pairIterator.Next()) ) {
111 pair->SetPIDMethod(fPID->GetMethod());
113 if (fAnalyzer->GetMixPairs() && !fAnalyzer->GetMixPairs()->IsEmpty()) {
114 TObjArrayIter mixIterator(fAnalyzer->GetMixPairs());
115 while ( (pair = (AliRsnPairSimple*)mixIterator.Next()) ) {
116 pair->SetPIDMethod(fPID->GetMethod());
120 // initialize analyzer
123 // at the end, update flag for initialization
124 fInitialized = kTRUE;
129 //_____________________________________________________________________________
130 Stat_t AliRsnAnalysisSimple::Process()
133 // Computes all invariant mass distributions defined in the AliRsnPair objects collected.
134 // Depending on the kind of background evaluation method, computes also this one.
137 // check initialization
139 AliError("Analysis not initialized. Use method 'Initialize()'");
144 AliRsnEvent *event = 0x0;
145 fTree->SetBranchAddress("rsnEvents", &event);
151 Int_t i, nEvents = (Int_t)fTree->GetEntries();
152 for (i = 0; i < nEvents; i++) {
154 if ((i % fStep) == 0) AliInfo(Form("Processing event %d", i));
157 if (!event) continue;
158 fPID->Identify(event);
159 nPairs += fAnalyzer->Process(event);
165 //_____________________________________________________________________________
166 void AliRsnAnalysisSimple::SaveOutput() const
169 // Writes histograms in current directory
171 TFile *file = TFile::Open(fFileName, "RECREATE");
172 AliRsnPairSimple *pair = 0;
174 TObjArrayIter pairIterator(fAnalyzer->GetPairs());
175 while ( (pair = (AliRsnPairSimple*)pairIterator.Next()) ) {
176 hist = pair->GetHistogram();
177 if (hist) hist->Write();
178 hist = pair->GetHistogramMC();
179 if (hist) hist->Write();
181 if (fAnalyzer->GetMixPairs() && !fAnalyzer->GetMixPairs()->IsEmpty()) {
182 TObjArrayIter mixIterator(fAnalyzer->GetMixPairs());
183 while ( (pair = (AliRsnPairSimple*)mixIterator.Next()) ) {
184 hist = pair->GetHistogram();
185 if (hist) hist->Write();
186 hist = pair->GetHistogramMC();
187 if (hist) hist->Write();