Merge remote-tracking branch 'remotes/origin/master' into TPCdev
authormivanov <marian.ivanov@cern.ch>
Wed, 23 Apr 2014 14:46:49 +0000 (16:46 +0200)
committermivanov <marian.ivanov@cern.ch>
Wed, 23 Apr 2014 14:46:49 +0000 (16:46 +0200)
Conflicts:
STEER/ESD/AliESDtrack.cxx

38 files changed:
PWGPP/CalibMacros/AliOCDBToolkit.cxx [new file with mode: 0644]
PWGPP/CalibMacros/AliOCDBtoolkit.sh [new file with mode: 0644]
PWGPP/CalibMacros/CPass0/runCPass0.sh
PWGPP/CalibMacros/README.txt [new file with mode: 0644]
PWGPP/CalibMacros/dumpObject.C [new file with mode: 0644]
PWGPP/CalibMacros/xmldump [new file with mode: 0644]
PWGPP/QA/Tracking/ExpertQA/makeTrendingPlots.C
PWGPP/TPC/macros/filterPIDSelected.C
PWGPP/macros/runFilteringTask.C
STAT/TStatToolkit.cxx
STAT/TStatToolkit.h
STEER/CDB/AliCDBEntry.cxx
STEER/CDB/AliCDBEntry.h
STEER/CDB/AliCDBId.cxx
STEER/CDB/AliCDBId.h
STEER/CDB/AliCDBLocal.cxx
STEER/CDB/AliOCDBtoolkit.cxx [new file with mode: 0644]
STEER/CDB/AliOCDBtoolkit.h [new file with mode: 0644]
STEER/CDBLinkDef.h
STEER/CMakelibCDB.pkg
STEER/ESD/AliESDtrack.cxx
STEER/ESD/AliESDtrack.h
STEER/STEERBase/AliExternalTrackParam.cxx
STEER/STEERBase/AliExternalTrackParam.h
STEER/STEERBase/AliTPCdEdxInfo.cxx
STEER/STEERBase/AliTPCdEdxInfo.h
TPC/Rec/AliTPCtracker.cxx
TPC/Upgrade/macros/makeResidualSpaceChargeOCDB.C
TPC/fastSimul/AliTPCclusterFast.cxx
TPC/fastSimul/simul.C
TPC/fastSimul/simul.sh
TPC/macros/CalibratedEdxRegion.C [deleted file]
TPC/stressTest/stressTest.sh
TRD/AliTRDReconstructor.cxx
TRD/AliTRDReconstructor.h
TRD/AliTRDseedV1.cxx
TRD/AliTRDtrackerV1.cxx
cmake/CMakelinuxx8664gcc.cmake

