Example #1
0
void runPolyMarker()
{
   // Check creation of JSON for object, where TObject is not first parent
   // Also verify instrumented custom streamer of TPolyMarker3D

   TPolyMarker3D* marker = new TPolyMarker3D(10);
   for (Int_t n=0;n<10;++n)
      marker->SetPoint(n, n*2, n*3, n*4);

   TString json = TBufferJSON::ConvertToJSON(marker);

   cout << json << endl;
}
Example #2
0
void spheres(Int_t nspheres=20, Int_t npoints=100000) {
   // generate random points uniformly distributed over the surface
   // of spheres generated at random positions.

   TCanvas *c1 = new TCanvas("c1","spheres",600,600);
   c1->SetFillColor(kBlack);
   TView *view = new TView(1);
   Double_t k=0.8;
   view->SetRange( -k, -k, -k, k, k, k);
   
   //generate sphere coordinates and radius
   TRandom r;
   if (nspheres <=0) nspheres = 10;
   Double_t *xs = new Double_t[nspheres];
   Double_t *ys = new Double_t[nspheres];
   Double_t *zs = new Double_t[nspheres];
   Double_t *rs = new Double_t[nspheres];
   Int_t i;
   for (i=0;i<nspheres;i++) {
      xs[i] = r.Uniform(-1,1);
      ys[i] = r.Uniform(-1,1);
      zs[i] = r.Uniform(-1,1);
      rs[i] = r.Uniform(0.05,0.25);
   }

   //generate points
   TPolyMarker3D *pm = new TPolyMarker3D(npoints);
   pm->SetMarkerColor(kRed);
   Double_t x,y,z;
   for (Int_t j=0;j<npoints;j++) {
       i = (Int_t)r.Uniform(0,nspheres);  //choose sphere
       r.Sphere(x,y,z,rs[i]);
       pm->SetPoint(j,xs[i]+x, ys[i]+y,zs[i]+z);
   }
   
   delete [] xs;
   delete [] ys;
   delete [] zs;
   delete [] rs;
    
   pm->Draw();
}
void Avalanche::DrawAvalanche() {
	for (uint e=0; e<ax0->size(); e++) {
		/*
		TPolyLine3D* track = new TPolyLine3D(2);
		track->SetPoint(0, ax0->at(e), ay0->at(e), az0->at(e));
		track->SetPoint(1, ax1->at(e), ay1->at(e), az1->at(e));
		track->SetLineWidth(2);
		//track->SetLineStyle(3);
		track->SetLineColor(kGreen);
		track->Draw();
		*/

		TPolyMarker3D* endpoint = new TPolyMarker3D(1);
		endpoint->SetPoint(0, ax1->at(e), ay1->at(e), az1->at(e));
		endpoint->SetMarkerSize(0.5);
		endpoint->SetMarkerStyle(kFullDotLarge);
		endpoint->SetMarkerColor(kRed);
		endpoint->Draw();
	}
}
Example #4
0
//_____________________________________________________________________________
Int_t AliTRDdisplayDigits3D(Int_t event = 0, Int_t thresh = 4
                          , Bool_t sdigits = kFALSE) 
{
  //  
  //  TRD digits display
  //
  //  Input parameter:
  //    <event>   : Event number 
  //    <thresh>  : Threshold to suppress the noise
  //    <sdigits> : If kTRUE it will display summable digits, normal digits otherwise.
  //                The signal event is displayed in yellow.
  //

  Char_t *inputFile = "galice.root";

  // Define the objects
  AliTRDv1       *trd;
  AliTRDgeometry *geo;

  TString       evfoldname = AliConfig::GetDefaultEventFolderName();
  AliRunLoader *runLoader  = AliRunLoader::GetRunLoader(evfoldname);
  if (!runLoader) {
    runLoader = AliRunLoader::Open(inputFile
                                  ,AliConfig::GetDefaultEventFolderName()
                                  ,"UPDATE");
  }
  if (!runLoader) {
    printf("Can not open session for file %s.",inputFile);
    return kFALSE;
  }
   
  if (!runLoader->GetAliRun()) {
    runLoader->LoadgAlice();
  }
  gAlice = runLoader->GetAliRun();  
  if (!gAlice) {
    printf("Could not find AliRun object.\n");
    return kFALSE;
  }

  runLoader->GetEvent(event);
  
  AliLoader *loader = runLoader->GetLoader("TRDLoader");
  if (!loader) {
    printf("Can not get TRD loader from Run Loader");
  }
  loader->LoadDigits();
  
  // Get the pointer to the detector object
  trd = (AliTRDv1*) gAlice->GetDetector("TRD");

  // Get the pointer to the geometry object
  if (trd) {
    geo = trd->GetGeometry();
  }
  else {
    printf("Cannot find the geometry\n");
    return 1;
  }

  AliCDBManager *cdbManager  = AliCDBManager::Instance();
  cdbManager->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
  AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
  calibration->SetRun(0);

  TCanvas *c1 = new TCanvas("digits","TRD digits display",0,0,700,730);
  TView   *v  = new TView(1);
  v->SetRange(-430,-560,-430,430,560,1710);
  v->SetParallel();
  c1->Clear();
  c1->SetFillColor(1);
  c1->SetTheta(90.0);
  c1->SetPhi(0.0);

  Int_t markerColorSignal = 2;
  Int_t markerColorBgnd   = 7;
  Int_t markerColorMerged = 5;
  Int_t mask              = 10000000;

  // Create the digits manager
  AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
  digitsManager->SetSDigits(sdigits);

  // Read the digits from the file
  if (sdigits) {
    digitsManager->ReadDigits(loader->TreeS());
  }
  else {
    if (!loader->TreeD()) {
      printf("mist\n");
      return kFALSE;
    }
    digitsManager->ReadDigits(loader->TreeD());
  }

  Int_t totalsignal = 0;
  Int_t totalbgnd   = 0;
  Int_t totalmerged = 0;
  Int_t timeMax     = calibration->GetNumberOfTimeBins();

  // Loop through all detectors
  for (Int_t idet = 0; idet < geo->Ndet(); idet++) {

    printf("<AliTRDdisplayDigits3D> Loading detector %d\n",idet);
    AliTRDdataArrayI *digits  = digitsManager->GetDigits(idet);
    digits->Expand();

    Int_t isec    = geo->GetSector(idet);
    Int_t icha    = geo->GetChamber(idet);
    Int_t ipla    = geo->GetPlane(idet);
    AliTRDpadPlane *padPlane = new AliTRDpadPlane(ipla,icha);
    Int_t  rowMax = padPlane->GetNrows();
    Int_t  colMax = padPlane->GetNcols();

    Int_t ndigits = digits->GetOverThreshold(thresh);

    if (ndigits > 0) {

      TPolyMarker3D *pmSignal = new TPolyMarker3D(ndigits);
      Int_t isignal = 0;

      for (Int_t time = 0; time < timeMax; time++) {
        for (Int_t  col = 0;  col <  colMax;  col++) {
          for (Int_t  row = 0;  row <  rowMax;  row++) {

            Int_t amp = digits->GetDataUnchecked(row,col,time);

            if (amp > thresh) {
          
              Double_t glb[3];
              Double_t loc[3];

              loc[0] = row;
              loc[1] = col;
              loc[2] = time;
              geo->Local2Global(idet,loc,glb);
              Double_t x = glb[0];
              Double_t y = glb[1];
              Double_t z = glb[2];

              pmSignal->SetPoint(isignal,x,y,z);
              isignal++;
              totalsignal++;

	    }

	  }
        }
      }

      digits->Compress(1,0);

      pmSignal->SetMarkerSize(1); 
      pmSignal->SetMarkerColor(markerColorSignal);
      pmSignal->SetMarkerStyle(1);
      pmSignal->Draw();
   
    }

  }

  delete padPlane;

  TGeometry *geoAlice = gAlice->GetGeometry();
  TNode     *main     = (TNode *) ((geoAlice->GetListOfNodes())->First());
  TIter      next(main->GetListOfNodes());
  TNode     *module   = 0;
  while ((module = (TNode *) next())) {
    Char_t ch[100];
    sprintf(ch,"%s\n",module->GetTitle());
    if ((ch[0] == 'T') && ((ch[1] == 'R') || (ch[1] == 'P'))) {
      module->SetVisibility( 3);
    }
    else {
      module->SetVisibility(-1);
    }
  }
      
  geoAlice->Draw("same");

  c1->Modified(); 
  c1->Update(); 

  return 0;

}
Example #5
0
void AliTRDdisplayTracks(Int_t track=157) 
{

  c1 = new TCanvas( "RecPoints", "RecPoints Display", 10, 10, 710, 740);
  c1->SetFillColor(1);
  TView *v=new TView(1);
  
      v->SetRange(-350.,-350.,-400.,350.,350.,400.); // full
  //  v->SetRange(0.,0.,0.,350.,350.,400.);  // top right
  //  v->SetRange(-350.,0.,0.,0.,350.,400.); // top left
  //  v->SetRange(0.,-350.,0.,350.,0.,400.); // bottom right 
  //  v->SetRange(-350.,-350.,0.,0.,0.,400.); // bottom left
  //  v->Side();
  v->Top();
  cerr<<"psi = "<<v->GetPsi()<<endl;

  // Dynamically link some shared libs
  if (gClassTable->GetID("AliRun") < 0) {
    gROOT->LoadMacro("loadlibs.C");
    loadlibs();
    cout << "Loaded shared libraries" << endl;
  }       


// Load tracks

   TFile *tf=TFile::Open("AliTRDtracks.root");
   if (!tf->IsOpen()) {cerr<<"Can't open AliTRDtracks.root !\n"; return 3;}
   TObjArray tarray(2000);
   //  tf->ls();
   TTree *tracktree=(TTree*)tf->Get("TreeT0_TRD");
   //   tracktree->ls();
   TBranch *tbranch=tracktree->GetBranch("tracks");
   Int_t nentr=tracktree->GetEntries();
   cerr<<"Found "<<nentr<<" entries in the track tree"<<endl;
   for (Int_t i=0; i<nentr; i++) {
       AliTRDtrack *iotrack=new AliTRDtrack;
       tbranch->SetAddress(&iotrack);
       tracktree->GetEvent(i);
       tarray.AddLast(iotrack);
       cerr<<"got track "<<i<<": index ="<<iotrack->GetLabel()<<endl;
   }
   tf->Close();                 


  // Load clusters
  Char_t *alifile = "TRDclusters.root";
  Int_t   nEvent  = 0;
  TObjArray rparray(2000);
  TObjArray *RecPointsArray = &rparray;
  const TFile *geofile =TFile::Open(alifile);
  //  AliTRDtracker *Tracker = new AliTRDtracker("dummy","dummy");
  AliTRDtracker *Tracker = new AliTRDtracker(geofile);
   Tracker->ReadClusters(RecPointsArray,alifile); 
  Int_t nRecPoints = RecPointsArray->GetEntriesFast();
  cerr<<"Found "<<nRecPoints<<" rec. points"<<endl;


  // Connect the AliRoot file containing Geometry, Kine, Hits, and Digits
      alifile = "galice.root";

   TFile *gafl = (TFile*) gROOT->GetListOfFiles()->FindObject(alifile);
  if (!gafl) {
    cout << "Open the ALIROOT-file " << alifile << endl;
    gafl = new TFile(alifile);
  }
  else {
    cout << alifile << " is already open" << endl;
  }
  

  // Get AliRun object from file or create it if not on file
  gAlice = (AliRun*) gafl->Get("gAlice");
  if (gAlice)
    cout << "AliRun object found on file" << endl;
  else
    gAlice = new AliRun("gAlice","Alice test program");
	

       AliTRDparameter *par =  ( AliTRDparameter *par) gafl->Get("TRDparameter");
       AliTRDv1       *TRD           = (AliTRDv1*) gAlice->GetDetector("TRD");
       AliTRDgeometry *fGeom   = TRD->GetGeometry();   
       
  Int_t i,j,index,det,sector, ti[3];
  Double_t x,y,z, cs,sn,tmp;
  Float_t global[3], local[3];

  // Display all TRD RecPoints
  TPolyMarker3D *pm = new TPolyMarker3D(nRecPoints);

  for (Int_t i = 0; i < nRecPoints; i++) {
    printf("\r point %d out of %d",i,nRecPoints);
    AliTRDcluster *rp = (AliTRDcluster *) RecPointsArray->UncheckedAt(i);    
  
   Int_t  idet=rp->GetDetector();
   Int_t iplan = fGeom->GetPlane(idet);    
   Int_t itt=rp->GetLocalTimeBin();
   Float_t  timeSlice = itt+0.5; 
   Float_t  time0     = par->GetTime0(iplan);

  // calculate (x,y,z) position in rotated chamber
   local[0] = time0 - (timeSlice - par->GetTimeBefore()) 
         * par->GetTimeBinSize();
   local[1]=rp->GetY();
   local[2]=rp->GetZ(); 

    for (j = 0; j < 3; j++) { ti[j] = rp->GetTrackIndex(j); }

    if((track < 0) ||
       ((ti[0]==track)||(ti[1]==track)||(ti[2]==track))) {

        if(fGeom->RotateBack(idet,local,global)) {     
       	x=global[0]; y=global[1]; z=global[2];
       	pm->SetPoint(i,x,y,z);
         }

    }
  }

  pm->SetMarkerSize(1); pm->SetMarkerColor(10); pm->SetMarkerStyle(1);
  pm->Draw();
  
   AliTRDparameter *par =  ( AliTRDparameter *par) gafl->Get("TRDparameter");

  Int_t ntracks = tarray.GetEntriesFast();

  for (i = 0; i < ntracks; i++) {
    AliTRDtrack *pt = (AliTRDtrack *) tarray.UncheckedAt(i), &t=*pt;
    Int_t nclusters = t.GetNumberOfClusters();
    cerr<<"in track "<<i<<" found "<<nclusters<<" clusters"<<endl;
   
    TPolyMarker3D *pm = new TPolyMarker3D(nclusters);
    for(j = 0; j < nclusters; j++) {
      index = t.GetClusterIndex(j);
      AliTRDcluster *rp = (AliTRDcluster *) RecPointsArray->UncheckedAt(index); 

   Int_t  idet=rp->GetDetector();
   Int_t iplan = fGeom->GetPlane(idet);    
   Int_t itt=rp->GetLocalTimeBin();
   Float_t  timeSlice = itt+0.5; 
   Float_t  time0     = par->GetTime0(iplan);


  // calculate (x,y,z) position in rotated chamber
       local[0] = time0 - (timeSlice - par->GetTimeBefore()) 
         * par->GetTimeBinSize();
       local[1]=rp->GetY(); 
       local[2]=rp->GetZ();

            if(fGeom->RotateBack(idet,local,global)) {     
      	x=global[0]; y=global[1]; z=global[2];
      	pm->SetPoint(j,x,y,z);
       }
    } 
    pm->SetMarkerSize(1); pm->SetMarkerColor(i%6+3); pm->SetMarkerStyle(1);
    //    pm->Draw();
  }
  
  TGeometry *geom=(TGeometry*)gafl->Get("AliceGeom");
  geom->Draw("same");

  c1->Modified(); 
  
  c1->Update();
  
  gafl->Close();

}