Adding visulaization for ExB effect (Marian)
authormarian <marian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 24 Feb 2008 21:13:08 +0000 (21:13 +0000)
committermarian <marian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 24 Feb 2008 21:13:08 +0000 (21:13 +0000)
TPC/AliTPCExB.cxx
TPC/AliTPCExB.h
TPC/AliTPCExBFirst.cxx

index cff7236..1f95318 100644 (file)
@@ -1,4 +1,131 @@
 #include "AliTPCExB.h"
+#include "TMath.h"
+#include "TTreeStream.h"
+
+
+//
+// Abstract class for ExB effect parameterization
+// 
+//
+// 
+// The ExB correction map is stored in the calib DB
+// The lookup can be dumped to the tree:
+/*
+
+   //
+  char *storage = "local://OCDBres"
+  Int_t RunNumber=0;
+  AliCDBManager::Instance()->SetDefaultStorage(storage);
+  AliCDBManager::Instance()->SetRun(RunNumber) 
+  AliTPCExBFirst * exb = AliTPCcalibDB::Instance()->GetExB();
+  //
+  // See example macro $ALICE_ROOT/TPC/macros/AliTPCExBdraw.C 
+  //
+  .L $ALICE_ROOT/TPC/macros/AliTPCExBdraw.C 
+  Draw0(0)
+
+
+
+
+*/
+
+AliTPCExB* AliTPCExB::fgInstance = 0;
 
 ClassImp(AliTPCExB)
 
+
+void AliTPCExB::TestExB(const char* fileName) {
+  //
+  // well, as the name sais...
+  //
+  TTreeSRedirector ts(fileName);
+  Double_t x[3];
+  for (x[0]=-250.;x[0]<=250.;x[0]+=10.)
+    for (x[1]=-250.;x[1]<=250.;x[1]+=10.)
+      for (x[2]=-250.;x[2]<=250.;x[2]+=10.) {
+       Double_t d[3];
+       Correct(x,d);
+       Double_t r=TMath::Sqrt(x[0]*x[0]+x[1]*x[1]);
+       Double_t rd=TMath::Sqrt(d[0]*d[0]+d[1]*d[1]);
+       Double_t dr=r-rd;
+       Double_t phi=TMath::ATan2(x[0],x[1]);
+       Double_t phid=TMath::ATan2(d[0],d[1]);
+       Double_t dphi=phi-phid;
+       if (dphi<0.) dphi+=TMath::TwoPi();
+       if (dphi>TMath::Pi()) dphi=TMath::TwoPi()-dphi;
+       Double_t drphi=r*dphi;
+       Double_t dx=x[0]-d[0];
+       Double_t dy=x[1]-d[1];
+       Double_t dz=x[2]-d[2];
+       ts<<"positions"
+         <<"x0="<<x[0]
+         <<"x1="<<x[1]
+         <<"x2="<<x[2]
+         <<"dx="<<dx
+         <<"dy="<<dy
+         <<"dz="<<dz
+         <<"r="<<r
+         <<"phi="<<phi
+         <<"dr="<<dr
+         <<"drphi="<<drphi
+         <<"\n";
+      }
+}
+
+
+
+Double_t AliTPCExB::GetDr(Double_t r, Double_t phi, Double_t z){
+  //
+  // Static function
+  // Posibble to us it for visualization 
+  // 
+  //
+  if (!fgInstance) return 0;
+  Double_t pos0[3] = {r*TMath::Sin(phi), r*TMath::Cos(phi),z};
+  Double_t pos1[3];
+  fgInstance->Correct(pos0,pos1);
+  Double_t dx=pos1[0]-pos0[0];
+  Double_t dy=pos1[1]-pos0[1];
+  //  Double_t dz=pos1[2]-pos0[2];
+  return TMath::Sqrt(dx*dx+dy*dy);  
+}
+
+
+Double_t AliTPCExB::GetDrphi(Double_t r, Double_t phi, Double_t z){
+  //
+  //
+  //
+  if (!fgInstance) return 0;
+  Double_t pos0[3] = {r*TMath::Sin(phi), r*TMath::Cos(phi),z};
+  Double_t pos1[3];
+  fgInstance->Correct(pos0,pos1);
+  Double_t dphi=TMath::ATan2(pos1[1],pos1[0])-TMath::ATan2(pos0[1],pos0[0]);
+  return r*dphi;  
+
+}
+
+
+Double_t AliTPCExB::GetDphi(Double_t r, Double_t phi, Double_t z){
+  //
+  //
+  //
+  if (!fgInstance) return 0;
+  Double_t pos0[3] = {r*TMath::Sin(phi), r*TMath::Cos(phi),z};
+  Double_t pos1[3];
+  fgInstance->Correct(pos0,pos1);
+  Double_t dphi=TMath::ATan2(pos1[1],pos1[0])-TMath::ATan2(pos0[1],pos0[0]);
+  return dphi;  
+
+}
+
+Double_t AliTPCExB::GetDz(Double_t r, Double_t phi, Double_t z){
+  //
+  //
+  //
+  if (!fgInstance) return 0;
+  Double_t pos0[3] = {r*TMath::Sin(phi), r*TMath::Cos(phi),z};
+  Double_t pos1[3];
+  fgInstance->Correct(pos0,pos1);
+  Double_t dz=pos1[2]-pos0[2];
+  return dz;  
+}
index d9cd1f3..7e03b41 100644 (file)
@@ -12,7 +12,18 @@ public:
     for (Int_t i=0;i<3;++i)
       corrected[i]=position[i]-(corrected[i]-position[i]);
   }