diff --git a/PWGPP/CalibMacros/AliOCDBToolkit.cxx b/PWGPP/CalibMacros/AliOCDBToolkit.cxx
new file mode 100644 (file)
index 0000000..b54c6d8
--- /dev/null
@@ -0,0 +1,396 @@
+/*
+
+  Primary goal of the proposal was to provide functionality to browse and compare the content of the OCDB
+  specified by different means.
+
+  a.) galice.root               - as currently implemented by Ruben in MC (or any file with cdbMap, and cdbList)
+  b.) AliESDs.root              - for the reconstructed data
+  c.) ocdb snapshot             - as used for grid productions
+  d.) TMap(s)                   - as used internally in galice.root and AliESDs,root  
+  e.) log file (if possible)    - looks logs aways used similar syntax, tested and working
+  f.) C macro                   - custom macro
+
+  Content comparison should be done:
+  a.) on the level of symbolic links 
+  b.) on the level of content itself 
+  - by by byte comparison dif
+  - data member by data member comparison
+
+  Implementation assumption:
+  All input formats (a .. f) will  be converted to the TMap storages and TList if AliCDBIds 
+
+
+  Example usage:
+  export mcProd=$ALICE_ROOT/PWGPP/CalibMacros/
+  .L  $mcProd/AliOCDBToolkit.cxx+
+  MakeDiffExampleUseCase();
+
+
+*/
+
+// STD
+#include <iostream>
+#include <algorithm>
+#include <sstream>
+#include <stdexcept>
+#include <functional>
+//
+#include "TSystem.h"
+#include "TObjArray.h"
+#include "TString.h"
+#include "TTree.h"
+#include "TMessage.h"
+//
+#include "AliCDBManager.h"
+#include "AliCDBEntry.h"
+
+//
+//
+//
+
+
+void MakeDiffExampleUseCase();    // example usage
+//
+//
+Bool_t   ParseInfoFromOcdbString(TString ocdbString, TString &ocdbPath, Int_t &run0, Int_t &run1, Int_t &version, Int_t &subVersion);   
+Bool_t   ParseInfoFromOcdbString(TString ocdbString, AliCDBId &cdbId);
+TList  * ConvertListStringToCDBId(const TList *cdbList0); 
+
+void LoadOCDBFromLog(const char *logName, Int_t verbose);
+void LoadOCDBFromMap(const TMap *cdbMap, const TList *cdbList);
+void MakeDiff(const TMap *cdbMap0, const TList *cdbList0, const TMap *cdbMap1, const TList *cdbList1, Int_t verbose);
+void DumpOCDB(const TMap *cdbMap0, const TList *cdbList0);
+
+
+
+void MakeDiffExampleUseCase(){
+  //
+  // Example usage for the MC 
+  // To run example case, assuming presence of following files in working directory: 
+  //    - rec.log        
+  //    - galice.root   
+  //    - AliESDs.root
+  //
+  AliCDBManager * man = AliCDBManager::Instance();
+  LoadOCDBFromLog("rec.log",0);
+  const TMap *cdbMapLog= man->GetStorageMap();        // this is map of 
+  const TList *cdbListLog=man->GetRetrievedIds();     // this is list of AliCDBId
+  //  TList *cdbListLog0=man->GetRetrievedIds();     // this is list of AliCDBId
+  //
+  TFile *fmc = TFile::Open("galice.root");
+  TMap *cdbMapMC= (TMap*)fmc->Get("cdbMap");          // 
+  TList *cdbListMC0= (TList*)fmc->Get("cdbList");     // this is list of TObjStrings
+  TList *cdbListMC = ConvertListStringToCDBId(cdbListMC0);        // convert to the TObjArray of AliCDBids
+  //
+  TFile *fesd = TFile::Open("AliESDs.root");
+  TList *listESD = ((TTree*)fesd->Get("esdTree"))->GetUserInfo();
+  TMap *cdbMapESD= (TMap*)listESD->FindObject("cdbMap");  
+  TList *cdbListESD0= (TList*)listESD->FindObject("cdbList"); // this is list of TObjStrings
+  TList *cdbListESD = ConvertListStringToCDBId(cdbListESD0);              // convert to the TObjArray  of AliCDBids
+  //
+  //
+  //
+  printf("\n\n");
+  printf("Diff log>>>ESD\n\n:");
+  MakeDiff(cdbMapLog, cdbListLog, cdbMapESD, cdbListESD,0);
+  printf("\n\n");
+  printf("Diff ESD>>>log\n\n:");
+  MakeDiff(cdbMapESD, cdbListESD,cdbMapLog, cdbListLog,0);
+  // 
+  printf("\n\n");
+  printf("Diff ESD>>>MC\n\n:");
+  MakeDiff(cdbMapMC, cdbListMC, cdbMapESD, cdbListESD,0);
+}
+
+
+void DumpOCDBAsTxt(const TString fInput,const TString fType){
+    TFile *file;
+    const TMap *cdbMap;
+    const TList *cdbList;
+
+
+    if(fType.EqualTo("MC",TString::kIgnoreCase)){
+        file = TFile::Open(fInput.Data());
+        cdbMap = (TMap*)file->Get("cdbMap");          // 
+        TList *cdbListMC0 = (TList*)file->Get("cdbList");     // this is list of TObjStrings
+        cdbList = ConvertListStringToCDBId(cdbListMC0);        // convert to the TObjArray of AliCDBids
+    } 
+    else if(fType.EqualTo("ESD",TString::kIgnoreCase)){
+        file = TFile::Open(fInput.Data());
+        TList *listESD = ((TTree*)file->Get("esdTree"))->GetUserInfo();
+        cdbMap = (TMap*)listESD->FindObject("cdbMap");  
+        TList *cdbListESD0= (TList*)listESD->FindObject("cdbList"); // this is list of TObjStrings
+        cdbList = ConvertListStringToCDBId(cdbListESD0);              // convert to the TObjArray  of AliCDBids
+    }
+    else if(fType.EqualTo("log",TString::kIgnoreCase)){
+        AliCDBManager * man = AliCDBManager::Instance();
+        LoadOCDBFromLog(fInput.Data(),0);
+        cdbMap = man->GetStorageMap();        // this is map of 
+        cdbList =man->GetRetrievedIds();     // this is list of AliCDBId
+    }
+    else{
+        printf("unsupported option: %s",fType.Data());
+        return;
+    }
+    cout <<"BEGINDUMP:" << endl;
+    DumpOCDB(cdbMap,cdbList);
+}
+
+
+Bool_t ParseInfoFromOcdbString(TString ocdbString, TString &ocdbPath, Int_t &run0, Int_t &run1, Int_t &version, Int_t &subVersion){
+  //
+  // Parse OCDB id string and provide basic ocdb information
+  //
+  //  a.) parse ocdbPath
+  Int_t indexBeginPath= ocdbString.Index("path: ")+7;
+  if (indexBeginPath<0) return kFALSE;
+  Int_t indexEndPath=ocdbString.Index(";",indexBeginPath);
+  if (indexEndPath<0) return kFALSE;
+  ocdbPath=TString(&(ocdbString.Data()[indexBeginPath]), indexEndPath-indexBeginPath-1);
+  // b.) parse runRange
+  Int_t indexRun0= ocdbString.Index(": [",indexEndPath)+3;
+  if (indexRun0<0) return kFALSE;
+  Int_t indexRun1= ocdbString.Index(",",indexRun0)+1;
+  if (indexRun1<0) return kFALSE;
+  run0=atoi(&(ocdbString.Data()[indexRun0]));
+  run1=atoi(&(ocdbString.Data()[indexRun1]));
+  AliCDBRunRange runRange(run0,run1);
+  //c.) parse version, subversion
+  Int_t indexVersion= ocdbString.Index("version: v",indexRun1)+10;
+  if (indexVersion<0) return kFALSE;
+  Int_t indexSubVersion= ocdbString.Index("_s",indexVersion)+2;
+  if (indexSubVersion<0) return kFALSE;
+  version=atoi(&(ocdbString.Data()[indexVersion]));
+  subVersion=atoi(&(ocdbString.Data()[indexSubVersion]));
+  return kTRUE;
+}
+
+Bool_t ParseInfoFromOcdbString(TString ocdbString, AliCDBId &cdbId){
+  //
+  // Parse OCDB id string and provide basic ocdb information and fillcdbID object
+  //
+  TString ocdbPath;
+  Int_t run0=0, run1=0;
+  Int_t version=0, subVersion=0;
+  Bool_t parseStatus = ParseInfoFromOcdbString(ocdbString, ocdbPath, run0,run1,version,subVersion); 
+  if (parseStatus) {
+    AliCDBRunRange runRange(run0,run1);
+    cdbId=AliCDBId(ocdbPath.Data(),runRange,version,subVersion);
+    AliCDBId* id = AliCDBId::MakeFromString(ocdbString);
+    cdbId=*id;
+    delete id;
+  }
+  //
+  return parseStatus;
+}
+
+TList  * ConvertListStringToCDBId(const TList *cdbList0){
+  //
+  // Convert input  list of the TObjString to list to AliCDBid 
+  //
+  Int_t entriesList0=cdbList0->GetEntries();
+  TList * array0 = new TList();
+  AliCDBId tmp0;
+  for (Int_t ientry0=0; ientry0<entriesList0; ientry0++){
+    if (cdbList0->At(ientry0)==0) continue;
+    Bool_t isId =  cdbList0->At(ientry0)->IsA()->InheritsFrom("AliCDBId");
+    if (isId){
+      array0->AddLast(cdbList0->At(ientry0));
+    }else{
+      Bool_t isString =  cdbList0->At(ientry0)->IsA()->InheritsFrom("TObjString");
+      if (isString){
+       TObjString* sid0 = dynamic_cast<TObjString*> (cdbList0->At(ientry0));
+       Bool_t status =  ParseInfoFromOcdbString(sid0->String(), tmp0);
+       if (!status) continue;
+       array0->AddLast(new AliCDBId(tmp0));
+      }
+    }
+  }
+  return array0;  
+}
+
+
+
+void LoadOCDBFromLog(const char *logName, Int_t verbose){
+  //
+  // Initilaize OCDB
+  // Load OCDB setting as specified in log
+  // Assuming fixed version of the log 
+  // AliCDBManager is initilaized - ocdbMap and ID list can be exported
+  //
+
+  // Parsing/loading sequence:
+  //    0.) SetDefault storage  *** Default Storage URI:
+  //    1.) SetSpecific storage  *** Specific storage
+  //    2.) SetRunNumber  Run number:
+  //    3.) Set used IDs
+  //
+  AliCDBManager * man = AliCDBManager::Instance();
+  //
+  // 0.) SetDefault storage  *** Default Storage URI:
+  // 
+  TString  defaultOCDB = gSystem->GetFromPipe(TString::Format("cat %s| grep \"Storage URI:\"",logName).Data());
+  TObjArray *array = defaultOCDB.Tokenize("\"");
+  man->SetDefaultStorage(array->Last()->GetName());
+  delete array;
+  //
+  // 1.) SetSpecific storage  *** Specific storage
+  //
+  TString  specificStorage  = gSystem->GetFromPipe(TString::Format("cat %s| grep \"Specific storage\"",logName).Data());
+  array = specificStorage.Tokenize("\"");
+  Int_t entries = array->GetEntries();
+  for (Int_t i=1; i<entries-2; i+=4){    
+    // add protection here line shuld be in expected format
+    if (verbose&2>0) printf("%s\t%s\n",array->At(i)->GetName(),array->At(i+2)->GetName());    
+    man->SetSpecificStorage(array->At(i)->GetName(),array->At(i+2)->GetName());
+  }
+  delete array;
+  //
+  // 2.) SetRunNumber  Run number:
+  //
+  TString  runLine  = gSystem->GetFromPipe(TString::Format("cat %s| grep \"I-AliCDBManager::Print: Run number =\"",logName).Data());
+  array = runLine.Tokenize("=");
+  Int_t run = 0;
+  if (array->GetEntries()>1) run=atoi(array->At(1)->GetName()); 
+  delete array;
+  man->SetRun(run);  
+  //
+  // 3.) Set used IDs
+  //   
+  TString  ids =   gSystem->GetFromPipe(TString::Format("cat %s| grep I-AliCDB | grep path| grep range | grep version", logName).Data());
+  array= ids.Tokenize("\n");
+  entries = array->GetEntries();
+  //
+  for (Int_t i=0; i<entries; i++){
+    //
+    TString ocdbString = array->At(i)->GetName();
+    TString ocdbEntry;
+    TString ocdbPath;
+    Int_t run0=0, run1=0;
+    Int_t version=0, subVersion=0;
+    Bool_t parseStatus = ParseInfoFromOcdbString(ocdbString, ocdbPath, run0,run1,version,subVersion); 
+    if (!parseStatus) continue;
+    AliCDBRunRange runRange(run0,run1);
+    //
+    if ((verbose&2)!=0) {
+      printf("%s/Run%d_%d_v%d_s%d.root\n",ocdbPath.Data(),run0,run1,version,subVersion); 
+    }
+    try {
+      AliCDBEntry*entry= man->Get(ocdbPath.Data(),runRange,version,subVersion);
+    } catch(const exception &e){
+      cerr << "OCDB retrieval failed!" << endl;
+      cerr << "Detailes: " << e.what() << endl;
+    }
+  }  
+  if ((verbose&1)!=0){
+    man->Print();
+    man->GetStorageMap()->Print();
+    man->GetRetrievedIds()->Print(); 
+  }
+}
+
+
+void LoadOCDBFromMap(TMap */*cdbMap*/, TList */*cdbList*/){
+  //
+  // Initilaize OCDB
+  // Load OCDB setting as specified in maps
+  // Or Do we have already implementation in AliCDBanager?
+}
+
+
+
+void MakeDiff(const TMap *cdbMap0, const TList *cdbList0, const TMap *cdbMap1, const TList *cdbList1, Int_t verbose){
+  //
+  //
+  // Print difference between the 2 ocdb maps
+  // Input:
+  //   maps and list charactireizing OCDB setup  
+  // Output:
+  //   To be decided, currently it is the teinal output
+  //
+  Int_t entriesList0=cdbList0->GetEntries();
+  Int_t entriesList1=cdbList1->GetEntries();
+  //
+  for (Int_t ientry0=0; ientry0<entriesList0; ientry0++){
+    AliCDBId *id0    = dynamic_cast<AliCDBId*> (cdbList0->At(ientry0));
+    AliCDBId *id1=0;
+    for (Int_t ientry1=0; ientry1<entriesList1; ientry1++){
+      AliCDBId *cid1    = dynamic_cast<AliCDBId*> (cdbList1->At(ientry1));
+      //id0.Print();
+      //cid1.Print();
+      if (cid1->GetPath().Contains(id0->GetPath().Data())==0) continue;
+      id1=cid1;
+    }
+    if (!id1) {
+      printf("Missing entry\t");
+      id0->Print();
+      continue;
+    }
+    Bool_t isOK=kTRUE;
+    if (id0->GetFirstRun()!= id1->GetFirstRun() ||id0->GetLastRun()!= id1->GetLastRun()){
+      printf("Differrent run range\n");
+      id0->Print();
+      id1->Print();
+    }    
+    if (id0->GetVersion()!= id1->GetVersion() ||id0->GetSubVersion()!= id1->GetSubVersion()){
+      printf("Differrent version\n");
+      id0->Print();
+      id1->Print();
+    }    
+  }
+}
+
+void DumpOCDB(const TMap *cdbMap0, const TList *cdbList0){
+  //
+  // Dump the OCDb configuatation as formated text file 
+  // with following collumns
+  // cdb name  prefix cdb path
+  // OCDB entries are sorted alphabetically
+  // e.g:
+    // TPC/Calib/RecoParam /hera/alice/jwagner/software/aliroot/AliRoot_TPCdev/OCDB/ TPC/Calib/RecoParam/Run0_999999999_v0_s0.root $SIZE_AliCDBEntry_Object $HASH_AliCDBEntry_Object
+
+    AliCDBManager * man = AliCDBManager::Instance();
+    TIter next(cdbList0);
+    AliCDBId *CDBId;
+    TString cdbName;
+    TString cdbPath;
+    TObjString *ostr;
+    AliCDBEntry *cdbEntry;
+    UInt_t hash;
+    TMessage * file;
+    Int_t size; 
+
+    while ((CDBId  =(AliCDBId*) next())){
+        cdbName = CDBId->GetPath();
+        ostr = (TObjString*)cdbMap0->GetValue(cdbName.Data());
+        if(!ostr) ostr = (TObjString*)cdbMap0->GetValue("default");
+        cdbPath = ostr->GetString();
+        if(cdbPath.Contains("local://"))cdbPath=cdbPath(8,cdbPath.Length()).Data();
+
+        cdbEntry = (AliCDBEntry*) man->Get(*CDBId);
+        TObject *obj = cdbEntry->GetObject();
+        file = new TMessage(TBuffer::kWrite);
+        file->WriteObject(obj);
+        size = file->Length();
+        if(!obj){
+            printf("object %s empty!\n",cdbName.Data());
+            continue;
+        }
+        hash = TString::Hash(file->Buffer(),size);
+        printf("%s\t%s\t%s/Run%d_%d_v%d_s%d.root\t%d\t%u\n",
+                cdbName.Data(),
+                cdbPath.Data(),
+                cdbName.Data(),
+                CDBId->GetFirstRun(),
+                CDBId->GetLastRun(),
+                CDBId->GetVersion(),
+                CDBId->GetSubVersion(),
+                size,
+                hash
+              );
+        //if(!(CDBId->GetPathLevel(0)).Contains("TPC")) continue;
+        //cout << CDBId.ToString() << endl;
+
+        delete file;
+    }
+}
diff --git a/PWGPP/CalibMacros/AliOCDBtoolkit.sh b/PWGPP/CalibMacros/AliOCDBtoolkit.sh
new file mode 100644 (file)
index 0000000..87ce236
--- /dev/null
@@ -0,0 +1,198 @@
+#!/bin/bash
+#
+# Shell script to compare content of the OCDB entries.
+#
+# ocdbMakeTable() 
+#       Usage: bash $inputFile $flag $outputFile
+# dumpObject()
+#       Usage: bash $inputFile $object_name $dump_type [XML/MI] $outfile
+# diffObject
+#       Usage: bash $inputFile1 $inputFile2 $object_name $dump_type [XML/MI] $outfile
+# Example usage:  see example functions below
+
+ocdbMakeTable(){
+#
+# create a text file with the OCDB setupt descriptors#
+#
+# Input: 
+#   $1 inputFile name
+#   $2 flag type of the input file
+#   flags: 
+#   log file = "log"
+#   AliESDs.root = "ESD"
+#   galice.root = "MC"
+# Output:
+#   $3 output file name
+    if [ $# -lt 3 ] ; then
+        echo "Usage: $0 \$inputFile \$flag \$outputFile"
+        return 1
+    fi
+    local inFile=${1}
+    local inFlag=${2}
+    local outFile=${3}
+    shift 3
+    if [ ! -f ${inFile} ] ; then 
+        echo ${inFile} not found!
+        return 1
+    fi
+    if [ -f ${outFile} ] ; then 
+        >${outFile}
+    fi
+
+    tmpscript=$(mktemp)
+    cat > ${tmpscript} <<HEREDOC
+        {
+            AliOCDBtoolkit::DumpOCDBAsTxt("${inFile}","${inFlag}","${outFile}");
+        }
+HEREDOC
+
+    aliroot -l -q -b ${tmpscript} 
+    sleep 60 && rm ${tmpscript} &
+    return 1
+}
+
+
+dumpObject(){
+#
+#
+#  Input:
+#    $1 path
+#    $2 obj name 
+#    $3 type of the dump (XML or MI recursive dump )
+#  Output:
+#    $4 output file name   
+    if [ $# -lt 4 ] ; then
+        echo "Usage: $0 \$inputFile \$object_name \$dump_type [XML/MI] \$outfile"
+        return 1
+    fi
+    local inFile=${1}
+    local fobject=${2}
+    local ftype=${3}
+    local outFile=${4}
+    shift 4
+    if [ ! -f ${inFile} ] ; then 
+        echo ${inFile} not found!
+        return 1
+    fi
+    if [ -f ${outFile} ] ; then 
+        >${outFile}
+    fi
+    if [ ${ftype} = "XML" ] ; then
+        isXML=kTRUE
+    elif [ ${ftype} = "MI" ] ; then
+        isXML=kFALSE
+    else
+        echo "option ${ftype} not recognized! Use \"XML\" or \"MI\"!"
+        return 1
+    fi
+    tmpscript=$(mktemp)
+    cat > ${tmpscript} <<HEREDOC
+        {
+            AliOCDBtoolkit::DumpOCDBFile("${inFile}","${outFile}",1,${isXML});
+        }
+HEREDOC
+
+    aliroot -l -q -b ${tmpscript} 
+    sleep 60 && rm ${tmpscript} &
+    return 1
+}
+
+diffObject(){
+#
+#
+#  Input:
+#    $1 path0
+#    $2 path1
+#    $3 obj name 
+#    $4 type of the dump (xml or MI recursive dump )
+#  Output:
+#    $5 output diff file name   
+    if [ $# -lt 5 ] ; then
+        echo "Usage: $0 \$inputFile1 \$inputFile2 \$object_name \$dump_type [XML/MI] \$outfile"
+        return 1
+    fi
+    local inFile1=${1}
+    local inFile2=${2}
+    local fobject=${3}
+    local ftype=${4}
+    local outFile=${5}
+    shift 5
+    local tmp1=$(mktemp)
+    local tmp2=$(mktemp)
+    if [ ${ftype} = "XML" ] ; then
+        isXML=kTRUE
+        tmp1="${tmp1}.xml"
+        tmp2="${tmp2}.xml"
+    elif [ ${ftype} = "MI" ] ; then
+        isXML=kFALSE
+    else
+        echo "option ${ftype} not recognized! Use \"XML\" or \"MI\"!"
+        return 1
+    fi
+    dumpObject ${inFile1} ${fobject} ${ftype} ${tmp1%.xml}
+    dumpObject ${inFile2} ${fobject} ${ftype} ${tmp2%.xml}
+    diff ${tmp1} ${tmp2} >${outFile}
+    rm ${tmp1} ${tmp2} 2>/dev/null
+    rm "${tmp1}.xml" "${tmp2}.xml" 2>/dev/null
+    return 1
+}
+
+dumpOCDBDiffTable(){
+#
+# Dump  differences between the OCDB tables -comparison based on the hash values of OCDB entries
+# Input:
+#   $1  - list 1
+#   $2  - list 2
+# Output:
+#   difference is stdout
+
+    list1=$1
+    list2=$2
+    shift 2
+    cdbName=$(cut -f1 $list1)
+    for i in $cdbName ; do
+        line1="$(grep $i $list1)"
+        line2="$(grep $i $list2)"
+        if [ -z "${line2}" ] ; then
+            echo $i not found in $list2!
+            continue
+        fi
+        match1=$(echo $line1 | cut -d' ' -f 5)
+        match2=$(echo $line2 | cut -d' ' -f 5)
+        if [ "$match1" -ne "$match2" ] ; then
+            echo $i doesnt match:
+            echo $(echo $line1| awk '{print $2 "/" $3}') \#hash: $match1
+            echo $(echo $line2| awk '{print $2 "/" $3}') \#hash: $match2
+            echo 
+        fi
+    done
+}
+
+
+
+
+
+#
+# Example usage+ developer test routines. 
+#
+
+example1(){
+    ocdbMakeTable "/hera/alice/jwagner/simulations/benchmark/aliroot_tests/ppbench/rec.log" "log" "testout"
+}
+example2(){
+    dumpObject "/hera/alice/jwagner/OCDB/temp/TPC/Calib/RecoParam/Run0_999999999_v0_s0.root" "object" "XML" "testout2XML"
+    dumpObject "/hera/alice/jwagner/OCDB/temp/TPC/Calib/RecoParam/Run0_999999999_v0_s0.root" "object" "MI" "testout2MI" 
+}
+example3(){
+    file1="/hera/alice/jwagner/OCDB/temp/TPC/Calib/RecoParam/Run0_999999999_v0_s0.root"
+    file2="$ALICE_ROOT/OCDB/TPC/Calib/RecoParam/Run0_999999999_v0_s0.root"
+    diffObject ${file1} ${file2} "object" "MI" "testdiffMI"
+    diffObject ${file1} ${file2} "object" "XML" "testdiffXML"
+}
+
+developerTest(){
+    source /hera/alice/jwagner/software/aliroot/loadMyAliroot.sh TPCdev
+    example1
+    example2
+    example3
+}
index eca44f0..2d69be8 100644 (file)
@@ -93,7 +93,7 @@ echo "*! Exit code of recCPass0.C: $exitcode"
 
 if [ $exitcode -ne 0 ]; then
     exit $exitcode
-fi
+fi 
 
 mv syswatch.log syswatch_rec.log
 
diff --git a/PWGPP/CalibMacros/README.txt b/PWGPP/CalibMacros/README.txt
new file mode 100644 (file)
index 0000000..a2255af
--- /dev/null
@@ -0,0 +1,10 @@
+CPass0 - CPass0 calibration macros
+CPass1 - CPass1 calibration macros
+
+
+Temporary files: functionality from macros below to be combined to the one toolikit class
+
+AliOCDBToolkit.cxx - macros with set of function to compare the OCDB content
+dumpObject.C       - macros with function do recorsive dump content of obeject 
+                     (Dictionary, reflection based)
+
diff --git a/PWGPP/CalibMacros/dumpObject.C b/PWGPP/CalibMacros/dumpObject.C
new file mode 100644 (file)
index 0000000..01b1ee6
--- /dev/null
@@ -0,0 +1,294 @@
+/*
+  //
+  // Function to dump recursivally in human readable format, content of the objects + example use case
+  // 
+  //
+  .L  $mcProd/dumpObject.C+
+  ExampleUse(); > AliTPCClusterParam.dump
+  AliTPCRecoParam param; 
+  DumpObjectRecursive(&param); >> AliTPCRecoParam.dump
+
+  Use case examples 
+  1.) compare oontent of alignent OCDB files for differnt yers
+  2.) compare ClusterParam for different periods
+   
+=================================================================================================================
+  // 1.)
+  // Compare alignment example:
+  // Compare TPC alignemnt 2013 and 2010
+  //
+  DumpOCDBFile("/cvmfs/alice.gsi.de/alice/data/2013/OCDB/TPC/Align/Data/Run0_999999999_v1_s0.root","TPCalign2013.dump",1);
+  DumpOCDBFile("/cvmfs/alice.gsi.de/alice/data/2010/OCDB/TPC/Align/Data/Run0_999999999_v1_s0.root","TPCalign2010.dump",1);
+  diff  TPCalign2013.dump TPCalign2010.dump > TPCalign2013_TPCalign2010.diff
+  //
+  //    
+=================================================================================================================
+//  2.) 
+  // Compare CluterParam OCDB etry
+  //
+  DumpOCDBFile("/cvmfs/alice.gsi.de/alice/data/2010/OCDB/TPC/Calib/ClusterParam/Run131541_999999999_v2_s0.root","2010_TPC_Calib_ClusterParam_Run131541_999999999_v2_s0.dump",1);
+  DumpOCDBFile("/cvmfs/alice.gsi.de/alice/data/2010/OCDB/TPC/Calib/ClusterParam/Run0_999999999_v1_s0.root","2010_TPC_Calib_ClusterParam_Run0_999999999_v1_s0.dump",1);
+  DumpOCDBFile("/cvmfs/alice.gsi.de/alice/data/2013/OCDB/TPC/Calib/ClusterParam/Run0_999999999_v1_s0.root","2013_TPC_Calib_ClusterParam_Run0_999999999_v1_s0.dump",1);
+  
+  diff 2010_TPC_Calib_ClusterParam_Run131541_999999999_v2_s0.dump 2010_TPC_Calib_ClusterParam_Run0_999999999_v1_s0.dump
+
+
+*/
+#if !defined(__CINT__) || defined(__MAKECINT__)
+#include "TMath.h"
+#include "TFile.h"
+#include "TTree.h"
+#include <TVectorF.h>
+#include <TLinearFitter.h>
+#include <TH1F.h>
+#include <TH3F.h>
+#include <TProfile2D.h>
+#include <TVectorD.h>
+#include <TObjArray.h>
+#include "THnBase.h"
+#include "TRealData.h"
+#include "TDataMember.h"
+#include "TClass.h"
+#include "AliCDBEntry.h"
+#include "TObjArray.h"
+#include "TNamed.h"
+#include "TROOT.h"
+#endif
+
+void DumpObjectRecursive(TObject *obj);
+void DumpObjectRecursive(TObject *obj, TString prefix, Int_t &counterRec);
+
+void ExampleUse(){
+  //
+  //
+  //
+  TFile *f = TFile::Open("/cvmfs/alice.gsi.de/alice/simulation/2008/v4-15-Release/Residual/TPC/Calib/ClusterParam/Run127712_130850_v3_s0.root");
+  //TFile *f = TFile::Open("./OCDB_NoClustersBelowThreshold/TPC/Calib/RecoParam/Run127712_130850_v0_s0.root");
+  AliCDBEntry * entry = (AliCDBEntry*)f->Get("AliCDBEntry");
+  TObject  *obj = ( TObject*)entry->GetObject();
+  DumpObjectRecursive(obj);
+  //
+  //
+}
+
+void DumpOCDBFile(const char *finput , const char *foutput, Bool_t dumpMetaData, Bool_t xml){
+  //
+  //  
+  //  DumpOCDBFile("$ALICE_ROOT/OCDB/ITS/Align/Data/Run0_999999999_v0_s0.root", "ITS_Align_Data_Run0_999999999_v0_s0.dump")
+  //
+  if (finput==0) return ;
+  TFile *falignITS  = TFile::Open(finput);
+  AliCDBEntry *entry  = (AliCDBEntry*)falignITS->Get("AliCDBEntry");
+  if (!entry) return; 
+  TObject *obj = ((AliCDBEntry*)falignITS->Get("AliCDBEntry"))->GetObject();  
+
+  //
+  if (!xml){
+    if (dumpMetaData) gROOT->ProcessLine(TString::Format("((TObject*)%p)->Dump(); >%s",entry, foutput).Data());
+    if (!obj) return;
+    gROOT->ProcessLine(TString::Format("DumpObjectRecursive((TObject*)%p); >>%s",obj, foutput).Data());
+  }
+  if (xml){
+    TFile * f = TFile::Open(TString::Format("%s.xml",foutput).Data(),"recreate");
+    if (dumpMetaData) entry->Write("AliCDBEntry");
+    else obj->Write("AliCDBEntry");
+    f->Close();
+  }
+}
+
+
+
+void DumpObjectRecursive(TObject *obj){
+  //
+  //
+  //
+  Int_t counterRec=0;
+  printf("==> Dumping object at: %p, name=%s, class=%s)\n", obj, obj->GetName(), (obj->IsA()->GetName()));
+  DumpObjectRecursive(obj, TString(obj->IsA()->GetName())+".",counterRec);
+}
+//
+//
+//
+void DumpObjectRecursive(TObject *obj, TString prefix, Int_t &counterRec){
+  //
+  // Recursive dump of the TObject
+  // Dump all basic types and follow pointers to the objects
+  // current limitation:
+  //    a.) clases and structures not derived from TObject not followed (to fix)
+  //    b.) dynamic arrays not followed
+  //    c.) std maps,array ....  not followed
+  //    
+  //
+  if (!obj) return;
+  //
+  // Special case of Collection classes
+  //
+  if (obj->IsA()->InheritsFrom(TCollection::Class())) {
+    TIter myiter((TCollection*)obj);
+    TObject  *arObject=0;
+    Int_t counter=0;
+    while ((arObject = (TObject*)myiter.Next())) {
+      TString prefixArr = TString::Format("%s[%d]",prefix.Data(),counter);
+      DumpObjectRecursive(arObject,prefixArr,counterRec);
+      counter++;
+    } 
+    counterRec++;
+    return;
+  }
+
+  TClass * cl = obj->IsA();
+  if (!(cl->GetListOfRealData())) cl->BuildRealData();
+  TRealData* rd = 0;
+  TIter next(cl->GetListOfRealData());  
+  while ((rd = (TRealData*) next())) {
+    counterRec++;
+    TDataMember* dm = rd->GetDataMember();
+    TDataType* dtype = dm->GetDataType();
+    Int_t offset = rd->GetThisOffset();
+    char* pointer = ((char*) obj) + offset;
+    
+    if (dm->IsaPointer()) {
+      // We have a pointer to an object or a pointer to an array of basic types.
+      TClass* clobj = 0;
+      if (!dm->IsBasic()) {
+       clobj = TClass::GetClass(dm->GetTypeName());
+      }
+      if (clobj) {
+       // We have a pointer to an object.
+       //
+       if (!clobj->InheritsFrom(TObject::Class())) {
+         // It must be a TObject object.
+         continue; 
+       }
+       char** apointer = (char**) pointer;
+       TObject* robj = (TObject*) *apointer;
+       //      
+       if(!robj)
+         printf("M:%s%s\n",prefix.Data(),dm->GetName()); // Missing - 0 pointer
+       else{
+         printf("T:%s\t%s%s\n", clobj->GetName(),prefix.Data(), dm->GetName());
+         TString prefixNew=prefix;
+         prefixNew+=dm->GetName();
+         prefixNew+=".";
+         if (robj!=obj) DumpObjectRecursive(robj,prefixNew,counterRec);  // trivial check 
+         if (robj==obj){
+           printf("R:%s\t%s%s\n",clobj->GetName(),prefix.Data(), dm->GetName());
+         }
+       }
+      }
+    } else if (dm->IsBasic()) {
+      //
+      // Basic data type
+      //
+      const char* index = dm->GetArrayIndex();
+      if (dm->GetArrayDim()==0){
+       printf("B:\t%s%s\t%s\n", prefix.Data(),rd->GetName(), dtype->AsString(pointer));
+      }
+      //
+      // Basic array - fixed length
+      //
+      //      if (dm->GetArrayDim()>0 && strlen(index) != 0){
+      if (dm->GetArrayDim()>0 ){
+       printf("A:\t%s%s\t",prefix.Data(),rd->GetName());
+       Int_t counter=0;
+       for  (Int_t idim=0; idim<dm->GetArrayDim(); idim++){
+         //printf("A:%d\t%d\n", dm->GetArrayDim(),dm->GetMaxIndex(idim));
+         for (Int_t j=0; j<dm->GetMaxIndex(idim); j++){
+           printf("%s\t",dtype->AsString(pointer+dm->GetUnitSize()*counter));
+           counter++;
+           if (counter%5==0) printf("\nA:\t%s%s\t",prefix.Data(),rd->GetName());
+         }
+       }
+       printf("\n");
+      }
+      //
+      // Basic array - dynamic length
+      //
+      if (dm->GetArrayDim()>0 && strlen(index) != 0){
+       //
+       // Dump first only for the moment
+       //  
+       printf("B:\t%s%s\t%s\n",prefix.Data(),rd->GetName(), dtype->AsString(pointer));
+      }
+    } else {
+    }
+  }
+}  
+
+//
+// Small checks to test the TRealData and TDataType
+//
+
+
+
+void DumpDataSimple(){
+  //
+  // Dump example for elenatr data types 
+  //
+  TObject *obj = new TVectorD(20);
+  TClass * cl = obj->IsA();
+  if (!cl->GetListOfRealData()) cl->BuildRealData();
+  //
+  TRealData* rd = 0;
+  rd = (TRealData*)(cl->GetListOfRealData()->FindObject("fNrows"));
+  TDataMember* dm = rd->GetDataMember();
+  TDataType* dtype = dm->GetDataType();
+  //
+  Int_t offset = rd->GetThisOffset();
+  char* pointer = ((char*) obj) + offset;
+  printf("%s\n",dtype->AsString(pointer));
+  
+}
+
+void DumpDataArray(){
+  //
+  // print array example
+  // 
+  TObject *obj = new TVectorD(20);
+  TClass * cl = obj->IsA();
+  if (!cl->GetListOfRealData()) cl->BuildRealData();
+  TRealData* rd = 0;
+  rd = (TRealData*)(cl->GetListOfRealData()->FindObject("*fElements"));
+  TDataMember* dm = rd->GetDataMember();
+  TDataType* dtype = dm->GetDataType();
+  dtype->Print();
+  //
+  Int_t offset = rd->GetThisOffset();
+  char* pointer = ((char*) obj) + offset; 
+  printf("%s\n",dtype->AsString(pointer));
+}
+
+void DumpTObjectArray(){
+  //
+  //
+  //
+  TObjArray *array = new TObjArray(10);
+  for (Int_t i=0; i<10; i++) array->AddLast(new TNamed(Form("n%d",i), Form("n%d",i)));  
+  DumpObjectRecursive(array);
+  //
+  //
+  TObject *obj = array;
+  TClass * cl = obj->IsA();
+  if (!cl->GetListOfRealData()) cl->BuildRealData();
+  TRealData* rd = 0;
+  rd = (TRealData*)(cl->GetListOfRealData()->FindObject("*fCont"));
+  TDataMember* dm = rd->GetDataMember();
+  TDataType* dtype = dm->GetDataType();
+  //
+  Int_t offset = rd->GetThisOffset();
+  char* pointer = ((char*) obj) + offset;
+  char** apointer = (char**) pointer;
+  //we have pointer to pointer here
+  TObject** ppobj = (TObject**) *apointer;
+  (*ppobj)->Print();
+  //
+  TIter myiter(array);
+  TObject  *arObject; 
+  dtype->Print();
+  while ((arObject = (TObject*)myiter.Next())) {
+    DumpObjectRecursive(arObject);
+  } 
+
+
+}
diff --git a/PWGPP/CalibMacros/xmldump b/PWGPP/CalibMacros/xmldump
new file mode 100644 (file)
index 0000000..da9cd44
--- /dev/null
@@ -0,0 +1,27 @@
+xmldump(){
+#
+# Dump object from file
+#
+# Example usage:
+#       xmldump /cvmfs/alice.gsi.de/alice/data/2010/OCDB/TPC/Calib/RecoParam/Run0_999999999_v1_s0.root AliCDBEntry Run0_999999999_v1_s0.dump
+
+  fin=$1       
+  object=$2
+  fout=$3
+
+  cat > xmldump.C <<EOF
+void xmldump(){
+  printf(\"Hallo world\n\");
+  TFile* fin=TFile::Open(\"$fin\");
+  TFile* fout=TFile::Open(\"$fout.xml\",\"recreate\");
+  TObject * obj= (TObject*)fin->Get(\"$2\");
+  obj->Print();
+  obj->Write();
+  delete fout;
+}
+EOF
+  
+  aliroot -b -q xmldump.C
+}
+
+
index d7e453d..3f2af36 100644 (file)
@@ -227,8 +227,3 @@ void DrawAndSave( TGraphErrors *gr, const char *name ){
   delete can;
 
 }
-
-
-
-
-
index 8c54362..ba91258 100644 (file)
@@ -7,7 +7,7 @@
 
  */
 
-
+  
 
 
 
 TTree * tree  = 0;
 TTreeSRedirector *pcstream = 0; //new TTreeSRedirector("trend.root");
 //
-
+void filterPIDSelectedTOF( const char * chfinput="highptAll.list");
+void filterPIDSelectedV0( const char * chfinput="highptAll.list");
 
 void filterPIDSelected( const char * chfinput="highptAll.list"){
+  filterPIDSelectedTOF(chfinput);
+  filterPIDSelectedV0(chfinput);
+}
+
+void filterPIDSelectedV0( const char * chfinput){
   //
   // Code to select identified V0 for the PID 
   // As an input chain of filter trees is used
@@ -95,7 +101,7 @@ void filterPIDSelected( const char * chfinput="highptAll.list"){
   // V0 - cuts -PID, 
   //   
   chain->SetAlias("cutDist","sqrt((track0.fIp.fP[0]-track1.fIp.fP[0])**2+(track0.fIp.fP[1]-track1.fIp.fP[1])**2)>3");
-  chain->SetAlias("cutLong","track0.GetTPCClusterInfo(3,1,0)-5*abs(track0.fP[4])>130&&track1.GetTPCClusterInfo(3,1,0)>130-5*abs(track0.fP[4])");
+  chain->SetAlias("cutLong","track0.GetTPCClusterInfo(3,1,0)+5*abs(track0.fP[4])>130&&track1.GetTPCClusterInfo(3,1,0)>130-5*abs(track1.fP[4])");
   chain->SetAlias("cutPID","track0.fTPCsignal>0&&track1.fTPCsignal>0");
   chain->SetAlias("cutResol","sqrt(track0.fC[14]/track0.fP[4])<0.15&&sqrt(track1.fC[14]/track1.fP[4])<0.15");
   chain->SetAlias("cutV0","cutPID&&cutDist&&cutLong&&cutResol");       
@@ -132,6 +138,44 @@ void filterPIDSelected( const char * chfinput="highptAll.list"){
   //
 }
 
+void filterPIDSelectedTOF( const char * chfinput){
+  //
+  // Code to select identified V0 for the PID 
+  // As an input chain of filter trees is used
+   //
+  TTree * chain  = 0;  
+  if (TString(chfinput).Contains(".list")) {
+    chain = AliXRDPROOFtoolkit::MakeChainRandom(chfinput,"highPt",0,1000);
+  }else{
+    TFile * finput= TFile::Open(chfinput);
+    if (!finput) finput= TFile::Open(TString::Format("%s#FilterEvents_Trees.root",finput));
+    chain=(TTree*)finput->Get("highPt");
+  }  
+  chain->SetCacheSize(1000000000);
+  //
+  TDatabasePDG pdg;
+  Double_t massLambda = pdg.GetParticle("Lambda0")->Mass();
+  Double_t massK0 = pdg.GetParticle("K0")->Mass();
+  Double_t massPion = pdg.GetParticle("pi+")->Mass();
+  Double_t massProton = pdg.GetParticle("proton")->Mass();
+  chain->SetAlias("cutLong","esdTrack.GetTPCClusterInfo(3,1,0)+5*abs(esdTrack.fP[4])>130");
+  TFile *fselected  = TFile::Open("TOFSelected.root","recreate");
+
+  TCut cutDeltaProton="abs((esdTrack.fTrackTime[4]-esdTrack.fTrackTime[3]))>400&&abs(esdTrack.fTOFsignalDz<3)";
+  TCut cutDeltaKaon="abs((esdTrack.fTrackTime[3]-esdTrack.fTrackTime[2]))>400&&abs(esdTrack.fTOFsignalDz<3)";
+  TCut cutDeltaPion="abs((esdTrack.fTrackTime[2]-esdTrack.fTrackTime[0]))>200&&abs(esdTrack.fTOFsignalDz<3)";
+
+  TTree * treeEl  = chain->CopyTree(cutDeltaPion+"cutLong&&esdTrack.fTOFr[0]>0.3+max(2*max(esdTrack.fTOFr[1],esdTrack.fTOFr[3]),esdTrack.fTOFr[4])");
+  TTree * treePion  = chain->CopyTree(cutDeltaPion+"cutLong&&esdTrack.fTOFr[2]>0.3+max(max(esdTrack.fTOFr[0],esdTrack.fTOFr[3]),esdTrack.fTOFr[4])");
+  TTree * treeKaon  = chain->CopyTree(cutDeltaKaon+"cutLong&&esdTrack.fTOFr[3]>0.3+max(max(esdTrack.fTOFr[0],2*esdTrack.fTOFr[2]),esdTrack.fTOFr[4])");
+  TTree * treeProton  = chain->CopyTree(cutDeltaProton+"cutLong&&esdTrack.fTOFr[4]>0.3+max(max(esdTrack.fTOFr[0],2*esdTrack.fTOFr[2]),esdTrack.fTOFr[3])");
+  treeEl->Write("treeEl");
+  treePion->Write("treePion");
+  treeKaon->Write("treeKaon");
+  treeProton->Write("treeProton");
+  //
+  fselected->Close();
+}
 
 void FitPIDNCLSelected(){
   //
index 8995b84..6ae8084 100755 (executable)
@@ -88,4 +88,3 @@ void runFilteringTask( const char* esdList,
 
     delete mgr;
 }
-
index ec1ea5b..4a5fc44 100644 (file)
@@ -1433,6 +1433,12 @@ TGraphErrors * TStatToolkit::MakeGraphErrors(TTree * tree, const char * expr, co
   graph->SetMarkerStyle(mstyle); 
   graph->SetMarkerColor(mcolor);
   graph->SetLineColor(mcolor);
+  graph->SetTitle(expr);
+  TString chstring(expr);
+  TObjArray *charray = chstring.Tokenize(":");
+  graph->GetXaxis()->SetTitle(charray->At(1)->GetName());
+  graph->GetYaxis()->SetTitle(charray->At(0)->GetName());
+  delete charray;
   if (msize>0) graph->SetMarkerSize(msize);
   for(Int_t i=0;i<graph->GetN();i++) graph->GetX()[i]+=offset;
   return graph;
@@ -1523,7 +1529,13 @@ TGraph * TStatToolkit::MakeGraphSparse(TTree * tree, const char * expr, const ch
   delete [] runNumber;
   delete [] index;
   delete [] newBins;
-  //
+  // 
+  graphNew->SetTitle(expr);
+  TString chstring(expr);
+  TObjArray *charray = chstring.Tokenize(":");
+  graphNew->GetXaxis()->SetTitle(charray->At(1)->GetName());
+  graphNew->GetYaxis()->SetTitle(charray->At(0)->GetName());
+  delete charray;
   return graphNew;
 }
 
@@ -1759,7 +1771,7 @@ void  TStatToolkit::DrawStatusGraphs(TObjArray* oaMultGr)
 }
 
 
-void TStatToolkit::DrawHistogram(TTree * tree, const char* drawCommand, const char* cuts, const char* histoname, const char* histotitle, Int_t nsigma, Float_t fraction )
+TH1* TStatToolkit::DrawHistogram(TTree * tree, const char* drawCommand, const char* cuts, const char* histoname, const char* histotitle, Int_t nsigma, Float_t fraction )
 {
   //
   // Draw histogram from TTree with robust range
@@ -1778,14 +1790,14 @@ void TStatToolkit::DrawHistogram(TTree * tree, const char* drawCommand, const ch
 
    if(!tree) {
      cerr<<" Tree pointer is NULL!"<<endl;
-     return;
+     return 0;
    }
 
    // get entries
    Int_t entries = tree->Draw(drawStr.Data(), cutStr.Data(), "goff");
    if (entries == -1) {
      cerr<<"TTree draw returns -1"<<endl;
-     return;
+     return 0;
    }
 
    // get dimension
@@ -1794,7 +1806,7 @@ void TStatToolkit::DrawHistogram(TTree * tree, const char* drawCommand, const ch
    if(tree->GetV3()) dim = 3;
    if(dim > 2){
      cerr<<"TTree has more than 2 dimensions (not yet supported)"<<endl;
-     return;
+     return 0;
    }
 
    // draw robust
@@ -1819,5 +1831,5 @@ void TStatToolkit::DrawHistogram(TTree * tree, const char* drawCommand, const ch
      hOut->GetYaxis()->SetTitle(tree->GetHistogram()->GetYaxis()->GetTitle());
      hOut->Draw("colz");
    }
-
+   return hOut;
 }
index a6c9205..0c79822 100644 (file)
@@ -81,7 +81,7 @@ class TStatToolkit : public TObject
   //
   // TTree function for robust draw
   //
-  static void DrawHistogram(TTree * tree, const char* drawCommand, const char* cuts = "1", const char* hname = "histo", const char* htitle = "histo", Int_t nsigma = 4, Float_t fraction = 0.75);
+  static TH1* DrawHistogram(TTree * tree, const char* drawCommand, const char* cuts = "1", const char* hname = "histo", const char* htitle = "histo", Int_t nsigma = 4, Float_t fraction = 0.75);
   //
   // TestFunctions:
   //
index eda7b17..35897c0 100644 (file)
@@ -143,3 +143,17 @@ void AliCDBEntry::PrintId() const {
   AliInfo(Form("%s",fId.ToString().Data()));
 
 }
+
+
+Int_t AliCDBEntry::Compare(const TObject* obj) const
+{
+  //
+  // compare according y
+  AliCDBEntry * o2 = (AliCDBEntry*)obj;
+  return TString(this->GetId().GetPath()).CompareTo((o2->GetId().GetPath()));
+  
+}
+
+Bool_t AliCDBEntry::IsSortable() const {
+   return kTRUE;
+} 
index 0e9c83d..a3bc0d6 100644 (file)
@@ -68,7 +68,8 @@ class AliCDBEntry: public TObject {
 
     const TString      GetLastStorage() const {return fId.GetLastStorage();};
     void               SetLastStorage(TString lastStorage) {fId.SetLastStorage(lastStorage);};
-
+    virtual Int_t Compare(const TObject* obj) const;
+    virtual Bool_t IsSortable() const;
   private:
 
     AliCDBEntry(const AliCDBEntry& other); // no copy ctor
index aeb38f7..23cf0d1 100644 (file)
@@ -178,3 +178,18 @@ void AliCDBId::Print(Option_t* /*option*/) const {
   cout << ToString().Data() << endl;
 
 }
+
+
+
+Int_t AliCDBId::Compare(const TObject* obj) const
+{
+  //
+  // compare according y
+  AliCDBId * o2 = (AliCDBId*)obj;
+  return TString(this->GetPath()).CompareTo((o2->GetPath()));
+  
+}
+
+Bool_t AliCDBId::IsSortable() const {
+   return kTRUE;
+} 
index 69b287b..1a1cbf6 100644 (file)
@@ -78,7 +78,8 @@ class AliCDBId: public TObject {
 
     TString ToString() const;
     void Print(Option_t* option="") const;
-
+    virtual Int_t Compare(const TObject* obj) const;
+    virtual Bool_t IsSortable() const;
   private:
 
     AliCDBPath fPath;          // path 
index 53de862..6962b72 100644 (file)
@@ -240,6 +240,7 @@ Bool_t AliCDBLocal::PrepareId(AliCDBId& id) {
   return kTRUE;
 }
 
+
 //_____________________________________________________________________________
 AliCDBId* AliCDBLocal::GetId(const AliCDBId& query) {
   // look for filename matching query (called by GetEntryId)
@@ -1025,8 +1026,6 @@ void AliCDBLocal::QueryValidCVMFSFiles(TString& cvmfsOcdbTag) {
   return;
 }
 
-
-
 /////////////////////////////////////////////////////////////////////////////////////////////////
 //                                                                                             //
 // AliCDBLocal factory                                                                        //
@@ -1089,7 +1088,6 @@ AliCDBStorage* AliCDBLocalFactory::Create(const AliCDBParam* param) {
 
   return NULL;
 }
-
 //_____________________________________________________________________________
 void AliCDBLocal::SetRetry(Int_t /* nretry */, Int_t /* initsec */) {
 
diff --git a/STEER/CDB/AliOCDBtoolkit.cxx b/STEER/CDB/AliOCDBtoolkit.cxx
new file mode 100644 (file)
index 0000000..bf228c4
--- /dev/null
@@ -0,0 +1,701 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/*
+
+  Primary goal of the proposal was to provide functionality to browse and compare the content of the OCDB
+  specified by different means.
+
+  a.) galice.root               - as currently implemented by Ruben in MC (or any file with cdbMap, and cdbList)
+  b.) AliESDs.root              - for the reconstructed data
+  c.) ocdb snapshot             - as used for grid productions
+  d.) TMap(s)                   - as used internally in galice.root and AliESDs,root  
+  e.) log file (if possible)    - looks logs aways used similar syntax, tested and working
+  f.) C macro                   - custom macro
+
+  Content comparison should be done:
+  a.) on the level of symbolic links 
+  b.) on the level of content itself 
+  - by by byte comparison dif
+  - data member by data member comparison
+
+  Implementation assumption:
+  All input formats (a .. f) will  be converted to the TMap storages and TList if AliCDBIds 
+
+  Example usage:
+  AliOCDBtoolkit::MakeDiffExampleUseCase();
+
+
+
+  //=============================================================================
+  // Functionality to dump content of  objects in human readable format
+  //=============================================================================
+  Use case examples 
+  1.) compare oontent of alignent OCDB files for differnt yers
+  2.) compare ClusterParam for different periods
+  
+  
+   
+  =================================================================================================================
+  // 1.)
+  // Compare alignment example:
+  // Compare TPC alignemnt 2013 and 2010
+  //
+  AliOCDBtoolkit::DumpOCDBFile("/cvmfs/alice.gsi.de/alice/data/2013/OCDB/TPC/Align/Data/Run0_999999999_v1_s0.root","TPCalign2013.dump",1,1);
+  AliOCDBtoolkit::DumpOCDBFile("/cvmfs/alice.gsi.de/alice/data/2010/OCDB/TPC/Align/Data/Run0_999999999_v1_s0.root","TPCalign2010.dump",1,1);
+  diff  TPCalign2013.dump TPCalign2010.dump > TPCalign2013_TPCalign2010.diff
+  //
+  //    
+  =================================================================================================================
+  //  2.) 
+  // Compare CluterParam OCDB etry
+  //
+  AliOCDBtoolkit::DumpOCDBFile("/cvmfs/alice.gsi.de/alice/data/2010/OCDB/TPC/Calib/ClusterParam/Run131541_999999999_v2_s0.root","2010_TPC_Calib_ClusterParam_Run131541_999999999_v2_s0.dump",1);
+  AliOCDBtoolkit:: AliOCDBtoolkit::DumpOCDBFile("/cvmfs/alice.gsi.de/alice/data/2010/OCDB/TPC/Calib/ClusterParam/Run0_999999999_v1_s0.root","2010_TPC_Calib_ClusterParam_Run0_999999999_v1_s0.dump",1);
+  AliOCDBtoolkit::DumpOCDBFile("/cvmfs/alice.gsi.de/alice/data/2013/OCDB/TPC/Calib/ClusterParam/Run0_999999999_v1_s0.root","2013_TPC_Calib_ClusterParam_Run0_999999999_v1_s0.dump",1);
+  diff 2010_TPC_Calib_ClusterParam_Run131541_999999999_v2_s0.dump 2010_TPC_Calib_ClusterParam_Run0_999999999_v1_s0.dump
+
+*/
+
+
+using namespace std;
+
+// STD
+#include <iostream>
+#include <algorithm>
+#include <sstream>
+#include <stdexcept>
+#include <functional>
+#include "TRealData.h"
+#include "TDataMember.h"
+#include "TClass.h"
+#include "TROOT.h"
+#include <TVectorD.h>
+//
+#include "TSystem.h"
+#include "TObjArray.h"
+#include "TString.h"
+#include "TTree.h"
+#include "TMessage.h"
+//
+#include "AliCDBManager.h"
+#include "AliCDBEntry.h"
+#include "AliOCDBtoolkit.h"
+#include "AliCDBStorage.h"
+
+
+void AliOCDBtoolkit::MakeDiffExampleUseCase(){
+  //
+  // Example usage for the MC 
+  // To run example case, assuming presence of following files in working directory: 
+  //    - rec.log        
+  //    - galice.root   
+  //    - AliESDs.root
+  //
+  AliCDBManager * man = AliCDBManager::Instance();
+  LoadOCDBFromLog("rec.log",0);
+  const TMap *cdbMapLog= man->GetStorageMap();        // this is map of 
+  const TList *cdbListLog=man->GetRetrievedIds();     // this is list of AliCDBId
+  //  TList *cdbListLog0=man->GetRetrievedIds();     // this is list of AliCDBId
+  //
+  TFile *fmc = TFile::Open("galice.root");
+  TMap *cdbMapMC= (TMap*)fmc->Get("cdbMap");          // 
+  TList *cdbListMC0= (TList*)fmc->Get("cdbList");     // this is list of TObjStrings
+  TList *cdbListMC = ConvertListStringToCDBId(cdbListMC0);        // convert to the TObjArray of AliCDBids
+  //
+  TFile *fesd = TFile::Open("AliESDs.root");
+  TList *listESD = ((TTree*)fesd->Get("esdTree"))->GetUserInfo();
+  TMap *cdbMapESD= (TMap*)listESD->FindObject("cdbMap");  
+  TList *cdbListESD0= (TList*)listESD->FindObject("cdbList"); // this is list of TObjStrings
+  TList *cdbListESD = ConvertListStringToCDBId(cdbListESD0);              // convert to the TObjArray  of AliCDBids
+  //
+  //
+  //
+  printf("\n\n");
+  printf("Diff log>>>ESD\n\n:");
+  MakeDiff(cdbMapLog, cdbListLog, cdbMapESD, cdbListESD,0);
+  printf("\n\n");
+  printf("Diff ESD>>>log\n\n:");
+  MakeDiff(cdbMapESD, cdbListESD,cdbMapLog, cdbListLog,0);
+  // 
+  printf("\n\n");
+  printf("Diff ESD>>>MC\n\n:");
+  MakeDiff(cdbMapMC, cdbListMC, cdbMapESD, cdbListESD,0);
+}
+
+
+void AliOCDBtoolkit::DumpOCDBAsTxt(const TString fInput, const TString fType, const TString outfile){
+  //
+  //
+  //
+  TFile *file;
+  const TMap *cdbMap;
+  const TList *cdbList;
+  //
+  //
+  
+  if(fType.EqualTo("MC",TString::kIgnoreCase)){
+        file = TFile::Open(fInput.Data());
+        cdbMap = (TMap*)file->Get("cdbMap");          // 
+        TList *cdbListMC0 = (TList*)file->Get("cdbList");     // this is list of TObjStrings
+        cdbList = ConvertListStringToCDBId(cdbListMC0);        // convert to the TObjArray of AliCDBids
+  } 
+    else if(fType.EqualTo("ESD",TString::kIgnoreCase)){
+      file = TFile::Open(fInput.Data());
+      TList *listESD = ((TTree*)file->Get("esdTree"))->GetUserInfo();
+      cdbMap = (TMap*)listESD->FindObject("cdbMap");  
+      TList *cdbListESD0= (TList*)listESD->FindObject("cdbList"); // this is list of TObjStrings
+      cdbList = ConvertListStringToCDBId(cdbListESD0);              // convert to the TObjArray  of AliCDBids
+    }
+    else if(fType.EqualTo("log",TString::kIgnoreCase)){
+        AliCDBManager * man = AliCDBManager::Instance();
+        LoadOCDBFromLog(fInput.Data(),0);
+        cdbMap = man->GetStorageMap();        // this is map of 
+        cdbList =man->GetRetrievedIds();     // this is list of AliCDBId
+    }
+    else{
+        printf("unsupported option: %s",fType.Data());
+        return;
+    }
+  cout <<"BEGINDUMP:" << endl;
+  DumpOCDB(cdbMap,cdbList,outfile);
+}
+
+
+Bool_t AliOCDBtoolkit::ParseInfoFromOcdbString(TString ocdbString, TString &ocdbPath, Int_t &run0, Int_t &run1, Int_t &version, Int_t &subVersion){
+  //
+  // Parse OCDB id string and provide basic ocdb information
+  //
+  //  a.) parse ocdbPath
+  Int_t indexBeginPath= ocdbString.Index("path: ")+7;
+  if (indexBeginPath<0) return kFALSE;
+  Int_t indexEndPath=ocdbString.Index(";",indexBeginPath);
+  if (indexEndPath<0) return kFALSE;
+  ocdbPath=TString(&(ocdbString.Data()[indexBeginPath]), indexEndPath-indexBeginPath-1);
+  // b.) parse runRange
+  Int_t indexRun0= ocdbString.Index(": [",indexEndPath)+3;
+  if (indexRun0<0) return kFALSE;
+  Int_t indexRun1= ocdbString.Index(",",indexRun0)+1;
+  if (indexRun1<0) return kFALSE;
+  run0=atoi(&(ocdbString.Data()[indexRun0]));
+  run1=atoi(&(ocdbString.Data()[indexRun1]));
+  AliCDBRunRange runRange(run0,run1);
+  //c.) parse version, subversion
+  Int_t indexVersion= ocdbString.Index("version: v",indexRun1)+10;
+  if (indexVersion<0) return kFALSE;
+  Int_t indexSubVersion= ocdbString.Index("_s",indexVersion)+2;
+  if (indexSubVersion<0) return kFALSE;
+  version=atoi(&(ocdbString.Data()[indexVersion]));
+  subVersion=atoi(&(ocdbString.Data()[indexSubVersion]));
+  return kTRUE;
+}
+
+Bool_t AliOCDBtoolkit::ParseInfoFromOcdbString(TString ocdbString, AliCDBId &cdbId){
+  //
+  // Parse OCDB id string and provide basic ocdb information and fillcdbID object
+  //
+  TString ocdbPath;
+  Int_t run0=0, run1=0;
+  Int_t version=0, subVersion=0;
+  Bool_t parseStatus = ParseInfoFromOcdbString(ocdbString, ocdbPath, run0,run1,version,subVersion); 
+  if (parseStatus) {
+    AliCDBRunRange runRange(run0,run1);
+    cdbId=AliCDBId(ocdbPath.Data(),runRange,version,subVersion);
+    AliCDBId* id = AliCDBId::MakeFromString(ocdbString);
+    cdbId=*id;
+    delete id;
+  }
+  //
+  return parseStatus;
+}
+
+TList  * AliOCDBtoolkit::ConvertListStringToCDBId(const TList *cdbList0){
+  //
+  // Convert input  list of the TObjString to list to AliCDBid 
+  //
+  Int_t entriesList0=cdbList0->GetEntries();
+  TList * array0 = new TList();
+  AliCDBId tmp0;
+  for (Int_t ientry0=0; ientry0<entriesList0; ientry0++){
+    if (cdbList0->At(ientry0)==0) continue;
+    Bool_t isId =  cdbList0->At(ientry0)->IsA()->InheritsFrom("AliCDBId");
+    if (isId){
+      array0->AddLast(cdbList0->At(ientry0));
+    }else{
+      Bool_t isString =  cdbList0->At(ientry0)->IsA()->InheritsFrom("TObjString");
+      if (isString){
+       TObjString* sid0 = dynamic_cast<TObjString*> (cdbList0->At(ientry0));
+       Bool_t status =  ParseInfoFromOcdbString(sid0->String(), tmp0);
+       if (!status) continue;
+       array0->AddLast(new AliCDBId(tmp0));
+      }
+    }
+  }
+  return array0;  
+}
+
+
+
+void AliOCDBtoolkit::LoadOCDBFromLog(const char *logName, Int_t verbose){
+  //
+  // Initilaize OCDB
+  // Load OCDB setting as specified in log
+  // Assuming fixed version of the log 
+  // AliCDBManager is initilaized - ocdbMap and ID list can be exported
+  //
+
+  // Parsing/loading sequence:
+  //    0.) SetDefault storage  *** Default Storage URI:
+  //    1.) SetSpecific storage  *** Specific storage
+  //    2.) SetRunNumber  Run number:
+  //    3.) Set used IDs
+  //
+  AliCDBManager * man = AliCDBManager::Instance();
+  //
+  // 0.) SetDefault storage  *** Default Storage URI:
+  // 
+  TString  defaultOCDB = gSystem->GetFromPipe(TString::Format("cat %s| grep \"Storage URI:\"",logName).Data());
+  TObjArray *array = defaultOCDB.Tokenize("\"");
+  man->SetDefaultStorage(array->Last()->GetName());
+  delete array;
+  //
+  // 1.) SetSpecific storage  *** Specific storage
+  //
+  TString  specificStorage  = gSystem->GetFromPipe(TString::Format("cat %s| grep \"Specific storage\"",logName).Data());
+  array = specificStorage.Tokenize("\"");
+  Int_t entries = array->GetEntries();
+  for (Int_t i=1; i<entries-2; i+=4){    
+    // add protection here line shuld be in expected format
+    if ((verbose&2)>0) printf("%s\t%s\n",array->At(i)->GetName(),array->At(i+2)->GetName());    
+    man->SetSpecificStorage(array->At(i)->GetName(),array->At(i+2)->GetName());
+  }
+  delete array;
+  //
+  // 2.) SetRunNumber  Run number:
+  //
+  TString  runLine  = gSystem->GetFromPipe(TString::Format("cat %s| grep \"I-AliCDBManager::Print: Run number =\"",logName).Data());
+  array = runLine.Tokenize("=");
+  Int_t run = 0;
+  if (array->GetEntries()>1) run=atoi(array->At(1)->GetName()); 
+  delete array;
+  man->SetRun(run);  
+  //
+  // 3.) Set used IDs
+  //   
+  TString  ids =   gSystem->GetFromPipe(TString::Format("cat %s| grep I-AliCDB | grep path| grep range | grep version", logName).Data());
+  array= ids.Tokenize("\n");
+  entries = array->GetEntries();
+  //
+  for (Int_t i=0; i<entries; i++){
+    //
+    TString ocdbString = array->At(i)->GetName();
+    TString ocdbEntry;
+    TString ocdbPath;
+    Int_t run0=0, run1=0;
+    Int_t version=0, subVersion=0;
+    Bool_t parseStatus = ParseInfoFromOcdbString(ocdbString, ocdbPath, run0,run1,version,subVersion); 
+    if (!parseStatus) continue;
+    AliCDBRunRange runRange(run0,run1);
+    //
+    if ((verbose&2)!=0) {
+      printf("%s/Run%d_%d_v%d_s%d.root\n",ocdbPath.Data(),run0,run1,version,subVersion); 
+    }
+    try {
+      man->Get(ocdbPath.Data(),runRange,version,subVersion);      
+    } catch(const exception &e){
+      cerr << "OCDB retrieval failed!" << endl;
+      cerr << "Detailes: " << e.what() << endl;
+    }    
+  }  
+  if ((verbose&1)!=0){
+    man->Print();
+    man->GetStorageMap()->Print();
+    man->GetRetrievedIds()->Print(); 
+  }
+}
+
+
+void AliOCDBtoolkit::LoadOCDBFromMap(const TMap */*cdbMap*/, const TList */*cdbList*/){
+  //
+  // Initilaize OCDB
+  // Load OCDB setting as specified in maps
+  // Or Do we have already implementation in AliCDBanager?
+}
+
+
+
+void AliOCDBtoolkit::MakeDiff(const TMap */*cdbMap0*/, const TList *cdbList0, const TMap */*cdbMap1*/, const TList *cdbList1, Int_t /*verbose*/){
+  //
+  //
+  // Print difference between the 2 ocdb maps
+  // Input:
+  //   maps and list charactireizing OCDB setup  
+  // Output:
+  //   To be decided, currently it is the teinal output
+  //
+  Int_t entriesList0=cdbList0->GetEntries();
+  Int_t entriesList1=cdbList1->GetEntries();
+  //
+  for (Int_t ientry0=0; ientry0<entriesList0; ientry0++){
+    AliCDBId *id0    = dynamic_cast<AliCDBId*> (cdbList0->At(ientry0));
+    AliCDBId *id1=0;
+    for (Int_t ientry1=0; ientry1<entriesList1; ientry1++){
+      AliCDBId *cid1    = dynamic_cast<AliCDBId*> (cdbList1->At(ientry1));
+      //id0.Print();
+      //cid1.Print();
+      if (cid1->GetPath().Contains(id0->GetPath().Data())==0) continue;
+      id1=cid1;
+    }
+    if (!id1) {
+      printf("Missing entry\t");
+      id0->Print();
+      continue;
+    }
+    //   Bool_t isOK=kTRUE;
+    if (id0->GetFirstRun()!= id1->GetFirstRun() ||id0->GetLastRun()!= id1->GetLastRun()){
+      printf("Differrent run range\n");
+      id0->Print();
+      id1->Print();
+    }    
+    if (id0->GetVersion()!= id1->GetVersion() ||id0->GetSubVersion()!= id1->GetSubVersion()){
+      printf("Differrent version\n");
+      id0->Print();
+      id1->Print();
+    }    
+  }
+}
+
+void AliOCDBtoolkit::DumpOCDB(const TMap *cdbMap0, const TList *cdbList0, const TString outfile){
+  //
+  // Dump the OCDB configuatation as formated text file 
+  // with following collumns
+  // cdb name  prefix cdb path
+  // OCDB entries are sorted alphabetically
+  // e.g:
+  // TPC/Calib/RecoParam /hera/alice/jwagner/software/aliroot/AliRoot_TPCdev/OCDB/ TPC/Calib/RecoParam/Run0_999999999_v0_s0.root $SIZE_AliCDBEntry_Object $HASH_AliCDBEntry_Object
+  
+  AliCDBManager * man = AliCDBManager::Instance();
+  
+  TList * cdbList = (TList*) cdbList0;   // sorted array
+  cdbList->Sort();
+
+  TIter next(cdbList);
+  AliCDBId *CDBId;
+  TString cdbName;
+  TString cdbPath;
+  TObjString *ostr;
+  AliCDBEntry *cdbEntry;
+  UInt_t hash;
+  TMessage * file;
+  Int_t size; 
+  FILE *ofs = fopen(outfile.Data(),"w");
+  
+  while ((CDBId  =(AliCDBId*) next())){
+    cdbName = CDBId->GetPath();
+    ostr = (TObjString*)cdbMap0->GetValue(cdbName.Data());
+    if(!ostr) ostr = (TObjString*)cdbMap0->GetValue("default");
+    cdbPath = ostr->GetString();
+    if(cdbPath.Contains("local://"))cdbPath=cdbPath(8,cdbPath.Length()).Data();
+    
+    cdbEntry = (AliCDBEntry*) man->Get(*CDBId);
+    TObject *obj = cdbEntry->GetObject();
+    file = new TMessage(TBuffer::kWrite);
+    file->WriteObject(obj);
+    size = file->Length();
+    if(!obj){
+      fprintf(ofs,"object %s empty!\n",cdbName.Data());
+      continue;
+    }
+    hash = TString::Hash(file->Buffer(),size);
+    fprintf(ofs,"%s\t%s\t%s/Run%d_%d_v%d_s%d.root\t%d\t%u\n",
+          cdbName.Data(),
+          cdbPath.Data(),
+          cdbName.Data(),
+          CDBId->GetFirstRun(),
+          CDBId->GetLastRun(),
+          CDBId->GetVersion(),
+          CDBId->GetSubVersion(),
+          size,
+          hash
+          );
+    //if(!(CDBId->GetPathLevel(0)).Contains("TPC")) continue;
+    //cout << CDBId.ToString() << endl;
+    delete file;
+  }
+  fclose(ofs);
+}
+
+
+//====================================================================================================
+//  Dump object part
+//==================================================================================================== 
+
+
+
+
+
+void AliOCDBtoolkit::DumpOCDBFile(const char *finput , const char *foutput, Bool_t dumpMetaData, Bool_t xml){
+  //
+  //  
+  //  DumpOCDBFile("$ALICE_ROOT/OCDB/ITS/Align/Data/Run0_999999999_v0_s0.root", "ITS_Align_Data_Run0_999999999_v0_s0.dump")
+  //
+  if (finput==0) return ;
+  TFile *falignITS  = TFile::Open(finput);
+  AliCDBEntry *entry  = (AliCDBEntry*)falignITS->Get("AliCDBEntry");
+  if (!entry) return; 
+  TObject *obj = ((AliCDBEntry*)falignITS->Get("AliCDBEntry"))->GetObject();  
+
+  //
+  if (!xml){
+    if (dumpMetaData) gROOT->ProcessLine(TString::Format("((TObject*)%p)->Dump(); >%s",entry, foutput).Data());
+    if (!obj) return;
+    gROOT->ProcessLine(TString::Format("AliOCDBtoolkit::DumpObjectRecursive((TObject*)%p); >>%s",obj, foutput).Data());
+  }
+  if (xml){
+    TFile * f = TFile::Open(TString::Format("%s.xml",foutput).Data(),"recreate");
+    if (dumpMetaData) entry->Write("AliCDBEntry");
+    else obj->Write("AliCDBEntry");
+    f->Close();
+  }
+}
+
+
+
+void AliOCDBtoolkit::DumpObjectRecursive(TObject *obj){
+  //
+  //
+  //
+  Int_t counterRec=0;
+  printf("==> Dumping object at: %p, name=%s, class=%s)\n", obj, obj->GetName(), (obj->IsA()->GetName()));
+  DumpObjectRecursive(obj, TString(obj->IsA()->GetName())+".",counterRec);
+}
+//
+//
+//
+void AliOCDBtoolkit::DumpObjectRecursive(TObject *obj, TString prefix, Int_t &counterRec){
+  //
+  // Recursive dump of the TObject
+  // Dump all basic types and follow pointers to the objects
+  // current limitation:
+  //    a.) clases and structures not derived from TObject not followed (to fix)
+  //    b.) dynamic arrays not followed
+  //    c.) std maps,array ....  not followed
+  //    
+  //
+  if (!obj) return;
+  //
+  // Special case of Collection classes
+  //
+  if (obj->IsA()->InheritsFrom(TCollection::Class())) {
+    TIter myiter((TCollection*)obj);
+    TObject  *arObject=0;
+    Int_t counter=0;
+    while ((arObject = (TObject*)myiter.Next())) {
+      TString prefixArr = TString::Format("%s[%d]",prefix.Data(),counter);
+      DumpObjectRecursive(arObject,prefixArr,counterRec);
+      counter++;
+    } 
+    counterRec++;
+    return;
+  }
+
+  TClass * cl = obj->IsA();
+  if (!(cl->GetListOfRealData())) cl->BuildRealData();
+  TRealData* rd = 0;
+  TIter next(cl->GetListOfRealData());  
+  while ((rd = (TRealData*) next())) {
+    counterRec++;
+    TDataMember* dm = rd->GetDataMember();
+    TDataType* dtype = dm->GetDataType();
+    Int_t offset = rd->GetThisOffset();
+    char* pointer = ((char*) obj) + offset;
+    
+    if (dm->IsaPointer()) {
+      // We have a pointer to an object or a pointer to an array of basic types.
+      TClass* clobj = 0;
+      if (!dm->IsBasic()) {
+       clobj = TClass::GetClass(dm->GetTypeName());
+      }
+      if (clobj) {
+       // We have a pointer to an object.
+       //
+       if (!clobj->InheritsFrom(TObject::Class())) {
+         // It must be a TObject object.
+         continue; 
+       }
+       char** apointer = (char**) pointer;
+       TObject* robj = (TObject*) *apointer;
+       //      
+       if(!robj)
+         printf("M:%s%s\n",prefix.Data(),dm->GetName()); // Missing - 0 pointer
+       else{
+         printf("T:%s\t%s%s\n", clobj->GetName(),prefix.Data(), dm->GetName());
+         TString prefixNew=prefix;
+         prefixNew+=dm->GetName();
+         prefixNew+=".";
+         if (robj!=obj) DumpObjectRecursive(robj,prefixNew,counterRec);  // trivial check 
+         if (robj==obj){
+           printf("R:%s\t%s%s\n",clobj->GetName(),prefix.Data(), dm->GetName());
+         }
+       }
+      }
+    } else if (dm->IsBasic()) {
+      //
+      // Basic data type
+      //
+      const char* index = dm->GetArrayIndex();
+      if (dm->GetArrayDim()==0){
+       printf("B:\t%s%s\t%s\n", prefix.Data(),rd->GetName(), dtype->AsString(pointer));
+      }
+      //
+      // Basic array - fixed length
+      //
+      //      if (dm->GetArrayDim()>0 && strlen(index) != 0){
+      if (dm->GetArrayDim()>0 ){
+       printf("A:\t%s%s\t",prefix.Data(),rd->GetName());
+       Int_t counter=0;
+       for  (Int_t idim=0; idim<dm->GetArrayDim(); idim++){
+         //printf("A:%d\t%d\n", dm->GetArrayDim(),dm->GetMaxIndex(idim));
+         for (Int_t j=0; j<dm->GetMaxIndex(idim); j++){
+           printf("%s\t",dtype->AsString(pointer+dm->GetUnitSize()*counter));
+           counter++;
+           if (counter%5==0) printf("\nA:\t%s%s\t",prefix.Data(),rd->GetName());
+         }
+       }
+       printf("\n");
+      }
+      //
+      // Basic array - dynamic length
+      //
+      if (dm->GetArrayDim()>0 && strlen(index) != 0){
+       //
+       // Dump first only for the moment
+       //  
+       printf("B:\t%s%s\t%s\n",prefix.Data(),rd->GetName(), dtype->AsString(pointer));
+      }
+    } else {
+    }
+  }
+}  
+
+//
+// Small checks to test the TRealData and TDataType
+//
+
+
+
+void DumpDataSimple(){
+  //
+  // Dump example for elenatr data types 
+  //
+  TObject *obj = new TVectorD(20);
+  TClass * cl = obj->IsA();
+  if (!cl->GetListOfRealData()) cl->BuildRealData();
+  //
+  TRealData* rd = 0;
+  rd = (TRealData*)(cl->GetListOfRealData()->FindObject("fNrows"));
+  TDataMember* dm = rd->GetDataMember();
+  TDataType* dtype = dm->GetDataType();
+  //
+  Int_t offset = rd->GetThisOffset();
+  char* pointer = ((char*) obj) + offset;
+  printf("%s\n",dtype->AsString(pointer));
+}
+
+void DumpDataArray(){
+  //
+  // print array example
+  // 
+  TObject *obj = new TVectorD(20);
+  TClass * cl = obj->IsA();
+  if (!cl->GetListOfRealData()) cl->BuildRealData();
+  TRealData* rd = 0;
+  rd = (TRealData*)(cl->GetListOfRealData()->FindObject("*fElements"));
+  TDataMember* dm = rd->GetDataMember();
+  TDataType* dtype = dm->GetDataType();
+  dtype->Print();
+  //
+  Int_t offset = rd->GetThisOffset();
+  char* pointer = ((char*) obj) + offset; 
+  printf("%s\n",dtype->AsString(pointer));
+}
+
+void DumpTObjectArray(){
+  //
+  //
+  //
+  TObjArray *array = new TObjArray(10);
+  for (Int_t i=0; i<10; i++) array->AddLast(new TNamed(Form("n%d",i), Form("n%d",i)));  
+   AliOCDBtoolkit::DumpObjectRecursive(array);
+  //
+  //
+  TObject *obj = array;
+  TClass * cl = obj->IsA();
+  if (!cl->GetListOfRealData()) cl->BuildRealData();
+  TRealData* rd = 0;
+  rd = (TRealData*)(cl->GetListOfRealData()->FindObject("*fCont"));
+  TDataMember* dm = rd->GetDataMember();
+  TDataType* dtype = dm->GetDataType();
+  //
+  Int_t offset = rd->GetThisOffset();
+  char* pointer = ((char*) obj) + offset;
+  char** apointer = (char**) pointer;
+  //we have pointer to pointer here
+  TObject** ppobj = (TObject**) *apointer;
+  (*ppobj)->Print();
+  //
+  TIter myiter(array);
+  TObject  *arObject; 
+  dtype->Print();
+  while ((arObject = (TObject*)myiter.Next())) {
+    AliOCDBtoolkit::DumpObjectRecursive(arObject);
+  } 
+}
+
+
+Bool_t AliOCDBtoolkit::AddoptOCDBEntry( const char *finput, const char *output,  Int_t ustartRun, Int_t uendRun){
+  //
+  // Addopt OCDB entry - keeping all of the CDBentry quantities
+  // finput = "/cvmfs/alice.gsi.de/alice/simulation/2008/v4-15-Release/Residual/TPC/Calib/ClusterParam/Run127712_130850_v4_s0.root"
+  
+  TFile * fin = TFile::Open(finput);
+  if (!fin) return kFALSE;
+  AliCDBEntry * entry = (AliCDBEntry*) fin->Get("AliCDBEntry");
+  if (!entry) return kFALSE;
+  
+  AliCDBStorage* pocdbStorage = 0;
+  if (output!=0) AliCDBManager::Instance()->GetStorage(output);
+  else{
+    TString localStorage = "local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
+    pocdbStorage = AliCDBManager::Instance()->GetStorage(localStorage.Data());
+  }
+  //
+  AliCDBId  idIn = entry->GetId();
+  AliCDBMetaData *metaDataIn = entry->GetMetaData();
+
+  AliCDBMetaData *metaData= new AliCDBMetaData();
+  metaData->SetObjectClassName(metaDataIn->GetObjectClassName());
+  metaData->SetResponsible(TString::Format("%s: copy",metaDataIn->GetResponsible()).Data());
+  metaData->SetBeamPeriod(metaDataIn->GetBeamPeriod());
+  //
+  metaData->SetAliRootVersion(metaDataIn->GetAliRootVersion()); //root version
+  metaData->SetComment((TString::Format("%s: copy",metaDataIn->GetComment()).Data()));
+  AliCDBId* id1=NULL;
+  id1=new AliCDBId(idIn.GetPath(), ustartRun, uendRun);
+  pocdbStorage->Put(entry->GetObject(), (*id1), metaData);
+  return kTRUE;
+}
diff --git a/STEER/CDB/AliOCDBtoolkit.h b/STEER/CDB/AliOCDBtoolkit.h
new file mode 100644 (file)
index 0000000..415c88f
--- /dev/null
@@ -0,0 +1,48 @@
+#ifndef ALIOCDBTOOLKIT_H
+#define ALIOCDBTOOLKIT_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+
+
+#include <TObject.h>
+class TStopwatch;
+class TTree;
+class TMemStatManager;
+using std::fstream;
+
+class AliOCDBtoolkit : public TObject {
+public:
+  //AliOCDBtoolkit();
+  //static AliOCDBtoolkit * Instance();
+  
+  static void MakeDiffExampleUseCase();    // example usage
+  static void DumpOCDBAsTxt(const TString fInput,const TString fType, const TString outfile);
+  //
+  static Bool_t   ParseInfoFromOcdbString(TString ocdbString, TString &ocdbPath, Int_t &run0, Int_t &run1, Int_t &version, Int_t &subVersion);   
+  static Bool_t   ParseInfoFromOcdbString(TString ocdbString, AliCDBId &cdbId);
+  //
+  static TList  * ConvertListStringToCDBId(const TList *cdbList0); 
+  
+  static void LoadOCDBFromLog(const char *logName, Int_t verbose);
+  static void LoadOCDBFromMap(const TMap *cdbMap, const TList *cdbList);
+  static void MakeDiff(const TMap *cdbMap0, const TList *cdbList0, const TMap *cdbMap1, const TList *cdbList1, Int_t verbose);
+  static void DumpOCDB(const TMap *cdbMap0, const TList *cdbList0, const TString outfile);
+  //
+  // dump object functionality
+  //  
+  static void DumpObjectRecursive(TObject *obj);
+  static void DumpObjectRecursive(TObject *obj, TString prefix, Int_t &counterRec);
+  static void DumpOCDBFile(const char *finput , const char *foutput, Bool_t dumpMetaData, Bool_t xml);
+  //
+  // addopt OCDB entry
+  //
+  static Bool_t AddoptOCDBEntry( const char *finput, const char *output,  Int_t ustartRun, Int_t uendRun);
+private:
+  AliOCDBtoolkit(const AliOCDBtoolkit& source);
+  AliOCDBtoolkit& operator= (const AliOCDBtoolkit& rec);
+
+  ClassDef(AliOCDBtoolkit,0)
+};
+
+#endif
index cb2e6d9..6a17812 100644 (file)
@@ -43,5 +43,7 @@
 #pragma link C++ class  AliBaseCalibViewer+;
 #pragma link C++ class  AliBaseCalibViewerGUI+;
 #pragma link C++ class  AliCalibViewerGUItime+;
+#pragma link C++ class  AliOCDBtoolkit+;
+
 
 #endif
index 848b4f9..16a9278 100644 (file)
@@ -23,6 +23,7 @@ set ( SRCS
     CDB/AliBaseCalibViewer.cxx 
     CDB/AliBaseCalibViewerGUI.cxx 
     CDB/AliCalibViewerGUItime.cxx
+    CDB/AliOCDBtoolkit.cxx
     )
 
 string( REPLACE ".cxx" ".h" HDRS "${SRCS}")
index 09bc93a..932a6a7 100644 (file)
@@ -581,6 +581,7 @@ AliESDtrack::AliESDtrack(const AliVTrack *track) :
   for (i=0;i<10;i++) {fTOFInfo[i]=0;}
   for (i=0;i<12;i++) {fITSModule[i]=-1;}
 
+
   // Set ITS cluster map
   fITSClusterMap=track->GetITSClusterMap();
   fITSSharedMap=0;
@@ -1865,7 +1866,6 @@ void AliESDtrack::GetIntegratedTimes(Double_t *times, Int_t nspec) const
     for (int i=AliPID::kSPECIESC; i--;) times[i]=0.0;
   //
 }
-
 //_______________________________________________________________________
 Double_t AliESDtrack::GetIntegratedLength() const{
   Int_t index = -1;
@@ -2891,7 +2891,7 @@ Double_t AliESDtrack::GetLengthInActiveZone( Int_t mode, Double_t deltaY, Double
   return 0;
 }
 
-Double_t AliESDtrack::GetLengthInActiveZone(const AliExternalTrackParam  *paramT, Double_t deltaY, Double_t deltaZ, Double_t bz, Double_t exbPhi , TTreeSRedirector * pcstream) const {
+Double_t AliESDtrack::GetLengthInActiveZone(const AliExternalTrackParam  *paramT, Double_t deltaY, Double_t deltaZ, Double_t bz, Double_t exbPhi , TTreeSRedirector * pcstream) {
   //
   // Numerical code to calculate the length of the track in active region of the TPC
   // ( can be speed up if somebody wants to invest time - analysical version shoult be possible) 
@@ -3283,7 +3283,6 @@ const AliTOFHeader* AliESDtrack::GetTOFHeader() const {
   return fESDEvent->GetTOFHeader();
 }
 
-
 //___________________________________________
 void AliESDtrack::SetID(Short_t id) 
 {
@@ -3291,3 +3290,15 @@ void AliESDtrack::SetID(Short_t id)
   if (fNtofClusters) ReplaceTOFTrackID(fID,id); 
   fID=id;
 }
+
+
+Double_t  AliESDtrack::GetdEdxInfo(Int_t regionID, Int_t calibID, Int_t qID, Int_t valueID){
+  //
+  // Interface to get the calibrated dEdx information 
+  // For details of arguments and return values see 
+  //     AliTPCdEdxInfo::GetdEdxInfo(Int_t regionID, Int_t calibID, Int_t valueID)
+  //
+  if (!fTPCdEdxInfo) return 0;
+  if (!fIp) return 0;
+  return fTPCdEdxInfo->GetdEdxInfo(fIp, regionID, calibID, qID, valueID);
+}
index 26f1859..1970aed 100644 (file)
@@ -232,6 +232,7 @@ public:
       fTPCsignalTuned = signal;
   }
   void  SetTPCdEdxInfo(AliTPCdEdxInfo * dEdxInfo); 
+  Double_t  GetdEdxInfo(Int_t regionID, Int_t calibID, Int_t qID,Int_t valueID);
 
   AliTPCdEdxInfo * GetTPCdEdxInfo() const {return fTPCdEdxInfo;}
   Double_t GetTPCsignal() const {return fTPCsignal;}
@@ -447,7 +448,7 @@ public:
   // - set lengt of bit fields fTPCClusterMap and fTPCSharedMap to 0
   static void OnlineMode(bool mode) {fgkOnlineMode=mode;}
   static bool OnlineMode() {return fgkOnlineMode;}
-  Double_t GetLengthInActiveZone(const AliExternalTrackParam  *paramT, Double_t deltaY, Double_t deltaZ, Double_t bz, Double_t exbPhi =0 , TTreeSRedirector * pcstream =0 ) const;
+  static Double_t GetLengthInActiveZone(const AliExternalTrackParam  *paramT, Double_t deltaY, Double_t deltaZ, Double_t bz, Double_t exbPhi =0 , TTreeSRedirector * pcstream =0 );
   Double_t GetLengthInActiveZone( Int_t mode, Double_t deltaY, Double_t deltaZ, Double_t bz, Double_t exbPhi =0 , TTreeSRedirector * pcstream =0 ) const;
 protected:
   
index cb5bc75..d197d3d 100644 (file)
@@ -2971,3 +2971,69 @@ Bool_t AliExternalTrackParam::GetXYZatR(Double_t xr,Double_t bz, Double_t *xyz,
   return kTRUE;  
   //
 }
+
+
+Double_t  AliExternalTrackParam::GetParameterAtRadius(Double_t r, Double_t bz, Int_t parType) const
+{
+  //
+  // Get track parameters at the radius of interest.
+  // Given function is aimed to be used to interactivelly (tree->Draw())
+  // access track properties at different radii
+  //
+  // TO BE USED WITH SPECICAL CARE - 
+  //     it is aimed to be used for rough calculation as constant field and  
+  //     no correction for material is used
+  //  
+  // r  - radius of interest
+  // bz - magentic field 
+  // retun values dependens on parType:
+  //    parType = 0  -gx 
+  //    parType = 1  -gy 
+  //    parType = 2  -gz 
+  //
+  //    parType = 3  -pgx 
+  //    parType = 4  -pgy 
+  //    parType = 5  -pgz
+  //
+  //    parType = 6  - r
+  //    parType = 7  - global position phi
+  //    parType = 8  - global direction phi
+  //    parType = 9  - direction phi- positionphi
+  if (parType<0) {
+    parType=-1;
+     return 0;
+  }
+  Double_t xyz[3];
+  Double_t pxyz[3];  
+  Double_t localX=0;
+  Bool_t res = GetXatLabR(r,localX,bz,1);
+  if (!res) {
+    parType=-1;
+    return 0;
+  }
+  //
+  // position parameters
+  // 
+  GetXYZAt(localX,bz,xyz); 
+  if (parType<3)   {
+    return xyz[parType];
+  }
+
+  if (parType==6) return TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
+  if (parType==7) return TMath::ATan2(xyz[1],xyz[0]);
+  //
+  // momenta parameters
+  //
+  GetPxPyPzAt(localX,bz,pxyz); 
+  if (parType==8) return TMath::ATan2(pxyz[1],pxyz[0]);
+  if (parType==9) {
+    Double_t diff = TMath::ATan2(pxyz[1],pxyz[0])-TMath::ATan2(xyz[1],xyz[0]);
+    if (diff>TMath::Pi()) diff-=TMath::TwoPi();
+    if (diff<-TMath::Pi()) diff+=TMath::TwoPi();
+    return diff;
+  }
+  if (parType>=3&&parType<6) {
+    return pxyz[parType%3];
+  }
+  return 0;
+}
index 93fb09a..208b931 100644 (file)
@@ -223,6 +223,8 @@ class AliExternalTrackParam: public AliVTrack {
   Bool_t GetCovarianceXYZPxPyPz(Double_t cv[21]) const;
   Bool_t GetPxPyPzAt(Double_t x, Double_t b, Double_t p[3]) const;
   Bool_t GetXYZAt(Double_t x, Double_t b, Double_t r[3]) const;
+  Double_t GetParameterAtRadius(Double_t r, Double_t bz, Int_t parType) const;
+
   Bool_t GetYAt(Double_t x,  Double_t b,  Double_t &y) const;
   Bool_t GetZAt(Double_t x,  Double_t b,  Double_t &z) const;
   void Print(Option_t* option = "") const;
index 964a07f..0ccf551 100644 (file)
@@ -1,6 +1,3 @@
-#include "AliTPCdEdxInfo.h"
-#include "TObjArray.h"
-#include "TGraphErrors.h"
 
 //##################################################################
 //
@@ -10,6 +7,12 @@
 //
 //##################################################################
 
+#include "AliTPCdEdxInfo.h"
+#include "TObjArray.h"
+#include "TGraphErrors.h"
+#include "AliExternalTrackParam.h"
+
+
 TObjArray * AliTPCdEdxInfo::fArraySectorCalibration=0;
 
 ClassImp(AliTPCdEdxInfo)
@@ -216,7 +219,9 @@ Double_t AliTPCdEdxInfo::GetWeightedMean(Int_t qType, Int_t wType, Double_t w0,
   return result;
 }
 
-
+//
+// Apply second order calibration  of the dEdx
+//
 
 void  AliTPCdEdxInfo::RegisterSectorCalibration(TGraphErrors* gainSector, Int_t regionID, Int_t calibID){
   //
@@ -229,3 +234,33 @@ void  AliTPCdEdxInfo::RegisterSectorCalibration(TGraphErrors* gainSector, Int_t
   //
   fArraySectorCalibration->AddAt(gainSector, 3*calibID+regionID);
 }
+
+// Double_t AliTPCdEdxInfo::GetNormalizeddEdx(AliExternalTrackParam *param, Double_t bz,  Int_t regionID, Int_t calibID, Int_t qID){
+//   //
+//   //
+//   // 
+//   static AliTPCParamSR paramSR;
+//   static Double_t radius[3] ={0.5*(paramSR.GetInnerRadiusLow()+paramSR.GetInnerRadiusUp()),
+//                           0.5*(paramSR.GetPadRowRadii(36,0)+paramSR.GetPadRowRadii(36,paramSR.GetNRowUp1()-1)),
+//                           0.5*(paramSR.GetPadRowRadii(36,0)+paramSR.GetPadRowRadii(36,paramSR.GetNRowUp()-1))};
+//   Double_t phi= param->GetParameterAtRadius(radius[regionID],bz,7);
+
+//   TGraphErrors * graphSectorCorection = fArraySectorCalibration->At(regionID+3*calibID);
+//   Double_t dEdx = 0;
+//   if (qID==0) dEdx = fTPCsignalRegion[regionID];
+//   if (qID==1) dEdx = fTPCsignalRegionQmax[regionID];
+//   if (graphSectorCorection) dEdx /=graphSectorCorection->EvalAt(sector);
+//   return dEdx;
+// }
+
+
+
+Double_t   AliTPCdEdxInfo::GetdEdxInfo(AliExternalTrackParam *param, Int_t regionID, Int_t calibID, Int_t qID, Int_t valueID){
+  //
+  //
+  //
+
+  return param->GetParameter()[regionID];
+}
+
+
index f204bdb..7e9d514 100644 (file)
@@ -3,6 +3,7 @@
 
 class TGraphErrors;
 class TObjArray;
+class AliExternalTrackParam;
 #include <TObject.h>
 
 class AliTPCdEdxInfo : public TObject 
@@ -12,6 +13,7 @@ public:
   AliTPCdEdxInfo(const AliTPCdEdxInfo& source);
   AliTPCdEdxInfo& operator=(const AliTPCdEdxInfo& source);
   Double_t GetWeightedMean(Int_t qType, Int_t wType, Double_t w0, Double_t w1, Double_t w2); 
+  Double_t GetFractionOfClusters(Int_t iregion){ return fTPCsignalNRowRegion[iregion]>0 ? Double_t(fTPCsignalNRegion[iregion])/Double_t(fTPCsignalNRowRegion[iregion]):0;}
   //
   // qTot info
   void     GetTPCSignalRegionInfo(Double_t signal[4], Char_t ncl[3], Char_t nrows[3]) const;
@@ -30,6 +32,8 @@ public:
   
   Double_t GetSignalTot(Int_t index){ return fTPCsignalRegion[index];}
   Double_t GetSignalMax(Int_t index){ return fTPCsignalRegionQmax[index];}
+  Double_t GetNumberOfClusters(Int_t index) {return fTPCsignalNRegion[index%3];}
+  Double_t GetNumberOfCrossedRows(Int_t index) {return fTPCsignalNRowRegion[index%3];}
   //
   Double_t GetTPCsignalShortPad()      const {return fTPCsignalRegion[0];}
   Double_t GetTPCsignalMediumPad()     const {return fTPCsignalRegion[1];}
@@ -41,6 +45,7 @@ public:
   Double_t GetTPCsignalLongPadQmax()   const {return fTPCsignalRegionQmax[2];}
   Double_t GetTPCsignalOROCQmax()      const {return fTPCsignalRegionQmax[3];}
   static void     RegisterSectorCalibration(TGraphErrors* gainSector, Int_t regionID, Int_t calibID);
+  Double_t  GetdEdxInfo(AliExternalTrackParam *param, Int_t regionID, Int_t calibID, Int_t qID, Int_t valueID);
 private: 
 
   Double32_t  fTPCsignalRegion[4]; //[0.,0.,10] TPC dEdx signal in 4 different regions - 0 - IROC, 1- OROC medium, 2 - OROC long, 3- OROC all, (default truncation used)  - for qTot
index 2613004..49d90db 100644 (file)
@@ -302,6 +302,15 @@ Int_t AliTPCtracker::UpdateTrack(AliTPCseed * track, Int_t accept){
     //  new(larr[ihelix]) AliHelix(*track) ;    
     //}
   }
+  if (AliTPCReconstructor::StreamLevel()>0) {
+    Int_t event = (fEvent==NULL)? 0: fEvent->GetEventNumberInFile();
+    AliExternalTrackParam param(*track);
+    TTreeSRedirector &cstream = *fDebugStreamer;
+    cstream<<"Update"<<
+      "cl.="<<c<<
+      "track.="<<&param<<
+      "\n";
+  }
   track->SetNoCluster(0);
   return track->Update(c,chi2,i);
 }
@@ -347,6 +356,7 @@ Int_t AliTPCtracker::AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster)
     
     if (AliTPCReconstructor::StreamLevel()>2) {
     (*fDebugStreamer)<<"ErrParam"<<
+      "iter="<<fIteration<<
       "Cl.="<<cluster<<
       "T.="<<&param<<
       "dy="<<dy<<
@@ -2983,8 +2993,9 @@ Int_t AliTPCtracker::RefitInward(AliESDEvent *event)
   PropagateForward2(fSeeds);
   RemoveUsed2(fSeeds,0.4,0.4,20);
 
-  TObjArray arraySeed(fSeeds->GetEntries());
-  for (Int_t i=0;i<fSeeds->GetEntries();i++) {
+  Int_t entriesSeed=fSeeds->GetEntries();
+  TObjArray arraySeed(entriesSeed);
+  for (Int_t i=0;i<entriesSeed;i++) {
     arraySeed.AddAt(fSeeds->At(i),i);    
   }
   SignShared(&arraySeed);
index f6c5edd..2f383dd 100644 (file)
@@ -9,12 +9,21 @@
 .x $ALICE_ROOT/TPC/Upgrade/macros/ConfigOCDB.C(1)
 .L $ALICE_ROOT/TPC/Upgrade/macros/makeResidualSpaceChargeOCDB.C
 
-Example usage:
+Example usage rescaling fit:
 
-ln -sf /hera/alice/wiechula/Upgrade/LUTs_fluctuation/dir1/SpaceChargeFluc10_1.lookup.root current.root
-ln -sf /hera/alice/wiechula/Upgrade/LUTs_fluctuation/average/SpaceChargeFluc0_1.lookup.root  mean.root
+
+aliroot -b -q $ALICE_ROOT/TPC/Upgrade/macros/makeResidualSpaceChargeOCDB.C\(0\)
+
+
+Example usage Jens alignment lookup tables:
+
+ln -sf /hera/alice/wiechula/Upgrade/LUTs_fluctuation_eps20/MeasuredResidual2D/residualMap.1.root current.root
+ln -sf /hera/alice/wiechula/Upgrade/LUTs_fluctuation_eps20/ResidualResidual2D/residualMap.1.root mean.root
 ln -sf $ALICE_ROOT/OCDB/TPC/Calib/Correction/Run0_999999999_v0_s2.root ocdb.root
-aliroot -b -q $ALICE_ROOT/TPC/Upgrade/macros/makeResidualSpaceChargeOCDB.C
+aliroot -b -q $ALICE_ROOT/TPC/Upgrade/macros/makeResidualSpaceChargeOCDB.C\(1\)
+
+
+
 
 */
 
@@ -123,8 +132,7 @@ void makeResidualSpaceChargeOCDBLookup(const char *ocdbInName="ocdb.root",const
 
 
 
-
-void makeResidualSpaceChargeOCDB(const char *ocdbInName="ocdb.root",const char *scCurrentName="current.root", const char *scMeanName="mean.root"){
+void makeResidualSpaceChargeOCDBFit(const char *ocdbInName="ocdb.root",const char *scCurrentName="current.root", const char *scMeanName="mean.root"){
   //
   // Macro to create a clone original  OCDB entry with space point distortion and add there space point
   // distortions cause by resifual sapce charge
@@ -271,3 +279,130 @@ void makeResidualSpaceChargeOCDB(const char *ocdbInName="ocdb.root",const char *
 }
 
 
+
+
+void makeResidualSpaceChargeOCDBAlign(const char *ocdbInName="ocdb.root",const char *scCurrentName="current.root", const char *scMeanName="mean.root"){
+  //
+  // Macro to create a clone original  OCDB entry with space point distortion and add there space point
+  // distortion due residual space charge isalignemnt
+  // Output is stored by default in the current directory.
+  // 
+
+  // Parameters to Specify:
+  //    ocdbInName      : path to the original OCDB entry
+  //    scCurrentName   : path to the fluctuetaed distortion map
+  //    scMeanName      : path to the mean distortion map
+  //    
+  
+  /*
+    scCurrentName="/hera/alice/wiechula/Upgrade/LUTs_fluctuation_eps20/MeasuredResidual2D/residualMap.10.root";
+    scMeanName="/hera/alice/wiechula/Upgrade/LUTs_fluctuation_eps20/ResidualResidual2D/residualMap.10.root";
+    ocdbInName="$ALICE_ROOT/OCDB/TPC/Calib/Correction/Run0_999999999_v0_s2.root"
+  */
+  TFile * finCurrent = TFile::Open(scCurrentName);
+  TFile * finMean = TFile::Open(scMeanName);
+  //
+  AliTPCCorrectionLookupTable *spaceChargeCurrent=  (AliTPCCorrectionLookupTable *)finCurrent->Get("map");
+  AliTPCCorrectionLookupTable *spaceChargeMean   =  (AliTPCCorrectionLookupTable *)finMean->Get("map");
+  //
+  TObjArray * arraySC = new TObjArray(2);
+  arraySC->AddAt(spaceChargeCurrent,0);
+  arraySC->AddAt(spaceChargeMean,1);
+  AliTPCComposedCorrection *corrSC = new AliTPCComposedCorrection(arraySC,AliTPCComposedCorrection::kParallel);
+  AliTPCComposedCorrection *corrSCW = new AliTPCComposedCorrection(arraySC,AliTPCComposedCorrection::kParallel);
+  AliTPCComposedCorrection::AddVisualCorrection(spaceChargeCurrent,1);        // reconstructed
+  AliTPCComposedCorrection::AddVisualCorrection(spaceChargeMean,2);           // ideal
+  AliTPCComposedCorrection::AddVisualCorrection(corrSCW,5);
+  //
+  TVectorD weights(2);
+  weights[0]=1;
+  weights[1]=1;
+  corrSCW->SetWeights( &weights);
+  TTreeSRedirector * pcstream = new TTreeSRedirector("residualDelta.root","recreate");
+  //
+  for (Int_t ipoint=0; ipoint<50000; ipoint++){ 
+    Double_t phi = gRandom->Rndm()*TMath::TwoPi();
+    Double_t r   = 85+gRandom->Rndm()*(245-85);
+    Double_t theta   = -0.9+gRandom->Rndm()*1.8;
+    Double_t z=r*theta;     
+    Double_t x = r*TMath::Cos(phi);
+    Double_t y = r*TMath::Sin(phi);
+    Double_t drInput = AliTPCCorrection::GetCorrXYZ(x,y,z,0,1);
+    Double_t drOutput = AliTPCCorrection::GetCorrXYZ(x,y,z,0,2);
+    Double_t drDiff = AliTPCCorrection::GetCorrXYZ(x,y,z,0,5);
+    Double_t drphiInput = AliTPCCorrection::GetCorrXYZ(x,y,z,1,1);   // 
+    Double_t drphiOutput = AliTPCCorrection::GetCorrXYZ(x,y,z,1,2);  //
+    Double_t drphiDiff = AliTPCCorrection::GetCorrXYZ(x,y,z,1,5);  //    
+    //
+    (*pcstream)<<"diff"<<
+      "phi="<<phi<<
+      "r="<<r<<
+      "x="<<x<<
+      "y="<<y<<
+      "z="<<z<<
+      //
+      "drInput="<<drInput<<
+      "drOutput="<<drOutput<<
+      "drDiff="<<drDiff<<
+      //
+      "drphiInput="<<drphiInput<<
+      "drphiOutput="<<drphiOutput<<
+      "drphiDiff="<<drphiDiff<<
+      "\n";
+  }
+  TTree * tree = ((*pcstream)<<"diff")->GetTree();
+  //
+  TCanvas *canvas = new TCanvas("canvasDiff","canvasDiff",900,800); 
+  canvas->Divide(3,2);
+  canvas->cd(1);
+  tree->Draw("drphiOutput:drphiInput","abs(drphiDiff)+abs(drphiOutput)+abs(drphiInput)<3","");
+  canvas->cd(2);
+  tree->Draw("drphiDiff:r","abs(drphiDiff)+abs(drphiOutput)+abs(drphiInput)<3","colz");
+  canvas->cd(3);
+  tree->Draw("drphiDiff","abs(drphiDiff)+abs(drphiOutput)+abs(drphiInput)<3","");
+  canvas->cd(4);
+  tree->Draw("drOutput:drInput","abs(drDiff)+abs(drOutput)+abs(drInput)<3","");
+  canvas->cd(5);
+  tree->Draw("drDiff:r","abs(drDiff)+abs(drOutput)+abs(drInput)<3","colz");
+  canvas->cd(6);
+  tree->Draw("drDiff","abs(drDiff)+abs(drOutput)+abs(drInput)<3","");
+  canvas->SaveAs("residualSpaceChargeDistortion.pdf");
+  //
+  //
+  //
+  TFile *fileOCDBIn=TFile::Open(ocdbInName);
+  AliCDBEntry   *entry =  ( AliCDBEntry   *)fileOCDBIn->Get("AliCDBEntry");
+  TObjArray * array = (TObjArray*)entry->GetObject();
+  for (Int_t i=0;  i<3;  i++){
+    AliTPCComposedCorrection *corr = ( AliTPCComposedCorrection*)array->At(i);
+    if (corr){
+      TObjArray* corrArray = corr->GetCorrections();
+      corrArray->AddLast(corrSCW);
+    }    
+  }
+  AliCDBMetaData *metaData= new AliCDBMetaData();
+  metaData->SetObjectClassName("TObjArray");
+  metaData->SetResponsible("Marian Ivanov");
+  metaData->SetBeamPeriod(1);
+  metaData->SetAliRootVersion("05-25-01"); //root version
+  metaData->SetComment("Standard+fluctuation");
+  AliCDBId* id1=NULL;
+  id1=new AliCDBId("TPC/Calib/Correction", 0, 9999999999999999);
+  //
+  TString localStorage = "local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
+  pocdbStorage = AliCDBManager::Instance()->GetStorage(localStorage.Data());
+  pocdbStorage->Put(array, (*id1), metaData);
+
+
+}
+
+
+
+void makeResidualSpaceChargeOCDB(Int_t action=1){
+  //
+  //
+  //
+  if (action==0) makeResidualSpaceChargeOCDBFit();  // fit mean charge to current charge
+  if (action==1) makeResidualSpaceChargeOCDBAlign();  // use difference of the map and the reconstructed distorion map as a residual OCDB
+}
+
index 41c38b9..800a448 100644 (file)
@@ -1,4 +1,8 @@
+
 /*
+  
+
+
   gSystem->Load("libSTAT.so");
   .x ~/NimStyle.C
  
 class AliTPCclusterFast: public TObject {
 public:
   AliTPCclusterFast();
+  void Init();
+  
   virtual ~AliTPCclusterFast();
-  void SetParam(Float_t mnprim, Float_t diff, Float_t y, Float_t z, Float_t ky, Float_t kz);
-  void GenerElectrons();
+  void SetParam(Float_t mnprim, Float_t diff, Float_t diffL, Float_t y, Float_t z, Float_t ky, Float_t kz);
+  static void GenerElectrons(AliTPCclusterFast *cl0, AliTPCclusterFast *clm, AliTPCclusterFast *clp);
   void Digitize();
   Double_t GetQtot(Float_t gain,Float_t thr, Float_t noise, Bool_t rounding=kTRUE, Bool_t addPedestal=kTRUE);
   Double_t GetQmax(Float_t gain,Float_t thr, Float_t noise, Bool_t rounding=kTRUE, Bool_t addPedestal=kTRUE);
@@ -37,7 +43,7 @@ public:
   Double_t GetQtotCorr(Float_t rmsy0, Float_t rmsz0, Float_t gain, Float_t thr);
   
   Double_t GetNsec();
-  static void Simul(const char* simul, Int_t npoints);
+  //static void Simul(const char* simul, Int_t npoints);
   static Double_t GaussConvolution(Double_t x0, Double_t x1, Double_t k0, Double_t k1, Double_t s0, Double_t s1);
   static Double_t GaussExpConvolution(Double_t x0, Double_t s0,Double_t t1);
   static Double_t GaussGamma4(Double_t x, Double_t s0, Double_t p1);
@@ -50,6 +56,7 @@ public:
   Float_t fQtot;       // total charge - Gas gain flucuation taken into account
   //
   Float_t fDiff;       // diffusion sigma
+  Float_t fDiffLong;       // diffusion sigma longitudinal direction
   Float_t fY;          // y position 
   Float_t fZ;          // z postion 
   Float_t fAngleY;     // y angle - tan(y)
@@ -82,16 +89,19 @@ public:
   static void Simul(const char* simul, Int_t ntracks);
   Double_t  CookdEdxNtot(Double_t f0,Float_t f1);
   Double_t  CookdEdxQtot(Double_t f0,Float_t f1);
+  Double_t  CookdEdxNtotThr(Double_t f0,Float_t f1, Double_t thr, Int_t mode);
+  Double_t  CookdEdxQtotThr(Double_t f0,Float_t f1, Double_t thr, Int_t mode);
   //
-  Double_t  CookdEdxDtot(Double_t f0,Float_t f1, Float_t gain,Float_t thr, Float_t noise, Bool_t corr = kTRUE);
-  Double_t  CookdEdxDmax(Double_t f0,Float_t f1,Float_t gain,Float_t thr, Float_t noise, Bool_t corr=kTRUE);
+  Double_t  CookdEdxDtot(Double_t f0,Float_t f1, Float_t gain,Float_t thr, Float_t noise, Bool_t corr, Int_t mode);
+  Double_t  CookdEdxDmax(Double_t f0,Float_t f1,Float_t gain,Float_t thr, Float_t noise, Bool_t corr, Int_t mode);
   //
-  Double_t  CookdEdx(Int_t npoints, Double_t *amp, Double_t f0,Float_t f1);
+  Double_t  CookdEdx(Int_t npoints, Double_t *amp, Double_t f0,Float_t f1, Int_t mode);
   //
   Float_t fMNprim;     // mean number of primary electrons
   Float_t fAngleY;     // y angle - tan(y)
   Float_t fAngleZ;     // z angle - tan z
   Float_t fDiff;       // diffusion
+  Float_t fDiffLong;       // diffusion sigma longitudinal direction
   Int_t   fN;          // number of clusters
   TClonesArray *fCl;   // array of clusters  
   //
@@ -141,93 +151,249 @@ void AliTPCtrackFast::MakeTrack(){
   //
   if (!fCl) fCl = new TClonesArray("AliTPCclusterFast",160);
   for (Int_t i=0;i<fN;i++){
+    AliTPCclusterFast * cluster = (AliTPCclusterFast*) fCl->UncheckedAt(i);
+    if (!cluster) cluster =   new ((*fCl)[i]) AliTPCclusterFast;
+    cluster->Init();
+  }
+
+  for (Int_t i=0;i<fN;i++){
     Double_t tY = i*fAngleY;
     Double_t tZ = i*fAngleZ;
     AliTPCclusterFast * cluster = (AliTPCclusterFast*) fCl->UncheckedAt(i);
+    AliTPCclusterFast * clusterm = (AliTPCclusterFast*) fCl->UncheckedAt(TMath::Max(i-1,0));
+    AliTPCclusterFast * clusterp = (AliTPCclusterFast*) fCl->UncheckedAt(TMath::Min(i+1,159));
     if (!cluster) cluster =   new ((*fCl)[i]) AliTPCclusterFast;
     //
     Double_t posY = tY-TMath::Nint(tY);
     Double_t posZ = tZ-TMath::Nint(tZ);
-    cluster->SetParam(fMNprim,fDiff,posY,posZ,fAngleY,fAngleZ); 
+    cluster->SetParam(fMNprim,fDiff, fDiffLong, posY,posZ,fAngleY,fAngleZ); 
     //
-    cluster->GenerElectrons();
+    cluster->GenerElectrons(cluster, clusterm, clusterp);
     cluster->Digitize();
   }
 }
 
 Double_t  AliTPCtrackFast::CookdEdxNtot(Double_t f0,Float_t f1){
   //
+  //    Double_t  CookdEdxNtot(Double_t f0,Float_t f1);   //  dEdx_{hit}  reconstructed meen number of  electrons
+  //
   Double_t amp[160];
   for (Int_t i=0;i<fN;i++){ 
     AliTPCclusterFast * cluster = ( AliTPCclusterFast *)((*fCl)[i]);
     amp[i]=cluster->fNtot;
   }
-  return CookdEdx(fN,amp,f0,f1);
+  return CookdEdx(fN,amp,f0,f1,0);
 }
 
 Double_t  AliTPCtrackFast::CookdEdxQtot(Double_t f0,Float_t f1){
   //
+  //     dEdx_{Q} reconstructed mean number of electronsxGain
+  //
   Double_t amp[160];
   for (Int_t i=0;i<fN;i++){ 
     AliTPCclusterFast * cluster = ( AliTPCclusterFast *)((*fCl)[i]);
     amp[i]=cluster->fQtot;
   }
-  return CookdEdx(fN,amp,f0,f1);
+  return CookdEdx(fN,amp,f0,f1,0);
 }
 
-Double_t   AliTPCtrackFast::CookdEdxDtot(Double_t f0,Float_t f1, Float_t gain,Float_t thr, Float_t noise, Bool_t doCorr){
+
+Double_t  AliTPCtrackFast::CookdEdxNtotThr(Double_t f0,Float_t f1, Double_t thr, Int_t mode){
   //
+  //   dEdx_{hit}  reconstructed mean number of  electrons 
+  //     thr  = threshold in terms of the number of electrons
+  //     mode = algorithm to deal with trhesold values replacing
   //
+  Double_t amp[160];
+  Int_t nBellow=0;
+  //
+  Double_t minAbove=-1;
+  for (Int_t i=0;i<fN;i++){ 
+    AliTPCclusterFast * cluster = ( AliTPCclusterFast *)((*fCl)[i]);
+    Double_t clQ= cluster->fNtot;
+    if (clQ<thr) {
+      nBellow++;
+      continue;
+    }
+    if (minAbove<0) minAbove=clQ;
+    if (minAbove>clQ) minAbove=clQ;
+  }
+  //
+  if (mode==-1) return Double_t(nBellow)/Double_t(fN);
+
+  for (Int_t i=0;i<fN;i++){ 
+    AliTPCclusterFast * cluster = ( AliTPCclusterFast *)((*fCl)[i]);
+    Double_t clQ= cluster->fNtot;
+    //
+    if (mode==0)  amp[i]=clQ;              // mode0 - not threshold  - keep default
+    //
+    //
+    if (mode==1 && clQ>thr) amp[i]=clQ;    // mode1 - skip if bellow 
+    if (mode==1 && clQ<thr) amp[i]=0;      // mode1 - skip if bellow 
+    //
+    //
+    if (mode==2 && clQ>thr) amp[i]=clQ;    // mode2 - use 0 if below
+    if (mode==2 && clQ<thr) amp[i]=0;      // mode2 - use 0 if below
+    //
+    //
+    if (mode==3)  amp[i]=(clQ>thr)?clQ:thr; // mode3 - use thr if below
+    if (mode==4)  amp[i]=(clQ>thr)?clQ:minAbove; // mode4 -  use minimal above threshold if bellow thr
+  }
+  return CookdEdx(fN,amp,f0,f1, mode);
+}
+
+
+
+Double_t  AliTPCtrackFast::CookdEdxQtotThr(Double_t f0,Float_t f1, Double_t thr, Int_t mode){
+  //
+  //
+  //   dEdx_{Q}  reconstructed mean number of  electrons xgain
+  //     thr  = threshold in terms of the number of electrons
+  //     mode = algorithm to deal with trhesold values replacing
+  //
+
   //
   Double_t amp[160];
-  Int_t over=0;
+  Int_t nBellow=0;
+  //
+  Double_t minAbove=-1;
   for (Int_t i=0;i<fN;i++){ 
     AliTPCclusterFast * cluster = ( AliTPCclusterFast *)((*fCl)[i]);
-    Float_t camp = cluster->GetQtot(gain,thr,noise);
-    if (camp==0) continue;
-    Float_t corr =  1;
-    if (doCorr) corr = cluster->GetQtotCorr(0.5,0.5,gain,thr);
-    amp[over]=camp/corr;
-    over++;
+    Double_t clQ= cluster->fQtot;
+    if (clQ<thr) {
+      nBellow++;
+      continue;
+    }
+    if (minAbove<0) minAbove=clQ;
+    if (minAbove>clQ) minAbove=clQ;
   }
-  return CookdEdx(over,amp,f0,f1);
+  //
+  if (mode==-1) return Double_t(nBellow)/Double_t(fN);
 
+  for (Int_t i=0;i<fN;i++){ 
+    AliTPCclusterFast * cluster = ( AliTPCclusterFast *)((*fCl)[i]);
+    Double_t clQ= cluster->fQtot;
+    //
+    if (mode==0)  amp[i]=clQ;              // mode0 - not threshold  - keep default
+    //
+    //
+    if (mode==1 && clQ>thr) amp[i]=clQ;    // mode1 - skip if bellow 
+    if (mode==1 && clQ<thr) amp[i]=0;      // mode1 - skip if bellow 
+    //
+    //
+    if (mode==2 && clQ>thr) amp[i]=clQ;    // mode2 - use 0 if below
+    if (mode==2 && clQ<thr) amp[i]=0;      // mode2 - use 0 if below
+    //
+    //
+    if (mode==3)  amp[i]=(clQ>thr)?clQ:thr; // mode3 - use thr if below
+    if (mode==4)  amp[i]=(clQ>thr)?clQ:minAbove; // mode4 -  use minimal above threshold if bellow thr
+  }
+  return CookdEdx(fN,amp,f0,f1, mode);
 }
 
-Double_t   AliTPCtrackFast::CookdEdxDmax(Double_t f0,Float_t f1, Float_t gain,Float_t thr, Float_t noise, Bool_t doCorr){
+
+
+
+
+Double_t   AliTPCtrackFast::CookdEdxDtot(Double_t f0,Float_t f1, Float_t gain,Float_t thr, Float_t noise, Bool_t doCorr, Int_t mode){
   //
+  // total charge in the cluster (sum of the pad x time matrix ), hits were digitized before, but additional 
+  // actions can be specified by switches  // dEdx_{Qtot}
   //
+  Double_t amp[160];
+  Double_t minAmp=-1;
+  //
+  for (Int_t i=0;i<fN;i++){ 
+    AliTPCclusterFast * cluster = ( AliTPCclusterFast *)((*fCl)[i]);
+    Float_t camp = 0;
+    if (mode==0) camp = cluster->GetQtot(gain,0,noise);
+    else
+      camp = cluster->GetQtot(gain,thr,noise);
+    Float_t corr =  1;
+    if (doCorr) corr = cluster->GetQtotCorr(0.5,0.5,gain,thr);
+    camp/=corr;
+    amp[i]=camp;
+    if (camp>0){
+      if (minAmp <0) minAmp=camp;
+      if (minAmp >camp) minAmp=camp;
+    }
+  }
+  if (mode==3) for (Int_t i=0;i<fN;i++) if (amp[i]<=0) amp[i]=thr;
+  if (mode==4) for (Int_t i=0;i<fN;i++) if (amp[i]<=0) amp[i]=minAmp;
+  return CookdEdx(fN,amp,f0,f1, mode);
+}
+
+
+
+Double_t   AliTPCtrackFast::CookdEdxDmax(Double_t f0,Float_t f1, Float_t gain,Float_t thr, Float_t noise, Bool_t doCorr, Int_t mode){
+  //
+  // maximal charge in the cluster (maximal amplitude in the digit matrix), hits were digitized before, 
+  // but additional actions can be specified by switches  
   //
   Double_t amp[160];
-  Int_t over=0;
+  Double_t minAmp=-1;
+  //
   for (Int_t i=0;i<fN;i++){ 
     AliTPCclusterFast * cluster = ( AliTPCclusterFast *)((*fCl)[i]);
-    Float_t camp = cluster->GetQmax(gain,thr,noise);
-    if (camp==0) continue;    
+    Float_t camp = 0;
+    if (mode==0) camp =  cluster->GetQmax(gain,0,noise);
+    else
+      camp =  cluster->GetQmax(gain,thr,noise);
     Float_t corr =  1;
     if (doCorr) corr = cluster->GetQmaxCorr(0.5,0.5);
-    amp[over]=camp/corr;
-    over++;
+    camp/=corr;
+    amp[i]=camp;
+    if (camp>0){
+      if (minAmp <0) minAmp=camp;
+      if (minAmp >camp) minAmp=camp;
+    }
   }
-  return CookdEdx(over,amp,f0,f1);
-
+  if (mode==3) for (Int_t i=0;i<fN;i++) if (amp[i]<=0) amp[i]=thr;
+  if (mode==4) for (Int_t i=0;i<fN;i++) if (amp[i]<=0) amp[i]=minAmp;
+  return CookdEdx(fN,amp,f0,f1, mode);
 }
 
 
-Double_t  AliTPCtrackFast::CookdEdx(Int_t npoints, Double_t *amp,Double_t f0,Float_t f1){
+Double_t  AliTPCtrackFast::CookdEdx(Int_t npoints, Double_t *amp,Double_t f0,Float_t f1, Int_t mode){
   //
+  // Calculate truncated mean
+  //   npoints   - number of points in array
+  //   amp       - array with points
+  //   f0-f1     - truncation range
+  //   mode      - specify handling of the 0 clusters, actual handling - filling of amplitude defiend in algorithm above
+  //      mode =  0     - accept everything
+  //      mode =  1     - do not count 0 amplitudes
+  //      mode =  2     - use 0 amplitude as it is 
+  //      mode =  3     - use amplitude as it is (in above function amp. replace by the thr)
+  //      mode =  4     - use amplitude as it is (in above function amp. replace by the minimal amplitude)
   //
+
+  //
+  // 0. sorted the array of amplitudes
   //
   Int_t index[160];
   TMath::Sort(npoints,amp,index,kFALSE);
+  //
+  // 1.) Calculate truncated mean from the selected range of the array (ranking statistic )
+  //     dependening on the mode 0 amplitude can be skipped
   Float_t sum0=0, sum1=0,sum2=0;
+  Int_t   accepted=0;
+  Int_t above=0;
+  for (Int_t i=0;i<npoints;i++) if  (amp[index[i]]>0) above++;
+
   for (Int_t i=0;i<npoints;i++){
-    if (i<npoints*f0) continue;
-    if (i>npoints*f1) continue;
+    //
+    if (mode==1 && amp[index[i]]==0) {
+      continue;
+    }
+    if (accepted<npoints*f0) continue;
+    if (accepted>npoints*f1) continue;
     sum0++;
     sum1+= amp[index[i]];
     sum2+= amp[index[i]];
+    accepted++;
   }
+  if (mode==-1) return 1-Double_t(above)/Double_t(npoints);
   if (sum0<=0) return 0;
   return sum1/sum0;
 }
@@ -240,12 +406,15 @@ void AliTPCtrackFast::Simul(const char* fname, Int_t ntracks){
   TTreeSRedirector cstream(fname,"recreate");
   for (Int_t itr=0; itr<ntracks; itr++){
     //
-    fast.fMNprim=(5+50*gRandom->Rndm());
+    fast.fMNprim=(10.+100*gRandom->Rndm());
+    if (gRandom->Rndm()>0.5) fast.fMNprim=1./(0.00001+gRandom->Rndm()*0.1);
+
     fast.fDiff =0.01 +0.35*gRandom->Rndm();
+    fast.fDiffLong =  fast.fDiff*0.6/1.;
     //
     fast.fAngleY   = 4.0*(gRandom->Rndm()-0.5);
     fast.fAngleZ   = 4.0*(gRandom->Rndm()-0.5);
-    fast.fN  = TMath::Nint(80.+gRandom->Rndm()*80.);
+    fast.fN  = 160;
     fast.MakeTrack();
     if (itr%100==0) printf("%d\n",itr);
     cstream<<"simulTrack"<<
@@ -263,14 +432,40 @@ AliTPCclusterFast::AliTPCclusterFast(){
   fDigits.ResizeTo(5,7);
 }
 
+void AliTPCclusterFast::Init(){
+  //
+  // reset all counters  
+  //
+  const Int_t knMax=1000;
+  fMNprim=0;     // mean number of primary electrons
+  //                   //electrons part input
+  fNprim=0;      // mean number of primary electrons
+  fNtot=0;       // total number of  electrons
+  fQtot=0;       // total charge - Gas gain flucuation taken into account
+  //
+  fPosY.ResizeTo(knMax);
+  fPosZ.ResizeTo(knMax);
+  fGain.ResizeTo(knMax);
+  fSec.ResizeTo(knMax);
+  fStatY.ResizeTo(3);
+  fStatZ.ResizeTo(3);
+  for (Int_t i=0; i<knMax; i++){
+    fPosY[i]=0;
+    fPosZ[i]=0;
+    fGain[i]=0;
+  }
+}
+
+
+
 AliTPCclusterFast::~AliTPCclusterFast(){
 }
 
 
-void AliTPCclusterFast::SetParam(Float_t mnprim, Float_t diff, Float_t y, Float_t z, Float_t ky, Float_t kz){
+void AliTPCclusterFast::SetParam(Float_t mnprim, Float_t diff,  Float_t diffL,Float_t y, Float_t z, Float_t ky, Float_t kz){
   //
   //
-  fMNprim = mnprim; fDiff = diff;
+  fMNprim = mnprim; fDiff = diff; fDiffLong=diffL;
   fY=y; fZ=z; 
   fAngleY=ky; fAngleZ=kz;
 }
@@ -289,23 +484,15 @@ Double_t AliTPCclusterFast::GetNsec(){
   return TMath::Nint(TMath::Power((TMath::Power(FPOT,XEXPO)*(1-RAN)+TMath::Power(EEND,XEXPO)*RAN),YEXPO)/W);
 }
 
-void AliTPCclusterFast::GenerElectrons(){
+void AliTPCclusterFast::GenerElectrons(AliTPCclusterFast *cl0, AliTPCclusterFast *clm, AliTPCclusterFast *clp){
   //
   //
   //
   //
   const Int_t knMax=1000;
-  if (fPosY.GetNrows()<knMax){
-    fPosY.ResizeTo(knMax);
-    fPosZ.ResizeTo(knMax);
-    fGain.ResizeTo(knMax);
-    fSec.ResizeTo(knMax);
-    fStatY.ResizeTo(3);
-    fStatZ.ResizeTo(3);
-  }
-  fNprim = gRandom->Poisson(fMNprim);  //number of primary electrons
-  fNtot=0; //total number of electrons
-  fQtot=0; //total number of electrons after gain multiplification
+  cl0->fNprim = gRandom->Poisson(cl0->fMNprim);  //number of primary electrons
+  cl0->fNtot=0; //total number of electrons
+  cl0->fQtot=0; //total number of electrons after gain multiplification
   //
   Double_t sumQ=0;
   Double_t sumYQ=0;
@@ -313,41 +500,51 @@ void AliTPCclusterFast::GenerElectrons(){
   Double_t sumY2Q=0;
   Double_t sumZ2Q=0;
   for (Int_t i=0;i<knMax;i++){ 
-    fSec[i]=0;
+    cl0->fSec[i]=0;
   }
-  for (Int_t iprim=0; iprim<fNprim;iprim++){
-    Float_t dN   =  GetNsec();
-    fSec[iprim]=dN;
-    Double_t yc = fY+(gRandom->Rndm()-0.5)*fAngleY;
-    Double_t zc = fZ+(gRandom->Rndm()-0.5)*fAngleZ;
+  for (Int_t iprim=0; iprim<cl0->fNprim;iprim++){
+    Float_t dN   =  cl0->GetNsec();
+    cl0->fSec[iprim]=dN;
+    Double_t yc = cl0->fY+(gRandom->Rndm()-0.5)*cl0->fAngleY;
+    Double_t zc = cl0->fZ+(gRandom->Rndm()-0.5)*cl0->fAngleZ;
+    Double_t rc = (gRandom->Rndm()-0.5);
+
     for (Int_t isec=0;isec<=dN;isec++){
       //
       //
-      Double_t y = gRandom->Gaus(0,fDiff)+yc;
-      Double_t z = gRandom->Gaus(0,fDiff)+zc;
+      Double_t y = gRandom->Gaus(0,cl0->fDiff)+yc;
+      Double_t z = gRandom->Gaus(0,cl0->fDiff)+zc;
+      Double_t r = gRandom->Gaus(0,cl0->fDiffLong)+rc;
+      // choose pad row
+      AliTPCclusterFast *cl=cl0;
+      if (r<-0.5 &&cl) cl=clm;
+      if (r>0.5 &&cl)  cl=clp;
+      //
       Double_t gg = -TMath::Log(gRandom->Rndm());
-      fPosY[fNtot]=y;
-      fPosZ[fNtot]=z;
-      fGain[fNtot]=gg;
-      fQtot+=gg;
-      fNtot++;
-      sumQ+=gg;
-      sumYQ+=gg*y;
-      sumY2Q+=gg*y*y;
-      sumZQ+=gg*z;
-      sumZ2Q+=gg*z*z;
-      if (fNtot>=knMax) break;
+      cl->fPosY[cl->fNtot]=y;
+      cl->fPosZ[cl->fNtot]=z;
+      cl->fGain[cl->fNtot]=gg;
+      cl->fQtot+=gg;
+      cl->fNtot++;
+      //
+  //     cl->sumQ+=gg;
+//       cl->sumYQ+=gg*y;
+//       cl->sumY2Q+=gg*y*y;
+//       cl->sumZQ+=gg*z;
+//       cl->sumZ2Q+=gg*z*z;
+      if (cl->fNtot>=knMax) continue;
     }
-    if (fNtot>=knMax) break;
-  }
-  if (sumQ>0){
-    fStatY[0]=sumQ;
-    fStatY[1]=sumYQ/sumQ;
-    fStatY[2]=sumY2Q/sumQ-fStatY[1]*fStatY[1];
-    fStatZ[0]=sumQ;
-    fStatZ[1]=sumZQ/sumQ;
-    fStatZ[2]=sumZ2Q/sumQ-fStatZ[1]*fStatZ[1];
+    if (cl0->fNtot>=knMax) break;
   }
+
+ //  if (sumQ>0){
+//     fStatY[0]=sumQ;
+//     fStatY[1]=sumYQ/sumQ;
+//     fStatY[2]=sumY2Q/sumQ-fStatY[1]*fStatY[1];
+//     fStatZ[0]=sumQ;
+//     fStatZ[1]=sumZQ/sumQ;
+//     fStatZ[2]=sumZ2Q/sumQ-fStatZ[1]*fStatZ[1];
+//   }
 }
 
 void AliTPCclusterFast::Digitize(){
@@ -369,34 +566,36 @@ void AliTPCclusterFast::Digitize(){
        fDigits(2+di,3+dj)+=fac;
       }
   }
-  
+  //
+  //
+  //
 }
 
 
 
-void AliTPCclusterFast::Simul(const char* fname, Int_t npoints){
-  //
-  // Calc rms
-  //
-  AliTPCclusterFast fast;
-  TTreeSRedirector cstream(fname);
-  for (Int_t icl=0; icl<npoints; icl++){
-    Float_t nprim=(10+20*gRandom->Rndm());
-    Float_t diff =0.01 +0.35*gRandom->Rndm();
-    Float_t posY = gRandom->Rndm()-0.5;
-    Float_t posZ = gRandom->Rndm()-0.5;
-    //
-    Float_t ky   = 4.0*(gRandom->Rndm()-0.5);
-    Float_t kz   = 4.0*(gRandom->Rndm()-0.5);
-    fast.SetParam(nprim,diff,posY,posZ,ky,kz);
-    fast.GenerElectrons();
-    fast.Digitize();
-    if (icl%10000==0) printf("%d\n",icl);
-    cstream<<"simul"<<
-      "s.="<<&fast<<
-      "\n";
-  }
-}
+// void AliTPCclusterFast::Simul(const char* fname, Int_t npoints){
+//   //
+//   // Calc rms
+//   //
+//   AliTPCclusterFast fast;
+//   TTreeSRedirector cstream(fname);
+//   for (Int_t icl=0; icl<npoints; icl++){
+//     Float_t nprim=(10+20*gRandom->Rndm());
+//     Float_t diff =0.01 +0.35*gRandom->Rndm();
+//     Float_t posY = gRandom->Rndm()-0.5;
+//     Float_t posZ = gRandom->Rndm()-0.5;
+//     //
+//     Float_t ky   = 4.0*(gRandom->Rndm()-0.5);
+//     Float_t kz   = 4.0*(gRandom->Rndm()-0.5);
+//     fast.SetParam(nprim,diff,posY,posZ,ky,kz);
+//     fast.GenerElectrons();
+//     fast.Digitize();
+//     if (icl%10000==0) printf("%d\n",icl);
+//     cstream<<"simul"<<
+//       "s.="<<&fast<<
+//       "\n";
+//   }
+// }
 
 
 Double_t AliTPCclusterFast::GetQtot(Float_t gain, Float_t thr, Float_t noise, Bool_t brounding, Bool_t baddPedestal){
index 3b5f76b..29aa4d2 100644 (file)
@@ -6,6 +6,8 @@
 
 */
 
+Int_t  kmarkes[5]={20,21,24,25,23};
+Int_t  kcolors[5]={1,2,4,3,6};
 
 void simul(Int_t npoints){ 
   //
@@ -66,12 +68,16 @@ void DrawdEdxResolExample(){
   //
   chain->Draw("tr.CookdEdxDmax(0,0.6,1,0,1,0)/tr.CookdEdxDtot(0,0.6,1,0,1,0):tr.fMNprim>>hisQtotMax(10,10,50)","","prof",10000);
   //
-  // 2.) Non linearity due to the tucncation Qtot_{60%}/Qtot 100% 
+  // 2.) Non linearity due to the truncation Qtot_{60%}/Qtot 100% 
   //
   chain->Draw("tr.CookdEdxDtot(0,0.6,1,0,1,0)/tr.CookdEdxDtot(0,0.99,1,0,1,0):tr.fMNprim>>hisQtot60100(10,10,50)","","prof",10000);
   //
+  // 3.) 
   //
-  //
-
+  chain->Draw("tr.CookdEdxDtot(0,0.6,1,0,1,0)/tr.fMNprim:tr.fMNprim>>profQtot60(10,10,50)","","prof",10000);
+  chain->Draw("tr.CookdEdxDtot(0,0.99,1,0,1,0)/tr.fMNprim:tr.fMNprim>>profQtot100(10,10,50)","","profsame",10000);
 
 }
+
+
+
index 9d555b8..176277d 100755 (executable)
@@ -1,7 +1,4 @@
 #!/bin/sh
-
-
-
 main()
 {
   #
@@ -33,9 +30,9 @@ exampleCase(){
 #
 #  Example case to subit Toy MC jobs
 # 
-   source $ALICE_ROOT/TPCdev/TPC/fastSimul/simul.sh
+   source $ALICE_ROOT/TPC/fastSimul/simul.sh
    makeEnvLocal
-   makeSubmitRUN 40 100
+   makeSubmitRUN 80 400
    ls `pwd`/MC*/trackerSimul.root >  trackerSimul.list
 
 }
diff --git a/TPC/macros/CalibratedEdxRegion.C b/TPC/macros/CalibratedEdxRegion.C
deleted file mode 100644 (file)
index df253bc..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
-  Macro to make an per region dEdx calibration.
-  Here we assue we have suufiecint ammount of V) PID selected tracks for the calibration
-
-  .x $HOME/rootlogon.C
-  .L $ALICE_ROOT/TPC/macros/CalibratedEdxRegion.C+
-  
- */
-
-#include "TTree.h"
-#include "TFile.h"
-#include "TH1.h"
-#include "TH2.h" 
-#include "TCut.h"
-#include "TStatToolkit.h"
-#include "TGraphErrors.h"
-
-#include "AliESDtrack.h"
-#include "AliESDv0.h"
-#include "AliExternalTrackParam.h"
-#include "AliTPCdEdxInfo.h"
-#include "AliTPCParamSR.h"
-
-//TTree * trees[4]={treeK0, treeLambda,treeALambda,treeGamma};
-TTree * trees[4]={0};
-TFile * calibrationFile=0;
-
-void InitTrees(const char * v0file= "/hera/alice/miranov/ExpertQA/data/LHC13c/pass1/V0Selected.root"){
-  //
-  //
-  //
-  //  const char * v0file = "/hera/alice/miranov/ExpertQA/data/LHC13c/pass1/V0Selected.root";
-  TFile * f = TFile::Open(v0file);
-  TTree * treeLambda=(TTree*)f->Get("treeLambda");
-  TTree * treeALambda=(TTree*)f->Get("treeALambda");
-  TTree * treeK0=(TTree*)f->Get("treeK0");
-  TTree * treeGamma=(TTree*)f->Get("treeGamma");
-  calibrationFile=TFile::Open("dEdxCalibration.root","update");
-  //
-  // register BetheBloch parameterization for each type of identified particles
-  //
-  AliTPCParam param;
-  param.RegisterBBParam(param.GetBetheBlochParamAlice(),1);
-  treeK0->SetAlias("dEdxExp0","AliTPCParam::BetheBlochAleph(track0.fIp.P()/massPion,1)");
-  treeK0->SetAlias("dEdxExp1","AliTPCParam::BetheBlochAleph(track1.fIp.P()/massPion,1)");
-  treeLambda->SetAlias("dEdxExp0","AliTPCParam::BetheBlochAleph(track0.fIp.P()/massProton,1)");
-  treeLambda->SetAlias("dEdxExp1","AliTPCParam::BetheBlochAleph(track1.fIp.P()/massPion,1)");
-  treeALambda->SetAlias("dEdxExp0","AliTPCParam::BetheBlochAleph(track0.fIp.P()/massPion,1)");
-  treeALambda->SetAlias("dEdxExp1","AliTPCParam::BetheBlochAleph(track1.fIp.P()/massProton,1)");
-  treeGamma->SetAlias("dEdxExp0","AliTPCParam::BetheBlochAleph(track0.fIp.P()/0.005,1)");
-  treeGamma->SetAlias("dEdxExp1","AliTPCParam::BetheBlochAleph(track1.fIp.P()/0.005,1)");
-  //
-  //
-  //
-  AliTPCParamSR paramSR;
-  TString rROC0=TString::Format("%2.2f", 0.5*(paramSR.GetInnerRadiusLow()+paramSR.GetInnerRadiusUp()));
-  TString rROC1=TString::Format("%2.2f", 0.5*(paramSR.GetPadRowRadii(36,0)+paramSR.GetPadRowRadii(36,paramSR.GetNRowUp1()-1)));
-  TString rROC2=TString::Format("%2.2f", 0.5*(paramSR.GetPadRowRadii(36,0)+paramSR.GetPadRowRadii(36,paramSR.GetNRowUp()-1)));
-  //
-  //
-  // 
-  Double_t bz=-5;
-  trees={treeK0, treeLambda,treeALambda,treeGamma};
-  for (Int_t itree=0; itree<4;itree++){
-    trees[itree]->SetAlias("bz","-5");
-    trees[itree]->SetAlias("phi0ROC0",TString::Format("track0.fIp.GetParameterAtRadius(%s+0,%2.2f,7)",rROC0.Data(),bz));
-    trees[itree]->SetAlias("phi0ROC1",TString::Format("track0.fIp.GetParameterAtRadius(%s+0,%2.2f,7)",rROC1.Data(),bz));
-    trees[itree]->SetAlias("phi0ROC2",TString::Format("track0.fIp.GetParameterAtRadius(%s+0,%2.2f,7)",rROC2.Data(),bz));
-    trees[itree]->SetAlias("phi1ROC0",TString::Format("track1.fIp.GetParameterAtRadius(%s+0,%2.2f,7)",rROC0.Data(),bz));
-    trees[itree]->SetAlias("phi1ROC1",TString::Format("track1.fIp.GetParameterAtRadius(%s+0,%2.2f,7)",rROC1.Data(),bz));
-    trees[itree]->SetAlias("phi1ROC2",TString::Format("track1.fIp.GetParameterAtRadius(%s+0,%2.2f,7)",rROC2.Data(),bz));
-    //
-    //
-    trees[itree]->SetAlias("side0","(track0.fIp.fP[3]>0&&track0.fIp.fP[1]>0)+2*(track0.fIp.fP[3]<0&&track0.fIp.fP[1]<0)");  // 0 - both sides, 1- A side, 2- C side
-    trees[itree]->SetAlias("side1","(track1.fIp.fP[3]>0&&track1.fIp.fP[1]>0)+2*(track1.fIp.fP[3]<0&&track1.fIp.fP[1]<0)");
-  }
-  /*
-    consistency check: 
-    // Phi position extrapolated to the IFC OK
-    treeK0->Draw("track0.GetParameterAtRadius(83.8,-5,7)-track0.fIp.fAlpha-track0.fIp.fP[0]/track0.fIp.fX>>his(100,-0.02,0.02)","abs(track0.GetParameterAtRadius(83.8,-5,7)-track0.fIp.fAlpha)<0.5","",100000);
-    // Phi angle extrapolated to the IFC
-    treeK0->Draw("track0.GetParameterAtRadius(83.8,-5,8)-track0.fIp.Phi()>>his(100,-0.02,0.02)","abs(track0.GetParameterAtRadius(83.8,-5,7)-track0.fIp.fAlpha)<0.5","",100000);
-    //
-    treeK0->Draw("track0.GetParameterAtRadius(103.8,-5,9)-(track0.fIp.GetParameterAtRadius(103.8,-5,8)-track0.fIp.GetParameterAtRadius(103.8,-5,7))>>his(100,-0.05,0.05)","abs(track0.GetParameterAtRadius(103.8,-5,8)-track0.GetParameterAtRadius(103.8,-5,7))<0.5","",10000);
-
-   */
-}
-
-void MakeSectorCalibration(){
-  //
-  // Get sector phi correction - separate for 
-  //
-  TCut cutASide0="side0>0";
-  TCut cutPt0="abs(track0.fIp.fP[4])<3";
-  TCut cutASide1="side1>0";
-  TCut cutPt1="abs(track0.fIp.fP[4])<3";
-  TObjArray * histoArray = new TObjArray(100);
-  TObjArray * graphArray = new TObjArray(100);
-  //
-  //
-  //
-  for (Int_t iregion=0; iregion<3; iregion++){
-    //    
-    TH2F *hisSectorROC=0;
-    TH2F *hisSectorROCP=0;
-    TH2F *hisSectorROCM=0;
-    TGraphErrors * graphs[3]={0};
-
-    for (Int_t itree=0; itree<3; itree++){
-      TString var0=TString::Format("track0.fTPCdEdxInfo.fTPCsignalRegion[%d]/dEdxExp0:18*(phi0ROC%d/pi+(side0-1))>>hisSectorROCPlus%d(36,0,36,60,20,80)",iregion,iregion,iregion);
-      TString var1=TString::Format("track1.fTPCdEdxInfo.fTPCsignalRegion[%d]/dEdxExp1:18*(phi1ROC%d/pi+(side1-1))>>hisSectorROCMinus%d(36,0,36,60,20,80)",iregion,iregion,iregion);
-      
-      trees[itree]->Draw(var0.Data(),cutASide0+cutPt0,"colzgoff");
-      if (hisSectorROCP==0) {
-       hisSectorROCP=(TH2F*)trees[itree]->GetHistogram()->Clone();
-      }
-      if (hisSectorROCP) hisSectorROCP->Add((TH2F*)trees[itree]->GetHistogram());
-      trees[itree]->Draw(var1.Data(),cutASide1+cutPt1,"colzgoff");
-      if (hisSectorROCM==0) hisSectorROCM=(TH2F*)trees[itree]->GetHistogram()->Clone();
-      if (hisSectorROCM) hisSectorROCM->Add((TH2F*)trees[itree]->GetHistogram());      
-    }
-    hisSectorROC=(TH2F*)hisSectorROCP->Clone();
-    hisSectorROC->SetName(TString::Format("hisSectorROCBoth%d(36,0,36,60,20,80)",iregion));
-    hisSectorROC->Add(hisSectorROCM);
-    //
-    graphs[0]=TStatToolkit::MakeStat1D(hisSectorROC, 0, 0.85,4,20,1);    
-    graphs[1]=TStatToolkit::MakeStat1D(hisSectorROCP, 0, 0.85,4,24,2);
-    graphs[2]=TStatToolkit::MakeStat1D(hisSectorROCM, 0, 0.85,4,25,4);    
-    graphs[0]->SetName(TString::Format("graphSectorROCBoth%d(36,0,36,60,20,80)",iregion));
-    graphs[1]->SetName(TString::Format("graphSectorROCPlus%d(36,0,36,60,20,80)",iregion));
-    graphs[2]->SetName(TString::Format("graphSectorROCMinus%d(36,0,36,60,20,80)",iregion));
-    graphs[0]->Draw("alp");
-    TStatToolkit::MakeStat1D(hisSectorROCP, 0, 0.85,4,24,2)->Draw("lp");
-    TStatToolkit::MakeStat1D(hisSectorROCM, 0, 0.85,4,25,4)->Draw("lp");
-    histoArray->AddLast(hisSectorROC);
-    histoArray->AddLast(hisSectorROCP);
-    histoArray->AddLast(hisSectorROCM); 
-    for (Int_t i=0; i<3; i++){
-      graphArray->AddLast(graphs[i]);
-    }
-  }
-  calibrationFile->mkdir("histos");
-  calibrationFile->cd("histos");
-  histoArray->Write();
-  calibrationFile->mkdir("graphs");
-  calibrationFile->cd("graphs");
-  graphArray->Write();
-  
-}
index 18978f5..213509f 100755 (executable)
@@ -9,7 +9,7 @@
 # $ALICE_ROOT/test/stressTest/stressTest.sh /d/alice12/miranov/streeTest/ "bsub -q proof"
 # 
 
-outdir=$1/$ALICE_LEVEL/$ALICE_TARGET
+outdir=$1/$ALICE_LEVEL/
 submitcommand=$2
 echo _____________________________________________________________
 echo _____________________________________________________________
@@ -27,21 +27,22 @@ echo _____________________________________________________________
 #
 # Loop over all run*sh macros
 #
-svn status $ALICE_ROOT  > svn.status
-svn diff   $ALICE_ROOT  > svn.diff 
+cd $ALICE_ROOT
+git status   > $outdir/git.status
+git diff     > $outdir/git.diff 
+cd $outdir
 for tmacro in `ls $ALICE_ROOT/test/*/run*.sh` ; do
-#
-dname=`dirname $tmacro`
-sname=`basename $dname`
-workdir=$outdir/$sname
-echo $sname $tmacro;
-mkdirhier $workdir
-cp $dname/* $workdir/
-cd $workdir
-rm *.root
-echo $submitcommand   $tmacro
-$submitcommand  $tmacro
-cd $outdir;
+    dname=`dirname $tmacro`
+    sname=`basename $dname`
+    workdir=$outdir/$sname
+    echo $sname $tmacro;
+    mkdirhier $workdir
+    cp $dname/* $workdir/
+    cd $workdir
+    rm *.root
+    echo $submitcommand   $tmacro
+    $submitcommand  $tmacro
+    cd $outdir;
 done;
 
 
index 1f47c83..db1b61b 100644 (file)
@@ -52,6 +52,9 @@
 
 ClassImp(AliTRDReconstructor)
 
+Int_t    AliTRDReconstructor::fgStreamLevel     = 1;        // stream (debug) level
+
+
 AliESDTrdTrigger AliTRDReconstructor::fgTriggerFlags;
 AliTRDonlineTrackMatching AliTRDReconstructor::fgOnlineTrackMatcher;
 TClonesArray *AliTRDReconstructor::fgClusters = NULL;
@@ -139,7 +142,7 @@ AliTRDReconstructor::~AliTRDReconstructor()
     delete fgTracks;
     fgTracks = NULL;
   }
-  if(fSteerParam&kOwner){
+  if((fSteerParam&kOwner)||  AliTRDReconstructor::GetStreamLevel()>0){
     for(Int_t itask = 0; itask < AliTRDrecoParam::kTRDreconstructionTasks; itask++)
       if(fDebugStream[itask]) delete fDebugStream[itask];
   }
index afb02c1..ed87d3f 100644 (file)
@@ -71,7 +71,7 @@ public:
   Bool_t              IsHLT() const              { return fSteerParam&kHLT;}
   Bool_t              IsSeeding() const          { return fSteerParam&kSeeding;}
   Bool_t              IsProcessingTracklets() const { return fSteerParam&kProcTracklets;}
-  Bool_t              IsDebugStreaming() const   { return fSteerParam&kDebug;}
+  Bool_t              IsDebugStreaming() const   { return (fSteerParam&kDebug || AliTRDReconstructor::GetStreamLevel()>0);}
   Bool_t              UseClusterRadialCorrection() const { return fSteerParam&kClRadialCorr;}
 
   static void         Options(UInt_t steer=0);
@@ -82,11 +82,14 @@ public:
  static void         SetTracklets(TClonesArray *tracklets) { fgTracklets = tracklets;}
  static void         SetTracks(TClonesArray *tracks) { fgTracks = tracks;}
   void               SetOption(Option_t *opt);
+  static Int_t GetStreamLevel()               { return fgStreamLevel;}
+  static void  SetStreamLevel(Int_t level) { fgStreamLevel = level;}
 
 private:
   AliTRDReconstructor(const AliTRDReconstructor &r); //Not implemented
   AliTRDReconstructor& operator = (const AliTRDReconstructor&); //Not implemented
   void                ResetContainers() const;
+  static Int_t               fgStreamLevel; // flag for streaming      - for TRD reconstruction
 
   static Char_t const *fgSteerNames[kNsteer];//! steering names
   static Char_t const *fgSteerFlags[kNsteer];//! steering flags
index 2babc75..99027a3 100644 (file)
@@ -1303,7 +1303,7 @@ Bool_t  AliTRDseedV1::AttachClusters(AliTRDtrackingChamber *const chamber, Bool_
 
   // initialize debug streamer
   TTreeSRedirector *pstreamer(NULL);
-  if(recoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 3 && fkReconstructor->IsDebugStreaming()) pstreamer = fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker);
+  if((recoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 3 && fkReconstructor->IsDebugStreaming())||AliTRDReconstructor::GetStreamLevel()>3) pstreamer = fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker);
   if(pstreamer){
     // save config. for calibration
     TVectorD vdy[2], vdx[2], vs2[2];
@@ -1330,7 +1330,7 @@ Bool_t  AliTRDseedV1::AttachClusters(AliTRDtrackingChamber *const chamber, Bool_
         << "\n";
     vdx[0].Clear(); vdy[0].Clear(); vs2[0].Clear();
     vdx[1].Clear(); vdy[1].Clear(); vs2[1].Clear();
-    if(recoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 4){    
+    if(recoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 4 ||AliTRDReconstructor::GetStreamLevel()>4){    
       Int_t idx(idxRow[1]);
       if(idx<0){ 
         for(Int_t ir(0); ir<kNrows; ir++){ 
index 4ab9e5d..d605067 100644 (file)
@@ -374,7 +374,7 @@ Int_t AliTRDtrackerV1::PropagateBack(AliESDEvent *event)
       // update calibration references using this track
       if(calibra->GetHisto2d()) calibra->UpdateHistogramsV1(&track);
       // save calibration object
-      if (fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 0) { 
+      if (fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 0 || AliTRDReconstructor::GetStreamLevel()>0 ) { 
         AliTRDtrackV1 *calibTrack = new AliTRDtrackV1(track);
         calibTrack->SetOwner();
         seed->AddCalibObject(calibTrack);
@@ -516,7 +516,7 @@ Int_t AliTRDtrackerV1::RefitInward(AliESDEvent *event)
     Double_t xTPC = 250.0;
     if(FollowProlongation(track)){     
       // Update the friend track
-      if (fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 0){ 
+      if (fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 0  || AliTRDReconstructor::GetStreamLevel()>0 ){ 
         TObject *o = NULL; Int_t ic = 0;
         AliTRDtrackV1 *calibTrack = NULL; 
         while((o = seed->GetCalibObject(ic++))){
@@ -624,6 +624,24 @@ Int_t AliTRDtrackerV1::FollowProlongation(AliTRDtrackV1 &t)
     Double_t cov[3]; tracklet->GetCovAt(x, cov);
     Double_t p[2] = { tracklet->GetY(), tracklet->GetZ()};
     Double_t chi2 = ((AliExternalTrackParam)t).GetPredictedChi2(p, cov);
+    if(fkReconstructor->IsDebugStreaming()){
+      Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber();
+      TTreeSRedirector &cstreamer = *fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker);
+      AliExternalTrackParam param0(t);
+      AliExternalTrackParam param1(t);
+      param1.Update(p, cov);
+      TVectorD vcov(3,cov);
+      TVectorD vpar(3,p);
+      cstreamer << "FollowProlongationInfo"
+               << "EventNumber="       << eventNumber
+               << "iplane="<<iplane
+               << "vcov.="<<&vcov
+               << "vpar.="<<&vpar
+               << "tracklet.="      << tracklet
+               << "param0.="           << &param0
+               << "param1.="           << &param1
+               << "\n";
+    }
     if (chi2 < 1e+10 && ((AliExternalTrackParam&)t).Update(p, cov)){ 
       // Register info to track
       t.SetNumberOfClusters();
@@ -632,7 +650,7 @@ Int_t AliTRDtrackerV1::FollowProlongation(AliTRDtrackV1 &t)
     }
   }
 
-  if(fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 1){
+  if(fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 1 || AliTRDReconstructor::GetStreamLevel()>1){
     Int_t index;
     for(int iplane=0; iplane<AliTRDgeometry::kNlayer; iplane++){
       AliTRDseedV1 *tracklet = GetTracklet(&t, iplane, index);
@@ -703,6 +721,7 @@ Int_t AliTRDtrackerV1::FollowBackProlongation(AliTRDtrackV1 &t)
   AliTRDtrackingChamber *chamber = NULL;
   
   Int_t debugLevel = fkReconstructor->IsDebugStreaming() ? fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) : 0;
+  if ( AliTRDReconstructor::GetStreamLevel()>0) debugLevel= AliTRDReconstructor::GetStreamLevel();
   TTreeSRedirector *cstreamer = fkReconstructor->IsDebugStreaming() ? fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker) : 0x0;
 
   Bool_t kStoreIn(kTRUE),     // toggel store track params. at TRD entry
@@ -970,6 +989,26 @@ Int_t AliTRDtrackerV1::FollowBackProlongation(AliTRDtrackV1 &t)
       AliDebug(4, Form("Failed Chi2[%f]", chi2));
       continue; 
     }
+     if(fkReconstructor->IsDebugStreaming()){
+      Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber();
+      //      TTreeSRedirector &cstreamer = *fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker);
+      AliExternalTrackParam param0(t);
+      AliExternalTrackParam param1(t);
+      param1.Update(p, cov);
+      TVectorD vcov(3,cov);
+      TVectorD vpar(3,p);
+      (*cstreamer) << "FollowBackProlongationInfo"
+               << "EventNumber="       << eventNumber
+               << "chi2="<<chi2
+               << "iplane="<<ily
+               << "vcov.="<<&vcov
+               << "vpar.="<<&vpar
+               << "tracklet.="      << ptrTracklet
+               << "param0.="           << &param0
+               << "param1.="           << &param1
+               << "\n";
+    }
+
     // mark track as entering the FIDUCIAL volume of TRD
     if(kStoreIn){
       t.SetTrackIn();
@@ -2235,7 +2274,7 @@ Int_t AliTRDtrackerV1::Clusters2TracksSM(Int_t sector, AliESDEvent *esd)
     Int_t id = esd->AddTrack(esdTrack);
 
     // set ESD id to stand alone TRD tracks
-    if (fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 0){ 
+    if (fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 0 || AliTRDReconstructor::GetStreamLevel()>0 ){ 
       esdTrack=esd->GetTrack(id);
       TObject *o(NULL); Int_t ic(0);
       AliTRDtrackV1 *calibTrack(NULL); 
@@ -2303,7 +2342,7 @@ Int_t AliTRDtrackerV1::Clusters2TracksStack(AliTRDtrackingChamber **stack, TClon
 
   // Build initial seeding configurations
   Double_t quality = BuildSeedingConfigs(stack, configs);
-  if(fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 10){
+  if(fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 10  || AliTRDReconstructor::GetStreamLevel()>10){
     AliInfo(Form("Plane config %d %d %d Quality %f"
     , configs[0], configs[1], configs[2], quality));
   }
@@ -2480,7 +2519,7 @@ Int_t AliTRDtrackerV1::Clusters2TracksStack(AliTRDtrackingChamber **stack, TClon
         esdTrack->SetLabel(track->GetLabel());
         track->UpdateESDtrack(esdTrack);
         // write ESD-friends if neccessary
-        if (fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 0){
+        if (fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 0 || AliTRDReconstructor::GetStreamLevel()>0 ){
           AliTRDtrackV1 *calibTrack = new AliTRDtrackV1(*track);
           calibTrack->SetOwner();
           esdTrack->AddCalibObject(calibTrack);
@@ -2508,7 +2547,7 @@ Int_t AliTRDtrackerV1::Clusters2TracksStack(AliTRDtrackingChamber **stack, TClon
       chamber->Build(fGeom);//Indices(fSieveSeeding);
     }
 
-    if(fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 10){ 
+    if(fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 10 || AliTRDReconstructor::GetStreamLevel()>10){ 
       AliInfo(Form("Sieve level %d Plane config %d %d %d Quality %f", fSieveSeeding, configs[0], configs[1], configs[2], quality));
     }
   } while(fSieveSeeding<10); // end stack clusters sieve
@@ -2749,7 +2788,7 @@ Int_t AliTRDtrackerV1::MakeSeeds(AliTRDtrackingChamber **stack, AliTRDseedV1 * c
         }
       
         Bool_t isFake = kFALSE;
-        if(fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) >= 2 && fkReconstructor->IsDebugStreaming()){
+        if((fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) >= 2 && fkReconstructor->IsDebugStreaming()) ||AliTRDReconstructor::GetStreamLevel()>=2 ){
           if (c[0]->GetLabel(0) != c[3]->GetLabel(0)) isFake = kTRUE;
           if (c[1]->GetLabel(0) != c[3]->GetLabel(0)) isFake = kTRUE;
           if (c[2]->GetLabel(0) != c[3]->GetLabel(0)) isFake = kTRUE;
@@ -2892,7 +2931,7 @@ Int_t AliTRDtrackerV1::MakeSeeds(AliTRDtrackingChamber **stack, AliTRDseedV1 * c
       
         // AliInfo("Extrapolation done.");
         // Debug Stream containing all the 6 tracklets
-        if(fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) >= 2 && fkReconstructor->IsDebugStreaming()){
+        if((fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) >= 2 && fkReconstructor->IsDebugStreaming())||AliTRDReconstructor::GetStreamLevel()>=2){
           TTreeSRedirector &cstreamer = *fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker);
           TLinearFitter *tiltedRieman = GetTiltedRiemanFitter();
           Int_t eventNumber            = AliTRDtrackerDebug::GetEventNumber();
@@ -2926,7 +2965,7 @@ Int_t AliTRDtrackerV1::MakeSeeds(AliTRDtrackingChamber **stack, AliTRDseedV1 * c
         // calculate track quality
         fTrackQuality[ntracks] = CalculateTrackLikelihood(&chi2Vals[0]);
                   
-        if(fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) >= 2 && fkReconstructor->IsDebugStreaming()){
+        if((fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) >= 2 && fkReconstructor->IsDebugStreaming()) ||AliTRDReconstructor::GetStreamLevel()>=2){
           TTreeSRedirector &cstreamer = *fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker);
           Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber();
           Int_t candidateNumber = AliTRDtrackerDebug::GetCandidateNumber();
@@ -3087,7 +3126,7 @@ AliTRDtrackV1* AliTRDtrackerV1::MakeTrack(AliTRDseedV1 * const tracklet)
 
   track.ResetCovariance(1);
   Int_t nc = TMath::Abs(FollowBackProlongation(track));
-  if(fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 5 && fkReconstructor->IsDebugStreaming()){
+  if((fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 5 && fkReconstructor->IsDebugStreaming()) ||AliTRDReconstructor::GetStreamLevel()>5){
     Int_t eventNumber          = AliTRDtrackerDebug::GetEventNumber();
     Int_t candidateNumber = AliTRDtrackerDebug::GetCandidateNumber();
     Double_t p[5]; // Track Params for the Debug Stream
@@ -3216,7 +3255,7 @@ Bool_t AliTRDtrackerV1::ImproveSeedQuality(AliTRDtrackingChamber **stack, AliTRD
     AliDebug(2, Form("Iter[%d] Q[%f] chi2[%f]", iter, quality, chi2));
 
 
-    if(fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) >= 7 && fkReconstructor->IsDebugStreaming()){
+    if((fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) >= 7 && fkReconstructor->IsDebugStreaming())||AliTRDReconstructor::GetStreamLevel()>=7){
       Int_t eventNumber                = AliTRDtrackerDebug::GetEventNumber();
       Int_t candidateNumber = AliTRDtrackerDebug::GetCandidateNumber();
       TLinearFitter *tiltedRieman = GetTiltedRiemanFitter();
@@ -3291,7 +3330,7 @@ Double_t AliTRDtrackerV1::CalculateTrackLikelihood(Double_t *chi2){
     , chi2[3], likeChi2Phi
   ));
 
-  if(fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) >= 2 && fkReconstructor->IsDebugStreaming()){
+  if((fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) >= 2 && fkReconstructor->IsDebugStreaming())||AliTRDReconstructor::GetStreamLevel()>=2){
     Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber();
     Int_t candidateNumber = AliTRDtrackerDebug::GetCandidateNumber();
     TTreeSRedirector &cstreamer = *fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker);
@@ -3356,7 +3395,7 @@ Double_t AliTRDtrackerV1::CookLikelihood(AliTRDseedV1 *cseed, Int_t planes[4])
   Double_t likeN     = TMath::Exp(-(fkRecoParam->GetNMeanClusters() - nclusters) / fkRecoParam->GetNSigmaClusters());
   Double_t like      = likea * likechi2y * likechi2z * likeN;
 
-  if(fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) >= 2 && fkReconstructor->IsDebugStreaming()){
+  if((fkRecoParam->GetStreamLevel(AliTRDrecoParam::kTracker) >= 2 && fkReconstructor->IsDebugStreaming())||AliTRDReconstructor::GetStreamLevel()>=2){
     Int_t eventNumber = AliTRDtrackerDebug::GetEventNumber();
     Int_t candidateNumber = AliTRDtrackerDebug::GetCandidateNumber();
     Int_t nTracklets = 0; Float_t meanNcls = 0;
index d36b7b6..dd8b9d8 100644 (file)
@@ -29,7 +29,7 @@ set(OPT)
 # ------- Setting optimization flags for default configuration -------
 
 if((NOT CMAKE_BUILD_TYPE) OR (CMAKE_BUILD_TYPE STREQUAL "None"))
-    set(DEFAULT_CXX_FLAGS "-O -g")
+    set(DEFAULT_CXX_FLAGS "-g -ggdb")
     set(OPT "${DEFAULT_CXX_FLAGS}")
     message("-- Setting compiler flags for default configuration: ${DEFAULT_CXX_FLAGS}")
 endif((NOT CMAKE_BUILD_TYPE) OR (CMAKE_BUILD_TYPE STREQUAL "None"))
@@ -37,7 +37,7 @@ endif((NOT CMAKE_BUILD_TYPE) OR (CMAKE_BUILD_TYPE STREQUAL "None"))
 # --------------------------------------------------------------------
 
 
-set(NOOPT "-g")
+set(NOOPT "-g -ggdb")
 
 set(CXXOPT ${OPT})
 set(CXXNOPT ${NOOPT})