/* $Id$ */
+/* History of cvs commits:
+ *
+ * $Log$
+ * Revision 1.14 2007/01/23 10:27:37 alibrary
+ * Adding include files where needed for latest ROOT
+ *
+ * Revision 1.13 2006/09/07 18:31:08 kharlov
+ * Effective c++ corrections (T.Pocheptsov)
+ *
+ * Revision 1.12 2005/05/28 14:19:04 schutz
+ * Compilation warnings fixed by T.P.
+ *
+ */
+
//_________________________________________________________________________
// Class designed to convert raw data to aliroot format. We assume, that
// prototype is situated in the center of 3 PHOS module and convert prototype
//////////////////////////////////////////////////////////////////////////////
// --- ROOT system ---
-#include "TClonesArray.h"
-#include "TFile.h"
-#include "TTree.h"
-#include "TSystem.h"
-#include "Bytes.h"
+#include <Bytes.h>
+#include <TClonesArray.h>
+#include <TFile.h>
+#include <TSystem.h>
+#include <TTree.h>
// --- Standard library ---
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <ctype.h>
+
#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
// --- AliRoot header files ---
#include "AliPHOSDigit.h"
#include "AliPHOSConTableDB.h"
#include "AliPHOSBeamTestEvent.h"
#include "AliPHOSRaw2Digits.h"
-#include "AliPHOSv1.h"
-#include "../EVGEN/AliGenBox.h"
#include "AliRun.h"
ClassImp(AliPHOSRaw2Digits)
-
//____________________________________________________________________________
- AliPHOSRaw2Digits::AliPHOSRaw2Digits():TTask()
+AliPHOSRaw2Digits::AliPHOSRaw2Digits() :
+ fDigits(0),
+ fPHOSHeader(0),
+ fctdb(0),
+ fHeaderFile(0),
+ fDigitsFile(0),
+ fBeamEnergy(0.f),
+ fMaxPerFile(20000),
+ fEvent(0),
+ fStatus(0),
+ fInName(""),
+ fDebug(kFALSE),
+ fIsInitialized(kFALSE),
+ fMK1(0x0123CDEF),
+ fMK2(0x80708070),
+ fMK3(0x4321ABCD),
+ fMK4(0x80618061),
+ fCKW(0x4640E400)
{
- fInName="";
- fMK1 = 0x0123CDEF ;
- fMK2 = 0x80708070 ;
- fMK3 = 0x4321ABCD ;
- fMK4 = 0x80618061 ;
- fCKW = 0x4640E400 ;
- fDebug = kFALSE; // Debug flag
- fToSplit = kFALSE ;
- fIsInitialized = kFALSE ;
+ //As one can easily see, this is constructor.
fTarget[0] = 0 ;
fTarget[1] = 0 ;
fTarget[2] = 0 ;
- fDigits = 0 ;
- fHeaderFile = 0 ;
- fDigitsFile = 0 ;
- fPHOSHeader =0 ;
- fMaxPerFile = 20000 ;
- fEvent = 0 ;
- fctdb = 0;
}
+
//____________________________________________________________________________
- AliPHOSRaw2Digits::AliPHOSRaw2Digits(const char * filename,Bool_t toSplit):TTask("Default","")
+AliPHOSRaw2Digits::AliPHOSRaw2Digits(const char * filename) :
+ TTask("Default",""),
+ fDigits(0),
+ fPHOSHeader(0),
+ fctdb(0),
+ fHeaderFile(0),
+ fDigitsFile(0),
+ fBeamEnergy(0.f),
+ fMaxPerFile(20000),
+ fEvent(0),
+ fStatus(0),
+ fInName(filename),
+ fDebug(kFALSE),
+ fIsInitialized(kFALSE),
+ fMK1(0x0123CDEF),
+ fMK2(0x80708070),
+ fMK3(0x4321ABCD),
+ fMK4(0x80618061),
+ fCKW(0x4640E400)
{
- fInName=filename;
- fToSplit = toSplit ;
- TString outname("") ;
- if(fToSplit)
- outname = "galice.root" ;
- else{
- outname =fInName ;
- outname.ToLower() ;
- outname.ReplaceAll(".fz",".root") ;
- outname.ReplaceAll(".gz","") ;
- }
- SetTitle(outname) ;
-
- fMK1 = 0x0123CDEF ;
- fMK2 = 0x80708070 ;
- fMK3 = 0x4321ABCD ;
- fMK4 = 0x80618061 ;
- fCKW = 0x4640E400 ;
- fDebug = kFALSE; // Debug flag
- fIsInitialized = kFALSE ;
+ //this constructor should be normally used. Parameters: input file
+ TString outname(fInName) ;
+ outname.ToLower() ;
+ outname.ReplaceAll(".fz",".root") ;
+ outname.ReplaceAll(".gz","") ;
+ SetTitle(outname);
+
fTarget[0] = 0 ;
fTarget[1] = 0 ;
fTarget[2] = 0 ;
- fDigits = 0 ;
- fPHOSHeader =0 ;
- fHeaderFile = 0 ;
- fDigitsFile = 0 ;
- fMaxPerFile = 20000 ;
- fEvent = 0 ;
- fctdb = 0;
+}
+
+//____________________________________________________________________________
+AliPHOSRaw2Digits::AliPHOSRaw2Digits(AliPHOSRaw2Digits & r2d) :
+ TTask(r2d.GetName(), r2d.GetTitle()),
+ fDigits(r2d.fDigits),
+ fPHOSHeader(r2d.fPHOSHeader),
+ fctdb(new AliPHOSConTableDB(*r2d.fctdb)),
+ fHeaderFile(new TFile(r2d.fHeaderFile->GetName(), "new" )),
+ fDigitsFile(new TFile(r2d.fDigitsFile->GetName(), "new" )),
+ fBeamEnergy(r2d.fBeamEnergy),
+ fMaxPerFile(r2d.fMaxPerFile),
+ fEvent(r2d.fEvent),
+ fStatus(r2d.fStatus),
+ fInName(r2d.fInName),
+ fDebug(kFALSE),
+ fIsInitialized(kFALSE),
+ fMK1(r2d.fMK1),
+ fMK2(r2d.fMK2),
+ fMK3(r2d.fMK3),
+ fMK4(r2d.fMK4),
+ fCKW(r2d.fCKW)
+{
+ // cpy ctor. wrong. because dtor can delete fDigits twice (or n times you copy AliPHOSRaw2Digits)
+ //because fHeaderFile and fDigitsFile will recreate existing files etc.
+ fTarget[0] = r2d.fTarget[0] ;
+ fTarget[1] = r2d.fTarget[1] ;
+ fTarget[2] = r2d.fTarget[2] ;
}
//____________________________________________________________________________
AliPHOSRaw2Digits::~AliPHOSRaw2Digits()
{
+//destructor
if(fPHOSHeader)
fPHOSHeader->Delete() ;
if(fDigits){
}
//____________________________________________________________________________
-void AliPHOSRaw2Digits::Exec(Option_t * option){
+void AliPHOSRaw2Digits::Exec(const Option_t *){
//This is steering method performing all the conversion
if(!fIsInitialized) //need initialization
ProcessRawFile() ;
- FinishRun() ;
}
//____________________________________________________________________________
Bool_t AliPHOSRaw2Digits::Init(void){
}
//____________________________________________________________________________
-Bool_t AliPHOSRaw2Digits::StartRootFiles(void ){
- //Create PHOS geometry, sets magnetic field to zero,
- //create Generator - to store target position,
- //opens out file, creates TreeE
-
- //create gAlice if nececcary
- if(!gAlice)
- new AliRun("gAlice","The ALICE Off-line Simulation Framework") ;
-
- //Create PHOS
- if(!gAlice->GetModule("PHOS"))
- new AliPHOSv1("PHOS","GPS2") ;
-
- //Set Magnetic field
- gAlice->SetField(0,2);
-
- //Set positin of the virtex
- AliGenerator * gener = gAlice->Generator() ;
- if(!gener)
- gener = new AliGenBox(1);
- Float_t ox = fTarget[1];
- Float_t oy = fTarget[2]-460.;
- Float_t oz = fTarget[0];
- gener->SetOrigin(ox, oy, oz);
-
- //make directory
- Int_t nRootFile = (fEvent+1)/fMaxPerFile ;
- if(nRootFile){
- char dname[20];
- sprintf(dname,"%d",nRootFile) ;
- if(gSystem->AccessPathName(dname)) //strange return: 0 if exists
- if(gSystem->MakeDirectory(dname)!=0)
- Fatal("StartRootFiles","Can not make directory %s \n",dname) ;
+Bool_t AliPHOSRaw2Digits::StartRootFiles(void ) const {
+// //Create PHOS geometry, sets magnetic field to zero,
+// //create Generator - to store target position,
+// //opens out file, creates TreeE
+
+// //create gAlice if nececcary
+// if(!gAlice)
+// new AliRun("gAlice","The ALICE Off-line Simulation Framework") ;
+
+// //Create PHOS
+// if(!gAlice->GetModule("PHOS"))
+// new AliPHOSv1("PHOS","GPS2") ;
+
+// //Set Magnetic field
+// gAlice->SetField(0,2);
+
+// //Set positin of the virtex
+// AliGenerator * gener = gAlice->Generator() ;
+// if(!gener)
+// gener = new AliGenBox(1);
+// Float_t ox = fTarget[1];
+// Float_t oy = fTarget[2]+460.;
+// Float_t oz = fTarget[0];
+// gener->SetOrigin(ox, oy, oz);
+
+// //make directory
+// Int_t nRootFile = (fEvent+1)/fMaxPerFile ;
+// if(nRootFile){
+// char dname[20];
+// sprintf(dname,"%d",nRootFile) ;
+// if(gSystem->AccessPathName(dname)) //strange return: 0 if exists
+// if(gSystem->MakeDirectory(dname)!=0)
+// Fatal("StartRootFiles","Can not make directory %s \n",dname) ;
- if(!gSystem->ChangeDirectory(dname))
- Fatal("StartRootFiles","Can not cd to %s\n",dname) ;
- }
-
- // Create the output file
- TString outname("") ;
- if(strstr(GetTitle(),"root")){
- outname=GetTitle();
- }
- else{
- outname = fInName ;
- outname.ToLower() ;
- outname.ReplaceAll(".fz",".root") ;
- }
-
- fHeaderFile = new TFile(outname,"recreate");
- fHeaderFile->SetCompressionLevel(2);
+// if(!gSystem->ChangeDirectory(dname))
+// Fatal("StartRootFiles","Can not cd to %s\n",dname) ;
+// }
+
+// // Create the output file
+// TString outname("") ;
+// if(strstr(GetTitle(),"root")){
+// outname=GetTitle();
+// }
+// else{
+// outname = fInName ;
+// outname.ToLower() ;
+// outname.ReplaceAll(".fz",".root") ;
+// }
+
+// fHeaderFile = new TFile(outname,"recreate");
+// fHeaderFile->SetCompressionLevel(2);
- // Create the Root Trees
- gAlice->MakeTree("E") ;
+// // Create the Root Trees
- //Fill now TreeE
- Int_t splitlevel = 0 ;
- Int_t bufferSize = 32000 ;
- TBranch * headerBranch = gAlice->TreeE()->Branch("AliPHOSBeamTestEvent",
- "AliPHOSBeamTestEvent",
- &fPHOSHeader,bufferSize,splitlevel);
- headerBranch->SetName("AliPHOSBeamTestEvent") ;
-
- if(fToSplit){
- fDigitsFile = new TFile("PHOS.Digits.root","recreate") ;
- fDigitsFile->SetCompressionLevel(2) ;
- }
- return kTRUE ;
+// gime->MakeTree("E") ;
+
+// //Fill now TreeE
+// Int_t splitlevel = 0 ;
+// Int_t bufferSize = 32000 ;
+// TBranch * headerBranch = gAlice->TreeE()->Branch("AliPHOSBeamTestEvent",
+// "AliPHOSBeamTestEvent",
+// &fPHOSHeader,bufferSize,splitlevel);
+// headerBranch->SetName("AliPHOSBeamTestEvent") ;
+
+// // if(fToSplit){
+// // fDigitsFile = new TFile("PHOS.Digits.root","recreate") ;
+// // fDigitsFile->SetCompressionLevel(2) ;
+// // }
+ return kTRUE ;
}
//____________________________________________________________________________
Bool_t AliPHOSRaw2Digits::CloseRootFiles(void ){
//cleans everething to start next root file
+ if(fHeaderFile){
+ printf("writing gAlice \n") ;
+ fHeaderFile->cd() ;
+ gAlice->Write(0,TObject::kOverwrite);
+ gAlice->TreeE()->Write(0,TObject::kOverwrite);
+ }
delete gAlice ;
Info("ProcessRawFile", "event= %d written", fEvent) ;
// Read next record
- UInt_t nb = nwphr *sizeof(UInt_t);
+ nb = nwphr *sizeof(UInt_t);
n = fread( recBuf, nb,1,dataFile);
if (n < 0 ){
perror(fInName);
}
fEvent++ ;
}
+ CloseRootFiles() ;
fStatus = 1 ;
return kTRUE ;
}
+
//____________________________________________________________________________
-void AliPHOSRaw2Digits::Swab4(void *from, void *to, size_t nwords){
+void AliPHOSRaw2Digits::Swab4(void *from, void *to, size_t nwords)const
+{
// The function swaps 4 bytes: byte#3<-->byte#0, byte#2<-->byte#1
register char *pf=static_cast<char*>(from) ;
register char *pt=static_cast<char*>(to) ;
}
//____________________________________________________________________________
-void AliPHOSRaw2Digits::Swab2(void *from, void *to, size_t nwords)
-{ //The function swaps 2x2 bytes: byte#0<-->byte#1, byte#2<-->byte#3
+void AliPHOSRaw2Digits::Swab2(void *from, void *to, size_t nwords)const
+{
+ //The function swaps 2x2 bytes: byte#0<-->byte#1, byte#2<-->byte#3
register char *pf=static_cast<char*>(from) ;
register char *pt=static_cast<char*>(to);
register char c;
}
}
-//____________________________________________________________________________
-void AliPHOSRaw2Digits::FinishRun(){
- //Write geometry and header tree
- gAlice->Write(0,TObject::kOverwrite);
- gAlice->TreeE()->Write(0,TObject::kOverwrite);
-
-}
//____________________________________________________________________________
void AliPHOSRaw2Digits::WriteDigits(void){
//In this method we create TreeD, write digits and Raw2Digits to it
gAlice->TreeE()->Fill();
}
//____________________________________________________________________________
-void AliPHOSRaw2Digits::Print(Option_t * option)const{
-
+void AliPHOSRaw2Digits::Print(const Option_t *)const{
+ //prints current configuration and status.
printf("----------AliPHOSRaw2Digits---------- \n") ;
printf("Current input File: %s\n",fInName.Data()) ;