From 6c8e94cf90d957a418e57ad3e3a96b18e6ecf0b0 Mon Sep 17 00:00:00 2001 From: masera Date: Mon, 1 Aug 2011 15:37:54 +0000 Subject: [PATCH] Definition of labels for SDigits from Raw Data. They will be used for embedding purposes (Ruben) --- ITS/AliITS.cxx | 42 +++++++++++++++++++++++++------ ITS/AliITS.h | 7 ++++-- ITS/AliITSClusterFinder.cxx | 26 +++++++++++++++---- ITS/AliITSClusterFinder.h | 20 ++++++++++++--- ITS/AliITSClusterFinderV2SDD.cxx | 11 +++++++- ITS/AliITSClusterFinderV2SPD.cxx | 20 ++++++++++++--- ITS/AliITSClusterFinderV2SSD.cxx | 43 +++++++++++++++++++++++++++----- ITS/AliITSClusterFinderV2SSD.h | 2 ++ 8 files changed, 142 insertions(+), 29 deletions(-) diff --git a/ITS/AliITS.cxx b/ITS/AliITS.cxx index b109d66eb00..78407b11d71 100644 --- a/ITS/AliITS.cxx +++ b/ITS/AliITS.cxx @@ -72,6 +72,7 @@ the AliITS class. #include #include #include +#include #include "AliDetector.h" #include "AliITS.h" #include "AliITSDetTypeSim.h" @@ -125,6 +126,7 @@ fpSDigits(0) // SetDetectors(); // default to fOpt="All". This variable not written out. //PH SetMarkerColor(kRed); + for (int i=fgkNTYPES;i--;) fRawID2ClusID[i] = 0; } //______________________________________________________________________ AliITS::AliITS(const Char_t *title): @@ -165,6 +167,7 @@ AliITS::AliITS(const Char_t *title): //PH SetMarkerColor(kRed); if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName()); fDetTypeSim->SetLoader((AliITSLoader*)fLoader); + for (int i=fgkNTYPES;i--;) fRawID2ClusID[i] = 0; } //______________________________________________________________________ AliITS::AliITS(const char *name, const char *title): @@ -201,7 +204,7 @@ AliITS::AliITS(const char *name, const char *title): //PH SetMarkerColor(kRed); if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName()); fDetTypeSim->SetLoader((AliITSLoader*)fLoader); - + for (int i=fgkNTYPES;i--;) fRawID2ClusID[i] = 0; } //______________________________________________________________________ AliITS::~AliITS(){ @@ -1246,12 +1249,15 @@ Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader) } npx = segSPD->Npx(); Double_t thr, sigma; - + + Int_t countRW = -1; // RS counter for raw -> cluster ID's (used in embedding) + const TArrayI* rawID2clusID = fRawID2ClusID[kSPD]; AliITSRawStreamSPD inputSPD(rawReader); while(1){ Bool_t next = inputSPD.Next(); if (!next) break; + countRW++; // RS Int_t module = inputSPD.GetModuleID(); Int_t column = inputSPD.GetColumn(); Int_t row = inputSPD.GetRow(); @@ -1263,7 +1269,12 @@ Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader) TClonesArray& dum = *fModA[module]; fDetTypeSim->GetSimuParam()->SPDThresholds(module,thr,sigma); thr += 1.; - new (dum[last]) AliITSpListItem(-1, -1, module, index, thr); + int label = -1; + if (rawID2clusID) { // RS If the raw->cluster ID is set (filled by cluster finder) store cluster ID's in SDigits + if (rawID2clusID->GetSize()<=countRW) {AliError(Form("The buffer of rawSPD to clusSPD ID's is shorter than current rawSPD ID=%d",countRW));} + else label = (*rawID2clusID)[countRW]; + } + new (dum[last]) AliITSpListItem(label, -1, module, index, thr); } rawReader->Reset(); @@ -1275,7 +1286,9 @@ Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader) Int_t scalef=AliITSsimulationSDD::ScaleFourier(segSDD); Int_t firstSDD=AliITSgeomTGeo::GetModuleIndex(3,1,1); Int_t firstSSD=AliITSgeomTGeo::GetModuleIndex(5,1,1); - + // + countRW = -1; // RS + rawID2clusID = fRawID2ClusID[kSDD]; AliITSRawStream* inputSDD=AliITSRawStreamSDD::CreateRawStreamSDD(rawReader); for(Int_t iMod=firstSDD; iModGetCalibrationModel(iMod); @@ -1290,6 +1303,7 @@ Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader) AliITSDDLModuleMapSDD* ddlmap=fDetTypeSim->GetDDLModuleMapSDD(); inputSDD->SetDDLModuleMap(ddlmap); while(inputSDD->Next()){ + countRW++; // RS if(inputSDD->IsCompletedModule()==kFALSE && inputSDD->IsCompletedDDL()==kFALSE){ @@ -1302,7 +1316,12 @@ Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader) if (module >= size) continue; last = fModA[module]->GetEntries(); TClonesArray& dum = *fModA[module]; - new (dum[last]) AliITSpListItem(-1, -1, module, index, Double_t(signal10)); + int label = -1; + if (rawID2clusID) { // RS If the raw->cluster ID is set (filled by cluster finder) store cluster ID's in SDigits + if (rawID2clusID->GetSize()<=countRW) {AliError(Form("The buffer of rawSDD to clusSDD ID's is shorter than current rawSDD ID=%d",countRW));} + else label = (*rawID2clusID)[countRW]; + } + new (dum[last]) AliITSpListItem(label, -1, module, index, Double_t(signal10)); ((AliITSpListItem*) dum.At(last))->AddSignalAfterElect(module, index, Double_t(signal10)); } } @@ -1315,10 +1334,12 @@ Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader) AliITSsegmentationSSD* segSSD = (AliITSsegmentationSSD*) fDetTypeSim->GetSegmentationModel(2); npx = segSSD->Npx(); AliITSRawStreamSSD inputSSD(rawReader); + countRW = -1; + rawID2clusID = fRawID2ClusID[kSSD]; while(1){ Bool_t next = inputSSD.Next(); if (!next) break; - + countRW++; // RS Int_t module = inputSSD.GetModuleID(); if(module<0)AliError(Form("Invalid SSD module %d \n",module)); if(module<0)continue; @@ -1331,7 +1352,12 @@ Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader) last = fModA[module]->GetEntries(); TClonesArray& dum = *fModA[module]; - new (dum[last]) AliITSpListItem(-1, -1, module, index, Double_t(signal)); + int label = -1; + if (rawID2clusID) { // RS If the raw->cluster ID is set (filled by cluster finder) store cluster ID's in SDigits + if (rawID2clusID->GetSize()<=countRW) {AliError(Form("The buffer of rawSSD to clusSSD ID's is shorter than current rawSSD ID=%d",countRW));} + else label = (*rawID2clusID)[countRW]; + } + new (dum[last]) AliITSpListItem(label, -1, module, index, Double_t(signal)); } rawReader->Reset(); AliITSpListItem* sdig = 0; @@ -1349,7 +1375,7 @@ Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader) sdig = (AliITSpListItem*) (fModA[mod]->At(ie)); Double_t digsig = sdig->GetSignal(); if(mod>=firstssd) digsig*=adcToEv; // for SSD: convert back charge from ADC to electron - new (aSDigits[ie]) AliITSpListItem(-1, -1, mod, sdig->GetIndex(), digsig); + new (aSDigits[ie]) AliITSpListItem(sdig->GetTrack(0), -1, mod, sdig->GetIndex(), digsig); Float_t sig = sdig->GetSignalAfterElect(); if(mod>=firstssd) sig*=adcToEv; if (sig > 0.) { diff --git a/ITS/AliITS.h b/ITS/AliITS.h index 76bdca5cabd..96990e45544 100644 --- a/ITS/AliITS.h +++ b/ITS/AliITS.h @@ -28,11 +28,12 @@ class AliITSgeom; class AliITSdigit; class AliITSmodule; class AliRunDigitizer; - +class TArrayI; class AliITS : public AliDetector { public: + enum {kSPD,kSDD,kSSD}; //================= Standard Classes =============================== AliITS(); // Default creator. AliITS(const Char_t *title); // standard Creator @@ -149,6 +150,8 @@ class AliITS : public AliDetector { //===================== FO signals ================================ // Write FO signals in UserInfo of SDigits/Digits tree void WriteFOSignals(); + void SetRawID2ClusID(const TArrayI* arr, Int_t iDet) { if (iDet>-1&&iDet-1&&iDetCluster assingment in Raw2SDigit (for embedding) private: AliITS(const AliITS &source); // copy constructor. Not to be used! AliITS& operator=(const AliITS &source); // = operator. Not to be used! diff --git a/ITS/AliITSClusterFinder.cxx b/ITS/AliITSClusterFinder.cxx index 838a66fd6e3..52bc25b816d 100644 --- a/ITS/AliITSClusterFinder.cxx +++ b/ITS/AliITSClusterFinder.cxx @@ -28,6 +28,7 @@ #include "AliITSMap.h" #include "AliITSgeomTGeo.h" #include +#include #include "AliMC.h" #include "AliLog.h" @@ -50,7 +51,10 @@ fEvent(0), fZmin(0), fZmax(0), fXmin(0), -fXmax(0){ +fXmax(0), +fNClusters(0), +fRawID2ClusID(0) +{ // default cluster finder // Input: // none. @@ -78,7 +82,10 @@ fEvent(0), fZmin(0), fZmax(0), fXmin(0), -fXmax(0){ +fXmax(0), +fNClusters(0), +fRawID2ClusID(0) +{ // default cluster finder // Standard constructor for cluster finder // Input: @@ -109,7 +116,10 @@ fEvent(0), fZmin(0), fZmax(0), fXmin(0), -fXmax(0){ +fXmax(0), +fNClusters(0), +fRawID2ClusID(0) +{ // default cluster finder // Standard + cluster finder constructor // Input: @@ -143,7 +153,9 @@ AliITSClusterFinder::AliITSClusterFinder(const AliITSClusterFinder &source) : fZmin(source.fZmin), fZmax(source.fZmax), fXmin(source.fXmin), - fXmax(source.fXmax) + fXmax(source.fXmax), + fNClusters(source.fNClusters), + fRawID2ClusID(source.fRawID2ClusID) { // Copy constructor // Copies are not allowed. The method is protected to avoid misuse. @@ -473,7 +485,11 @@ MakeCluster(Int_t k,Int_t max,AliBin *bins,UInt_t m,AliITSRecPoint &c) { c.SetSigmaZ2(c.GetSigmaZ2()+j*j*q); bins[k].SetMask(0xFFFFFFFE); - + if (fRawID2ClusID) { // RS: Register cluster id in raw words list + int rwid = bins[k].GetRawID(); + if (fRawID2ClusID->GetSize()<=rwid) fRawID2ClusID->Set( (rwid+10)<<1 ); + (*fRawID2ClusID)[rwid] = fNClusters+1; // RS: store clID+1 as a reference to the cluster + } if (bins[k-max].GetMask() == m) MakeCluster(k-max,max,bins,m,c); if (bins[k-1 ].GetMask() == m) MakeCluster(k-1 ,max,bins,m,c); if (bins[k+max].GetMask() == m) MakeCluster(k+max,max,bins,m,c); diff --git a/ITS/AliITSClusterFinder.h b/ITS/AliITSClusterFinder.h index db36088727c..9027e06fa9c 100644 --- a/ITS/AliITSClusterFinder.h +++ b/ITS/AliITSClusterFinder.h @@ -23,6 +23,7 @@ class AliITSdigit; class AliITSRecPoint; class AliITSDetTypeRec; class AliRawReader; +class TArrayI; //---------------------------------------------------------------------- class AliITSClusterFinder :public TObject{ @@ -78,7 +79,11 @@ class AliITSClusterFinder :public TObject{ AliITSDetTypeRec* GetDetTypeRec() const {return fDetTypeRec;} void InitGeometry(); - + // + Int_t GetNClusters() const {return fNClusters;} + void SetRawID2ClusID(TArrayI *arr) {fRawID2ClusID = arr;} + TArrayI* GetRawID2ClusID() const {return fRawID2ClusID;} + // protected: class Ali1Dcluster { public: @@ -98,11 +103,12 @@ class AliITSClusterFinder :public TObject{ }; class AliBin { public: - AliBin():fIndex(0),fMask(0xFFFFFFFE),fQ(0){} + AliBin():fIndex(0),fMask(0xFFFFFFFE),fRawID(-1),fQ(0){} void SetIndex(UInt_t idx) {fIndex=idx;} void SetQ(UShort_t q) {fQ=q;} void SetMask(UInt_t m) {fMask=m;} - void Reset() {fIndex=0; fMask=0xFFFFFFFE; fQ=0;} + void SetRawID(Int_t id) {fRawID=id;} + void Reset() {fIndex=0; fMask=0xFFFFFFFE; fQ=0; fRawID=-1;} void Use() {fMask&=0xFFFFFFFE;} Bool_t IsNotUsed() const {return (fMask&1);} @@ -111,9 +117,11 @@ class AliITSClusterFinder :public TObject{ UInt_t GetIndex() const {return fIndex;} UShort_t GetQ() const {return fQ;} UInt_t GetMask() const {return fMask;} + Int_t GetRawID() const {return fRawID;} protected: UInt_t fIndex; //digit index UInt_t fMask; //peak mask + Int_t fRawID; // ID of raw word (used for embedding) UShort_t fQ; //signal }; void MakeCluster(Int_t k,Int_t max,AliBin *bins,UInt_t m,AliITSRecPoint &c); @@ -145,13 +153,17 @@ class AliITSClusterFinder :public TObject{ Int_t fZmax; // maximum channel in Zloc Int_t fXmin; // minimum channel in Xloc Int_t fXmax; // maximum channel in Xloc + // + UInt_t fNClusters; // total number of clusters found + // + TArrayI* fRawID2ClusID; //! optional array to store raw word ID -> ClusID for embedding (not owned) AliITSClusterFinder(const AliITSClusterFinder &source); // copy constructor // assignment operator AliITSClusterFinder& operator=(const AliITSClusterFinder &source); - ClassDef(AliITSClusterFinder,10) //Class for clustering and reconstruction of space points + ClassDef(AliITSClusterFinder,11) //Class for clustering and reconstruction of space points }; // Input and output functions for standard C++ input/output. ostream &operator<<(ostream &os,AliITSClusterFinder &source); diff --git a/ITS/AliITSClusterFinderV2SDD.cxx b/ITS/AliITSClusterFinderV2SDD.cxx index ea8d39494dc..02b91c594b2 100644 --- a/ITS/AliITSClusterFinderV2SDD.cxx +++ b/ITS/AliITSClusterFinderV2SDD.cxx @@ -250,6 +250,9 @@ FindClustersSDD(AliBin* bins[2], TBits* anodeFired[2], } } } + } + else { // raw data + if (fRawID2ClusID) milab[0] = fNClusters+1; // RS: store clID+1 as a reference to the cluster } @@ -309,6 +312,7 @@ FindClustersSDD(AliBin* bins[2], TBits* anodeFired[2], else { fDetTypeRec->AddRecPoint(cc); } + fNClusters++; // RS ncl++; } } @@ -322,7 +326,7 @@ void AliITSClusterFinderV2SDD::RawdataToClusters(AliRawReader* rawReader){ //------------------------------------------------------------ // This function creates ITS clusters from raw data //------------------------------------------------------------ - + fNClusters = 0; //RS AliITSRawStream* inputSDD=AliITSRawStreamSDD::CreateRawStreamSDD(rawReader); AliDebug(1,Form("%s is used",inputSDD->ClassName())); @@ -367,6 +371,9 @@ void AliITSClusterFinderV2SDD::FindClustersSDD(AliITSRawStream* input) for(Int_t iMod=0; iModReset(); //RS if array was provided, we shall store the rawID -> ClusterID + // while (input->Next()) { Int_t iModule = input->GetModuleID(); if(iModule<0){ @@ -438,6 +445,7 @@ void AliITSClusterFinderV2SDD::FindClustersSDD(AliITSRawStream* input) fDDLBins[iHybrid][index].SetQ(q); fDDLBins[iHybrid][index].SetMask(1); fDDLBins[iHybrid][index].SetIndex(index); + fDDLBins[iHybrid][index].SetRawID(countRW); //RS register raw id ddlAnodeFired[iHybrid]->SetBitNumber(iz); }else{ AliWarning(Form("Invalid SDD cell: Anode=%d TimeBin=%d",iz,itb)); @@ -445,6 +453,7 @@ void AliITSClusterFinderV2SDD::FindClustersSDD(AliITSRawStream* input) } } } + countRW++; //RS } for(Int_t iHyb=0;iHybReset(); + fNClusters = 0; //RS AliITSRawStreamSPD inputSPD(rawReader); FindClustersSPD(&inputSPD); @@ -232,7 +233,7 @@ Int_t AliITSClusterFinderV2SPD::ClustersSPD(AliBin* bins, TClonesArray* digits,T idy=ymax-ymin+1; idz=zmax-zmin+1; } - + // for(Int_t iiz=zmin; iiz<=zmax;iiz+=idz){ for(Int_t iiy=ymin;iiy<=ymax;iiy+=idy){ @@ -256,7 +257,14 @@ Int_t AliITSClusterFinderV2SPD::ClustersSPD(AliBin* bins, TClonesArray* digits,T } ndigits++; Float_t qBin=0.; - if(rawdata) qBin = bins[idxBins[idx]].GetQ(); + if(rawdata) { + qBin = bins[idxBins[idx]].GetQ(); + if (fRawID2ClusID) { // RS: Register cluster id in raw words list + int rwid = bins[idxBins[idx]].GetRawID(); + if (fRawID2ClusID->GetSize()<=rwid) fRawID2ClusID->Set( (rwid+10)<<1 ); + (*fRawID2ClusID)[rwid] = milab[0] = fNClusters+1; // RS: store clID+1 as a reference to the cluster + } + } if(!rawdata){ AliITSdigitSPD* dig = (AliITSdigitSPD*)digits->UncheckedAt(idxBins[idx]); qBin = (Float_t)dig->GetSignal(); @@ -303,6 +311,7 @@ Int_t AliITSClusterFinderV2SPD::ClustersSPD(AliBin* bins, TClonesArray* digits,T AliITSRecPoint(cl); } nclu++; + fNClusters++; }// for iiy }// for iiz }//end for iBin @@ -327,6 +336,9 @@ void AliITSClusterFinderV2SPD::FindClustersSPD(AliITSRawStreamSPD* input) AliBin* bins = NULL; // read raw data input stream + int countRW = 0; //RS + if (fRawID2ClusID) fRawID2ClusID->Reset(); //RS if array was provided, we shall store the rawID -> ClusterID + // while (kTRUE) { Bool_t next = input->Next(); if (!next || input->IsNewModule()) { @@ -345,13 +357,15 @@ void AliITSClusterFinderV2SPD::FindClustersSPD(AliITSRawStreamSPD* input) memcpy(binsSPD,binsSPDInit,sizeof(AliBin)*kMaxBin); } - if (next && bins) { + if (next && bins) { // fill the current digit into the bins array Int_t index = (input->GetCoord2()+1) * kNzBins + (input->GetCoord1()+1); bins[index].SetIndex(index); bins[index].SetQ(1); bins[index].SetMask(1); + bins[index].SetRawID(countRW); //RS register raw id } + countRW++; //RS } delete [] binsSPDInit; diff --git a/ITS/AliITSClusterFinderV2SSD.cxx b/ITS/AliITSClusterFinderV2SSD.cxx index d52a99bd9f0..5f69cd4c97b 100644 --- a/ITS/AliITSClusterFinderV2SSD.cxx +++ b/ITS/AliITSClusterFinderV2SSD.cxx @@ -412,6 +412,7 @@ void AliITSClusterFinderV2SSD::RawdataToClusters(AliRawReader* rawReader){ //------------------------------------------------------------ // This function creates ITS clusters from raw data //------------------------------------------------------------ + fNClusters = 0; rawReader->Reset(); AliITSRawStreamSSD inputSSD(rawReader); FindClustersSSD(&inputSSD); @@ -434,11 +435,15 @@ void AliITSClusterFinderV2SSD::FindClustersSSD(AliITSRawStreamSSD* input) AliWarning("Using default AliITSRecoParam class"); } } + if (fRawID2ClusID) { // RS: reset references from 1D clusters to rawID's + fRawIDRef[0].Reset(); + fRawIDRef[1].Reset(); + } Int_t nClustersSSD = 0; const Int_t kNADC = 12; const Int_t kMaxADCClusters = 1000; - Int_t strips[kNADC][2][kMaxADCClusters][2]; // [ADC],[side],[istrip], [0]=istrip [1]=signal + Int_t strips[kNADC][2][kMaxADCClusters][3]; // [ADC],[side],[istrip], [0]=istrip [1]=signal [2]=rawID (for embedding, RS) Int_t nStrips[kNADC][2]; for( int i=0; iReset(); //RS if array was provided, we shall store the rawID -> ClusterID + while (kTRUE) { bool next = input->Next(); @@ -545,13 +552,13 @@ void AliITSClusterFinderV2SSD::FindClustersSSD(AliITSRawStreamSSD* input) for( int istr = 0; istrGetDDL()<<" "<GetAD()<<" " //<GetADC()<<" "<GetSideFlag()<<" "<<((int)input->GetStrip())<<" "<GetSignal()< clusterID correspondence for embedding + const int kMaxRefRW = 200; + UInt_t nrefsRW,refsRW[kMaxRefRW]; + nrefsRW = fRawIDRef[0].GetReferences(j,refsRW,kMaxRefRW); // n-side + for (int ir=nrefsRW;ir--;) { + int rwid = (int)refsRW[ir]; + if (fRawID2ClusID->GetSize()<=rwid) fRawID2ClusID->Set( (rwid+10)<<1 ); + (*fRawID2ClusID)[rwid] = fNClusters+1; // RS: store clID+1 as a reference to the cluster + } + // + nrefsRW = fRawIDRef[1].GetReferences(ip,refsRW,kMaxRefRW); // p-side + for (int ir=nrefsRW;ir--;) { + int rwid = (int)refsRW[ir]; + if (fRawID2ClusID->GetSize()<=rwid) fRawID2ClusID->Set( (rwid+10)<<1 ); + (*fRawID2ClusID)[rwid] = fNClusters+1; // RS: store clID+1 as a reference to the cluster + } + // + milab[0] = fNClusters+1; // RS: assign id as cluster label + } AliITSRecPoint * cl2; cl2 = new ((*clusters)[ncl]) AliITSRecPoint(milab,lp,info); @@ -1520,7 +1550,8 @@ FindClustersSSD(const Ali1Dcluster* neg, Int_t nn, } cused1[ip]++; cused2[j]++; - ncl++; + ncl++; + fNClusters++; } // manyXmany } // loop over Pside 1Dclusters diff --git a/ITS/AliITSClusterFinderV2SSD.h b/ITS/AliITSClusterFinderV2SSD.h index 3087d149f93..1991de870e0 100644 --- a/ITS/AliITSClusterFinderV2SSD.h +++ b/ITS/AliITSClusterFinderV2SSD.h @@ -16,6 +16,7 @@ //-------------------------------------------------------------- #include "AliITSClusterFinder.h" #include "AliITSDetTypeRec.h" +#include "AliRefArray.h" class TClonesArray; class AliRawReader; @@ -44,6 +45,7 @@ public: Int_t fLastSSD1; //index of the last SSD1 detector Float_t fLorentzShiftP; // Shift due to ExB on drift N-side @ actual B field, layer 5, units: strip width Float_t fLorentzShiftN; // Shift due to ExB on drift P-side @ actual B field, layer 5, units: strip width + AliRefArray fRawIDRef[2]; // storage for rawID -> ClusterID (used in embedding) static Short_t* fgPairs; //array used to build positive-negative pairs static Int_t fgPairsSize; //actual size of pairs array static const Float_t fgkCosmic2008StripShifts[16][9]; // Shifts for 2007/2008 Cosmic data (timing problem) -- 2.43.0