]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Add new example macros
authorcblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 14 Nov 2001 10:54:44 +0000 (10:54 +0000)
committercblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 14 Nov 2001 10:54:44 +0000 (10:54 +0000)
TRD/anaCluster.C [new file with mode: 0644]
TRD/anaDigits.C [new file with mode: 0644]
TRD/digits2cluster.C [new file with mode: 0644]
TRD/hits2digits.C [new file with mode: 0644]
TRD/hits2sdigits.C [new file with mode: 0644]
TRD/sdigits2digits.C [new file with mode: 0644]

diff --git a/TRD/anaCluster.C b/TRD/anaCluster.C
new file mode 100644 (file)
index 0000000..79476c5
--- /dev/null
@@ -0,0 +1,95 @@
+void anaCluster() 
+{
+
+/////////////////////////////////////////////////////////////////////////
+//
+// Example macro for the analysis of the TRD cluster
+//
+/////////////////////////////////////////////////////////////////////////
+
+  // Dynamically link some shared libs
+  if (gClassTable->GetID("AliRun") < 0) {
+    gROOT->LoadMacro("loadlibs.C");
+    loadlibs();
+  }
+
+  // Input file name
+  Char_t *alifile = "galice.root"; 
+
+  // Event number
+  Int_t   nEvent  = 0;
+
+  // Define the histograms
+  TH1F *hCharge = new TH1F("hCharge","Cluster charge",100,0.0,1000.0);
+
+  // Connect the AliRoot file containing Geometry, Kine, Hits, and Digits
+  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");
+  }
+
+  // Import the Trees for the event nEvent in the file
+  Int_t nparticles = gAlice->GetEvent(nEvent);
+  if (nparticles <= 0) break;
+  
+  // Get the pointer to the hit-tree
+  Char_t treeName[14];
+  sprintf(treeName,"TreeR%d_TRD",nEvent);
+  TTree          *clusterTree  = gafl->Get(treeName);
+  clusterTree->Print();
+  // Get the pointer to the detector classes
+  AliTRDv1       *trd          = (AliTRDv1*) gAlice->GetDetector("TRD");
+  // Get the geometry
+  AliTRDgeometry *geo          = trd->GetGeometry();
+  // Get the pointer to the hit container
+  TObjArray      *clusterArray = trd->RecPoints();
+  // Set the branch address
+  clusterTree->GetBranch("TRDcluster")->SetAddress(&clusterArray);
+
+  Int_t nEntries = clusterTree->GetEntries();
+  cout << "nEntries = " << nEntries << endl;
+
+  // Loop through all entries in the tree
+  Int_t nbytes;
+  for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
+
+    // Import the tree
+    nbytes += clusterTree->GetEvent(iEntry);
+
+    // Get the number of points in the detector 
+    Int_t ncluster = clusterArray->GetEntriesFast();
+
+    // Loop through all TRD digits
+    for (Int_t icluster = 0; icluster < ncluster; icluster++) {
+
+      // Get the information for this digit
+      AliTRDcluster *cluster = (AliTRDcluster *) clusterArray->UncheckedAt(icluster);
+      Int_t    detector = cluster->GetDetector();      
+      Int_t    sector   = geo->GetSector(detector);
+      Int_t    plane    = geo->GetPlane(detector);
+      Int_t    chamber  = geo->GetChamber(detector);
+      Float_t  charge   = cluster->GetQ();
+
+      hCharge->Fill(charge);
+
+    }
+
+  }
+
+  TCanvas *c1 = new TCanvas("c1","Cluster",50,50,600,400);
+  hCharge->Draw();
+
+}
diff --git a/TRD/anaDigits.C b/TRD/anaDigits.C
new file mode 100644 (file)
index 0000000..949fdc2
--- /dev/null
@@ -0,0 +1,112 @@
+void anaDigits() 
+{
+
+/////////////////////////////////////////////////////////////////////////
+//
+// Example macro for the analysis of the TRD digits and the use
+// of the AliTRDmatrix class.
+//
+/////////////////////////////////////////////////////////////////////////
+
+  // Dynamically link some shared libs
+  if (gClassTable->GetID("AliRun") < 0) {
+    gROOT->LoadMacro("loadlibs.C");
+    loadlibs();
+  }
+
+  // Input file name
+  Char_t *alifile = "galice.root"; 
+
+  // Event number
+  Int_t   nEvent  = 0;
+
+  // Define the objects
+  AliTRDv1       *trd;
+  AliTRDgeometry *geo;
+  AliTRDdigit    *digit;
+
+  Int_t           track;
+
+  // Connect the AliRoot file containing Geometry, Kine, Hits, and digits
+  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");
+
+  // Import the Trees for the event nEvent in the file
+  Int_t nparticles = gAlice->GetEvent(nEvent);
+  if (nparticles <= 0) break;
+  
+  // 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 {
+    cout << "Cannot find the geometry" << endl;
+    break;
+  }
+
+  // Create the digits manager
+  AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
+  digitsManager->SetVerbose(1);
+
+  // Read the digits from the file
+  digitsManager->Open(alifile);
+  digitsManager->ReadDigits();
+
+  // Define the detector matrix for one chamber
+  const Int_t iSec = 11;
+  const Int_t iCha = 2;
+  const Int_t iPla = 0;
+  Int_t  rowMax = geo->GetRowMax(iPla,iCha,iSec);
+  Int_t  colMax = geo->GetColMax(iPla);
+  Int_t timeMax = geo->GetTimeMax();
+  cout << "Geometry: rowMax = "  <<  rowMax
+                << " colMax = "  <<  colMax
+                << " timeMax = " << timeMax << endl;
+  AliTRDmatrix *matrix = new AliTRDmatrix(rowMax,colMax,timeMax,iSec,iCha,iPla);
+
+  // Get the detector number
+  Int_t iDet = geo->GetDetector(iPla,iCha,iSec); 
+  cout << " iDet = " << iDet << endl;
+
+  // Loop through the detector pixel
+  for (Int_t time = 0; time < timeMax; time++) {
+    for (Int_t  col = 0;  col <  colMax;  col++) {
+      for (Int_t  row = 0;  row <  rowMax;  row++) {
+
+        digit = digitsManager->GetDigit(row,col,time,iDet);
+        track = digitsManager->GetTrack(0,row,col,time,iDet);
+        
+        matrix->SetSignal(row,col,time,digit->GetAmp());
+
+        delete digit;
+
+      }
+    }
+  }
+
+  // Display the detector matrix
+  matrix->Draw();
+  //matrix->DrawRow(18);
+  //matrix->DrawCol(58);
+  //matrix->DrawTime(20);
+  matrix->ProjRow();
+  matrix->ProjCol();
+  matrix->ProjTime();
+
+}
diff --git a/TRD/digits2cluster.C b/TRD/digits2cluster.C
new file mode 100644 (file)
index 0000000..2f403c4
--- /dev/null
@@ -0,0 +1,47 @@
+void digits2cluster() 
+{
+
+///////////////////////////////////////////////////////////////////////// 
+//
+// Creates cluster from the digit information. 
+//
+///////////////////////////////////////////////////////////////////////// 
+
+  // Dynamically link some shared libs
+  if (gClassTable->GetID("AliRun") < 0) {
+    gROOT->LoadMacro("loadlibs.C");
+    loadlibs();
+    cout << "Loaded shared libraries" << endl;
+  }
+
+  // Input and output file names
+  Char_t *infile  = "galice.root";
+  Char_t *outfile = "TRDclusters.root";
+
+  // Create the clusterizer
+  AliTRDclusterizerV1 *clusterizer = 
+    new AliTRDclusterizerV1("clusterizer","Clusterizer class"); 
+
+  // Set the parameter
+  clusterizer->SetClusMaxThresh(0);
+  clusterizer->SetClusSigThresh(0);
+  //clusterizer->SetVerbose(1);
+  clusterizer->Dump();
+
+  // Open the AliRoot file 
+  clusterizer->Open(infile,0);
+  //clusterizer->Open(infile,outfile,0);
+
+  // Load the digits
+  clusterizer->ReadDigits();
+  // Find the cluster
+  clusterizer->MakeClusters();
+
+  // Write the cluster tree into file AliTRDclusters.root
+  clusterizer->WriteClusters(-1);
+
+  // Save the clusterizer class in the AliROOT file
+  // clusterizer->Write();
+
+}
diff --git a/TRD/hits2digits.C b/TRD/hits2digits.C
new file mode 100644 (file)
index 0000000..fc6dc29
--- /dev/null
@@ -0,0 +1,38 @@
+void hits2digits() 
+{
+
+/////////////////////////////////////////////////////////////////////////
+//
+// Creates digits from the hit information. 
+//
+/////////////////////////////////////////////////////////////////////////
+
+  // Dynamically link some shared libs
+  if (gClassTable->GetID("AliRun") < 0) {
+    gROOT->LoadMacro("loadlibs.C");
+    loadlibs();
+    cout << "Loaded shared libraries" << endl;
+  }
+
+  // Input (and output) file name
+  Char_t *alifile = "galice.root"; 
+
+  // Create the TRD digitzer 
+  AliTRDdigitizer *digitizer = new AliTRDdigitizer("digitizer","Digitizer class");
+
+  // Set the parameter
+  digitizer->SetVerbose(1);
+
+  // Open the AliRoot file
+  digitizer->Open(alifile);
+
+  // Create the digits
+  digitizer->MakeDigits();
+
+  // Write the digits into the input file
+  digitizer->WriteDigits();
+
+  // Save the digitizer class in the AliROOT file
+  digitizer->Write();
+
+}
diff --git a/TRD/hits2sdigits.C b/TRD/hits2sdigits.C
new file mode 100644 (file)
index 0000000..58b0409
--- /dev/null
@@ -0,0 +1,41 @@
+void hits2sdigits() 
+{
+
+  /////////////////////////////////////////////////////////////////////////
+  //
+  // Creates summable digits from the hit information. 
+  //
+  /////////////////////////////////////////////////////////////////////////
+
+  // Dynamically link some shared libs
+  if (gClassTable->GetID("AliRun") < 0) {
+    gROOT->LoadMacro("loadlibs.C");
+    loadlibs();
+    cout << "Loaded shared libraries" << endl;
+  }
+
+  // Input (and output) file name
+  Char_t *alifile = "galice.root"; 
+
+  // Create the TRD digitzer 
+  AliTRDdigitizer *digitizer = new AliTRDdigitizer("digitizer","Digitizer class");
+
+  // Set the parameter
+  digitizer->SetVerbose(1);
+
+  // For the summable digits
+  digitizer->SetSDigits(kTRUE);
+
+  // Open the AliRoot file
+  digitizer->Open(alifile);
+
+  // Create the digits
+  digitizer->MakeDigits();
+
+  // Write the digits into the input file
+  digitizer->WriteDigits();
+
+  // Save the digitizer class in the AliROOT file
+  digitizer->Write();
+
+}
diff --git a/TRD/sdigits2digits.C b/TRD/sdigits2digits.C
new file mode 100644 (file)
index 0000000..1a4d294
--- /dev/null
@@ -0,0 +1,43 @@
+void sdigits2digits()
+{
+
+  /////////////////////////////////////////////////////////////////////////
+  //
+  // Converts s-digits to normal digits
+  //
+  /////////////////////////////////////////////////////////////////////////
+
+  // Dynamically link some shared libs
+  if (gClassTable->GetID("AliRun") < 0) {
+    gROOT->LoadMacro("loadlibs.C");
+    loadlibs();
+    cout << "Loaded shared libraries" << endl;
+  }
+
+  Char_t *fileName = "galice.root";
+
+  // Create the TRD digits merger
+  AliTRDdigitizer *digitizer = new AliTRDdigitizer("digitizer","Digitizer class");  
+
+  // Set the parameter
+  digitizer->SetVerbose(1);
+
+  // Initialize the geometry 
+  digitizer->Open(fileName);
+
+  // Create the digits manager for the input s-digits
+  AliTRDdigitsManager *sdigitsManager = new AliTRDdigitsManager();
+  sdigitsManager->SetVerbose(1);
+  sdigitsManager->SetSDigits(kTRUE);
+  sdigitsManager->ReadDigits();
+
+  // Add the s-digits to the input list 
+  digitizer->AddSDigitsManager(sdigitsManager);
+
+  // Convert the s-digits to normal digits
+  digitizer->SDigits2Digits();
+
+  // Store the digits
+  digitizer->WriteDigits();
+
+}