From 25ca55ce1319759ab4aef50a95d664a47f1cd597 Mon Sep 17 00:00:00 2001 From: cblume Date: Sun, 6 May 2007 18:41:49 +0000 Subject: [PATCH] Go back to previous version of simulation --- TRD/AliTRDCalibraFillHisto.cxx | 2 +- TRD/AliTRDReconstructor.cxx | 192 ++++++++++++---- TRD/AliTRDReconstructor.h | 26 ++- TRD/AliTRDclusterizer.cxx | 16 ++ TRD/AliTRDclusterizer.h | 1 + TRD/AliTRDclusterizerV1.cxx | 12 + TRD/AliTRDclusterizerV1.h | 1 + TRD/AliTRDdigitizer.cxx | 390 ++++++++++++++------------------- TRD/AliTRDdigitizer.h | 5 +- TRD/AliTRDgeometry.cxx | 119 +++++----- TRD/AliTRDgeometry.h | 20 +- TRD/AliTRDpadPlane.cxx | 110 +++------- TRD/AliTRDpadPlane.h | 23 +- TRD/AliTRDpidESD.cxx | 6 +- TRD/AliTRDtrigger.cxx | 11 + TRD/AliTRDtrigger.h | 3 +- TRD/AliTRDv1.cxx | 22 +- 17 files changed, 498 insertions(+), 461 deletions(-) diff --git a/TRD/AliTRDCalibraFillHisto.cxx b/TRD/AliTRDCalibraFillHisto.cxx index c6974b0e758..e9bcdfa31e0 100644 --- a/TRD/AliTRDCalibraFillHisto.cxx +++ b/TRD/AliTRDCalibraFillHisto.cxx @@ -538,7 +538,7 @@ Bool_t AliTRDCalibraFillHisto::UpdateHistograms(AliTRDcluster *cl, AliTRDtrack * Int_t row = padplane->GetPadRowNumber(pos[2]); Double_t offsetz = padplane->GetPadRowOffset(row,pos[2]); Double_t offsettilt = padplane->GetTiltOffset(offsetz); - Int_t col = padplane->GetPadColNumber(pos[1]+offsettilt); + Int_t col = padplane->GetPadColNumber(pos[1]+offsettilt,offsetz); // See if we are not near a masked pad if (!IsPadOn(detector,col,row)) { diff --git a/TRD/AliTRDReconstructor.cxx b/TRD/AliTRDReconstructor.cxx index ab56022cb7e..74afd72ec99 100644 --- a/TRD/AliTRDReconstructor.cxx +++ b/TRD/AliTRDReconstructor.cxx @@ -43,53 +43,14 @@ Bool_t AliTRDReconstructor::fgkSeedingOn = kFALSE; Int_t AliTRDReconstructor::fgStreamLevel = 0; // Stream (debug) level //_____________________________________________________________________________ -void AliTRDReconstructor::Reconstruct(AliRunLoader *runLoader) const +void AliTRDReconstructor::ConvertDigits(AliRawReader* /*rawReader*/ + , TTree* /*digitsTree*/) const { // - // Reconstruct clusters + // Convert raw data digits into digit objects in a root tree // - AliLoader *loader = runLoader->GetLoader("TRDLoader"); - loader->LoadRecPoints("recreate"); - - runLoader->CdGAFile(); - Int_t nEvents = runLoader->GetNumberOfEvents(); - - for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) { - AliTRDclusterizerV1 clusterer("clusterer","TRD clusterizer"); - clusterer.Open(runLoader->GetFileName(),iEvent); - clusterer.ReadDigits(); - clusterer.MakeClusters(); - clusterer.WriteClusters(-1); - } - - loader->UnloadRecPoints(); - - // - // Trigger (tracklets, LTU) - // - loader->LoadTracks("RECREATE"); - AliInfo("Trigger tracklets will be produced"); - - AliTRDtrigger trdTrigger("Trigger","Trigger class"); - - AliTRDtrigParam *trigp = new AliTRDtrigParam("TRDtrigParam" - ,"TRD Trigger parameters"); - - Float_t field = AliTracker::GetBz() * 0.1; // Tesla - AliInfo(Form("Trigger set for magnetic field = %f Tesla \n",field)); - trigp->SetField(field); - trigp->Init(); - trdTrigger.SetParameter(trigp); - - for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) { - trdTrigger.Open(runLoader->GetFileName(),iEvent); - trdTrigger.ReadDigits(); - trdTrigger.MakeTracklets(); - trdTrigger.WriteTracklets(-1); - } - - loader->UnloadTracks(); + AliError("conversion of raw data digits into digit objects not implemented"); } @@ -153,6 +114,97 @@ void AliTRDReconstructor::Reconstruct(AliRunLoader *runLoader // loader->UnloadTracks(); +} +//_____________________________________________________________________________ +void AliTRDReconstructor::Reconstruct(AliRawReader *rawReader + , TTree *clusterTree) const +{ + // + // Reconstruct clusters + // + + AliInfo("Reconstruct TRD clusters from RAW data"); + + AliTRDclusterizerV1 clusterer("clusterer","TRD clusterizer"); + clusterer.OpenOutput(clusterTree); + clusterer.ReadDigits(rawReader); + clusterer.MakeClusters(); + clusterer.WriteClusters(-1); + + // + // No trigger, since we don't have the output tree for tracklets + // + +} + +//_____________________________________________________________________________ +void AliTRDReconstructor::Reconstruct(TTree *digitsTree, TTree *clusterTree) const +{ + // + // Reconstruct clusters + // + + AliTRDclusterizerV1 clusterer("clusterer","TRD clusterizer"); + clusterer.OpenOutput(clusterTree); + clusterer.ReadDigits(digitsTree); + clusterer.MakeClusters(); + clusterer.WriteClusters(-1); + + // + // No trigger, since we don't have the output tree for tracklets + // + +} + +//_____________________________________________________________________________ +void AliTRDReconstructor::Reconstruct(AliRunLoader *runLoader) const +{ + // + // Reconstruct clusters + // + + AliLoader *loader = runLoader->GetLoader("TRDLoader"); + loader->LoadRecPoints("recreate"); + + runLoader->CdGAFile(); + Int_t nEvents = runLoader->GetNumberOfEvents(); + + for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) { + AliTRDclusterizerV1 clusterer("clusterer","TRD clusterizer"); + clusterer.Open(runLoader->GetFileName(),iEvent); + clusterer.ReadDigits(); + clusterer.MakeClusters(); + clusterer.WriteClusters(-1); + } + + loader->UnloadRecPoints(); + + // + // Trigger (tracklets, LTU) + // + loader->LoadTracks("RECREATE"); + AliInfo("Trigger tracklets will be produced"); + + AliTRDtrigger trdTrigger("Trigger","Trigger class"); + + AliTRDtrigParam *trigp = new AliTRDtrigParam("TRDtrigParam" + ,"TRD Trigger parameters"); + + Float_t field = AliTracker::GetBz() * 0.1; // Tesla + AliInfo(Form("Trigger set for magnetic field = %f Tesla \n",field)); + trigp->SetField(field); + trigp->Init(); + trdTrigger.SetParameter(trigp); + + for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) { + trdTrigger.Open(runLoader->GetFileName(),iEvent); + trdTrigger.ReadDigits(); + trdTrigger.MakeTracklets(); + trdTrigger.WriteTracklets(-1); + } + + loader->UnloadTracks(); + } //_____________________________________________________________________________ @@ -168,6 +220,60 @@ AliTracker *AliTRDReconstructor::CreateTracker(AliRunLoader *runLoader) const } +//_____________________________________________________________________________ +void AliTRDReconstructor::FillESD(AliRunLoader* /*runLoader*/ + , AliRawReader* /*rawReader*/ + , AliESD *esd) const +{ + // + // Make PID + // + + AliTRDpidESD trdPID; + trdPID.MakePID(esd); + + // + // No trigger, since we don't have the output tree for tracklets + // + +} + +//_____________________________________________________________________________ +void AliTRDReconstructor::FillESD(AliRawReader* /*rawReader*/ + , TTree* /*clusterTree*/ + , AliESD *esd) const +{ + // + // Make PID + // + + AliTRDpidESD trdPID; + trdPID.MakePID(esd); + + // + // No trigger, since we don't have the output tree for tracklets + // + +} + +//_____________________________________________________________________________ +void AliTRDReconstructor::FillESD(TTree* /*digitsTree*/ + , TTree* /*clusterTree*/ + , AliESD *esd) const +{ + // + // Make PID + // + + AliTRDpidESD trdPID; + trdPID.MakePID(esd); + + // + // No trigger, since we don't have the output tree for tracklets + // + +} + //_____________________________________________________________________________ void AliTRDReconstructor::FillESD(AliRunLoader *runLoader , AliESD *esd) const diff --git a/TRD/AliTRDReconstructor.h b/TRD/AliTRDReconstructor.h index 8475489f2ab..6c23bc480ea 100644 --- a/TRD/AliTRDReconstructor.h +++ b/TRD/AliTRDReconstructor.h @@ -22,23 +22,25 @@ class AliTRDReconstructor: public AliReconstructor { AliTRDReconstructor(): AliReconstructor() { }; virtual ~AliTRDReconstructor() { }; - virtual void Reconstruct(AliRunLoader *runLoader, AliRawReader *rawReader) const; - virtual void Reconstruct(AliRawReader*, TTree*) const { }; - virtual void Reconstruct(TTree*, TTree*) const { }; - virtual void Reconstruct(AliRunLoader *runLoader) const; + virtual void ConvertDigits(AliRawReader *rawReader, TTree *digitsTree) const; + + virtual void Reconstruct(AliRunLoader *runLoader, AliRawReader *rawReader) const; + virtual void Reconstruct(AliRawReader *rawReader, TTree *clusterTree) const; + virtual void Reconstruct(TTree *digitsTree, TTree *clusterTree) const; + virtual void Reconstruct(AliRunLoader *runLoader) const; virtual AliTracker *CreateTracker(AliRunLoader *runLoader) const; - virtual void FillESD(AliRunLoader*, AliRawReader*, AliESD*) const { }; - virtual void FillESD(AliRawReader*, TTree*, AliESD*) const { }; - virtual void FillESD(TTree*, TTree*, AliESD*) const { }; - virtual void FillESD(AliRunLoader *runLoader, AliESD *esd) const; + virtual void FillESD(AliRunLoader *runLoader, AliRawReader *rawReader, AliESD *esd) const; + virtual void FillESD(AliRawReader *rawReader, TTree *clusterTree, AliESD *esd) const; + virtual void FillESD(TTree *digitsTree, TTree *clusterTree, AliESD *esd) const; + virtual void FillESD(AliRunLoader *runLoader, AliESD *esd) const; - static void SetSeedingOn(Bool_t seeding) { fgkSeedingOn = seeding; } - static void SetStreamLevel(Int_t level) { fgStreamLevel = level; } + static void SetSeedingOn(Bool_t seeding) { fgkSeedingOn = seeding; } + static void SetStreamLevel(Int_t level) { fgStreamLevel = level; } - static Bool_t SeedingOn() { return fgkSeedingOn; } - static Int_t StreamLevel() { return fgStreamLevel; } + static Bool_t SeedingOn() { return fgkSeedingOn; } + static Int_t StreamLevel() { return fgStreamLevel; } private: diff --git a/TRD/AliTRDclusterizer.cxx b/TRD/AliTRDclusterizer.cxx index 305d477c0d9..584dac756a1 100644 --- a/TRD/AliTRDclusterizer.cxx +++ b/TRD/AliTRDclusterizer.cxx @@ -163,6 +163,22 @@ Bool_t AliTRDclusterizer::OpenOutput() } +//_____________________________________________________________________________ +Bool_t AliTRDclusterizer::OpenOutput(TTree *clusterTree) +{ + // + // Connect the output tree + // + + TObjArray *ioArray = 0; + + fClusterTree = clusterTree; + fClusterTree->Branch("TRDcluster","TObjArray",&ioArray,32000,0); + + return kTRUE; + +} + //_____________________________________________________________________________ Bool_t AliTRDclusterizer::OpenInput(Int_t nEvent) { diff --git a/TRD/AliTRDclusterizer.h b/TRD/AliTRDclusterizer.h index 4fd83714e96..ba769a1823b 100644 --- a/TRD/AliTRDclusterizer.h +++ b/TRD/AliTRDclusterizer.h @@ -36,6 +36,7 @@ class AliTRDclusterizer : public TNamed { virtual Bool_t Open(const Char_t *name, Int_t nEvent = 0); virtual Bool_t OpenInput(Int_t nEvent = 0); virtual Bool_t OpenOutput(); + virtual Bool_t OpenOutput(TTree *clusterTree); virtual Bool_t MakeClusters() = 0; virtual Bool_t WriteClusters(Int_t det); void ResetRecPoints(); diff --git a/TRD/AliTRDclusterizerV1.cxx b/TRD/AliTRDclusterizerV1.cxx index 459342e48cf..66f8fc145ad 100644 --- a/TRD/AliTRDclusterizerV1.cxx +++ b/TRD/AliTRDclusterizerV1.cxx @@ -146,6 +146,18 @@ Bool_t AliTRDclusterizerV1::ReadDigits() } +//_____________________________________________________________________________ +Bool_t AliTRDclusterizerV1::ReadDigits(TTree *digitsTree) +{ + // + // Reads the digits arrays from the input tree + // + + // Read in the digit arrays + return (fDigitsManager->ReadDigits(digitsTree)); + +} + //_____________________________________________________________________________ Bool_t AliTRDclusterizerV1::ReadDigits(AliRawReader *rawReader) { diff --git a/TRD/AliTRDclusterizerV1.h b/TRD/AliTRDclusterizerV1.h index 955e9b33430..cf4dff00b20 100644 --- a/TRD/AliTRDclusterizerV1.h +++ b/TRD/AliTRDclusterizerV1.h @@ -33,6 +33,7 @@ class AliTRDclusterizerV1 : public AliTRDclusterizer { virtual Bool_t MakeClusters(); virtual Bool_t ReadDigits(); virtual Bool_t ReadDigits(AliRawReader *rawReader); + virtual Bool_t ReadDigits(TTree *digitsTree); protected: diff --git a/TRD/AliTRDdigitizer.cxx b/TRD/AliTRDdigitizer.cxx index 44131b5bc0f..9767950f3bf 100644 --- a/TRD/AliTRDdigitizer.cxx +++ b/TRD/AliTRDdigitizer.cxx @@ -74,9 +74,6 @@ #include "AliTRDSimParam.h" #include "AliTRDCommonParam.h" -#include "Cal/AliTRDCalROC.h" -#include "Cal/AliTRDCalDet.h" - ClassImp(AliTRDdigitizer) //_____________________________________________________________________________ @@ -320,7 +317,7 @@ AliTRDdigitizer::~AliTRDdigitizer() if (fMasks) { delete [] fMasks; - fMasks = 0; + fMasks = 0; } if (fTimeStruct1) { @@ -713,13 +710,10 @@ Bool_t AliTRDdigitizer::MakeDigits() // Number of track dictionary arrays const Int_t kNDict = AliTRDdigitsManager::kNDict; - // Width of the amplification region - const Float_t kAmWidth = AliTRDgeometry::AmThick(); + // Half the width of the amplification region + const Float_t kAmWidth = AliTRDgeometry::AmThick() / 2.0; // Width of the drift region const Float_t kDrWidth = AliTRDgeometry::DrThick(); - // Drift + amplification region - const Float_t kDrMin = - 0.5 * kAmWidth; - const Float_t kDrMax = kDrWidth + 0.5 * kAmWidth; Int_t iRow; Int_t iCol; @@ -736,7 +730,8 @@ Bool_t AliTRDdigitizer::MakeDigits() Int_t timeBinTRFend = 1; Double_t pos[3]; - Double_t loc[3]; + Double_t rot[3]; + Double_t xyz[3]; Double_t padSignal[kNpad]; Double_t signalOld[kNpad]; @@ -746,46 +741,46 @@ Bool_t AliTRDdigitizer::MakeDigits() AliTRDpadPlane *padPlane = 0; - AliTRDCalROC *calVdriftROC = 0; - Float_t calVdriftDetValue = 0.0; - AliTRDCalROC *calT0ROC = 0; - Float_t calT0DetValue = 0.0; - AliTRDCalROC *calGainFactorROC = 0; - Float_t calGainFactorDetValue = 0.0; - if (!gGeoManager) { AliFatal("No geometry manager!"); } - if (!fGeo) { - AliError("No geometry defined"); - return kFALSE; - } - fGeo->ReadGeoMatrices(); - AliTRDSimParam *simParam = AliTRDSimParam::Instance(); if (!simParam) { - AliFatal("Could not get simulation parameters"); + AliError("Could not get simulation parameters"); return kFALSE; } AliTRDCommonParam *commonParam = AliTRDCommonParam::Instance(); if (!commonParam) { - AliFatal("Could not get common parameterss"); + AliError("Could not get common parameterss"); return kFALSE; } + + // Create a container for the amplitudes + AliTRDsegmentArray *signalsArray = new AliTRDsegmentArray("AliTRDdataArrayF" + ,AliTRDgeometry::Ndet()); - AliTRDcalibDB *calibration = AliTRDcalibDB::Instance(); + AliTRDcalibDB* calibration = AliTRDcalibDB::Instance(); if (!calibration) { - AliFatal("Could not get calibration object"); + AliError("Could not get calibration object"); return kFALSE; } - AliDebug(1,"Start creating digits"); - - // Create a container for the amplitudes - AliTRDsegmentArray *signalsArray = new AliTRDsegmentArray("AliTRDdataArrayF" - ,AliTRDgeometry::Ndet()); + if (simParam->TRFOn()) { + timeBinTRFend = ((Int_t) (simParam->GetTRFhi() + * commonParam->GetSamplingFrequency())) - 1; + AliDebug(1,Form("Sample the TRF up to bin %d",timeBinTRFend)); + } + + Float_t elAttachProp = simParam->GetElAttachProp() / 100.0; + + if (!fGeo) { + AliError("No geometry defined"); + return kFALSE; + } + + AliDebug(1,"Start creating digits."); AliLoader *gimme = fRunLoader->GetLoader("TRDLoader"); if (!gimme->TreeH()) { @@ -797,7 +792,7 @@ Bool_t AliTRDdigitizer::MakeDigits() return kFALSE; } fTRD->SetTreeAddress(); - + // Get the number of entries in the hit tree // (Number of primary particles creating a hit somewhere) Int_t nTrack = (Int_t) hitTree->GetEntries(); @@ -811,23 +806,12 @@ Bool_t AliTRDdigitizer::MakeDigits() else { AliDebug(1,"Constant drift velocity in drift cells."); } - if (simParam->TRFOn()) { - timeBinTRFend = ((Int_t) (simParam->GetTRFhi() - * commonParam->GetSamplingFrequency())) - 1; - AliDebug(1,Form("Sample the TRF up to bin %d",timeBinTRFend)); - } - - // Get the detector wise calibration objects - const AliTRDCalDet *calVdriftDet = calibration->GetVdriftDet(); - const AliTRDCalDet *calT0Det = calibration->GetT0Det(); - const AliTRDCalDet *calGainFactorDet = calibration->GetGainFactorDet(); - + Int_t detectorOld = -1; Int_t countHits = 0; Int_t nTimeTotal = calibration->GetNumberOfTimeBins(); Float_t samplingRate = commonParam->GetSamplingFrequency(); - Float_t elAttachProp = simParam->GetElAttachProp() / 100.0; // Loop through all entries in the tree for (Int_t iTrack = 0; iTrack < nTrack; iTrack++) { @@ -858,18 +842,19 @@ Bool_t AliTRDdigitizer::MakeDigits() Float_t hittime = hit->GetTime(); Int_t plane = fGeo->GetPlane(detector); Int_t chamber = fGeo->GetChamber(detector); + Float_t time0 = AliTRDgeometry::GetTime0(plane); padPlane = commonParam->GetPadPlane(plane,chamber); - Float_t row0 = padPlane->GetRow0ROC(); + Float_t row0 = padPlane->GetRow0(); Int_t nRowMax = padPlane->GetNrows(); Int_t nColMax = padPlane->GetNcols(); Int_t inDrift = 1; // Find the current volume with the geo manager - gGeoManager->SetCurrentPoint(pos); - gGeoManager->FindNode(); - if (strstr(gGeoManager->GetPath(),"/UK")) { - inDrift = 0; - } + gGeoManager->SetCurrentPoint(pos); + gGeoManager->FindNode(); + if (strstr(gGeoManager->GetPath(),"/UK")) { + inDrift = 0; + } if (detector != detectorOld) { @@ -902,150 +887,129 @@ Bool_t AliTRDdigitizer::MakeDigits() if (fCompress) dictionary[iDict]->Expand(); } } - - // Get the calibration objects - calVdriftROC = calibration->GetVdriftROC(detector); - calVdriftDetValue = calVdriftDet->GetValue(detector); - calT0ROC = calibration->GetT0ROC(detector); - calT0DetValue = calT0Det->GetValue(detector); - detectorOld = detector; - } - // Go to the local coordinate system: - // loc[0] - col direction in amplification or driftvolume - // loc[1] - row direction in amplification or driftvolume - // loc[2] - time direction in amplification or driftvolume - gGeoManager->MasterToLocal(pos,loc); + // Rotate the sectors on top of each other + // by using the geoManager + Double_t aaa[3]; + gGeoManager->MasterToLocal(pos,aaa); if (inDrift) { - // Relative to middle of amplification region - loc[2] = loc[2] - kDrWidth/2.0 - kAmWidth/2.0; + aaa[2] = time0 - (kDrWidth / 2.0 + kAmWidth) + aaa[2]; } - - // The driftlength [cm] (w/o diffusion yet !). - // It is negative if the hit is between pad plane and anode wires. - Double_t driftlength = -1.0 * loc[2]; - - // Stupid patch to take care of TR photons that are absorbed - // outside the chamber volume. A real fix would actually need - // a more clever implementation of the TR hit generation - if (q < 0.0) { - if ((loc[1] < padPlane->GetRowEndROC()) || - (loc[1] > padPlane->GetRow0ROC())) { - AliDebug(2,Form("Hit outside of sensitive volume, row (z=%f, row0=%f, rowE=%f)\n" - ,loc[1],padPlane->GetRow0ROC(),padPlane->GetRowEndROC())); - hit = (AliTRDhit *) fTRD->NextHit(); - continue; - } - if ((driftlength < kDrMin) || - (driftlength > kDrMax)) { - AliDebug(2,Form("Hit outside of sensitive volume, time (Q = %d)\n" - ,((Int_t) q))); - hit = (AliTRDhit *) fTRD->NextHit(); - continue; - } + else { + aaa[2] = time0 + aaa[2]; } + aaa[1] = row0 + padPlane->GetLengthRim() + fGeo->RpadW() + - 0.5 * fGeo->GetChamberLength(plane,chamber) + + aaa[1]; + rot[0] = aaa[2]; + rot[1] = aaa[0]; + rot[2] = aaa[1]; - // Get row and col of unsmeared electron to retrieve drift velocity - // The pad row (z-direction) - Int_t rowE = padPlane->GetPadRowNumberROC(loc[1]); - if (rowE < 0) { - hit = (AliTRDhit *) fTRD->NextHit(); - continue; - } - Double_t rowOffset = padPlane->GetPadRowOffsetROC(rowE,loc[1]); - - // The pad column (rphi-direction) - Double_t offsetTilt = padPlane->GetTiltOffset(rowOffset); - Int_t colE = padPlane->GetPadColNumber(loc[0]+offsetTilt); - if (colE < 0) { - hit = (AliTRDhit *) fTRD->NextHit(); - continue; - } - Double_t colOffset = padPlane->GetPadColOffset(colE,loc[0]+offsetTilt); - - Float_t driftvelocity = calVdriftDetValue * calVdriftROC->GetValue(colE,rowE); - - // Normalized drift length - Double_t absdriftlength = TMath::Abs(driftlength); - if (commonParam->ExBOn()) { - absdriftlength /= TMath::Sqrt(GetLorentzFactor(driftvelocity)); - } + // The driftlength. It is negative if the hit is between pad plane and anode wires. + Double_t driftlength = time0 - rot[0]; // Loop over all electrons of this hit // TR photons produce hits with negative charge Int_t nEl = ((Int_t) TMath::Abs(q)); for (Int_t iEl = 0; iEl < nEl; iEl++) { - // Now the real local coordinate system of the ROC - // column direction: locC - // row direction: locR - // time direction: locT - // locR and locC are identical to the coordinates of the corresponding - // volumina of the drift or amplification region. - // locT is defined relative to the wire plane (i.e. middle of amplification - // region), meaming locT = 0, and is negative for hits coming from the - // drift region. - Double_t locC = loc[0]; - Double_t locR = loc[1]; - Double_t locT = loc[2]; + xyz[0] = rot[0]; + xyz[1] = rot[1]; + xyz[2] = rot[2]; + + // Stupid patch to take care of TR photons that are absorbed + // outside the chamber volume. A real fix would actually need + // a more clever implementation of the TR hit generation + if (q < 0.0) { + if ((xyz[2] < padPlane->GetRowEnd()) || + (xyz[2] > padPlane->GetRow0())) { + if (iEl == 0) { + AliDebug(2,Form("Hit outside of sensitive volume, row (z=%f, row0=%f, rowE=%f)" + ,xyz[2],padPlane->GetRow0(),padPlane->GetRowEnd())); + } + continue; + } + Float_t tt = driftlength + kAmWidth; + if ((tt < 0.0) || + (tt > kDrWidth + 2.0*kAmWidth)) { + if (iEl == 0) { + AliDebug(2,Form("Hit outside of sensitive volume, time (Q = %d)" + ,((Int_t) q))); + } + continue; + } + } + + // Get row and col of unsmeared electron to retrieve drift velocity + // The pad row (z-direction) + Int_t rowE = padPlane->GetPadRowNumber(xyz[2]); + if (rowE < 0) continue; + Double_t rowOffset = padPlane->GetPadRowOffset(rowE,xyz[2]); + + // The pad column (rphi-direction) + Double_t offsetTilt = padPlane->GetTiltOffset(rowOffset); + Int_t colE = padPlane->GetPadColNumber(xyz[1]+offsetTilt,rowOffset); + if (colE < 0) continue; + Double_t colOffset = padPlane->GetPadColOffset(colE,xyz[1]+offsetTilt); + + Float_t driftvelocity = calibration->GetVdrift(detector,colE,rowE); + + // Normalised drift length + Double_t absdriftlength = TMath::Abs(driftlength); + if (commonParam->ExBOn()) { + absdriftlength /= TMath::Sqrt(GetLorentzFactor(driftvelocity)); + } // Electron attachment if (simParam->ElAttachOn()) { - if (gRandom->Rndm() < (absdriftlength * elAttachProp)) { - continue; - } + if (gRandom->Rndm() < (absdriftlength * elAttachProp)) continue; } // Apply the diffusion smearing if (simParam->DiffusionOn()) { - if (!(Diffusion(driftvelocity,absdriftlength,locR,locC,locT))) { - continue; - } + if (!(Diffusion(driftvelocity,absdriftlength,xyz))) continue; } // Apply E x B effects (depends on drift direction) if (commonParam->ExBOn()) { - if (!(ExB(driftvelocity,driftlength,locC))) { - continue; - } + if (!(ExB(driftvelocity,driftlength,xyz))) continue; } // The electron position after diffusion and ExB in pad coordinates. // The pad row (z-direction) - rowE = padPlane->GetPadRowNumberROC(locR); + rowE = padPlane->GetPadRowNumber(xyz[2]); if (rowE < 0) continue; - rowOffset = padPlane->GetPadRowOffsetROC(rowE,locR); + rowOffset = padPlane->GetPadRowOffset(rowE,xyz[2]); // The pad column (rphi-direction) offsetTilt = padPlane->GetTiltOffset(rowOffset); - colE = padPlane->GetPadColNumber(locC+offsetTilt); + colE = padPlane->GetPadColNumber(xyz[1]+offsetTilt,rowOffset); if (colE < 0) continue; - colOffset = padPlane->GetPadColOffset(colE,locC+offsetTilt); + colOffset = padPlane->GetPadColOffset(colE,xyz[1]+offsetTilt); // Also re-retrieve drift velocity because col and row may have changed - driftvelocity = calVdriftDetValue * calVdriftROC->GetValue(colE,rowE); - Float_t t0 = calT0DetValue + calT0ROC->GetValue(colE,rowE); + driftvelocity = calibration->GetVdrift(detector,colE,rowE); + Float_t t0 = calibration->GetT0(detector,colE,rowE); - // Convert the position to drift time [mus], using either constant drift velocity or + // Convert the position to drift time, using either constant drift velocity or // time structure of drift cells (non-isochronity, GARFIELD calculation). - // Also add absolute time of hits to take pile-up events into account properly Double_t drifttime; if (simParam->TimeStructOn()) { - // Get z-position with respect to anode wire - Double_t zz = row0 - locR + simParam->GetAnodeWireOffset(); - zz -= ((Int_t)(2 * zz)) / 2.0; - if (zz > 0.25) { - zz = 0.5 - zz; + // Get z-position with respect to anode wire: + Double_t Z = row0 - xyz[2] + simParam->GetAnodeWireOffset(); + Z -= ((Int_t)(2 * Z)) / 2.0; + if (Z > 0.25) { + Z = 0.5 - Z; } // Use drift time map (GARFIELD) - drifttime = TimeStruct(driftvelocity,0.5*kAmWidth-1.0*locT,zz) + drifttime = TimeStruct(driftvelocity,time0-xyz[0]+kAmWidth,Z) + hittime; } else { // Use constant drift velocity - drifttime = -1.0 * locT / driftvelocity + drifttime = TMath::Abs(time0 - xyz[0]) / driftvelocity + hittime; } @@ -1062,8 +1026,6 @@ Bool_t AliTRDdigitizer::MakeDigits() // in units of pad width Double_t dist = (colOffset - 0.5*padPlane->GetColSize(colE)) / padPlane->GetColSize(colE); - // This is still the fixed parametrization, i.e. not dependent on - // calibration values !!!! if (!(calibration->PadResponse(signal,dist,plane,padSignal))) continue; } else { @@ -1072,7 +1034,7 @@ Bool_t AliTRDdigitizer::MakeDigits() padSignal[2] = 0.0; } - // The time bin (always positive), with t0 distortion + // The time bin (always positive), with t0 correction Double_t timeBinIdeal = drifttime * samplingRate + t0; // Protection if (TMath::Abs(timeBinIdeal) > 2*nTimeTotal) { @@ -1086,9 +1048,9 @@ Bool_t AliTRDdigitizer::MakeDigits() // Sample the time response inside the drift region // + additional time bins before and after. // The sampling is done always in the middle of the time bin - for (Int_t iTimeBin = TMath::Max(timeBinTruncated,0) - ;iTimeBin < TMath::Min(timeBinTruncated+timeBinTRFend,nTimeTotal) - ;iTimeBin++) { + for (Int_t iTimeBin = TMath::Max(timeBinTruncated, 0); + iTimeBin < TMath::Min(timeBinTruncated+timeBinTRFend,nTimeTotal); + iTimeBin++) { // Apply the time response Double_t timeResponse = 1.0; @@ -1151,12 +1113,6 @@ Bool_t AliTRDdigitizer::MakeDigits() AliDebug(1,Form("Finished analyzing %d hits",countHits)); - //____________________________________________________________________ - // - // Create (s)digits - //____________________________________________________________________ - // - // The coupling factor Double_t coupling = simParam->GetPadCoupling() * simParam->GetTimeCoupling(); @@ -1211,19 +1167,13 @@ Bool_t AliTRDdigitizer::MakeDigits() (!calibration->IsChamberMasked(iDet)) && ( fGeo->GetSMstatus(sector))) { - // Get the calibration objects - calGainFactorROC = calibration->GetGainFactorROC(iDet); - calGainFactorDetValue = calGainFactorDet->GetValue(iDet); - // Create the digits for this chamber for (iRow = 0; iRow < nRowMax; iRow++ ) { for (iCol = 0; iCol < nColMax; iCol++ ) { // Check whether pad is masked // Bridged pads are not considered yet!!! - if (calibration->IsPadMasked(iDet,iCol,iRow)) { - continue; - } + if (calibration->IsPadMasked(iDet,iCol,iRow)) continue; // Create summable digits if (fSDigits) { @@ -1241,19 +1191,17 @@ Bool_t AliTRDdigitizer::MakeDigits() // Create normal digits else { - Float_t padgain = calGainFactorDetValue - * calGainFactorROC->GetValue(iCol,iRow); - if (padgain <= 0) { - AliError(Form("Not a valid gain %f, %d %d %d",padgain,iDet,iCol,iRow)); - } - for (iTime = 0; iTime < nTimeTotal; iTime++) { Float_t signalAmp = signals->GetDataUnchecked(iRow,iCol,iTime); // Pad and time coupling signalAmp *= coupling; - // Gain factors + + Float_t padgain = calibration->GetGainFactor(iDet,iCol,iRow); + if (padgain <= 0) { + AliError(Form("Not a valid gain %f, %d %d %d",padgain,iDet,iCol,iRow)); + } signalAmp *= padgain; // Add the noise, starting from minus ADC baseline in electrons @@ -1332,9 +1280,9 @@ Bool_t AliTRDdigitizer::MakeDigits() AliDebug(1,Form("Total number of analyzed hits = %d",countHits)); AliDebug(1,Form("Total digits data size = %d, %d, %d, %d",totalSizeDigits - ,totalSizeDict0 - ,totalSizeDict1 - ,totalSizeDict2)); + ,totalSizeDict0 + ,totalSizeDict1 + ,totalSizeDict2)); return kTRUE; @@ -1380,24 +1328,21 @@ Bool_t AliTRDdigitizer::ConvertSDigits() Int_t iCol; Int_t iTime; - AliTRDCalROC *calGainFactorROC = 0; - Float_t calGainFactorDetValue = 0.0; - - AliTRDSimParam *simParam = AliTRDSimParam::Instance(); + AliTRDSimParam *simParam = AliTRDSimParam::Instance(); if (!simParam) { - AliFatal("Could not get simulation parameters"); + AliError("Could not get simulation parameters"); return kFALSE; } AliTRDCommonParam *commonParam = AliTRDCommonParam::Instance(); if (!commonParam) { - AliFatal("Could not get common parameters"); + AliError("Could not get common parameters"); return kFALSE; } - AliTRDcalibDB *calibration = AliTRDcalibDB::Instance(); + AliTRDcalibDB *calibration = AliTRDcalibDB::Instance(); if (!calibration) { - AliFatal("Could not get calibration object"); + AliError("Could not get calibration object"); return kFALSE; } @@ -1418,9 +1363,6 @@ Bool_t AliTRDdigitizer::ConvertSDigits() AliTRDdataArrayI *digitsOut; AliTRDdataArrayI *dictionaryIn[kNDict]; AliTRDdataArrayI *dictionaryOut[kNDict]; - - // Get the detector wise calibration objects - const AliTRDCalDet *calGainFactorDet = calibration->GetGainFactorDet(); // Loop through the detectors for (Int_t iDet = 0; iDet < AliTRDgeometry::Ndet(); iDet++) { @@ -1450,34 +1392,26 @@ Bool_t AliTRDdigitizer::ConvertSDigits() (!calibration->IsChamberMasked(iDet)) && ( fGeo->GetSMstatus(sector))) { - // Get the calibration objects - calGainFactorROC = calibration->GetGainFactorROC(iDet); - calGainFactorDetValue = calGainFactorDet->GetValue(iDet); - for (iRow = 0; iRow < nRowMax; iRow++ ) { for (iCol = 0; iCol < nColMax; iCol++ ) { // Check whether pad is masked // Bridged pads are not considered yet!!! - if (calibration->IsPadMasked(iDet,iCol,iRow)) { - continue; - } - - Float_t padgain = calGainFactorDetValue - * calGainFactorROC->GetValue(iCol,iRow); - if (padgain <= 0) { - AliError(Form("Not a valid gain %f, %d %d %d",padgain,iDet,iCol,iRow)); - } + if (calibration->IsPadMasked(iDet,iCol,iRow)) continue; - for (iTime = 0; iTime < nTimeTotal; iTime++) { + for (iTime = 0; iTime < nTimeTotal; iTime++) { // Scale s-digits to normal digits Double_t signal = (Double_t) digitsIn->GetDataUnchecked(iRow,iCol,iTime); signal *= sDigitsScale; + // Apply the pad-by-pad gain factors + Float_t padgain = calibration->GetGainFactor(iDet,iCol,iRow); + if (padgain <= 0.0) { + AliError(Form("Not a valid gain %f, %d %d %d",padgain,iDet,iCol,iRow)); + } + signal *= padgain; // Pad and time coupling signal *= coupling; - // Gain factors - signal *= padgain; // Add the noise, starting from minus ADC baseline in electrons Double_t baselineEl = adcBaseline * (adcInRange / adcOutRange) / convert; signal = TMath::Max((Double_t) gRandom->Gaus(signal,noise),-baselineEl); @@ -1549,19 +1483,19 @@ Bool_t AliTRDdigitizer::MergeSDigits() AliTRDSimParam *simParam = AliTRDSimParam::Instance(); if (!simParam) { - AliFatal("Could not get simulation parameters"); + AliError("Could not get simulation parameters"); return kFALSE; } AliTRDCommonParam *commonParam = AliTRDCommonParam::Instance(); if (!commonParam) { - AliFatal("Could not get common parameters"); + AliError("Could not get common parameters"); return kFALSE; } AliTRDcalibDB *calibration = AliTRDcalibDB::Instance(); if (!calibration) { - AliFatal("Could not get calibration object"); + AliError("Could not get calibration object"); return kFALSE; } @@ -1727,7 +1661,7 @@ void AliTRDdigitizer::InitOutput(Int_t iEvent) return; } - AliLoader *loader = fRunLoader->GetLoader("TRDLoader"); + AliLoader* loader = fRunLoader->GetLoader("TRDLoader"); if (!loader) { AliError("Can not get TRD loader from Run Loader"); return; @@ -1857,10 +1791,13 @@ void AliTRDdigitizer::SampleTimeStruct(Float_t vdrift) // Drift Time data calculated with Garfield (by C.Lippmann) // - // Nothing to do + // TODO make caching proper, if same timing structure is selected: do not update timestructs! + + // Noting to do if (vdrift == fTimeLastVdrift) { return; } + fTimeLastVdrift = vdrift; // Drift time maps are saved for some drift velocity values (in drift region): @@ -2593,19 +2530,19 @@ void AliTRDdigitizer::RecalcDiffusion(Float_t vdrift) AliTRDSimParam *simParam = AliTRDSimParam::Instance(); if (!simParam) { - AliFatal("Could not get simulation parameters"); + AliError("Could not get simulation parameters"); return; } AliTRDCommonParam *commonParam = AliTRDCommonParam::Instance(); if (!commonParam) { - AliFatal("Could not get common parameters"); + AliError("Could not get common parameters"); return; } AliTRDcalibDB *calibration = AliTRDcalibDB::Instance(); if (!calibration) { - AliFatal("Could not get calibration object"); + AliError("Could not get calibration object"); return; } @@ -2693,22 +2630,20 @@ Float_t AliTRDdigitizer::GetDiffusionT(Float_t vdrift) } //_____________________________________________________________________________ -Int_t AliTRDdigitizer::Diffusion(Float_t vdrift, Double_t absdriftlength - , Double_t &lRow, Double_t &lCol, Double_t &lTime) +Int_t AliTRDdigitizer::Diffusion(Float_t vdrift, Double_t driftlength, Double_t *xyz) { // - // Applies the diffusion smearing to the position of a single electron. - // Depends on absolute drift length. + // Applies the diffusion smearing to the position of a single electron // RecalcDiffusion(vdrift); - Float_t driftSqrt = TMath::Sqrt(absdriftlength); + Float_t driftSqrt = TMath::Sqrt(driftlength); Float_t sigmaT = driftSqrt * fDiffusionT; Float_t sigmaL = driftSqrt * fDiffusionL; - lRow = gRandom->Gaus(lRow ,sigmaT); - lCol = gRandom->Gaus(lCol ,sigmaT * GetLorentzFactor(vdrift)); - lTime = gRandom->Gaus(lTime,sigmaL * GetLorentzFactor(vdrift)); + xyz[0] = gRandom->Gaus(xyz[0],sigmaL * GetLorentzFactor(vdrift)); + xyz[1] = gRandom->Gaus(xyz[1],sigmaT * GetLorentzFactor(vdrift)); + xyz[2] = gRandom->Gaus(xyz[2],sigmaT); return 1; @@ -2728,16 +2663,17 @@ Float_t AliTRDdigitizer::GetLorentzFactor(Float_t vd) } //_____________________________________________________________________________ -Int_t AliTRDdigitizer::ExB(Float_t vdrift, Double_t driftlength, Double_t &lCol) +Int_t AliTRDdigitizer::ExB(Float_t vdrift, Double_t driftlength, Double_t *xyz) { // - // Applies E x B effects to the position of a single electron. - // Depends on signed drift length. + // Applies E x B effects to the position of a single electron // RecalcDiffusion(vdrift); - - lCol = lCol + fOmegaTau * driftlength; + + xyz[0] = xyz[0]; + xyz[1] = xyz[1] + fOmegaTau * driftlength; + xyz[2] = xyz[2]; return 1; diff --git a/TRD/AliTRDdigitizer.h b/TRD/AliTRDdigitizer.h index c27a391aa49..a5f40cdd705 100644 --- a/TRD/AliTRDdigitizer.h +++ b/TRD/AliTRDdigitizer.h @@ -67,9 +67,8 @@ class AliTRDdigitizer : public AliDigitizer { Float_t GetLorentzFactor(Float_t vdrift); virtual Double_t TimeStruct(Float_t vdrift, Double_t time, Double_t z); - virtual Int_t Diffusion(Float_t vdrift, Double_t absdriftlength - , Double_t &lRow, Double_t &lCol, Double_t &lTime); - virtual Int_t ExB(Float_t vdrift, Double_t driftlength, Double_t &lRow); + virtual Int_t Diffusion(Float_t vdrift, Double_t driftlength, Double_t *xyz); + virtual Int_t ExB(Float_t vdrift, Double_t driftlength, Double_t *xyz); AliTRDdigitsManager *Digits() const { return fDigitsManager; } diff --git a/TRD/AliTRDgeometry.cxx b/TRD/AliTRDgeometry.cxx index d370bde29c4..bd862eaf61b 100644 --- a/TRD/AliTRDgeometry.cxx +++ b/TRD/AliTRDgeometry.cxx @@ -76,7 +76,7 @@ ClassImp(AliTRDgeometry) const Float_t AliTRDgeometry::fgkCH = AliTRDgeometry::fgkCraH + AliTRDgeometry::fgkCdrH + AliTRDgeometry::fgkCamH - + AliTRDgeometry::fgkCroH; + + AliTRDgeometry::fgkCroH; // Vertical spacing of the chambers const Float_t AliTRDgeometry::fgkVspace = 1.784; @@ -112,13 +112,13 @@ ClassImp(AliTRDgeometry) // Thickness of the the material layers // const Float_t AliTRDgeometry::fgkMyThick = 0.005; - const Float_t AliTRDgeometry::fgkRaThick = 0.3233; + const Float_t AliTRDgeometry::fgkRaThick = 0.3233; const Float_t AliTRDgeometry::fgkDrThick = AliTRDgeometry::fgkCdrH; const Float_t AliTRDgeometry::fgkAmThick = AliTRDgeometry::fgkCamH; const Float_t AliTRDgeometry::fgkXeThick = AliTRDgeometry::fgkDrThick + AliTRDgeometry::fgkAmThick; const Float_t AliTRDgeometry::fgkWrThick = 0.0002; - const Float_t AliTRDgeometry::fgkCuThick = 0.0072; + const Float_t AliTRDgeometry::fgkCuThick = 0.0072; const Float_t AliTRDgeometry::fgkGlThick = 0.05; const Float_t AliTRDgeometry::fgkSuThick = 0.0919; const Float_t AliTRDgeometry::fgkRcThick = 0.0058; @@ -139,20 +139,18 @@ ClassImp(AliTRDgeometry) const Float_t AliTRDgeometry::fgkRpZpos = 1.0; const Float_t AliTRDgeometry::fgkRoZpos = 1.05; - const Int_t AliTRDgeometry::fgkMCMmax = 16; - const Int_t AliTRDgeometry::fgkMCMrow = 4; - const Int_t AliTRDgeometry::fgkROBmaxC0 = 6; - const Int_t AliTRDgeometry::fgkROBmaxC1 = 8; + const Int_t AliTRDgeometry::fgkMCMmax = 16; + const Int_t AliTRDgeometry::fgkMCMrow = 4; + const Int_t AliTRDgeometry::fgkROBmaxC0 = 6; + const Int_t AliTRDgeometry::fgkROBmaxC1 = 8; const Int_t AliTRDgeometry::fgkADCmax = 21; const Int_t AliTRDgeometry::fgkTBmax = 60; - const Int_t AliTRDgeometry::fgkPadmax = 18; + const Int_t AliTRDgeometry::fgkPadmax = 18; const Int_t AliTRDgeometry::fgkColmax = 144; const Int_t AliTRDgeometry::fgkRowmaxC0 = 12; const Int_t AliTRDgeometry::fgkRowmaxC1 = 16; const Double_t AliTRDgeometry::fgkTime0Base = 300.65; - // New value - //const Double_t AliTRDgeometry::fgkTime0Base = 299.95; const Float_t AliTRDgeometry::fgkTime0[6] = { fgkTime0Base + 0 * (Cheight() + Cspace()) , fgkTime0Base + 1 * (Cheight() + Cspace()) , fgkTime0Base + 2 * (Cheight() + Cspace()) @@ -263,6 +261,11 @@ void AliTRDgeometry::Init() Float_t phi = 0.0; for (isect = 0; isect < fgkNsect; isect++) { phi = 2.0 * TMath::Pi() / (Float_t) fgkNsect * ((Float_t) isect + 0.5); + fRotA11[isect] = TMath::Cos(phi); + fRotA12[isect] = TMath::Sin(phi); + fRotA21[isect] = TMath::Sin(phi); + fRotA22[isect] = TMath::Cos(phi); + phi = -1.0 * phi; fRotB11[isect] = TMath::Cos(phi); fRotB12[isect] = TMath::Sin(phi); fRotB21[isect] = TMath::Sin(phi); @@ -584,11 +587,11 @@ void AliTRDgeometry::CreateGeometry(Int_t *idtmed) // Position the frames of the chambers in the TRD mother volume xpos = 0.0; - ypos = fClength[iplan][0] + fClength[iplan][1] + fClength[iplan][2]/2.0; + ypos = - fClength[iplan][0] - fClength[iplan][1] - fClength[iplan][2]/2.0; for (Int_t ic = 0; ic < icham; ic++) { - ypos -= fClength[iplan][ic]; + ypos += fClength[iplan][ic]; } - ypos -= fClength[iplan][icham]/2.0; + ypos += fClength[iplan][icham]/2.0; zpos = fgkVrocsm + fgkSMpltT + fgkCraH/2.0 + fgkCdrH/2.0 - fgkSheight/2.0 + iplan * (fgkCH + fgkVspace); // The lower aluminum frame, radiator + drift region @@ -1040,11 +1043,11 @@ void AliTRDgeometry::CreateServices(Int_t *idtmed) gMC->Gsvolu(cTagV,"BOX",idtmed[1302-1],parServ,kNparServ); xpos = 0.0; - ypos = fClength[iplan][0] + fClength[iplan][1] + fClength[iplan][2]/2.0; + ypos = - fClength[iplan][0] - fClength[iplan][1] - fClength[iplan][2]/2.0; for (Int_t ic = 0; ic < icham; ic++) { - ypos -= fClength[iplan][ic]; + ypos += fClength[iplan][ic]; } - ypos -= fClength[iplan][icham]/2.0; + ypos += fClength[iplan][icham]/2.0; zpos = fgkVrocsm + fgkSMpltT + fgkCH + fgkVspace/2.0 - fgkSheight/2.0 + iplan * (fgkCH + fgkVspace); zpos -= 0.742/2.0; @@ -1319,18 +1322,38 @@ void AliTRDgeometry::GroupChamber(Int_t iplan, Int_t icham, Int_t *idtmed) } //_____________________________________________________________________________ -Bool_t AliTRDgeometry::RotateBack(Int_t det, Double_t *loc, Double_t *glb) const +Bool_t AliTRDgeometry::Rotate(Int_t d, Double_t *pos, Double_t *rot) const { // - // Rotates a chambers to transform the corresponding local frame - // coordinates into the coordinates of the ALICE restframe . + // Rotates all chambers in the position of sector 0 and transforms + // the coordinates in the ALICE restframe into the + // corresponding local frame . // - Int_t sector = GetSector(det); + Int_t sector = GetSector(d); - glb[0] = loc[0] * fRotB11[sector] - loc[1] * fRotB12[sector]; - glb[1] = loc[0] * fRotB21[sector] + loc[1] * fRotB22[sector]; - glb[2] = loc[2]; + rot[0] = pos[0] * fRotA11[sector] + pos[1] * fRotA12[sector]; + rot[1] = -pos[0] * fRotA21[sector] + pos[1] * fRotA22[sector]; + rot[2] = pos[2]; + + return kTRUE; + +} + +//_____________________________________________________________________________ +Bool_t AliTRDgeometry::RotateBack(Int_t d, Double_t *rot, Double_t *pos) const +{ + // + // Rotates a chambers from the position of sector 0 into its + // original position and transforms the corresponding local frame + // coordinates into the coordinates of the ALICE restframe . + // + + Int_t sector = GetSector(d); + + pos[0] = rot[0] * fRotB11[sector] + rot[1] * fRotB12[sector]; + pos[1] = -rot[0] * fRotB21[sector] + rot[1] * fRotB22[sector]; + pos[2] = rot[2]; return kTRUE; @@ -1391,6 +1414,7 @@ Int_t AliTRDgeometry::GetSector(Int_t d) const } +//CL //_____________________________________________________________________________ Int_t AliTRDgeometry::GetPadRowFromMCM(Int_t irob, Int_t imcm) const { @@ -1399,30 +1423,20 @@ Int_t AliTRDgeometry::GetPadRowFromMCM(Int_t irob, Int_t imcm) const return fgkMCMrow*(irob/2) + imcm/fgkMCMrow; +; } //_____________________________________________________________________________ Int_t AliTRDgeometry::GetPadColFromADC(Int_t irob, Int_t imcm, Int_t iadc) const { // - // return which pad is connected to this adc channel. - // - // ADC channels 2 to 19 are connected directly to a pad via PASA. - // ADC channels 0, 1 and 20 are not connected to the PASA on this MCM. - // So the mapping (for MCM 0 on ROB 0 at least) is - // - // ADC channel : 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 - // Pad : x x 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 x - // Func. returns: 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 -1 - // - // Here we assume that 21 ADC channels are transmitted. Maybe it will only be - // 18 later on!!! - // - // This function maps also correctly the channels that cross from MCM to MCM - // (ADC channels 0, 1, 20). + // return which pad is connected to this adc channel. return -1 if it + // is one of the not directly connected adc channels (0, 1 20) // - return (17-(iadc-2)) + (imcm%fgkMCMrow)*fgkPadmax + GetRobSide(irob)*fgkColmax/2; + if (iadc < 2 || iadc > 19 ) return -1; + + return (iadc-2) + (imcm%fgkMCMrow)*fgkPadmax + GetRobSide(irob)*fgkColmax/2; } @@ -1495,10 +1509,8 @@ AliTRDgeometry *AliTRDgeometry::GetGeometry(AliRunLoader *runLoader) if (!geom) { // If it is not in the file, try to get it from the run loader - if (runLoader->GetAliRun()) { - AliTRD *trd = (AliTRD *) runLoader->GetAliRun()->GetDetector("TRD"); - if (trd) geom = trd->GetGeometry(); - } + AliTRD *trd = (AliTRD *) runLoader->GetAliRun()->GetDetector("TRD"); + geom = trd->GetGeometry(); } if (!geom) { AliErrorGeneral("AliTRDgeometry::GetGeometry","Geometry not found"); @@ -1521,7 +1533,7 @@ Bool_t AliTRDgeometry::ReadGeoMatrices() return kFALSE; } - fMatrixArray = new TObjArray(kNdet); + fMatrixArray = new TObjArray(kNdet); fMatrixCorrectionArray = new TObjArray(kNdet); fMatrixGeo = new TObjArray(kNdet); AliAlignObjAngles o; @@ -1543,20 +1555,20 @@ Bool_t AliTRDgeometry::ReadGeoMatrices() Int_t iLayerTRD = iLayer - AliAlignObj::kTRD1; Int_t isector = Nsect() - 1 - (iModule/Ncham()); Int_t ichamber = Ncham() - 1 - (iModule%Ncham()); - Int_t lid = GetDetector(iLayerTRD,ichamber,isector); + Int_t lid = GetDetector(iLayerTRD,ichamber,isector); // - // Local geo system z-x-y to x-y--z + // Local geo system z-x-y to x-y--z // fMatrixGeo->AddAt(new TGeoHMatrix(*m),lid); - - TGeoRotation mchange; - mchange.RotateY(90); + + TGeoRotation mchange; + mchange.RotateY(90); mchange.RotateX(90); TGeoHMatrix gMatrix(mchange.Inverse()); gMatrix.MultiplyLeft(m); - fMatrixArray->AddAt(new TGeoHMatrix(gMatrix),lid); + fMatrixArray->AddAt(new TGeoHMatrix(gMatrix),lid); // // Cluster transformation matrix @@ -1566,13 +1578,14 @@ Bool_t AliTRDgeometry::ReadGeoMatrices() Double_t sectorAngle = 20.0 * (isector % 18) + 10.0; TGeoHMatrix rotSector; rotSector.RotateZ(sectorAngle); - rotMatrix.MultiplyLeft(&rotSector); + rotMatrix.MultiplyLeft(&rotSector); - fMatrixCorrectionArray->AddAt(new TGeoHMatrix(rotMatrix),lid); + fMatrixCorrectionArray->AddAt(new TGeoHMatrix(rotMatrix),lid); - } + } } return kTRUE; } + diff --git a/TRD/AliTRDgeometry.h b/TRD/AliTRDgeometry.h index 5a300c39617..95a543d1f55 100644 --- a/TRD/AliTRDgeometry.h +++ b/TRD/AliTRDgeometry.h @@ -36,10 +36,11 @@ class AliTRDgeometry : public AliGeometry { virtual void Init(); virtual void CreateGeometry(Int_t *idtmed); virtual Int_t IsVersion() { return 1; } - virtual Bool_t Impact(const TParticle *) const { return kTRUE; } + virtual Bool_t Impact(const TParticle* ) const { return kTRUE; } virtual Bool_t IsHole(Int_t /*p*/, Int_t /*c*/, Int_t /*s*/) const { return kFALSE; } - virtual Bool_t RotateBack(Int_t det, Double_t *loc, Double_t *glb) const; + virtual Bool_t Rotate(Int_t d, Double_t *pos, Double_t *rot) const; + virtual Bool_t RotateBack(Int_t d, Double_t *rot, Double_t *pos) const; void GroupChamber(Int_t iplan, Int_t icham, Int_t *idtmed); void CreateFrame(Int_t *idtmed); @@ -71,8 +72,8 @@ class AliTRDgeometry : public AliGeometry { Float_t GetChamberWidth(Int_t p) const { return fCwidth[p]; } Float_t GetChamberLength(Int_t p, Int_t c) const { return fClength[p][c]; } - virtual void GetGlobal(const AliRecPoint*, TVector3&, TMatrixF&) const { }; - virtual void GetGlobal(const AliRecPoint*, TVector3&) const { }; + virtual void GetGlobal(const AliRecPoint*, TVector3&, TMatrixF& ) const { }; + virtual void GetGlobal(const AliRecPoint*, TVector3& ) const { }; static Double_t GetAlpha() { return 2.0 * 3.14159265358979324 @@ -195,6 +196,11 @@ class AliTRDgeometry : public AliGeometry { Float_t fCwidth[kNplan]; // Outer widths of the chambers Float_t fClength[kNplan][kNcham]; // Outer lengths of the chambers + Float_t fRotA11[kNsect]; // Matrix elements for the rotation + Float_t fRotA12[kNsect]; // Matrix elements for the rotation + Float_t fRotA21[kNsect]; // Matrix elements for the rotation + Float_t fRotA22[kNsect]; // Matrix elements for the rotation + Float_t fRotB11[kNsect]; // Matrix elements for the backward rotation Float_t fRotB12[kNsect]; // Matrix elements for the backward rotation Float_t fRotB21[kNsect]; // Matrix elements for the backward rotation @@ -213,11 +219,11 @@ class AliTRDgeometry : public AliGeometry { Float_t fChamberUFboxd[3*kNdets][3]; // [3] = x, y, z Float_t fChamberUUboxd[3*kNdets][3]; // - TObjArray *fMatrixArray; //! Transformation global to local - TObjArray *fMatrixCorrectionArray; //! Transformation cluster to tracking system + TObjArray *fMatrixArray; //! Transformation Global to Local + TObjArray *fMatrixCorrectionArray; //! Transformation Cluster to Tracking systerm TObjArray *fMatrixGeo; //! Geo matrices - ClassDef(AliTRDgeometry,13) // TRD geometry class + ClassDef(AliTRDgeometry,12) // TRD geometry class }; diff --git a/TRD/AliTRDpadPlane.cxx b/TRD/AliTRDpadPlane.cxx index 23e40f01ecf..89cf7140b1a 100644 --- a/TRD/AliTRDpadPlane.cxx +++ b/TRD/AliTRDpadPlane.cxx @@ -57,7 +57,6 @@ AliTRDpadPlane::AliTRDpadPlane() ,fTiltingTan(0) ,fPadRow(0) ,fPadCol(0) - ,fPadRowSMOffset(0) { // // Default constructor @@ -87,7 +86,6 @@ AliTRDpadPlane::AliTRDpadPlane(Int_t p, Int_t c) ,fTiltingTan(0) ,fPadRow(0) ,fPadCol(0) - ,fPadRowSMOffset(0) { // // Constructor that initializes a given pad plane type @@ -267,9 +265,14 @@ AliTRDpadPlane::AliTRDpadPlane(Int_t p, Int_t c) // Row direction // fPadRow = new Double_t[fNrows]; - Double_t row = fGeo->GetChamberLength(p,c) / 2.0 + Double_t row = fGeo->GetChamberLength(p,0) + + fGeo->GetChamberLength(p,1) + + fGeo->GetChamberLength(p,2) / 2.0 - fGeo->RpadW() - fLengthRim; + for (Int_t ic = 0; ic < c; ic++) { + row -= fGeo->GetChamberLength(p,ic); + } for (Int_t ir = 0; ir < fNrows; ir++) { fPadRow[ir] = row; row -= fRowSpacing; @@ -297,15 +300,6 @@ AliTRDpadPlane::AliTRDpadPlane(Int_t p, Int_t c) col -= fWidthIPad; } } - // Calculate the offset to translate from the local ROC system into - // the local supermodule system, which is used for clusters - Double_t rowTmp = fGeo->GetChamberLength(p,0) - + fGeo->GetChamberLength(p,1) - + fGeo->GetChamberLength(p,2) / 2.0; - for (Int_t ic = 0; ic < c; ic++) { - rowTmp -= fGeo->GetChamberLength(p,ic); - } - fPadRowSMOffset = rowTmp - fGeo->GetChamberLength(p,c)/2.0; } @@ -331,7 +325,6 @@ AliTRDpadPlane::AliTRDpadPlane(const AliTRDpadPlane &p) ,fTiltingTan(p.fTiltingTan) ,fPadRow(0) ,fPadCol(0) - ,fPadRowSMOffset(p.fPadRowSMOffset) { // // AliTRDpadPlane copy constructor @@ -405,30 +398,28 @@ void AliTRDpadPlane::Copy(TObject &p) const Int_t iBin = 0; - ((AliTRDpadPlane &) p).fGeo = 0; - - ((AliTRDpadPlane &) p).fPla = fPla; - ((AliTRDpadPlane &) p).fCha = fCha; + ((AliTRDpadPlane &) p).fGeo = 0; - ((AliTRDpadPlane &) p).fLength = fLength; - ((AliTRDpadPlane &) p).fWidth = fWidth; - ((AliTRDpadPlane &) p).fLengthRim = fLengthRim; - ((AliTRDpadPlane &) p).fWidthRim = fWidthRim; - ((AliTRDpadPlane &) p).fLengthOPad = fLengthOPad; - ((AliTRDpadPlane &) p).fWidthOPad = fWidthOPad; - ((AliTRDpadPlane &) p).fLengthIPad = fLengthIPad; - ((AliTRDpadPlane &) p).fWidthIPad = fWidthIPad; + ((AliTRDpadPlane &) p).fPla = fPla; + ((AliTRDpadPlane &) p).fCha = fCha; - ((AliTRDpadPlane &) p).fRowSpacing = fRowSpacing; - ((AliTRDpadPlane &) p).fColSpacing = fColSpacing; + ((AliTRDpadPlane &) p).fLength = fLength; + ((AliTRDpadPlane &) p).fWidth = fWidth; + ((AliTRDpadPlane &) p).fLengthRim = fLengthRim; + ((AliTRDpadPlane &) p).fWidthRim = fWidthRim; + ((AliTRDpadPlane &) p).fLengthOPad = fLengthOPad; + ((AliTRDpadPlane &) p).fWidthOPad = fWidthOPad; + ((AliTRDpadPlane &) p).fLengthIPad = fLengthIPad; + ((AliTRDpadPlane &) p).fWidthIPad = fWidthIPad; - ((AliTRDpadPlane &) p).fNrows = fNrows; - ((AliTRDpadPlane &) p).fNcols = fNcols; + ((AliTRDpadPlane &) p).fRowSpacing = fRowSpacing; + ((AliTRDpadPlane &) p).fColSpacing = fColSpacing; - ((AliTRDpadPlane &) p).fTiltingAngle = fTiltingAngle; - ((AliTRDpadPlane &) p).fTiltingTan = fTiltingTan; + ((AliTRDpadPlane &) p).fNrows = fNrows; + ((AliTRDpadPlane &) p).fNcols = fNcols; - ((AliTRDpadPlane &) p).fPadRowSMOffset = fPadRowSMOffset; + ((AliTRDpadPlane &) p).fTiltingAngle = fTiltingAngle; + ((AliTRDpadPlane &) p).fTiltingTan = fTiltingTan; if (((AliTRDpadPlane &) p).fPadRow) { delete [] ((AliTRDpadPlane &) p).fPadRow; @@ -454,7 +445,7 @@ void AliTRDpadPlane::Copy(TObject &p) const Int_t AliTRDpadPlane::GetPadRowNumber(Double_t z) const { // - // Finds the pad row number for a given z-position in local supermodule system + // Finds the pad row number for a given global z-position // Int_t row = 0; @@ -467,48 +458,6 @@ Int_t AliTRDpadPlane::GetPadRowNumber(Double_t z) const row = -1; - } - else { - - nabove = fNrows + 1; - nbelow = 0; - while (nabove - nbelow > 1) { - middle = (nabove + nbelow) / 2; - if (z == (fPadRow[middle-1] + fPadRowSMOffset)) { - row = middle; - } - if (z > (fPadRow[middle-1] + fPadRowSMOffset)) { - nabove = middle; - } - else { - nbelow = middle; - } - } - row = nbelow - 1; - - } - - return row; - -} - -//_____________________________________________________________________________ -Int_t AliTRDpadPlane::GetPadRowNumberROC(Double_t z) const -{ - // - // Finds the pad row number for a given z-position in local ROC system - // - - Int_t row = 0; - Int_t nabove = 0; - Int_t nbelow = 0; - Int_t middle = 0; - - if ((z > GetRow0ROC() ) || - (z < GetRowEndROC())) { - - row = -1; - } else { @@ -535,16 +484,17 @@ Int_t AliTRDpadPlane::GetPadRowNumberROC(Double_t z) const } //_____________________________________________________________________________ -Int_t AliTRDpadPlane::GetPadColNumber(Double_t rphi) const +Int_t AliTRDpadPlane::GetPadColNumber(Double_t rphi + , Double_t /*rowOffset*/) const { // // Finds the pad column number for a given global rphi-position // - Int_t col = 0; - Int_t nabove = 0; - Int_t nbelow = 0; - Int_t middle = 0; + Int_t col = 0; + Int_t nabove = 0; + Int_t nbelow = 0; + Int_t middle = 0; if ((rphi > GetCol0() ) || (rphi < GetColEnd())) { diff --git a/TRD/AliTRDpadPlane.h b/TRD/AliTRDpadPlane.h index 000166b3482..d9bcaf827cd 100644 --- a/TRD/AliTRDpadPlane.h +++ b/TRD/AliTRDpadPlane.h @@ -33,18 +33,10 @@ class AliTRDpadPlane : public TObject { virtual void Copy(TObject &p) const; Int_t GetPadRowNumber(Double_t z) const; - Int_t GetPadRowNumberROC(Double_t z) const; - Int_t GetPadColNumber(Double_t rphi) const; - + Int_t GetPadColNumber(Double_t rphi, Double_t rowOffset) const; Double_t GetTiltOffset(Double_t rowOffset) const { return fTiltingTan * (rowOffset - 0.5*fLengthIPad); }; - Double_t GetPadRowOffset(Int_t row, Double_t z) const - { if ((row < 0) || (row >= fNrows)) - return -1.0; - else - return fPadRow[row] + fPadRowSMOffset - z; }; - Double_t GetPadRowOffsetROC(Int_t row, Double_t z) const { if ((row < 0) || (row >= fNrows)) return -1.0; else @@ -61,16 +53,13 @@ class AliTRDpadPlane : public TObject { Int_t GetNrows() const { return fNrows; }; Int_t GetNcols() const { return fNcols; }; - Double_t GetRow0() const { return fPadRow[0] + fPadRowSMOffset; }; - Double_t GetRow0ROC() const { return fPadRow[0]; }; + Double_t GetRow0() const { return fPadRow[0]; }; Double_t GetCol0() const { return fPadCol[0]; }; - Double_t GetRowEnd() const { return fPadRow[fNrows-1] - fLengthOPad + fPadRowSMOffset; }; - Double_t GetRowEndROC() const { return fPadRow[fNrows-1] - fLengthOPad; }; + Double_t GetRowEnd() const { return fPadRow[fNrows-1] - fLengthOPad; }; Double_t GetColEnd() const { return fPadCol[fNcols-1] - fWidthOPad; }; - Double_t GetRowPos(Int_t row) const { return fPadRow[row] + fPadRowSMOffset; }; - Double_t GetRowPosROC(Int_t row) const { return fPadRow[row]; }; + Double_t GetRowPos(Int_t row) const { return fPadRow[row]; }; Double_t GetColPos(Int_t col) const { return fPadCol[col]; }; Double_t GetRowSize(Int_t row) const { if ((row == 0) || (row == fNrows-1)) @@ -114,9 +103,7 @@ class AliTRDpadPlane : public TObject { Double_t *fPadRow; //! Pad border positions in row direction Double_t *fPadCol; //! Pad border positions in column direction - Double_t fPadRowSMOffset; // To be added to translate local ROC system to local SM system - - ClassDef(AliTRDpadPlane,3) // TRD ROC pad plane + ClassDef(AliTRDpadPlane,2) // TRD ROC pad plane }; diff --git a/TRD/AliTRDpidESD.cxx b/TRD/AliTRDpidESD.cxx index c16ef1964b2..f5a9f55a2a1 100644 --- a/TRD/AliTRDpidESD.cxx +++ b/TRD/AliTRDpidESD.cxx @@ -82,9 +82,9 @@ void AliTRDpidESD::Copy(TObject &p) const // Copy function // - ((AliTRDpidESD &) p).fCheckTrackStatus = fCheckTrackStatus; - ((AliTRDpidESD &) p).fCheckKinkStatus = fCheckKinkStatus; - ((AliTRDpidESD &) p).fMinPlane = fMinPlane; + ((AliTRDpidESD &) p).fCheckTrackStatus = fCheckTrackStatus; + ((AliTRDpidESD &) p).fCheckKinkStatus = fCheckKinkStatus; + ((AliTRDpidESD &) p).fMinPlane = fMinPlane; } diff --git a/TRD/AliTRDtrigger.cxx b/TRD/AliTRDtrigger.cxx index 5f5bbec4fd3..e0f4ddbd918 100644 --- a/TRD/AliTRDtrigger.cxx +++ b/TRD/AliTRDtrigger.cxx @@ -283,6 +283,17 @@ Bool_t AliTRDtrigger::ReadDigits(AliRawReader* rawReader) } +//_____________________________________________________________________________ +Bool_t AliTRDtrigger::ReadDigits(TTree *digitsTree) +{ + // + // Reads the digits arrays from the input tree + // + + return (fDigitsManager->ReadDigits(digitsTree)); + +} + //_____________________________________________________________________________ Bool_t AliTRDtrigger::ReadTracklets(AliRunLoader *rl) { diff --git a/TRD/AliTRDtrigger.h b/TRD/AliTRDtrigger.h index 1224e546608..8682f0258c0 100644 --- a/TRD/AliTRDtrigger.h +++ b/TRD/AliTRDtrigger.h @@ -49,7 +49,8 @@ class AliTRDtrigger : public TNamed { Bool_t Open(const Char_t *name, Int_t nEvent = 0); Bool_t ReadDigits(); - Bool_t ReadDigits(AliRawReader* rawReader); + Bool_t ReadDigits(AliRawReader *rawReader); + Bool_t ReadDigits(TTree *digitsTree); Bool_t MakeTracklets(Bool_t makeTracks = kFALSE); void MakeTracks(Int_t det); Bool_t WriteTracklets(Int_t det); diff --git a/TRD/AliTRDv1.cxx b/TRD/AliTRDv1.cxx index 0c238f9c51b..bc1b5653243 100644 --- a/TRD/AliTRDv1.cxx +++ b/TRD/AliTRDv1.cxx @@ -297,12 +297,11 @@ void AliTRDv1::CreateTRhit(Int_t det) // Add the hit to the array. TR photon hits are marked // by negative charge - // The hit time is needed for pile-up events AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber() ,det ,posHit ,-q - ,gMC->TrackTime()*1.0e06 + ,gMC->TrackTime()*1.0e06 ,kTRUE); } @@ -498,7 +497,7 @@ void AliTRDv1::StepManagerGeant() cIdChamber[0] = cIdCurrent[2]; cIdChamber[1] = cIdCurrent[3]; Int_t idChamber = (atoi(cIdChamber) % kNdetsec); - cha = ((Int_t) idChamber / kNplan); + cha = kNcham - ((Int_t) idChamber / kNplan) - 1; pla = ((Int_t) idChamber % kNplan); // The detector number @@ -595,12 +594,11 @@ void AliTRDv1::StepManagerGeant() qTot = ((Int_t) (eDelta / kWion) + 1); // Create a new dEdx hit - // The hit time is needed for pile-up events AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber() ,det ,hits ,qTot - ,gMC->TrackTime()*1.0e06 + ,gMC->TrackTime()*1.0e06 ,drRegion); } @@ -746,7 +744,7 @@ void AliTRDv1::StepManagerErmilova() cIdChamber[0] = cIdCurrent[2]; cIdChamber[1] = cIdCurrent[3]; Int_t idChamber = (atoi(cIdChamber) % kNdetsec); - cha = ((Int_t) idChamber / kNplan); + cha = kNcham - ((Int_t) idChamber / kNplan) - 1; pla = ((Int_t) idChamber % kNplan); // The detector number @@ -789,13 +787,12 @@ void AliTRDv1::StepManagerErmilova() qTot = ((Int_t) (eDelta / kWion) + 1); // Create a new dEdx hit - // The hit time is needed for pile-up events if (drRegion) { AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber() ,det ,hits ,qTot - ,gMC->TrackTime()*1.0e06 + ,gMC->TrackTime()*1.0e06 ,kTRUE); } else { @@ -803,7 +800,7 @@ void AliTRDv1::StepManagerErmilova() ,det ,hits ,qTot - ,gMC->TrackTime()*1.0e06 + ,gMC->TrackTime()*1.0e06 ,kFALSE); } @@ -939,13 +936,13 @@ void AliTRDv1::StepManagerFixedStep() cIdChamber[0] = cIdCurrent[2]; cIdChamber[1] = cIdCurrent[3]; Int_t idChamber = (atoi(cIdChamber) % kNdetsec); - cha = ((Int_t) idChamber / kNplan); + cha = kNcham - ((Int_t) idChamber / kNplan) - 1; pla = ((Int_t) idChamber % kNplan); // The detector number det = fGeometry->GetDetector(pla,cha,sec); - // 0:InFlight 1:Entering 2:Exiting + // 0: InFlight 1:Entering 2:Exiting Int_t trkStat = 0; // Special hits only in the drift region @@ -979,7 +976,6 @@ void AliTRDv1::StepManagerFixedStep() // Calculate the charge according to GEANT Edep // Create a new dEdx hit - // The hit time is needed for pile-up events eDep = TMath::Max(gMC->Edep(),0.0) * 1.0e+09; qTot = (Int_t) (eDep / kWion); if ((qTot) || @@ -988,7 +984,7 @@ void AliTRDv1::StepManagerFixedStep() ,det ,hits ,qTot - ,gMC->TrackTime()*1.0e06 + ,gMC->TrackTime()*1.0e06 ,drRegion); } -- 2.43.0