#include "AliRunLoader.h"
#include "AliLoader.h"
#include "AliHeader.h"
+#include "AliRawReader.h"
#include "AliPMDdigit.h"
#include "AliPMDClusterFinder.h"
#include "AliPMDClustering.h"
#include "AliPMDcluster.h"
#include "AliPMDrecpoint1.h"
-
+#include "AliPMDRawStream.h"
ClassImp(AliPMDClusterFinder)
-AliPMDClusterFinder::AliPMDClusterFinder()
+AliPMDClusterFinder::AliPMDClusterFinder(AliRunLoader* runLoader):
+ fRunLoader(runLoader),
+ fPMDLoader(runLoader->GetLoader("PMDLoader")),
+ fTreeD(0),
+ fTreeR(0),
+ fDigits(new TClonesArray("AliPMDdigit", 1000)),
+ fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)),
+ fNpoint(0),
+ fDebug(0),
+ fEcut(0.)
{
//
-// Default Constructor
+// Constructor
//
- if (!fRecpoints) fRecpoints = new TClonesArray("AliPMDrecpoint1", 1000);
- fNpoint = 0;
-
- fDebug = 0;
- fEcut = 0.;
-
}
+// ------------------------------------------------------------------------- //
AliPMDClusterFinder::~AliPMDClusterFinder()
{
// Destructor
- delete fRecpoints;
-}
-
-void AliPMDClusterFinder::OpengAliceFile(Char_t *file, Option_t *option)
-{
- // Loads galice.root file and corresponding header, kinematics
- // hits and sdigits or digits depending on the option
- //
- fRunLoader = AliRunLoader::Open(file,AliConfig::fgkDefaultEventFolderName,
- "UPDATE");
-
- if (!fRunLoader)
- {
- Error("Open","Can not open session for file %s.",file);
- }
-
- fRunLoader->LoadgAlice();
- fRunLoader->LoadHeader();
- fRunLoader->LoadKinematics();
-
- gAlice = fRunLoader->GetAliRun();
-
- if (gAlice)
+ if (fDigits)
{
- printf("<AliPMDdigitizer::Open> ");
- printf("AliRun object found on file.\n");
+ fDigits->Delete();
+ delete fDigits;
+ fDigits=0;
}
- else
+ if (fRecpoints)
{
- printf("<AliPMDdigitizer::Open> ");
- printf("Could not find AliRun object.\n");
- }
- fPMD = (AliPMD*)gAlice->GetDetector("PMD");
- fPMDLoader = fRunLoader->GetLoader("PMDLoader");
- if (fPMDLoader == 0x0)
- {
- cerr<<"OpengAlice : Can not find PMD or PMDLoader\n";
- }
-
- const char *cDR = strstr(option,"DR");
-
- if (cDR)
- {
- fPMDLoader->LoadDigits("READ");
- fPMDLoader->LoadRecPoints("recreate");
+ fRecpoints->Delete();
+ delete fRecpoints;
+ fRecpoints=0;
}
}
+// ------------------------------------------------------------------------- //
void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt)
{
// algorithm on CPV plane and PREshower plane
//
Int_t det = 0,smn = 0;
- Int_t cellno;
Int_t xpos,ypos;
Float_t adc;
- Int_t isup;
+ Int_t ismn;
Int_t idet;
- Float_t clusdata[7];
+ Float_t clusdata[5];
TObjArray *pmdcont = new TObjArray();
- AliPMDcluster *pmdcl = new AliPMDcluster;
AliPMDClustering *pmdclust = new AliPMDClustering();
pmdclust->SetDebug(fDebug);
pmdclust->SetEdepCut(fEcut);
det = pmddigit->GetDetector();
smn = pmddigit->GetSMNumber();
- cellno = pmddigit->GetCellNumber();
+ xpos = pmddigit->GetRow();
+ ypos = pmddigit->GetColumn();
adc = pmddigit->GetADC();
//Int_t trno = pmddigit->GetTrackNumber();
-
- xpos = cellno/fCol;
- ypos = cellno - xpos*fCol;
fCellADC[xpos][ypos] = (Double_t) adc;
}
idet = det;
- isup = smn;
- pmdclust->DoClust(fCellADC,pmdcont);
+ ismn = smn;
+ pmdclust->DoClust(idet,ismn,fCellADC,pmdcont);
Int_t nentries1 = pmdcont->GetEntries();
- cout << " nentries1 = " << nentries1 << endl;
+// cout << " nentries1 = " << nentries1 << endl;
for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
{
- clusdata[0] = (Float_t) idet;
- clusdata[1] = (Float_t) isup;
-
- pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
-
- clusdata[2] = pmdcl->GetClusX();
- clusdata[3] = pmdcl->GetClusY();
- clusdata[4] = pmdcl->GetClusADC();
- clusdata[5] = pmdcl->GetClusCells();
- clusdata[6] = pmdcl->GetClusRadius();
+ AliPMDcluster *pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
+ idet = pmdcl->GetDetector();
+ ismn = pmdcl->GetSMN();
+ clusdata[0] = pmdcl->GetClusX();
+ clusdata[1] = pmdcl->GetClusY();
+ clusdata[2] = pmdcl->GetClusADC();
+ clusdata[3] = pmdcl->GetClusCells();
+ clusdata[4] = pmdcl->GetClusRadius();
- AddRecPoint(clusdata);
+ AddRecPoint(idet,ismn,clusdata);
}
pmdcont->Clear();
} // modules
ResetCellADC();
-
+ fPMDLoader = fRunLoader->GetLoader("PMDLoader");
fPMDLoader->WriteRecPoints("OVERWRITE");
// delete the pointers
// cout << " ***** End::Digits2RecPoints *****" << endl;
}
+// ------------------------------------------------------------------------- //
+
+void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt, AliRawReader *rawReader)
+{
+ // Converts digits to recpoints after running clustering
+ // algorithm on CPV plane and PREshower plane
+ //
+
+ Float_t clusdata[5];
+
+
+ rawReader->Reset();
+ AliPMDRawStream pmdinput(rawReader);
+
+ TObjArray *pmdcont = new TObjArray();
+ AliPMDClustering *pmdclust = new AliPMDClustering();
+ pmdclust->SetDebug(fDebug);
+ pmdclust->SetEdepCut(fEcut);
+
+ fRunLoader->GetEvent(ievt);
+
+ ResetRecpoint();
+ fTreeR = fPMDLoader->TreeR();
+ if (fTreeR == 0x0)
+ {
+ fPMDLoader->MakeTree("R");
+ fTreeR = fPMDLoader->TreeR();
+ }
+
+ Int_t bufsize = 16000;
+ fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize);
+
+ Int_t irownew = 0;
+ Int_t icolnew = 0;
+ Int_t irownew1 = 0;
+ Int_t icolnew1 = 0;
+ const Int_t kDet = 2;
+ const Int_t kSMN = 24;
+ const Int_t kRow = 48;
+ const Int_t kCol = 96;
+ Int_t preADC[kSMN][kRow][kCol];
+ Int_t cpvADC[kSMN][kRow][kCol];
+
+ for (Int_t i = 0; i < kSMN; i++)
+ {
+ for (Int_t j = 0; j < kRow; j++)
+ {
+ for (Int_t k = 0; k < kCol; k++)
+ {
+ preADC[i][j][k] = 0;
+ cpvADC[i][j][k] = 0;
+ }
+ }
+ }
+ ResetCellADC();
+
+ while(pmdinput.Next())
+ {
+ Int_t det = pmdinput.GetDetector();
+ Int_t smn = pmdinput.GetSMN();
+ //Int_t mcm = pmdinput.GetMCM();
+ //Int_t chno = pmdinput.GetChannel();
+ Int_t row = pmdinput.GetRow();
+ Int_t col = pmdinput.GetColumn();
+ Int_t sig = pmdinput.GetSignal();
+
+ //cout << " det = " << det << " smn = " << smn
+ // << " row = " << row << " col = " << col
+ // << " sig = " << sig << endl;
+
+ // Transform all the (0,0) coordinates to the geant frame
+ if(smn < 6)
+ {
+ irownew1 = 95 - row;
+ icolnew1 = col;
+ }
+ else if(smn >= 6 && smn < 12)
+ {
+ irownew1 = row;
+ icolnew1 = 47 - col;
+ }
+ else if(smn >= 12 && smn < 18)
+ {
+ irownew1 = 47 - row;
+ icolnew1 = col;
+ }
+ else if(smn >= 18 && smn < 24)
+ {
+ irownew1 = row;
+ icolnew1 = 95 - col;
+ }
+
+ // for smn < 12 : row = 96, column = 48
+ // for smn>= 12 and < 24 : row = 48, column = 96
+ // In order to make it uniform dimension, smn < 12 are inverted
+ // i.i., row becomes column and column becomes row
+ // for others it remains same
+ // This is further inverted back while calculating eta and phi
+ if(smn < 12)
+ {
+ // SupeModule 1 and 2 : Rows are inverted to columns and vice versa
+ // and at the time of calculating the eta,phi it is again reverted
+ // back
+ irownew = icolnew1;
+ icolnew = irownew1;
+ }
+ else if( smn >= 12 && smn < 24)
+ {
+ irownew = irownew1;
+ icolnew = icolnew1;
+ }
+
+ if (det == 0)
+ {
+ preADC[smn][irownew][icolnew] = sig;
+ }
+ else if (det == 1)
+ {
+ cpvADC[smn][irownew][icolnew] = sig;
+ }
+ } // while loop
+
+ for (Int_t idet = 0; idet < kDet; idet++)
+ {
+ for (Int_t ismn = 0; ismn < kSMN; ismn++)
+ {
+ for (Int_t irow = 0; irow < kRow; irow++)
+ {
+ for (Int_t icol = 0; icol < kCol; icol++)
+ {
+ if (idet == 0)
+ {
+ fCellADC[irow][icol] =
+ (Double_t) preADC[ismn][irow][icol];
+ }
+ else if (idet == 1)
+ {
+ fCellADC[irow][icol] =
+ (Double_t) cpvADC[ismn][irow][icol];
+ }
+ } // row
+ } // col
+ pmdclust->DoClust(idet,ismn,fCellADC,pmdcont);
+ Int_t nentries1 = pmdcont->GetEntries();
+ // cout << " nentries1 = " << nentries1 << endl;
+ for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
+ {
+ AliPMDcluster *pmdcl =
+ (AliPMDcluster*)pmdcont->UncheckedAt(ient1);
+ idet = pmdcl->GetDetector();
+ ismn = pmdcl->GetSMN();
+ clusdata[0] = pmdcl->GetClusX();
+ clusdata[1] = pmdcl->GetClusY();
+ clusdata[2] = pmdcl->GetClusADC();
+ clusdata[3] = pmdcl->GetClusCells();
+ clusdata[4] = pmdcl->GetClusRadius();
+
+ AddRecPoint(idet,ismn,clusdata);
+ }
+ pmdcont->Clear();
+
+ fTreeR->Fill();
+ ResetRecpoint();
+
+ } // smn
+ } // det (pre, cpv)
+
+ ResetCellADC();
+ fPMDLoader = fRunLoader->GetLoader("PMDLoader");
+ fPMDLoader->WriteRecPoints("OVERWRITE");
+
+ // delete the pointers
+ delete pmdclust;
+ delete pmdcont;
+
+ // cout << " ***** End::Digits2RecPoints :: Raw *****" << endl;
+}
+// ------------------------------------------------------------------------- //
void AliPMDClusterFinder::SetCellEdepCut(Float_t ecut)
{
fEcut = ecut;
}
+// ------------------------------------------------------------------------- //
void AliPMDClusterFinder::SetDebug(Int_t idebug)
{
fDebug = idebug;
}
-
-void AliPMDClusterFinder::AddRecPoint(Float_t *clusdata)
+// ------------------------------------------------------------------------- //
+void AliPMDClusterFinder::AddRecPoint(Int_t idet,Int_t ismn,Float_t *clusdata)
{
// Add Reconstructed points
//
TClonesArray &lrecpoints = *fRecpoints;
AliPMDrecpoint1 *newrecpoint;
- newrecpoint = new AliPMDrecpoint1(clusdata);
+ newrecpoint = new AliPMDrecpoint1(idet, ismn, clusdata);
new(lrecpoints[fNpoint++]) AliPMDrecpoint1(newrecpoint);
delete newrecpoint;
}
+// ------------------------------------------------------------------------- //
void AliPMDClusterFinder::ResetCellADC()
{
// Reset the individual cell ADC value to zero
//
- for(Int_t irow = 0; irow < fRow; irow++)
+ for(Int_t irow = 0; irow < fgkRow; irow++)
{
- for(Int_t icol = 0; icol < fCol; icol++)
+ for(Int_t icol = 0; icol < fgkCol; icol++)
{
fCellADC[irow][icol] = 0.;
}
}
}
+// ------------------------------------------------------------------------- //
void AliPMDClusterFinder::ResetRecpoint()
{
fNpoint = 0;
if (fRecpoints) fRecpoints->Clear();
}
-void AliPMDClusterFinder::UnLoad(Option_t *option)
+// ------------------------------------------------------------------------- //
+void AliPMDClusterFinder::Load()
+{
+ // Load all the *.root files
+ //
+ fPMDLoader->LoadDigits("READ");
+ fPMDLoader->LoadRecPoints("recreate");
+}
+// ------------------------------------------------------------------------- //
+void AliPMDClusterFinder::UnLoad()
{
// Unload all the *.root files
//
- const char *cR = strstr(option,"R");
-
- fRunLoader->UnloadgAlice();
- fRunLoader->UnloadHeader();
- fRunLoader->UnloadKinematics();
-
- if (cR)
- {
- fPMDLoader->UnloadDigits();
- }
+ fPMDLoader->UnloadDigits();
+ fPMDLoader->UnloadRecPoints();
}
+// ------------------------------------------------------------------------- //