1. Renaming Pass0 --> CPass0
authormarian <marian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 28 Mar 2012 11:08:46 +0000 (11:08 +0000)
committermarian <marian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 28 Mar 2012 11:08:46 +0000 (11:08 +0000)
2. Renaming PassX --> CPass1

3. User defined macros to submit alien test jobs
      CPass0/test/runPass0User.sh
      CPass0/test/mergeMakeOCDBUser.sh

4.  ConfigCalibTrain.C and  recPass0.C
      Optional usage of the OCDB snapshot

5.  CPass0/AddTaskTPCCalib.C
      Adding the component for cluster errors

6.  CPass0/runPass0.sh
      Additional options for  local test

39 files changed:
PWGPP/CalibMacros/CPass0/AddTOFAnalysisTaskCalibPass0.C [new file with mode: 0644]
PWGPP/CalibMacros/CPass0/AddTaskMeanVertexCalib.C [new file with mode: 0644]
PWGPP/CalibMacros/CPass0/AddTaskSDDCalib.C [new file with mode: 0644]
PWGPP/CalibMacros/CPass0/AddTaskT0Calib.C [new file with mode: 0755]
PWGPP/CalibMacros/CPass0/AddTaskTPCCalib.C [new file with mode: 0644]
PWGPP/CalibMacros/CPass0/AddTaskTRDCalib.C [new file with mode: 0644]
PWGPP/CalibMacros/CPass0/ConfigCalibTrain.C [new file with mode: 0644]
PWGPP/CalibMacros/CPass0/LoadLibraries.C [new file with mode: 0644]
PWGPP/CalibMacros/CPass0/MeanVertexCalibPass0.C [new file with mode: 0644]
PWGPP/CalibMacros/CPass0/Pass0.jdl [new file with mode: 0644]
PWGPP/CalibMacros/CPass0/README [new file with mode: 0644]
PWGPP/CalibMacros/CPass0/README.OCDB [new file with mode: 0644]
PWGPP/CalibMacros/CPass0/makeOCDB.C [new file with mode: 0644]
PWGPP/CalibMacros/CPass0/makeOCDB.byComponent.C [new file with mode: 0644]
PWGPP/CalibMacros/CPass0/merge.C [new file with mode: 0644]
PWGPP/CalibMacros/CPass0/merge.byComponent.C [new file with mode: 0644]
PWGPP/CalibMacros/CPass0/mergeMakeOCDB.byComponent.sh [new file with mode: 0755]
PWGPP/CalibMacros/CPass0/mergeMakeOCDB.jdl [new file with mode: 0644]
PWGPP/CalibMacros/CPass0/mergeMakeOCDB.sh [new file with mode: 0755]
PWGPP/CalibMacros/CPass0/recPass0.C [new file with mode: 0644]
PWGPP/CalibMacros/CPass0/runCalibTrain.C [new file with mode: 0644]
PWGPP/CalibMacros/CPass0/runPass0.sh [new file with mode: 0644]
PWGPP/CalibMacros/CPass0/test/mergeMakeOCDBUser.sh [new file with mode: 0755]
PWGPP/CalibMacros/CPass0/test/runPass0User.sh [new file with mode: 0755]
PWGPP/CalibMacros/CPass0/validation.sh [new file with mode: 0644]
PWGPP/CalibMacros/CPass0/validationMerging.sh [new file with mode: 0755]
PWGPP/CalibMacros/CPass1/AddTaskAddObject.C [new file with mode: 0644]
PWGPP/CalibMacros/CPass1/AddTaskFilterFriend.C [new file with mode: 0644]
PWGPP/CalibMacros/CPass1/AddTaskFilterFriendSecond.C [new file with mode: 0644]
PWGPP/CalibMacros/CPass1/AddTaskFilterSteer.C [new file with mode: 0644]
PWGPP/CalibMacros/CPass1/AddTaskTPCCalib.C [new file with mode: 0644]
PWGPP/CalibMacros/CPass1/ConfigCalibTrain.C [new file with mode: 0644]
PWGPP/CalibMacros/CPass1/LoadLibraries.C [new file with mode: 0644]
PWGPP/CalibMacros/CPass1/PassX.jdl [new file with mode: 0644]
PWGPP/CalibMacros/CPass1/rec.C [new file with mode: 0644]
PWGPP/CalibMacros/CPass1/runCalibTrain.C [new file with mode: 0644]
PWGPP/CalibMacros/CPass1/runPassX.sh [new file with mode: 0644]
PWGPP/CalibMacros/CPass1/tag.C [new file with mode: 0644]
PWGPP/CalibMacros/CPass1/validation.sh [new file with mode: 0644]

