void Embedding(const char* dataset="collection.xml") { gSystem->Load("libTree"); gSystem->Load("libGeom"); gSystem->Load("libVMC"); gSystem->Load("libPhysics"); //load analysis framework gSystem->Load("libSTEERBase"); gSystem->Load("libANALYSIS"); gSystem->Load("libANALYSISalice"); //AliAnalysisTaskSE gSystem->AddIncludePath("-I$ALICE_ROOT/include -I$ALICE_ROOT/PHOS"); // A task can be compiled dynamically with AClic gROOT->LoadMacro("AliPHOSEmbedding.cxx+g"); // Connect to alien TString token = gSystem->Getenv("GRID_TOKEN") ; if (1) // token == "OK" ) TGrid::Connect("alien://"); else AliInfo("You are not connected to the GRID") ; cout << "Pi0Analysis: processing collection " << dataset << endl; // Create the chain TChain* chain = new TChain("esdTree"); TGridCollection * collection = dynamic_cast<TGridCollection*>(TAlienCollection::Open(dataset)); TAlienResult* result = collection->GetGridResult("",0 ,0); TList* rawFileList = result->GetFileInfoList(); for (Int_t counter=0 ; counter < rawFileList->GetEntries() ; counter++) { TFileInfo * fi = static_cast<TFileInfo*>(rawFileList->At(counter)) ; const char * rawFile = fi->GetCurrentUrl()->GetUrl() ; printf("Processing %s\n", rawFile) ; chain->Add(rawFile); printf("Chain: %d entries.\n",chain->GetEntries()); } TFileInfo * fi = static_cast<TFileInfo*>(rawFileList->At(0)); const char * fn = fi->GetCurrentUrl()->GetUrl() ; char runNum[7]; for(Int_t i=0;i<6;i++)runNum[i]=fn[35+i] ; runNum[6]=0 ; Int_t iRunNum=atoi(runNum) ; printf("Run number=%d \n",iRunNum) ; //Run AOD simulation int nrun = atoi(runNum); int nevent = 0; int seed = 0; char sseed[1024]; char sevent[1024]; char sprocess[1024]; char sfield[1024]; char senergy[1024]; sprintf(sevent,""); sprintf(sprocess,""); sprintf(sfield,""); sprintf(senergy,""); seed = 0; sprintf(sseed,"%d",seed); if (seed==0) { fprintf(stderr,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); fprintf(stderr,"!!!! WARNING! Seeding variable for MC is 0 !!!!\n"); fprintf(stderr,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); } else { fprintf(stdout,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); fprintf(stdout,"!!! MC Seed is %d \n",seed); fprintf(stdout,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); } // set the seed environment variable gSystem->Setenv("CONFIG_SEED",sseed); gSystem->Setenv("CONFIG_RUN_TYPE","kPythia6"); // kPythia6 or kPhojet^M gSystem->Setenv("CONFIG_FIELD","k5kG"); // kNoField or k5kG^M gSystem->Setenv("CONFIG_ENERGY","2760"); // 900 or 10000 (GeV) gSystem->Setenv("DC_RUN",runNum); //run number char nSimEvents[55] ; sprintf(nSimEvents,"%d",chain->GetEntries()); gSystem->Setenv("SIM_EVENTS",nSimEvents); gSystem->Exec("mv geometry.root geometry_PHOS.root") ; gSystem->Exec("aliroot -b -q simrun.C > simrun.log 2>&1"); gSystem->Exec("mv geometry_PHOS.root geometry.root") ; // Make the analysis manager AliAnalysisManager *mgr = new AliAnalysisManager("Pi0EmbeddingManager"); // ESD input handler AliESDInputHandler* esdH = new AliESDInputHandler(); esdH->SetReadFriends(kFALSE); mgr->SetInputEventHandler(esdH); // Output AliAODHandler* aodHandler = new AliAODHandler(); aodHandler->SetOutputFileName("AliAODout.root"); mgr->SetOutputEventHandler(aodHandler); // Debug level mgr->SetDebugLevel(0); // Add physics selection gROOT->LoadMacro("$ALICE_ROOT/OADB/macros/AddTaskPhysicsSelection.C"); AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(kFALSE); gROOT->LoadMacro("$ALICE_ROOT/OADB/macros/AddTaskCentrality.C"); AliCentralitySelectionTask *taskCentrality = AddTaskCentrality() ; gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskEventplane.C"); AliEPSelectionTask *taskEP = AddTaskEventplane() ; // Add my task AliPHOSEmbedding *task1 = new AliPHOSEmbedding("Embedding"); TChain* chainAOD = new TChain("aodTree"); chainAOD->AddFile("AliAOD.root") ; task1->SetSignalChain(chainAOD) ; task1->SelectCollisionCandidates(); TFile *fOldCalib = TFile::Open("OldCalibration.root"); if(fOldCalib->IsOpen()){ printf("\n\n...Adding PHOS calibration used in ESD production \n") ; char key[55] ; TH2F * hCalib[5] ; for(Int_t mod=0;mod<5; mod++){ sprintf(key,"calibrationMod%d",mod) ; hCalib[mod] = (TH2F*)fOldCalib->Get(key) ; } task1->SetOldCalibration(hCalib) ; fOldCalib->Close() ; } mgr->AddTask(task1); // Create containers for input/output AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer(); AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("output0", TTree::Class(), AliAnalysisManager::kOutputContainer); // Connect input/output mgr->ConnectInput(task1 , 0, cinput); mgr->ConnectOutput(task1, 0,coutput1); AliLog::SetClassDebugLevel("AliGeomManager", 10) ; AliCDBManager::Instance()->SetRun(iRunNum) ; // AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB") ; // AliCDBManager::Instance()->SetDefaultStorage("raw://") ; AliCDBManager::Instance()->SetDefaultStorage("alien://folder=/alice/data/2010/OCDB") ; AliCDBManager::Instance()->SetSpecificStorage("PHOS/*/*", "local://OCDB"); printf("RunNunm===%d \n",iRunNum) ; if (mgr->InitAnalysis()) { mgr->PrintStatus(); mgr->StartAnalysis("local", chain); } if(iRunNum<=137848){ //period 1 gSystem->Exec("mv BadMap_LHC10h_period1.root BadMap_LHC10h.root") ; } else{ gSystem->Exec("mv BadMap_LHC10h_period234.root BadMap_LHC10h.root") ; } gSystem->Exec("aliroot -b -q AnalyzeDiff.C> analyze3.log 2>&1"); }
void AnaPi0Select(const char* dataset="minbias_LHC09a4_81040_81050.xml") { gSystem->Load("libTree"); gSystem->Load("libGeom"); gSystem->Load("libVMC"); gSystem->Load("libPhysics"); //load analysis framework gSystem->Load("libANALYSIS"); gSystem->Load("libANALYSISalice"); //AliAnalysisTaskSE //Set local DB for PHOS gROOT->ProcessLine(".! tar xzvf PHOS.tgz") ; AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); AliCDBManager::Instance()->SetSpecificStorage("PHOS/*","local://./"); // A task can be compiled dynamically with AClic gROOT->LoadMacro("AliAnalysisTaskPi0CalibSelection.cxx+g"); // Connect to alien TString token = gSystem->Getenv("GRID_TOKEN") ; if ( token == "OK" ) TGrid::Connect("alien://"); else AliInfo("You are not connected to the GRID") ; // Create the chain TChain* chain = new TChain("esdTree"); TGridCollection * collection = dynamic_cast<TGridCollection*>(TAlienCollection::Open(dataset)); TAlienResult* result = collection->GetGridResult("",0 ,0); TList* rawFileList = result->GetFileInfoList(); for (Int_t counter=0 ; counter < rawFileList->GetEntries() ; counter++) { TFileInfo * fi = static_cast<TFileInfo*>(rawFileList->At(counter)) ; const char * rawFile = fi->GetCurrentUrl()->GetUrl() ; printf("Processing %s\n", rawFile) ; chain->Add(rawFile); printf("Chain: %d entries.\n",chain->GetEntries()); } // Make the analysis manager AliAnalysisManager *mgr = new AliAnalysisManager("Pi0CalibSelect","Pi0CalibSelection"); // ESD input handler AliESDInputHandler* esdH = new AliESDInputHandler(); mgr->SetInputEventHandler(esdH); // Debug level mgr->SetDebugLevel(10); // Add task AliAnalysisTaskPi0CalibSelection *task = new AliAnalysisTaskPi0CalibSelection("Pi0CalibSelection"); task->SetClusterMinEnergy(0.4); mgr->AddTask(task); // Create containers for input/output AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer(); AliAnalysisDataContainer *coutput = mgr->CreateContainer("histos",TList::Class(),AliAnalysisManager::kOutputContainer,"histos.root"); // Connect input/output mgr->ConnectInput(task, 0, cinput); mgr->ConnectOutput(task, 1, coutput); if (mgr->InitAnalysis()) { mgr->PrintStatus(); mgr->StartAnalysis("local", chain); } }
void Hyperon(const char* dataset="collection.xml") { /* $Id$ */ TStopwatch timer; timer.Start(); TStringToken libs("Core,Tree,Geom,VMC,Physics,Minuit,Gui,XMLParser,Minuit2,Proof,STEERBase,ESD,AOD,OADB,ANALYSIS,ANALYSISalice,CDB,RAWDatabase,STEER,CORRFW,PHOSUtils,PHOSbase,PHOSpi0Calib,PHOSrec,PHOSshuttle,PHOSsim", ","); while( libs.NextToken() ) gSystem->Load( Form("lib%s", libs.Data()) ); gSystem->Load("libTree"); gSystem->Load("libGeom"); gSystem->Load("libVMC"); gSystem->Load("libPhysics"); gSystem->Load("libPWGGAGammaConv"); gSystem->Load("libPWGGAHyperon"); //load analysis framework gSystem->Load("libANALYSIS"); gSystem->Load("libANALYSISalice"); //AliAnalysisTaskSE // Connect to alien TString token = gSystem->Getenv("GRID_TOKEN") ; if (1) // token == "OK" ) TGrid::Connect("alien://"); else AliInfo("You are not connected to the GRID") ; cout << "Pi0Analysis: processing collection " << dataset << endl; // Create the chain TChain* chain = new TChain("aodTree"); TGridCollection * collection = dynamic_cast<TGridCollection*>(TAlienCollection::Open(dataset)); TAlienResult* result = collection->GetGridResult("",0 ,0); TList* rawFileList = result->GetFileInfoList(); for (Int_t counter=0 ; counter < rawFileList->GetEntries() ; counter++) { TFileInfo * fi = static_cast<TFileInfo*>(rawFileList->At(counter)) ; const char * rawFile = fi->GetCurrentUrl()->GetUrl() ; printf("Processing %s\n", rawFile) ; chain->Add(rawFile); printf("Chain: %d entries.\n",chain->GetEntriesFast()); } // Make the analysis manager AliAnalysisManager *mgr = new AliAnalysisManager("Hyperon"); mgr->SetCommonFileName("histos.root"); // AOD input handler AliAODInputHandler* aodH = new AliAODInputHandler(); mgr->SetInputEventHandler(aodH); // Debug level mgr->SetDebugLevel(2); gROOT->LoadMacro("$ALICE_PHYSICS/OADB/macros/AddTaskCentrality.C"); AliCentralitySelectionTask* taskCentrality = AddTaskCentrality(); if (analysisMC) taskCentrality->SetMCInput(); // // Update it for Hyperon (YK 22.01.2015) // gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskEventplane.C"); // AliEPSelectionTask *taskEP = AddTaskEventplane() ; // gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskVZEROEPSelection.C"); // AliVZEROEPSelectionTask *selTask = AddTaskVZEROEPSelection(); // Add my task AliAnalysisHyperon* task = new AliAnalysisHyperon(); // gROOT->LoadMacro("$ALICE_ROOT/PWGGA/PHOSTasks/PHOS_PbPb/AddTaskPHOSPi0Flow.C"); // Update it for Hyperon (YK 22.01.2015) // task = AddTaskPHOSPi0Flow(); // // Create containers for input/output AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer(); AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("Hyperon",TList::Class(),AliAnalysisManager::kOutputContainer,"HyperonHist.root"); // // Connect input/output mgr->ConnectInput(task , 0, cinput); mgr->ConnectOutput(task, 1, coutput1); if (mgr->InitAnalysis()) { mgr->PrintStatus(); mgr->StartAnalysis("local", chain); } timer.Stop(); timer.Print(); }
void CreateChain(const anaModes mode, TChain * chain){ //Fills chain with data TString ocwd = gSystem->WorkingDirectory(); //----------------------------------------------------------- //Analysis of CAF data locally and with PROOF //----------------------------------------------------------- if(mode ==mPROOF || mode ==mLocalCAF){ // Chain from CAF gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C"); // The second parameter is the number of input files in the chain chain = CreateESDChain("ESD12001.txt", 5); } //--------------------------------------- //Local files analysis //--------------------------------------- else if(mode == mLocal){ //If you want to add several ESD files sitting in a common directory INDIR //Specify as environmental variables the directory (INDIR), the number of files //to analyze (NFILES) and the pattern name of the directories with files (PATTERN) if(gSystem->Getenv("INDIR")) kInDir = gSystem->Getenv("INDIR") ; else cout<<"INDIR not set, use default: "<<kInDir<<endl; if(gSystem->Getenv("PATTERN")) kPattern = gSystem->Getenv("PATTERN") ; else cout<<"PATTERN not set, use default: "<<kPattern<<endl; if(gSystem->Getenv("NFILES")) kFile = atoi(gSystem->Getenv("NFILES")) ; else cout<<"NFILES not set, use default: "<<kFile<<endl; //Check if env variables are set and are correct if ( kInDir && kFile) { printf("Get %d files from directory %s\n",kFile,kInDir); if ( ! gSystem->cd(kInDir) ) {//check if ESDs directory exist printf("%s does not exist\n", kInDir) ; return ; } cout<<"INDIR : "<<kInDir<<endl; cout<<"NFILES : "<<kFile<<endl; cout<<"PATTERN : " <<kPattern<<endl; TString datafile=""; if(kInputData == "ESD") datafile = "AliESDs.root" ; else if(kInputData == "AOD") datafile = "AliAOD.root" ; else if(kInputData == "MC") datafile = "galice.root" ; //Loop on ESD files, add them to chain Int_t event =0; Int_t skipped=0 ; char file[120] ; for (event = 0 ; event < kFile ; event++) { sprintf(file, "%s/%s%d/%s", kInDir,kPattern,event,datafile.Data()) ; TFile * fESD = 0 ; //Check if file exists and add it, if not skip it if ( fESD = TFile::Open(file)) { if ( fESD->Get(kTreeName) ) { printf("++++ Adding %s\n", file) ; chain->AddFile(file); } } else { printf("---- Skipping %s\n", file) ; skipped++ ; } } printf("number of entries # %lld, skipped %d\n", chain->GetEntries(), skipped*100) ; } else { TString input = "AliESDs.root" ; cout<<">>>>>> No list added, take a single file <<<<<<<<< "<<input<<endl; chain->AddFile(input); } }// local files analysis //------------------------------ //GRID xml files //----------------------------- else if(mode == mGRID){ //Get colection file. It is specified by the environmental //variable XML if(gSystem->Getenv("XML") ) kXML = gSystem->Getenv("XML"); else sprintf(kXML, "collection.xml") ; if (!TFile::Open(kXML)) { printf("No collection file with name -- %s -- was found\n",kXML); return ; } else cout<<"XML file "<<kXML<<endl; //Load necessary libraries and connect to the GRID gSystem->Load("libNetx") ; gSystem->Load("libRAliEn"); TGrid::Connect("alien://") ; //Feed Grid with collection file //TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\", 0)", kXML)); TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML); if (! collection) { AliError(Form("%s not found", kXML)) ; return kFALSE ; } TGridResult* result = collection->GetGridResult("",0 ,0); // Makes the ESD chain printf("*** Getting the Chain ***\n"); for (Int_t index = 0; index < result->GetEntries(); index++) { TString alienURL = result->GetKey(index, "turl") ; cout << "================== " << alienURL << endl ; chain->Add(alienURL) ; } }// xml analysis gSystem->ChangeDirectory(ocwd.Data()); }
void CPVanalysis(const TString dataset="") { gSystem->Load("libTree"); gSystem->Load("libGeom"); gSystem->Load("libVMC"); gSystem->Load("libPhysics"); //load analysis framework gSystem->Load("libANALYSIS"); gSystem->Load("libANALYSISalice"); //AliAnalysisTaskSE gSystem->AddIncludePath("-I$ALICE_ROOT/include -I$ALICE_ROOT/PHOS"); // A task can be compiled dynamically with AClic gROOT->LoadMacro("AliAnalysisTaskCPV.cxx+g"); // Connect to alien TString token = gSystem->Getenv("GRID_TOKEN") ; token="OK"; if ( token == "OK" ) TGrid::Connect("alien://"); else Printf("You are not connected to the GRID") ; // AliInfo("You are not connected to the GRID") ; cout << "CPVanalysis: processing collection " << dataset << endl; // Create the chain TChain* chain; if (dataset.Contains(".txt")) { gROOT->LoadMacro("$ALICE_PHYSICS/PWG/EMCAL/macros/CreateESDChain.C"); chain = CreateESDChain(dataset.Data(), 1000); } else if (dataset.Contains(".xml")) { chain = new TChain("esdTree"); TGridCollection * collection = dynamic_cast<TGridCollection*>(TAlienCollection::Open(dataset)); TAlienResult* result = collection->GetGridResult("",0 ,0); TList* rawFileList = result->GetFileInfoList(); for (Int_t counter=0 ; counter < rawFileList->GetEntries() ; counter++) { TFileInfo * fi = static_cast<TFileInfo*>(rawFileList->At(counter)) ; const char * rawFile = fi->GetCurrentUrl()->GetUrl() ; printf("Processing %s\n", rawFile) ; chain->Add(rawFile); printf("Chain: %d entries.\n",chain->GetEntries()); } } // Make the analysis manager AliAnalysisManager *mgr = new AliAnalysisManager("CPVanalysis"); // ESD input handler AliESDInputHandler* esdH = new AliESDInputHandler(); esdH->SetReadFriends(kFALSE); mgr->SetInputEventHandler(esdH); // Debug level mgr->SetDebugLevel(0); //PID task gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C"); AliAnalysisTask *taskPID = AddTaskPIDResponse(/*Bool_t isMC=*/ kFALSE, /*Bool_t autoMCesd=*/kTRUE, /*Bool_t tuneOnData=*/kTRUE); // // Add physics selection gROOT->LoadMacro("$ALICE_PHYSICS/OADB/macros/AddTaskPhysicsSelection.C"); AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(); physSelTask->GetPhysicsSelection()->SetUseBXNumbers(kFALSE);// ---> ??? // Add my task AliAnalysisTaskCPV *task1 = new AliAnalysisTaskCPV("CPVanalysis"); // task1->SelectCollisionCandidates(AliVEvent::kMB); mgr->AddTask(task1); // Create containers for input/output AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer(); AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("histCPV1",TList::Class(),AliAnalysisManager::kOutputContainer,"CPVanalysis.root"); AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("histCPV2",TList::Class(),AliAnalysisManager::kOutputContainer,"CPVanalysis.root"); ((AliInputEventHandler*)mgr->GetInputEventHandler())->SetNeedField(1); // Connect input/output mgr->ConnectInput(task1 , 0, cinput); mgr->ConnectOutput(task1, 1, coutput1); mgr->ConnectOutput(task1, 2, coutput2); if (mgr->InitAnalysis()) { mgr->PrintStatus(); mgr->StartAnalysis("local", chain); } }
//_____________________________________________________________________ /// Fills chain with data files paths. //_____________________________________________________________________ void CreateChain(const anaModes mode, TChain * chain){//, TChain * chainxs){ //Fills chain with data TString datafileName=""; if(kInputData == "ESD") datafileName = "AliESDs.root" ; else if(kInputData == "AOD") datafileName = "AliAOD.root" ; else if(kInputData == "MC") datafileName = "galice.root" ; TString ocwd = gSystem->WorkingDirectory(); //--------------------------------------- // Local files analysis //--------------------------------------- if(mode == mLocal) { //If you want to add several ESD files sitting in a common directory INDIR //Specify as environmental variables the directory (INDIR), the number of files //to analyze (NFILES) and the pattern name of the directories with files (PATTERN) cout<<"INDIR : "<<kInDir<<endl; cout<<"NFILES : "<<kFile<<endl; cout<<"PATTERN: " <<kPattern<<endl; //Loop on ESD files, add them to chain TString FileName ; for (Int_t iFile = 0 ; iFile < kFile ; iFile++) { FileName = Form("%s/%s%d/%s", kInDir,kPattern,iFile,datafileName.Data()) ; //cout << "FileName: " << FileName <<endl ; TFile * dataFile = 0 ; //Check if file exists and add it, if not skip it if ( dataFile = TFile::Open(FileName.Data())) { if ( dataFile->Get(kTreeName) ) { Int_t nEventsPerFile = ((TTree*) dataFile->Get(kTreeName)) ->GetEntries(); printf(" ++++ Adding %s, with %d events \n", FileName.Data(), nEventsPerFile) ; chain->AddFile(FileName); } } } printf("number of entries # %lld \n", chain->GetEntries()) ; }// local files analysis //------------------------------ //GRID xml files //----------------------------- else if(mode == mGRID) { //Load necessary libraries and connect to the GRID gSystem->Load("libNetx") ; gSystem->Load("libRAliEn"); TGrid::Connect("alien://") ; //Feed Grid with collection file //TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\", 0)", kXML)); TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML); if (! collection) { AliError(Form("%s not found", kXML)) ; return kFALSE ; } TGridResult* result = collection->GetGridResult("",0 ,0); // Makes the ESD chain printf("*** Getting the Chain ***\n"); Int_t nEventsPerFile = 0; for (Int_t index = 0; index < result->GetEntries(); index++) { TString alienURL = result->GetKey(index, "turl") ; cout << "================== " << alienURL << endl ; chain->Add(alienURL) ; } }// xml analysis gSystem->ChangeDirectory(ocwd.Data()); }