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 AliRsnSimpleAnalysis
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 //-------------------------------------------------------------------------
41 #include <TClonesArray.h>
44 #include "AliRsnPID.h"
45 #include "AliRsnDaughter.h"
46 #include "AliRsnEvent.h"
47 #include "AliRsnEventBuffer.h"
48 #include "AliRsnSimpleFunction.h"
49 #include "AliRsnSimpleAnalyzer.h"
50 #include "AliRsnSimpleAnalysis.h"
52 ClassImp(AliRsnSimpleAnalysis)
54 //_____________________________________________________________________________
55 AliRsnSimpleAnalysis::AliRsnSimpleAnalysis(AliRsnSimpleAnalyzer *ana, AliRsnPID *pid) :
65 // Initializes all pointers and collections to NULL.
68 strcpy(fFileName, "default.root");
72 //_____________________________________________________________________________
73 void AliRsnSimpleAnalysis::Clear(Option_t* /*option*/)
80 //_____________________________________________________________________________
81 void AliRsnSimpleAnalysis::SetEventsTree(TTree *tree)
84 // Set the tree containing the events to be processed.
85 // Counts also the number of events and stores it in a private datamember.
86 // This can avoid the time-wasting entries count in a long TChain.
89 AliInfo(Form("Total number of events to be processed: %d", fTree->GetEntries()));
92 //_____________________________________________________________________________
93 Bool_t AliRsnSimpleAnalysis::Initialize()
96 // Various initialization processes
98 // check process objects
101 AliError("Analyzer not initialized");
105 // initialize analyzer
108 // at the end, update flag for initialization
109 fInitialized = kTRUE;
114 //_____________________________________________________________________________
115 Stat_t AliRsnSimpleAnalysis::Process()
118 // Computes all invariant mass distributions defined in the AliRsnPair objects collected.
119 // Depending on the kind of background evaluation method, computes also this one.
122 // check initialization
125 AliError("Analysis not initialized. Use method 'Initialize()'");
130 AliRsnEvent *event = 0x0;
131 fTree->SetBranchAddress("rsnEvents", &event);
137 Int_t i, nEvents = (Int_t)fTree->GetEntries();
138 for (i = 0; i < nEvents; i++)
141 if ((i % fStep) == 0) AliInfo(Form("Processing event %d", i));
144 if (!event) continue;
145 fPID->Process(event);
146 fAnalyzer->Process(event);
152 //_____________________________________________________________________________
153 void AliRsnSimpleAnalysis::SaveOutput() const
156 // Writes histograms in current directory
158 TFile *file = TFile::Open(fFileName, "RECREATE");
159 AliRsnSimpleFunction *pair = 0;
162 TObjArrayIter pairIterator(fAnalyzer->GetSingle());
163 while ((pair = (AliRsnSimpleFunction*)pairIterator.Next()))
165 h1D = pair->GetHistogram1D();
166 h2D = pair->GetHistogram2D();
167 if (h1D) h1D->Write();
168 if (h2D) h2D->Write();
170 if (fAnalyzer->GetMix() && !fAnalyzer->GetMix()->IsEmpty())
172 TObjArrayIter mixIterator(fAnalyzer->GetMix());
173 while ((pair = (AliRsnSimpleFunction*)mixIterator.Next()))
175 h1D = pair->GetHistogram1D();
176 h2D = pair->GetHistogram2D();
177 if (h1D) h1D->Write();
178 if (h2D) h2D->Write();