diff --git a/PWGPP/CalibMacros/CPass0/AddTOFAnalysisTaskCalibPass0.C b/PWGPP/CalibMacros/CPass0/AddTOFAnalysisTaskCalibPass0.C
new file mode 100644 (file)
index 0000000..3125051
--- /dev/null
@@ -0,0 +1,74 @@
+AliTOFAnalysisTaskCalibPass0 *
+AddTOFAnalysisTaskCalibPass0()
+{
+
+  /* check analysis manager */
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    Error("AddAnalysisTaskEventTime", "cannot get analysis manager");
+    return NULL;
+  }
+
+  /* check input event handler */
+  if (!mgr->GetInputEventHandler()) {
+    Error("AddAnalysisTaskEventTime", "cannot get input event handler");
+    return NULL;
+  }
+  
+  /* check input data type */
+  TString str = mgr->GetInputEventHandler()->GetDataType();
+  if (str.CompareTo("ESD")) {
+    Error("AddAnalysisTaskEventTime", "input data type is not \"ESD\"");
+    return NULL;
+  }
+
+  /* get common input data container */
+  AliAnalysisDataContainer *inputc = mgr->GetCommonInputContainer();
+  if (!inputc) {
+    Error("AddAnalysisTaskEventTime", "cannot get common input container");
+    return NULL;
+  }
+  
+  /* create output data container */
+  AliAnalysisDataContainer *outputc1 = mgr->CreateContainer("TOFHistos", TList::Class(), AliAnalysisManager::kOutputContainer, "AliESDfriends_v1.root");
+  if (!outputc1) {
+    Error("AddAnalysisTaskEventTime", "cannot create output container \"Histos\"");
+    return NULL;
+  }
+
+  /*  create task and connect input/output */
+  AliTOFAnalysisTaskCalibPass0 *task = new AliTOFAnalysisTaskCalibPass0();
+
+  // adding the task
+  mgr->AddTask(task);
+
+  mgr->ConnectInput(task, 0, inputc);
+  mgr->ConnectOutput(task, 1, outputc1);
+
+  /* setup task */
+  task->SetEventSelectionFlag(kFALSE);
+  task->SetVertexSelectionFlag(kTRUE);
+  task->SetVertexCut(25.0);
+  /* setup TOF calib */
+  task->GetTOFcalib()->SetRemoveMeanT0(kFALSE);
+  task->GetTOFcalib()->SetUseLHCClockPhase(kTRUE);
+  task->GetTOFcalib()->SetCalibrateTOFsignal(kTRUE);
+  task->GetTOFcalib()->SetCorrectTExp(kFALSE);
+  /* setup track cuts */
+  AliESDtrackCuts *trackCuts = task->GetTrackCuts();
+  trackCuts->SetPtRange(0.5, 10.);
+  trackCuts->SetEtaRange(-1.0, 1.0);
+  trackCuts->SetRequireITSRefit(kTRUE);
+  trackCuts->SetMinNClustersITS(1);
+  trackCuts->SetRequireTPCRefit(kTRUE);
+  trackCuts->SetMinNClustersTPC(70);
+  trackCuts->SetMaxChi2PerClusterTPC(4.);
+  trackCuts->SetAcceptKinkDaughters(kFALSE);
+  trackCuts->SetMaxDCAToVertexZ(3.2);
+  trackCuts->SetMaxDCAToVertexXY(2.4);
+  trackCuts->SetDCAToVertex2D(kTRUE);
+
+  /* return task */
+  return task;
+
+}
diff --git a/PWGPP/CalibMacros/CPass0/AddTaskMeanVertexCalib.C b/PWGPP/CalibMacros/CPass0/AddTaskMeanVertexCalib.C
new file mode 100644 (file)
index 0000000..785a0f1
--- /dev/null
@@ -0,0 +1,33 @@
+AliMeanVertexCalibTask *AddTaskMeanVertexCalib(){
+  //
+  //AddTask for MeanVertex Task to run with pass0
+  //Author: D.Caffarri davide.caffarri@pd.infn.it
+  //
+
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    ::Error("AddTaskMeanVertex", "No analysis manager to connect to.");
+    return NULL;
+  }
+
+
+  if (!mgr->GetInputEventHandler()) {
+    ::Error("AddTaskMeanVertex", "This task requires an input event handler");
+    return NULL;
+  }  
+
+  
+  AliMeanVertexCalibTask *meanVertexTask = new AliMeanVertexCalibTask("AliMeanVertexCalibTask");
+  
+  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
+  if (!cinput1) cinput1 = mgr->CreateContainer("cchain",TChain::Class(), AliAnalysisManager::kInputContainer);
+  
+  
+  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("MeanVertex", TList::Class(),AliAnalysisManager::kOutputContainer, "AliESDfriends_v1.root"); 
+  
+  mgr->ConnectInput(meanVertexTask,0,cinput1);
+  mgr->ConnectOutput(meanVertexTask,1,coutput1);
+  
+  return meanVertexTask;
+  
+}
diff --git a/PWGPP/CalibMacros/CPass0/AddTaskSDDCalib.C b/PWGPP/CalibMacros/CPass0/AddTaskSDDCalib.C
new file mode 100644 (file)
index 0000000..3e27913
--- /dev/null
@@ -0,0 +1,47 @@
+AliAnalysisTaskITSAlignQA *AddTaskSDDCalib(Int_t nrun=0) 
+{
+
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    ::Error("AddTaskITSAlign", "No analysis manager to connect to.");
+    return NULL;
+  }   
+  
+  if (!mgr->GetInputEventHandler()) {
+    ::Error("AddTaskITSAlign", "This task requires an input event handler");
+    return NULL;
+  }   
+  
+  TString type = mgr->GetInputEventHandler()->GetDataType(); 
+  if(type.Contains("AOD")){
+    ::Error("AddTaskITSAlign", "This task requires to run on ESD");
+    return NULL;
+  }
+  
+  // Create and configure the task
+  AliAnalysisTaskITSAlignQA *taskali = new AliAnalysisTaskITSAlignQA();
+  //  taskali->SelectCollisionCandidates();
+  if (nrun>0) taskali->SetOCDBInfo(nrun,Form("raw://")) ; 
+  taskali->SetLoadGeometryFromOCDB(kFALSE);
+  mgr->AddTask(taskali);
+  //  
+  taskali->SetUseVertex(kTRUE);
+  taskali->SetUseVertexForZOnly(kFALSE);
+  taskali->SetDoSPDResiduals(kFALSE);
+  taskali->SetDoSDDResiduals(kFALSE);
+  taskali->SetDoSSDResiduals(kFALSE);
+  taskali->SetDoSDDDriftTime(kFALSE);
+  taskali->SetMinMaxMult(20.,1070.);
+  //
+  //
+  TString outputFileName = AliAnalysisManager::GetCommonFileName();
+  
+  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("clistSDDCalib",
+                                                           TList::Class(),
+                                                           AliAnalysisManager::kOutputContainer,
+                                                           outputFileName );
+  
+  mgr->ConnectInput(taskali, 0, mgr->GetCommonInputContainer());
+  mgr->ConnectOutput(taskali, 1, coutput1);
+  return taskali;
+}
diff --git a/PWGPP/CalibMacros/CPass0/AddTaskT0Calib.C b/PWGPP/CalibMacros/CPass0/AddTaskT0Calib.C
new file mode 100755 (executable)
index 0000000..3b139fa
--- /dev/null
@@ -0,0 +1,115 @@
+
+void    readCDB (TObject *task1);
+//_____________________________________________________________________________
+AliAnalysisTask  *AddTaskT0Calib(Int_t runNumber)
+{
+  //
+  // add calibration task
+  //
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    ::Error("AddTaskT0Calib", "No analysis manager to connect to.");
+    return NULL;
+  }  
+  
+  // check the input handler
+  if (!mgr->GetInputEventHandler()) {
+    ::Error("AddTaskT0Calib", "This task requires an input event handler");
+    return NULL;
+  }  
+
+  // set TPC OCDB parameters
+  //ConfigOCDB(runNumber);
+
+  // setup task
+  AliT0CalibOffsetChannelsTask  *task1 = new AliT0CalibOffsetChannelsTask("CalibObjectsTrain1");
+  readCDB(task1, runNumber);
+  mgr->AddTask(task1);
+  
+  //  AliT0AnalysisTaskQA * task2 = new AliT0AnalysisTaskQA("QA task");
+  //    mgr->AddTask(task2);
+
+  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
+  if (!cinput1) cinput1 = mgr->CreateContainer("cchain",TChain::Class(), 
+                                      AliAnalysisManager::kInputContainer);
+  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("T0Calib",TObjArray::Class(), AliAnalysisManager::kOutputContainer, "AliESDfriends_v1.root");  
+
+  mgr->ConnectInput(task1,0,cinput1);
+  mgr->ConnectOutput(task1,1,coutput1);
+  return task1;
+}
+//_____________________________________________________________________________
+void    readCDB (TObject *task1,  Int_t runNumber) {
+
+  Float_t zero_timecdb[24]={0};
+  Float_t *timecdb = zero_timecdb;
+  Float_t cfdvalue[24][5];
+  for(Int_t i=0; i<24; i++) 
+    for (Int_t i0=0; i0<5; i0++)
+      cfdvalue[i][i0] = 0;
+      
+  Float_t zero_shiftcdb[4]={0};
+  Float_t *shiftcdb = zero_shiftcdb;
+  AliT0CalibOffsetChannelsTask *mytask = (AliT0CalibOffsetChannelsTask*)task1;
+
+  AliCDBManager* man = AliCDBManager::Instance();
+  man->SetDefaultStorage("raw://");
+  man->SetRun(runNumber);
+  AliCDBEntry *entry = AliCDBManager::Instance()->Get("GRP/CTP/CTPtiming");
+  if (!entry) AliFatal("CTP timing parameters are not found in OCDB !");
+  AliCTPTimeParams *ctpParams = (AliCTPTimeParams*)entry->GetObject();
+  Float_t l1Delay = (Float_t)ctpParams->GetDelayL1L0()*25.0;
+
+  AliCDBEntry *entry1 = AliCDBManager::Instance()->Get("GRP/CTP/TimeAlign");
+  if (!entry1) AliFatal("CTP time-alignment is not found in OCDB !");
+  AliCTPTimeParams *ctpTimeAlign = (AliCTPTimeParams*)entry1->GetObject();
+  l1Delay += ((Float_t)ctpTimeAlign->GetDelayL1L0()*25.0);
+  AliCDBEntry *entry4 = AliCDBManager::Instance()->Get("GRP/Calib/LHCClockPhase");
+  if (!entry4) AliFatal("LHC clock-phase shift is not found in OCDB !");
+  AliLHCClockPhase *phase = (AliLHCClockPhase*)entry4->GetObject();
+  Float_t fGRPdelays = l1Delay - phase->GetMeanPhase();
+
+  AliCDBEntry *entryCalib0 = man->Get("T0/Calib/Latency");
+  if(!entryCalib0) {
+    AliError::(Form("Cannot find any AliCDBEntry for [Calib, Latency]!"));
+    return;
+  }
+  AliT0CalibLatency *calibda=(AliT0CalibLatency*)entryCalib0->GetObject();
+  Float_t fLatencyL1 = calibda->GetLatencyL1();
+  Float_t fLatencyHPTDC = calibda->GetLatencyHPTDC();
+  AliCDBEntry *entryCalib1 = man->Get("T0/Calib/TimeDelay");
+  if(!entryCalib1) {
+    AliError::(Form("Cannot find any AliCDBEntry for [Calib, TimeDelay]!"));
+    return;
+  }
+  else
+    {
+      AliT0CalibTimeEq *clb = (AliT0CalibTimeEq*)entryCalib1->GetObject();
+      timecdb = clb->GetTimeEq();
+      for(Int_t i=0; i<24; i++) 
+       for (Int_t i0=0; i0<5; i0++){
+         cfdvalue[i][i0] = clb->GetCFDvalue(i, i0);
+       }
+    }
+  for (Int_t i=0; i<24; i++) {
+    Float_t cfdmean = cfdvalue[i][0];
+    if( cfdvalue[i][0] < 500 || cfdvalue[i][0] > 50000) cfdmean = ( 1000.*fLatencyHPTDC - 1000.*fLatencyL1 + 1000.*fGRPdelays)/24.4;
+     mytask->SetCFDvalue(i, cfdmean);
+    mytask->SetTimeEq(i, timecdb[i]);
+  } 
+
+  AliCDBEntry *entryCalib2 = man->Get("T0/Calib/TimeAdjust");
+  if(!entryCalib2) {
+     AliError(Form("Cannot find any AliCDBEntry for [Calib, TimeAdjust]!"));
+  }
+ else
+    {
+      AliT0CalibSeasonTimeShift *clb1 = (AliT0CalibSeasonTimeShift*)entryCalib2->GetObject();
+      shiftcdb = clb1->GetT0Means();
+    }
+  
+  for (Int_t i=0; i<4; i++)  mytask->SetT0Means(i,shiftcdb[i]);
+}
diff --git a/PWGPP/CalibMacros/CPass0/AddTaskTPCCalib.C b/PWGPP/CalibMacros/CPass0/AddTaskTPCCalib.C
new file mode 100644 (file)
index 0000000..3d63337
--- /dev/null
@@ -0,0 +1,257 @@
+/*
+
+ This macros setup the TPC calibration task AddTaskTPCCalib
+ for Pass0.
+ - the run number is required to config TPC OCDB
+ The following calibration components are added to the AliTPCAnalysisTaskcalib task:
+ 1. AliTPCcalibCalib - redo reconstruction with current calibration
+ 2. AliTPCcalibTimeGain - TPC time dependent gain calibration
+ 3. AliTPCcalibTime - TPC time dependent drift time calibration
+
+*/
+
+// function to set TPC OCDB parameters
+void ConfigOCDB(Int_t crun);
+
+Int_t debugLevel=0;
+Int_t streamLevel=0;
+
+//_____________________________________________________________________________
+AliAnalysisTask  *AddTaskTPCCalib(Int_t runNumber)
+{
+  //
+  // add calibration task
+  //
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    ::Error("AddTaskTPCCalib", "No analysis manager to connect to.");
+    return NULL;
+  }  
+  
+  // check the input handler
+  if (!mgr->GetInputEventHandler()) {
+    ::Error("AddTaskTPCCalib", "This task requires an input event handler");
+    return NULL;
+  }  
+
+  // set TPC OCDB parameters
+  ConfigOCDB(runNumber);
+
+  // setup task
+  AliTPCAnalysisTaskcalib *task1=new AliTPCAnalysisTaskcalib("CalibObjectsTrain1");
+  SetupCalibTaskTrain1(task1);
+  mgr->AddTask(task1);
+
+  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
+  if (!cinput1) cinput1 = mgr->CreateContainer("cchain",TChain::Class(), 
+                                      AliAnalysisManager::kInputContainer);
+  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("TPCCalib",TObjArray::Class(), AliAnalysisManager::kOutputContainer, "AliESDfriends_v1.root");  
+
+  mgr->ConnectInput(task1,0,cinput1);
+  mgr->ConnectOutput(task1,0,coutput1);
+  return task1;
+}
+
+//_____________________________________________________________________________
+void AddCalibCalib(TObject* task){
+  //
+  // Responsible: Marian Ivanov
+  // Description:
+  // calibCalib is a prefilter 
+  // The current OCDB entries transformation are applied on cluster, tracks are refitted
+  //
+  AliTPCAnalysisTaskcalib* myTask = (AliTPCAnalysisTaskcalib*) task;
+  AliTPCcalibCalib *calibCalib = new AliTPCcalibCalib("calibTPC","calibTPC");
+  calibCalib->SetDebugLevel(0);
+  calibCalib->SetStreamLevel(0);
+  calibCalib->SetTriggerMask(-1,-1,kFALSE);        //accept everything 
+  myTask->AddJob(calibCalib);
+}
+
+//_____________________________________________________________________________
+void AddCalibTimeGain(TObject* task, Bool_t isCosmic = kFALSE, char * name = "calibTimeGain"){
+  //
+  //  Responsible: Alexander Kalweit
+  //  Description: Time Gain calibration
+  //
+
+  // Set run time ranges (time stamps)
+  AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
+  if(!entry) { 
+    ::Error("AddCalibTimeGain","Cannot get AliCDBEntry");
+    return;
+  }
+  const AliGRPObject* grpData = dynamic_cast<AliGRPObject*>(entry->GetObject());
+  if(!grpData) { 
+    ::Error("AddCalibTimeGain","Cannot get AliGRPObject");
+    return;
+  }
+  time_t sTime = grpData->GetTimeStart(); 
+  time_t eTime = grpData->GetTimeEnd(); 
+  TTimeStamp startRunTime(sTime);
+  TTimeStamp stopRunTime(eTime);
+
+  UInt_t year;
+  startRunTime.GetDate(kTRUE,0,&year);
+  TTimeStamp startTime(year,1,1,0,0,0);
+  TTimeStamp stopTime(year,12,31,23,59,59);
+
+  // 
+  // setup calibration component
+  //
+  AliTPCAnalysisTaskcalib* myTask = (AliTPCAnalysisTaskcalib*) task;
+  AliTPCcalibTimeGain *calibTimeGain = new AliTPCcalibTimeGain(name,"calibTimeGain", startTime.GetSec(), stopTime.GetSec(), 10*60);
+  calibTimeGain->SetIsCosmic(isCosmic);
+  calibTimeGain->SetUseCookAnalytical(kTRUE);
+  calibTimeGain->SetUseMax(kTRUE);
+  calibTimeGain->SetDebugLevel(0);
+  calibTimeGain->SetStreamLevel(0);
+  calibTimeGain->SetTriggerMask(-1,-1,kTRUE);        //reject laser
+  calibTimeGain->SetLowerTrunc(0.02);
+  calibTimeGain->SetUpperTrunc(0.6);
+
+  myTask->AddJob(calibTimeGain);
+
+  AliTPCcalibGainMult *calibGainMult = new AliTPCcalibGainMult("calibGainMult","calibGainMult");
+  calibGainMult->SetUseMax(kTRUE);
+  calibGainMult->SetDebugLevel(0);
+  calibGainMult->SetStreamLevel(0);
+  calibGainMult->SetTriggerMask(-1,-1,kTRUE);        //reject laser
+  calibGainMult->SetLowerTrunc(0.02);
+  calibGainMult->SetUpperTrunc(0.6);
+
+  myTask->AddJob(calibGainMult);
+
+}
+
+//_____________________________________________________________________________
+void AddCalibTime(TObject* task){
+  //
+  // Responsible: Dag Larsen
+  // Description: Time V drift calibration
+  //
+
+  // Set run time ranges (time stamps)
+  AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
+  if(!entry) { 
+    ::Error("AddCalibTime","Cannot get AliCDBEntry");
+    return;
+  }
+  const AliGRPObject* grpData = dynamic_cast<AliGRPObject*>(entry->GetObject());
+  if(!grpData) { 
+    ::Error("AddCalibTime","Cannot get AliGRPObject");
+    return;
+  }
+  time_t sTime = grpData->GetTimeStart(); 
+  time_t eTime = grpData->GetTimeEnd(); 
+
+  TTimeStamp startRunTime(sTime);
+  TTimeStamp stopRunTime(eTime);
+
+  UInt_t year;
+  startRunTime.GetDate(kTRUE,0,&year);
+  TTimeStamp startTime(year,1,1,0,0,0);
+  TTimeStamp stopTime(year,12,31,23,59,59);
+
+  // 
+  // setup calibration component
+  //
+  AliTPCAnalysisTaskcalib* myTask = (AliTPCAnalysisTaskcalib*) task;
+  AliTPCcalibTime *calibTime = new AliTPCcalibTime("calibTime","calibTime",  startTime.GetSec(), stopTime.GetSec(), 10*60, 2);
+  calibTime->SetDebugLevel(0);
+  calibTime->SetStreamLevel(0);
+  calibTime->SetTriggerMask(-1,-1,kFALSE);        //accept everything 
+
+  // max 600 tracks per event
+  calibTime->SetCutTracks(600);
+
+  myTask->AddJob(calibTime);
+}
+
+
+void AddCalibTracks(TObject* task){
+  //
+  // Responsible: Marian Ivanov
+  // Description:
+  // Histogram residuals and pulls of the track parameters in bins of track parameters
+  //
+  AliTPCAnalysisTaskcalib* myTask = (AliTPCAnalysisTaskcalib*) task; 
+  AliTPCClusterParam * clusterParam = AliTPCcalibDB::Instance()->GetClusterParam();
+
+   AliTPCcalibTracksCuts *cuts = new AliTPCcalibTracksCuts(30, 0.4, 5, 0.13, 0.018);
+  //
+  AliTPCcalibTracks *calibTracks =  new AliTPCcalibTracks("calibTracks", "Resolution calibration object for tracks", clusterParam, cuts);
+  calibTracks->SetDebugLevel(debugLevel);
+  calibTracks->SetStreamLevel(streamLevel);
+  calibTracks->SetTriggerMask(-1,-1,kTRUE);       
+  myTask->AddJob(calibTracks); 
+}
+
+
+//_____________________________________________________________________________
+void SetupCalibTaskTrain1(TObject* task){
+  //
+  // Setup tasks for calibration train
+  //
+  AddCalibCalib(task);
+  AddCalibTimeGain(task);
+  AddCalibTime(task);
+  //AddCalibTracks(task);
+}
+
+//_____________________________________________________________________________
+void ConfigOCDB(Int_t run){
+  //
+  // Configure TPC OCDB
+  //
+  printf("SETUP OCBD for TPC\n");
+  printf("SETUP OCBD for TPC\n");
+  printf("SETUP OCBD for TPC Run =%d\n", run);
+  //
+  //
+  AliTPCParam *param= AliTPCcalibDB::Instance()->GetParameters();
+  param->ReadGeoMatrices();
+  //
+  AliMagF* magF= TGeoGlobalMagField::Instance()->GetField();
+  printf("\n\nSET EXB FIELD\t\n\n");
+  AliTPCcalibDB::Instance()->SetExBField(magF);
+  //
+  //
+  //
+  AliTPCTransform *transform     = AliTPCcalibDB::Instance()->GetTransform() ;
+  //
+  //AliTPCRecoParam * tpcRecoParam = AliTPCRecoParam::GetCosmicTestParam(kTRUE);
+  //
+  AliCDBEntry* entry = AliCDBManager::Instance()->Get("TPC/Calib/RecoParam");
+  if (!entry){
+    printf("TPC reco param not available");
+  }
+  TObjArray * array = (TObjArray*)entry->GetObject();
+  if (!array){
+    printf("TPC reco param not available");
+  }
+  // 0 - Low Flux (pp), 1- High Flux (Pb-Pb)
+  AliTPCRecoParam * tpcRecoParam = (AliTPCRecoParam*)array->At(1);
+
+  transform->SetCurrentRecoParam(tpcRecoParam);
+  tpcRecoParam->SetUseGainCorrectionTime(0);
+  tpcRecoParam->SetUseRPHICorrection(kFALSE); 
+  tpcRecoParam->SetUseTOFCorrection(kFALSE);
+  //
+  tpcRecoParam->SetUseDriftCorrectionTime(0);
+  tpcRecoParam->SetUseDriftCorrectionGY(0);
+  //
+  tpcRecoParam->SetUseRadialCorrection(kFALSE);
+  tpcRecoParam->SetUseQuadrantAlignment(kFALSE);
+  //
+  tpcRecoParam->SetUseSectorAlignment(kFALSE);
+  tpcRecoParam->SetUseFieldCorrection(kFALSE);
+  tpcRecoParam->SetUseExBCorrection(kFALSE);
+  //
+  tpcRecoParam->SetUseMultiplicityCorrectionDedx(kFALSE);
+  tpcRecoParam->SetUseAlignmentTime(kFALSE);
+  tpcRecoParam->SetUseComposedCorrection(kTRUE);
+
+  AliTPCcalibDB::Instance()->SetRun(run); 
+}
diff --git a/PWGPP/CalibMacros/CPass0/AddTaskTRDCalib.C b/PWGPP/CalibMacros/CPass0/AddTaskTRDCalib.C
new file mode 100644 (file)
index 0000000..67201c8
--- /dev/null
@@ -0,0 +1,114 @@
+//=============================================================================
+//
+// *** AddTaskTRDCalib
+//
+// This macros setup the TRD calibration task
+//
+//=============================================================================
+
+AliAnalysisTask  *AddTaskTRDCalib(Int_t runNumber)
+{
+  gSystem->Load("libTRDcalib");
+  // pointer to the analysis manager
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    Error("AddTaskTRDCalib", "No analysis manager to connect to.");
+    return NULL;
+  }
+
+  // check the input handler
+  if (!mgr->GetInputEventHandler()) {
+    ::Error("AddTask", "This task requires an input event handler");
+    return NULL;
+  }
+
+  ////////////////////////////////////////////
+  // Number of timebins
+  ///////////////////////////////////////////
+  AliTRDcalibDB *calib = AliTRDcalibDB::Instance();
+  Int_t nbOfTimeBins = calib->GetNumberOfTimeBinsDCS();
+  if(nbOfTimeBins < 0) nbOfTimeBins = 27;
+  ////////////////////////////////////////////
+  //
+  /////////////////////////////////////////////
+  Int_t versiongain, subversiongain, versionvdrift, subversionvdrift;
+
+  /////////////////////////
+  // The TRD calib Task
+  /////////////////////////
+  AliTRDCalibTask *calibTask = new AliTRDCalibTask();
+
+  // Disabling TRD CPAss0 as per https://savannah.cern.ch/bugs/?88813
+  //calibTask->SetMaxEvent(-1);
+  
+  calibTask->SetMaxNbTracks(1600);
+  calibTask->SetHisto2d(kTRUE);
+  calibTask->SetVector2d(kFALSE);
+  calibTask->SetVdriftLinear(kTRUE);
+  calibTask->SetExbAlt(kFALSE);
+  calibTask->SetNz(0,0);
+  calibTask->SetNrphi(0,0);
+  calibTask->SetNz(0,1);
+  calibTask->SetNrphi(0,1);
+  calibTask->SetNz(0,2);
+  calibTask->SetNrphi(0,2);
+  calibTask->SetLow(0);
+  calibTask->SetHigh(30);
+  calibTask->SetFillZero(kFALSE);
+  // now
+  calibTask->AddSelectedTriggerClass("C0OB0-ABCE-NOPF-ALL");
+  calibTask->AddSelectedTriggerClass("CTRDCO2-ABCE-NOPF-CENT");
+  calibTask->AddSelectedTriggerClass("CTRDCO2-ABCE-NOPF-TRD");
+  calibTask->AddSelectedTriggerClass("CTRDCO2-ABCE-NOPF-ALL");
+  calibTask->SetReject(kTRUE);
+  // before
+  //calibTask->AddSelectedTriggerClass("CINT1B-ABCE-NOPF-ALL");
+  //calibTask->AddSelectedTriggerClass("CINT1WU-B-NOPF-ALL");
+  //calibTask->AddSelectedTriggerClass("CINT7WU-B-NOPF-ALL");
+  //calibTask->AddSelectedTriggerClass("CINT7WU-I-NOPF-ALL");
+  //calibTask->SetReject(kFALSE);
+  //calibTask->SetDebug(2);
+  calibTask->SetNbTimeBins(nbOfTimeBins);
+  //calibTask->SetMaxEvent(10);
+  //calibTask->SetThresholdP(1.0);
+  calibTask->SetRequirePrimaryVertex(kTRUE);
+  calibTask->SetMinNbOfContributors(1);
+  calibTask->SetMaxCluster(100.0);
+  calibTask->SetNbMaxCluster(2);
+  //calibTask->SetLimitChargeIntegration(kTRUE);
+
+
+  /////////////////////////////
+  // Track cuts
+  /////////////////////////////
+  AliESDtrackCuts *trackCuts = new AliESDtrackCuts("trackcuts","trackcuts");
+  trackCuts->SetMinNClustersTPC(50);
+  trackCuts->SetMaxChi2PerClusterTPC(3.5);
+  //trackCuts->SetMaxCovDiagonalElements(2,2,0.5,0.5,2);
+  trackCuts->SetRequireTPCRefit(kTRUE);
+  //trackCuts->SetRequireITSRefit(kTRUE);
+  //trackCuts->SetMinNsigmaToVertex(10);
+  trackCuts->SetRequireSigmaToVertex(kFALSE);
+  trackCuts->SetAcceptKinkDaughters(kFALSE);
+  trackCuts->SetMaxDCAToVertexZ(30.0);
+  trackCuts->SetMaxDCAToVertexXY(3.0);
+  trackCuts->SetDCAToVertex2D(kFALSE);
+
+  calibTask->SetESDtrackCuts(trackCuts);
+
+  mgr->AddTask(calibTask);
+
+  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
+  //AliAnalysisDataContainer *cinput = mgr->GetCommonOutputContainer();
+
+  if (!cinput) cinput = mgr->CreateContainer("cchain",TChain::Class(),
+                                      AliAnalysisManager::kInputContainer);
+
+  AliAnalysisDataContainer *coutput =mgr->CreateContainer("TRDCalib",TList::Class(), AliAnalysisManager::kOutputContainer, "AliESDfriends_v1.root");
+
+
+  mgr->ConnectInput(calibTask,0,cinput);
+  mgr->ConnectOutput(calibTask,1,coutput);
+  return calibTask;
+
+}
diff --git a/PWGPP/CalibMacros/CPass0/ConfigCalibTrain.C b/PWGPP/CalibMacros/CPass0/ConfigCalibTrain.C
new file mode 100644 (file)
index 0000000..fd57b11
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+
+ Macro to initialize: 
+ - the OCDB (run number required as input argument)
+ - the geometry (expected to be in the current directory)
+ to run the Calibration train.
+ Example:
+ .L $ALICE_ROOT/ANALYSIS/CalibMacros/MergeCalibration/ConfigCalibTrain.C
+ ConfigCalibTrain(129160,"raw://");
+
+*/
+
+void ConfigCalibTrain(Int_t run, const char *ocdb="raw://"){
+
+  // OCDB
+  printf("setting run to %d\n",run);
+  AliCDBManager::Instance()->SetDefaultStorage(ocdb);
+  AliCDBManager::Instance()->SetRun(run); 
+  if (gSystem->AccessPathName("OCDB.root", kFileExists)==0) {  
+    AliCDBManager::Instance()->InitFromSnapshot("OCDB.root");
+  }
+  // magnetic field
+  if ( !TGeoGlobalMagField::Instance()->GetField() ) {
+    printf("Loading field map...\n");
+    AliGRPManager grpMan;
+    if( !grpMan.ReadGRPEntry() ) { 
+      printf("Cannot get GRP entry\n"); 
+    }
+    if( !grpMan.SetMagField() ) { 
+      printf("Problem with magnetic field setup\n"); 
+    }
+  }
+
+  // geometry
+  printf("Loading geometry...\n");
+  AliGeomManager::LoadGeometry();
+  if( !AliGeomManager::ApplyAlignObjsFromCDB("GRP ITS TPC") ) {
+    printf("Problem with align objects\n"); 
+  }
+
+}
diff --git a/PWGPP/CalibMacros/CPass0/LoadLibraries.C b/PWGPP/CalibMacros/CPass0/LoadLibraries.C
new file mode 100644 (file)
index 0000000..e2892c3
--- /dev/null
@@ -0,0 +1,25 @@
+void LoadLibraries() {
+    //
+    // load libraries needed for Pass0
+    //
+    gSystem->Load("libSTAT");
+    gSystem->Load("libANALYSIS");
+    gSystem->Load("libANALYSISalice");
+    gSystem->Load("libANALYSIScalib");
+    //
+    // detector libraries
+    //    
+    gSystem->Load("libTPCcalib");
+    gSystem->Load("libTRDcalib");
+    gSystem->Load("libT0calib");
+    gSystem->Load("libTOFcalib");
+    //
+    // PWGPP libraries
+    //    
+    gSystem->Load("libANALYSISalice.so");
+    gSystem->Load("libANALYSIScalib.so");
+    gSystem->Load("libTENDER.so");
+    gSystem->Load("libPWGPP.so");
+    //gSystem->Load("libPWG4PartCorrBase.so");
+    //gSystem->Load("libHMPIDbase.so");
+}
diff --git a/PWGPP/CalibMacros/CPass0/MeanVertexCalibPass0.C b/PWGPP/CalibMacros/CPass0/MeanVertexCalibPass0.C
new file mode 100644 (file)
index 0000000..36a8f7d
--- /dev/null
@@ -0,0 +1,19 @@
+//___________________________________________________________________________
+
+LoadLibraries()
+{
+  gSystem->Load("libANALYSIS");
+  gSystem->Load("libANALYSISalice");
+  
+}
+
+//___________________________________________________________________________
+
+MakeOCDB(const Char_t *filename = "AliESDfriends_v1.root", const Char_t *dbString = "raw://", Int_t runNB)
+{
+  LoadLibraries();
+  AliMeanVertexPreprocessorOffline meanVertexCalib;
+  meanVertexCalib.ProcessOutput(filename, dbString, runNB);
+}
+
+
diff --git a/PWGPP/CalibMacros/CPass0/Pass0.jdl b/PWGPP/CalibMacros/CPass0/Pass0.jdl
new file mode 100644 (file)
index 0000000..9ab0098
--- /dev/null
@@ -0,0 +1,41 @@
+Executable="/alice/cern.ch/user/j/jotwinow/bin/runPass0.sh";
+
+Packages= { "VO_ALICE@AliRoot::v5-02-Rev-04",
+           "VO_ALICE@ROOT::v5-30-06-1",        
+            "VO_ALICE@APISCONFIG::V1.1x"
+};
+
+Jobtag = { "Test Pass0 Calibration Train" };
+
+GUIDFILE="guid.txt";
+TTL = "28000";
+Price = 1;
+
+Validationcommand ="/alice/cern.ch/user/j/jotwinow/Pass0/CalibMacros/validation.sh";
+
+Split="file";
+
+JDLVariables={"Packages", "OutputDir"};
+GUIDFILE="guid.txt";
+
+
+SplitArguments = {"/alice/data/2010/LHC10d/$1/raw/#alienfilename#"};
+Workdirectorysize={"6000MB"};
+
+InputFile={"LF:/alice/cern.ch/user/j/jotwinow/Pass0/CalibMacros/recPass0.C",
+           "LF:/alice/cern.ch/user/j/jotwinow/Pass0/CalibMacros/ConfigCalibTrain.C",
+           "LF:/alice/cern.ch/user/j/jotwinow/Pass0/CalibMacros/runCalibTrain.C",
+           "LF:/alice/cern.ch/user/j/jotwinow/Pass0/CalibMacros/AddTaskTPCCalib.C",
+           "LF:/alice/cern.ch/user/j/jotwinow/Pass0/CalibMacros/AddTaskTRDCalib.C",
+           "LF:/alice/cern.ch/user/j/jotwinow/Pass0/CalibMacros/AddTaskT0Calib.C",
+           "LF:/alice/cern.ch/user/j/jotwinow/Pass0/CalibMacros/AddTOFAnalysisTaskCalibPass0.C",
+           "LF:/alice/cern.ch/user/j/jotwinow/Pass0/CalibMacros/LoadLibraries.C"
+};
+
+InputDataCollection="LF:/alice/data/2010/LHC10d/$1/collection,nodownload";
+
+OutputDir="/alice/cern.ch/user/j/jotwinow/Pass0/output/$1/#alienfilename/.root//#";
+
+OutputArchive={"log_archive:*.log@disk=1",
+              "root_archive.zip:AliESDfriends_v1.root,@disk=1"};
+
diff --git a/PWGPP/CalibMacros/CPass0/README b/PWGPP/CalibMacros/CPass0/README
new file mode 100644 (file)
index 0000000..59c5e87
--- /dev/null
@@ -0,0 +1,78 @@
+Calibraion mactos directory - OCDB updates for TPC, TRD, TOF and T0 and vertex calculation
+
+History:
+
+26/07/2011 - directory created according to http://savannah.cern.ch/bugs/?84135
+           - first run post-creation is from LHC11d, after 157272
+           - AliRoot version v4-20-Rev-35  
+
+29/07/2011 - modified validationMerging.sh to catch "E-AliCDBGrid::PutEntry" and invalidate the merging job.   
+
+09/08/2011 - modified AddTaskTRDCalib.C according to https://savannah.cern.ch/bugs/?85312. Modification valid for all runs > 158780 (LHC11d)  
+
+24/08/2011 - modified AddTaskTRDCalib.C according to https://savannah.cern.ch/bugs/?85791. Modification valid for all runs > 159606 (LHC11d)
+
+13/09/2011 - modified makeOCDB.C - adding Menvertex calculation https://savannah.cern.ch/task/?22379. Valid for LHC11d Pass1 and LHC11e onward. 
+
+14/09/2011 - new AddTaskT0Calib.C as per https://savannah.cern.ch/task/?22276
+
+14/09/2011 - modified makeOCDB.C as per https://savannah.cern.ch/bugs/?86736
+
+15/09/2011 - modified makeOCDB.C as per https://savannah.cern.ch/task/?22379#comment57
+
+16/09/2011 - new AddTaskTRDCalib.C as per http://savannah.cern.ch/bugs/?86830
+
+25/10/2011 - new AddTOFAnalysisTaskCalibPass0.C as per https://savannah.cern.ch/bugs/?87953
+
+25/10/2011 - new AddTaskT0Calib.C as per http://savannah.cern.ch/bugs/?87877 and again after a quickie debugging session
+
+02/11/2011 - update from current production code (from AliEn) + adding SDD calibration task
+
+10/11/2011 - Update of makeOCDB.C as per https://savannah.cern.ch/task/?23987#comment10
+
+11/11/2011 - updated AddTOFAnalysisTaskCalibPass0.C as requested in https://savannah.cern.ch/task/?23987#comment23
+
+12/11/2011 - updated AddTaskTPCCalib.C as requested in http://savannah.cern.ch/bugs/?88792 (active after run 167713)
+
+13/11/2011 - updated AddTaskTPCCalib.C as requested in https://savannah.cern.ch/bugs/?88812 (active after run 167713)
+
+13/11/2011 - Disable TRD CPass0, see https://savannah.cern.ch/bugs/?88813 (disable active after run 167713 to run 167988)
+
+15/11/2011 - Modified merge.C as per https://savannah.cern.ch/task/?23160#comment86
+
+16/11/2011 - Modified merge.C as per https://savannah.cern.ch/task/?23160#comment94
+
+17/11/2011 - Update makeOCDB.C and AddTaskTRDCalib.C as per https://savannah.cern.ch/bugs/?88813#comment21. Active from run 168068.
+
+18/11/2011 - updated mergeMakeOCDB.sh and merge.C as per https://savannah.cern.ch/task/?23987#comment42. Acrive for runs >= 168066
+
+18/11/2011 - reverted changes to mergeMakeOCDB.sh (from previous comment) and updated merge.C as per https://savannah.cern.ch/task/index.php?23987#comment43 No runs were processed with the macros from https://savannah.cern.ch/task/?23987#comment42
+
+18/11/2011 - modified merge.C as per https://savannah.cern.ch/task/?23987#comment52
+
+19/11/2011 - modified merge.C as per https://savannah.cern.ch/task/?23987#comment57
+
+19/11/2011 - Reverting to AliRoot v5-01-Rev-12 and disabling the TRD task - line 'calibTask->SetMaxEvent(-1); ' in AddTaskTRDcalib.C
+
+19/11/2011 - reducing the nubmer of input files im merge.C as per https://savannah.cern.ch/task/?23987#comment64
+
+20/11/2011 - In macro makeOCDB.C commented out SetAlternativeDriftVelocityFit(kTRUE) as per https://savannah.cern.ch/bugs/index.php?88813#comment30 (related to the revert to Rev-12)
+
+22/11/2011 - Reverting back to Rev-13:
+
+a) makeOCDB.C un-commented out SetAlternativeDriftVelocityFit(kTRUE) - TRD
+b) AddTaskTRDcalib.C - commented out calibTask->SetMaxEvent(-1) - TRD
+c) AddTaskTRDcalib.C - modified 
+
+22/11/2011 - Modified AddTaskTRDCalib.C as per https://savannah.cern.ch/bugs/?88813#comment33 
+
+23/11/2011 - Modified recPass0.C MB trigger selection CPBI2WU_B1-B-NOPF-ALL to CPBI2_B1-B-NOPF-ALLNOTRD as per https://savannah.cern.ch/task/index.php?23987#comment122  
+
+
+14/12/2011 - recPass0.C - Added removal of recpoints for TPC/ITS/TRD to avoid filling up of the local disk
+
+14/12/2011 - recPass0.C, ConfigCalibTrain.C - Added OCDB snapshot for CPass0 reco and calibration train
+
+14/12/2011 - recPass0.C - switch off V0 finder, as per https://savannah.cern.ch/task/?23987#comment163
+
+15/12/2011 - sync trunk with code used for PbPb production 2011
\ No newline at end of file
diff --git a/PWGPP/CalibMacros/CPass0/README.OCDB b/PWGPP/CalibMacros/CPass0/README.OCDB
new file mode 100644 (file)
index 0000000..f00b216
--- /dev/null
@@ -0,0 +1,9 @@
+Calibration entries to be modified in Pass0
+
+TPC        - TPC/Calib/TimeDrift, TPC/Calib/TimeGain
+TOF        - TOF/Calib/RunParams
+T0         - T0/Calib/TimeDelay , T0/Calib/TimeAdjust
+TRD        - ???
+MeanVertex - not active
+
\ No newline at end of file
diff --git a/PWGPP/CalibMacros/CPass0/makeOCDB.C b/PWGPP/CalibMacros/CPass0/makeOCDB.C
new file mode 100644 (file)
index 0000000..5fad7bb
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+  macro to extract the OCDB entries
+
+  input: CalibObjects.root
+  ouput: TimeGain and TimeVdrift calibration objects for TPC and TRD
+
+  Example:
+  .L $ALICE_ROOT/PWGPP/CalibMacros/Pass0/makeOCDB.C
+  makeOCDB("105160");
+
+*/
+
+void makeOCDB(TString runNumberString, TString  ocdbStorage="")
+{
+  //
+  // extract TPC OCDB entries
+  //
+  gROOT->Macro("LoadLibraries.C");
+  gROOT->LoadMacro("ConfigCalibTrain.C");
+
+  // switch off log info
+  AliLog::SetClassDebugLevel("AliESDEvent",0);
+
+  // config GRP
+  Int_t runNumber = runNumberString.Atoi();
+  printf("runNumber from runCalibTrain = %d\n",runNumber);
+  ConfigCalibTrain(runNumber, "raw://");
+
+  // Steering Tasks - set output storage
+  // DefaultStorage set already before - in ConfigCalibTrain.C
+//ocdbStorage+="?se=ALICE::CERN::SE";
+
+  AliCDBManager::Instance()->SetSpecificStorage("*/*/*",ocdbStorage.Data());
+
+  // set OCDB storage
+  if (ocdbStorage.Length()==0) ocdbStorage+="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
+
+  // TPC part
+  TFile fcalib("CalibObjects.root");
+  AliTPCPreprocessorOffline proces;
+
+  // switch on parameter validation
+  proces.SetTimeGainRange(0.5,3.0);
+  proces.SwitchOnValidation();
+
+  // Make timegain calibration
+  //proces.CalibTimeGain("CalibObjects.root", runNumber,AliCDBRunRange::Infinity(),ocdbStorage);
+  proces.CalibTimeGain("CalibObjects.root", runNumber,runNumber,ocdbStorage);
+
+  // Make vdrift calibration
+  //proces.CalibTimeVdrift("CalibObjects.root",runNumber,AliCDBRunRange::Infinity(),ocdbStorage);
+  proces.CalibTimeVdrift("CalibObjects.root",runNumber,runNumber,ocdbStorage);
+  //
+  // TOF part
+  //
+  AliTOFAnalysisTaskCalibPass0 calibTask;
+  Printf("Calibrating TOF");
+  calibTask.ProcessOutput("CalibObjects.root", ocdbStorage);
+//
+//
+
+// T0 part
+  AliT0PreprocessorOffline procesT0;
+  // Make  calibration of channels offset
+   procesT0.Process("CalibObjects.root",runNumber, runNumber, ocdbStorage);
+
+
+
+   //TRD part
+   AliTRDPreprocessorOffline procestrd;
+   procestrd.SetLinearFitForVdrift(kTRUE);
+   procestrd.SetMinStatsVdriftT0PH(600*10);
+   procestrd.SetMinStatsVdriftLinear(50);
+   procestrd.SetMinStatsGain(600);
+   procestrd.SetLimitValidateNoData(40);
+   procestrd.SetLimitValidateBadCalib(40);
+   procestrd.SetAlternativeDriftVelocityFit(kTRUE);
+   procestrd.Init("CalibObjects.root");
+   Int_t versionVdriftUsed = procestrd.GetVersionVdriftUsed();
+   Int_t subversionVdriftUsed = procestrd.GetSubVersionVdriftUsed();
+   Int_t versionGainUsed = procestrd.GetVersionGainUsed();
+   Int_t subversionGainUsed = procestrd.GetSubVersionGainUsed();
+   Int_t versionExBUsed = procestrd.GetVersionExBUsed();
+   Int_t subversionExBUsed = procestrd.GetSubVersionExBUsed();
+   printf("version and subversion vdrift %d and %d\n",versionVdriftUsed,subversionVdriftUsed);
+   printf("version and subversion gain %d and %d\n",versionGainUsed,subversionGainUsed);
+   printf("version and subversion exb %d and %d\n",versionExBUsed,subversionExBUsed);
+   procestrd.Process("CalibObjects.root",runNumber,runNumber,ocdbStorage);
+   Int_t trdstatus = procestrd.GetStatus();
+  
+  
+  //Mean Vertex
+  AliMeanVertexPreprocessorOffline procesMeanVtx;
+  procesMeanVtx.ProcessOutput("CalibObjects.root", ocdbStorage, runNumber);
+       
+  return;
+}
diff --git a/PWGPP/CalibMacros/CPass0/makeOCDB.byComponent.C b/PWGPP/CalibMacros/CPass0/makeOCDB.byComponent.C
new file mode 100644 (file)
index 0000000..e9a14ce
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+  macro to extract the OCDB entries
+
+  input: CalibObjects.root
+  ouput: TimeGain and TimeVdrift calibration objects for TPC and TRD
+
+  Example:
+  .L $ALICE_ROOT/PWGPP/CalibMacros/Pass0/makeOCDB.C
+  makeOCDB("105160");
+
+*/
+
+//__________________________________________________________________
+
+void makeOCDB(TString runNumberString, TString ocdbStorage = "")
+{
+  makeOCDB("CalibObjects.root", "ALL", runNumberString, ocdbStorage);
+}
+
+//___________________________________________________________________
+
+void makeOCDB(const Char_t *filename, TString component, TString runNumberString, TString ocdbStorage = "")
+{
+  //
+  // extract TPC OCDB entries
+  //
+  gROOT->Macro("LoadLibraries.C");
+  gROOT->LoadMacro("ConfigCalibTrain.C");
+
+  // switch off log info
+  AliLog::SetClassDebugLevel("AliESDEvent",0);
+
+  // config GRP
+  Int_t runNumber = runNumberString.Atoi();
+  printf("runNumber from runCalibTrain = %d\n",runNumber);
+
+  /* configCalibTrain only if needed */
+  if (component == "TPC" || component == "TRD" || component == "ALL")
+    ConfigCalibTrain(runNumber, "raw://");
+  else
+    AliCDBManager::Instance()->SetDefaultStorage("raw://");
+  
+  // Steering Tasks - set output storage
+  // DefaultStorage set already before - in ConfigCalibTrain.C
+//ocdbStorage+="?se=ALICE::CERN::SE";
+
+  AliCDBManager::Instance()->SetSpecificStorage("*/*/*",ocdbStorage.Data());
+
+  // set OCDB storage
+  if (ocdbStorage.Length()==0) ocdbStorage+="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
+
+  
+  /* makeOCDB for selected component */
+  if (component == "TPC" || component == "ALL")
+    makeOCDB_TPC(filename, runNumber, ocdbStorage);
+  if (component == "TOF" || component == "ALL")
+    makeOCDB_TOF(filename, runNumber, ocdbStorage);
+  if (component == "T0" || component == "ALL")
+    makeOCDB_T0(filename, runNumber, ocdbStorage);
+  if (component == "TRD" || component == "ALL")
+    makeOCDB_TRD(filename, runNumber, ocdbStorage);
+  if (component == "MeanVertex" || component == "ALL")
+    makeOCDB_MeanVertex(filename, runNumber, ocdbStorage);
+  
+  gSystem->Exec(Form("touch %s_ocdb_done", component.Data()));
+  return;
+}
+
+//___________________________________________________________________
+
+void makeOCDB_TPC(const Char_t *filename, Int_t runNumber, TString ocdbStorage)
+{
+
+  // TPC part
+  TFile fcalib(filename);
+  AliTPCPreprocessorOffline proces;
+
+  // switch on parameter validation
+  proces.SetTimeGainRange(0.5,3.0);
+  proces.SwitchOnValidation();
+
+  // Make timegain calibration
+  //proces.CalibTimeGain(filename, runNumber,AliCDBRunRange::Infinity(),ocdbStorage);
+  proces.CalibTimeGain(filename, runNumber,runNumber,ocdbStorage);
+
+  // Make vdrift calibration
+  //proces.CalibTimeVdrift(filename,runNumber,AliCDBRunRange::Infinity(),ocdbStorage);
+  proces.CalibTimeVdrift(filename,runNumber,runNumber,ocdbStorage);
+
+}
+
+//___________________________________________________________________
+
+void makeOCDB_TOF(const Char_t *filename, Int_t runNumber, TString ocdbStorage)
+{
+  AliTOFAnalysisTaskCalibPass0 calibTask;
+  Printf("Calibrating TOF");
+  calibTask.ProcessOutput(filename, ocdbStorage);
+}
+
+//___________________________________________________________________
+
+void makeOCDB_T0(const Char_t *filename, Int_t runNumber, TString ocdbStorage)
+{
+  // T0 part
+  AliT0PreprocessorOffline procesT0;
+  // Make  calibration of channels offset
+  procesT0.Process(filename,runNumber, runNumber, ocdbStorage);
+}
+
+//___________________________________________________________________
+
+void makeOCDB_TRD(const Char_t *filename, Int_t runNumber, TString ocdbStorage)
+{
+   //TRD part
+   AliTRDPreprocessorOffline procestrd;
+   procestrd.SetLinearFitForVdrift(kTRUE);
+   procestrd.SetMinStatsVdriftT0PH(600*10);
+   procestrd.SetMinStatsVdriftLinear(50);
+   procestrd.SetMinStatsGain(600);
+   procestrd.Init(filename);
+   Int_t versionVdriftUsed = procestrd.GetVersionVdriftUsed();
+   Int_t subversionVdriftUsed = procestrd.GetSubVersionVdriftUsed();
+   Int_t versionGainUsed = procestrd.GetVersionGainUsed();
+   Int_t subversionGainUsed = procestrd.GetSubVersionGainUsed();
+   Int_t versionExBUsed = procestrd.GetVersionExBUsed();
+   Int_t subversionExBUsed = procestrd.GetSubVersionExBUsed();
+   printf("version and subversion vdrift %d and %d\n",versionVdriftUsed,subversionVdriftUsed);
+   printf("version and subversion gain %d and %d\n",versionGainUsed,subversionGainUsed);
+   printf("version and subversion exb %d and %d\n",versionExBUsed,subversionExBUsed);
+   procestrd.Process(filename,runNumber,runNumber,ocdbStorage);
+   Int_t trdstatus = procestrd.GetStatus();
+
+}
+
+//___________________________________________________________________
+
+void makeOCDB_MeanVertex(const Char_t *filename, Int_t runNumber, TString ocdbStorage)
+{
+  //Mean Vertex
+  AliMeanVertexPreprocessorOffline procesMeanVtx;
+  procesMeanVtx.ProcessOutput(filename, ocdbStorage, runNumber);
+}
+
+//___________________________________________________________________
+
diff --git a/PWGPP/CalibMacros/CPass0/merge.C b/PWGPP/CalibMacros/CPass0/merge.C
new file mode 100644 (file)
index 0000000..856aa0b
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+  merge output calib objects on Alien
+  using AliFileMerger functionality
+
+  Directory with runCalibTrain output: outputDir
+  pattern: AliESDfriends_v1.root
+  Output file name: CalibObjects.root
+
+  Example:
+  .L $ALICE_ROOT/ANALYSIS/CalibMacros/MergeCalibration/merge.C
+  merge("alien:///alice/cern.ch/user/j/jotwinow/CalibTrain/output","AliESDfriends_v1.root");
+*/
+void mergeInChunksTXT(const char* mlist, const char* dest, int maxFiles=700);
+
+
+void merge(const char* outputDir, const char* pattern, Bool_t copyLocal=kFALSE)
+{
+  //
+  // load libraries
+  //
+  printf("Merging with chunks copying turned %s\n",copyLocal ? "ON":"OFF");
+  gROOT->Macro("LoadLibraries.C");
+  //
+  cpTimeOut(outputDir, pattern,10, copyLocal);
+  //
+  // local
+  mergeInChunksTXT("calib.list","CalibObjects.root");
+  //  AliFileMerger merger;
+  //  merger.AddReject("esdFriend"); // do not merge
+  //  merger.SetMaxFilesOpen(700);
+  //  merger.IterTXT("calib.list","CalibObjects.root",kFALSE);
+
+  // alien
+  //merger.IterAlien(outputDir, "CalibObjects.root", pattern);
+
+  return;
+}
+
+void cpTimeOut(const char * searchdir, const char* pattern, Int_t timeOut=10, Bool_t copyLocal)
+{
+
+  gSystem->Setenv("XRDCLIENTMAXWAIT",Form("%d",timeOut));
+  gEnv->SetValue("XNet.RequestTimeout", timeOut);
+  gEnv->SetValue("XNet.ConnectTimeout", timeOut);
+  gEnv->SetValue("XNet.TransactionTimeout", timeOut);
+  TFile::SetOpenTimeout(timeOut);
+
+  TGrid::Connect("alien");
+
+  TString filelist;
+  TString command;
+  command = Form("find %s/ %s", searchdir, pattern);
+  cerr<<"command: "<<command<<endl;
+  TGridResult *res = gGrid->Command(command);
+  if (!res) return;
+  res->Print();
+  TIter nextmap(res);
+  TMap *map = 0;
+
+  ofstream outputFile;
+  outputFile.open(Form("calib.list"));
+  Int_t counter=0;
+
+  while((map=(TMap*)nextmap())) 
+  {
+    TObjString *objs = dynamic_cast<TObjString*>(map->GetValue("turl"));
+    if (!objs || !objs->GetString().Length())
+    {
+      delete res;
+      break;
+    }
+
+    TString src=Form("%s",objs->GetString().Data());
+    TString dst=src;
+    Bool_t result = kTRUE;
+    if (copyLocal) {
+      dst.ReplaceAll("alien:///","");
+      dst.ReplaceAll("/","_");
+      TTimeStamp s1;
+      result = TFile::Cp(src.Data(),dst.Data(),kTRUE);
+      TTimeStamp s2;
+      AliSysInfo::AddStamp(dst.Data(),counter, result);
+    }
+    if (result) {
+      counter++;
+      outputFile << dst.Data()<< endl;
+    }
+  }
+  if (copyLocal) cout<<counter<<" files copied!"<<endl;
+  else           cout<<counter<<" files registerd!"<<endl;
+  outputFile.close();
+  gSystem->Exec("mv syswatch.log syswatch_copy.log");
+  return;
+}
+
+void mergeInChunksTXT(const char* mlist, const char* dest, int maxFiles)
+{
+  TH1::AddDirectory(0);
+  AliFileMerger merger;
+  //  merger.SetMaxFilesOpen(999);
+  merger.AddReject("esdFriend"); // do not merge
+  //
+  if (maxFiles<2) maxFiles = 2;
+  TString filesToMerge = mlist, fileDest = dest;
+  if (filesToMerge.IsNull()) {printf("List to merge is not provided\n"); return;}
+  if (fileDest.IsNull())     {printf("Merging destination is not provided\n"); return;}
+  const char* tmpMerge[3]={"__merge_part0.root","__merge_part1.root","__part_of_calib.list"};
+  //
+  gSystem->ExpandPathName(filesToMerge);
+  ofstream outfile;
+  ifstream infile(filesToMerge.Data());
+  if (!infile) {printf("No %s file\n",filesToMerge.Data()); return;}
+  //
+  int currTmp = 0, nfiles = 0, nparts = 0; // counter for number of merging operations
+  string line;
+  TString lineS;
+  while ( !infile.eof() ) {
+    getline(infile, line); 
+    lineS = line;
+    if (lineS.IsNull() || lineS.BeginsWith("#")) continue;
+    int st = nfiles%maxFiles;
+    if (st==0) { // new chunk should be started
+      if (nfiles) { // merge prev. chunk
+       outfile.close();
+       merger.IterTXT(tmpMerge[2], tmpMerge[currTmp] ,kFALSE);
+       printf("Merging to %s | %d files at step %d\n",tmpMerge[currTmp], nfiles,nparts);
+      }
+      outfile.open(tmpMerge[2], ios::out); // start list for new chunk  
+      if (nparts++) {
+       printf("Adding previous result %s | %d files %d at part\n",tmpMerge[currTmp], nfiles,nparts);
+       outfile << tmpMerge[currTmp] << endl; // result of previous merge goes 1st
+      }
+      currTmp = (currTmp==0) ? 1:0;         // swap tmp files
+    }
+    outfile << line << endl;
+    nfiles++;
+  }
+  // merge the rest
+  merger.IterTXT(tmpMerge[2], dest ,kFALSE);
+  outfile.close();
+  infile.close();
+  for (int i=0;i<3;i++) gSystem->Exec(Form("if [ -e %s ]; then \nrm %s\nfi",tmpMerge[i],tmpMerge[i]));
+  printf("Merged %d files in %d steps\n",nfiles, nparts);
+  //
+}
+
diff --git a/PWGPP/CalibMacros/CPass0/merge.byComponent.C b/PWGPP/CalibMacros/CPass0/merge.byComponent.C
new file mode 100644 (file)
index 0000000..21fdb13
--- /dev/null
@@ -0,0 +1,93 @@
+//___________________________________________________________________
+
+void merge(TString component, const Char_t *inputstring)
+{
+
+  /* load libs */
+  gROOT->Macro("LoadLibraries.C");
+  TH1::AddDirectory(0);
+
+  /* copy only */
+  if (component == "COPY") {
+    CopyCPass(inputstring, "AliESDfriends_v1.root");
+    return;
+  }
+  
+  /* merge component */
+  MergeCPass(inputstring, component);
+  
+}
+
+//___________________________________________________________________
+
+void MergeCPass(const Char_t *list, TString component)
+{
+  AliFileMerger merger;
+  /* select what to merge */
+  if (component == "ALL")
+    merger.AddReject("esdFriend");
+  else
+    merger.AddAccept(component.Data());
+  /* merge */
+  merger.IterTXT(list, "CalibObjects.root", kFALSE);
+  /* notify */
+  gSystem->Exec(Form("touch %s_merge_done", component.Data()));
+  return;
+}
+
+//___________________________________________________________________
+
+void CopyCPass(const char *searchdir, const char *pattern, Int_t timeOut=10)
+{
+
+  gSystem->Setenv("XRDCLIENTMAXWAIT",Form("%d",timeOut));
+  gEnv->SetValue("XNet.RequestTimeout", timeOut);
+  gEnv->SetValue("XNet.ConnectTimeout", timeOut);
+  gEnv->SetValue("XNet.TransactionTimeout", timeOut);
+  TFile::SetOpenTimeout(timeOut);
+
+  TGrid::Connect("alien");
+
+  TString filelist;
+  TString command;
+  command = Form("find %s/ %s", searchdir, pattern);
+  cerr<<"command: "<<command<<endl;
+  TGridResult *res = gGrid->Command(command);
+  if (!res) return;
+  TIter nextmap(res);
+  TMap *map = 0;
+
+  ofstream outputFile;
+  outputFile.open(Form("calib.list"));
+  Int_t counter=0;
+
+  while((map=(TMap*)nextmap()))
+  {
+    TObjString *objs = dynamic_cast<TObjString*>(map->GetValue("turl"));
+    if (!objs || !objs->GetString().Length())
+    {
+      delete res;
+      break;
+    }
+
+    TString src=Form("%s",objs->GetString().Data());
+    TString dst=src;
+    dst.ReplaceAll("alien:///","");
+    dst.ReplaceAll("/","_");
+    TTimeStamp s1;
+    Bool_t result = TFile::Cp(src.Data(),dst.Data(),kTRUE);
+    TTimeStamp s2;
+    AliSysInfo::AddStamp(dst.Data(),counter, result);
+    if (result)
+    {
+      counter++;
+      outputFile << dst.Data()<< endl;
+    }
+  }
+  cout<<counter<<" files copied!"<<endl;
+
+  outputFile.close();
+  gSystem->Exec("touch copy_done");
+  return;
+}
+
diff --git a/PWGPP/CalibMacros/CPass0/mergeMakeOCDB.byComponent.sh b/PWGPP/CalibMacros/CPass0/mergeMakeOCDB.byComponent.sh
new file mode 100755 (executable)
index 0000000..7f80f73
--- /dev/null
@@ -0,0 +1,56 @@
+#! /bin/bash
+
+# init
+path=$1
+run=$2
+ocdb=$3
+echo "***********************" 2>&1 | tee -a merge.log
+echo mergeMakeOCDB.sh started 2>&1 | tee -a merge.log
+echo path = $path 2>&1 | tee -a merge.log
+echo run  = $run 2>&1 | tee -a merge.log
+echo ocdb = $ocdb 2>&1 | tee -a merge.log
+echo "***********************" 2>&1 | tee -a merge.log
+
+# setup components
+components="TOF MeanVertex T0 TRD TPC SDD"
+
+# copy
+echo "***********************" 2>&1 | tee -a merge.log
+echo copying files for run $run 2>&1 | tee -a merge.log
+echo from $path 2>&1 | tee -a merge.log
+echo "***********************" 2>&1 | tee -a merge.log
+aliroot -b -q "merge.C(\"COPY\", \"$path\")" 2>&1 | tee -a merge.log
+mv syswatch.log copy_syswatch.log
+
+# process by component
+for det in $components; do
+
+    # merge
+    echo "***********************" 2>&1 | tee -a merge.log
+    echo merging $det data 2>&1 | tee -a merge.log
+    echo "***********************" 2>&1 | tee -a merge.log
+    aliroot -b -q "merge.C(\"$det\", \"calib.list\")" 2>&1 | tee -a merge.log
+    mv syswatch.log $det\_merge_syswatch.log
+
+    # make OCDB
+    echo "***********************" 2>&1 | tee -a ocdb.log
+    echo making $det OCDB 2>&1 | tee -a ocdb.log
+    echo "***********************" 2>&1 | tee -a ocdb.log
+    aliroot -b -q "makeOCDB.C(\"CalibObjects.root\", \"$det\", \"$run\", \"$ocdb\")" 2>&1 | tee -a ocdb.log
+    mv CalibObjects.root $det\_CalibObjects.root
+
+done
+
+# global merge
+echo "***********************" 2>&1 | tee -a merge.log
+echo merging ALL data 2>&1 | tee -a merge.log
+echo "***********************" 2>&1 | tee -a merge.log
+ls *CalibObjects.root > objects.list
+aliroot -b -q "merge.C(\"ALL\", \"objects.list\")" 2>&1 | tee -a merge.log
+touch CalibObjects.root
+
+# summary
+echo "***********************" 2>&1 | tee -a ocdb.log
+echo SUMMARY 2>&1 | tee -a ocdb.log
+echo "***********************" 2>&1 | tee -a ocdb.log
+ls -altr *CalibObjects.root *done 2>&1 | tee -a ocdb.log
\ No newline at end of file
diff --git a/PWGPP/CalibMacros/CPass0/mergeMakeOCDB.jdl b/PWGPP/CalibMacros/CPass0/mergeMakeOCDB.jdl
new file mode 100644 (file)
index 0000000..eab6890
--- /dev/null
@@ -0,0 +1,30 @@
+Executable="/alice/cern.ch/user/j/jotwinow/bin/mergeMakeOCDB.sh";
+
+Packages= { "VO_ALICE@AliRoot::v5-01-Rev-19", "VO_ALICE@ROOT::v5-30-03-1", "VO_ALICE@APISCONFIG::V1.1x" };
+
+Jobtag = { "Merging Calibration Objects from calib train and make OCDB params" };
+
+GUIDFILE="guid.txt";
+TTL = "28000";
+Price = 1;
+
+Validationcommand ="/alice/cern.ch/user/j/jotwinow/Pass0/MergeCalibration/validationMerging.sh";
+
+JDLVariables={"Packages", "OutputDir"};
+GUIDFILE="guid.txt";
+
+Arguments = "$1 $2 $3";
+
+Workdirectorysize={"6000MB"}; 
+
+InputFile={"LF:/alice/cern.ch/user/j/jotwinow/Pass0/MergeCalibration/ConfigCalibTrain.C",
+           "LF:/alice/cern.ch/user/j/jotwinow/Pass0/MergeCalibration/LoadLibraries.C",
+           "LF:/alice/cern.ch/user/j/jotwinow/Pass0/MergeCalibration/makeOCDB.C",
+           "LF:/alice/cern.ch/user/j/jotwinow/Pass0/MergeCalibration/merge.C"
+};
+
+OutputDir="/alice/cern.ch/user/j/jotwinow/Pass0/output/$2/";
+
+OutputArchive={"log_archive:*.log@disk=1",
+              "root_archive.zip:CalibObjects.root,meanITSVertex.root,fitITSVertex.root@disk=1"};
+
diff --git a/PWGPP/CalibMacros/CPass0/mergeMakeOCDB.sh b/PWGPP/CalibMacros/CPass0/mergeMakeOCDB.sh
new file mode 100755 (executable)
index 0000000..e818ae0
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+# Script to merge objects coming out of the calibration train:
+# Arguments:
+#    1 - directory on which to look for the files to be merged 
+#    2 - pattern
+#    3 - OCDB output path
+
+# example:
+# mergeMakeOCDB.sh /alice/cern.ch/user/a/aliprod/Pass0/output/ 000120691 alien://folder=/alice/cern.ch/user/a/aliprod/Pass0/output
+
+#ALIEN setting
+# $1 = directory where to perform the find 
+# $2 = pattern
+# $3 = OCDB path
+
+if [ -f Run0_999999999_v3_s0.root ]; then
+    mkdir -p TPC/Calib/Correction
+    mv Run0_999999999_v3_s0.root TPC/Calib/Correction/
+fi
+
+echo ">>>>>>> Running AliRoot to merge calib objects found in $1 with pattern AliESDfriends_v1.root"
+aliroot -l -b -q merge.C\(\"$1\",\"AliESDfriends_v1.root\"\) 2>&1 | tee merge.log
+mv syswatch.log syswatch_merge.log
+
+echo ">>>>>>> Extract OCDB entries for run = $2, to be stored in $3"
+aliroot -l -b -q makeOCDB.C\(\"$2\",\"$3\"\) 2>&1 | tee ocdb.log
+mv syswatch.log syswatch_makeOCDB.log
diff --git a/PWGPP/CalibMacros/CPass0/recPass0.C b/PWGPP/CalibMacros/CPass0/recPass0.C
new file mode 100644 (file)
index 0000000..2b8bf8e
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+   rec.C to be used for pass0
+   - reconstruction of raw data
+   - QA information switched off
+   - store all friends
+   - default OCDB storage set to "raw://"
+
+   Example:
+   aliroot -b -q 'recPass0.C("raw.root",100)'
+*/
+
+void recPass0(const char *filename="raw.root",Int_t nevents=-1, const char *ocdb="raw://")
+{
+  // Load some system libs for Grid and monitoring
+  // Set the CDB storage location
+  AliCDBManager * man = AliCDBManager::Instance();
+  man->SetDefaultStorage(ocdb);
+  // Reconstruction settings
+  AliReconstruction rec;
+  // Upload CDB entries from the snapshot (local root file) if snapshot exist
+  if (gSystem->AccessPathName("OCDB.root", kFileExists)==0) {        
+    rec.SetFromCDBSnapshot("OCDB.root");
+  }
+  // All friends
+  rec.SetFractionFriends(1.0);
+
+ // AliReconstruction settings - hardwired MB trigger for calibration
+
+  TString newfilename = filename;
+//  newfilename += "?Trigger=CPBI2_B1-B-NOPF-ALLNOTRD";
+  rec.SetInput(newfilename.Data());
+
+  // Set protection against too many events in a chunk (should not happen)
+  if (nevents>0) rec.SetEventRange(0,nevents);
+
+  // Remove recpoints after each event
+  rec.SetDeleteRecPoints("TPC TRD ITS");
+
+  // Switch off the V0 finder - saves time!
+  rec.SetRunMultFinder(kFALSE);
+  rec.SetRunV0Finder(kFALSE); 
+
+  //
+  // QA options - all QA is off
+  //
+  rec.SetRunQA(":");
+  rec.SetRunGlobalQA(kFALSE);
+
+  // AliReconstruction settings
+  rec.SetWriteESDfriend(kTRUE);
+  rec.SetWriteAlignmentData();
+  rec.SetUseTrackingErrorsForAlignment("ITS");
+  rec.SetRunReconstruction("ALL");
+  rec.SetFillESD("ALL");
+  rec.SetCleanESD(kFALSE);
+
+  // Specific reco params for ZDC (why isn't this automatic?)
+//  rec.SetRecoParam("ZDC",AliZDCRecoParamPbPb::GetHighFluxParam(2760));
+
+  //Ignore SetStopOnError
+  rec.SetStopOnError(kFALSE);
+
+  AliLog::Flush();
+  rec.Run();
+}
+
diff --git a/PWGPP/CalibMacros/CPass0/runCalibTrain.C b/PWGPP/CalibMacros/CPass0/runCalibTrain.C
new file mode 100644 (file)
index 0000000..e32f027
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+  Template of calibration/filtering macro using ESD:
+  - requires AliESDs.root and AliESDfriend.root
+  - requires OCDB access (default set to "raw://")
+  - requires run number as argument to init OCDB
+  - calls LoadLibraries.C, ConfigCalibTrain.C and AddTaskTPCCalib.C macros
+  - output AliESDfriends_v1.root with TPC and TRD calibration objects are created
+
+  Example:
+  .L $ALICE_ROOT/ANALYSIS/macros/runCalibTrain.C
+  runCalibTrain("104892");
+*/
+
+void runCalibTrain(TString runNumberString, const char *inFileName = "AliESDs.root", const char *ocdb="raw://")
+{
+  //
+  // macro to run TPC calibration train 
+  //
+  AliLog::SetGlobalLogLevel(AliLog::kError); 
+  gROOT->Macro("LoadLibraries.C");
+  gROOT->LoadMacro("ConfigCalibTrain.C");
+
+  // detector tasks
+  gROOT->LoadMacro("AddTaskTPCCalib.C");
+  gROOT->LoadMacro("AddTaskTRDCalib.C");
+  gROOT->LoadMacro("AddTOFAnalysisTaskCalibPass0.C");
+  gROOT->LoadMacro("AddTaskT0Calib.C");
+  gROOT->LoadMacro("AddTaskMeanVertexCalib.C");
+  gROOT->LoadMacro("AddTaskSDDCalib.C"); 
+
+  // switch off debug 
+  AliLog::SetClassDebugLevel("AliESDEvent",0);
+  
+  // steering input chain
+  TChain *chain = new TChain("esdTree");
+  chain->Add(inFileName);
+
+  // config calibration train
+  // setting geometry and B-field from GRP
+  Int_t runNumber = runNumberString.Atoi();
+  printf("runNumber from runCalibTrain = %d\n",runNumber);
+  printf("ocdb from runCalibTrain = %s\n",ocdb);
+  ConfigCalibTrain(runNumber, ocdb);
+  
+  //
+  // setup analysis
+  //
+  AliAnalysisManager *mgr  = new AliAnalysisManager("ESD to ESD", "Analysis Manager");
+  // mgr->SetDebugLevel(3);
+  
+  // Input
+  AliESDInputHandler* inpHandler = new AliESDInputHandler();
+  inpHandler->SetReadFriends(1);
+  mgr->SetInputEventHandler(inpHandler);
+  
+  // Output
+  const char *outFile = "AliESDfriends_v1.root";
+  AliESDHandler* esdHandler   = new AliESDHandler();
+  mgr->SetOutputEventHandler(esdHandler);
+  esdHandler->SetOutputFileName(outFile);
+  mgr->SetCommonFileName(outFile);
+  //  
+  // Detector Tasks
+  AliAnalysisTask* tTPC = AddTaskTPCCalib(runNumber);
+  AliAnalysisTask* tTRD = AddTaskTRDCalib(runNumber);
+  AliTOFAnalysisTaskCalibPass0 *thisTask = AddTOFAnalysisTaskCalibPass0();
+  AliAnalysisTask* tT0 = AddTaskT0Calib(runNumber);
+  AliMeanVertexCalibTask *tMeanVtx = AddTaskMeanVertexCalib();
+  AliAnalysisTaskITSAlignQA *itsAlign = AddTaskSDDCalib();
+
+  // Run the analysis
+  if (!mgr->InitAnalysis()) {
+    printf("Analysis cannot be started, returning\n");
+    return;
+  }
+  
+  mgr->PrintStatus();
+  mgr->StartAnalysis("local", chain);
+  
+  return;
+}
diff --git a/PWGPP/CalibMacros/CPass0/runPass0.sh b/PWGPP/CalibMacros/CPass0/runPass0.sh
new file mode 100644 (file)
index 0000000..9890c38
--- /dev/null
@@ -0,0 +1,68 @@
+#!/bin/bash
+
+# Script to run:
+#    1. reconstruction
+#    2. calibration and friend track filtering
+#
+# Files assumed to be in working directory:
+# recPass0.C          - reconstruction macro
+# runCalibTrain.C     - calibration/filtering macro
+# Arguments (run locally):
+#    1  - raw data file name
+#    2  - number of events to be processed
+#    3  - run number 
+
+# example:
+# runPass0.sh raw.root  50  104892
+
+#ALIEN setting
+# $1 = raw input filename
+runNum=`echo $1 | cut -d "/" -f 6`
+if [ $# -eq 1 ] ; then
+  # alien Setup
+  nEvents=99999999
+  fileName="alien://"$1
+  ocdbPath="raw://"
+fi;
+if [ $# -eq 4 ] ; then
+  # local setup
+  nEvents=$2
+  runNum=$3
+  fileName=$1
+  ocdbPath=$4
+fi
+
+echo xxxxxxxxxxxxxxxxxxxxxxxxxxx
+echo runPass0.sh Input arguments
+echo fileName=$fileName
+echo nEvents=$nEvents
+echo runNum=$runNum
+echo ocdbPath=$ocdbPath
+echo xxxxxxxxxxxxxxxxxxxxxxxxxxx
+
+if [ -f Run0_999999999_v3_s0.root ]; then
+    mkdir -p TPC/Calib/Correction
+    mv Run0_999999999_v3_s0.root TPC/Calib/Correction/
+fi
+
+
+
+echo File to be  processed $1
+echo Number of events to be processed $nEvents
+
+echo ">>>>>>>>> PATH is..."
+echo $PATH
+echo ">>>>>>>>> LD_LIBRARY_PATH is..."
+echo $LD_LIBRARY_PATH
+echo ">>>>>>>>> recPass0.C is..."
+#cat recPass0.C
+echo
+
+echo ">>>>>>> Running AliRoot to reconstruct $1. Run number is $runNum..."
+
+aliroot -l -b -q recPass0.C\(\""$fileName\", $nEvents, \"$ocdbPath"\"\) 2>&1 | tee rec.log
+mv syswatch.log syswatch_rec.log
+
+echo ">>>>>>> Running AliRoot to make calibration..."
+aliroot -l -b -q  runCalibTrain.C\(\""$runNum\",\"AliESDs.root\",\"$ocdbPath"\"\)   2>&1 | tee calib.log
+mv syswatch.log syswatch_calib.log
diff --git a/PWGPP/CalibMacros/CPass0/test/mergeMakeOCDBUser.sh b/PWGPP/CalibMacros/CPass0/test/mergeMakeOCDBUser.sh
new file mode 100755 (executable)
index 0000000..762074e
--- /dev/null
@@ -0,0 +1,66 @@
+# Script for testing of the mergemakeOCDB on the grid for user purposes
+# To be used in case the standard production failed or was not automatically validated
+# Output objects are writn to the predefined path:
+
+# 
+# Parameters for macro:
+# 1  -   alien user dir name                 - e.g  /m/miranov/
+# 2  -   input directory with data to merge  - e.g /alice/data/2011/LHC11h/000169926/cpass0_HLT/
+# 3  -   run number                          - e.g run number 169926
+# 4  -   OCDB output path                    - alien://folder=/alice/cern.ch/user/m/miranov/Pass0/169926
+# Example:
+# run=170572
+# AlienName=/m/miranov/
+# $ALICE_ROOT/PWGPP/CalibMacros/Pass0/test/mergeMakeOCDBUser.sh $AlienName /alice/data/2011/LHC11h/000$Run/cpass0_HLT/  $Run alien://folder=/alice/cern.ch/user/m/miranov/Pass0/$Run
+#
+# authors:   marian.ivanov#cern.ch, mikolaj.krzewicki@cern.ch 
+
+AlienName=$1
+InputDataDir=$2
+Run=$3
+OCDBPath=$4
+InputMacros=$ALICE_ROOT/PWGPP/CalibMacros/Pass0/
+
+echo xxxxxxxxxxxxxxxxxxxxxxxxxx
+echo SETUP
+echo AlienName=$1
+echo InputDataDir=$2
+echo Run=$3
+echo OCDBPath=$4
+echo InputMacros=$ALICE_ROOT/PWGPP/CalibMacros/Pass0/
+echo xxxxxxxxxxxxxxxxxxxxxxxxxx
+
+#
+# 1. copy macroses and sh to the predefiend alien directory
+#
+OutputMacros=`echo /alice/cern.ch/user/j/jotwinow/Pass0/MergeCalibration/ | sed s_\/j\/jotwinow\/_$AlienName\_ `
+alien_mkdir  $OutputMacros
+
+for lfile in `ls $InputMacros/{*C,*sh,*jdl} | grep -v AddTask`; do
+    bname=`basename $lfile`  
+    echo  Copping alien_cp -n $lfile alien://$OutputMacros/$bname 
+    alien_cp -n $lfile alien://$OutputMacros/$bname
+done
+#
+# 2. Copy shell script and jdl
+#
+OutputBin=`echo  /alice/cern.ch/user/j/jotwinow/bin/ | sed s_\/j\/jotwinow\/_$AlienName\_ `
+echo alien_cp -n $InputMacros/mergeMakeOCDB.sh  alien://$OutputBin/mergeMakeOCDB.sh
+alien_cp -n  $InputMacros/mergeMakeOCDB.sh  alien://$OutputBin/mergeMakeOCDB.sh
+cat $InputMacros/mergeMakeOCDB.jdl | sed "s_/j/jotwinow/_${AlienName}_g" > mergeMakeOCDB.jdl
+echo alien_cp -n mergeMakeOCDB.jdl alien://$OutputMacros/mergeMakeOCDB.jdl
+alien_cp -n mergeMakeOCDB.jdl alien://$OutputMacros/mergeMakeOCDB.jdl
+
+#
+# 3. Copy validation switch off return value - job will alway finish
+#
+cat $InputMacros/validationMerging.sh |  sed "s_exit \$error_exit 0_" > validationMerging.sh
+echo alien_cp  -n validationMerging.sh  alien:///$OutputMacros/validationMerging.sh
+alien_cp  -n validationMerging.sh  alien:///$OutputMacros/validationMerging.sh
+#
+# 4. Submit job
+#
+echo alien_submit alien:///$OutputMacros/mergeMakeOCDB.jdl $InputDataDir $Run $OCDBPath
+alien_submit alien:///$OutputMacros/mergeMakeOCDB.jdl $InputDataDir $Run $OCDBPath &
+echo Alien job submitted $!
+
diff --git a/PWGPP/CalibMacros/CPass0/test/runPass0User.sh b/PWGPP/CalibMacros/CPass0/test/runPass0User.sh
new file mode 100755 (executable)
index 0000000..7ddd78b
--- /dev/null
@@ -0,0 +1,65 @@
+# Script for testing of the Pass0.jdl  on the grid for user purposes
+# To be used for validation of modified user code before asking for porting
+
+# 
+# Parameters for macro:
+# 1  -   alien user dir name                 - e.g  /m/miranov/
+# 2  -   input directory with raw data       - e.g /alice/data/2011/LHC11a/
+# 3  -   run number                          - e.g run number 000146807
+# Example:
+# Run=000146807
+# AlienName=/m/miranov/
+# RawPath=/alice/data/2011/LHC11a/
+# $ALICE_ROOT/PWGPP/CalibMacros/Pass0/test/runPass0User.sh  $AlienName $RawPath  $Run 
+#
+# authors:   marian.ivanov#cern.ch, mikolaj.krzewicki@cern.ch 
+
+AlienName=$1
+RawPath=$2
+Run=$3
+InputMacros=$ALICE_ROOT/PWGPP/CalibMacros/Pass0/
+
+echo xxxxxxxxxxxxxxxxxxxxxxxxxx
+echo SETUP
+echo AlienName=$1
+echo RawPath=$2
+echo Run=$3 
+echo InputMacros=$ALICE_ROOT/PWGPP/CalibMacros/Pass0/
+echo xxxxxxxxxxxxxxxxxxxxxxxxxx
+
+#
+# 1. copy macroses and sh to the predefiend alien directory
+#
+OutputMacros=`echo /alice/cern.ch/user/j/jotwinow/Pass0/CalibMacros/ | sed s_\/j\/jotwinow\/_$AlienName\_ `
+alien_mkdir  $OutputMacros
+
+for lfile in `ls $InputMacros/{*C,*sh} `; do
+    bname=`basename $lfile`  
+    echo  Copping alien_cp -n $lfile alien://$OutputMacros/$bname 
+    alien_cp -n $lfile alien://$OutputMacros/$bname
+done
+
+
+#
+# 2. Copy shell script and jdl
+#
+OutputBin=`echo  /alice/cern.ch/user/j/jotwinow/bin/ | sed s_\/j\/jotwinow\/_$AlienName\_ `
+echo alien_cp -n $InputMacros/runPass0.sh  alien://$OutputBin/runPass0.sh
+alien_cp -n  $InputMacros/runPass0.sh   alien://$OutputBin/runPass0.sh
+cat $InputMacros/Pass0.jdl | sed "s_/j/jotwinow/_${AlienName}_g" | sed "s_/alice/data/2010/LHC10d/_${RawPath}_g" > Pass0.jdl
+echo alien_cp -n Pass0.jdl alien://$OutputMacros/Pass0.jdl
+alien_cp -n Pass0.jdl alien://$OutputMacros/Pass0.jdl
+
+#
+# 3. Copy validation switch off return value - job will alway finish
+#
+cat $InputMacros/validation.sh |  sed "s_exit \$error_exit 0_" > validation.sh
+echo alien_cp  -n validation.sh  alien:///$OutputMacros/validation.sh
+alien_cp  -n validation.sh  alien:///$OutputMacros/validation.sh
+#
+# 4. Submit job
+#
+echo nohup alien_submit alien:///$OutputMacros/Pass0.jdl $Run  >submitJob$Run.txt
+#nohup alien_submit alien:///$OutputMacros/Pass0.jdl $Run  >submitJob$Run.txt
+#echo Alien job submitted $!
+
diff --git a/PWGPP/CalibMacros/CPass0/validation.sh b/PWGPP/CalibMacros/CPass0/validation.sh
new file mode 100644 (file)
index 0000000..cadafcc
--- /dev/null
@@ -0,0 +1,75 @@
+#!/bin/sh
+##################################################
+validateout=`dirname $0`
+validatetime=`date`
+validated="0";
+error=1
+
+if [ -z $validateout ]
+then
+    validateout="."
+fi
+cd $validateout;
+validateworkdir=`pwd`;
+
+echo "*******************************************************" >> stdout;
+echo "* AliRoot Validation Script V1.0                      *" >> stdout;
+echo "* Time:    $validatetime " >> stdout;
+echo "* Dir:     $validateout" >> stdout;
+echo "* Workdir: $validateworkdir" >> stdout;
+echo "* ----------------------------------------------------*" >> stdout;
+ls -la ./ >> stdout;
+echo "* ----------------------------------------------------*" >> stdout;
+
+cp stdout stdout.log
+cp stderr stderr.log
+
+##################################################
+if [ -f rec.log ] && [ -f calib.log ] && [ -f AliESDs.root ] && [ -f AliESDfriends_v1.root ]  
+then 
+sv=`grep -i  "Segmentation violation" *.log`
+if [ "$sv" = "" ]
+    then
+    sf=`grep -i  "Segmentation fault" *.log`
+    if [ "$sf" = "" ]
+        then
+        be=`grep -i  "Bus error" *.log`
+        if [ "$be" = "" ]
+           then
+           ab=`grep -i "Break" *.log`
+           if [ "$ab" = "" ]
+               then
+               fp=`grep -i  "Floating point exception" *.log`
+               if [ "$fp" = "" ]
+                   then
+                   kl=`grep -i  "Killed" *.log`
+                   if [ "$kl" = "" ]
+                       then
+                       bf=`grep -i "busy flag cleared" *.log`
+                       if [ "$bf" = "" ]
+                            then
+                              echo "* ----------------   Job Validated  ------------------*" >> stdout;
+                              error="0";
+                            else
+                               echo "* #             Check Macro failed !                  #" >> stdout;
+                        fi
+                   fi
+               fi
+            fi
+        fi
+    fi
+fi
+else
+    echo "* ########## Job not validated - no rec.log or calib.log or AliESDs.root  && AliESDfriends.root ###" >> stdout;
+    echo "* ########## Removing all ROOT files from the local directory, leaving only the logs ###" >> stdout;
+    rm -rf *.root
+fi
+if [ "$error" = "1" ] 
+    then
+    echo "* ################   Job not validated ################" >> stdout;
+fi
+echo "* ----------------------------------------------------*" >> stdout;
+echo "*******************************************************" >> stdout;
+sleep 15;
+cd -
+exit $error
diff --git a/PWGPP/CalibMacros/CPass0/validationMerging.sh b/PWGPP/CalibMacros/CPass0/validationMerging.sh
new file mode 100755 (executable)
index 0000000..ba89c09
--- /dev/null
@@ -0,0 +1,84 @@
+
+#!/bin/sh
+##################################################
+validateout=`dirname $0`
+validatetime=`date`
+validated="0";
+error=1
+
+if [ -z $validateout ]
+then
+    validateout="."
+fi
+cd $validateout;
+validateworkdir=`pwd`;
+
+echo "*******************************************************" >> stdout;
+echo "* AliRoot Validation Script V1.0                      *" >> stdout;
+echo "* Time:    $validatetime " >> stdout;
+echo "* Dir:     $validateout" >> stdout;
+echo "* Workdir: $validateworkdir" >> stdout;
+echo "* ----------------------------------------------------*" >> stdout;
+ls -la ./ >> stdout;
+echo "* ----------------------------------------------------*" >> stdout;
+
+cp stdout stdout.log
+cp stderr stderr.log
+
+##################################################
+if [ -f merge.log ] && [ -f CalibObjects.root ] 
+then 
+sv=`grep -i  "Segmentation violation" *.log`
+if [ "$sv" = "" ]
+    then
+    sf=`grep -i  "Segmentation fault" *.log`
+    if [ "$sf" = "" ]
+        then
+        be=`grep -i  "Bus error" *.log`
+        if [ "$be" = "" ]
+           then
+           ab=`grep -i "Break" *.log`
+           if [ "$ab" = "" ]
+               then
+               fp=`grep -i  "Floating point exception" *.log`
+               if [ "$fp" = "" ]
+                   then
+                   kl=`grep -i  "Killed" *.log`
+                   if [ "$kl" = "" ]
+                       then
+                       bf=`grep -i "busy flag cleared" *.log`
+                       if [ "$bf" = "" ]
+                            then
+                               es=`grep -i "E-AliCDBGrid::PutEntry:" *.log`
+                                if [ "$es" = "" ]
+                                  then
+                                   fg=`grep -i "F-AliCDBGrid::" *.log`
+                                    if [ "$fg" = "" ]
+                                      then
+                                   echo "* ----------------   Job Validated  ------------------*" >> stdout;
+                                   error="0";
+                                  else
+                                    echo "* #             Check Macro failed !                  #" >> stdout;
+                               fi
+                            fi
+                        fi
+                   fi
+               fi
+            fi
+        fi
+    fi
+fi
+else
+    echo "* ########## Job not validated - no merge.log or CalibObjects.root ###" >> stdout;
+    echo "* ########## Removing all ROOT files from the local directory, leaving only the logs ###" >> stdout;
+    rm -rf *.root
+fi
+if [ "$error" = "1" ] 
+    then
+    echo "* ################   Job not validated ################" >> stdout;
+fi
+echo "* ----------------------------------------------------*" >> stdout;
+echo "*******************************************************" >> stdout;
+sleep 15;
+cd -
+exit $error
diff --git a/PWGPP/CalibMacros/CPass1/AddTaskAddObject.C b/PWGPP/CalibMacros/CPass1/AddTaskAddObject.C
new file mode 100644 (file)
index 0000000..56eb5bd
--- /dev/null
@@ -0,0 +1,38 @@
+//=============================================================================
+//
+// *** AddTaskAddObject.C ***
+//
+// This macro initialize a complete AnalysisTask object for filtering ESD with AliAnalysisTaskFilterFriendSecond.
+//
+//=============================================================================
+
+AliAnalysisTaskAddObject *AddTaskAddObject()
+{
+
+       // pointer to the analysis manager
+       AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+       if (!mgr) {
+               Error("AddTaskTOFCalib", "No analysis manager to connect to.");
+               return NULL;
+       }  
+
+       // check the input handler
+       if (!mgr->GetInputEventHandler()) {
+               ::Error("AddTask", "This task requires an input event handler");
+               return NULL;
+       }  
+       TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
+
+       // create the task
+       AliAnalysisTaskAddObject* add = new AliAnalysisTaskAddObject("addObj");
+       mgr->AddTask(add);
+
+       // connecting the input/output containers
+       AliAnalysisDataContainer *cinput0  = mgr->GetCommonInputContainer();
+       AliAnalysisDataContainer *coutput0 = mgr->CreateContainer("histo",  TH1::Class(), AliAnalysisManager::kOutputContainer, "AliESDfriends_v1.root");
+
+       mgr->ConnectInput (add, 0, cinput0 );
+       mgr->ConnectOutput(add, 0, coutput0);
+
+       return add;
+}
diff --git a/PWGPP/CalibMacros/CPass1/AddTaskFilterFriend.C b/PWGPP/CalibMacros/CPass1/AddTaskFilterFriend.C
new file mode 100644 (file)
index 0000000..0076536
--- /dev/null
@@ -0,0 +1,38 @@
+//=============================================================================
+//
+// *** AddTaskFilterFriend.C ***
+//
+// This macro initialize a complete AnalysisTask object for filtering ESD with AliAnalysisTaskFilterFriend.
+//
+//=============================================================================
+
+AliAnalysisTaskFilterFriend *AddTaskFilterFriend()
+{
+
+       // pointer to the analysis manager
+       AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+       if (!mgr) {
+               Error("AddTaskTOFCalib", "No analysis manager to connect to.");
+               return NULL;
+       }  
+
+       // check the input handler
+       if (!mgr->GetInputEventHandler()) {
+               ::Error("AddTask", "This task requires an input event handler");
+               return NULL;
+       }  
+       TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
+
+       // create the task
+       AliAnalysisTaskFilterFriend* filter = new AliAnalysisTaskFilterFriend("filter_1");
+       mgr->AddTask(filter);
+
+       // connecting the input/output containers
+       AliAnalysisDataContainer *cinput0  = mgr->GetCommonInputContainer();
+       AliAnalysisDataContainer *coutput0 = mgr->GetCommonOutputContainer();
+
+       mgr->ConnectInput (filter, 0, cinput0 );
+       //mgr->ConnectOutput(filter, 0, coutput0);
+
+       return filter;
+}
diff --git a/PWGPP/CalibMacros/CPass1/AddTaskFilterFriendSecond.C b/PWGPP/CalibMacros/CPass1/AddTaskFilterFriendSecond.C
new file mode 100644 (file)
index 0000000..dc19fdf
--- /dev/null
@@ -0,0 +1,38 @@
+//=============================================================================
+//
+// *** AddTaskFilterFriendSecond.C ***
+//
+// This macro initialize a complete AnalysisTask object for filtering ESD with AliAnalysisTaskFilterFriendSecond.
+//
+//=============================================================================
+
+AliAnalysisTaskFilterFriendSecond *AddTaskFilterFriendSecond()
+{
+
+       // pointer to the analysis manager
+       AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+       if (!mgr) {
+               Error("AddTaskTOFCalib", "No analysis manager to connect to.");
+               return NULL;
+       }  
+
+       // check the input handler
+       if (!mgr->GetInputEventHandler()) {
+               ::Error("AddTask", "This task requires an input event handler");
+               return NULL;
+       }  
+       TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
+
+       // create the task
+       AliAnalysisTaskFilterFriendSecond* filter = new AliAnalysisTaskFilterFriendSecond("filter_2");
+       mgr->AddTask(filter);
+
+       // connecting the input/output containers
+       AliAnalysisDataContainer *cinput0  = mgr->GetCommonInputContainer();
+       AliAnalysisDataContainer *coutput0 = mgr->GetCommonOutputContainer();
+
+       mgr->ConnectInput (filter, 0, cinput0 );
+       //mgr->ConnectOutput(filter, 0, coutput0);
+
+       return filter;
+}
diff --git a/PWGPP/CalibMacros/CPass1/AddTaskFilterSteer.C b/PWGPP/CalibMacros/CPass1/AddTaskFilterSteer.C
new file mode 100644 (file)
index 0000000..cbf6f1a
--- /dev/null
@@ -0,0 +1,38 @@
+//=============================================================================
+//
+// *** AddTaskFilterFriendSteer.C ***
+//
+// This macro initialize a complete AnalysisTask object for filtering ESD with AliAnalysisTaskFilterFriendSteer
+//
+//=============================================================================
+
+AliAnalysisTaskFilterSteer *AddTaskFilterSteer()
+{
+
+       // pointer to the analysis manager
+       AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+       if (!mgr) {
+               Error("AddTaskTOFCalib", "No analysis manager to connect to.");
+               return NULL;
+       }  
+
+       // check the input handler
+       if (!mgr->GetInputEventHandler()) {
+               ::Error("AddTask", "This task requires an input event handler");
+               return NULL;
+       }  
+
+       // create the task
+       AliAnalysisTaskFilterSteer* filter = new AliAnalysisTaskFilterSteer("samplingFilter");
+       filter->SetFraction(0.7);
+       mgr->AddTask(filter);
+
+       // connecting the input/output containers
+       AliAnalysisDataContainer *cinput0  = mgr->GetCommonInputContainer();
+       AliAnalysisDataContainer *coutput0 = mgr->GetCommonOutputContainer();
+
+       mgr->ConnectInput (filter, 0, cinput0 );
+       //mgr->ConnectOutput(filter, 0, coutput0);
+
+       return filter;
+}
diff --git a/PWGPP/CalibMacros/CPass1/AddTaskTPCCalib.C b/PWGPP/CalibMacros/CPass1/AddTaskTPCCalib.C
new file mode 100644 (file)
index 0000000..25e8e0e
--- /dev/null
@@ -0,0 +1,206 @@
+//=============================================================================
+//
+// *** AddTaskTPCCalib
+//
+// This macros setup the TPC calibration task
+//
+//=============================================================================
+
+
+
+
+Int_t debugLevel  = 2;
+Int_t streamLevel = 20;
+TTimeStamp startTime(2010,2,1,0,0,0);
+TTimeStamp stopTime(2010,12,31,0,0,0);
+char * prefix = "/V6/";
+
+void ConfigOCDB(Int_t crun);
+
+AliAnalysisTask  *AddTaskTPCCalib(Int_t runNumber)
+{
+  gSystem->Load("libTPCcalib");
+  // pointer to the analysis manager
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    Error("AddTaskTPCCalib", "No analysis manager to connect to.");
+    return NULL;
+  }  
+  
+  // check the input handler
+  if (!mgr->GetInputEventHandler()) {
+    ::Error("AddTask", "This task requires an input event handler");
+    return NULL;
+  }  
+  ConfigOCDB(runNumber);
+  AliTPCAnalysisTaskcalib *task1=new AliTPCAnalysisTaskcalib("CalibObjectsTrain1");
+  //
+  SetupCalibTaskTrain1(task1);
+  mgr->AddTask(task1);
+  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
+  
+  if (!cinput1) cinput1 = mgr->CreateContainer("cchain",TChain::Class(), 
+                                      AliAnalysisManager::kInputContainer);
+
+  AliAnalysisDataContainer *coutput1 =mgr->CreateContainer("TPCCalib",TObjArray::Class(), AliAnalysisManager::kOutputContainer, "AliESDfriends_v1.root");  
+  mgr->ConnectInput(task1,0,cinput1);
+  mgr->ConnectOutput(task1,0,coutput1);
+  return task1;
+}
+
+
+
+
+void AddCalibCalib(TObject* task){
+  //
+  // Responsible: Marian Ivanov
+  // Description:
+  // calibCalib is a prefilter 
+  // The current OCDB entries transformation are applied on cluster, tracks are refitted
+  //
+  AliTPCAnalysisTaskcalib* myTask = (AliTPCAnalysisTaskcalib*) task;
+  AliTPCcalibCalib *calibCalib = new AliTPCcalibCalib("calibTPC","calibTPC");
+  calibCalib->SetDebugLevel(debugLevel);
+  calibCalib->SetStreamLevel(streamLevel);
+  calibCalib->SetTriggerMask(-1,-1,kFALSE);        //accept everything 
+  myTask->AddJob(calibCalib);
+
+}
+void AddCalibTimeGain(TObject* task, Bool_t isCosmic = kFALSE, char * name = "calibTimeGain"){
+  //
+  //  Responsible: Alexander Kalweit
+  //  Description:
+  //  Parameters to set
+  AliTPCAnalysisTaskcalib* myTask = (AliTPCAnalysisTaskcalib*) task;
+  AliTPCcalibTimeGain *calibTimeGain = new AliTPCcalibTimeGain(name,"calibTimeGain", startTime.GetSec(), stopTime.GetSec(), 30*60);
+  //calibTimeGain->SetLowMemoryConsumption(kTRUE);
+  //calibTimeGain->SetMIP(25.);
+  calibTimeGain->SetIsCosmic(isCosmic);
+  calibTimeGain->SetUseCookAnalytical(kTRUE);
+  calibTimeGain->SetUseMax(kFALSE);
+  calibTimeGain->SetDebugLevel(debugLevel);
+  calibTimeGain->SetStreamLevel(streamLevel);
+  calibTimeGain->SetTriggerMask(-1,-1,kTRUE);        //reject laser
+  myTask->AddJob(calibTimeGain);
+}
+
+void AddCalibTime(TObject* task){
+  //
+  // Responsible: Dag Larsen
+  // Description:
+  //
+  //
+  AliTPCAnalysisTaskcalib* myTask = (AliTPCAnalysisTaskcalib*) task;
+  AliTPCcalibTime *calibTime = new AliTPCcalibTime("calibTime","calibTime",  startTime.GetSec(), stopTime.GetSec(), 20*60);
+  calibTime->SetDebugLevel(debugLevel);
+  calibTime->SetStreamLevel(streamLevel);
+  calibTime->SetTriggerMask(-1,-1,kFALSE);        //accept everything 
+  myTask->AddJob(calibTime);
+}
+
+void AddCalibLaser(TObject* task){
+  //
+  // Responsible: Marian Ivanov
+  // Description:
+  //
+  AliTPCAnalysisTaskcalib* myTask = (AliTPCAnalysisTaskcalib*) task;
+  AliTPCcalibLaser *calibLaser = new AliTPCcalibLaser("laserTPC","laserTPC");
+  calibLaser->SetDebugLevel(debugLevel);
+  calibLaser->SetStreamLevel(streamLevel);
+  calibLaser->SetTriggerMask(-1,-1,kFALSE);        //accept everything
+  myTask->AddJob(calibLaser);
+}
+
+
+void AddCalibAlign(TObject* task){
+  //
+  // Responsible: Marian Ivanov
+  // Description:
+  //
+  AliTPCAnalysisTaskcalib* myTask = (AliTPCAnalysisTaskcalib*) task;
+  AliTPCcalibAlign *calibAlign = new AliTPCcalibAlign("alignTPC","Alignment of the TPC sectors");
+  calibAlign->SetDebugLevel(debugLevel);
+  calibAlign->SetStreamLevel(streamLevel);
+  calibAlign->SetTriggerMask(-1,-1,kTRUE);        //accept everything
+  myTask->AddJob(calibAlign);
+}
+
+void AddCalibCosmic(TObject* task){
+  //
+  // Responsible: Marian Ivanov
+  // Description:
+  // Histogram residuals and pulls of the track parameters in bins of track parameters
+  //
+  AliTPCAnalysisTaskcalib* myTask = (AliTPCAnalysisTaskcalib*) task;
+  AliTPCcalibCosmic *calibCosmic = new AliTPCcalibCosmic("cosmicTPC","cosmicTPC");
+  calibCosmic->SetDebugLevel(debugLevel);
+  calibCosmic->SetStreamLevel(streamLevel);
+  calibCosmic->SetTriggerMask(-1,-1,kTRUE);        //accept everything
+  myTask->AddJob(calibCosmic);
+}
+
+
+
+
+void SetupCalibTaskTrain1(TObject* task){
+  //
+  //
+  //
+  AliTPCAnalysisTaskcalib* myTask = (AliTPCAnalysisTaskcalib*) task;
+  AddCalibCalib(task);
+  AddCalibTimeGain(task);
+  AddCalibTimeGain(task,kTRUE,"calibTimeGainCosmic"); // 2nd task for cosmic runs
+  AddCalibTime(task);
+  AddCalibLaser(task);
+  AddCalibAlign(task);
+  AddCalibCosmic(task);
+  //
+  TString path=gSystem->pwd();
+  path+=prefix;
+  gSystem->mkdir(path);
+  myTask->SetDebugOuputhPath(path.Data());
+
+}
+
+
+
+void ConfigOCDB(Int_t run){
+  // 
+  printf("SETUP OCBD for TPC\n");
+  printf("SETUP OCBD for TPC\n");
+  printf("SETUP OCBD for TPC Run =%d\n", run);
+  //
+  //
+  AliTPCParam *param= AliTPCcalibDB::Instance()->GetParameters();
+  param->ReadGeoMatrices();
+  //
+  AliMagF* magF= TGeoGlobalMagField::Instance()->GetField();
+  printf("\n\nSET EXB FIELD\t\n\n");
+  AliTPCcalibDB::Instance()->SetExBField(magF);
+  //
+  //
+  //
+  AliTPCTransform *transform     = AliTPCcalibDB::Instance()->GetTransform() ;
+  AliTPCRecoParam * tpcRecoParam = AliTPCRecoParam::GetCosmicTestParam(kTRUE);
+  //
+  transform->SetCurrentRecoParam(tpcRecoParam);
+  tpcRecoParam->SetUseGainCorrectionTime(0);
+  tpcRecoParam->SetUseRPHICorrection(kTRUE); 
+  tpcRecoParam->SetUseTOFCorrection(kFALSE);
+  //
+  tpcRecoParam->SetUseDriftCorrectionTime(0);
+  tpcRecoParam->SetUseDriftCorrectionGY(0);
+  //
+  tpcRecoParam->SetUseRadialCorrection(kFALSE);
+  tpcRecoParam->SetUseQuadrantAlignment(kFALSE);
+  //
+  tpcRecoParam->SetUseSectorAlignment(kTRUE);
+  tpcRecoParam->SetUseGainCorrectionTime(kFALSE);
+  tpcRecoParam->SetUseFieldCorrection(kFALSE);
+  tpcRecoParam->SetUseExBCorrection(kTRUE);
+  AliTPCcalibDB::Instance()->SetRun(run); 
+}
+
+
+
+
diff --git a/PWGPP/CalibMacros/CPass1/ConfigCalibTrain.C b/PWGPP/CalibMacros/CPass1/ConfigCalibTrain.C
new file mode 100644 (file)
index 0000000..87a3bd5
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// Macro to initialize: 
+// - the OCDB (run number required as input argument)
+// - the geometry (expected to be in the current directory)
+// to run the Calibration train.
+// 
+
+void ConfigCalibTrain(Int_t run, const char *ocdb="raw://"){
+
+  // OCDB
+  printf("setting run to %d\n",run);
+  AliCDBManager::Instance()->SetDefaultStorage(ocdb);
+  AliCDBManager::Instance()->SetRun(run); 
+
+  // geometry
+  AliGeomManager::LoadGeometry();
+  AliGeomManager::ApplyAlignObjsFromCDB("GRP ITS TPC");
+
+
+
+  AliCDBEntry *entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
+  AliGRPObject* grpData = (AliGRPObject*)entry->GetObject();
+
+  Bool_t ok=kTRUE;
+  Float_t l3Current = grpData->GetL3Current((AliGRPObject::Stats)0);
+  if (l3Current == AliGRPObject::GetInvalidFloat()) {
+    printf("GRP/GRP/Data entry:  missing value for the L3 current !");
+    ok = kFALSE;
+  }
+  
+  Char_t l3Polarity = grpData->GetL3Polarity();
+  if (l3Polarity == AliGRPObject::GetInvalidChar()) {
+    printf("GRP/GRP/Data entry:  missing value for the L3 polarity !");
+    ok = kFALSE;
+  }
+  
+  // Dipole
+  Float_t diCurrent = grpData->GetDipoleCurrent((AliGRPObject::Stats)0);
+  if (diCurrent == AliGRPObject::GetInvalidFloat()) {
+    printf("GRP/GRP/Data entry:  missing value for the dipole current !");
+    ok = kFALSE;
+  }
+  
+  Char_t diPolarity = grpData->GetDipolePolarity();
+  if (diPolarity == AliGRPObject::GetInvalidChar()) {
+    printf("GRP/GRP/Data entry:  missing value for the dipole polarity !");
+    ok = kFALSE;
+  }
+
+  TString beamType = grpData->GetBeamType();
+  if (beamType==AliGRPObject::GetInvalidString()) {
+    printf("GRP/GRP/Data entry:  missing value for the beam type ! Using UNKNOWN");
+    beamType = "UNKNOWN";
+  }
+
+  Float_t beamEnergy = grpData->GetBeamEnergy();
+  if (beamEnergy==AliGRPObject::GetInvalidFloat()) {
+    printf("GRP/GRP/Data entry:  missing value for the beam energy ! Using 0");
+    beamEnergy = 0;
+  }
+
+  // read special bits for the polarity convention and map type
+  //Int_t  polConvention = grpData->IsPolarityConventionLHC() ? AliMagF::kConvLHC : AliMagF::kConvDCS2008;
+  Int_t  polConvention = grpData->IsPolarityConventionLHC() ? 0 : 1;
+  Bool_t uniformB = grpData->IsUniformBMap();
+  
+  if (ok) {
+    AliMagF* fld = AliMagF::CreateFieldMap(TMath::Abs(l3Current) * (l3Polarity ? -1:1),
+                                          TMath::Abs(diCurrent) * (diPolarity ? -1:1),
+                                          polConvention,uniformB,beamEnergy, beamType.Data());
+    if (fld) {
+      TGeoGlobalMagField::Instance()->SetField( fld );
+      TGeoGlobalMagField::Instance()->Lock();
+      printf("Running with the B field constructed out of GRP !");
+    }
+  }
+  printf("Problem with magnetic field setup\n");
+}
diff --git a/PWGPP/CalibMacros/CPass1/LoadLibraries.C b/PWGPP/CalibMacros/CPass1/LoadLibraries.C
new file mode 100644 (file)
index 0000000..17ec533
--- /dev/null
@@ -0,0 +1,19 @@
+void LoadLibraries(){
+    gSystem->Load("libTree");
+    gSystem->Load("libGeom");
+    gSystem->Load("libPhysics");
+    gSystem->Load("libVMC");
+    gSystem->Load("libSTEERBase");
+    gSystem->Load("libESD");
+    gSystem->Load("libAOD");
+
+    gSystem->Load("libANALYSIS");
+    gSystem->Load("libANALYSISalice");
+    gSystem->Load("libANALYSIScalib");
+    gSystem->Load("libCORRFW");
+    gSystem->Load("libPWGmuon");
+    //
+    // detector libraries
+    //    
+    gSystem->Load("libTPCcalib");
+}
diff --git a/PWGPP/CalibMacros/CPass1/PassX.jdl b/PWGPP/CalibMacros/CPass1/PassX.jdl
new file mode 100644 (file)
index 0000000..76fce7e
--- /dev/null
@@ -0,0 +1,42 @@
+Executable="/alice/cern.ch/user/z/zampolli/bin/runPassX.sh";
+
+Packages={"VO_ALICE@AliRoot::v4-19-07-AN","VO_ALICE@ROOT::v5-26-00b-1","VO_ALICE@APISCONFIG::V1.1x"};
+Jobtag =
+           {
+              "test Calibration Train"
+           };
+
+GUIDFILE="guid.txt";
+TTL = "28000";
+Price = 1;
+
+Requirements = ( other.CE == "ALICE::CERN::LCG" );
+
+Validationcommand ="/alice/cern.ch/user/z/zampolli/PassX/validation.sh";
+
+Split="file";
+
+JDLVariables={"Packages", "OutputDir"};
+GUIDFILE="guid.txt";
+
+
+SplitArguments = {"/alice/data/2009/LHC09d/$1/raw/#alienfilename#"};
+Workdirectorysize={"6000MB"};
+
+InputFile={"LF:/alice/cern.ch/user/z/zampolli/PassX/rec.C",
+           "LF:/alice/cern.ch/user/z/zampolli/PassX/ConfigCalibTrain.C",
+           "LF:/alice/cern.ch/user/z/zampolli/PassX/runCalibTrain.C",
+           "LF:/alice/cern.ch/user/z/zampolli/PassX/AddTaskAddObject.C",
+           "LF:/alice/cern.ch/user/z/zampolli/PassX/AddTaskFilterFriend.C",
+           "LF:/alice/cern.ch/user/z/zampolli/PassX/AddTaskFilterFriendSecond.C",
+           "LF:/alice/cern.ch/user/z/zampolli/PassX/AddTaskTPCCalib.C",
+           "LF:/alice/cern.ch/user/z/zampolli/PassX/LoadLibraries.C",
+           "LF:/alice/cern.ch/user/z/zampolli/PassX/tag.C"
+};
+InputDataCollection="LF:/alice/data/2009/LHC09d/$1/collection,nodownload";
+
+OutputDir="/alice/cern.ch/user/z/zampolli/PassX/output/$1/#alienfilename/.root//#";
+
+OutputArchive={"log_archive:*.log@disk=1",
+              "root_archive.zip:galice.root,AliESDs.root,AliESDfriends.root,AliESDfriends_v1.root,Merged.QA.Data*.root,*.ESD.tag.root,@disk=1"};
+
diff --git a/PWGPP/CalibMacros/CPass1/rec.C b/PWGPP/CalibMacros/CPass1/rec.C
new file mode 100644 (file)
index 0000000..e2db10d
--- /dev/null
@@ -0,0 +1,55 @@
+void rec(const char *filename="raw.root")
+{
+  /////////////////////////////////////////////////////////////////////////////////////////
+  //
+  // Reconstruction script for 2009 RAW data
+  //
+  /////////////////////////////////////////////////////////////////////////////////////////
+
+  
+  // Set the CDB storage location
+  AliCDBManager * man = AliCDBManager::Instance();
+  man->SetDefaultStorage("raw://");
+  
+  // Reconstruction settings
+  AliReconstruction rec;
+
+  // Set protection against too many events in a chunk (should not happen)
+  //  rec.SetEventRange(0,30000);
+
+  // Set reconstruction flags (skip detectors here if neded
+  rec.SetRunReconstruction("ITS TPC TRD TOF");
+  //rec.SetFillESD("ITS TPC TRD");
+  // QA options
+  //rec.SetRunQA("Global:ESDs") ;
+  
+  //rec.SetRunQA(":") ;
+  AliQAManager *qam = AliQAManager::QAManager(AliQAv1::kRECMODE) ;
+  rec.SetRunQA(":");
+  rec.SetRunGlobalQA(kFALSE);
+  //ITS QA Off (https://savannah.cern.ch/bugs/?60187)   
+  //rec.SetRunQA("ALL -HLT:ALL") ;
+
+  //rec.SetQARefDefaultStorage("local://$ALICE_ROOT/QAref") ;
+
+  // AliReconstruction settings
+  rec.SetWriteESDfriend(kTRUE);
+  rec.SetWriteAlignmentData();
+  rec.SetInput(filename);
+  rec.SetUseTrackingErrorsForAlignment("ITS");
+
+
+  // Specially for ITS (https://savannah.cern.ch/bugs/?59368)
+
+  rec.SetRunPlaneEff(kTRUE); 
+
+  // switch off cleanESD
+  rec.SetCleanESD(kFALSE);
+
+  //Ignore SetStopOnError
+  rec.SetStopOnError(kFALSE);
+
+  AliLog::Flush();
+  rec.Run();
+
+}
diff --git a/PWGPP/CalibMacros/CPass1/runCalibTrain.C b/PWGPP/CalibMacros/CPass1/runCalibTrain.C
new file mode 100644 (file)
index 0000000..5677f00
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+  Template of calibration/filtering  macro using ESD
+
+  Example:
+  .L $ALICE_ROOT/ANALYSIS/macros/runCalibTrain.C
+  runCalibTrain(105160);
+
+*/
+
+void runCalibTrain(TString runNumberString, const char *inFileName = "AliESDs.root")
+{
+  gROOT->Macro("LoadLibraries.C");
+  gROOT->LoadMacro("ConfigCalibTrain.C");
+  gROOT->LoadMacro("AddTaskFilterFriend.C");
+  gROOT->LoadMacro("AddTaskFilterFriendSecond.C");
+  gROOT->LoadMacro("AddTaskAddObject.C");
+
+  // detector tasks
+  
+  gROOT->LoadMacro("AddTaskTPCCalib.C");
+  
+  AliLog::SetClassDebugLevel("AliESDEvent",19);
+  TChain *chain = new TChain("esdTree");
+  
+  // Steering input chain
+  
+  chain->Add(inFileName);
+  Int_t runNumber = runNumberString.Atoi();
+  printf("runNumber from runCalibTrain = %d\n",runNumber);
+  ConfigCalibTrain(runNumber, "raw://");
+  
+  AliAnalysisManager *mgr  = new AliAnalysisManager("ESD to ESD", "Analysis Manager");
+  // mgr->SetDebugLevel(3);
+  
+  // Input
+  
+  AliESDInputHandler* inpHandler = new AliESDInputHandler();
+  mgr->SetInputEventHandler  (inpHandler);
+  
+  // Output
+  
+  AliESDHandler* esdHandler   = new AliESDHandler();
+  mgr->SetOutputEventHandler(esdHandler);
+  esdHandler->SetOutputFileName("AliESDfriends_v1.root");
+  // Steering Tasks
+  
+  AliAnalysisTaskFilterFriend* filter = AddTaskFilterFriend();
+  AliAnalysisTaskFilterFriendSecond* filter2 = AddTaskFilterFriendSecond();
+  AliAnalysisTaskAddObject* add = AddTaskAddObject();
+  
+  // Detector Tasks
+  
+  AliAnalysisTask* tTPC = AddTaskTPCCalib(runNumber);
+  
+  // Run the analysis
+  
+  if (!mgr->InitAnalysis()) {
+    printf("Analysis cannot be started, returning\n");
+    return;
+  }
+  
+  mgr->PrintStatus();
+  mgr->StartAnalysis("local", chain);
+  
+  return;
+}
diff --git a/PWGPP/CalibMacros/CPass1/runPassX.sh b/PWGPP/CalibMacros/CPass1/runPassX.sh
new file mode 100644 (file)
index 0000000..1feedd0
--- /dev/null
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+# Script to run:
+#    1. reconstruction
+#    2. calibration and friend track filtering
+#    3. tag creation
+#
+# Files assumed to be in working directory:
+# rec.C               - reconstruction macro
+# runCalibTrain.C     - calibration/filtering macro
+# Arguments:
+#    1  - raw data file name
+#    2  - number of events to be processed
+#    3  - run number 
+
+# example:
+# runPassX.sh raw.root  50  104892
+
+#ALIEN setting
+entries=1000
+# $1 = raw input filename
+runnum=`echo $1 | cut -d "/" -f 6`
+
+#Local setting
+#entries=$2
+#runnum=$3
+
+echo File to be  processed $1
+echo Number of events to be processed $entries
+
+echo ">>>>>>>>> PATH is..."
+echo $PATH
+echo ">>>>>>>>> LD_LIBRARY_PATH is..."
+echo $LD_LIBRARY_PATH
+echo ">>>>>>>>> rec.C is..."
+cat rec.C
+echo
+
+echo ">>>>>>> Running AliRoot to reconstruct $1. Run number is $runnum..."
+aliroot -l -b -q rec.C\(\"alien://$1\"\) 2>&1 | tee rec.log
+
+echo ">>>>>>> Running AliRoot to make calibration..."
+aliroot -l -b -q  runCalibTrain.C\(\"$runnum\"\)   2>&1 | tee calib.log
+
+echo ">>>>>>> Running AliRoot to generate Tags..."
+aliroot -l -b -q tag.C\(\) 2>&1 | tee tag.log
diff --git a/PWGPP/CalibMacros/CPass1/tag.C b/PWGPP/CalibMacros/CPass1/tag.C
new file mode 100644 (file)
index 0000000..d434fa6
--- /dev/null
@@ -0,0 +1,120 @@
+void tag() {
+  const char* turl = gSystem->Getenv("ALIEN_JDL_OUTPUTDIR");
+
+  gSystem->Load("libNet.so");
+  gSystem->Load("libMonaLisa.so");
+  new TMonaLisaWriter(0, "GridAliRoot-tag.C", 0, 0, "global");
+
+  TString fESDFileName = "alien://";
+  fESDFileName += turl;
+  fESDFileName += "/AliESDs.root";  
+
+  TString fGUID = 0;
+  GetGUID(fGUID);
+
+  gEnv->Print();
+
+  TString fAliroot, fRoot, fGeant;
+  GetVersions(fAliroot,fRoot,fGeant);
+
+  UpdateTag(fAliroot,fRoot,fGeant,fESDFileName,fGUID);
+}
+  
+//_____________________________________//
+GetVersions(TString &fAliroot, TString &froot, TString &fgeant) {
+  const char* fver = gSystem->Getenv("ALIEN_JDL_PACKAGES");
+  TString fS = fver;
+  Int_t fFirst = fS.First("#");
+
+  while(fFirst != -1) {
+    Int_t fTotalLength = fS.Length();
+    TString tmp = fS;
+    TString fS1 = fS(0,fFirst);
+    tmp = fS(fFirst+2,fTotalLength);
+    fS = tmp;
+
+    if(fS1.Contains("Root")) fAliroot = fS1;
+    if(fS1.Contains("ROOT")) froot = fS1;
+    if(fS1.Contains("GEANT")) fgeant = fS1;
+
+    if(tmp.Contains("Root")) fAliroot = tmp;
+    if(tmp.Contains("ROOT")) froot = tmp;
+    if(tmp.Contains("GEANT")) fgeant = tmp;
+    
+    fFirst = tmp.First("#");
+  }
+}
+
+//_____________________________________//
+GetGUID(TString &guid) {
+  ofstream myfile ("guid.txt");
+  if (myfile.is_open()) {
+    TFile *f = TFile::Open("AliESDs.root","read");
+    if(f && !f->IsZombie() && f->IsOpen()) {
+      guid = f->GetUUID().AsString();
+      myfile << "AliESDs.root \t"<<f->GetUUID().AsString();
+      cout<<guid.Data()<<endl;
+      myfile.close();
+    }
+    else cout<<"Input file not found"<<endl;
+  }
+  else cout<<"Output file can't be created..."<<endl;
+}
+
+
+//_____________________________________//
+Bool_t UpdateTag(TString faliroot, TString froot, TString fgeant, TString turl, TString guid) {
+  cout<<"> Updating tags...."<<endl;
+
+  const char * tagPattern = "tag.root";
+  // Open the working directory
+  void * dirp = gSystem->OpenDirectory(gSystem->pwd());
+  const char * name = 0x0;
+  // Add all files matching *pattern* to the chain
+  while((name = gSystem->GetDirEntry(dirp))) {
+    cout<<">>> Adding to chain file " << name << "...." << endl;
+    if (strstr(name,tagPattern)) {
+      TFile *f = TFile::Open(name,"read") ;
+      AliRunTag *tag = 0x0;
+      AliEventTag *evTag = 0x0;
+      TTree *fTree = (TTree *)f->Get("T");
+      if (!fTree) { f->Close(); continue; }
+      fTree->SetBranchAddress("AliTAG",&tag);
+   
+      //Defining new tag objects
+      AliRunTag *newTag = 0x0;
+      TTree ttag("T","A Tree with event tags");
+      TBranch * btag = ttag.Branch("AliTAG", &newTag);
+      btag->SetCompressionLevel(9);
+      
+      cout<<">>>>> Found " << fTree->GetEntries() << " entries...." << endl;
+      for(Int_t iTagFiles = 0; iTagFiles < fTree->GetEntries(); iTagFiles++) {
+       fTree->GetEntry(iTagFiles);
+       newTag = new AliRunTag(*tag);
+       newTag->SetAlirootVersion(faliroot);
+       newTag->SetRootVersion(froot);
+       newTag->SetGeant3Version(fgeant);
+       TClonesArray *tagList = newTag->GetEventTags();
+       cout << "Found " << tagList->GetEntries() << " tags" << endl;
+       for(Int_t j = 0; j < tagList->GetEntries(); j++) {
+         evTag = (AliEventTag *) tagList->At(j);
+         evTag->SetTURL(turl);
+         evTag->SetGUID(guid);
+       }
+       ttag.Fill();
+
+       delete tag;
+       delete newTag;
+      }//tag file loop 
+      
+      TFile* ftag = TFile::Open(name, "recreate");
+      ftag->cd();
+      ttag.Write();
+      ftag->Close();
+
+    }//pattern check
+  }//directory loop
+  return kTRUE;
+}
+
diff --git a/PWGPP/CalibMacros/CPass1/validation.sh b/PWGPP/CalibMacros/CPass1/validation.sh
new file mode 100644 (file)
index 0000000..27dcbe1
--- /dev/null
@@ -0,0 +1,75 @@
+#!/bin/sh
+##################################################
+validateout=`dirname $0`
+validatetime=`date`
+validated="0";
+error=1
+
+if [ -z $validateout ]
+then
+    validateout="."
+fi
+cd $validateout;
+validateworkdir=`pwd`;
+
+echo "*******************************************************" >> stdout;
+echo "* AliRoot Validation Script V1.0                      *" >> stdout;
+echo "* Time:    $validatetime " >> stdout;
+echo "* Dir:     $validateout" >> stdout;
+echo "* Workdir: $validateworkdir" >> stdout;
+echo "* ----------------------------------------------------*" >> stdout;
+ls -la ./ >> stdout;
+echo "* ----------------------------------------------------*" >> stdout;
+
+cp stdout stdout.log
+cp stderr stderr.log
+
+##################################################
+if [ -f rec.log ] && [ -f calib.log ] && [ -f AliESDs.root ] && [ -f AliESDfriends_v1.root ] && [ -f Run*.ESD.tag.root ] 
+then 
+sv=`grep -i  "Segmentation violation" *.log`
+if [ "$sv" = "" ]
+    then
+    sf=`grep -i  "Segmentation fault" *.log`
+    if [ "$sf" = "" ]
+        then
+        be=`grep -i  "Bus error" *.log`
+        if [ "$be" = "" ]
+           then
+           ab=`grep -i "Break" *.log`
+           if [ "$ab" = "" ]
+               then
+               fp=`grep -i  "Floating point exception" *.log`
+               if [ "$fp" = "" ]
+                   then
+                   kl=`grep -i  "Killed" *.log`
+                   if [ "$kl" = "" ]
+                       then
+                       bf=`grep -i "busy flag cleared" *.log`
+                       if [ "$bf" = "" ]
+                            then
+                              echo "* ----------------   Job Validated  ------------------*" >> stdout;
+                              error="0";
+                            else
+                               echo "* #             Check Macro failed !                  #" >> stdout;
+                        fi
+                   fi
+               fi
+            fi
+        fi
+    fi
+fi
+else
+    echo "* ########## Job not validated - no rec.log or calib.log or tag.log or AliESDs.root or ESD.tag.root && AliESDfriends.root ###" >> stdout;
+    echo "* ########## Removing all ROOT files from the local directory, leaving only the logs ###" >> stdout;
+    rm -rf *.root
+fi
+if [ "$error" = "1" ] 
+    then
+    echo "* ################   Job not validated ################" >> stdout;
+fi
+echo "* ----------------------------------------------------*" >> stdout;
+echo "*******************************************************" >> stdout;
+sleep 15;
+cd -
+exit $error