FMD geometry with pad and SDigits
authoralla <alla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 27 Mar 2001 07:39:20 +0000 (07:39 +0000)
committeralla <alla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 27 Mar 2001 07:39:20 +0000 (07:39 +0000)
FMD/AliFMDSDigitizer.cxx [new file with mode: 0644]
FMD/AliFMDSDigitizer.h [new file with mode: 0644]
FMD/AliFMDdigit.cxx [new file with mode: 0644]
FMD/AliFMDdigit.h [new file with mode: 0644]
FMD/Hits2SDigits.C [new file with mode: 0644]

diff --git a/FMD/AliFMDSDigitizer.cxx b/FMD/AliFMDSDigitizer.cxx
new file mode 100644 (file)
index 0000000..173f1c8
--- /dev/null
@@ -0,0 +1,223 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+//_________________________________________________________________________
+// This is a TTask that constructs SDigits out of Hits
+// A Summable Digits is the sum of all hits in a cell
+// A threshold is applied 
+//
+//-- Author: Alla Maevskaia(INR)
+//////////////////////////////////////////////////////////////////////////////
+
+// --- ROOT system ---
+#include "TTask.h"
+#include "TTree.h"
+#include "TSystem.h"
+#include "TFile.h"
+// --- Standard library ---
+
+// --- AliRoot header files ---
+
+#include "AliFMDdigit.h"
+#include "AliFMDhit.h"
+#include "AliFMD.h"
+#include "AliFMDv1.h"
+#include "AliFMDSDigitizer.h"
+#include "AliRun.h"
+#include "AliDetector.h"
+#include "AliMC.h"
+
+#include "TROOT.h"
+#include "TFolder.h"
+#include <stdlib.h>
+#include <iostream.h>
+#include <fstream.h>
+
+ClassImp(AliFMDSDigitizer)
+
+           
+//____________________________________________________________________________ 
+  AliFMDSDigitizer::AliFMDSDigitizer():TTask("AliFMDSDigitizer","") 
+{
+  fNevents = 0 ;     // Number of events to digitize, 0 means all evens in current file
+  // add Task to //root/Tasks folder
+  TTask * roottasks = (TTask*)gROOT->GetRootFolder()->FindObject("Tasks") ; 
+  roottasks->Add(this) ; 
+}
+//____________________________________________________________________________ 
+AliFMDSDigitizer::AliFMDSDigitizer(char* HeaderFile, char *SDigitsFile):TTask("AliFMDSDigitizer","")
+{
+  // ctor
+  fNevents = 0 ;    // Number of events to digitize, 0 means all events in current file
+  fSDigitsFile = SDigitsFile ;
+  fHeadersFile = HeaderFile ;
+  //add Task to //root/Tasks folder
+  TTask * roottasks = (TTask*)gROOT->GetRootFolder()->FindObject("Tasks") ; 
+  roottasks->Add(this) ; 
+    
+}
+
+//____________________________________________________________________________ 
+  AliFMDSDigitizer::~AliFMDSDigitizer()
+{
+  // dtor
+}
+
+
+//____________________________________________________________________________
+void AliFMDSDigitizer::Exec(Option_t *option) { 
+  //Collects all hits in the same active volume into digit
+  TClonesArray * sdigits = new TClonesArray("AliFMDdigit",1000) ;
+  TFile * file = 0;
+
+  AliFMD * FMD = (AliFMD *) gAlice->GetDetector("FMD") ;
+  
+  if(fNevents == 0) 
+    fNevents = (Int_t) gAlice->TreeE()->GetEntries() ; 
+
+  cout<<"AliFMDSDigitizer-> Nevents"<<fNevents<<endl;
+  for(Int_t ievent = 0; ievent < fNevents; ievent++){
+    gAlice->GetEvent(ievent) ;
+    if(gAlice->TreeH()==0) return ;
+
+    if(gAlice->TreeS() == 0)           
+      gAlice->MakeTree("S") ;
+    
+    TClonesArray * FMDhits = FMD->Hits() ;
+
+    
+
+    Int_t nSdigits = 0 ;
+    
+    //Make branches
+    char branchname[20];
+    sprintf(branchname,"%s",FMD->GetName());  
+    
+    Int_t bufferSize = 16000 ;
+    char * file =0;
+    if(!fSDigitsFile.IsNull())
+      file = (char*) fSDigitsFile.Data() ; //ievent ;
+    else
+      if(gSystem->Getenv("CONFIG_SPLIT_FILE")){ //generating file name
+       file = new char[30] ;
+       sprintf(file,"FMD.SDigits.root") ;
+       cout<<"CONFIG_SPLIT_FILE "<<file<<endl; 
+      }
+      else{
+       file = 0 ;
+       cout<<" FILE =0 "<<endl;}
+       cout<<"After CONFIG_SPLIT_FILE "<<file<<endl; 
+    
+    gAlice->MakeBranchInTree(gAlice->TreeS(),branchname,&sdigits,bufferSize,file);  
+    /*    
+    Int_t splitlevel = 0 ;
+    sprintf(branchname,"AliFMDSDigitizer");   
+    AliFMDSDigitizer * sd = this ;
+    gAlice->MakeBranchInTree(gAlice->TreeS(),branchname,"AliFMDSDigitizer",&sd, bufferSize, splitlevel,file); 
+    */
+
+    //Now made SDigits from hits, for PHOS it is the same
+  Int_t volume,sector,ring,charge;
+  Float_t e;
+  Float_t de[10][20][150];
+  Int_t ivol,isec,iring;
+  Int_t hit,nbytes;
+  TParticle *particle;
+  AliFMDhit  *fmdHit;
+
+ // Event ------------------------- LOOP  
+  for (ivol=1; ivol<=6; ivol++)
+    for(isec=0; isec<16; isec++)
+      for(iring=0; iring<128; iring++)
+       de[ivol][isec][iring]=0;
+      
+  if (FMD){
+    FMDhits   = FMD->Hits();
+    TTree *TH = gAlice->TreeH();
+    Stat_t ntracks    = TH->GetEntries();
+   for (Int_t track=0; track<ntracks;track++) {
+     gAlice->ResetHits();
+     nbytes += TH->GetEvent(track);
+     particle=gAlice->Particle(track);
+     Int_t nhits =FMDhits->GetEntriesFast();
+     
+     for (hit=0;hit<nhits;hit++) {
+       fmdHit   = (AliFMDhit*)FMDhits->UncheckedAt(hit);
+       
+       volume = fmdHit->Volume();
+       sector = fmdHit->NumberOfSector();
+       ring   = fmdHit->NumberOfRing();
+       e = fmdHit->Edep();
+       de[volume][sector][ring]=de[volume][sector][ring]+e;
+
+     } //hit loop
+   } //track loop
+  }//if FMD
+  Int_t digit[5];
+  Float_t I=1.664*0.04*2.33/22400; // = 0.69e-6;
+  for(ivol=1; ivol<=6; ivol++){
+    for(isec=0; isec<16; isec++){
+      for(iring=0; iring<128; iring++){
+       if(de[ivol][isec][iring]>0.){
+         digit[0]=ivol;
+         digit[1]=isec;
+         digit[2]=iring;
+         charge=Int_t (de[ivol][isec][iring]/I);
+         digit[3]=charge;
+
+         //dinamic diapason from MIP(0.155MeV) to 30MIP(4.65MeV)
+         //1024 ADC channels 
+         Float_t channelWidth=(22400*30)/1024;
+         digit[4]=Int_t(digit[3]/channelWidth);
+
+         new((*sdigits)[nSdigits++]) AliFMDdigit(digit) ;
+         
+       } //de >threshold
+      }// iring loop
+    }//sector loop
+  } // volume loop
+
+
+  
+  
+    gAlice->TreeS()->Fill() ;
+    TFile *f1 = new TFile(file,"RECREATE");
+    f1->cd();
+    gAlice->TreeS()->Write(0,TObject::kOverwrite) ;
+  }
+
+  delete sdigits ;
+  if(file)
+    file->Close() ;
+
+}
+//__________________________________________________________________
+void AliFMDSDigitizer::SetSDigitsFile(char * file ){
+  if(!fSDigitsFile.IsNull())
+    cout << "Changing SDigits file from " <<(char *)fSDigitsFile.Data() << " to " << file << endl ;
+  fSDigitsFile=file ;
+}
+//__________________________________________________________________
+void AliFMDSDigitizer::Print(Option_t* option)const{
+  cout << "------------------- "<< GetName() << " -------------" << endl ;
+  if(fSDigitsFile.IsNull())
+    cout << " Writing SDigitis to file galice.root "<< endl ;
+  else
+    cout << "    Writing SDigitis to file  " << (char*) fSDigitsFile.Data() << endl ;
+
+}
diff --git a/FMD/AliFMDSDigitizer.h b/FMD/AliFMDSDigitizer.h
new file mode 100644 (file)
index 0000000..c775afe
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef ALIFMDSDigitizer_H
+#define ALIFMDSDigitizer_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+//_________________________________________________________________________
+//  Task Class for making SDigits in FMD      
+//                  
+//-- Author: Alla Maevskaia(INR)
+
+
+// --- ROOT system ---
+#include "TTask.h"
+#include "TString.h"
+#include "AliFMD.h"
+#include "AliDetector.h"
+
+// --- Standard library ---
+
+// --- AliRoot header files ---
+
+class AliFMDSDigitizer: public TTask {
+
+public:
+  AliFMDSDigitizer() ;          // ctor
+  AliFMDSDigitizer(char* HeaderFile,char *SdigitsFile = 0) ; 
+
+  virtual ~AliFMDSDigitizer() ; // dtor
+  Int_t    Digitize(Float_t Energy);
+
+  char *GetSDigitsFile()const{return (char*) fSDigitsFile.Data();}  
+  virtual void  Exec(Option_t *option); 
+  void SetNEvents(Int_t Nevents){fNevents = Nevents;}
+  Stat_t GetNEvents(){return fNevents;}
+  void SetSDigitsFile(char * file ) ;
+  virtual void Print(Option_t* option) const ;
+
+private:
+  Int_t   fNevents ;        // Number of events to digitize
+  TString fSDigitsFile ;    //output file 
+  TString fHeadersFile ;    //input file
+
+
+  ClassDef(AliFMDSDigitizer,2)  // description 
+
+};
+
+#endif // AliFMDSDigitizer_H
diff --git a/FMD/AliFMDdigit.cxx b/FMD/AliFMDdigit.cxx
new file mode 100644 (file)
index 0000000..9f645f5
--- /dev/null
@@ -0,0 +1,20 @@
+////////////////////////////////////////////////
+//  Digits classes for set:FMD                //
+////////////////////////////////////////////////
+
+
+#include "AliFMDdigit.h"
+
+ClassImp(AliFMDdigit)
+
+AliFMDdigit::AliFMDdigit(Int_t *digits) {
+  //
+  // Creates a real data digit object
+  //
+  fNumOfDet       = digits[0];
+  fNumOfSector    = digits[1];
+  fNumOfRing      = digits[2];
+  fNelectrons     = digits[3];
+  fADC            = digits[4];
+}
+
diff --git a/FMD/AliFMDdigit.h b/FMD/AliFMDdigit.h
new file mode 100644 (file)
index 0000000..6df5275
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef ALIFMDDIGIT_H
+#define ALIFMDDIGIT_H
+
+////////////////////////////////////////////////
+//  Digits classes for set:FMD                //
+////////////////////////////////////////////////
+#include <TClonesArray.h>
+#include <TObject.h>
+
+
+//___________________________________________
+class AliFMDdigit: public TObject  {
+  
+private:
+  Int_t fNumOfDet ;       //Number of FMD disk
+  Int_t fNumOfSector ;    //Number of sector
+  Int_t fNumOfRing;       //Number of ring
+  Int_t fNelectrons;      // real charge
+  Int_t fADC;             // ADC signal for this charge
+public:
+  AliFMDdigit() {
+    // constructor
+    fNumOfDet=fNumOfSector=fNumOfRing=fNelectrons=fADC=0;
+  }
+  AliFMDdigit(Int_t *digits);
+  virtual ~AliFMDdigit() {
+    // destructor
+  }
+  Int_t Volume();
+  Int_t NumberOfSector();
+  Int_t NumberOfRing();
+  Int_t Charge();
+  Int_t ADCsignal();
+  
+  ClassDef(AliFMDdigit,2)     // Real data digit object for set:ITS
+};
+inline Int_t AliFMDdigit::Volume(){return fNumOfDet;}
+inline Int_t AliFMDdigit::NumberOfSector() {return fNumOfSector;} 
+inline Int_t AliFMDdigit::NumberOfRing() {return fNumOfRing;}
+inline Int_t AliFMDdigit::Charge() {return fNelectrons;}
+inline Int_t AliFMDdigit::ADCsignal() {return fADC;}
+
+
+#endif
diff --git a/FMD/Hits2SDigits.C b/FMD/Hits2SDigits.C
new file mode 100644 (file)
index 0000000..553ce7b
--- /dev/null
@@ -0,0 +1,16 @@
+void Hits2SDigits(){  
+  if (gClassTable->GetID("AliRun") < 0) {
+    gROOT->LoadMacro("$ALICE_ROOT/macros/loadlibs.C");
+    loadlibs();
+  }
+   gSystem->Setenv("CONFIG_SPLIT_FILE","1") ;
+   if (gSystem->Getenv("CONFIG_SPLIT_FILE"))
+    cout << "SPLIT" << endl;
+   else
+    cout << "NO SPLIT" << endl ;
+  TFile * f = new TFile("galice.root","UPDATE");
+  gAlice = (AliRun*) f->Get("gAlice") ;
+  cout<<"gAlice="<<gAlice<<endl;
+  AliFMD* FMD  = (AliFMD *)gAlice->GetDetector("FMD") ;
+  gAlice->Hits2SDigits("FMD") ;
+ }