using namespace std; //required for resolving the 'cout' symbol
-TTree* kOpen(int evtN=0) ;
-//TChain* CreateKineChain(const char* aDataDir = "MCfiles.txt", Int_t aRuns = 10, Int_t offset = 0) ;
-//void LookupWrite(TChain* chain, const char* target) ;
+const char* aDataDir = "./" ; Int_t aRuns = -1 ; Int_t offset = 0 ;
-void testKiner(TString output = "flowKevts.root")
+//////////////////////////////////////////////////////////////////////////////////////////////////////
+
+int testKiner(int cen = -1)
{
- cout << " . Here the new flow kinemaker (2007b) ... " << endl ;
+ cout << " . Here the new flow kinemaker (2007 noRL) ... " << endl ;
cout << endl ;
- bool kOne = kFALSE ;
+ int limit = -1 ;
+ if(limit>0)
+ {
+ cout << " . limited to " << limit << "events . " << endl ;
+ cout << endl ;
+ }
+
+ // flowEvents file (output) //
+
+ TString output = "flowKevts" ;
+ if(cen >= 0) { output += cen ; }
+ output += ".root" ;
+
+ // start, load libs //
TStopwatch timer;
timer.Start();
- gSystem->Load("AliFlow_All.so");
+ //gSystem->Load("libPhysics.so");
+ gSystem->Load("libPWG2flow.so");
- // output file //
+ // open output file //
TFile * fFlowfile = new TFile(output.Data(),"RECREATE") ;
//fFlowfile->cd() ;
- // esd chain //
-
-// // TString fESDfileName = "AliESDs.root" ; TString fESDtree = "esdTree" ;
-// TChain* pMCchain = CreateESDChain(".",10,0);
-// Int_t fNumberOfEvents = (Int_t)pMCchain->GetEntries() ;
-// cout << " tot. " << fNumberOfEvents << " events in the TChain ... " << endl ; cout << endl ;
-
-// TString fKineBranch = "TreeK" ;
-// TTree treeK = 0 ;
-// pMCchain->SetBranchAddress(fKineBranch.Data(),&treeK) ;
-
- Int_t fNumberOfEvents = 1 ;
- TTree* treeK = 0 ;
-
// flow maker //
AliFlowKineMaker * flowKiner = new AliFlowKineMaker() ;
// cuts, etc.
- flowKiner->SetAbsEtaCut(2.1) ;
- flowKiner->SetECut(0.01,100.) ;
+ flowKiner->SetAbsEtaCut(10.) ;
+ flowKiner->SetECut(0.001,100.) ;
//flowKiner->SetLabelCut(..,..) ;
- flowKiner->SetPrimaryCut(Bool_t prim = kTRUE) ;
+ flowKiner->SetPrimaryCut(kTRUE) ;
flowKiner->PrintCutList() ;
- // loop //
-
- Int_t evtN = 0 ;
AliFlowEvent * flowEvt = 0 ;
- for(evtN=0;evtN<fNumberOfEvents;evtN++)
+ Int_t count = 0 ;
+
+ // loop (folders) //
+
+ TString execDir(gSystem->pwd());
+ TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
+ TList* dirList = baseDir->GetListOfFiles();
+ Int_t nDirs = dirList->GetEntries();
+ gSystem->cd(execDir);
+
+ for(Int_t iDir=0; iDir<nDirs; ++iDir)
{
- treeK = kOpen(0) ;
-
- Int_t evtNN = -1 ;
- Int_t nTrk = treeK->GetEntries() ;
+ TSystemFile* presentDir = (TSystemFile*)dirList->At(iDir) ;
+ if(!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
+ {
+ cout << endl ;
+ cout << "Directory (" << iDir << "): " << presentDir->GetName() << " - Skipping ... " << endl ;
+ continue ;
+ }
+ if(offset > 0) { --offset ; continue ; }
+ if((aRuns > 0) && (count >= aRuns)) { break ; }
+
+ TString presentDirName(aDataDir);
+ presentDirName += presentDir->GetName();
+ presentDirName += "/";
+
+ TString fileName = presentDirName ;
+ fileName += "galice.root" ;
+ Long_t *id, *size, *flags, *modtime ;
+ if(gSystem->GetPathInfo(fileName.Data(),id,size,flags,modtime))
+ {
+ cout << " File : " << fileName << " does NOT exist ! - Skipping ... " << endl ;
+ continue ;
+ }
+ cout << endl ; cout << "Directory (" << iDir << "): " << presentDirName << " ... " << endl ;
+
+ // loop (simulations in the present dir) //
- cout << endl ; cout << " Event " << evtN << " ( " << evtNN << " ) : " << nTrk << " tracks ." << endl ;
+ TSystemDirectory* evtsDir = new TSystemDirectory(".", presentDirName.Data());
+ TList* fileList = evtsDir->GetListOfFiles();
+ Int_t nFiles = fileList->GetEntries();
+ gSystem->cd(execDir);
- flowEvt = flowKiner->FillFlowEvent(treeK) ;
+ for(Int_t iFiles=0; iFiles<nFiles; ++iFiles)
+ {
+ TSystemFile* presentFile = (TSystemFile*) fileList->At(iFiles);
- cout << " Event filled " << flowEvt << " ... " << endl ;
- // cout << endl ; cout << " trks : " << flowEvt->TrackCollection()->GetEntries() << endl ;
- // flowEvt->Dump() ; cout << endl ;
+ TString presentFileName(presentDirName);
+ presentFileName += presentFile->GetName();
- TString evtID = "" ; evtID += evtN ;
- fFlowfile->cd() ;
- flowEvt->Write(evtID.Data()) ;
- cout << " Event " << evtN << " ( " << evtID.Data() << " ) - written on disk (" << output << ") ." << endl;
- delete flowEvt ;
+ if(!(presentFileName.Contains("Kinematics") && presentFileName.Contains("root"))) { continue ; }
+
+ cout << " found: " << presentFileName.Data() << endl ;
+
+ TFile* kineFile = new TFile(presentFileName.Data(), "READ") ;
+ // kineFile->ls() ;
+ Int_t nEvts = kineFile->GetNkeys() ;
+ cout << " . found: " << nEvts << " KineTree(s) in " << presentFileName.Data() << endl ;
+ TList* kineEventsList = (TList*)kineFile->GetListOfKeys() ;
+ TTree* kTree ;
+ TIter next(kineEventsList);
+ TKey* key ;
+
+ // Loop over the events
+ while( key=(TKey *)next() )
+ {
+ TDirectory* tDir = (TDirectory*)key->ReadObj() ;
+ if(!tDir) break;
+
+ TString evtDir(tDir->GetName()) ;
+ cout << " . . found: " << tDir->GetName() << endl ;
+
+ kTree = (TTree *)tDir->Get("TreeK");
+ if(!kTree) break;
+
+ Int_t nPart = kTree->GetEntries() ;
+ cout << " . . . kTree " << count << " has " << nPart << " particles " << endl ;
+
+ // fill and save the flow event
+ flowEvt = flowKiner->FillFlowEvent(kTree) ;
+ cout << " . . . flowEvent " << flowEvt << " filled from ttree " << kTree << " ... " << endl ;
+ // flowEvt->Dump() ; cout << endl ;
+ TString evtID = "" ; evtID += iDir ; evtID += "-" ; evtID += evtDir ;
+ fFlowfile->cd() ; flowEvt->Write(evtID.Data()) ;
+ cout << " . . . flowEvent " << flowEvt << " ( " << evtID.Data() << " ) - written on disk (" << output << ") ... " << endl;
+ delete flowEvt ; cout << endl ;
+ // -
+
+ if(count == limit) { break ; }
+ count ++ ;
+
+ delete kTree ;
+ }
+ delete kineFile ;
+ }
+ delete evtsDir ;
}
fFlowfile->Close() ;
cout << endl ;
cout << " Finished ... " << endl ;
- cout << " nTracks: " << flowKiner->GetNgoodTracks() << endl ;
- cout << " nV0s: " << flowKiner->GetNgoodV0s() << endl ;
- cout << " nTracks (|eta|<0.5): " << flowKiner->GetNgoodTracksEta() << endl ;
- cout << " nTracks+: " << flowKiner->GetNposiTracks() << endl ;
- cout << " nTracks-: " << flowKiner->GetNnegaTracks() << endl ;
- cout << " nTracks unconstrained: " << flowKiner->GetNunconstrained() << endl ;
- //cout << " Bayesian : " ;
- //for(int ii=0;ii<5;ii++) { cout << flowKiner->GetBayesianNorm(ii) << " " ; }
+ cout << " nParticles: " << (flowKiner->GetNgoodTracks() + flowKiner->GetNgoodV0s()) << " (" << flowKiner->GetNposiTracks() << "+ , " << flowKiner->GetNnegaTracks() << "- , " << flowKiner->GetNgoodV0s() << " neutral) " << endl ;
+ cout << " <nCharged> (|eta|<0.5): " << (Int_t)(flowKiner->GetNgoodTracksEta()/count) << endl ;
+ cout << " Bayesian : " ;
+ for(int ii=0;ii<5;ii++) { cout << flowKiner->GetBayesianNorm(ii) << " " ; }
cout << " . " << endl ;
timer.Stop() ;
cout << endl ;
timer.Print() ;
- cout << " . here it was (kiner) ... " << endl ; //juice!
+ cout << " . here it was (kiner noRL) ... " << endl ; //juice!
cout << endl ;
- // break ;
-
-}
-
-TTree* kOpen(int evtN)
-{
- TString fileName = "./0/galice.root" ;
- AliRunLoader* rl = AliRunLoader::Open(fileName.Data(),"MyEvent","read");
- rl->LoadgAlice();
- AliRun* gAlice = rl->GetAliRun();
- rl->LoadHeader();
- rl->LoadKinematics();
- Int_t fNumberOfEvents = rl->GetNumberOfEvents() ;
- cout << " Found : " << fNumberOfEvents << " event(s) ... " << endl ;
-
- Int_t exitStatus = rl->GetEvent(evtN) ; if(exitStatus!=0) { return 0 ; }
-
- TTree* kTree = (TTree*)rl->TreeK(); // Particles TTree (KineTree)
- AliStack* kStack = gAlice->Stack(); // Particles Stack (use "Label()" to get the number in the stack)
-
- Int_t fNumberOfParticles = kTree->GetEntries() ;
- Int_t nPart = kStack->GetNtrack() ;
- cout << " Event n. " << evtN << " contains : " << fNumberOfParticles << " particles in the TTree ( = " << nPart << " in the stack ) . " << endl ;
+ // cout << endl ; cout << " Memory Check (from Paul)" << endl ;
+ // gObjectTable->Print();
+ // cout << endl ; cout << endl ;
- return kTree ;
+ return cen ;
}
+//////////////////////////////////////////////////////////////////////////////////////////////////////
-// // Helper macros for creating chains (from: CreateESDChain.C,v 1.10 jgrosseo Exp)
-// TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
-// {
-// // creates chain of files in a given directory or file containing a list.
-// // In case of directory the structure is expected as:
-// // <aDataDir>/<dir0>/AliESDs.root
-// // <aDataDir>/<dir1>/AliESDs.root
-// // ...
-//
-// if (!aDataDir)
-// return 0;
-//
-// Long_t id, size, flags, modtime;
-// if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
-// {
-// printf("%s not found.\n", aDataDir);
-// return 0;
-// }
-//
-// TChain* chain = new TChain("esdTree");
-// TChain* chaingAlice = 0;
-//
-// if (flags & 2)
-// {
-// TString execDir(gSystem->pwd());
-// TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
-// TList* dirList = baseDir->GetListOfFiles();
-// Int_t nDirs = dirList->GetEntries();
-// gSystem->cd(execDir);
-//
-// Int_t count = 0;
-//
-// for (Int_t iDir=0; iDir<nDirs; ++iDir)
-// {
-// TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
-// if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
-// continue;
-//
-// if (offset > 0)
-// {
-// --offset;
-// continue;
-// }
-//
-// if (count++ == aRuns)
-// break;
-//
-// TString presentDirName(aDataDir);
-// presentDirName += "/";
-// presentDirName += presentDir->GetName();
-//
-// chain->Add(presentDirName + "/AliESDs.root/esdTree");
-// }
-// }
-// else
-// {
-// // Open the input stream
-// ifstream in;
-// in.open(aDataDir);
-//
-// Int_t count = 0;
-//
-// // Read the input list of files and add them to the chain
-// TString esdfile;
-// while(in.good()) {
-// in >> esdfile;
-// if (!esdfile.Contains("root")) continue; // protection
-//
-// if (offset > 0)
-// {
-// --offset;
-// continue;
-// }
-//
-// if (count++ == aRuns)
-// break;
-//
-// // add esd file
-// chain->Add(esdfile);
-// }
-//
-// in.close();
-// }
-//
-// return chain;
-// }
-//
-// void LookupWrite(TChain* chain, const char* target)
-// {
-// // looks up the chain and writes the remaining files to the text file target
-//
-// chain->Lookup();
-//
-// TObjArray* list = chain->GetListOfFiles();
-// TIterator* iter = list->MakeIterator();
-// TObject* obj = 0;
-//
-// ofstream outfile;
-// outfile.open(target);
-//
-// while ((obj = iter->Next()))
-// outfile << obj->GetTitle() << "#AliESDs.root" << endl;
-//
-// outfile.close();
-//
-// delete iter;
-// }