From af0954303815e43283e68b13d4855eab3e33a46d Mon Sep 17 00:00:00 2001 From: cheynis Date: Mon, 14 Jun 2004 12:44:10 +0000 Subject: [PATCH] Implementation for raw data simulation --- VZERO/AliVZEROBuffer.cxx | 89 ++++++++++++++++++++++++++++++++++++++++ VZERO/AliVZEROBuffer.h | 39 ++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 VZERO/AliVZEROBuffer.cxx create mode 100644 VZERO/AliVZEROBuffer.h diff --git a/VZERO/AliVZEROBuffer.cxx b/VZERO/AliVZEROBuffer.cxx new file mode 100644 index 00000000000..988f7ca830f --- /dev/null +++ b/VZERO/AliVZEROBuffer.cxx @@ -0,0 +1,89 @@ +/************************************************************************** + * Copyright(c) 1998-2003, 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. * + **************************************************************************/ +/* $Id$ */ + +// Storing digits in a binary file +// according to the DDL mapping +// To be used in Alice Data Challenges +// This class is used by AliVZERODDL.C macro +// Author: + +#include +#include +#include "AliVZEROBuffer.h" + +//#include "TFile.h" +//#include "TTree.h" + +ClassImp(AliVZEROBuffer) +//_____________________________________________________________________________ +AliVZEROBuffer::AliVZEROBuffer(const char* fileName){ + // Constructor +#ifndef __DECCXX + f.open(fileName,ios::binary|ios::out); +#else + f.open(fileName,ios::out); +#endif + // fout=new TFile(fileName,"recreate"); + // tree=new TTree("tree","Values"); + fNumberOfDigits=0; + fVerbose=0; + remove("VZEROdigits.txt"); +} + +//_____________________________________________________________________________ +AliVZEROBuffer::~AliVZEROBuffer(){ + // Destructor, it closes the IO stream + f.close(); + //delete tree; + //delete fout; +} + +//_____________________________________________________________________________ +AliVZEROBuffer::AliVZEROBuffer(const AliVZEROBuffer &source):TObject(source){ + // Copy Constructor + this->fVerbose=source.fVerbose; + return; +} + +//_____________________________________________________________________________ +AliVZEROBuffer& AliVZEROBuffer::operator=(const AliVZEROBuffer &source){ + //Assigment operator + this->fVerbose=source.fVerbose; + return *this; +} + +//_____________________________________________________________________________ +void AliVZEROBuffer::WriteBinary(Int_t cell,Int_t ADC){ + // It writes VZERO digits as a raw data file. + // Being called by AliVZERODDL.C + + struct DataFile{ + Int_t cell; + Int_t ADC; + }; + + DataFile data; + data.cell = cell; + data.ADC = ADC; + + ofstream ftxt; + ftxt.open("VZEROdigits.txt",ios::app); + + fNumberOfDigits++; + f.write((char*)(&data),sizeof(data)); + +} + diff --git a/VZERO/AliVZEROBuffer.h b/VZERO/AliVZEROBuffer.h new file mode 100644 index 00000000000..54391d681d0 --- /dev/null +++ b/VZERO/AliVZEROBuffer.h @@ -0,0 +1,39 @@ +#ifndef AliVZEROBUFFER_H +#define AliVZEROBUFFER_H +/* Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/////////////////////////////////////////////////////////////////// +// Class used for storing TPC digits according to the DDLs format// +////////////////////////////////////////////////////////////////// + +#ifdef __CINT__ +class fstream; +#else +#include "Riostream.h" +#endif + + +class AliVZEROBuffer:public TObject{ + +public: + AliVZEROBuffer(){ + //default constructor + } + AliVZEROBuffer(const char* fileName); //constructor + virtual ~AliVZEROBuffer(); //destructor + AliVZEROBuffer(const AliVZEROBuffer &source); // copy constructor + AliVZEROBuffer& operator=(const AliVZEROBuffer &source); // ass. op. + void WriteBinary(Int_t cell,Int_t ADC); + UInt_t GetDigNumber()const{return fNumberOfDigits;} + void SetVerbose(Int_t val){fVerbose=val;} + Int_t GetVerbose() const{return fVerbose;} + +private: + Int_t fVerbose; //Verbosity level: 0-silent, 1:cout msg, 2: txt files for checking + fstream f; //The IO file name + UInt_t fNumberOfDigits; //Number of VZERO digits + ClassDef(AliVZEROBuffer,1) +}; + +#endif -- 2.39.3