X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TRD%2FAliTRDclusterizer.cxx;h=87af305108a4d6ecfe1caaf4c99cff3994025bdc;hb=30f6c8cbe5b1c7ca16927082fe9cbd03d50fc374;hp=58fcab22928da107e9319d728d21da2e87d009cf;hpb=c630aafd1da7fec82908f28924c025969497227d;p=u%2Fmrichter%2FAliRoot.git diff --git a/TRD/AliTRDclusterizer.cxx b/TRD/AliTRDclusterizer.cxx index 58fcab22928..87af305108a 100644 --- a/TRD/AliTRDclusterizer.cxx +++ b/TRD/AliTRDclusterizer.cxx @@ -29,12 +29,11 @@ #include "AliRunLoader.h" #include "AliLoader.h" -#include "AliTRD.h" #include "AliTRDclusterizer.h" #include "AliTRDcluster.h" #include "AliTRDrecPoint.h" #include "AliTRDgeometry.h" -#include "AliTRDparameter.h" +#include "AliTRDcalibDB.h" ClassImp(AliTRDclusterizer) @@ -46,10 +45,8 @@ AliTRDclusterizer::AliTRDclusterizer():TNamed() // fClusterTree = NULL; - fTRD = 0; - fEvent = 0; + fRecPoints = 0; fVerbose = 0; - fPar = 0; } @@ -62,14 +59,13 @@ AliTRDclusterizer::AliTRDclusterizer(const Text_t* name, const Text_t* title) // fClusterTree = NULL; - fEvent = 0; + fRecPoints = 0; fVerbose = 0; - fPar = 0; } //_____________________________________________________________________________ -AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c) +AliTRDclusterizer::AliTRDclusterizer(const AliTRDclusterizer &c):TNamed(c) { // // AliTRDclusterizer copy constructor @@ -86,6 +82,10 @@ AliTRDclusterizer::~AliTRDclusterizer() // AliTRDclusterizer destructor // + if (fRecPoints) { + fRecPoints->Delete(); + delete fRecPoints; + } } //_____________________________________________________________________________ @@ -101,16 +101,15 @@ AliTRDclusterizer &AliTRDclusterizer::operator=(const AliTRDclusterizer &c) } //_____________________________________________________________________________ -void AliTRDclusterizer::Copy(TObject &c) +void AliTRDclusterizer::Copy(TObject &c) const { // // Copy function // ((AliTRDclusterizer &) c).fClusterTree = NULL; - ((AliTRDclusterizer &) c).fEvent = 0; + ((AliTRDclusterizer &) c).fRecPoints = NULL; ((AliTRDclusterizer &) c).fVerbose = fVerbose; - ((AliTRDclusterizer &) c).fPar = 0; } @@ -120,7 +119,10 @@ Bool_t AliTRDclusterizer::Open(const Char_t *name, Int_t nEvent) // // Opens the AliROOT file. Output and input are in the same file // - fRunLoader = AliRunLoader::Open(name); + TString evfoldname = AliConfig::GetDefaultEventFolderName(); + fRunLoader = AliRunLoader::GetRunLoader(evfoldname); + if (!fRunLoader) + fRunLoader = AliRunLoader::Open(name); if (!fRunLoader) { Error("Open","Can not open session for file %s.",name); @@ -160,7 +162,7 @@ Bool_t AliTRDclusterizer::OpenInput(Int_t nEvent) // // Connect the AliRoot file containing Geometry, Kine, and Hits - fRunLoader->LoadgAlice(); + if (fRunLoader->GetAliRun() == 0x0) fRunLoader->LoadgAlice(); gAlice = fRunLoader->GetAliRun(); if (!(gAlice)) { @@ -173,19 +175,9 @@ Bool_t AliTRDclusterizer::OpenInput(Int_t nEvent) } } - fEvent = nEvent; - // Import the Trees for the event nEvent in the file - fRunLoader->GetEvent(fEvent); + fRunLoader->GetEvent(nEvent); - // Get the TRD object - fTRD = (AliTRD*) gAlice->GetDetector("TRD"); - if (!fTRD) { - printf("AliTRDclusterizer::OpenInput -- "); - printf("No TRD detector object found\n"); - return kFALSE; - } - return kTRUE; } @@ -213,11 +205,11 @@ Bool_t AliTRDclusterizer::WriteClusters(Int_t det) if ((det >= 0) && (det < AliTRDgeometry::Ndet())) { - Int_t nRecPoints = fTRD->RecPoints()->GetEntriesFast(); + Int_t nRecPoints = RecPoints()->GetEntriesFast(); TObjArray *detRecPoints = new TObjArray(400); for (Int_t i = 0; i < nRecPoints; i++) { - AliTRDcluster *c = (AliTRDcluster *) fTRD->RecPoints()->UncheckedAt(i); + AliTRDcluster *c = (AliTRDcluster *) RecPoints()->UncheckedAt(i); if (det == c->GetDetector()) { detRecPoints->AddLast(c); } @@ -230,21 +222,21 @@ Bool_t AliTRDclusterizer::WriteClusters(Int_t det) branch->SetAddress(&detRecPoints); fClusterTree->Fill(); + delete detRecPoints; + return kTRUE; } if (det == -1) { - printf("AliTRDclusterizer::WriteClusters -- "); - printf("Writing the cluster tree %-18s for event %d.\n" - ,fClusterTree->GetName(),fEvent); + Info("WriteClusters","Writing the cluster tree %s for event %d." + ,fClusterTree->GetName(),fRunLoader->GetEventNumber()); /* fClusterTree->Write(); AliTRDgeometry *geo = fTRD->GetGeometry(); geo->SetName("TRDgeometry"); geo->Write(); - fPar->Write(); */ AliLoader* loader = fRunLoader->GetLoader("TRDLoader"); loader->WriteRecPoints("OVERWRITE"); @@ -264,4 +256,65 @@ Bool_t AliTRDclusterizer::WriteClusters(Int_t det) } +//_____________________________________________________________________________ +AliTRDcluster* AliTRDclusterizer::AddCluster(Double_t *pos, Int_t timebin, Int_t det, Double_t amp + , Int_t *tracks, Double_t *sig, Int_t iType, Float_t center) +{ + // + // Add a cluster for the TRD + // + AliTRDcluster *c = new AliTRDcluster(); + + c->SetDetector(det); + c->AddTrackIndex(tracks); + c->SetQ(amp); + c->SetX(pos[2]); + c->SetY(pos[0]); + c->SetZ(pos[1]); + c->SetSigmaY2(sig[0]); + c->SetSigmaZ2(sig[1]); + c->SetLocalTimeBin(timebin); + c->SetCenter(center); + switch (iType) { + case 0: + c->Set2pad(); + break; + case 1: + c->Set3pad(); + break; + case 2: + c->Set4pad(); + break; + case 3: + c->Set5pad(); + break; + case 4: + c->SetLarge(); + break; + }; + + RecPoints()->Add(c); + return c; +} + +//_____________________________________________________________________________ +Double_t AliTRDclusterizer::CalcXposFromTimebin(Float_t timebin, Int_t idet, Int_t col, Int_t row) +{ + // + // Calculates the local x position in the detector from the timebin, depends on the drift velocity + // and t0 + // + + AliTRDcalibDB* calibration = AliTRDcalibDB::Instance(); + if (!calibration) + return -1; + + Float_t vdrift = calibration->GetVdrift(idet, col, row); + Float_t t0 = calibration->GetT0(idet, col, row); + Float_t samplingFrequency = calibration->GetSamplingFrequency(); + + timebin -= t0; + + return timebin / samplingFrequency * vdrift; +}