]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - VZERO/AliVZERO.cxx
Method to extract the TPC space-points added
[u/mrichter/AliRoot.git] / VZERO / AliVZERO.cxx
index 29d56728b74b743f68fd0a6d236b1f9435d223f0..ffa8864ad3958695b05ba98d2bba53b16a7f09a2 100755 (executable)
@@ -19,6 +19,8 @@
 //                                                                       //
 //                          V-Zero   Detector                            //
 //  This class contains the base procedures for the VZERO  detector      //
+//  Default geometry of November 2003 :   V0R box is 4.4 cm thick        //
+//                                  scintillators are 2 cm thick         //
 //  All comments should be sent to Brigitte CHEYNIS :                    //
 //                                 b.cheynis@ipnl.in2p3.fr               //
 //                                                                       //
 
 // --- Standard libraries ---
 #include <Riostream.h>
+#include <stdlib.h>
 
 // --- ROOT libraries ---
 #include <TNamed.h>
-#include <TTree.h>
+#include "TROOT.h"
+#include "TFile.h"
+#include "TNetFile.h"
+#include "TRandom.h"
+#include "TTree.h"
+#include "TBranch.h"
+#include "TClonesArray.h"
+#include "TStopwatch.h"
 
 // --- AliRoot header files ---
 #include "AliRun.h"
 #include "AliMC.h"
 #include "AliVZERO.h"
 #include "AliVZEROLoader.h"
+#include "AliVZERODigitizer.h"
+#include "AliVZEROBuffer.h"
+#include "AliRunDigitizer.h"
+#include "AliVZEROdigit.h"
 
 ClassImp(AliVZERO)
  
@@ -49,15 +63,15 @@ AliVZERO::AliVZERO(const char *name, const char *title)
   // Standard constructor for VZERO Detector
   //
   
-  fIshunt       =  1;  // All hits are associated with primary particles  
+  //  fIshunt       =  1;  // All hits are associated with primary particles  
    
   fHits         =  new TClonesArray("AliVZEROhit", 400);
   fDigits       =  new TClonesArray("AliVZEROdigit",400); 
    
   gAlice->GetMCApp()->AddHitList(fHits);
 
-  fThickness    =  4.1;   // total thickness of the V0R box
-  fThickness1   =  0.7;   // thickness of the thickest cell (2.5 in version 0)
+  fThickness    =  4.4;   // total thickness of the V0R box in cm
+  fThickness1   =  2.0;   // thickness of scintillating cells in cm
   
   fMaxStepQua   =  0.05; 
   fMaxStepAlu   =  0.01; 
@@ -78,14 +92,12 @@ AliVZERO::~AliVZERO()
     if (fHits) {
         fHits->Delete();
         delete fHits;
-       fHits=0;
-    }
+       fHits=0; }
     
     if (fDigits) {
         fDigits->Delete();
         delete fDigits;
-        fDigits=0;
-    }
+        fDigits=0; }
 }
 
 //_____________________________________________________________________________
@@ -185,14 +197,104 @@ AliLoader* AliVZERO::MakeLoader(const char* topfoldername)
 //_____________________________________________________________________________
 void AliVZERO::SetTreeAddress()
 {
-  // 
+  //
   // Sets tree address for hits.
   //
-
   if (fLoader->TreeH() && (fHits == 0x0))
     fHits = new  TClonesArray("AliVZEROhit", 400);
 
   AliDetector::SetTreeAddress();
 }
 
+//_____________________________________________________________________________
+AliDigitizer* AliVZERO::CreateDigitizer(AliRunDigitizer* manager) const
+{
+  //
+  // Creates a digitizer for VZERO
+  //
+  return new AliVZERODigitizer(manager);
+}
+
+//_____________________________________________________________________________
+void AliVZERO::Hits2Digits(){
+  //
+  // Converts hits to digits of the current event
+  //
+  // Inputs file name
+  const char *alifile = "galice.root";   
+
+  // Create the run digitizer 
+  AliRunDigitizer* manager = new AliRunDigitizer(1, 1);
+  manager->SetInputStream(0, alifile);
+  manager->SetOutputFile("H2Dfile");
+
+  // Creates the VZERO digitizer 
+  AliVZERODigitizer* dig = new AliVZERODigitizer(manager);
+
+  // Creates the digits
+  dig->Exec("");
+
+}
+//_____________________________________________________________________________
+void AliVZERO::Digits2Raw()
+{
+  //
+  // Converts digits of the current event to raw data
+  //
+  AliVZERO *fVZERO = (AliVZERO*)gAlice->GetDetector("VZERO");
+  fLoader->LoadDigits();
+  TTree* digits = fLoader->TreeD();
+  if (!digits) {
+    Error("Digits2Raw", "no digits tree");
+    return;
+  }
+  TClonesArray * VZEROdigits = new TClonesArray("AliVZEROdigit",1000);
+  fVZERO->SetTreeAddress();            
+  digits->GetBranch("VZERODigit")->SetAddress(&VZEROdigits); 
+  
+  const char *fileName    = "VZERO_3584.ddl";
+  AliVZEROBuffer* buffer  = new AliVZEROBuffer(fileName);
+  
+  //  Verbose level
+  //  0: Silent
+  //  1: cout messages
+  //  2: txt files with digits 
+  //  BE CAREFUL, verbose level 2 MUST be used only for debugging and
+  //  it is highly suggested to use this mode only for debugging digits files
+  //  reasonably small, because otherwise the size of the txt files can reach
+  //  quickly several MB wasting time and disk space.
+  
+  ofstream ftxt;
+  buffer->SetVerbose(0);
+  Int_t fVerbose = buffer->GetVerbose();
+
+  Int_t nEntries = Int_t(digits->GetEntries());
+  
+  for (Int_t i = 0; i < nEntries; i++) {
+  
+    fVZERO->ResetDigits();
+    digits->GetEvent(i);
+    Int_t ndig = VZEROdigits->GetEntriesFast(); 
+   
+    if(ndig == 0) continue;
+    if(fVerbose == 2) {ftxt.open("VZEROdigits.txt",ios::app);}
+    for(Int_t k=0; k<ndig; k++){
+        AliVZEROdigit* fVZERODigit = (AliVZEROdigit*) VZEROdigits->At(k);                      
+       Int_t ADC  = fVZERODigit->ADC();
+       Int_t cell = fVZERODigit->CellNumber();
+        if(fVerbose == 1) { cout <<"DDL: "<<fileName<< "\tdigit number: "<< k<<"\tcell: "
+                           <<cell<<"\tADC: "<< ADC << endl;} 
+       if(fVerbose == 2) {
+           ftxt<<"DDL: "<<fileName<< "\tdigit number: "<< k<<"\tcell: "
+                          <<cell<<"\tADC: "<< ADC << endl;           
+       }
+        buffer->WriteBinary(cell, ADC);
+    }
+  if(fVerbose==2) ftxt.close();
+  }
+
+  delete buffer;
+  fLoader->UnloadDigits();
+}
+