#include <TString.h>
#include <TTree.h>
#include <TVirtualMC.h>
+#include <TArrayI.h>
#include "AliDetector.h"
#include "AliITS.h"
#include "AliITSDetTypeSim.h"
// 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):
//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):
//PH SetMarkerColor(kRed);
if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName());
fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
-
+ for (int i=fgkNTYPES;i--;) fRawID2ClusID[i] = 0;
}
//______________________________________________________________________
AliITS::~AliITS(){
}
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();
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();
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; iMod<firstSSD; iMod++){
AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)fDetTypeSim->GetCalibrationModel(iMod);
AliITSDDLModuleMapSDD* ddlmap=fDetTypeSim->GetDDLModuleMapSDD();
inputSDD->SetDDLModuleMap(ddlmap);
while(inputSDD->Next()){
+ countRW++; // RS
if(inputSDD->IsCompletedModule()==kFALSE &&
inputSDD->IsCompletedDDL()==kFALSE){
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));
}
}
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;
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;
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.) {
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
//===================== 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<fgkNTYPES) fRawID2ClusID[iDet] = arr;}
+ const TArrayI* GetRawID2ClusID(Int_t iDet) const {return (iDet>-1&&iDet<fgkNTYPES) ? fRawID2ClusID[iDet]:0;}
protected:
static const Int_t fgkNTYPES=3; //number of detector types
AliITSSimuParam* fSimuParam; //simulation parameters
TClonesArray** fModA; //! Used by Raw2SDigits (one TC per module)
TClonesArray* fpSDigits; //! Branch address to build SD from raw data
-
+ const TArrayI* fRawID2ClusID[fgkNTYPES]; //! optional array for SDigit->Cluster 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!
#include "AliITSMap.h"
#include "AliITSgeomTGeo.h"
#include <TParticle.h>
+#include <TArrayI.h>
#include "AliMC.h"
#include "AliLog.h"
fZmin(0),
fZmax(0),
fXmin(0),
-fXmax(0){
+fXmax(0),
+fNClusters(0),
+fRawID2ClusID(0)
+{
// default cluster finder
// Input:
// none.
fZmin(0),
fZmax(0),
fXmin(0),
-fXmax(0){
+fXmax(0),
+fNClusters(0),
+fRawID2ClusID(0)
+{
// default cluster finder
// Standard constructor for cluster finder
// Input:
fZmin(0),
fZmax(0),
fXmin(0),
-fXmax(0){
+fXmax(0),
+fNClusters(0),
+fRawID2ClusID(0)
+{
// default cluster finder
// Standard + cluster finder constructor
// Input:
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.
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);
class AliITSRecPoint;
class AliITSDetTypeRec;
class AliRawReader;
+class TArrayI;
//----------------------------------------------------------------------
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:
};
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);}
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);
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);
}
}
}
+ }
+ else { // raw data
+ if (fRawID2ClusID) milab[0] = fNClusters+1; // RS: store clID+1 as a reference to the cluster
}
else {
fDetTypeRec->AddRecPoint(cc);
}
+ fNClusters++; // RS
ncl++;
}
}
//------------------------------------------------------------
// This function creates ITS clusters from raw data
//------------------------------------------------------------
-
+ fNClusters = 0; //RS
AliITSRawStream* inputSDD=AliITSRawStreamSDD::CreateRawStreamSDD(rawReader);
AliDebug(1,Form("%s is used",inputSDD->ClassName()));
for(Int_t iMod=0; iMod<kModulesPerDDL; iMod++) vectModId[iMod]=-1;
// 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 (input->Next()) {
Int_t iModule = input->GetModuleID();
if(iModule<0){
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));
}
}
}
+ countRW++; //RS
}
for(Int_t iHyb=0;iHyb<kHybridsPerDDL;iHyb++){
delete ddlAnodeFired[iHyb];
// This function creates ITS clusters from raw data
//------------------------------------------------------------
rawReader->Reset();
+ fNClusters = 0; //RS
AliITSRawStreamSPD inputSPD(rawReader);
FindClustersSPD(&inputSPD);
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){
}
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();
AliITSRecPoint(cl);
}
nclu++;
+ fNClusters++;
}// for iiy
}// for iiz
}//end for iBin
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()) {
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;
//------------------------------------------------------------
// This function creates ITS clusters from raw data
//------------------------------------------------------------
+ fNClusters = 0;
rawReader->Reset();
AliITSRawStreamSSD inputSSD(rawReader);
FindClustersSSD(&inputSSD);
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; i<kNADC; i++ ){
//*
//* Loop over modules DDL+AD
//*
-
+ int countRW = 0; //RS
+ if (fRawID2ClusID) fRawID2ClusID->Reset(); //RS if array was provided, we shall store the rawID -> ClusterID
+
while (kTRUE) {
bool next = input->Next();
for( int istr = 0; istr<n+1; istr++ ){
bool stripOK = 1;
- Int_t strip=0;
+ Int_t strip=0, rwID = 0;
Float_t signal=0.0, noise=0.0, gain=0.0;
if( istr<n ){
strip = strips[adc][side][istr][0];
signal = strips[adc][side][istr][1];
-
+ rwID = strips[adc][side][istr][2]; // RS
//cout<<"strip "<<adc<<" / "<<side<<": "<<strip<<endl;
if( cal ){
nDigits++;
//nstat[side]++;
ostrip = strip;
+ if (fRawID2ClusID) fRawIDRef[side].AddReference(nClusters1D[side],rwID);
}
} //* end loop over strips
}
strips[adc][side][n][0] = strip;
strips[adc][side][n][1] = signal;
+ strips[adc][side][n][2] = countRW;
n++;
//cout<<"SSD: "<<input->GetDDL()<<" "<<input->GetAD()<<" "
//<<input->GetADC()<<" "<<input->GetSideFlag()<<" "<<((int)input->GetStrip())<<" "<<strip<<" : "<<input->GetSignal()<<endl;
-
+ //
+ countRW++; //RS
} //* End main loop over the input
AliDebug(1,Form("found clusters in ITS SSD: %d", nClustersSSD));
lp[5]=-4.32e-05;
}
}
+ //
+ if (fRawID2ClusID) { // set rawID <-> 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);
}
cused1[ip]++;
cused2[j]++;
- ncl++;
+ ncl++;
+ fNClusters++;
} // manyXmany
} // loop over Pside 1Dclusters
//--------------------------------------------------------------
#include "AliITSClusterFinder.h"
#include "AliITSDetTypeRec.h"
+#include "AliRefArray.h"
class TClonesArray;
class AliRawReader;
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)