From dc8af42e765ec2b5d86ad0fee473cdcc33ce6f99 Mon Sep 17 00:00:00 2001 From: hristov Date: Tue, 29 May 2001 12:01:06 +0000 Subject: [PATCH] Last minute changes and new code for event mixing and reconstruction (A.Maevskaia) --- FMD/AliFMD.cxx | 480 ++++++++++++++++++++++----------- FMD/AliFMD.h | 17 +- FMD/AliFMDMerger.cxx | 215 +++++++++++++++ FMD/AliFMDMerger.h | 58 ++++ FMD/AliFMDReconstParticles.cxx | 23 ++ FMD/AliFMDReconstParticles.h | 25 ++ FMD/AliFMDReconstruction.cxx | 137 ++++++++++ FMD/AliFMDReconstruction.h | 45 ++++ FMD/AliFMDdigit.h | 2 +- FMD/AliFMDhit.h | 2 +- FMD/AliFMDv0.cxx | 11 +- FMD/AliFMDv1.cxx | 37 ++- FMD/AliFMDv1.h | 12 +- FMD/FMDLinkDef.h | 4 +- FMD/FMDMerger.C | 81 ++++++ FMD/Hits2SDigits.C | 11 +- FMD/Makefile | 6 +- FMD/TestReconstruction.C | 19 ++ 18 files changed, 993 insertions(+), 192 deletions(-) create mode 100644 FMD/AliFMDMerger.cxx create mode 100644 FMD/AliFMDMerger.h create mode 100644 FMD/AliFMDReconstParticles.cxx create mode 100644 FMD/AliFMDReconstParticles.h create mode 100644 FMD/AliFMDReconstruction.cxx create mode 100644 FMD/AliFMDReconstruction.h create mode 100644 FMD/FMDMerger.C create mode 100644 FMD/TestReconstruction.C diff --git a/FMD/AliFMD.cxx b/FMD/AliFMD.cxx index 84ff0b8f7f8..36050ee2b02 100644 --- a/FMD/AliFMD.cxx +++ b/FMD/AliFMD.cxx @@ -42,148 +42,167 @@ #include #include #include +#include #include #include #include "AliFMDv1.h" #include "AliRun.h" #include "AliMC.h" +#include "AliDetector.h" #include #include #include "AliMagF.h" #include "AliFMDhit.h" #include "AliFMDdigit.h" +#include "AliFMDReconstruction.h" #include -ClassImp(AliFMD) - +ClassImp (AliFMD) //_____________________________________________________________________________ - AliFMD::AliFMD(): AliDetector() +AliFMD::AliFMD ():AliDetector () { // // Default constructor for class AliFMD // - fIshunt = 0; + fIshunt = 0; + fHits = 0; + fDigits = 0; + fSDigits = 0; + fReconParticles=0; } - + //_____________________________________________________________________________ -AliFMD::AliFMD(const char *name, const char *title) - : AliDetector(name,title) +AliFMD::AliFMD (const char *name, const char *title): +AliDetector (name, title) { // // Standard constructor for Forward Multiplicity Detector // - + // // Initialise Hit array - fHits = new TClonesArray("AliFMDhit", 1000); + fHits = new TClonesArray ("AliFMDhit", 1000); // Digits for each Si disk - fDigits = new TClonesArray("AliFMDdigit", 1000); - fSDigits = new TClonesArray("AliFMDdigit", 1000) ; - gAlice->AddHitList(fHits); + fDigits = new TClonesArray ("AliFMDdigit", 1000); + fSDigits = new TClonesArray ("AliFMDdigit", 1000); + gAlice->AddHitList (fHits); - fIshunt = 0; - fIdSens1 = 0; + fIshunt = 0; + fIdSens1 = 0; - SetMarkerColor(kRed); + SetMarkerColor (kRed); } - -AliFMD::~AliFMD() +//----------------------------------------------------------------------------- +AliFMD::~AliFMD () { - if (fHits) { - fHits->Delete(); + if (fHits) + { + fHits->Delete (); delete fHits; fHits = 0; - } - if (fDigits) { - fDigits->Delete(); + } + if (fDigits) + { + fDigits->Delete (); delete fDigits; fDigits = 0; - } - if (fSDigits) { - fSDigits->Delete(); + } + if (fSDigits) + { + fSDigits->Delete (); delete fSDigits; fSDigits = 0; - } - + } + if (fReconParticles) + { + fReconParticles->Delete (); + delete fReconParticles; + fReconParticles = 0; + } + } + //_____________________________________________________________________________ -void AliFMD::AddHit(Int_t track, Int_t *vol, Float_t *hits) +void AliFMD::AddHit (Int_t track, Int_t * vol, Float_t * hits) { // // Add a hit to the list // - TClonesArray &lhits = *fHits; - new(lhits[fNhits++]) AliFMDhit(fIshunt,track,vol,hits); + TClonesArray & lhits = *fHits; + new (lhits[fNhits++]) AliFMDhit (fIshunt, track, vol, hits); } + //_____________________________________________________________________________ -void AliFMD::AddDigit( Int_t *digits) +void AliFMD::AddDigit (Int_t * digits) { // add a real digit - as coming from data // printf("AddDigit\n"); - TClonesArray &ldigits = *fDigits; - new(ldigits[fNdigits++]) AliFMDdigit(digits); + TClonesArray & ldigits = *fDigits; + new (ldigits[fNdigits++]) AliFMDdigit (digits); } + //_____________________________________________________________________________ -void AliFMD::BuildGeometry() +void AliFMD::BuildGeometry () { // // Build simple ROOT TNode geometry for event display // TNode *node, *top; - const int kColorFMD = 7; + const int kColorFMD = 7; // - top=gAlice->GetGeometry()->GetNode("alice"); + top = gAlice->GetGeometry ()->GetNode ("alice"); // FMD define the different volumes - new TRotMatrix("rot901","rot901", 90, 0, 90, 90, 180, 0); - - new TTUBE("S_FMD0","FMD volume 0","void",4.73,17.7,1.5); - top->cd(); - node = new TNode("FMD0","FMD0","S_FMD0",0,0,64,""); - node->SetLineColor(kColorFMD); - fNodes->Add(node); - - new TTUBE("S_FMD1","FMD volume 1","void",23.4,36.,1.5); - top->cd(); - node = new TNode("FMD1","FMD1","S_FMD1",0,0,85,""); - node->SetLineColor(kColorFMD); - fNodes->Add(node); - - new TTUBE("S_FMD2","FMD volume 2","void",4.73,17.7,1.5); - top->cd(); - node = new TNode("FMD2","FMD2","S_FMD2",0,0,-64,""); - node->SetLineColor(kColorFMD); - fNodes->Add(node); - - new TTUBE("S_FMD3","FMD volume 3","void",23.4,36.,1.5); - top->cd(); - node = new TNode("FMD3","FMD3","S_FMD3",0,0,-85,""); - node->SetLineColor(kColorFMD); - fNodes->Add(node); - - new TTUBE("S_FMD4","FMD volume 4","void",5,15,0.015); - top->cd(); - node = new TNode("FMD4","FMD4","S_FMD4",0,0,-270,""); - node->SetLineColor(kColorFMD); - fNodes->Add(node); - - - new TTUBE("S_FMD5","FMD volume 5","void",5,14,0.015); - top->cd(); - node = new TNode("FMD5","FMD5","S_FMD5",0,0,-630,""); - node->SetLineColor(kColorFMD); - fNodes->Add(node); - + new TRotMatrix ("rot901", "rot901", 90, 0, 90, 90, 180, 0); + + new TTUBE ("S_FMD0", "FMD volume 0", "void", 4.73, 17.7, 1.5); + top->cd (); + node = new TNode ("FMD0", "FMD0", "S_FMD0", 0, 0, 64, ""); + node->SetLineColor (kColorFMD); + fNodes->Add (node); + + new TTUBE ("S_FMD1", "FMD volume 1", "void", 23.4, 36., 1.5); + top->cd (); + node = new TNode ("FMD1", "FMD1", "S_FMD1", 0, 0, 85, ""); + node->SetLineColor (kColorFMD); + fNodes->Add (node); + + new TTUBE ("S_FMD2", "FMD volume 2", "void", 4.73, 17.7, 1.5); + top->cd (); + node = new TNode ("FMD2", "FMD2", "S_FMD2", 0, 0, -64, ""); + node->SetLineColor (kColorFMD); + fNodes->Add (node); + + new TTUBE ("S_FMD3", "FMD volume 3", "void", 23.4, 36., 1.5); + top->cd (); + node = new TNode ("FMD3", "FMD3", "S_FMD3", 0, 0, -85, ""); + node->SetLineColor (kColorFMD); + fNodes->Add (node); + + new TTUBE ("S_FMD4", "FMD volume 4", "void", 5, 15, 0.015); + top->cd (); + // node = new TNode("FMD4","FMD4","S_FMD4",0,0,-270,""); + node = new TNode ("FMD4", "FMD4", "S_FMD4", 0, 0, -270, ""); + node->SetLineColor (kColorFMD); + fNodes->Add (node); + + /* + new TTUBE("S_FMD5","FMD volume 5","void",5,14,0.015); + top->cd(); + node = new TNode("FMD5","FMD5","S_FMD5",0,0,-630,""); + node->SetLineColor(kColorFMD); + fNodes->Add(node); + */ } - + //_____________________________________________________________________________ -Int_t AliFMD::DistanceToPrimitive(Int_t px, Int_t py) +Int_t AliFMD::DistanceToPrimitive (Int_t px, Int_t py) { // // Calculate the distance from the mouse to the FMD on the screen @@ -191,144 +210,289 @@ Int_t AliFMD::DistanceToPrimitive(Int_t px, Int_t py) // return 9999; } + //___________________________________________ -void AliFMD::ResetHits() +void AliFMD::ResetHits () { // Reset number of clusters and the cluster array for this detector - AliDetector::ResetHits(); + AliDetector::ResetHits (); } //____________________________________________ -void AliFMD::ResetDigits() +void AliFMD::ResetDigits () { - // - // Reset number of digits and the digits array for this detector - AliDetector::ResetHits(); - // + // + // Reset number of digits and the digits array for this detector + AliDetector::ResetHits (); + // } //------------------------------------------------------------------------- -void AliFMD::Init() +void AliFMD::Init () { // // Initialis the FMD after it has been built Int_t i; - AliMC* pMC = AliMC::GetMC(); + AliMC *pMC = AliMC::GetMC (); // - if(fDebug) { - printf("\n%s: ",ClassName()); - for(i=0;i<35;i++) printf("*"); - printf(" FMD_INIT "); - for(i=0;i<35;i++) printf("*"); - printf("\n%s: ",ClassName()); - // - // Here the FMD initialisation code (if any!) - for(i=0;i<80;i++) printf("*"); - printf("\n"); - } + if (fDebug) + { + printf ("\n%s: ", ClassName ()); + for (i = 0; i < 35; i++) + printf ("*"); + printf (" FMD_INIT "); + for (i = 0; i < 35; i++) + printf ("*"); + printf ("\n%s: ", ClassName ()); + // + // Here the FMD initialisation code (if any!) + for (i = 0; i < 80; i++) + printf ("*"); + printf ("\n"); + } // // - if (IsVersion()!=0) - fIdSens1=pMC->VolId("GRIN"); //Si sensetive volume + if (IsVersion () != 0) + fIdSens1 = pMC->VolId ("GRIN"); //Si sensetive volume else - fIdSens1=pMC->VolId("GFSI"); //Si sensetive volume + fIdSens1 = pMC->VolId ("GFSI"); //Si sensetive volume } + //--------------------------------------------------------------------- -void AliFMD::MakeBranch(Option_t* option, const char *file) +void AliFMD::MakeBranch (Option_t * option, const char *file) { // Create Tree branches for the FMD. - const Int_t kBufferSize = 4000; char branchname[10]; - sprintf(branchname,"%s",GetName()); + const Int_t kBufferSize = 16000; + sprintf (branchname, "%s", GetName ()); + + AliDetector::MakeBranch (option, file); + const char *cD = strstr(option,"D"); + const char *cR = strstr(option,"R"); + const char *cS = strstr(option,"S"); + + if (cS){ - AliDetector::MakeBranch(option,file); + MakeBranchInTree(gAlice->TreeS(), + branchname,&fSDigits, + kBufferSize, file); + } + if (cD){ - const char *cD = strstr(option,"D"); - - if (cD) { - MakeBranchInTree(gAlice->TreeD(), - branchname, &fDigits, kBufferSize, file); - - printf("Making Branch %s for digits\n",branchname); - gAlice->TreeD()->Print(); + branchname,&fDigits, + kBufferSize, file); + } + if (cR){ + MakeBranchInTree(gAlice->TreeR(), + branchname,&fReconParticles, + kBufferSize, file); } + } - + //_____________________________________________________________________________ -void AliFMD::SetTreeAddress() +void AliFMD::SetTreeAddress () { // Set branch address for the Hits and Digits Tree. char branchname[30]; - AliDetector::SetTreeAddress(); + AliDetector::SetTreeAddress (); TBranch *branch; - TTree *treeD = gAlice->TreeD(); + TTree *treeD = gAlice->TreeD (); - if (treeD) { - if (fDigits) { - branch = treeD->GetBranch(branchname); - if (branch) branch->SetAddress(&fDigits); - } - - } - if(fSDigits) - fSDigits->Clear(); + if (treeD) + { + if (fDigits) + { + branch = treeD->GetBranch (branchname); + if (branch) + branch->SetAddress (&fDigits); + } - if (gAlice->TreeS() && fSDigits ) { - branch = gAlice->TreeS()->GetBranch("FMD"); - if (branch) branch->SetAddress(&fSDigits) ; - } + } + if (fSDigits) + fSDigits->Clear (); + + if (gAlice->TreeS () && fSDigits) + { + branch = gAlice->TreeS ()->GetBranch ("FMD"); + if (branch) + branch->SetAddress (&fSDigits); + } + if(fReconParticles) + fReconParticles->Clear(); + if (gAlice->TreeR()) + { + branch = gAlice->TreeR()->GetBranch("FMD"); + if (branch) branch->SetAddress(&fReconParticles) ; + } } //--------------------------------------------------------------------- -/* + void AliFMD::SDigits2Digits() { - Int_t ibg=0, bgr=0; - Int_t nbgr_ev= 0; - - if (ibg) { - printf("nbgr_ev %d\n",nbgr_ev); - // Hit2Digits(nbgr_ev,"Add"," ","galice_bgr.root"); - } - else { - // Hit2Digits(nbgr_ev,"rien","",""); + cout<<"AliFMD::SDigits2Digits"<Init(); + cout<<"AliFMD::SDigits2Digits Init"<Digitise(); } } -*/ +//--------------------------------------------------------------------- +void AliFMD::SetMerger(AliFMDMerger* merger) +{ +// Set pointer to merger + fMerger = merger; +} + +AliFMDMerger* AliFMD::Merger() +{ +// Return pointer to merger + return fMerger; +} + //--------------------------------------------------------------------- -void AliFMD::Eta2Radius(Float_t eta, Float_t zDisk, Float_t *radius) +void +AliFMD::Eta2Radius (Float_t eta, Float_t zDisk, Float_t * radius) { - Float_t expEta=TMath::Exp(-eta); - Float_t theta=TMath::ATan(expEta); - theta=2.*theta; - Float_t rad=zDisk*(TMath::Tan(theta)); - *radius=rad; - - if(fDebug) printf("%s: eta %f radius %f\n", ClassName(), eta, rad); + Float_t expEta = TMath::Exp (-eta); + Float_t theta = TMath::ATan (expEta); + theta = 2. * theta; + Float_t rad = zDisk * (TMath::Tan (theta)); + *radius = rad; + + if (fDebug) + printf ("%s: eta %f radius %f\n", ClassName (), eta, rad); } //--------------------------------------------------------------------- -void AliFMD::Hits2SDigits(){ - if(fDebug) cout << ClassName() << ": ALiFMD::Hits2SDigits> start...\n"; - // char * fileSDigits = 0 ; - // char * fileHeader=0 ; - AliFMDSDigitizer * sd = new AliFMDSDigitizer("mgalice.root","FMD.SDigit.root") ; - sd->Exec("") ; - sd->Print(""); - - delete sd ; -} +void AliFMD::Hits2SDigits () +{ + + AliFMD *FMD = (AliFMD *) gAlice->GetDetector ("FMD"); + + if (fNevents == 0) + fNevents = (Int_t) gAlice->TreeE ()->GetEntries (); + + for (Int_t ievent = 0; ievent < fNevents; ievent++) + { + gAlice->GetEvent (ievent); + if (gAlice->TreeH () == 0) + return; + if (gAlice->TreeS () == 0) + gAlice->MakeTree ("S"); + + + Int_t nSdigits = 0; + + //Make branches + char branchname[20]; + sprintf (branchname, "%s", FMD->GetName ()); + //Make branch for digits + FMD->MakeBranch ("S"); + + + //Now made SDigits from hits, for PHOS it is the same + Int_t volume, sector, ring, charge; + Float_t e; + Float_t de[10][20][150]; + Int_t ivol, isec, iring; + Int_t hit, nbytes; + TParticle *particle; + AliFMDhit *fmdHit; + TClonesArray *FMDhits = FMD->Hits (); + + // Event ------------------------- LOOP + + for (ivol = 1; ivol <= 5; ivol++) + for (isec = 1; isec <= 16; isec++) + for (iring = 1; iring <= 128; iring++) + de[ivol][isec][iring] = 0; + + if (FMD) + { + FMDhits = FMD->Hits (); + TTree *TH = gAlice->TreeH (); + Stat_t ntracks = TH->GetEntries (); + for (Int_t track = 0; track < ntracks; track++) + { + gAlice->ResetHits (); + nbytes += TH->GetEvent (track); + particle = gAlice->Particle (track); + Int_t nhits = FMDhits->GetEntriesFast (); + + 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] = de[volume][sector][ring] + e; + } //hit loop + } //track loop + } //if FMD + + + Int_t digit[5]; + Float_t I = 1.664 * 0.04 * 2.33 / 22400; // = 0.69e-6; + for (ivol = 1; ivol <= 5; ivol++) + { + for (isec = 1; isec <= 16; isec++) + { + for (iring = 1; iring <= 128; iring++) + { + digit[0] = ivol; + digit[1] = isec; + digit[2] = iring; + charge = Int_t (de[ivol][isec][iring] / I); + digit[3] = charge; + // if (charge!=0) cout<<" charge "<TreeS ()->Fill (); + gAlice->TreeS ()->Print (); + + } //event loop +} +//----------------------------------------------------------------------- + +void AliFMD::Digits2Reco() +{ +#ifdef DEBUG + cout<<"ALiFMD::Digits2Reco> start..."; +#endif + char * fileReconParticles=0; + char * fileHeader=0; + AliFMDReconstruction * reconstruction = + new AliFMDReconstruction(fileHeader,fileReconParticles) ; + fReconParticles=new TClonesArray("AliFMDReconstParticles",1000); + reconstruction->Exec(fReconParticles,""); + delete reconstruction; +} diff --git a/FMD/AliFMD.h b/FMD/AliFMD.h index 9b0bff13974..65823219cba 100644 --- a/FMD/AliFMD.h +++ b/FMD/AliFMD.h @@ -9,9 +9,11 @@ #include "AliDetector.h" #include "TString.h" +#include "AliFMDMerger.h" class TFile; class TTree; + class AliFMDMerger; class AliFMD : public AliDetector { public: @@ -34,13 +36,24 @@ public: virtual void StepManager() {} void Eta2Radius(Float_t, Float_t, Float_t*); void Hits2SDigits();// + void Digits2Reco(); // Digitisation TClonesArray *SDigits() const {return fSDigits;} // virtual void SDigits2Digits(); - + virtual void SDigits2Digits(); + virtual void SetMerger(AliFMDMerger* merger); + virtual AliFMDMerger* Merger(); + TClonesArray *ReconParticles() const {return fReconParticles;} + Int_t fNevents ; // Number of events to digitize + protected: Int_t fIdSens1; //Si sensetive volume + AliFMDMerger *fMerger; // ! pointer to merger TClonesArray *fSDigits ; // List of summable digits - ClassDef(AliFMD,2) //Class for the FMD detector + TClonesArray *fReconParticles; + + ClassDef(AliFMD,3) //Class for the FMD detector }; #endif // AliFMD_H + + diff --git a/FMD/AliFMDMerger.cxx b/FMD/AliFMDMerger.cxx new file mode 100644 index 00000000000..f5021bff874 --- /dev/null +++ b/FMD/AliFMDMerger.cxx @@ -0,0 +1,215 @@ +/************************************************************************** + * Copyright(c) 1998-2000, 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. * + **************************************************************************/ + +/* +$Log$ +Revision 1.3 2001/03/05 23:57:44 morsch +Writing of digit tree moved to macro. + +Revision 1.2 2001/03/05 08:40:25 morsch +Method SortTracks(..) imported from AliMUON. + +Revision 1.1 2001/02/02 14:11:53 morsch +AliMUONMerger prototype to be called by the merge manager. + +*/ + +#include +#include +#include +#include +#include + + +#include "AliFMDMerger.h" +#include "AliFMD.h" +#include "AliFMDSDigitizer.h" +#include "AliFMDhit.h" +#include "AliFMDdigit.h" + +#include "AliRun.h" +#include "AliPDG.h" + +#include +#include +#include + +ClassImp(AliFMDMerger) + +//___________________________________________ + AliFMDMerger::AliFMDMerger() +{ +// Default constructor + fEvNrSig = 0; + fEvNrBgr = 0; + fMerge =kDigitize; + fFnBgr = 0; +} + +//------------------------------------------------------------------------ +AliFMDMerger::~AliFMDMerger() +{ +// Destructor + if(fSDigits) { + fSDigits->Delete(); + delete fSDigits ; + fSDigits = 0; + } +} + + + +//------------------------------------------------------------------------ +void AliFMDMerger::Init() +{ +// Initialisation + if (fMerge) fBgrFile = InitBgr(); + +} + + + +//------------------------------------------------------------------------ +TFile* AliFMDMerger::InitBgr() +{ +// Initialise background event + TFile *file = new TFile(fFnBgr); +// add error checking later + printf("\n AliFMDMerger has opened %s file with background event \n", fFnBgr); + return file; +} + +//------------------------------------------------------------------------ +void AliFMDMerger::Digitise() +{ + + // keep galice.root for signal and name differently the file for + // background when add! otherwise the track info for signal will be lost ! + + + +#ifdef DEBUG + cout<<"ALiFMD::>SDigits2Digits start...\n"; +#endif + + AliFMD * FMD = (AliFMD *) gAlice->GetDetector("FMD") ; + + Int_t chargeSum[10][20][150]; + Int_t digit[5]; + Int_t ivol, iSector, iRing; + + TFile *f1 =0; + TTree *TK = gAlice->TreeK(); + if (TK) f1 = TK->GetCurrentFile(); + + gAlice->GetEvent(fEvNrSig) ; + + if(gAlice->TreeD() == 0) + gAlice->MakeTree("D") ; + gAlice->TreeD()->Reset(); + + //Make branches + ReadDigit( chargeSum, fEvNrSig); + + if(fMerge){ + fBgrFile->cd(); + // gAlice->TreeS()->Reset(); + gAlice = (AliRun*)fBgrFile->Get("gAlice"); + Int_t chargeBgr[10][20][150]; + ReadDigit( chargeBgr,fEvNrBgr); + for ( ivol=1; ivol<=5; ivol++) + for ( iSector=1; iSector<=16; iSector++) + for ( iRing=1; iRing<=128; iRing++) + chargeSum[ivol][iSector][iRing]= + chargeBgr[ivol][iSector][iRing]+ + chargeSum[ivol][iSector][iRing]; + + } //if merge + + + // Put noise and make ADC signal + for ( ivol=1; ivol<=5; ivol++){ + for ( iSector=1; iSector<=16; iSector++){ + for ( iRing=1; iRing<=128; iRing++){ + digit[0]=ivol; + digit[1]=iSector; + digit[2]=iRing; + digit[3]=PutNoise(chargeSum[ivol][iSector][iRing]); + if(chargeSum[ivol][iSector][iRing] <= 500) digit[3]=500; + + //dinamic diapason 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; + + FMD->AddDigit(digit); + + } //ivol + } //iSector + } //iRing + + f1->cd(); + + //Make branch for digits + FMD->MakeBranch("D"); + + gAlice->TreeD()->Reset(); + gAlice->TreeD()->Fill(); + + fDigits = FMD->Digits(); + + gAlice->TreeD()->Write(0,TObject::kOverwrite) ; + + gAlice->ResetDigits(); + +} + +//--------------------------------------------------------------------- + +void AliFMDMerger::ReadDigit(Int_t chargeSum[][20][150], Int_t iEvNum) +{ + AliFMDdigit *fmddigit; + + for (Int_t i=0; i<10; i++) + for(Int_t j=0; j<20; j++) + for(Int_t ij=0; ij<150; ij++) + chargeSum[i][j][ij]=0; + + AliFMD * FMD = (AliFMD *) gAlice->GetDetector("FMD") ; + + gAlice->GetEvent(iEvNum) ; + if(gAlice->TreeS()==0) { + cout<<" TreeS==0 -> return"<TreeS()<ResetDigits(); + gAlice->TreeS()->GetEvent(iEvNum); + TClonesArray * FMDdigits = FMD->SDigits(); + + ndig=FMDdigits->GetEntries(); + + for (k=0; kUncheckedAt(k); + + Int_t iVolume=fmddigit->Volume(); + Int_t iNumberOfSector =fmddigit->NumberOfSector(); + Int_t iNumberOfRing=fmddigit->NumberOfRing(); + chargeSum[iVolume][iNumberOfSector][iNumberOfRing]=fmddigit->Charge(); + } +} + + diff --git a/FMD/AliFMDMerger.h b/FMD/AliFMDMerger.h new file mode 100644 index 00000000000..29208ac9183 --- /dev/null +++ b/FMD/AliFMDMerger.h @@ -0,0 +1,58 @@ +#ifndef ALIFMDMERGER_H +#define ALIFMDMERGER_H +/* Copyright(c) 1998-2000, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +// #include "AliMerger.h" +// #include "AliMergable.h" +#include "TRandom.h" +#include "AliDetector.h" + +typedef enum {kDigitize=0, kMerge = 1} MergeMode_t; + +class AliFMDMerger { + public: + + AliFMDMerger(); + virtual ~AliFMDMerger(); + + + // Initialize merging and digitisation + virtual void Init(); + + // Do the main work + void Digitise() ; + Int_t PutNoise(Int_t charge){return (Int_t)(gRandom->Gaus(charge,500));} + TClonesArray *SDigits() const {return fSDigits;} + // TClonesArray *Digits() const {return fDigits;} + + void ReadDigit(Int_t a[][20][150], Int_t); + + // Setters -> Later Communication with gAlice + void SetSignalEventNumber(Int_t i) {fEvNrSig = i;} + void SetBackgroundEventNumber(Int_t i) {fEvNrBgr = i;} + void SetBackgroundFileName(char* file) {fFnBgr = file;} + void SetSignalFileName(char* file) {fFnSig = file;} + void SetMode(MergeMode_t mode) {fMerge = mode;} + + enum {kBgTag = -1}; + + private: + // Open the bgr file + TFile *InitBgr(); + + private: + TClonesArray *fDigits; // ! array with digits + // Int_t fDigits; + TClonesArray *fSDigits ; // List of summable digits + Int_t fEvNrSig; // signal event number + Int_t fEvNrBgr; // background event number + MergeMode_t fMerge; // merging type kDigitize, kMerge + char *fFnBgr; // background file name + char *fFnSig; // signal file name + TFile *fBgrFile; // Pointer to background file + + ClassDef(AliFMDMerger,0) +}; +#endif + diff --git a/FMD/AliFMDReconstParticles.cxx b/FMD/AliFMDReconstParticles.cxx new file mode 100644 index 00000000000..9a183f4053d --- /dev/null +++ b/FMD/AliFMDReconstParticles.cxx @@ -0,0 +1,23 @@ +#include "AliFMDReconstParticles.h" + +ClassImp(AliFMDReconstParticles) + +AliFMDReconstParticles::AliFMDReconstParticles() +{ + fNumOfDet=0; + fNumOfSector=0; + fNumOfRing=0; + fNumOfReconstParticles=0; +} +AliFMDReconstParticles::AliFMDReconstParticles(Int_t *RecParticles) +{ + fNumOfDet=RecParticles[0]; + fNumOfSector=RecParticles[1]; + fNumOfRing=RecParticles[2]; + fNumOfReconstParticles=RecParticles[3]; +} +Int_t AliFMDReconstParticles::GetVolume(){return fNumOfDet;} +Int_t AliFMDReconstParticles::GetNumberOfSector() {return fNumOfSector;} +Int_t AliFMDReconstParticles::GetNumberOfRing() {return fNumOfRing;} +Int_t AliFMDReconstParticles::GetNumberOfReconstParticles() {return fNumOfReconstParticles;} + diff --git a/FMD/AliFMDReconstParticles.h b/FMD/AliFMDReconstParticles.h new file mode 100644 index 00000000000..c2036146695 --- /dev/null +++ b/FMD/AliFMDReconstParticles.h @@ -0,0 +1,25 @@ +#ifndef AliFMDReconstParticles_h +#define AliFMDReconstParticles_h + +#include +#include +class AliFMDReconstParticles: public TObject +{ + //Reconstracted Particles Class + private: + Int_t fNumOfDet; //Number of FMD disk; + Int_t fNumOfSector; //Number of sector + Int_t fNumOfRing; //Number of ring + Int_t fNumOfReconstParticles; //Number of reconstructed particles + + public: + AliFMDReconstParticles(); + AliFMDReconstParticles (Int_t *RecParticles); + virtual ~AliFMDReconstParticles(){}; + Int_t GetVolume(); //Return the number of volume + Int_t GetNumberOfSector(); //Return the number of sector + Int_t GetNumberOfRing(); //Return the number of ring + Int_t GetNumberOfReconstParticles(); //Returnthe number of reconstructed particles + ClassDef(AliFMDReconstParticles,1) +}; +#endif diff --git a/FMD/AliFMDReconstruction.cxx b/FMD/AliFMDReconstruction.cxx new file mode 100644 index 00000000000..d003ccb910f --- /dev/null +++ b/FMD/AliFMDReconstruction.cxx @@ -0,0 +1,137 @@ +// --- ROOT system --- +#include "TTask.h" +#include "TTree.h" +#include "TSystem.h" +#include "TFile.h" +// --- Standard library --- + +// --- AliRoot header files --- + +#include "AliFMDdigit.h" +#include "AliFMDReconstParticles.h" +#include "AliFMD.h" +#include "AliFMDv1.h" +#include "AliFMDReconstruction.h" +#include "AliRun.h" +#include "AliDetector.h" + +#include "TROOT.h" +#include "TFolder.h" +#include +#include +#include + +ClassImp(AliFMDReconstruction) + + +//____________________________________________________________________________ + +AliFMDReconstruction::AliFMDReconstruction():TTask("AliFMDReconstruction","") +{ + fNevents = 0 ; // Number of events to rreconnstraction, 0 means all events in current file + // add Task to //root/Tasks folder + TTask * roottasks = (TTask*)gROOT->GetRootFolder()->FindObject("Tasks") ; + roottasks->Add(this) ; +} +//____________________________________________________________________________ + +AliFMDReconstruction::AliFMDReconstruction(char* HeaderFile, char *ReconstParticlesFile):TTask("AliFMDReconstruction","") +{ + fNevents = 0 ; // Number of events to rreconnstraction, 0 means all events in current file + fReconstParticlesFile=ReconstParticlesFile ; + fHeadersFile=HeaderFile ; + //add Task to //root/Tasks folder + TTask * roottasks = (TTask*)gROOT->GetRootFolder()->FindObject("Tasks") ; + roottasks->Add(this) ; +} + +//____________________________________________________________________________ + +AliFMDReconstruction::~AliFMDReconstruction() +{ + +} + +//____________________________________________________________________________ + +void AliFMDReconstruction::Exec(TClonesArray *fReconParticles,Option_t *option) +{ + //Collects all digits in the same active volume into number of particles + + AliFMD * FMD = (AliFMD *) gAlice->GetDetector("FMD"); + if(fNevents == 0) fNevents=(Int_t)gAlice->TreeD()->GetEntries(); + for(Int_t ievent=0;ieventGetEvent(ievent) ; + if(gAlice->TreeH()==0) return; + if(gAlice->TreeR()==0) gAlice->MakeTree("R"); + //Make branches + FMD->MakeBranch("R"); + Int_t threshold[]={ 0, 18, 37, 56, 76, + 96, 119, 138, 165, 172, + 218, 231, 238, 277, 304, + 330, 357, 423, 449, 476, + 522, 542, 555, 568, 581, + 614, 624, 657, 674, 687, + 700, 713, 720, 727, 733, + 740, 759, 778, 797, 816, + 834, 853, 872, 891, 910, + 929, 948, 967, 986, 1024}; + + + int threshold_array_size=sizeof(threshold)/sizeof(threshold[0]); + AliFMDdigit *fmdDigit; + + if (FMD) + { + gAlice->TreeD()->GetEvent(0); + TClonesArray *FMDdigits=FMD->Digits(); + Int_t nDigits=FMDdigits->GetEntries(); + Int_t RecParticles[4]; + Int_t nRecPart=0 ; + for (Int_t digit=0;digitUncheckedAt(digit); + RecParticles[0] = fmdDigit->Volume(); + RecParticles[1] = fmdDigit->NumberOfSector(); + RecParticles[2] = fmdDigit->NumberOfRing(); + Int_t ADC=fmdDigit->ADCsignal(); + RecParticles[3]=0; //case when fmdDigit->ADCsignal()==0 + for (int i=0;ithreshold[i]&&ADC<=threshold[i+1]) + RecParticles[3]=i; + } + new((*fReconParticles)[nRecPart++]) AliFMDReconstParticles(RecParticles); + } //digit loop + }//if FMD + gAlice->TreeR()->Reset(); + gAlice->TreeR()->Fill(); + gAlice->TreeR()->Write(0,TObject::kOverwrite); + } //event loop + cout<<"\nAliFMDReconstruction::Exec(TClonesArray *fReconParticles,Option_t *option) finished"< #include -//#include +#include "/afs/cern.ch/alice/offline/new/RALICE/AliRandom.h" #include "AliMagF.h" #include "AliFMDhit.h" #include @@ -108,11 +108,10 @@ void AliFMDv0::CreateGeometry() for (ifmd =0; ifmd < 6; ifmd++){ sprintf(name,"FMD%d",ifmd); - if(fDebug) - printf("%s: %s",ClassName(),name); + printf(name); zfmd=TMath::Abs(z[ifmd]); - if(fDebug) printf("zfmd %f z[ifmd] %f",zfmd,z[ifmd]); + printf("zfmd %f z[ifmd] %f",zfmd,z[ifmd]); AliFMD::Eta2Radius(etain[ifmd],zfmd,&rin[ifmd]); AliFMD::Eta2Radius(etaout[ifmd],zfmd,&rout[ifmd]); @@ -121,7 +120,7 @@ void AliFMDv0::CreateGeometry() par[2]=zFMD/2; gMC->Gsvolu(name,"TUBE", idtmed[3], par, 3); - if(fDebug) printf ("rin %f rout %f ZFMD %f\n",par[0],par[1],z[ifmd]); + printf ("rin %f rout %f ZFMD %f\n",par[0],par[1],z[ifmd]); if (z[ifmd] < 0){ gMC->Gspos(name,1,"ALIC",0,0,z[ifmd],0, "ONLY");} else { @@ -218,7 +217,7 @@ void AliFMDv0::Init() AliMC* gMC=AliMC::GetMC(); AliFMD::Init(); fIdSens1=gMC->VolId("GFSI"); -if(fDebug) printf("%s: *** FMD version 0 initialized ***\n",ClassName()); +printf("*** FMD version 0 initialized ***\n"); } //------------------------------------------------------------------- diff --git a/FMD/AliFMDv1.cxx b/FMD/AliFMDv1.cxx index 3639c314ba4..080559c4f32 100644 --- a/FMD/AliFMDv1.cxx +++ b/FMD/AliFMDv1.cxx @@ -92,9 +92,10 @@ void AliFMDv1::CreateGeometry() char name[5]; Float_t rin[6], rout[6],zpos; - Float_t etain[6]= {3.3, 2.0, 3.3, 2.0, 4.7, 5.5}; - Float_t etaout[6]={2.0, 1.6, 2.0, 1.6, 3.6, 4.5}; - Float_t z[6]={64., 85., -64., -85., -270., -630}; + Float_t etain[6]= {3.3, 2.0, 3.3, 2.0, 4.5, 5.5}; + Float_t etaout[6]={2.0, 1.6, 2.0, 1.6, 3.3, 4.5}; + // Float_t z[6]={64., 85., -64., -85., -270., -630}; + Float_t z[6]={64., 85., -64., -85., -240., -630}; Float_t zDet=0.04; Float_t zElectronic=0.75; Float_t zSupport=1.; @@ -109,14 +110,13 @@ void AliFMDv1::CreateGeometry() gMC->Gsvolu("GEL ","TUBE", idtmed[4], par, 0); gMC->Gsvolu("GSUP","TUBE", idtmed[2], par, 0); - for (ifmd =0; ifmd < 4; ifmd++){ + for (ifmd =0; ifmd < 5; ifmd++){ sprintf(name,"FMD%d",ifmd); - if(fDebug) - printf("%s: %s",ClassName(),name); + printf(name); zfmd=TMath::Abs(z[ifmd]); - if(fDebug) printf("zfmd %f z[ifmd] %f",zfmd,z[ifmd]); + printf("zfmd %f z[ifmd] %f",zfmd,z[ifmd]); AliFMD::Eta2Radius(etain[ifmd],zfmd,&rin[ifmd]); AliFMD::Eta2Radius(etaout[ifmd],zfmd,&rout[ifmd]); @@ -125,7 +125,7 @@ void AliFMDv1::CreateGeometry() par[2]=zFMD/2; gMC->Gsvolu(name,"TUBE", idtmed[3], par, 3); - if(fDebug) printf ("rin %f rout %f ZFMD %f\n",par[0],par[1],z[ifmd]); + printf ("rin %f rout %f ZFMD %f\n",par[0],par[1],z[ifmd]); if (z[ifmd] < 0){ gMC->Gspos(name,1,"ALIC",0,0,z[ifmd],0, "ONLY");} else { @@ -228,10 +228,10 @@ void AliFMDv1::Init() { // Initialises version 0 of the Forward Multiplicity Detector // - AliMC* gMC=AliMC::GetMC(); - AliFMD::Init(); - fIdSens1=gMC->VolId("GRIN"); - if(fDebug) printf("%s: *** FMD version 1 initialized ***\n",ClassName()); +AliMC* gMC=AliMC::GetMC(); +AliFMD::Init(); +fIdSens1=gMC->VolId("GRIN"); +printf("*** FMD version 1 initialized ***\n"); } //------------------------------------------------------------------- @@ -270,10 +270,12 @@ void AliFMDv1::StepManager() vol[1]=copy1; gMC->CurrentVolOffID(2,copy2); vol[0]=copy2; + // printf("vol0 %d vol1 %d vol2 %d\n",vol[0],vol[1],vol[2]); gMC->TrackPosition(pos); hits[0]=pos[0]; hits[1]=pos[1]; hits[2]=pos[2]; + // printf(" Zpos %f \n",hits[2]); gMC->TrackMomentum(mom); hits[3]=mom[0]; hits[4]=mom[1]; @@ -299,6 +301,17 @@ void AliFMDv1::StepManager() } // IsTrackExiting() } } +//-------------------------------------------------------------------------- + +void AliFMDv1::Response( Float_t Edep) +{ + Float_t I=1.664*0.04*2.33/22400; // = 0.69e-6; + Float_t chargeOnly=Edep/I; + //Add noise ~500electrons + Int_t charge=500; + if (Edep>0) + charge=Int_t(gRandom->Gaus(chargeOnly,500)); + } diff --git a/FMD/AliFMDv1.h b/FMD/AliFMDv1.h index 2fcc2dcb5c7..94dfcdf1cc4 100644 --- a/FMD/AliFMDv1.h +++ b/FMD/AliFMDv1.h @@ -8,7 +8,6 @@ //////////////////////////////////////////////// #include "AliFMD.h" -#include "AliFMDSDigitizer.h" class AliFMDv1 : public AliFMD { @@ -22,16 +21,19 @@ public: virtual void Init(); virtual Int_t IsVersion() const {return 0;} virtual void StepManager(); + // virtual void Hit2Digits(Int_t bgrEvent, Option_t *opt1=" ", + // Option_t *opt2=" ",Text_t *name=" "); // hit to digit for v1 :test + virtual void Response( Float_t Edep); +//private: + //Int_t fCharge; + protected: Int_t fIdSens1; // Sensetive volume in FMD // Background event for event mixing - Text_t *fFileName; // ! File with background hits - TTree *fTrH1; // Hits Tree for background event - TClonesArray *fHits2; // List of hits for one track only - ClassDef(AliFMDv1,2) //Class for FMD version 0 + ClassDef(AliFMDv1,2) //Class for FMD version 0 }; #endif diff --git a/FMD/FMDLinkDef.h b/FMD/FMDLinkDef.h index 09b61d4d0fa..3fe10ecd23c 100644 --- a/FMD/FMDLinkDef.h +++ b/FMD/FMDLinkDef.h @@ -13,6 +13,8 @@ #pragma link C++ class AliFMDv1+; #pragma link C++ class AliFMDhit+; #pragma link C++ class AliFMDdigit+; -#pragma link C++ class AliFMDSDigitizer+; +#pragma link C++ class AliFMDReconstruction+; +#pragma link C++ class AliFMDReconstParticles+; +#pragma link C++ class AliFMDMerger+; #endif diff --git a/FMD/FMDMerger.C b/FMD/FMDMerger.C new file mode 100644 index 00000000000..cd7bf05ce87 --- /dev/null +++ b/FMD/FMDMerger.C @@ -0,0 +1,81 @@ +void FMDMerger (Int_t evNumber1=0, Int_t evNumber2=0, Int_t ibg=0, Int_t bgr=10) +{ +// Dynamically link some shared libs + + if (gClassTable->GetID("AliRun") < 0) { + gROOT->LoadMacro("loadlibs.C"); + loadlibs(); + } + +// Connect the Root Galice file containing Geometry, Kine and Hits + + TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("mgalice.root"); + if (file) file->Close(); + file = new TFile("mgalice.root","UPDATE"); + cout<<" Just starting... file "<Get("gAlice"); + if (gAlice) printf("AliRun object found on file\n"); + if (!gAlice) gAlice = new AliRun("gAlice","Alice test program"); + } + AliFMD *FMD = (AliFMD*) gAlice->GetModule("FMD"); + cout<<" FMDMerger:: FMD "<SetMode(ibg); + merger->SetBackgroundFileName("bg.root"); + } + // pass + // merger->SetSignalFileName("mgalice.root"); + FMD->SetMerger(merger); + } +// Action ! +// +// Loop over events +// + for (int nev=evNumber1; nev<= evNumber2; nev++) { + Int_t nparticles = gAlice->GetEvent(nev); + cout << "nev " << nev <SetBackgroundEventNumber(nbgr_ev); + } + + gAlice->SDigits2Digits("FMD"); + + char hname[30]; + sprintf(hname,"TreeD%d",nev); + // gAlice->TreeD()->Write(hname); + // cout<TreeD()->Print(); + //reset tree + gAlice->TreeD()->Reset(); + + } // event loop +} + + + + + + + + + + + + + + diff --git a/FMD/Hits2SDigits.C b/FMD/Hits2SDigits.C index 553ce7bccbc..ee298bb95be 100644 --- a/FMD/Hits2SDigits.C +++ b/FMD/Hits2SDigits.C @@ -3,14 +3,17 @@ void Hits2SDigits(){ gROOT->LoadMacro("$ALICE_ROOT/macros/loadlibs.C"); loadlibs(); } - gSystem->Setenv("CONFIG_SPLIT_FILE","1") ; + // gSystem->Setenv("CONFIG_SPLIT_FILE","1") ; if (gSystem->Getenv("CONFIG_SPLIT_FILE")) cout << "SPLIT" << endl; else cout << "NO SPLIT" << endl ; - TFile * f = new TFile("galice.root","UPDATE"); + TFile * f = new TFile("mgalice.root","UPDATE"); gAlice = (AliRun*) f->Get("gAlice") ; cout<<"gAlice="<GetDetector("FMD") ; - gAlice->Hits2SDigits("FMD") ; - } + cout<<" FMD "<GetEvent(0); + gAlice->Hits2SDigits() ; + gAlice->TreeS()->Write(0,TObject::kOverwrite) ; + } diff --git a/FMD/Makefile b/FMD/Makefile index 1b17fafe17a..41f7d83be30 100644 --- a/FMD/Makefile +++ b/FMD/Makefile @@ -9,8 +9,7 @@ PACKAGE = FMD # C++ sources -SRCS = AliFMD.cxx AliFMDv0.cxx AliFMDv1.cxx AliFMDhit.cxx\ - AliFMDdigit.cxx AliFMDSDigitizer.cxx +SRCS = AliFMD.cxx AliFMDv0.cxx AliFMDv1.cxx AliFMDhit.cxx AliFMDdigit.cxx AliFMDMerger.cxx AliFMDReconstruction.cxx AliFMDReconstParticles.cxx # C++ Headers @@ -51,6 +50,9 @@ ALIBRARY = $(LIBDIR)/libFMD.a default: $(SLIBRARY) +tst: Hit2Digits.cxx + g++ -g $(CXXFLAGS) $(SLIBRARY) Hit2Digits.cxx $(ROOTLIBS) -o tst + $(LIBDIR)/libFMD.$(SL): $(OBJS) $(DICT): $(HDRS) diff --git a/FMD/TestReconstruction.C b/FMD/TestReconstruction.C new file mode 100644 index 00000000000..9392748135f --- /dev/null +++ b/FMD/TestReconstruction.C @@ -0,0 +1,19 @@ +void TestReconstruction (Int_t evNumber=1) +{ + if (gClassTable->GetID("AliRun") < 0) + { + gROOT->LoadMacro("$ALICE_ROOT/macros/loadlibs.C"); + loadlibs(); + } + if (gSystem->Getenv("CONFIG_SPLIT_FILE")) + cout << "SPLIT" << endl; + else + cout << "NO SPLIT" << endl ; + TFile * f = new TFile("mgalice.root","UPDATE"); + gAlice = (AliRun*) f->Get("gAlice") ; + cout<<"gAlice="<GetDetector("FMD"); + cout<<"\nFMD="<RunReco("FMD") ; +} + -- 2.43.0