3 // Author: Anders Vestbo <mailto:vestbo@fi.uib.no>, Uli Frankenfeld <mailto:franken@fi.uib.no>, Constantin Loizides <mailto:loizides@ikf.uni-frankfurt.de>
4 //*-- Copyright © ALICE HLT Group
7 #include "AliL3StandardIncludes.h"
13 #include <AliTPCParamSR.h>
14 #include <AliTPCPRF2D.h>
15 #include <AliTPCRF1D.h>
19 #include <TUnixSystem.h>
20 #include <TTimeStamp.h>
24 #include "AliL3Logging.h"
25 #include "AliL3Transform.h"
31 /** \class AliL3Transform
33 //_____________________________________________________________
36 // Transformation class for ALICE TPC.
38 // Class which contains all detector specific parameters for the TPC,
39 // and different useful functions for coordinate transforms.
41 // The class is completely static, which means that no object needs
42 // to be instantiated. Function calls should then be done like, e.g.:
44 // Double_t eta = AliL3Transform::GetEta(xyz);
46 // IMPORTANT: If used as is, default detector parameters will be used,
47 // and you really have to make sure that these correspond to
48 // the AliROOT version you are currently working on!!
49 // You should therefore always initialize the parameters by
51 // AliL3Transform::Init(path);
53 // where path is a char*, giving the path to where file containing
54 // the detector parameter is located. This file should be called
55 // "l3transform.config", and can be created with the function MakeInitFile.
57 // You can also force reading the parameters from a AliTPCParam object
58 // by setting the flag;
60 // AliL3Transform::Init(path,kTRUE);
62 // where path is a char*
63 // either providing the rootfile name containing the geometry or
64 // the path to the rootfile which should then be called alirunfile.root.
65 // Note that for both of these cases you have to
66 // compile with USEPACKAGE=ALIROOT set (see level3code/Makefile.conf).
68 // Currently, there are 4 versions of the Transformer:
69 // fVersion==fV_aliroot: ALIROOT-head compatible
70 // fVersion==fV_cosmics: Cosmics data run (2003) compatible
71 // fVersion==fV_default: means no config file has been loaded
72 // fVersion==fV_deprecated: dont use old (before July 2003) style of transformer
78 ClassImp(AliL3Transform)
81 const Double_t AliL3Transform::fAnodeWireSpacing = 0.25; //Taken from the TDR
82 const Double_t AliL3Transform::fBFACT = 0.0029980; //Conversion Factor
83 const Double_t AliL3Transform::fPi = 3.141592653589793;
85 //Defined by HLT and GSI
86 Int_t AliL3Transform::fNPatches = 6;
87 Int_t AliL3Transform::fRows[6][2] = {{0,29},{30,62},{63,90},{91,116},{117,139},{140,158}};
88 Int_t AliL3Transform::fNRows[6] = {30,33,28,26,23,19};
90 // The following definition is generated by MakeInitFile function
91 Double_t AliL3Transform::fBField = 0.2;
92 Double_t AliL3Transform::fSolenoidBField = 2;
93 Double_t AliL3Transform::fBFieldFactor = 1;
94 Int_t AliL3Transform::fVersion = fV_default;
95 Int_t AliL3Transform::fNTimeBins = 446;
96 Int_t AliL3Transform::fNRowLow = 63;
97 Int_t AliL3Transform::fNRowUp = 96;
98 Int_t AliL3Transform::fNRowUp1 = 64;
99 Int_t AliL3Transform::fNRowUp2 = 32;
100 Int_t AliL3Transform::fNSectorLow = 36;
101 Int_t AliL3Transform::fNSectorUp = 36;
102 Int_t AliL3Transform::fNSector = 72;
103 Double_t AliL3Transform::fPadPitchWidthLow = 0.4;
104 Double_t AliL3Transform::fPadPitchWidthUp = 0.6;
105 Double_t AliL3Transform::fZWidth = 0.5660;
106 Double_t AliL3Transform::fZSigma = 0.2288;
107 Double_t AliL3Transform::fZLength = 250.0000;
108 Double_t AliL3Transform::fZOffset = 0.6864;
109 Double_t AliL3Transform::fDiffT = 0.0220;
110 Double_t AliL3Transform::fDiffL = 0.0220;
111 Double_t AliL3Transform::fOmegaTau = 0.1450;
112 Double_t AliL3Transform::fInnerPadLength = 0.75;
113 Double_t AliL3Transform::fOuter1PadLength = 1.00;
114 Double_t AliL3Transform::fOuter2PadLength = 1.50;
115 Double_t AliL3Transform::fInnerPRFSigma = 0.203811;
116 Double_t AliL3Transform::fOuter1PRFSigma = 0.299325;
117 Double_t AliL3Transform::fOuter2PRFSigma = 0.299323;
118 Double_t AliL3Transform::fTimeSigma = 0.228809;
119 Int_t AliL3Transform::fADCSat = 1024;
120 Int_t AliL3Transform::fZeroSup = 0;
121 Int_t AliL3Transform::fNSlice = 36;
122 Int_t AliL3Transform::fNRow = 159;
123 Double_t AliL3Transform::fNRotShift = 0.5;
124 Int_t AliL3Transform::fSlice2Sector[36][2] = { { 0, 36},
162 Int_t AliL3Transform::fSector2Slice[72] = { 0,
236 Int_t AliL3Transform::fSectorLow[72] = { 1,
310 Double_t AliL3Transform::fX[159] = { 85.195,
471 Int_t AliL3Transform::fNPads[159] = {67,
632 Double_t AliL3Transform::fCos[36] = { 0.9848077297,
670 Double_t AliL3Transform::fSin[36] = { 0.1736481786,
708 Bool_t AliL3Transform::Init(Char_t* path,Bool_t UseAliTPCParam)
710 //Overwrite the parameters with values stored in file "l3transform.config" in path.
711 //If file does not exist, old default values will be used.
712 //If flag UseAliTPCParam is set, the parameters will be read from the the rootfile
713 //which then has to be called path/digitfile.root
715 if(fVersion != fV_default)
716 LOG(AliL3Log::kWarning,"AliL3Transform::Init","Init values")
717 <<AliL3Log::kDec<<"You are initializing the parameters more than once; check your code please! "<<fVersion<<ENDLOG;
719 if(UseAliTPCParam) //use rootfile to generate temporary init file
720 return ReadInit(path);
723 Char_t pathname[1024];
724 strcpy(pathname,path);
726 //test whether provided path is the file itself
727 //Long_t id=0,size=0,flags=0,modtime=0;
728 //gSystem->GetPathInfo(pathname, &id, &size, &flags, &modtime);
729 Int_t isdir = 0;// (Int_t)flags & 2;
730 DIR *testdir=opendir(pathname);
736 if(isdir) strcat(pathname,"/l3transform.config");
738 return ReadInitFile(pathname);
741 Bool_t AliL3Transform::ReadInitFile(Char_t* pathname)
743 //read transformer settings from pathname
745 FILE *fptr=fopen(pathname,"r");
747 LOG(AliL3Log::kWarning,"AliL3Transform::Init","File Open")
748 <<"Pointer to Config File \""<<pathname<<"\" 0x0!"<<ENDLOG;
752 Char_t d1[250], d2[100], d3[100];
757 fscanf(fptr,"%s",d1);
758 if(strcmp(d1,"fVersion")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fVersion=dummy;}
759 else if(strcmp(d1,"fBFieldFactor")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fBFieldFactor=(Double_t)ddummy;}
760 else if(strcmp(d1,"fSolenoidBField")==0)
762 fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);
763 fSolenoidBField=(Double_t)ddummy;
765 else if(strcmp(d1,"fNTimeBins")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNTimeBins=(Int_t)dummy;}
766 else if(strcmp(d1,"fNRowLow")==0)
768 fscanf(fptr,"%s %d %s",d2,&dummy,d3);
769 fNRowLow=(Int_t)dummy;
771 LOG(AliL3Log::kError,"AliL3Transform::Init","Overflow")
772 <<"Number of inner PadRows should be 63! Check and fgrep the code for 63 to see the consequences of this major change!"<<ENDLOG;
774 else if(strcmp(d1,"fNRowUp")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNRowUp=(Int_t)dummy;}
775 else if(strcmp(d1,"fNRowUp1")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNRowUp1=(Int_t)dummy;}
776 else if(strcmp(d1,"fNRowUp2")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNRowUp2=(Int_t)dummy;}
777 else if(strcmp(d1,"fNSectorLow")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNSectorLow=(Int_t)dummy;}
778 else if(strcmp(d1,"fNSectorUp")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNSectorUp=(Int_t)dummy;}
779 else if(strcmp(d1,"fNSector")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNSector=(Int_t)dummy;}
780 else if(strcmp(d1,"fPadPitchWidthLow")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fPadPitchWidthLow=(Double_t)ddummy;}
781 else if(strcmp(d1,"fPadPitchWidthUp")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fPadPitchWidthUp=(Double_t)ddummy;}
782 else if(strcmp(d1,"fZWidth")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fZWidth=(Double_t)ddummy;}
783 else if(strcmp(d1,"fZSigma")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fZSigma=(Double_t)ddummy;}
784 else if(strcmp(d1,"fZLength")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fZLength=(Double_t)ddummy;}
785 else if(strcmp(d1,"fZOffset")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fZOffset=(Double_t)ddummy;}
786 else if(strcmp(d1,"fNSlice")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNSlice=(Int_t)dummy;}
787 else if(strcmp(d1,"fDiffT")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fDiffT=(Double_t)ddummy;}
788 else if(strcmp(d1,"fDiffL")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fDiffL=(Double_t)ddummy;}
789 else if(strcmp(d1,"fOmegaTau")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fOmegaTau=(Double_t)ddummy;}
790 else if(strcmp(d1,"fInnerPadLength")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fInnerPadLength=(Double_t)ddummy;}
791 else if(strcmp(d1,"fOuter1PadLength")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fOuter1PadLength=(Double_t)ddummy;}
792 else if(strcmp(d1,"fOuter2PadLength")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fOuter2PadLength=(Double_t)ddummy;}
793 else if(strcmp(d1,"fInnerPRFSigma")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fInnerPRFSigma=(Double_t)ddummy;}
794 else if(strcmp(d1,"fOuter1PRFSigma")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fOuter1PRFSigma=(Double_t)ddummy;}
795 else if(strcmp(d1,"fOuter2PRFSigma")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fOuter2PRFSigma=(Double_t)ddummy;}
796 else if(strcmp(d1,"fTimeSigma")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fTimeSigma=(Double_t)ddummy;}
797 else if(strcmp(d1,"fADCSat")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fADCSat=(Int_t)dummy;}
798 else if(strcmp(d1,"fZeroSup")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fZeroSup=(Int_t)dummy;}
799 else if(strcmp(d1,"fNRow")==0){
800 fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNRow=(Int_t)dummy;
802 LOG(AliL3Log::kError,"AliL3Transform::Init","Overflow")<<"Number of PadRows should be 159! Check and fgrep the code for 159 to see the consequences of this major change!"<<ENDLOG;
805 else if(strcmp(d1,"fNRotShift")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fNRotShift=(Double_t)ddummy;}
806 else if(strcmp(d1,"fX[0]")==0){
807 fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fX[0]=(Double_t)ddummy;
808 for(Int_t i=1;i<fNRow;i++){fscanf(fptr,"%s %s %lf %s",d1,d2,&ddummy,d3);fX[i]=(Double_t)ddummy;}
810 else if(strcmp(d1,"fNPads[0]")==0){
811 fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNPads[0]=(Int_t)dummy;
812 for(Int_t i=1;i<fNRow;i++){fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fNPads[i]=(Int_t)dummy;}
814 else if(strcmp(d1,"fNRows[0]")==0){
815 fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNRows[0]=(Int_t)dummy;
816 for(Int_t i=1;i<fNPatches;i++){fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fNRows[i]=(Int_t)dummy;}
818 else if(strcmp(d1,"fRows[0][0]")==0){
819 fscanf(fptr,"%s %d %s",d2,&dummy,d3);fRows[0][0]=(Int_t)dummy;
820 fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fRows[0][1]=(Int_t)dummy;
821 for(Int_t i=1;i<fNPatches;i++){
822 fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fRows[i][0]=(Int_t)dummy;
823 fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fRows[i][1]=(Int_t)dummy;
826 else if(strcmp(d1,"fSlice2Sector[0][0]")==0){
827 fscanf(fptr,"%s %d %s",d2,&dummy,d3);fSlice2Sector[0][0]=(Int_t)dummy;
828 fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fSlice2Sector[0][1]=(Int_t)dummy;
829 for(Int_t i=1;i<fNSlice;i++){
830 fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fSlice2Sector[i][0]=(Int_t)dummy;
831 fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fSlice2Sector[i][1]=(Int_t)dummy;
834 else if(strcmp(d1,"fSector2Slice[0]")==0){
835 fscanf(fptr,"%s %d %s",d2,&dummy,d3);fSector2Slice[0]=(Int_t)dummy;
836 for(Int_t i=1;i<fNSector;i++){fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fSector2Slice[i]=(Int_t)dummy;}
838 else if(strcmp(d1,"fSectorLow[0]")==0){
839 fscanf(fptr,"%s %d %s",d2,&dummy,d3);fSectorLow[0]=(Int_t)dummy;
840 for(Int_t i=1;i<fNSector;i++){fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fSectorLow[i]=(Int_t)dummy;}
842 else if(strcmp(d1,"fCos[0]")==0){
843 fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fCos[0]=(Double_t)ddummy;
844 for(Int_t i=1;i<fNSlice;i++){fscanf(fptr,"%s %s %lf %s",d1,d2,&ddummy,d3);fCos[0]=(Double_t)ddummy;}
846 else if(strcmp(d1,"fSin[0]")==0){
847 fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fSin[0]=(Double_t)ddummy;
848 for(Int_t i=1;i<fNSlice;i++){fscanf(fptr,"%s %s %lf %s",d1,d2,&ddummy,d3);fSin[0]=(Double_t)ddummy;}
852 //The first multiplier gives the scale factor used to modify the field map
853 //defined by the second multiplier.
854 fBField=fBFieldFactor*fSolenoidBField*0.1;
858 //Test if new config file has been used.
859 if(fVersion==fV_deprecated){
860 LOG(AliL3Log::kError,"AliL3Transform::Init","Version")
861 <<"Version is deprecated, you have to create a new config file."<<ENDLOG;
868 Bool_t AliL3Transform::ReadInit(Char_t *path)
870 //Read all the parameters from a aliroot file, and store it in a temporary
871 //file which is read by Init. Use this if you want to read the parameters from
872 //the rootfile "every" time.
875 LOG(AliL3Log::kError,"AliL3Transform::ReadInit","Version")
876 <<"You have to compile with use_aliroot flag in order to read from AliROOT file"<<ENDLOG;
879 Char_t filename[1024];
880 //first test whether provided path is the rootfile itself
881 Int_t saveErrIgLevel=gErrorIgnoreLevel;
882 gErrorIgnoreLevel=kFatal; //dont report errors
883 TFile *rootfile = TFile::Open(path);
884 if(rootfile->IsZombie())
885 { //ok assume its path to alirunfile file
886 sprintf(filename,"%s/alirunfile.root",path); //create rootfile name
887 } else { //path contains itself the rootfile name
889 sprintf(filename,"%s",path);
891 gErrorIgnoreLevel=saveErrIgLevel;
892 //finally make dummy init file /tmp/l3transform.config
893 if(MakeInitFile(filename,"/tmp/"))
895 Bool_t ret=Init("/tmp/");
896 //Move the temp file to /tmp/l3transform.config-"time in seconds"
898 sprintf(filename,"/tmp/l3transform.config-%ld",(long)time.GetSec());
899 gSystem->Rename("/tmp/l3transform.config",filename);
907 Bool_t AliL3Transform::MakeInitFile(Char_t *filename,Char_t *path)
909 //Get the parameters from rootfile, and store it on the file "l3transform.config"
910 //which is being read by Init. fVersion will be fV_aliroot!
913 LOG(AliL3Log::kError,"AliL3Transform::MakeInitFile","Version")
914 <<"You have to compile with use_aliroot flag in order to use this function"<<ENDLOG;
917 TFile *rootfile = TFile::Open(filename);
920 LOG(AliL3Log::kError,"AliL3Transform::MakeInitFile","File")
921 <<"Could not open file: "<<filename<<ENDLOG;
924 AliRun *gAlice = (AliRun*)rootfile->Get("gAlice");
927 LOG(AliL3Log::kError,"AliL3Transform::MakeInitFile","File")
928 <<"No gAlice in file: "<<filename<<ENDLOG;
931 AliTPCParamSR *param=(AliTPCParamSR*)rootfile->Get(GetParamName());
934 LOG(AliL3Log::kError,"AliL3Transform::MakeInitFile","File")
935 <<"No TPC parameters found"<<ENDLOG;
939 AliTPCPRF2D * prfinner = new AliTPCPRF2D;
940 AliTPCPRF2D * prfouter1 = new AliTPCPRF2D;
941 AliTPCPRF2D * prfouter2 = new AliTPCPRF2D;
942 AliTPCRF1D * rf = new AliTPCRF1D(kTRUE);
943 rf->SetGauss(param->GetZSigma(),param->GetZWidth(),1.);
944 rf->SetOffset(3*param->GetZSigma());
947 TDirectory *savedir=gDirectory;
948 TFile *prf_file = TFile::Open("$ALICE_ROOT/TPC/AliTPCprf2d.root");
949 if (!prf_file->IsOpen())
951 LOG(AliL3Log::kError,"AliL3Transform::MakeInitFile","File")
952 <<"Can't open $ALICE_ROOT/TPC/AliTPCprf2d.root !"<<ENDLOG;
955 prfinner ->Read("prf_07504_Gati_056068_d02");
956 prfouter1->Read("prf_10006_Gati_047051_d03");
957 prfouter2->Read("prf_15006_Gati_047051_d03");
961 param->SetInnerPRF(prfinner);
962 param->SetOuter1PRF(prfouter1);
963 param->SetOuter2PRF(prfouter2);
964 param->SetTimeRF(rf);
966 fNTimeBins = param->GetMaxTBin()+1;
967 fNRowLow = param->GetNRowLow();
968 fNRowUp = param->GetNRowUp();
969 fNRowUp1 = param->GetNRowUp1();
970 fNRowUp2 = param->GetNRowUp2();
971 fNRow= fNRowLow + fNRowUp;
973 LOG(AliL3Log::kError,"AliL3Transform::MakeInitFile","fNRow")
974 <<"Number of rows have changed in ALIROOT"<<ENDLOG;
978 fNSectorLow = param->GetNInnerSector();
979 fNSectorUp = param->GetNOuterSector();
980 fNSector = fNSectorLow + fNSectorUp;
982 //test whether they were changes to the rotation shift
984 Float_t irotshift = param->GetInnerAngleShift(); //shift angle
985 Float_t orotshift = param->GetOuterAngleShift(); //shift angle
986 const Float_t kDegtoRad = 0.01745329251994;
987 Int_t shift1=TMath::Nint(irotshift/kDegtoRad);
988 Int_t shift2=TMath::Nint(orotshift/kDegtoRad+0.1);
989 if((shift1!=shift2) || (shift1!=10)){
990 LOG(AliL3Log::kError,"AliL3Transform::MakeInitFile","Rotshiftangle")
991 <<"Rotation shift angle has changed in ALIROOT"<<ENDLOG;
994 fNRotShift=0.5; //our version of the shift angle
998 fBFieldFactor=(Double_t)gAlice->Field()->Factor();
999 fSolenoidBField=(Double_t)gAlice->Field()->SolenoidField();
1000 fPadPitchWidthLow=param->GetInnerPadPitchWidth();
1001 fPadPitchWidthUp=param->GetOuterPadPitchWidth();
1002 fZWidth=param->GetZWidth();
1003 fZSigma=param->GetZSigma();
1004 fZLength=param->GetZLength();
1005 fZOffset=param->GetZOffset();
1006 fDiffT=param->GetDiffT();
1007 fDiffL=param->GetDiffL();
1008 fOmegaTau=param->GetOmegaTau();
1009 fInnerPadLength=param->GetInnerPadLength();
1010 fOuter1PadLength=param->GetOuter1PadLength();
1011 fOuter2PadLength=param->GetOuter2PadLength();
1012 fInnerPRFSigma=param->GetInnerPRF()->GetSigmaX();
1013 fOuter1PRFSigma=param->GetOuter1PRF()->GetSigmaX();
1014 fOuter2PRFSigma=param->GetOuter2PRF()->GetSigmaX();
1015 fTimeSigma=param->GetTimeRF()->GetSigma();
1016 fADCSat=param->GetADCSat();
1017 fZeroSup=param->GetZeroSup();
1018 fNSlice=fNSectorLow;
1021 for(Int_t i=0;i<fNRow;i++){
1023 if( i < fNRowLow){sec =0;row =i;}
1024 else{sec = fNSectorLow;row =i-fNRowLow;}
1025 fX[i]=param->GetPadRowRadii(sec,row);
1027 for(Int_t i=0;i<fNRow;i++){
1029 if( i < fNRowLow){sec =0;row =i;}
1030 else{sec = fNSectorLow;row =i-fNRowLow;}
1031 fNPads[i]=param->GetNPads(sec,row);
1033 for(Int_t i=0;i<fNSector;i++){
1034 if(i<fNSectorLow) fSectorLow[i]=1;
1035 else fSectorLow[i]=0;
1038 Char_t tofile[1024];
1039 sprintf(tofile,"%s/l3transform.config",path);
1040 //cout << tofile <<endl;
1041 return SaveInitFile(tofile);
1045 Bool_t AliL3Transform::SaveInitFile(Char_t *filenamepath)
1047 //store the parameters in the file "filenamepath"
1049 FILE *f = fopen(filenamepath,"w");
1055 fprintf(f,"void AliL3Transform::Init(){\n");
1056 fprintf(f," fVersion = %d;\n", fVersion);
1057 fprintf(f," fBFieldFactor = %.3f;\n",fBFieldFactor);
1058 fprintf(f," fSolenoidBField = %.3f;\n",fSolenoidBField);
1059 fprintf(f," fNTimeBins = %d;\n",fNTimeBins);
1060 fprintf(f," fNRowLow = %d;\n",fNRowLow);
1061 fprintf(f," fNRowUp = %d;\n",fNRowUp);
1062 fprintf(f," fNRowUp1 = %d;\n",fNRowUp1);
1063 fprintf(f," fNRowUp2 = %d;\n",fNRowUp2);
1064 fprintf(f," fNSectorLow = %d;\n",fNSectorLow);
1065 fprintf(f," fNSectorUp = %d;\n",fNSectorUp);
1066 fprintf(f," fNSector = %d;\n",fNSector);
1067 fprintf(f," fPadPitchWidthLow = %.3f;\n",fPadPitchWidthLow);
1068 fprintf(f," fPadPitchWidthUp = %.3f;\n",fPadPitchWidthUp);
1069 fprintf(f," fZWidth = %.4f;\n",fZWidth);
1070 fprintf(f," fZSigma = %.4f;\n",fZSigma);
1071 fprintf(f," fZLength = %.4f;\n",fZLength);
1072 fprintf(f," fZOffset = %.4f;\n",fZOffset);
1073 fprintf(f," fDiffT = %.4f;\n",fDiffT);
1074 fprintf(f," fDiffL = %.4f;\n",fDiffL);
1075 fprintf(f," fOmegaTau = %.4f;\n",fOmegaTau);
1076 fprintf(f," fInnerPadLength = %.3f;\n",fInnerPadLength);
1077 fprintf(f," fOuter1PadLength = %.3f;\n",fOuter1PadLength);
1078 fprintf(f," fOuter2PadLength = %.3f;\n",fOuter2PadLength);
1079 fprintf(f," fInnerPRFSigma = %.6f;\n",fInnerPRFSigma);
1080 fprintf(f," fOuter1PRFSigma = %.6f;\n",fOuter1PRFSigma);
1081 fprintf(f," fOuter2PRFSigma = %.6f;\n",fOuter2PRFSigma);
1082 fprintf(f," fTimeSigma = %.6f;\n",fTimeSigma);
1083 fprintf(f," fADCSat = %d;\n",fADCSat);
1084 fprintf(f," fZeroSup = %d;\n",fZeroSup);
1085 fprintf(f," fNSlice = %d;\n",fNSlice);
1086 fprintf(f," fNRow = %d;\n",fNRow);
1087 fprintf(f," fNRotShift = %.2f;\n",fNRotShift);
1089 for(Int_t i=0;i<fNRow;i++){
1090 fprintf(f," fX[%d] = %3.2f;\n",i,fX[i]);
1092 for(Int_t i=0;i<fNRow;i++){
1093 fprintf(f," fNPads[%d] = %d;\n",i,fNPads[i]);
1096 //Slice/Sector dont belong to aliroot, but we want to be flexible
1097 for(Int_t i=0;i<fNSlice;i++){
1098 fprintf(f," fSlice2Sector[%d][0] = %d;\n",i,fSlice2Sector[i][0]);
1099 fprintf(f," fSlice2Sector[%d][1] = %d;\n",i,fSlice2Sector[i][1]);
1101 for(Int_t i=0;i<fNSector;i++){
1102 fprintf(f," fSector2Slice[%d] = %d;\n",i,fSector2Slice[i]);
1104 for(Int_t i=0;i<fNSector;i++){
1105 fprintf(f," fSectorLow[%d] = %d;\n",i,fSectorLow[i]);
1108 //Patches also dont really belong to the aliroot settings (but nevermind)
1109 for(Int_t i=0;i<fNPatches;i++){
1110 fprintf(f," fNRows[%d] = %d;\n",i,fNRows[i]);
1112 for(Int_t i=0;i<fNPatches;i++){
1113 fprintf(f," fRows[%d][0] = %d;\n",i,fRows[i][0]);
1114 fprintf(f," fRows[%d][1] = %d;\n",i,fRows[i][1]);
1117 //Rotation shift is an addon, too
1118 for(Int_t i=0;i<fNSlice;i++){
1119 Float_t cs = cos( (2*fPi/18) * (i+fNRotShift) );
1120 fprintf(f," fCos[%d] = %.10f;\n",i,cs);
1122 for(Int_t i=0;i<fNSlice;i++){
1123 Float_t sn = sin( (2*fPi/18) * (i+fNRotShift) );
1124 fprintf(f," fSin[%d] = %.10f;\n",i,sn);
1130 LOG(AliL3Log::kInformational,"AliL3Transform::SaveInitFile","File created")
1131 <<"Init file \""<<filenamepath<<"\" created"<<ENDLOG;
1136 Int_t AliL3Transform::GetNPads(Int_t row)
1138 if(row < 0 || row >= fNRow)
1140 LOG(AliL3Log::kError,"AliL3Transform::GetNPads","Row")
1141 <<AliL3Log::kDec<<"Wrong row "<<row<<ENDLOG;
1148 Int_t AliL3Transform::GetFirstRow(Int_t patch)
1152 else if(patch < -1 || patch >= 6)
1154 LOG(AliL3Log::kError,"AliL3Transform::GetFirstRow","Patch")
1155 <<AliL3Log::kDec<<"Wrong patch "<<patch<<ENDLOG;
1159 return fRows[patch][0];
1162 Int_t AliL3Transform::GetLastRow(Int_t patch)
1166 else if(patch < -1 || patch >= 6)
1168 LOG(AliL3Log::kError,"AliL3Transform::GetLastRow","Patch")
1169 <<AliL3Log::kDec<<"Wrong patch "<<patch<<ENDLOG;
1173 return fRows[patch][1];
1176 Int_t AliL3Transform::GetNRows(Int_t patch)
1180 else if(patch < -1 || patch >= 6)
1182 LOG(AliL3Log::kError,"AliL3Transform::GetNRows","Patch")
1183 <<AliL3Log::kDec<<"Wrong patch "<<patch<<ENDLOG;
1187 return fNRows[patch];
1190 Int_t AliL3Transform::GetPadRow(Float_t xvalue)
1192 //Find the padrow number corresponding to cartesian _local_ x value
1194 if(xvalue < 0 || xvalue > 250)
1196 LOG(AliL3Log::kError,"AliL3Transform::GetPadRow","X-value")
1197 <<AliL3Log::kDec<<"Suspicious x-value, make sure it is in local coordinate! "
1202 Int_t x = (Int_t)rint(xvalue*10);
1203 if(x < (Int_t)rint(fX[1]*10))
1205 else if(x > (Int_t)rint(fX[fNRow-2]*10))
1209 Int_t padrow=1; //Of course, a more clever algorithm could help here
1210 while(padrow < fNRow-2)
1212 if(x > (Int_t)rint(fX[padrow-1]*10) && x < (Int_t)rint(fX[padrow+1]*10))
1220 Int_t AliL3Transform::GetPatch(Int_t padrow)
1222 if(padrow < 0 || padrow >= fNRow)
1224 LOG(AliL3Log::kError,"AliL3Transform::GetPatch","Padrow")
1225 <<AliL3Log::kDec<<"Wrong padrow "<<padrow<<ENDLOG;
1229 while(patch < fNPatches)
1231 if(padrow >= fRows[patch][0] && padrow <= fRows[patch][1])
1238 Double_t AliL3Transform::GetPadLength(Int_t padrow)
1240 if(padrow >= fNRow){
1241 LOG(AliL3Log::kError,"AliL3Transform::GetPadLength","Padrow")
1242 <<AliL3Log::kDec<<"Wrong padrow "<<padrow<<ENDLOG;
1246 if(padrow < fNRowLow)
1247 return fInnerPadLength;
1248 if(padrow >= fNRowLow && padrow < fNRowLow + fNRowUp1 - 1)
1249 return fOuter1PadLength;
1250 if(padrow >= fNRowLow + fNRowUp1 - 1)
1251 return fOuter2PadLength;
1253 //should never happen
1254 LOG(AliL3Log::kError,"AliL3Transform::GetPadLength","Padrow")
1255 <<AliL3Log::kDec<<"Wrong padrow "<<padrow<<ENDLOG;
1259 Double_t AliL3Transform::GetPadPitchWidth(Int_t patch)
1261 if(patch < 0 || patch > fNPatches)
1263 LOG(AliL3Log::kError,"AliL3Transform::GetPadPitchWidth","patct")
1264 <<AliL3Log::kDec<<"Wrong patch "<<patch<<ENDLOG;
1267 return patch < 2 ? fPadPitchWidthLow : fPadPitchWidthUp;
1270 Double_t AliL3Transform::GetParSigmaY2(Int_t padrow,Float_t z,Float_t angle)
1272 //Calculate the expected transverse cluster width as a function of
1273 //drift distance and crossing angle.
1274 //z = local z-coordinate of cluster
1275 //angle = track crossing angle with normal to padrow plane
1276 //return value = sigma^2 (cartesian coordinates)
1280 drift = fZLength - z;
1282 drift = fZLength + z;
1284 Double_t t1 = GetPRFSigma(padrow)*GetPRFSigma(padrow);
1285 Double_t t2 = fDiffT*fDiffT*drift;
1286 Double_t t3 = GetPadLength(padrow)*GetPadLength(padrow)*tan(angle)*tan(angle)/12;
1287 Double_t t4 = fAnodeWireSpacing*fAnodeWireSpacing*(tan(angle) - fOmegaTau)*(tan(angle) - fOmegaTau)/12;
1289 return (t1 + t2 + t3 + t4);
1292 Double_t AliL3Transform::GetParSigmaZ2(Int_t padrow,Float_t z,Float_t tgl)
1294 //Calculate the expected longitudinal cluster width as a function of
1295 //drift distance and track crossing angle.
1296 //z = local z-coordinate of cluster
1297 //tgl = tan(dipangle)
1298 //return value = sigma^2 (cartesian coordinates)
1302 drift = AliL3Transform::GetZLength() - z;
1304 drift = AliL3Transform::GetZLength() + z;
1306 Double_t t1 = fZSigma*fZSigma;
1307 Double_t t2 = fDiffL*fDiffL*drift;
1308 Double_t t3 = GetPadLength(padrow)*GetPadLength(padrow)*tgl*tgl/12;
1310 return (t1 + t2 + t3);
1313 Double_t AliL3Transform::GetPRFSigma(Int_t padrow)
1315 if(padrow >= fNRow){
1316 LOG(AliL3Log::kError,"AliL3Transform::GetPRFSigma","Padrow")
1317 <<AliL3Log::kDec<<"Wrong padrow "<<padrow<<ENDLOG;
1320 if(padrow < fNRowLow)
1321 return fInnerPRFSigma;
1322 if(padrow >= fNRowLow && padrow < fNRowLow + fNRowUp1 - 1)
1323 return fOuter1PRFSigma;
1324 if(padrow >= fNRowLow + fNRowUp1 - 1)
1325 return fOuter2PRFSigma;
1327 //should never happen
1328 LOG(AliL3Log::kError,"AliL3Transform::GetPRFSigma","Padrow")
1329 <<AliL3Log::kDec<<"Wrong padrow "<<padrow<<ENDLOG;
1333 Double_t AliL3Transform::GetEta(Float_t *xyz)
1335 Double_t r3 = sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]+xyz[2]*xyz[2]);
1336 Double_t eta = 0.5 * log((r3+xyz[2])/(r3-xyz[2]));
1340 void AliL3Transform::XYZtoRPhiEta(Float_t *rpe, Float_t *xyz)
1342 rpe[0] = sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]+xyz[2]*xyz[2]);
1343 rpe[1] = atan2(xyz[1],xyz[0]);
1344 rpe[2] = 0.5 * log((rpe[0]+xyz[2])/(rpe[0]-xyz[2]));
1347 Double_t AliL3Transform::GetEta(Int_t slice,Int_t padrow,Int_t pad,Int_t time)
1351 Slice2Sector(slice,padrow,sector,row);
1352 Raw2Local(xyz,sector,row,pad,time);
1357 Double_t AliL3Transform::GetPhi(Float_t *xyz)
1359 Double_t phi = atan2(xyz[1],xyz[0]);
1363 Bool_t AliL3Transform::Slice2Sector(Int_t slice, Int_t slicerow, Int_t & sector, Int_t &row)
1365 if(slicerow<0&&slicerow>=fNRow){
1366 LOG(AliL3Log::kError,"AliL3Transform::Slice2Sector","Slicerow")
1367 <<AliL3Log::kDec<<"Wrong slicerow "<<slicerow<<ENDLOG;
1370 if(slice<0||slice>=fNSlice){
1371 LOG(AliL3Log::kError,"AliL3Transform::Slice2Sector","Slice")
1372 <<AliL3Log::kDec<<"Wrong slice "<<slice<<ENDLOG;
1376 if(slicerow<fNRowLow){
1377 sector = fSlice2Sector[slice][0];
1381 sector = fSlice2Sector[slice][1];
1382 row = slicerow-fNRowLow;
1388 Bool_t AliL3Transform::Sector2Slice(Int_t & slice, Int_t sector)
1390 if(sector<0||sector>=fNSector){
1391 LOG(AliL3Log::kError,"AliL3Transform::Sector2Slice","Sector")
1392 <<AliL3Log::kDec<<"Wrong sector "<<sector<<ENDLOG;
1396 slice=fSector2Slice[sector];
1401 Bool_t AliL3Transform::Sector2Slice(Int_t & slice, Int_t & slicerow, Int_t sector, Int_t row)
1403 if(sector<0 || sector>=fNSector){
1404 LOG(AliL3Log::kError,"AliL3Transform::Sector2Slice","Sector")
1405 <<AliL3Log::kDec<<"Wrong sector "<<sector<<ENDLOG;
1409 LOG(AliL3Log::kError,"AliL3Transform::Sector2Slice","Row")
1410 <<AliL3Log::kDec<<"Wrong row "<<row<<ENDLOG;
1414 if(fSectorLow[sector]){
1416 LOG(AliL3Log::kError,"AliL3Transform::Sector2Slice","Row")
1417 <<AliL3Log::kDec<<"Wrong row "<<row<<ENDLOG;
1420 slice = fSector2Slice[sector];
1425 LOG(AliL3Log::kError,"AliL3Transform::Sector2Slice","Row")
1426 <<AliL3Log::kDec<<"Wrong row "<<row<<ENDLOG;
1429 slice = fSector2Slice[sector];
1430 slicerow = row + fNRowLow;
1436 Double_t AliL3Transform::Row2X(Int_t slicerow){
1437 if(slicerow<0||slicerow>=fNRow){
1438 LOG(AliL3Log::kError,"AliL3Transform::Row2X","Slicerow")
1439 <<AliL3Log::kDec<<"Wrong slicerow "<<slicerow<<ENDLOG;
1442 return fX[slicerow];
1445 void AliL3Transform::Local2Global(Float_t *xyz,Int_t slice)
1447 //Transformation to global coordinate system
1448 Float_t x0 = xyz[0];
1449 Float_t y0 = xyz[1];
1451 xyz[0]=x0*fCos[slice]-y0*fSin[slice];
1452 xyz[1]=x0*fSin[slice]+y0*fCos[slice];
1453 xyz[2]=xyz[2];//global z=local z
1456 void AliL3Transform::Local2GlobalAngle(Float_t *angle,Int_t slice){
1457 angle[0] = fmod(angle[0]+(slice+fNRotShift)*(2*fPi/18),2*fPi);
1460 void AliL3Transform::Global2LocalAngle(Float_t *angle,Int_t slice){
1461 angle[0] = angle[0]-(slice+fNRotShift)*(2*fPi/18);
1462 if(angle[0]<0) angle[0]+=2*fPi;
1465 void AliL3Transform::Raw2Local(Float_t *xyz,Int_t sector,Int_t row,Float_t pad,Float_t time)
1467 //Transformation from rawdata to local coordinate system
1469 Int_t slice,slicerow;
1470 Sector2Slice(slice, slicerow, sector, row);
1473 xyz[0]=Row2X(slicerow);
1476 Int_t npads= fNPads[slicerow];
1478 if(fSectorLow[sector])
1479 xyz[1]=(pad-0.5*(npads-1))*fPadPitchWidthLow;
1481 xyz[1]=(pad-0.5*(npads-1))*fPadPitchWidthUp;
1483 //Z-Value (remember PULSA Delay)
1484 //xyz[2]=fZWidth*time-3.*fZSigma;
1485 xyz[2]=fZWidth*time-fZOffset;
1487 xyz[2]=fZLength-xyz[2];
1489 xyz[2]=xyz[2]-fZLength;
1492 void AliL3Transform::Local2Global(Float_t *xyz,Int_t sector,Int_t row)
1494 //Transformation to global coordinate system
1495 Int_t slice,slicerow;
1496 Sector2Slice(slice, slicerow, sector, row);
1497 Float_t r=Row2X(slicerow); //have to get x value first
1499 xyz[0]=r*fCos[slice]-xyz[1]*fSin[slice];
1500 xyz[1]=r*fSin[slice]+xyz[1]*fCos[slice];
1501 xyz[2]=xyz[2];//global z=local z
1504 Double_t AliL3Transform::GetMaxY(Int_t slicerow)
1507 if(slicerow < fNRowLow)
1508 return fPadPitchWidthLow*fNPads[slicerow]/2;
1511 return fPadPitchWidthUp*fNPads[slicerow]/2;
1515 void AliL3Transform::Global2Local(Float_t *xyz,Int_t sector,Bool_t isSlice)
1519 Sector2Slice(slice, sector);
1523 Float_t x1 = xyz[0]*fCos[slice] + xyz[1]*fSin[slice];
1524 Float_t y1 = -xyz[0]*fSin[slice] + xyz[1]*fCos[slice];
1529 void AliL3Transform::Raw2Global(Float_t *xyz,Int_t sector,Int_t row,Float_t pad,Float_t time)
1531 //Transformation from raw to global coordinates
1533 Raw2Local(xyz,sector,row,pad,time);
1534 Local2Global(xyz,sector,row);
1537 void AliL3Transform::Local2Raw(Float_t *xyz,Int_t sector,Int_t row)
1539 //Transformation from local coordinates to raw
1541 Int_t slice,slicerow;
1542 Sector2Slice(slice, slicerow, sector, row);
1545 //xyz[0]=GetPadRow(xyz[0]);
1547 if(fSectorLow[sector])
1548 xyz[1]=xyz[1]/fPadPitchWidthLow+0.5*(fNPads[slicerow]-1);
1550 xyz[1]=xyz[1]/fPadPitchWidthUp+0.5*(fNPads[slicerow]-1);
1553 if(slice < 18) sign = 1;
1554 xyz[2]=fZLength-sign*xyz[2];
1555 xyz[2]=(xyz[2]+fZOffset)/fZWidth;
1558 void AliL3Transform::Global2Raw(Float_t *xyz,Int_t sector,Int_t row)
1560 //Transformation from global coordinates to raw.
1562 Global2Local(xyz,sector);
1563 Local2Raw(xyz,sector,row);
1566 void AliL3Transform::PrintCompileOptions()
1568 cout << "Compiler (g++) version used: " << GCCVERSION << endl;
1571 cout << "STANDALONE version: -Dno_root was given." << endl;
1573 const Char_t *roottest="$ROOTSYS/bin/root -n -b -q | grep Version | cut -b 17-25 | cut -d\" \" -f1";
1576 const Char_t *aliroottest="if test -n \"`cd $ALICE_ROOT/STEER/ && cvs stat AliRun.cxx | grep \"Sticky Tag\" | grep none`\"; then echo HEAD; else cd $ALICE_ROOT/STEER/ && cvs stat AliRun.cxx | grep \"Sticky Tag\" | cut -b 18- | cut -d\" \" -f1; fi";
1578 const Char_t *aliroottest="Unknown";
1580 cout << "ALIROOT version: -Duse_aliroot and -Duse_root was given." << endl;
1581 cout << "Root Version: " << ROOTVERSION << " found " << flush;
1582 gSystem->Exec(roottest);
1584 cout << "AliRoot Version: " << ALIROOTVERSION << " found " << flush;
1585 gSystem->Exec(aliroottest);
1587 cout << "ROOT version: -Duse_root was given." << endl;
1588 cout << "Root Version: " << ROOTVERSION << " found " << flush;
1589 gSystem->Exec(roottest);
1594 cout << "Using Monte Carlo Info: -Ddo_mc was given." << endl;
1596 cout << "NOT using Monte Carlo Info: -Ddo_mc was not given." << endl;
1600 cout << "Using logging classes (MLUC): -Duse_logging was given." << endl;
1602 cout << "NOT using logging classes (MLUC): -Duse_logging not was given." << endl;
1606 cout << "Using ASV version for the digitization: -DASVVERSION was given." << endl;
1608 cout << "NOT using ASV version for the digitization: -DASVVERSION was not given." << endl;