Esempio n. 1
0
void Mpdshape::SetPosition(TVector3 vec) {
  ostringstream o;
  o.precision(6);
  o.setf(ios::showpoint); 
  o.setf(ios::fixed);
  o << vec.x() << " " << vec.y() << " " << vec.z();
  fPosition.append(o.str().c_str());
}
Esempio n. 2
0
void tv3Read1() {
   //first read example showing how to read all branches
   TVector3 *v = 0;
   TFile *f = new TFile("v3.root");
   TTree *T = (TTree*)f->Get("T");
   T->SetBranchAddress("v3",&v);
   TH1F *h1 = new TH1F("x","x component of TVector3",100,-3,3);
   Int_t nentries = Int_t(T->GetEntries());
   for (Int_t i=0;i<nentries;i++) {
      T->GetEntry(i);
      h1->Fill(v->x());
   }
   h1->Draw();
}
Esempio n. 3
0
	  void qaP3(TString pre, TVector3 v, RhoTuple *n, bool skip=false){

		  if (n==0) return;

		  if(!skip){
			  n->Column(pre+"decayvx", (Float_t) v.x(), 0.0f);
			  n->Column(pre+"decayvy", (Float_t) v.y(), 0.0f);
			  n->Column(pre+"decayvz", (Float_t) v.z(), 0.0f);
		  }
		  else{
			  n->Column(pre+"decayvx", (Float_t) -999, 0.0f);
			  n->Column(pre+"decayvy", (Float_t) -999, 0.0f);
			  n->Column(pre+"decayvz", (Float_t) -999, 0.0f);
		  }

	  }