-
+  //
+  // Test and visulaization
+  //
+  void TestExB(const char* fileName);
+  static Double_t GetDr(Double_t r, Double_t phi, Double_t z);
+  static Double_t GetDrphi(Double_t r, Double_t phi, Double_t z);
+  static Double_t GetDphi(Double_t r, Double_t phi, Double_t z);
+  static Double_t GetDz(Double_t r, Double_t phi, Double_t z);
+  static AliTPCExB*  Instance(){return fgInstance;}
+  static void SetInstance(AliTPCExB*param){fgInstance = param;}
+ protected:
+  static AliTPCExB*   fgInstance; //! Instance of this class (singleton implementation)
   ClassDef(AliTPCExB,0)
 };
 
index 90e8034..1dc0abd 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-////
+//
 // This implementation AliTPCExB is using an aproximate calculation of the ExB
 // effect. Therefore the drift ODE is Taylor expanded and only the first
 // order part is taken.
-////
+//
+// 
+// The ExB correction map is stored in the calib DB
+// To test current version:
+/*
+  char *storage = "local://OCDBres"
+  Int_t RunNumber=0;
+  AliCDBManager::Instance()->SetDefaultStorage(storage);
+  AliCDBManager::Instance()->SetRun(RunNumber) 
+  AliTPCExBFirst * exb = AliTPCcalibDB::Instance()->GetExB();
+
+  //  exb->TestExB("exb.root");
+  // TFile f("exb.root");
+  //positions->Draw("drphi");
+*/
+
+
 
 #include "TMath.h"
 #include "AliFieldMap.h"
@@ -40,6 +56,7 @@ AliTPCExBFirst::AliTPCExBFirst()
   //
   // purely for I/O
   //
+  SetInstance(this);
 }
 
 AliTPCExBFirst::AliTPCExBFirst(const AliMagF *bField,
@@ -57,6 +74,7 @@ AliTPCExBFirst::AliTPCExBFirst(const AliMagF *bField,
   // number of its meshpoints can be supplied.
   //
   ConstructCommon(0,bField);
+  SetInstance(this);
 }
 
 AliTPCExBFirst::AliTPCExBFirst(const AliFieldMap *bFieldMap,
@@ -71,7 +89,7 @@ AliTPCExBFirst::AliTPCExBFirst(const AliFieldMap *bFieldMap,
   // The constructor. One has to supply a field map and an (initial)
   // drift velocity.
   //
-
+  SetInstance(this);
   fkXMin=bFieldMap->Xmin()
     -TMath::Ceil( (bFieldMap->Xmin()+250.0)/bFieldMap->DelX())
     *bFieldMap->DelX();