* provided "as is" without express or implied warranty. *
**************************************************************************/
+ //////////////////////////////////////////////////////////////////////////////
+// //
+// Forward Multiplicity Detector based on Silicon plates //
+// This class contains the procedures simulation ADC signal for //
+// the Forward Multiplicity detector : hits -> digits //
+// ADC signal consists //
+// - number of detector; //
+// - number of ring; //
+// - number of sector; //
+// - ADC signal in this channel //
+// //
+ //////////////////////////////////////////////////////////////////////////////
#include <TTree.h>
#include <TVector.h>
#include "AliFMDDigitizer.h"
#include "AliFMD.h"
-#include "AliFMDSDigitizer.h"
#include "AliFMDhit.h"
#include "AliFMDdigit.h"
#include "AliRunDigitizer.h"
#include "AliRun.h"
#include "AliPDG.h"
+#include "AliLoader.h"
+#include "AliRunLoader.h"
#include <stdlib.h>
#include <Riostream.h>
AliFMDDigitizer::AliFMDDigitizer(AliRunDigitizer* manager)
:AliDigitizer(manager)
{
- cout<<"AliFMDDigitizer::AliFMDDigitizer"<<endl;
-// ctor which should be used
-// fDebug =0;
- // if (GetDebug()>2)
+ // ctor which should be used
+ // fDebug =0;
+ // if (GetDebug()>2)
// cerr<<"AliFMDDigitizer::AliFMDDigitizer"
- // <<"(AliRunDigitizer* manager) was processed"<<endl;
+ // <<"(AliRunDigitizer* manager) was processed"<<endl;
}
//------------------------------------------------------------------------
Bool_t AliFMDDigitizer::Init()
{
// Initialization
- cout<<"AliFMDDigitizer::Init"<<endl;
+// cout<<"AliFMDDigitizer::Init"<<endl;
return kTRUE;
}
//---------------------------------------------------------------------
-void AliFMDDigitizer::Exec(Option_t* option)
+void AliFMDDigitizer::Exec(Option_t * /*option*/)
{
+ /*
+ Conver hits to digits:
+ - number of detector;
+ - number of ring;
+ - number of sector;
+ - ADC signal in this channel
+ */
+ AliRunLoader *inRL, *outRL;//in and out Run Loaders
+ AliLoader *ingime, *outgime;// in and out ITSLoaders
+
+ outRL = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
+ outgime = outRL->GetLoader("FMDLoader");
#ifdef DEBUG
cout<<"AliFMDDigitizer::>SDigits2Digits start...\n";
#endif
- // cout<<" FMD "<<FMD<<endl;
- Int_t volume, sector, ring, charge;
+ Int_t volume, sector, ring, charge;
Float_t e;
- Float_t de[10][50][300];
+ Float_t de[10][50][520];
Int_t hit;
Int_t digit[5];
Int_t ivol, iSector, iRing;
for (Int_t i=0; i<10; i++)
for(Int_t j=0; j<50; j++)
- for(Int_t ij=0; ij<300; ij++)
- de[i][j][ij]=0;
- Int_t NumberOfRings[5]=
- {256,128,256,128,256};
- Int_t NumberOfSectors[5]=
+ for(Int_t ij=0; ij<520; ij++)
+ de[i][j][ij]=0;
+ Int_t numberOfRings[5]=
+ {512,256,512,256,512};
+ Int_t numberOfSector[5]=
{20,40,20,40,20};
AliFMDhit *fmdHit=0;
- TTree *TH=0;
+ TTree *tH=0;
TBranch *brHits=0;
- // fHits = new TClonesArray ("AliFMDhit", 1000);
-
- AliFMD * fFMD = (AliFMD *) gAlice->GetDetector("FMD") ;
+ TBranch *brD=0;
+ inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(0));
+ if (inRL == 0x0)
+ {
+ Error("Exec","Can not find Run Loader for input stream 0");
+ return;
+ }
+ // Info("Exec","inRL->GetAliRun() %#x",inRL->GetAliRun());
+
+ if (!inRL->GetAliRun()) inRL->LoadgAlice();
+
+ AliFMD * fFMD = (AliFMD *) inRL->GetAliRun()->GetDetector("FMD");
+ // Info("Exec","inRL->GetAliRun(): %#x, FMD: %#x, InRL %#x.",inRL->GetAliRun(),fFMD,inRL);
+ if (fFMD == 0x0)
+ {
+ Error("Exec","Can not get FMD from gAlice");
+ return;
+ }
// Loop over files to digitize
Int_t nFiles=GetManager()->GetNinputs();
- for (Int_t inputFile=0; inputFile<nFiles;
- inputFile++) {
-
- cout<<" event "<<fManager->GetOutputEventNr()<<endl;
+ for (Int_t inputFile=0; inputFile<nFiles;inputFile++)
+ {
+ // cout<<" event "<<fManager->GetOutputEventNr()<<endl;
if (fFMD)
- {
- TClonesArray *FMDhits = fFMD->Hits ();
- TH = fManager->GetInputTreeH(inputFile);
- brHits = TH->GetBranch("FMD");
+ {
+
+ inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inputFile));
+ ingime = inRL->GetLoader("FMDLoader");
+ ingime->LoadHits("READ");//probably it is necessary to load them before
+
+
+ tH = ingime->TreeH();
+ if (tH == 0x0)
+ {
+ ingime->LoadHits("read");
+ tH = ingime->TreeH();
+ }
+ brHits = tH->GetBranch("FMD");
if (brHits) {
- fFMD->SetHitsAddressBranch(brHits);
+ // brHits->SetAddress(&fHits);
+ fFMD->SetHitsAddressBranch(brHits);
}else{
- cerr<<"EXEC Branch FMD hit not found"<<endl;
- exit(111);
- }
- Int_t ntracks = (Int_t) TH->GetEntries();
-
- for (Int_t track = 0; track < ntracks; track++)
- {
- brHits->GetEntry(track);
- Int_t nhits = FMDhits->GetEntries ();
-
- 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] += e;
-
- } //hit loop
- } //track loop
- } //if FMD
+ Fatal("Exec","EXEC Branch FMD hit not found");
+ }
+ TClonesArray *fFMDhits = fFMD->Hits ();
+
+ Int_t ntracks = (Int_t) tH->GetEntries();
+ // cout<<"Number of tracks TreeH"<<ntracks<<endl;
+ for (Int_t track = 0; track < ntracks; track++)
+ {
+ brHits->GetEntry(track);
+ Int_t nhits = fFMDhits->GetEntries ();
+ // if(nhits>0) cout<<"nhits "<<nhits<<endl;
+ for (hit = 0; hit < nhits; hit++)
+ {
+ fmdHit = (AliFMDhit *) fFMDhits->UncheckedAt(hit);
+
+ volume = fmdHit->Volume ();
+ sector = fmdHit->NumberOfSector ();
+ ring = fmdHit->NumberOfRing ();
+ e = fmdHit->Edep ();
+ de[volume][sector][ring] += e;
+ // if (fManager->GetOutputEventNr()>1)
+ // cout<<" "<<volume<<" "<<sector<<" "<<ring<<endl;
+ } //hit loop
+ } //track loop
+ }
+//if FMD
// Put noise and make ADC signal
- Float_t I = 1.664 * 0.04 * 2.33 / 22400; // = 0.69e-6;
- for ( ivol=1; ivol<=5; ivol++){
- for ( iSector=1; iSector<=NumberOfSectors[ivol-1]; iSector++){
- for ( iRing=1; iRing<=NumberOfRings[ivol-1]; iRing++){
- digit[0]=ivol;
- digit[1]=iSector;
- digit[2]=iRing;
- charge = Int_t (de[ivol][iSector][iRing] / I);
- digit[3]=PutNoise(charge);
- if(digit[3]<= 500) digit[3]=500;
+ Float_t mipI = 1.664 * 0.04 * 2.33 / 22400; // = 6.923e-6;
+ for ( ivol=1; ivol<=5; ivol++){
+ for ( iSector=1; iSector<=numberOfSector[ivol-1]; iSector++){
+ for ( iRing=1; iRing<=numberOfRings[ivol-1]; iRing++){
+ digit[0]=ivol;
+ digit[1]=iSector;
+ digit[2]=iRing;
+ charge = Int_t (de[ivol][iSector][iRing] / mipI);
+ Int_t pedestal=Int_t(gRandom->Gaus(500,250));
+ // digit[3]=PutNoise(charge);
+ digit[3]=charge + pedestal;
+ if(digit[3]<= 500) digit[3]=500;
//dynamic range from MIP(0.155MeV) to 30MIP(4.65MeV)
//1024 ADC channels
- Float_t channelWidth=(22400*50)/1024;
- digit[4]=Int_t(digit[3]/channelWidth);
- if (digit[4]>1024) digit[4]=1024;
- fFMD->AddDigit(digit);
- } //ivol
- } //iSector
- } //iRing
-
- TTree* treeD = fManager->GetTreeD();
- treeD->Clear();
- treeD->Reset();
- fFMD->MakeBranchInTreeD(treeD);
- treeD->Fill();
-
- fManager->GetTreeD()->Write(0,TObject::kOverwrite);
+ Float_t channelWidth=(22400*50)/1024;
+ digit[4]=Int_t(digit[3]/channelWidth);
+ if (digit[4]>1024) digit[4]=1024;
+ fFMD->AddDigit(digit);
+ } //ivol
+ } //iSector
+ } //iRing
+
+ TTree* treeD = outgime->TreeD();
+ // cout<<" treeD "<<treeD;
+ if (treeD == 0x0) {
+ outgime->MakeTree("D");
+ treeD = outgime->TreeD();
+ // cout<<" After MakeTree "<<treeD<<endl;
+ }
+ // cout<<" Before reset "<<treeD<<endl;
+ // treeD->Clear();
+ treeD->Reset();
+ fFMD->MakeBranchInTreeD(treeD);
+ brD = treeD->GetBranch("FMD");
+ // cout<<" Make branch "<<brD<<endl;
+
+ treeD->Fill(); //this operator does not work for events >1
+ //PH treeD->Print();
+ outgime->WriteDigits("OVERWRITE");
- gAlice->ResetDigits();
- }
+ gAlice->ResetDigits();
+ }
}
+
+
+
+