* provided "as is" without express or implied warranty. *
**************************************************************************/
+/* $Id$ */
+
//_________________________________________________________________________
// This is a TTask that constructs SDigits out of Hits
// A Summable Digits is the "sum" of all hits in a pad
// Use case: see AliTOFhits2sdigits.C macro in the CVS
//////////////////////////////////////////////////////////////////////////////
-#include "TBenchmark.h"
-#include "TTask.h"
-#include "TTree.h"
-#include "TSystem.h"
-#include "TParticle.h"
-#include "TH1.h"
-#include "TFile.h"
-#include "TROOT.h"
-#include "TFolder.h"
-#include <TF1.h>
+
+#include <Riostream.h>
#include <stdlib.h>
-#include <iostream.h>
-#include <fstream.h>
+#include <TBenchmark.h>
+#include <TF1.h>
+#include <TFile.h>
+#include <TFolder.h>
+#include <TH1.h>
+#include <TParticle.h>
+#include <TROOT.h>
+#include <TSystem.h>
+#include <TTask.h>
+#include <TTree.h>
+
+#include "AliDetector.h"
+#include "AliLoader.h"
+#include "AliRun.h"
+#include "AliRunLoader.h"
+#include "AliTOF.h"
+#include "AliTOFConstants.h"
#include "AliTOFHitMap.h"
#include "AliTOFSDigit.h"
-#include "AliTOFConstants.h"
+#include "AliTOFSDigitizer.h"
#include "AliTOFhit.h"
#include "AliTOFhitT0.h"
-#include "AliTOF.h"
#include "AliTOFv1.h"
#include "AliTOFv2.h"
#include "AliTOFv3.h"
#include "AliTOFv4.h"
-#include "AliTOFSDigitizer.h"
-#include "AliRun.h"
-#include "AliDetector.h"
#include "AliMC.h"
-
ClassImp(AliTOFSDigitizer)
//____________________________________________________________________________
AliTOFSDigitizer::AliTOFSDigitizer():TTask("AliTOFSDigitizer","")
{
// ctor
+
+ fRunLoader = 0 ;
+
fEvent1=0;
fEvent2=0;
ftail = 0;
- fSelectedSector=0;
- fSelectedPlate =0;
+ fSelectedSector=-1; //0; // AdC
+ fSelectedPlate =-1; //0; // AdC
}
//____________________________________________________________________________
- AliTOFSDigitizer::AliTOFSDigitizer(char* HeaderFile, Int_t evNumber1, Int_t nEvents):TTask("AliTOFSDigitizer","")
+ AliTOFSDigitizer::AliTOFSDigitizer(const char* HeaderFile, Int_t evNumber1, Int_t nEvents):TTask("AliTOFSDigitizer","")
{
fEvent1=evNumber1;
fEvent2=fEvent1+nEvents;
ftail = 0;
- fSelectedSector=0; // by default we sdigitize all sectors
- fSelectedPlate =0; // by default we sdigitize all plates in all sectors
+ fSelectedSector=-1; //0; // AdC // by default we sdigitize all sectors
+ fSelectedPlate =-1; //0; // AdC // by default we sdigitize all plates in all sectors
fHeadersFile = HeaderFile ; // input filename (with hits)
TFile * file = (TFile*) gROOT->GetFile(fHeadersFile.Data() ) ;
InitParameters();
// add Task to //root/Tasks folder
- TTask * roottasks = (TTask*)gROOT->GetRootFolder()->FindObject("Tasks") ;
- roottasks->Add(this) ;
+ fRunLoader = AliRunLoader::Open(HeaderFile);//open session and mount on default event folder
+ if (fRunLoader == 0x0)
+ {
+ Fatal("AliTOFSDigitizer","Event is not loaded. Exiting");
+ return;
+ }
+ AliLoader* gime = fRunLoader->GetLoader("TOFLoader");
+ if (gime == 0x0)
+ {
+ Fatal("AliTOFSDigitizer","Can not find TOF loader in event. Exiting.");
+ return;
+ }
+ gime->PostSDigitizer(this);
}
//____________________________________________________________________________
//____________________________________________________________________________
void AliTOFSDigitizer::Exec(Option_t *verboseOption, Option_t *allEvents) {
+ fRunLoader->LoadgAlice();
+ fRunLoader->LoadHeader();
+ fRunLoader->LoadKinematics();
+ gAlice = fRunLoader->GetAliRun();
+
+ AliLoader* gime = fRunLoader->GetLoader("TOFLoader");
+ gime->LoadHits("read");
+ gime->LoadSDigits("recreate");
if(strstr(verboseOption,"tim") || strstr(verboseOption,"all"))
gBenchmark->Start("TOFSDigitizer");
- AliTOF *TOF = (AliTOF *) gAlice->GetDetector ("TOF");
+ AliTOF *TOF = (AliTOF *) gAlice->GetDetector("TOF");
if (!TOF) {
Error("AliTOFSDigitizer","TOF not found");
fEvent2= (Int_t) gAlice->TreeE()->GetEntries();
}
- Bool_t thereIsNotASelection=(fSelectedSector==0) && (fSelectedPlate==0);
+ //Bool_t thereIsNotASelection=(fSelectedSector==0) && (fSelectedPlate==0); // AdC
+ Bool_t thereIsNotASelection=(fSelectedSector==-1) && (fSelectedPlate==-1);
for (Int_t ievent = fEvent1; ievent < fEvent2; ievent++) {
cout << "------------------- "<< GetName() << " -------------" << endl ;
Int_t nnoisesdigitsinEv=0;
Int_t nsignalsdigitsinEv=0;
- gAlice->GetEvent(ievent);
- TTree *TH = gAlice->TreeH ();
+ fRunLoader->GetEvent(ievent);
+ TOF->SetTreeAddress();
+ TTree *TH = gime->TreeH ();
if (!TH)
return;
- if (gAlice->TreeS () == 0)
- gAlice->MakeTree ("S");
+ if (gime->TreeS () == 0)
+ gime->MakeTree ("S");
//Make branches
char branchname[20];
sprintf (branchname, "%s", TOF->GetName ());
//Make branch for digits
- TOF->MakeBranch ("S");
+ TOF->MakeBranch("S");
//Now made SDigits from hits
AliTOFHitMap *hitMap = new AliTOFHitMap(TOF->SDigits());
// increase performances in terms of CPU time
- TH->SetBranchStatus("*",0); // switch off all branches
- TH->SetBranchStatus("TOF*",1); // switch on only TOF
+ //PH TH->SetBranchStatus("*",0); // switch off all branches
+ //PH TH->SetBranchStatus("TOF*",1); // switch on only TOF
+
+ TBranch * tofHitsBranch = TH->GetBranch("TOF");
Int_t ntracks = static_cast<Int_t>(TH->GetEntries());
for (Int_t track = 0; track < ntracks; track++)
{
gAlice->ResetHits();
- TH->GetEvent(track);
- particle = gAlice->Particle(track);
+ //PH TH->GetEvent(track);
+ tofHitsBranch->GetEvent(track);
+ particle = gAlice->GetMCApp()->Particle(track);
Int_t nhits = TOFhits->GetEntriesFast();
// cleaning all hits of the same track in the same pad volume
// it is a rare event, however it happens
- Int_t previousTrack =0;
- Int_t previousSector=0;
- Int_t previousPlate =0;
- Int_t previousStrip =0;
- Int_t previousPadX =0;
- Int_t previousPadZ =0;
+ Int_t previousTrack =-1; //0; // AdC
+ Int_t previousSector=-1; //0; // AdC
+ Int_t previousPlate =-1; //0; // AdC
+ Int_t previousStrip =-1; //0; // AdC
+ Int_t previousPadX =-1; //0; // AdC
+ Int_t previousPadZ =-1; //0; // AdC
for (Int_t hit = 0; hit < nhits; hit++)
{
nHitsFromPrim++;
} // counts hits due to primary particles
- Float_t xStrip=AliTOFConstants::fgkXPad*(vol[3]-0.5-0.5*AliTOFConstants::fgkNpadX)+Xpad;
- Float_t zStrip=AliTOFConstants::fgkZPad*(vol[4]-0.5-0.5*AliTOFConstants::fgkNpadZ)+Zpad;
+ //Float_t xStrip=AliTOFConstants::fgkXPad*(vol[3]-0.5-0.5*AliTOFConstants::fgkNpadX)+Xpad;
+ //Float_t zStrip=AliTOFConstants::fgkZPad*(vol[4]-0.5-0.5*AliTOFConstants::fgkNpadZ)+Zpad;
+ Float_t xStrip=AliTOFConstants::fgkXPad*(vol[3]+0.5-0.5*AliTOFConstants::fgkNpadX)+Xpad; // AdC
+ Float_t zStrip=AliTOFConstants::fgkZPad*(vol[4]+0.5-0.5*AliTOFConstants::fgkNpadZ)+Zpad; // AdC
//cout << "geantTime " << geantTime << " [ns]" << endl;
Int_t nActivatedPads = 0, nFiredPads = 0;
// recalculate the volume only for neighbouring pads
if(indexOfPad){
- (nPlace[indexOfPad]<=AliTOFConstants::fgkNpadX) ? vol[4] = 1 : vol[4] = 2;
- (nPlace[indexOfPad]<=AliTOFConstants::fgkNpadX) ? vol[3] = nPlace[indexOfPad] : vol[3] = nPlace[indexOfPad] - AliTOFConstants::fgkNpadX;
+ (nPlace[indexOfPad]<=AliTOFConstants::fgkNpadX) ? vol[4] = 0/*1*/ : vol[4] = 1/*2*/; // AdC
+ (nPlace[indexOfPad]<=AliTOFConstants::fgkNpadX) ? vol[3] = nPlace[indexOfPad] - 1 : vol[3] = nPlace[indexOfPad] - AliTOFConstants::fgkNpadX - 1; // AdC
}
// check if two sdigit are on the same pad; in that case we sum
delete hitMap;
- gAlice->TreeS()->Reset();
- gAlice->TreeS()->Fill();
+ gime->TreeS()->Reset();
+ gime->TreeS()->Fill();
//gAlice->TreeS()->Write(0,TObject::kOverwrite) ;
- gAlice->TreeS()->AutoSave();
+ gime->WriteSDigits("OVERWRITE");
if(strstr(verboseOption,"all")){
cout << "----------------------------------------" << endl;
}
//__________________________________________________________________
-void AliTOFSDigitizer::Print(Option_t* opt)const
+void AliTOFSDigitizer::Print(Option_t* /*opt*/)const
{
cout << "------------------- "<< GetName() << " -------------" << endl ;
//__________________________________________________________________
void AliTOFSDigitizer::SelectSectorAndPlate(Int_t sector, Int_t plate)
{
- Bool_t isaWrongSelection=(sector < 1) || (sector > AliTOFConstants::fgkNSectors) || (plate < 1) || (plate > AliTOFConstants::fgkNPlates);
+ //Bool_t isaWrongSelection=(sector < 1) || (sector > AliTOFConstants::fgkNSectors) || (plate < 1) || (plate > AliTOFConstants::fgkNPlates);
+ Bool_t isaWrongSelection=(sector < 0) || (sector >= AliTOFConstants::fgkNSectors) || (plate < 0) || (plate >= AliTOFConstants::fgkNPlates); // AdC
if(isaWrongSelection){
cout << "You have selected an invalid value for sector or plate " << endl;
- cout << "The correct range for sector is [1,"<< AliTOFConstants::fgkNSectors <<"]" << endl;
- cout << "The correct range for plate is [1,"<< AliTOFConstants::fgkNPlates <<"]" << endl;
+ //cout << "The correct range for sector is [1,"<< AliTOFConstants::fgkNSectors <<"]" << endl;
+ //cout << "The correct range for plate is [1,"<< AliTOFConstants::fgkNPlates <<"]" << endl;
+ cout << "The correct range for sector is [0,"<< AliTOFConstants::fgkNSectors-1 <<"]\n"; // AdC
+ cout << "The correct range for plate is [0,"<< AliTOFConstants::fgkNPlates-1 <<"]\n"; // AdC
cout << "By default we continue sdigitizing all hits in all plates of all sectors" << endl;
} else {
fSelectedSector=sector;