From 93ff27bdcbdbfef60008091f56b8a1891e1b0510 Mon Sep 17 00:00:00 2001 From: snelling Date: Wed, 29 Apr 2009 12:17:05 +0000 Subject: [PATCH] events based on the fly in memory and analysis for quick chekcs --- PWG2/CMake_libPWG2flowCommon.txt | 1 + .../AliFlowEventSimpleMakerOnTheFly.cxx | 129 ++++++ .../AliFlowEventSimpleMakerOnTheFly.h | 76 ++++ PWG2/FLOW/macros/runFlowAnalysisOnTheFly.C | 373 ++++++++++++++++++ PWG2/PWG2flowCommonLinkDef.h | 2 + PWG2/libPWG2flowCommon.pkg | 1 + 6 files changed, 582 insertions(+) create mode 100644 PWG2/FLOW/AliFlowCommon/AliFlowEventSimpleMakerOnTheFly.cxx create mode 100644 PWG2/FLOW/AliFlowCommon/AliFlowEventSimpleMakerOnTheFly.h create mode 100644 PWG2/FLOW/macros/runFlowAnalysisOnTheFly.C diff --git a/PWG2/CMake_libPWG2flowCommon.txt b/PWG2/CMake_libPWG2flowCommon.txt index 62c73296cfe..3df193bbfb1 100644 --- a/PWG2/CMake_libPWG2flowCommon.txt +++ b/PWG2/CMake_libPWG2flowCommon.txt @@ -7,6 +7,7 @@ set(SRCS FLOW/AliFlowCommon/AliFlowCommonConstants.cxx FLOW/AliFlowCommon/AliFlowLYZConstants.cxx FLOW/AliFlowCommon/AliFlowCumuConstants.cxx + FLOW/AliFlowCommon/AliFlowEventSimpleMakerOnTheFly.cxx FLOW/AliFlowCommon/AliFlowCommonHist.cxx FLOW/AliFlowCommon/AliFlowCommonHistResults.cxx FLOW/AliFlowCommon/AliFlowLYZHist1.cxx diff --git a/PWG2/FLOW/AliFlowCommon/AliFlowEventSimpleMakerOnTheFly.cxx b/PWG2/FLOW/AliFlowCommon/AliFlowEventSimpleMakerOnTheFly.cxx new file mode 100644 index 00000000000..a5c71fa37ed --- /dev/null +++ b/PWG2/FLOW/AliFlowCommon/AliFlowEventSimpleMakerOnTheFly.cxx @@ -0,0 +1,129 @@ +/************************************************************************* +* Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. * +* * +* Author: The ALICE Off-line Project. * +* Contributors are mentioned in the code where appropriate. * +* * +* Permission to use, copy, modify and distribute this software and its * +* documentation strictly for non-commercial purposes is hereby granted * +* without fee, provided that the above copyright notice appears in all * +* copies and that both the copyright notice and this permission notice * +* appear in the supporting documentation. The authors make no claims * +* about the suitability of this software for any purpose. It is * +* provided "as is" without express or implied warranty. * +**************************************************************************/ + +/********************************** + * create an event and perform * + * flow analysis 'on the fly' * + * * + * authors: Raimond Snellings * + * (snelling@nikhef.nl) * + * Ante Bilandzic * + * (anteb@nikhef.nl) * + *********************************/ + +#include "Riostream.h" +#include "TMath.h" +#include "TF1.h" +#include "TRandom3.h" + +#include "AliFlowEventSimpleMakerOnTheFly.h" +#include "AliFlowEventSimple.h" +#include "AliFlowTrackSimple.h" + +ClassImp(AliFlowEventSimpleMakerOnTheFly) + + +//======================================================================== + + +AliFlowEventSimpleMakerOnTheFly::AliFlowEventSimpleMakerOnTheFly(): + fMultiplicityOfRP(0), + fMultiplicitySpreadOfRP(0.), + fPtFormula(NULL), + fPhiFormula(NULL) + { + // constructor + } + + +//======================================================================== + + +AliFlowEventSimpleMakerOnTheFly::~AliFlowEventSimpleMakerOnTheFly() +{ + // destructor + if (fPtFormula) delete fPtFormula; + if (fPhiFormula) delete fPhiFormula; +} + + +//======================================================================== + + +AliFlowEventSimple* AliFlowEventSimpleMakerOnTheFly::CreateEventOnTheFly() +{ + // method to create event on the fly + + AliFlowEventSimple* pEvent = new AliFlowEventSimple(fMultiplicityOfRP); + + + // pt: + Double_t dPtMin = 0.; // to be improved + Double_t dPtMax = 10.; // to be improved + + fPtFormula = new TF1("PtFormula","[0]*x*TMath::Exp(-x*x)",dPtMin,dPtMax); + + fPtFormula->SetParName(0,"Multiplicity of RPs"); + fPtFormula->SetParameter(0,fMultiplicityOfRP); + + + // phi: + Double_t dPhiMin = 0.; // to be improved + Double_t dPhiMax = TMath::TwoPi(); // to be improved + + fPhiFormula = new TF1("phiDistribution","(1)*(1+2.*[0]*TMath::Cos(2*x))",dPhiMin,dPhiMax); + + Double_t dV2 = 0.044; // to be improved + + fPhiFormula->SetParName(0,"elliptic flow"); + fPhiFormula->SetParameter(0,dV2); + + + // eta: + Double_t dEtaMin = -1.; // to be improved + Double_t dEtaMax = 1.; // to be improved + TRandom3 myTRandom3; + + //reaction plane + Double_t fMCReactionPlaneAngle = TMath::TwoPi()*myTRandom3.Rndm(); + + Int_t iGoodTracks = 0; + Int_t iSelParticlesRP = 0; + Int_t iSelParticlesPOI = 0; + for(Int_t i=0;iSetPt(fPtFormula->GetRandom()); + pTrack->SetEta(myTRandom3.Uniform(dEtaMin,dEtaMax)); + pTrack->SetPhi(fPhiFormula->GetRandom()-fMCReactionPlaneAngle); + pTrack->SetForRPSelection(kTRUE); + iSelParticlesRP++; + pTrack->SetForPOISelection(kTRUE); + iSelParticlesPOI++; + + pEvent->TrackCollection()->Add(pTrack); + iGoodTracks++; + } + + pEvent->SetEventNSelTracksRP(iSelParticlesRP); + pEvent->SetNumberOfTracks(iGoodTracks);//tracks used either for RP or for POI selection + pEvent->SetMCReactionPlaneAngle(fMCReactionPlaneAngle); + + + return pEvent; + +} // end of CreateEventOnTheFly() + + + diff --git a/PWG2/FLOW/AliFlowCommon/AliFlowEventSimpleMakerOnTheFly.h b/PWG2/FLOW/AliFlowCommon/AliFlowEventSimpleMakerOnTheFly.h new file mode 100644 index 00000000000..3f274af1fb0 --- /dev/null +++ b/PWG2/FLOW/AliFlowCommon/AliFlowEventSimpleMakerOnTheFly.h @@ -0,0 +1,76 @@ +/* + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. + * See cxx source for full Copyright notice + * $Id$ + */ + +/********************************** + * create an event and perform * + * flow analysis 'on the fly' * + * * + * authors: Raimond Snellings * + * (snelling@nikhef.nl) * + * Ante Bilandzic * + * (anteb@nikhef.nl) * + *********************************/ + +#ifndef ALIFLOWEVENTSIMPLEMAKERONTHEFLY_H +#define ALIFLOWEVENTSIMPLEMAKERONTHEFLY_H + +class TF1; + +#include "AliFlowEventSimple.h" //needed as include + +class AliFlowEventSimpleMakerOnTheFly { + + public: + + AliFlowEventSimpleMakerOnTheFly(); // constructor + virtual ~AliFlowEventSimpleMakerOnTheFly(); // destructor + + AliFlowEventSimple* CreateEventOnTheFly(); // create an event on the fly + + + // ***************************** + // **** SETTERS AND GETTERS **** + // ***************************** + //................................................................................................ + // setters and getters for global parameters: + void SetMultiplicityOfRP(Int_t multRP) {this->fMultiplicityOfRP = multRP;} + Int_t GetMultiplicityOfRP() const {return this->fMultiplicityOfRP;} + //................................................................................................ + + //................................................................................................ + // setters and getters for event-by-event parameters: + void SetMultiplicitySpreadOfRP(Double_t multSpreadRP) {this->fMultiplicitySpreadOfRP = multSpreadRP;} + Double_t GetMultiplicitySpreadOfRP() const {return this->fMultiplicitySpreadOfRP;} + //................................................................................................ + + private: + + AliFlowEventSimpleMakerOnTheFly(const AliFlowEventSimpleMakerOnTheFly& anAnalysis); // copy constructor + AliFlowEventSimpleMakerOnTheFly& operator=(const AliFlowEventSimpleMakerOnTheFly& anAnalysis); // assignment operator + + //................................................................................................ + // global parameters: + Int_t fMultiplicityOfRP; // multiplicity of RPs + //................................................................................................ + + //................................................................................................ + // event-by-event parameters: + Double_t fMultiplicitySpreadOfRP; // multiplicity spread of RPs + //................................................................................................ + + //................................................................................................ + // equations for distributions: + TF1 *fPtFormula; // transverse momentum distribution + TF1 *fPhiFormula; // azimuthal distribution + //................................................................................................ + + ClassDef(AliFlowEventSimpleMakerOnTheFly,0) // macro for rootcint +}; + +#endif + + + diff --git a/PWG2/FLOW/macros/runFlowAnalysisOnTheFly.C b/PWG2/FLOW/macros/runFlowAnalysisOnTheFly.C new file mode 100644 index 00000000000..a798c337bb0 --- /dev/null +++ b/PWG2/FLOW/macros/runFlowAnalysisOnTheFly.C @@ -0,0 +1,373 @@ +#include "TStopwatch.h" +#include "TObjArray" +#include "Riostream.h" +#include "TFile.h" + +//-------------------------------------------------------------------------------------- +// RUN SETTINGS +// flow analysis method can be: (set to kTRUE or kFALSE) +Bool_t SP = kFALSE; +Bool_t LYZ1 = kFALSE; +Bool_t LYZ2 = kFALSE; +Bool_t LYZEP = kFALSE; +Bool_t GFC = kFALSE; +Bool_t QC = kFALSE; +Bool_t FQD = kFALSE; +Bool_t MCEP = kTRUE; +//-------------------------------------------------------------------------------------- + +//................................................................................. + +// Set the event parameters: +Int_t iMultiplicityOfRP = 4400; // multiplicity of RPs + +//................................................................................. + + + +enum anaModes {mLocal,mLocalSource,mLocalPAR,}; +// mLocal: Analyze data on your computer using aliroot +// mLocalPAR: Analyze data on your computer using root + PAR files +// mLocalSource: Analyze data on your computer using root + source files + +int runFlowAnalysisOnTheFly(Int_t mode=mLocal, Int_t nEvts=1) +{ + TStopwatch timer; + timer.Start(); + + if (LYZ1 && LYZ2) {cout<<"WARNING: you cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1. "<Init(); + } + + // QC = Q-cumulants + if(QC) { + AliFlowAnalysisWithQCumulants* qc = new AliFlowAnalysisWithQCumulants(); + qc->Init(); + } + + // GFC = Generating Function Cumulants + if(GFC) { + AliFlowAnalysisWithCumulants* gfc = new AliFlowAnalysisWithCumulants(); + gfc->Init(); + } + + // FQD = Fitting q-distribution + if(FQD) { + AliFittingQDistribution* fqd = new AliFittingQDistribution(); + fqd->Init(); + } + + // SP = Scalar Product + if(SP) { + AliFlowAnalysisWithScalarProduct* sp = new AliFlowAnalysisWithScalarProduct(); + sp->Init(); + } + + // LYZ1 = Lee-Yang Zeroes first run + if(LYZ1) { + AliFlowAnalysisWithLeeYangZeros* lyz1 = new AliFlowAnalysisWithLeeYangZeros(); + lyz1->SetFirstRun(kTRUE); + lyz1->SetUseSum(kTRUE); + lyz1->Init(); + } + + // LYZ2 = Lee-Yang Zeroes second run + if(LYZ2) { + AliFlowAnalysisWithLeeYangZeros* lyz2 = new AliFlowAnalysisWithLeeYangZeros(); + // read the input file from the first run + TString inputFileNameLYZ2 = "outputLYZ1analysis.root" ; + TFile* inputFileLYZ2 = new TFile(inputFileNameLYZ2.Data(),"READ"); + if(!inputFileLYZ2 || inputFileLYZ2->IsZombie()) { + cerr << " ERROR: NO First Run file... " << endl ; + break; + } + else { + TList* inputListLYZ2 = (TList*)inputFileLYZ2->Get("cobjLYZ1"); + if (!inputListLYZ2) {cout<<"Input list is NULL pointer!"<SetFirstRunList(inputListLYZ2); + lyz2->SetFirstRun(kFALSE); + lyz2->SetUseSum(kTRUE); + lyz2->Init(); + } + } + } + + // LYZEP = Lee-Yang Zeroes event plane + if(LYZEP) { + AliFlowLYZEventPlane* ep = new AliFlowLYZEventPlane() ; + AliFlowAnalysisWithLYZEventPlane* lyzep = new AliFlowAnalysisWithLYZEventPlane(); + // read the input file from the second lyz run + TString inputFileNameLYZEP = "outputLYZ2analysis.root" ; + TFile* inputFileLYZEP = new TFile(inputFileNameLYZEP.Data(),"READ"); + if(!inputFileLYZEP || inputFileLYZEP->IsZombie()) { + cerr << " ERROR: NO Second Run file... " << endl ; + break; + } + else { + TList* inputListLYZEP = (TList*)inputFileLYZEP->Get("cobjLYZ2"); + if (!inputListLYZEP) {cout<<"Input list is NULL pointer!"<SetSecondRunList(inputListLYZEP); + lyzep->SetSecondRunList(inputListLYZEP); + ep ->Init(); + lyzep->Init(); + } + } + } + //--------------------------------------------------------------------------------------- + + + //--------------------------------------------------------------------------------------- + // create and analyze events 'on the fly': + + // set the global event parameters: + eventMakerOnTheFly->SetMultiplicityOfRP(iMultiplicityOfRP); + + for(Int_t i=0;iCreateEventOnTheFly(); + cout<<" .... done .... "<Make(event); + if(QC) qc->Make(event); + if(GFC) gfc->Make(event); + if(FQD) fqd->Make(event); + if(LYZ1) lyz1->Make(event); + if(LYZ2) lyz2->Make(event); + if(LYZEP) lyzep->Make(event,ep); + if(SP) sp->Make(event); + + cout<<" .... done .... "<Finish(); mcep->WriteHistograms("outputMCEPanalysis.root");} + if(SP) {sp->Finish(); sp->WriteHistograms("outputSPanalysis.root");} + if(QC) {qc->Finish(); qc->WriteHistograms("outputQCanalysis.root");} + if(GFC) {gfc->Finish(); gfc->WriteHistograms("outputGFCanalysis.root");} + if(FQD) {fqd->Finish(); fqd->WriteHistograms("outputFQDanalysis.root");} + if(LYZ1) {lyz1->Finish(); lyz1->WriteHistograms("outputLYZ1analysis.root");} + if(LYZ2) {lyz2->Finish(); lyz2->WriteHistograms("outputLYZ2analysis.root");} + if(LYZEP) {lyzep->Finish(); lyzep->WriteHistograms("outputLYZEPanalysis.root");} + //--------------------------------------------------------------------------------------- + + + + cout<WorkingDirectory() )) ; + TString parpar(Form("%s.par", pararchivename)) ; + if ( gSystem->AccessPathName(parpar.Data()) ) { + gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ; + TString processline(Form(".! make %s", parpar.Data())) ; + gROOT->ProcessLine(processline.Data()) ; + gSystem->ChangeDirectory(cdir) ; + processline = Form(".! mv /tmp/%s .", parpar.Data()) ; + gROOT->ProcessLine(processline.Data()) ; + } + if ( gSystem->AccessPathName(pararchivename) ) { + TString processline = Form(".! tar xvzf %s",parpar.Data()) ; + gROOT->ProcessLine(processline.Data()); + } + + TString ocwd = gSystem->WorkingDirectory(); + gSystem->ChangeDirectory(pararchivename); + + // check for BUILD.sh and execute + if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) { + printf("*******************************\n"); + printf("*** Building PAR archive ***\n"); + cout<Exec("PROOF-INF/BUILD.sh")) { + Error("runProcess","Cannot Build the PAR Archive! - Abort!"); + return -1; + } + } + // check for SETUP.C and execute + if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) { + printf("*******************************\n"); + printf("*** Setup PAR archive ***\n"); + cout<Macro("PROOF-INF/SETUP.C"); + } + + gSystem->ChangeDirectory(ocwd.Data()); + printf("Current dir: %s\n", ocwd.Data()); +} + +void LoadLibraries(const anaModes mode) { + + //-------------------------------------- + // Load the needed libraries most of them already loaded by aliroot + //-------------------------------------- + gSystem->Load("libTree.so"); + gSystem->Load("libGeom.so"); + gSystem->Load("libVMC.so"); + gSystem->Load("libXMLIO.so"); + gSystem->Load("libPhysics.so"); + + //---------------------------------------------------------- + // >>>>>>>>>>> Local mode <<<<<<<<<<<<<< + //---------------------------------------------------------- + if (mode==mLocal) { + //-------------------------------------------------------- + // If you want to use already compiled libraries + // in the aliroot distribution + //-------------------------------------------------------- + gSystem->Load("libSTEERBase"); + gSystem->Load("libESD"); + gSystem->Load("libAOD"); + gSystem->Load("libANALYSIS"); + gSystem->Load("libANALYSISalice"); + gSystem->Load("libCORRFW.so"); + cerr<<"libCORRFW.so loaded..."<Load("libPWG2flowCommon.so"); + cerr<<"libPWG2flowCommon.so loaded..."<Load("libPWG2flowTasks.so"); + cerr<<"libPWG2flowTasks.so loaded..."<>>>>>>>>>>> + //--------------------------------------------------------- + else if (mode==mLocalSource) { + + // In root inline compile + + + // Constants + gROOT->LoadMacro("AliFlowCommon/AliFlowCommonConstants.cxx+"); + gROOT->LoadMacro("AliFlowCommon/AliFlowLYZConstants.cxx+"); + gROOT->LoadMacro("AliFlowCommon/AliFlowCumuConstants.cxx+"); + + // Flow event + gROOT->LoadMacro("AliFlowCommon/AliFlowVector.cxx+"); + gROOT->LoadMacro("AliFlowCommon/AliFlowTrackSimple.cxx+"); + gROOT->LoadMacro("AliFlowCommon/AliFlowEventSimple.cxx+"); + + // Cuts + gROOT->LoadMacro("AliFlowCommon/AliFlowTrackSimpleCuts.cxx+"); + + // Output histosgrams + gROOT->LoadMacro("AliFlowCommon/AliFlowCommonHist.cxx+"); + gROOT->LoadMacro("AliFlowCommon/AliFlowCommonHistResults.cxx+"); + gROOT->LoadMacro("AliFlowCommon/AliFlowLYZHist1.cxx+"); + gROOT->LoadMacro("AliFlowCommon/AliFlowLYZHist2.cxx+"); + + // Functions needed for various methods + gROOT->LoadMacro("AliFlowCommon/AliCumulantsFunctions.cxx+"); + gROOT->LoadMacro("AliFlowCommon/AliFittingFunctionsForQDistribution.cxx+"); + gROOT->LoadMacro("AliFlowCommon/AliFlowLYZEventPlane.cxx+"); + + // Flow Analysis code for various methods + gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithMCEventPlane.cxx+"); + gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithScalarProduct.cxx+"); + gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithLYZEventPlane.cxx+"); + gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithLeeYangZeros.cxx+"); + gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithCumulants.cxx+"); + gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithQCumulants.cxx+"); + gROOT->LoadMacro("AliFlowCommon/AliFittingQDistribution.cxx+"); + + // Class to fill the FlowEvent without aliroot dependence + // can be found in the directory FlowEventMakers + gROOT->LoadMacro("FlowEventMakers/FlowEventSimpleMaker.cxx+"); + + cout << "finished loading macros!" << endl; + + } + +} + + diff --git a/PWG2/PWG2flowCommonLinkDef.h b/PWG2/PWG2flowCommonLinkDef.h index e503eb0a62d..807415170a1 100644 --- a/PWG2/PWG2flowCommonLinkDef.h +++ b/PWG2/PWG2flowCommonLinkDef.h @@ -14,6 +14,8 @@ #pragma link C++ class AliFlowTrackSimpleCuts+; +#pragma link C++ class AliFlowEventSimpleMakerOnTheFly+; + #pragma link C++ class AliFlowCommonHist+; #pragma link C++ class AliFlowCommonHistResults+; #pragma link C++ class AliFlowLYZHist1+; diff --git a/PWG2/libPWG2flowCommon.pkg b/PWG2/libPWG2flowCommon.pkg index 44310bfc661..5db61192a5a 100644 --- a/PWG2/libPWG2flowCommon.pkg +++ b/PWG2/libPWG2flowCommon.pkg @@ -7,6 +7,7 @@ SRCS= FLOW/AliFlowCommon/AliFlowEventSimple.cxx \ FLOW/AliFlowCommon/AliFlowCommonConstants.cxx \ FLOW/AliFlowCommon/AliFlowLYZConstants.cxx \ FLOW/AliFlowCommon/AliFlowCumuConstants.cxx \ + FLOW/AliFlowCommon/AliFlowEventSimpleMakerOnTheFly.cxx \ FLOW/AliFlowCommon/AliFlowCommonHist.cxx \ FLOW/AliFlowCommon/AliFlowCommonHistResults.cxx \ FLOW/AliFlowCommon/AliFlowLYZHist1.cxx \ -- 2.39.3