Esempio n. 4
0
double distance2(double px,double py,double pz, double *p) {
   TVector3 xp(px,py,pz);
   TVector3 x0(p[0], p[1], p[2]);
   TVector3 u (TMath::Sin(p[3])*TMath::Cos(p[4]), TMath::Sin(p[3])*TMath::Sin(p[4]), TMath::Cos(p[3]));

   double coeff = u*(xp-x0);
   TVector3 n = xp - x0 - coeff * u;

   double dx = n.x();
   double dy = n.y();
   double dz = n.z();
   double d2_x = TMath::Power(dx/weight[0], 2);
   double d2_y = TMath::Power(dy/weight[1], 2);
   double d2_z = TMath::Power(dz/weight[2], 2);
   double d2 = d2_x + d2_y + d2_z;

   return d2;
}
Esempio n. 5
0
void KVGeoNavigator::PropagateParticle(KVNucleus* part, TVector3* TheOrigin)
{
   // Propagate a particle through the geometry in the direction of its momentum,
   // until we reach the boundary of the geometry, or until fStopPropagation is set to kFALSE.
   // Propagation will also stop if we encounter a volume whose name begins with "DEADZONE"

   // Define point of origin of particles
   if (TheOrigin) fGeometry->SetCurrentPoint(TheOrigin->X(), TheOrigin->Y(), TheOrigin->Z());
   else fGeometry->SetCurrentPoint(0., 0., 0.);

   // unit vector in direction of particle's momentum
   TVector3 v = part->GetMomentum().Unit();
   // use particle's momentum direction
   fGeometry->SetCurrentDirection(v.x(), v.y(), v.z());
   fGeometry->FindNode();

   fCurrentVolume = fGeometry->GetCurrentVolume();
   fCurrentNode = fGeometry->GetCurrentNode();
   fMotherNode = fGeometry->GetMother();
   fCurrentMatrix = *(fGeometry->GetCurrentMatrix());
   fCurrentPath = fGeometry->GetPath();
   // move along trajectory until we hit a new volume
   fGeometry->FindNextBoundaryAndStep();
   fStepSize = fGeometry->GetStep();
   TGeoVolume* newVol = fGeometry->GetCurrentVolume();
   TGeoNode* newNod = fGeometry->GetCurrentNode();
   TGeoNode* newMom = fGeometry->GetMother();
   TGeoHMatrix* newMatx = fGeometry->GetCurrentMatrix();
   TString newPath = fGeometry->GetPath();

   Double_t XX, YY, ZZ;
   XX = YY = ZZ = 0.;

   // reset user flag for stopping propagation of particle
   SetStopPropagation(kFALSE);

//    Info("PropagateParticle","Beginning: i am in %s on node %s with path %s, and matrix:",
//         fCurrentVolume->GetName(),fCurrentNode->GetName(),fCurrentPath.Data());
//    fCurrentMatrix.Print();

   // track particle until we leave the geometry or until fStopPropagation
   // becomes kTRUE
   while (!fGeometry->IsOutside()) {

      const Double_t* posi = fGeometry->GetCurrentPoint();
      fEntryPoint.SetXYZ(XX, YY, ZZ);
      XX = posi[0];
      YY = posi[1];
      ZZ = posi[2];
      fExitPoint.SetXYZ(XX, YY, ZZ);

      TString vn = GetCurrentVolume()->GetName();
      if (vn.BeginsWith("DEADZONE")) {
         part->GetParameters()->SetValue("DEADZONE", Form("%s/%s", GetCurrentVolume()->GetName(), GetCurrentNode()->GetName()));
         break;
      }

//        Info("PropagateParticle","just before ParticleEntersNewVolume\nnow i am in %s on node %s with path %s and matrix:",
//             fCurrentVolume->GetName(),fCurrentNode->GetName(),fCurrentPath.Data());
//        fCurrentMatrix.Print();

      ParticleEntersNewVolume(part);

      if (StopPropagation()) break;

      fCurrentVolume = newVol;
      fCurrentNode = newNod;
      fMotherNode = newMom;
      fCurrentMatrix = *newMatx;
      fCurrentPath = newPath;

//        Info("PropagateParticle","after ParticleEntersNewVolume\nnow i am in %s on node %s with path %s and matrix:",
//             fCurrentVolume->GetName(),fCurrentNode->GetName(),fCurrentPath.Data());
//        fCurrentMatrix.Print();

      // move on to next volume crossed by trajectory
      fGeometry->FindNextBoundaryAndStep();
      fStepSize = fGeometry->GetStep();
      newVol = fGeometry->GetCurrentVolume();
      newNod = fGeometry->GetCurrentNode();
      newMom = fGeometry->GetMother();
      newMatx = fGeometry->GetCurrentMatrix();
      newPath = fGeometry->GetPath();
   }
}
Esempio n. 6
0
void rotate_3vector(void){

  PI = TMath::Pi();

  TVector3 beam = TVector3(0.,0.,1.);
  TVector3 scat = TVector3(0.2,0.4,1.);
  std::cout << "beam x : " << beam.x() << std::endl;
  std::cout << "beam y : " << beam.y() << std::endl;
  std::cout << "beam z : " << beam.z() << std::endl;
  std::cout << "scat x : " << scat.x() << std::endl;
  std::cout << "scat y : " << scat.y() << std::endl;
  std::cout << "scat z : " << scat.z() << std::endl;

  double bx=beam.x();
  double by=beam.y();
  double bz=beam.z();
  double sx=scat.x();
  double sy=scat.y();
  double sz=scat.z();

  double theta  = acos((bx*sx + by*sy + bz*sz)/sqrt(bx*bx + by*by + bz*bz)/sqrt(sx*sx + sy*sy + sz*sz));
  double theta_ = acos(sz/sqrt(sx*sx+sy*sy+sz*sz));

  std::cout << "theta  : " << theta  << std::endl;
  std::cout << "theta_ : " << theta_ << std::endl;

  TVector3 beam2 = TVector3(0, 1, 0);
  double bx2=beam2.x();
  double by2=beam2.y();
  double bz2=beam2.z();

  std::cout << "beam2 x (nom) : " << beam2.x()/sqrt(bx2*bx2+by2*by2+bz2*bz2) << std::endl;
  std::cout << "beam2 y (nom) : " << beam2.y()/sqrt(bx2*bx2+by2*by2+bz2*bz2) << std::endl;
  std::cout << "beam2 z (nom) : " << beam2.z()/sqrt(bx2*bx2+by2*by2+bz2*bz2) << std::endl;

  double theta_tmp  = - atan(by2/sqrt(bx2*bx2 + bz2*bz2));
  double phi_tmp    = atan2(bx2, bz2);

  std::cout << "theta_tmp  : " << theta_tmp  << std::endl;
  std::cout << "phi_tmp  : " << phi_tmp  << std::endl;

  beam.RotateX(theta_tmp);
  beam.RotateY(phi_tmp);

  scat.RotateX(theta_tmp);
  scat.RotateY(phi_tmp);

  bx=beam.x();
  by=beam.y();
  bz=beam.z();
  sx=scat.x();
  sy=scat.y();
  sz=scat.z();

  std::cout << "roteta beam x : " << bx << std::endl;
  std::cout << "roteta beam y : " << by << std::endl;
  std::cout << "roteta beam z : " << bz << std::endl;
  std::cout << "roteta scat x : " << sx << std::endl;
  std::cout << "roteta scat y : " << sy << std::endl;
  std::cout << "roteta scat z : " << sz << std::endl;


  double theta_rotate  = acos((bx*sx + by*sy + bz*sz)/sqrt(bx*bx + by*by + bz*bz)/sqrt(sx*sx + sy*sy + sz*sz));

  std::cout << "===========================" << std::endl;
  std::cout << "theta         : " << theta  << std::endl;
  std::cout << "theta_rotate  : " << theta_rotate  << std::endl;

}
Esempio n. 7
0
void
ttmexample
(
 char*  inpDir    = "",             // MuDST directory
 char*  inpFile   = "ttm.lis",      // MuDST file(s);                      
 char*  outFile   = "ttm.ndst.root",// output nano dst root file
 Int_t  nFiles    = 150,            // # of MuDST file(s)
 Int_t  nEvents   = -1              // # of events
 )
  // NOTES: 
  // 1. EEmcTTMMaker main "product" is a list of EEmcTTMatch'es which in turn are 
  //    EEmcTower plus a list of StMuTrack's that fullfill certain criteria. 
  // 2. Optionally the Maker created a nanoDst file [ or a 'Not-a-Dst' file :) ]
  // 
{ 
  // load root/root4star libraries
  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
  loadSharedLibraries();
  // load more libraries :)
  gSystem->Load("libmysqlclient");
  gSystem->Load("StDbLib");
  gSystem->Load("StDbBroker");
  gSystem->Load("St_db_Maker");
  // load even more libraries (EEMC stuff) 
  gSystem->Load("StEEmcUtil");
  gSystem->Load("StEEmcDbMaker");
  gSystem->Load("StEEmcPoolTTM");

  // create the chain    
  chain = new StChain("StChain"); 
  
  // now we add Makers to the chain...  some of that is black magic to me :) 
  muDstMaker = new StMuDstMaker(0,0,inpDir,inpFile,"",nFiles);  // muDST main chain
  StMuDbReader  *db          = StMuDbReader::instance();        // need the database
  St_db_Maker   *dbMk        = new St_db_Maker("StarDb", "MySQL:StarDb"); // need more db?
  StEEmcDbMaker *eemcDbMaker = new StEEmcDbMaker("eemcDb");     // need EEMC database  

  // now comment in/out/change the below if you want it your way
  eemcDbMaker->setSectors(1,12);           // request sectors you need (default:1-12)
  eemcDbMaker->setPreferedFlavor("onlped","eemcPMTped"); // request alternative db flavor 

  // finally after so many lines we arrive at the good stuff
  ttm = new  EEmcTTMMaker ("TTM",muDstMaker,eemcDbMaker);
  ttm->SetFileName(outFile); // output nanoDst file
  // have cuts your way (optional)
  ttm->SetMaxCTBSum(1000); 
  ttm->SetMinTrackLength(20.0);
  ttm->SetMinTrackHits(5);
  ttm->SetMinTrackPt(0.5);
  ttm->SetMinTrackEta(0.7);
  ttm->SetMaxTrackEta(2.2);
  ttm->SetDeltaEtaCut(0.7); // ! note this is a fraction of tower width in eta
  ttm->SetDeltaPhiCut(0.7); // ! note this is a fraction of tower width in phi
  // this is even more optional :)
  // the lines here repeat the default
  // ttm->ResetZPositionsArray();
  // ttm->AddZPosition("pres",kEEmcZPRE1+0.1);
  // ttm->AddZPosition("post",kEEmcZPOST-0.1);
  // ttm->AddZPosition("smd" ,kEEmcZSMD);
  ttm->Summary(cout);       // prints cut summary

  StMuDebug::setLevel(0);
  chain->Init();
  chain->ls(3);

  //---------------------------------------------------
  int  stat=0;
  int  event=0;
  while(++event<nEvents) {
    stat=chain->Make();
    // STAR intelligence: stat=2 EOF,stat=4 FATAL; if so break the loop
    // if not OK (and not EOF nor FATAL) !!! try another event
    if( stat==2 || stat==4) break;
    if( stat!=0           ) continue;

    // if no track to tower matches try another event
    if(ttm->GetMatchList()->IsEmpty()) continue;

    // set up iterator and pointers
    TIter  nextMatch(ttm->GetMatchList());
    EEmcTTMatch *tmatch;
    EEmcTower   *tower;
    StMuTrack   *track;
    //event info (for fun), it shows we like xml
    StEventInfo    &evInfo = muDstMaker->muDst()->event()->eventInfo();   
    cerr << "<Event";
    cerr << "Run=\""  << evInfo.runId() << "\"\t";
    cerr << "Event=\""<< evInfo.id()    << "\">\n";
    // loop over all towers with track hits
    while ((tmatch = (EEmcTTMatch*) nextMatch())) {
      tmatch->Out(cerr); // prints all match info
      tower = tmatch->Tower();
      // here's how to acces tower information
      const char *tLabel = tower->TowerLabel();
      int sector = tower->Sec();    // 0..11
      int subsec = tower->SubSec(); // 0..4
      int etabin = tower->Eta();    // 0..11
      float adc  = tower->ADC();    // adc - pedestal
      float de   = tower->dE();     // (adc - pedestal)/gain
      //
      int seclab = tower->SecLabel();    // 1..12
      int sublab = tower->SubSecLabel(); // A..E
      int etalab = tower->EtaLabel();    // 1..12
      // now more than one track may hit a tower
      TIter nextTrack(tmatch->Tracks());
      while((track=(StMuTrack *)nextTrack()))  {
	// how to access StMuTrack consult muDST manual (does not exist)
	TVector3 r;
	// for example one could extrapolate track to a given z-depth
	EEmcTTMatch::ExtrapolateToZ(track,290.0,r);
	double pt = track->pt();
        double x  = r.x();
      }
    }
    cerr << "</Event>" << endl;
  }
  ttm->Summary(cerr);
}