X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TPC%2FAliTPCclustererMI.cxx;h=ecfad37cd71f0df786b9d237dfbf9459afa8680f;hb=49519b04d13fb4961e50bf1c6e63b8614e54f635;hp=b4946f82383aa5a95719786357fe6bfdb50c4a60;hpb=e7034a8bcbc44f90201a9fe45557beee6c6f3267;p=u%2Fmrichter%2FAliRoot.git diff --git a/TPC/AliTPCclustererMI.cxx b/TPC/AliTPCclustererMI.cxx index b4946f82383..ecfad37cd71 100644 --- a/TPC/AliTPCclustererMI.cxx +++ b/TPC/AliTPCclustererMI.cxx @@ -21,6 +21,14 @@ // 1. The Input data for reconstruction - Options // 1.a Simulated data - TTree - invoked Digits2Clusters() // 1.b Raw data - Digits2Clusters(AliRawReader* rawReader); +// 1.c HLT clusters - Digits2Clusters and Digits2Clusters(AliRawReader* rawReader) +// invoke ReadHLTClusters() +// +// fUseHLTClusters - switches between different inputs +// 1 -> only TPC raw/sim data +// 2 -> if present TPC raw/sim data, otherwise HLT clusters +// 3 -> only HLT clusters +// 4 -> if present HLT clusters, otherwise TPC raw/sim data // // 2. The Output data // 2.a TTree with clusters - if SetOutput(TTree * tree) invoked @@ -48,6 +56,8 @@ #include #include #include +#include "TSystem.h" +#include "TClass.h" #include "AliDigits.h" #include "AliLoader.h" @@ -108,6 +118,7 @@ AliTPCclustererMI::AliTPCclustererMI(const AliTPCParam* par, const AliTPCRecoPar fRecoParam(0), fBDumpSignal(kFALSE), fBClonesArray(kFALSE), + fUseHLTClusters(1), fAllBins(NULL), fAllSigBins(NULL), fAllNSigBins(NULL) @@ -132,9 +143,7 @@ AliTPCclustererMI::AliTPCclustererMI(const AliTPCParam* par, const AliTPCRecoPar } // Int_t nPoints = fRecoParam->GetLastBin()-fRecoParam->GetFirstBin(); - fRowCl= new AliTPCClustersRow(); - fRowCl->SetClass("AliTPCclusterMI"); - fRowCl->SetArray(1); + fRowCl= new AliTPCClustersRow("AliTPCclusterMI"); // Non-persistent arrays // @@ -190,6 +199,7 @@ AliTPCclustererMI::AliTPCclustererMI(const AliTPCclustererMI ¶m) fRecoParam(0), fBDumpSignal(kFALSE), fBClonesArray(kFALSE), + fUseHLTClusters(1), fAllBins(NULL), fAllSigBins(NULL), fAllNSigBins(NULL) @@ -223,6 +233,11 @@ AliTPCclustererMI::~AliTPCclustererMI(){ delete fOutputClonesArray; } + if (fRowCl) { + fRowCl->GetArray()->Delete(); + delete fRowCl; + } + AliTPCROC * roc = AliTPCROC::Instance(); Int_t nRowsMax = roc->GetNRows(roc->GetNSector()-1); for (Int_t iRow = 0; iRow < nRowsMax; iRow++) { @@ -255,10 +270,8 @@ void AliTPCclustererMI::SetOutput(TTree * tree) // if (!tree) return; fOutput= tree; - AliTPCClustersRow clrow; + AliTPCClustersRow clrow("AliTPCclusterMI"); AliTPCClustersRow *pclrow=&clrow; - clrow.SetClass("AliTPCclusterMI"); - clrow.SetArray(1); // to make Clones array fOutput->Branch("Segment","AliTPCClustersRow",&pclrow,32000,200); } @@ -631,6 +644,7 @@ void AliTPCclustererMI::AddCluster(AliTPCclusterMI &c, Float_t * /*matrix*/, Int AliTPCTransform *transform = AliTPCcalibDB::Instance()->GetTransform() ; if (!transform) { AliFatal("Tranformations not in calibDB"); + return; } transform->SetCurrentRecoParam((AliTPCRecoParam*)fRecoParam); Double_t x[3]={c.GetRow(),c.GetPad(),c.GetTimeBin()}; @@ -708,6 +722,42 @@ void AliTPCclustererMI::Digits2Clusters() fRecoParam->Dump(); } + //----------------------------------------------------------------- + // Use HLT clusters + //----------------------------------------------------------------- + fUseHLTClusters = fRecoParam->GetUseHLTClusters(); + + AliInfo(Form("Usage of HLT clusters in TPC reconstruction : %d",fUseHLTClusters)); + + if (fUseHLTClusters == 3 || fUseHLTClusters == 4) { + AliInfo("Using HLT clusters for TPC off-line reconstruction"); + fZWidth = fParam->GetZWidth(); + Int_t iResult = ReadHLTClusters(); + + // HLT clusters present + if (iResult >= 0 && fNclusters > 0) + return; + + // HLT clusters not present + if (iResult < 0 || fNclusters == 0) { + if (fUseHLTClusters == 3) { + AliError("No HLT clusters present, but requested."); + return; + } + else { + AliInfo("Now trying to read TPC RAW"); + } + } + // Some other problem during cluster reading + else { + AliWarning("Some problem while unpacking of HLT clusters."); + return; + } + } // if (fUseHLTClusters == 3 || fUseHLTClusters == 4) { + + //----------------------------------------------------------------- + // Run TPC off-line clusterer + //----------------------------------------------------------------- AliTPCCalPad * gainTPC = AliTPCcalibDB::Instance()->GetPadGainFactor(); AliTPCCalPad * noiseTPC = AliTPCcalibDB::Instance()->GetPadNoise(); AliSimDigits digarr, *dummy=&digarr; @@ -739,7 +789,7 @@ void AliTPCclustererMI::Digits2Clusters() fZWidth = fParam->GetZWidth(); if (fSector < kNIS) { fMaxPad = fParam->GetNPadsLow(row); - fSign = (fSector < kNIS/2) ? 1 : -1; + fSign = (fSector < kNIS/2) ? 1 : -1; fPadLength = fParam->GetPadPitchLength(fSector,row); fPadWidth = fParam->GetPadPitchWidth(); } else { @@ -774,7 +824,7 @@ void AliTPCclustererMI::Digits2Clusters() FindClusters(noiseROC); FillRow(); - fRowCl->GetArray()->Clear(); + fRowCl->GetArray()->Clear("C"); nclusters+=fNcluster; delete[] fBins; @@ -782,6 +832,13 @@ void AliTPCclustererMI::Digits2Clusters() } Info("Digits2Clusters", "Number of found clusters : %d", nclusters); + + if (fUseHLTClusters == 2 && nclusters == 0) { + AliInfo("No clusters from TPC Raw data, now trying to read HLT clusters."); + + fZWidth = fParam->GetZWidth(); + ReadHLTClusters(); + } } void AliTPCclustererMI::ProcessSectorData(){ @@ -911,7 +968,7 @@ void AliTPCclustererMI::ProcessSectorData(){ FindClusters(noiseROC); FillRow(); - if(fBClonesArray == kFALSE) fRowCl->GetArray()->Clear(); + if(fBClonesArray == kFALSE) fRowCl->GetArray()->Clear("C"); fNclusters += fNcluster; } // End of loop to find clusters @@ -937,6 +994,42 @@ void AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader) } fRowDig = NULL; + //----------------------------------------------------------------- + // Use HLT clusters + //----------------------------------------------------------------- + fUseHLTClusters = fRecoParam->GetUseHLTClusters(); + + AliInfo(Form("Usage of HLT clusters in TPC reconstruction : %d",fUseHLTClusters)); + + if (fUseHLTClusters == 3 || fUseHLTClusters == 4) { + AliInfo("Using HLT clusters for TPC off-line reconstruction"); + fZWidth = fParam->GetZWidth(); + Int_t iResult = ReadHLTClusters(); + + // HLT clusters present + if (iResult >= 0 && fNclusters > 0) + return; + + // HLT clusters not present + if (iResult < 0 || fNclusters == 0) { + if (fUseHLTClusters == 3) { + AliError("No HLT clusters present, but requested."); + return; + } + else { + AliInfo("Now trying to read TPC RAW"); + } + } + // Some other problem during cluster reading + else { + AliWarning("Some problem while unpacking of HLT clusters."); + return; + } + } // if (fUseHLTClusters == 3 || fUseHLTClusters == 4) { + + //----------------------------------------------------------------- + // Run TPC off-line clusterer + //----------------------------------------------------------------- AliTPCCalPad * gainTPC = AliTPCcalibDB::Instance()->GetPadGainFactor(); AliTPCAltroMapping** mapping =AliTPCcalibDB::Instance()->GetMapping(); // @@ -1094,16 +1187,23 @@ void AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader) } if (rawReader->GetEventId() && fOutput ){ - Info("Digits2Clusters", "File %s Event\t%d\tNumber of found clusters : %d\n", fOutput->GetName(),*(rawReader->GetEventId()), fNclusters); + Info("Digits2Clusters", "File %s Event\t%u\tNumber of found clusters : %d\n", fOutput->GetName(),*(rawReader->GetEventId()), fNclusters); } if(rawReader->GetEventId()) { - Info("Digits2Clusters", "Event\t%d\tNumber of found clusters : %d\n",*(rawReader->GetEventId()), fNclusters); + Info("Digits2Clusters", "Event\t%u\tNumber of found clusters : %d\n",*(rawReader->GetEventId()), fNclusters); } if(fBClonesArray) { //Info("Digits2Clusters", "Number of found clusters : %d\n",fOutputClonesArray->GetEntriesFast()); } + + if (fUseHLTClusters == 2 && fNclusters == 0) { + AliInfo("No clusters from TPC Raw data, now trying to read HLT clusters."); + + fZWidth = fParam->GetZWidth(); + ReadHLTClusters(); + } } @@ -1189,7 +1289,7 @@ void AliTPCclustererMI::Digits2ClustersOld rawReader->Select("TPC",indexDDL,indexDDL+nDDLs-1); // select only good sector - input.Next(); + if (!input.Next()) continue; if(input.GetSector() != fSector) continue; AliTPCCalROC * gainROC = gainTPC->GetCalROC(fSector); // pad gains per given sector @@ -1313,6 +1413,7 @@ void AliTPCclustererMI::FindClusters(AliTPCCalROC * noiseROC) Float_t minMaxCutSigma = fRecoParam->GetMinMaxCutSigma(); Float_t minLeftRightCutSigma = fRecoParam->GetMinLeftRightCutSigma(); Float_t minUpDownCutSigma = fRecoParam->GetMinUpDownCutSigma(); + Int_t useOnePadCluster = fRecoParam->GetUseOnePadCluster(); for (Int_t iSig = 0; iSig < fNSigBins; iSig++) { Int_t i = fSigBins[iSig]; if (i%fMaxTime<=crtime) continue; @@ -1320,9 +1421,11 @@ void AliTPCclustererMI::FindClusters(AliTPCCalROC * noiseROC) //absolute custs if (b[0]Load("libAliHLTTPC.so")==0); + if (!pCl || (pNewFunc=pCl->GetNew())==NULL) { + AliError("can not load class description of AliHLTTPCClusterAccessHLTOUT, aborting ..."); + return -1; + } + + void* p=(*pNewFunc)(NULL); + if (!p) { + AliError("unable to create instance of AliHLTTPCClusterAccessHLTOUT"); + return -2; + } + pClusterAccess=reinterpret_cast(p); + if (!pClusterAccess) { + AliError("instance not of type TObject"); + return -3 ; + } + const Int_t kNIS = fParam->GetNInnerSector(); + const Int_t kNOS = fParam->GetNOuterSector(); + const Int_t kNS = kNIS + kNOS; + fNclusters = 0; + + for(fSector = 0; fSector < kNS; fSector++) { + Int_t iResult = 1; + TString param("sector="); param+=fSector; + pClusterAccess->Clear(); + pClusterAccess->Execute("read", param, &iResult); + if (iResult < 0) { + return iResult; + AliError("HLT Clusters can not be found"); + } + + if (pClusterAccess->FindObject("clusterarray")==NULL) { + AliError("HLT clusters requested, but not cluster array not present"); + return -4; + } + + TClonesArray* clusterArray=dynamic_cast(pClusterAccess->FindObject("clusterarray")); + if (!clusterArray) { + AliError("HLT cluster array is not of class type TClonesArray"); + return -5; + } + AliDebug(4,Form("Reading %d clusters from HLT for sector %d", clusterArray->GetEntriesFast(), fSector)); + + Int_t nClusterSector=0; + Int_t nRows=fParam->GetNRow(fSector); + + for (fRow = 0; fRow < nRows; fRow++) { + fRowCl->SetID(fParam->GetIndex(fSector, fRow)); + if (fOutput) fOutput->GetBranch("Segment")->SetAddress(&fRowCl); + fNcluster=0; // reset clusters per row + + fRx = fParam->GetPadRowRadii(fSector, fRow); + fPadLength = fParam->GetPadPitchLength(fSector, fRow); + fPadWidth = fParam->GetPadPitchWidth(); + fMaxPad = fParam->GetNPads(fSector,fRow); + fMaxBin = fMaxTime*(fMaxPad+6); // add 3 virtual pads before and 3 after + + fBins = fAllBins[fRow]; + fSigBins = fAllSigBins[fRow]; + fNSigBins = fAllNSigBins[fRow]; + + for (Int_t i=0; iGetEntriesFast(); i++) { + if (!clusterArray->At(i)) + continue; + + AliTPCclusterMI* cluster=dynamic_cast(clusterArray->At(i)); + if (!cluster) continue; + if (cluster->GetRow()!=fRow) continue; + nClusterSector++; + AddCluster(*cluster, NULL, 0); + } + + FillRow(); + fRowCl->GetArray()->Clear("c"); + + } // for (fRow = 0; fRow < nRows; fRow++) { + if (nClusterSector!=clusterArray->GetEntriesFast()) { + AliError(Form("Failed to read %d out of %d HLT clusters", + clusterArray->GetEntriesFast()-nClusterSector, + clusterArray->GetEntriesFast())); + } + fNclusters+=nClusterSector; + } // for(fSector = 0; fSector < kNS; fSector++) { + + delete pClusterAccess; + + Info("Digits2Clusters", "Number of converted HLT clusters : %d", fNclusters); + + return 0; +}