//////////////////////////////////////////////////////////////////////////////
// --- ROOT system ---
-#include "TFile.h"
-#include "TROOT.h"
#include "TBenchmark.h"
+ //#include "TObjectTable.h"
// --- Standard library ---
+#include "stdlib.h"
// --- AliRoot header files ---
-#include "AliRun.h"
+#include "AliLog.h"
#include "AliEMCALDigit.h"
#include "AliEMCALGetter.h"
#include "AliEMCALHit.h"
#include "AliEMCALSDigitizer.h"
#include "AliEMCALGeometry.h"
+ //#include "AliMemoryWatcher.h"
ClassImp(AliEMCALSDigitizer)
AliEMCALSDigitizer::AliEMCALSDigitizer():TTask("","")
{
// ctor
- InitParameters() ;
+ fFirstEvent = fLastEvent = 0 ;
fDefaultInit = kTRUE ;
}
//____________________________________________________________________________
-AliEMCALSDigitizer::AliEMCALSDigitizer(const char * alirunFileName, const char * eventFolderName):
- TTask("EMCAL"+AliConfig::fgkSDigitizerTaskName, alirunFileName),
+AliEMCALSDigitizer::AliEMCALSDigitizer(const char * alirunFileName,
+ const char * eventFolderName):
+ TTask("EMCAL"+AliConfig::Instance()->GetSDigitizerTaskName(), alirunFileName),
fEventFolderName(eventFolderName)
{
// ctor
+ fFirstEvent = fLastEvent = 0 ; // runs one event by defaut
Init();
InitParameters() ;
fDefaultInit = kFALSE ;
AliEMCALSDigitizer::AliEMCALSDigitizer(const AliEMCALSDigitizer & sd) : TTask(sd) {
//cpy ctor
+ fFirstEvent = sd.fFirstEvent ;
+ fLastEvent = sd.fLastEvent ;
fA = sd.fA ;
fB = sd.fB ;
- fPREPrimThreshold = sd.fPREPrimThreshold ;
fECPrimThreshold = sd.fECPrimThreshold ;
- fHCPrimThreshold = sd.fHCPrimThreshold ;
fSDigitsInRun = sd.fSDigitsInRun ;
SetName(sd.GetName()) ;
SetTitle(sd.GetTitle()) ;
}
+//____________________________________________________________________________
+AliEMCALSDigitizer::~AliEMCALSDigitizer() {
+ // dtor
+ AliEMCALGetter * gime =
+ // AliEMCALGetter::Instance(GetTitle(), fEventFolderName.Data());
+ AliEMCALGetter::Instance();
+ gime->EmcalLoader()->CleanSDigitizer();
+}
+
//____________________________________________________________________________
void AliEMCALSDigitizer::Init(){
// Initialization: open root-file, allocate arrays for hits and sdigits,
//____________________________________________________________________________
void AliEMCALSDigitizer::InitParameters()
{
+ // Initializes parameters
fA = 0;
fB = 10000000.;
AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
const AliEMCALGeometry * geom = gime->EMCALGeometry() ;
if (geom->GetSampling() == 0.) {
- Error("InitParameters", "Sampling factor not set !") ;
- abort() ;
+ Fatal("InitParameters", "Sampling factor not set !") ;
}
- else
- Info("InitParameters", "Sampling factor set to %f\n", geom->GetSampling()) ;
+// else
+// Info("InitParameters", "Sampling factor set to %f", geom->GetSampling()) ;
// this threshold corresponds approximately to 100 MeV
- fECPrimThreshold = 100E-3 / ( geom->GetSampling() * ( geom->GetNPRLayers() + geom->GetNECLayers()) ) * geom->GetNECLayers() ;
- fPREPrimThreshold = 100E-3 / ( geom->GetSampling() * ( geom->GetNPRLayers() + geom->GetNECLayers()) ) * geom->GetNPRLayers() ;
- fHCPrimThreshold = fECPrimThreshold/5. ; // 5 is totally arbitrary
-
+ fECPrimThreshold = 100E-3;
}
//____________________________________________________________________________
void AliEMCALSDigitizer::Exec(Option_t *option)
{
- // Collects all hits in the section (PRE/ECAL/HCAL) of the same tower into digit
-
+ // Collects all hit of the same tower into digits
if (strstr(option, "print") ) {
- Print("") ;
+ Print() ;
return ;
}
if(strstr(option,"tim"))
gBenchmark->Start("EMCALSDigitizer");
+ //AliEMCALGetter * gime = AliEMCALGetter::Instance(GetTitle()) ;
AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
-
+
//switch off reloading of this task while getting event
if (!fInit) { // to prevent overwrite existing file
- Error( "Exec", "Give a version name different from %s", fEventFolderName.Data() ) ;
+ AliError( Form("Give a version name different from %s", fEventFolderName.Data()) ) ;
return ;
- }
-
- Int_t nevents = gime->MaxEvent() ;
+ }
+
+ if (fLastEvent == -1)
+ fLastEvent = gime->MaxEvent() - 1 ;
+ else
+ fLastEvent = TMath::Min(fFirstEvent, gime->MaxEvent()); // only ine event at the time
+ Int_t nEvents = fLastEvent - fFirstEvent + 1;
+
Int_t ievent ;
- for(ievent = 0; ievent < nevents; ievent++){
-
- gime->Event(ievent,"H") ;
+ //AliMemoryWatcher memwatcher;
+
+ for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) {
+ gime->Event(ievent,"H") ;
TTree * treeS = gime->TreeS();
TClonesArray * hits = gime->Hits() ;
TClonesArray * sdigits = gime->SDigits() ;
// Attention nPrim is the number of primaries tracked by Geant
// and this number could be different to the number of Primaries in TreeK;
Int_t iprim ;
-
for ( iprim = 0 ; iprim < nPrim ; iprim++ ) {
//=========== Get the EMCAL branch from Hits Tree for the Primary iprim
gime->Track(iprim) ;
Bool_t newsdigit = kTRUE;
// Assign primary number only if deposited energy is significant
-
AliEMCALGeometry * geom = gime->EMCALGeometry() ;
-
- if( geom->IsInPRE(hit->GetId()) )
- if( hit->GetEnergy() > fPREPrimThreshold )
- curSDigit = new AliEMCALDigit( hit->GetPrimary(),
- hit->GetIparent(), hit->GetId(),
- Digitize(hit->GetEnergy()), hit->GetTime() ) ;
- else
- curSDigit = new AliEMCALDigit( -1 ,
- -1 ,
- hit->GetId(),
- Digitize(hit->GetEnergy()), hit->GetTime() ) ;
- else if( geom->IsInECA(hit->GetId()) )
+ if( geom->IsInECA(hit->GetId()) ){
if( hit->GetEnergy() > fECPrimThreshold )
curSDigit = new AliEMCALDigit( hit->GetPrimary(),
hit->GetIparent(), hit->GetId(),
-1 ,
hit->GetId(),
Digitize(hit->GetEnergy()), hit->GetTime() ) ;
- else if( geom->IsInHCA(hit->GetId()) )
- if( hit->GetEnergy() > fHCPrimThreshold )
-
- curSDigit = new AliEMCALDigit( hit->GetPrimary(),
- hit->GetIparent(), hit->GetId(),
- Digitize(hit->GetEnergy()), hit->GetTime() ) ;
- else
- curSDigit = new AliEMCALDigit( -1 ,
- -1 ,
- hit->GetId(),
- Digitize(hit->GetEnergy()), hit->GetTime() ) ;
-
+ }
+ else{
+ newsdigit = kFALSE;
+ }
+
Int_t check = 0 ;
+
for(check= 0; check < nSdigits ; check++) {
sdigit = dynamic_cast<AliEMCALDigit *>(sdigits->At(check)) ;
- if( sdigit->GetId() == curSDigit->GetId()) { // Are we in the same ECAL/HCAL/preshower tower ?
+ if(curSDigit != 0){
+ if( sdigit->GetId() == curSDigit->GetId()) { // Are we in the same ECAL tower ?
*sdigit = *sdigit + *curSDigit;
newsdigit = kFALSE;
+ }
}
}
- if (newsdigit) {
+ if (newsdigit) {
new((*sdigits)[nSdigits]) AliEMCALDigit(*curSDigit);
nSdigits++ ;
}
delete curSDigit ;
- } // loop over all hits (hit = deposited energy/layer/entering particle)
+ } // loop over all hits (hit = deposited energy/entering particle)
} // loop over iprim
-
sdigits->Sort() ;
nSdigits = sdigits->GetEntriesFast() ;
fSDigitsInRun += nSdigits ;
sdigits->Expand(nSdigits) ;
- Int_t NPrimarymax = -1 ;
+ Int_t nPrimarymax = -1 ;
Int_t i ;
for (i = 0 ; i < sdigits->GetEntriesFast() ; i++) {
AliEMCALDigit * sdigit = dynamic_cast<AliEMCALDigit *>(sdigits->At(i)) ;
}
for (i = 0 ; i < sdigits->GetEntriesFast() ; i++) {
- if (((dynamic_cast<AliEMCALDigit *>(sdigits->At(i)))->GetNprimary()) > NPrimarymax)
- NPrimarymax = ((dynamic_cast<AliEMCALDigit *>(sdigits->At(i)))->GetNprimary()) ;
+ if (((dynamic_cast<AliEMCALDigit *>(sdigits->At(i)))->GetNprimary()) > nPrimarymax)
+ nPrimarymax = ((dynamic_cast<AliEMCALDigit *>(sdigits->At(i)))->GetNprimary()) ;
}
// Now write SDigits
-
//First list of sdigits
Int_t bufferSize = 32000 ;
if(strstr(option,"deb"))
PrintSDigits(option) ;
- }
+
+ //gObjectTable->Print() ;
+ //memwatcher.Watch(ievent);
+ }// event loop
Unload();
if(strstr(option,"tim")){
gBenchmark->Stop("EMCALSDigitizer");
- Info("Exec", "took %f seconds for SDigitizing %f seconds per event",
- gBenchmark->GetCpuTime("EMCALSDigitizer"), gBenchmark->GetCpuTime("EMCALSDigitizer") ) ;
+ printf("Exec: took %f seconds for SDigitizing %f seconds per event",
+ gBenchmark->GetCpuTime("EMCALSDigitizer"), gBenchmark->GetCpuTime("EMCALSDigitizer")/nEvents ) ;
}
+
+ //TFile f("out.root","RECREATE");
+ //memwatcher.WriteToFile();
+ //f.Close();
}
//__________________________________________________________________
-void AliEMCALSDigitizer::Print(Option_t*)const
+void AliEMCALSDigitizer::Print()const
{
// Prints parameters of SDigitizer
- Info("Print", "\n------------------- %s -------------", GetName() ) ;
+ printf("Print: \n------------------- %s -------------", GetName() ) ;
printf(" Writing SDigits to branch with title %s\n", fEventFolderName.Data()) ;
printf(" with digitization parameters A = %f\n", fA) ;
printf(" B = %f\n", fB) ;
- printf(" Threshold for PRE Primary assignment= %f\n", fPREPrimThreshold) ;
printf(" Threshold for EC Primary assignment= %f\n", fECPrimThreshold) ;
- printf(" Threshold for HC Primary assignment= %f\n", fHCPrimThreshold) ;
printf("---------------------------------------------------\n") ;
}
{
// Equal operator.
// SDititizers are equal if their pedestal, slope and threshold are equal
-
if( (fA==sd.fA)&&(fB==sd.fB)&&
- (fECPrimThreshold==sd.fECPrimThreshold) &&
- (fHCPrimThreshold==sd.fHCPrimThreshold) &&
- (fPREPrimThreshold==sd.fPREPrimThreshold))
+ (fECPrimThreshold==sd.fECPrimThreshold))
return kTRUE ;
else
return kFALSE ;
}
//__________________________________________________________________
-void AliEMCALSDigitizer::PrintSDigits(Option_t * option){
+void AliEMCALSDigitizer::PrintSDigits(Option_t * option)
+{
//Prints list of digits produced at the current pass of AliEMCALDigitizer
+
AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
const TClonesArray * sdigits = gime->SDigits() ;
- TString message("\n") ;
- message += "event " ;
- message += gAlice->GetEvNumber() ;
- message += "\n Number of entries in SDigits list " ;
- message += sdigits->GetEntriesFast() ;
+ printf("\n") ;
+ printf("event %i", gAlice->GetEvNumber()) ;
+ printf("\n Number of entries in SDigits list %i", sdigits->GetEntriesFast());
if(strstr(option,"all")||strstr(option,"EMC")){
//loop over digits
AliEMCALDigit * digit;
- message += "\n Id Amplitude Time Index Nprim: Primaries list \n" ;
+ printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ;
Int_t index ;
char * tempo = new char[8192];
for (index = 0 ; index < sdigits->GetEntries() ; index++) {
digit = dynamic_cast<AliEMCALDigit *>( sdigits->At(index) ) ;
sprintf(tempo, "\n%6d %8d %6.5e %4d %2d :",
digit->GetId(), digit->GetAmp(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ;
- message += tempo ;
+ printf(tempo);
Int_t iprimary;
for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
sprintf(tempo, "%d ",digit->GetPrimary(iprimary+1) ) ;
- message += tempo ;
+ printf(tempo);
}
}
delete tempo ;
}
- Info("PrintSDigits", message.Data() ) ;
}
//____________________________________________________________________________
void AliEMCALSDigitizer::Unload() const
{
+ // Unload Hits and SDigits from the folder
AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
AliEMCALLoader * loader = gime->EmcalLoader() ;
loader->UnloadHits() ;