LCOV - code coverage report
Current view: top level - STEER/ESD - AliMultiplicity.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 195 435 44.8 %
Date: 2016-06-14 17:26:59 Functions: 15 33 45.5 %

          Line data    Source code
       1             : #include <string.h>
       2             : #include "AliMultiplicity.h"
       3             : #include "AliLog.h"
       4             : #include "AliRefArray.h"
       5             : 
       6         172 : ClassImp(AliMultiplicity)
       7             : 
       8             : //______________________________________________________________________
       9             : AliMultiplicity::AliMultiplicity():
      10          51 : AliVMultiplicity("AliMultiplicity",""),  // must be named like that to be searchable in ESDEvent
      11          51 :   fNtracks(0),
      12          51 :   fNsingle(0),
      13          51 :   fNsingleSPD2(0),
      14             : //
      15          51 :   fDPhiWindow2(0.08*0.08),  
      16          51 :   fDThetaWindow2(0.025*0.025),
      17          51 :   fDPhiShift(0.0045),
      18          51 :   fNStdDev(1.0),
      19             : //
      20          51 :   fLabels(0),
      21          51 :   fLabelsL2(0),
      22          51 :   fUsedClusS(0), 
      23          51 :   fUsedClusT(0),
      24          51 :   fTh(0),
      25          51 :   fPhi(0),
      26          51 :   fDeltTh(0),
      27          51 :   fDeltPhi(0),
      28          51 :   fThsingle(0),
      29          51 :   fPhisingle(0),
      30          51 :   fLabelssingle(0),
      31          51 :   fFastOrFiredChips(1200),
      32          51 :   fClusterFiredChips(1200),
      33          51 :   fNtracksOnline(0)
      34         255 : {
      35             :   // Default Constructor
      36          51 :   fFiredChips[0] = 0;
      37          51 :   fFiredChips[1] = 0;
      38         306 :   for (int il=2;il--;) fSCl2Tracks[il] = fTCl2Tracks[il][0] = fTCl2Tracks[il][1] = 0;
      39         714 :   for(Int_t ilayer = 0; ilayer < 6; ilayer++)fITSClusters[ilayer] = 0;
      40         102 : }
      41             : 
      42             : //______________________________________________________________________
      43             : AliMultiplicity::AliMultiplicity(Int_t ntr, Float_t *th,  Float_t *ph, Float_t *dth, Float_t *dph, Int_t *labels, Int_t* labelsL2, Int_t ns, Float_t *ts, Float_t *ps, Int_t *labelss, Short_t nfcL1, Short_t nfcL2, const TBits & fFastOr):
      44           0 :   AliVMultiplicity("AliMultiplicity",""),
      45           0 :   fNtracks(ntr),
      46           0 :   fNsingle(ns),
      47           0 :   fNsingleSPD2(0),
      48             :   //
      49           0 :   fDPhiWindow2(0.08*0.08),  
      50           0 :   fDThetaWindow2(0.025*0.025),
      51           0 :   fDPhiShift(0.0045),
      52           0 :   fNStdDev(1.0),
      53             :   //
      54           0 :   fLabels(0),
      55           0 :   fLabelsL2(0),
      56           0 :   fUsedClusS(0),
      57           0 :   fUsedClusT(0),
      58           0 :   fTh(0),
      59           0 :   fPhi(0),
      60           0 :   fDeltTh(0),
      61           0 :   fDeltPhi(0),
      62           0 :   fThsingle(0),
      63           0 :   fPhisingle(0),
      64           0 :   fLabelssingle(0),
      65           0 :   fFastOrFiredChips(1200),
      66           0 :   fClusterFiredChips(1200),
      67           0 :   fNtracksOnline(0)
      68           0 : {
      69             : // Standard constructor
      70           0 :   for (int il=2;il--;) fSCl2Tracks[il] = fTCl2Tracks[il][0] = fTCl2Tracks[il][1] = 0;
      71           0 :   if(ntr>0){
      72           0 :     fLabels = new Int_t[ntr];
      73           0 :     fLabelsL2 = new Int_t[ntr];
      74           0 :     fTh = new Double_t [ntr];
      75           0 :     fPhi = new Double_t [ntr];
      76           0 :     fDeltTh = new Double_t [ntr];
      77           0 :     fDeltPhi = new Double_t [ntr];
      78           0 :     for(Int_t i=0;i<fNtracks;i++){
      79           0 :       fTh[i]=th[i];
      80           0 :       fPhi[i]=ph[i];
      81           0 :       fDeltTh[i]=dth[i];
      82           0 :       fDeltPhi[i]=dph[i];
      83           0 :       fLabels[i] = labels[i];
      84           0 :       fLabelsL2[i] = labelsL2[i];
      85             :     }
      86           0 :   }
      87           0 :   if(ns>0){
      88           0 :     fThsingle = new Double_t [ns];
      89           0 :     fPhisingle = new Double_t [ns];
      90           0 :     fLabelssingle = new Int_t [ns];
      91           0 :     for(Int_t i=0;i<fNsingle;i++){
      92           0 :       fThsingle[i]=ts[i];
      93           0 :       fPhisingle[i]=ps[i];
      94           0 :       fLabelssingle[i]=labelss[i];
      95             :     }
      96           0 :   }
      97           0 :   fFiredChips[0] = nfcL1;
      98           0 :   fFiredChips[1] = nfcL2;
      99           0 :   fFastOrFiredChips = fFastOr;
     100           0 :   for(Int_t ilayer = 0; ilayer < 6; ilayer++)fITSClusters[ilayer] = 0;
     101           0 : }
     102             : 
     103             : //______________________________________________________________________
     104             : AliMultiplicity::AliMultiplicity(Int_t ntr, Int_t ns, Short_t nfcL1, Short_t nfcL2, const TBits & fFastOr) :
     105           8 :   AliVMultiplicity("AliMultiplicity",""),
     106           8 :   fNtracks(ntr),
     107           8 :   fNsingle(ns),
     108           8 :   fNsingleSPD2(0),
     109             :   //
     110           8 :   fDPhiWindow2(0.08*0.08),  
     111           8 :   fDThetaWindow2(0.025*0.025),
     112           8 :   fDPhiShift(0.0045),
     113           8 :   fNStdDev(1.0),
     114             :   //
     115           8 :   fLabels(0),
     116           8 :   fLabelsL2(0),
     117           8 :   fUsedClusS(0),
     118           8 :   fUsedClusT(0),
     119           8 :   fTh(0),
     120           8 :   fPhi(0),
     121           8 :   fDeltTh(0),
     122           8 :   fDeltPhi(0),
     123           8 :   fThsingle(0),
     124           8 :   fPhisingle(0),
     125           8 :   fLabelssingle(0),
     126           8 :   fFastOrFiredChips(1200),
     127           8 :   fClusterFiredChips(1200),
     128           8 :   fNtracksOnline(0)
     129          40 : {
     130             :   // Standard constructor to create the arrays w/o filling
     131          48 :   for (int il=2;il--;) fSCl2Tracks[il] = fTCl2Tracks[il][0] = fTCl2Tracks[il][1] = 0;
     132           8 :   if(ntr>0){
     133          16 :     fLabels   = new Int_t[ntr];
     134          16 :     fLabelsL2 = new Int_t[ntr];
     135          16 :     fTh       = new Double_t [ntr];
     136          16 :     fPhi      = new Double_t [ntr];
     137          16 :     fDeltTh   = new Double_t [ntr];
     138          16 :     fDeltPhi  = new Double_t [ntr];
     139         112 :     for(Int_t i=fNtracks;i--;){
     140          48 :       fTh[i]=fPhi[i]=fDeltTh[i]=fDeltPhi[i] = 0;
     141          48 :       fLabels[i] = fLabelsL2[i] = 0;
     142             :     }
     143           8 :   }
     144           8 :   if(ns>0){
     145          16 :     fThsingle  = new Double_t [ns];
     146          16 :     fPhisingle = new Double_t [ns];
     147          16 :     fLabelssingle = new Int_t [ns];
     148          96 :     for(Int_t i=fNsingle;i--;) fThsingle[i] = fPhisingle[i] = fLabelssingle[i] = 0;
     149           8 :   }
     150           8 :   fFiredChips[0] = nfcL1;
     151           8 :   fFiredChips[1] = nfcL2;
     152           8 :   fFastOrFiredChips = fFastOr;
     153         112 :   for(Int_t ilayer=6;ilayer--;) fITSClusters[ilayer] = 0;
     154          16 : }
     155             : 
     156             : //______________________________________________________________________
     157             : AliMultiplicity::AliMultiplicity(const AliMultiplicity& m):
     158           0 :   AliVMultiplicity(m),
     159           0 :   fNtracks(m.fNtracks),
     160           0 :   fNsingle(m.fNsingle),
     161           0 :   fNsingleSPD2(m.fNsingleSPD2),
     162             :   //
     163           0 :   fDPhiWindow2(0.08*0.08),  
     164           0 :   fDThetaWindow2(0.025*0.025),
     165           0 :   fDPhiShift(0.0045),
     166           0 :   fNStdDev(1.0),
     167             :   //
     168           0 :   fLabels(0),
     169           0 :   fLabelsL2(0),
     170           0 :   fUsedClusS(0),
     171           0 :   fUsedClusT(0),
     172           0 :   fTh(0),
     173           0 :   fPhi(0),
     174           0 :   fDeltTh(0),
     175           0 :   fDeltPhi(0),
     176           0 :   fThsingle(0),
     177           0 :   fPhisingle(0),
     178           0 :   fLabelssingle(0),
     179           0 :   fFastOrFiredChips(1200),
     180           0 :   fClusterFiredChips(1200),
     181           0 :   fNtracksOnline(0)
     182           0 : {
     183             :   // copy constructor
     184           0 :   for (int il=2;il--;) fSCl2Tracks[il] = fTCl2Tracks[il][0] = fTCl2Tracks[il][1] = 0;
     185           0 :   Duplicate(m);
     186           0 : }
     187             : 
     188             : //______________________________________________________________________
     189             : AliMultiplicity &AliMultiplicity::operator=(const AliMultiplicity& m){
     190             :   // assignment operator
     191          20 :   if(this == &m)return *this;
     192          10 :   ((AliVMultiplicity*)this)->operator=(m);
     193             : 
     194          20 :   if(fTh)delete [] fTh;fTh = 0;
     195          20 :   if(fPhi)delete [] fPhi;fPhi = 0; 
     196          20 :   if(fDeltTh)delete [] fDeltTh;fDeltTh= 0; 
     197          20 :   if(fDeltPhi)delete [] fDeltPhi;fDeltPhi = 0; 
     198          20 :   if(fLabels)delete [] fLabels;fLabels = 0;
     199          20 :   if(fLabelsL2)delete [] fLabelsL2;fLabelsL2 = 0;
     200          20 :   if(fThsingle)delete [] fThsingle;fThsingle = 0;
     201          20 :   if(fPhisingle)delete [] fPhisingle;fPhisingle = 0;
     202          20 :   if(fLabelssingle)delete [] fLabelssingle;fLabelssingle = 0;
     203          20 :   if(fUsedClusS) delete[] fUsedClusS; fUsedClusS = 0;
     204          20 :   if(fUsedClusT) delete[] fUsedClusT; fUsedClusT = 0;
     205          60 :   for (int il=2;il--;) {
     206          40 :     if (fSCl2Tracks[il])    delete fSCl2Tracks[il];    fSCl2Tracks[il]    = 0;
     207          40 :     if (fTCl2Tracks[il][0]) delete fTCl2Tracks[il][0]; fTCl2Tracks[il][0] = 0;
     208          40 :     if (fTCl2Tracks[il][1]) delete fTCl2Tracks[il][1]; fTCl2Tracks[il][1] = 0;
     209             :   }
     210          10 :   Duplicate(m);
     211             :   //
     212          10 :   return *this;
     213          10 : }
     214             : 
     215             : void AliMultiplicity::Copy(TObject &obj) const {
     216             :   
     217             :   // this overwrites the virtual TOBject::Copy()
     218             :   // to allow run time copying without casting
     219             :   // in AliESDEvent
     220             : 
     221           4 :   if(this==&obj)return;
     222           6 :   AliMultiplicity *robj = dynamic_cast<AliMultiplicity*>(&obj);
     223           2 :   if(!robj)return; // not an AliMultiplicity
     224           2 :   *robj = *this;
     225             : 
     226           4 : }
     227             : 
     228             : 
     229             : //______________________________________________________________________
     230             : void AliMultiplicity::Duplicate(const AliMultiplicity& m){
     231             :   // used by copy constructor and assignment operator
     232          20 :   fNtracks = m.fNtracks;
     233          10 :   if(fNtracks>0){
     234           8 :     fTh = new Double_t[fNtracks];
     235           8 :     fPhi = new Double_t[fNtracks];
     236           8 :     fDeltTh = new Double_t[fNtracks];
     237           8 :     fDeltPhi = new Double_t[fNtracks];
     238           8 :     fLabels = new Int_t[fNtracks];
     239           8 :     fLabelsL2 = new Int_t[fNtracks];
     240          16 :     if (m.fUsedClusT) fUsedClusT = new ULong64_t[fNtracks]; else fUsedClusT = 0;
     241          16 :     if(m.fTh)memcpy(fTh,m.fTh,fNtracks*sizeof(Double_t));
     242          16 :     if(m.fPhi)memcpy(fPhi,m.fPhi,fNtracks*sizeof(Double_t));
     243          16 :     if(m.fDeltTh)memcpy(fDeltTh,m.fDeltTh,fNtracks*sizeof(Double_t));
     244          16 :     if(m.fDeltPhi)memcpy(fDeltPhi,m.fDeltPhi,fNtracks*sizeof(Double_t));
     245          16 :     if(m.fLabels)memcpy(fLabels,m.fLabels,fNtracks*sizeof(Int_t));
     246          16 :     if(m.fLabelsL2)memcpy(fLabelsL2,m.fLabelsL2,fNtracks*sizeof(Int_t));
     247           8 :     if(fUsedClusT) memcpy(fUsedClusT,m.fUsedClusT,fNtracks*sizeof(ULong64_t));
     248         176 :     for (int i=2;i--;) for (int j=2;j--;) if (m.fTCl2Tracks[i][j]) fTCl2Tracks[i][j] = new AliRefArray(*m.fTCl2Tracks[i][j]);
     249           8 :   }
     250             :   else {
     251           2 :     fTh = 0;
     252           2 :     fPhi = 0;
     253           2 :     fDeltTh = 0;
     254           2 :     fDeltPhi = 0;
     255           2 :     fLabels = 0;
     256           2 :     fLabelsL2 = 0;
     257             :   }
     258          10 :   fNsingle = m.fNsingle;
     259          10 :   fNsingleSPD2 = m.fNsingleSPD2;
     260          10 :   if(fNsingle>0){
     261           8 :     fThsingle = new Double_t[fNsingle];
     262           8 :     fPhisingle = new Double_t[fNsingle];
     263           8 :     fLabelssingle = new Int_t[fNsingle];
     264           8 :     if (m.fUsedClusS) fUsedClusS = new UInt_t[fNsingle];
     265           8 :     else fUsedClusS = 0;
     266          16 :     if(m.fThsingle)memcpy(fThsingle,m.fThsingle,fNsingle*sizeof(Double_t));
     267          16 :     if(m.fPhisingle)memcpy(fPhisingle,m.fPhisingle,fNsingle*sizeof(Double_t));
     268          16 :     if(m.fLabelssingle)memcpy(fLabelssingle,m.fLabelssingle,fNsingle*sizeof(Int_t));
     269           8 :     if(fUsedClusS) memcpy(fUsedClusS,m.fUsedClusS,fNsingle*sizeof(UInt_t));
     270          64 :     for (int i=2;i--;) if (m.fSCl2Tracks[i]) fSCl2Tracks[i] = new AliRefArray(*m.fSCl2Tracks[i]);
     271           8 :   }
     272             :   else {
     273           2 :     fThsingle = 0;
     274           2 :     fPhisingle = 0;
     275           2 :     fLabelssingle = 0;
     276             :   }
     277             : 
     278          10 :   fFiredChips[0] = m.fFiredChips[0];
     279          10 :   fFiredChips[1] = m.fFiredChips[1];
     280         140 :   for(Int_t ilayer = 0; ilayer < 6; ilayer++){
     281          60 :     fITSClusters[ilayer] = m.fITSClusters[ilayer];
     282             :   }
     283          10 :   fDPhiWindow2   = m.fDPhiWindow2;
     284          10 :   fDThetaWindow2 = m.fDThetaWindow2;
     285          10 :   fDPhiShift     = m.fDPhiShift;
     286          10 :   fNStdDev       = m.fNStdDev;
     287          10 :   fFastOrFiredChips = m.fFastOrFiredChips;
     288          10 :   fClusterFiredChips = m.fClusterFiredChips;
     289          10 :   fNtracksOnline = m.fNtracksOnline;
     290          10 : }
     291             : 
     292             : //______________________________________________________________________
     293         204 : AliMultiplicity::~AliMultiplicity(){
     294             :   // Destructor
     295         138 :   if(fTh)delete [] fTh;fTh = 0;
     296         138 :   if(fPhi)delete [] fPhi;fPhi = 0; 
     297         138 :   if(fDeltTh)delete [] fDeltTh;fDeltTh = 0; 
     298         138 :   if(fDeltPhi)delete [] fDeltPhi;fDeltPhi = 0; 
     299         138 :   if(fLabels)delete [] fLabels;fLabels = 0;
     300         138 :   if(fLabelsL2)delete [] fLabelsL2;fLabelsL2 = 0;
     301         138 :   if(fThsingle)delete [] fThsingle;fThsingle = 0;
     302         138 :   if(fPhisingle)delete [] fPhisingle;fPhisingle = 0;
     303         138 :   if(fLabelssingle)delete [] fLabelssingle;fLabelssingle = 0;
     304          90 :   if(fUsedClusS) delete[] fUsedClusS; fUsedClusS = 0;
     305          90 :   if(fUsedClusT) delete[] fUsedClusT; fUsedClusT = 0;
     306         270 :   for (int il=2;il--;) {
     307         228 :     if (fSCl2Tracks[il])    delete fSCl2Tracks[il];    fSCl2Tracks[il]    = 0;
     308         276 :     if (fTCl2Tracks[il][0]) delete fTCl2Tracks[il][0]; fTCl2Tracks[il][0] = 0;
     309         180 :     if (fTCl2Tracks[il][1]) delete fTCl2Tracks[il][1]; fTCl2Tracks[il][1] = 0;
     310             :   }
     311         102 : }
     312             : 
     313             : //______________________________________________________________________
     314             : void AliMultiplicity::Clear(Option_t*)
     315             : {
     316             :   // reset all
     317           0 :   AliVMultiplicity::Clear();
     318           0 :   if(fTh)delete [] fTh;fTh = 0;
     319           0 :   if(fPhi)delete [] fPhi;fPhi = 0; 
     320           0 :   if(fDeltTh)delete [] fDeltTh;fDeltTh = 0; 
     321           0 :   if(fDeltPhi)delete [] fDeltPhi;fDeltPhi = 0; 
     322           0 :   if(fLabels)delete [] fLabels;fLabels = 0;
     323           0 :   if(fLabelsL2)delete [] fLabelsL2;fLabelsL2 = 0;
     324           0 :   if(fThsingle)delete [] fThsingle;fThsingle = 0;
     325           0 :   if(fPhisingle)delete [] fPhisingle;fPhisingle = 0;
     326           0 :   if(fLabelssingle)delete [] fLabelssingle;fLabelssingle = 0;
     327           0 :   if(fUsedClusS) delete[] fUsedClusS; fUsedClusS = 0;
     328           0 :   if(fUsedClusT) delete[] fUsedClusT; fUsedClusT = 0;
     329           0 :   for (int il=2;il--;) {
     330           0 :     if (fSCl2Tracks[il])    delete fSCl2Tracks[il];    fSCl2Tracks[il]    = 0;
     331           0 :     if (fTCl2Tracks[il][0]) delete fTCl2Tracks[il][0]; fTCl2Tracks[il][0] = 0;
     332           0 :     if (fTCl2Tracks[il][1]) delete fTCl2Tracks[il][1]; fTCl2Tracks[il][1] = 0;
     333             :   }
     334           0 :   fNtracks = fNsingle = 0;
     335           0 :   for (int i=6;i--;) fITSClusters[0] = 0;
     336           0 :   fFiredChips[0] = fFiredChips[1] = 0;
     337           0 :   fFastOrFiredChips.ResetAllBits(kTRUE);
     338           0 :   fClusterFiredChips.ResetAllBits(kTRUE);
     339           0 :   fNtracksOnline = 0;
     340             :   //
     341           0 : }
     342             : 
     343             : //______________________________________________________________________
     344             : void AliMultiplicity::SetLabel(Int_t i, Int_t layer, Int_t label)
     345             : {
     346           0 :     if(i>=0 && i<fNtracks) {
     347           0 :         if (layer == 0) {
     348           0 :             fLabels[i] = label;
     349           0 :             return;
     350           0 :         } else if (layer == 1) {
     351           0 :             if (fLabelsL2) {
     352           0 :                 fLabelsL2[i] = label;
     353           0 :                 return;
     354             :             }
     355             :         }
     356             :     }
     357           0 :     Error("SetLabel","Invalid track number %d or layer %d",i,layer);
     358           0 : }
     359             : 
     360             : //______________________________________________________________________
     361             : void AliMultiplicity::SetLabelSingle(Int_t i, Int_t label) 
     362             : {
     363           0 :     if(i>=0 && i<fNsingle) {
     364           0 :       if (fLabelssingle) {
     365           0 :         fLabelssingle[i] = label;
     366           0 :         return;
     367             :       }
     368             :     }
     369           0 :     Error("SetLabelSingle","Invalid single cluster number %d",i);
     370           0 : }
     371             : 
     372             : //______________________________________________________________________
     373             : UInt_t AliMultiplicity::GetNumberOfITSClusters(Int_t layMin, Int_t layMax) const {
     374             : 
     375           0 :   if(layMax < layMin) {
     376           0 :     AliError("layer min > layer max");
     377           0 :     return 0;
     378             :   }
     379           0 :   if(layMin < 0) {
     380           0 :     AliError("layer min < 0");
     381           0 :     return 0;
     382             :   }
     383           0 :   if(layMax < 0) {
     384           0 :     AliError("layer max > 0");
     385           0 :     return 0;
     386             :   }
     387             : 
     388             :   Int_t sum=0; 
     389           0 :   for (Int_t i=layMin; i<=layMax; i++) sum+=fITSClusters[i]; 
     390             :   return sum; 
     391             : 
     392           0 : }
     393             : 
     394             : //______________________________________________________________________
     395             : void AliMultiplicity::SetTrackletData(Int_t id, const Float_t* tlet, UInt_t trSPD1, UInt_t trSPD2)
     396             : {
     397             :   // fill tracklet data
     398          96 :   if (id>=fNtracks) {AliError(Form("Number of declared tracklets %d < %d",fNtracks,id)); return;}
     399          48 :   fTh[id]      = tlet[0];
     400          48 :   fPhi[id]     = tlet[1];
     401          48 :   fDeltPhi[id] = tlet[2];
     402          48 :   fDeltTh[id]  = tlet[3];
     403          48 :   fLabels[id]   = Int_t(tlet[4]);
     404          48 :   fLabelsL2[id] = Int_t(tlet[5]);
     405          48 :   if (!GetMultTrackRefs()) {
     406           0 :     if (!fUsedClusT) {fUsedClusT = new ULong64_t[fNtracks]; memset(fUsedClusT,0,fNtracks*sizeof(ULong64_t));}
     407           0 :     fUsedClusT[id] = (((ULong64_t)trSPD2)<<32) + trSPD1;
     408           0 :   }
     409             :   //
     410          48 : }
     411             : 
     412             : //______________________________________________________________________
     413             : void AliMultiplicity::SetSingleClusterData(Int_t id, const Float_t* scl, UInt_t tr)
     414             : {
     415             :   // fill single cluster data
     416          80 :   if (id>=fNsingle) {AliError(Form("Number of declared singles %d < %d",fNsingle,id)); return;}
     417          40 :   fThsingle[id]  = scl[0];
     418          40 :   fPhisingle[id] = scl[1];
     419          40 :   fLabelssingle[id] = Int_t(scl[2]); 
     420          40 :   if (!GetMultTrackRefs()) {
     421           0 :     if (!fUsedClusS) {fUsedClusS = new UInt_t[fNsingle]; memset(fUsedClusS,0,fNsingle*sizeof(UInt_t));}
     422           0 :     fUsedClusS[id] = tr;
     423           0 :   }
     424             :   //
     425          40 : }
     426             : 
     427             : //______________________________________________________________________
     428             : Bool_t AliMultiplicity::FreeClustersTracklet(Int_t i, Int_t mode) const
     429             : {
     430             :   // return kTRUE if the tracklet was not used by the track (on any of layers) of type mode: 0=TPC/ITS or ITS_SA, 1=ITS_SA_Pure
     431           0 :   if (mode<0 || mode>1 || i<0 || i>fNtracks) return kFALSE;
     432           0 :   if (GetMultTrackRefs()) { // new format allows multiple references
     433           0 :     return !((fTCl2Tracks[0][mode] && fTCl2Tracks[0][mode]->HasReference(i)) ||
     434           0 :              (fTCl2Tracks[1][mode] && fTCl2Tracks[1][mode]->HasReference(i)));
     435             :   }
     436             :   //
     437           0 :   if (!fUsedClusT) return kFALSE;
     438             :   const ULong64_t kMask0 = 0x0000ffff0000ffffLL;
     439             :   const ULong64_t kMask1 = 0xffff0000ffff0000LL;
     440           0 :   return (fUsedClusT[i]&(mode ? kMask1:kMask0)) == 0;
     441           0 : }
     442             : 
     443             : //______________________________________________________________________
     444             : Bool_t AliMultiplicity::GetTrackletTrackIDs(Int_t i, Int_t mode, Int_t &spd1, Int_t &spd2) const
     445             : {
     446             :   // set spd1 and spd2 to ID's of the tracks using the clusters of the tracklet (-1 if not used)
     447             :   // Mode: 0=TPC/ITS or ITS_SA, 1=ITS_SA_Pure tracks
     448             :   // return false if the neither of clusters is used
     449             :   // note: stored value:  [(idSAPureSPD2+1)<<16+(idTPCITS/SA_SPD2+1)]<<32 +  [(idSAPureSPD1+1)<<16+(idTPCITS/SA_SPD1+1)]
     450             :   // Attention: new format allows references to multiple tracks, here only the 1st will be returned
     451         576 :   spd1 = spd2 = -1;
     452         576 :   if ( mode<0 || mode>1 || i<0 || i>fNtracks ) return kFALSE;
     453         288 :   if (GetMultTrackRefs()) {
     454         432 :     if (fTCl2Tracks[0][mode]) spd1 = fTCl2Tracks[0][mode]->GetReference(i,0);
     455         432 :     if (fTCl2Tracks[1][mode]) spd2 = fTCl2Tracks[1][mode]->GetReference(i,0);
     456             :   }
     457             :   else {
     458           0 :     if (!fUsedClusT) return kFALSE;
     459           0 :     spd1 = (fUsedClusT[i]&0xffffffffLL);
     460           0 :     spd2 = (fUsedClusT[i]>>32);
     461           0 :     if (mode) { spd1 >>= 16;    spd2 >>= 16;}
     462           0 :     else      { spd1 &= 0xffff; spd2 &= 0xffff;}
     463           0 :     spd1--; // we are storing id+1
     464           0 :     spd2--;
     465             :   }
     466         720 :   return !(spd1<0&&spd2<0);
     467         288 : }
     468             : 
     469             : //______________________________________________________________________
     470             : Int_t AliMultiplicity::GetTrackletTrackIDsLay(Int_t lr,Int_t i, Int_t mode, UInt_t* refs, UInt_t maxRef) const
     471             : {
     472             :   // fill array refs with maximum maxRef references on tracks used by the cluster of layer lr of tracklet i.
     473             :   // return number of filled references
     474             :   // Mode: 0=TPC/ITS or ITS_SA, 1=ITS_SA_Pure tracks
     475             :   //
     476             :   int nrefs = 0;
     477           0 :   if ( mode<0 || mode>1 || i<0 || i>fNtracks || lr<0||lr>1) return nrefs;
     478           0 :   if (GetMultTrackRefs()) {
     479           0 :     if (fTCl2Tracks[lr][mode]) nrefs = fTCl2Tracks[lr][mode]->GetReferences(i,refs, maxRef);
     480             :   }
     481             :   else {
     482           0 :     if (!fUsedClusT || maxRef<1) return nrefs;
     483           0 :     int tr = (fUsedClusT[i]&0xffffffffLL);
     484           0 :     if (mode) { lr==0 ? tr >>= 16    : tr >>= 16;}
     485           0 :     else      { lr==0 ? tr &= 0xffff : tr &= 0xffff;}
     486           0 :     refs[0] = tr--; // we are storing id+1
     487             :     nrefs = 1;
     488             :   }
     489           0 :   return nrefs;
     490           0 : }
     491             : 
     492             : //______________________________________________________________________
     493             : Int_t AliMultiplicity::GetSingleClusterTrackIDs(Int_t i, Int_t mode, UInt_t* refs, UInt_t maxRef) const
     494             : {
     495             :   // fill array refs with maximum maxRef references on tracks used by the single cluster i of layer lr
     496             :   // return number of filled references
     497             :   // Mode: 0=TPC/ITS or ITS_SA, 1=ITS_SA_Pure tracks
     498             :   //
     499             :   int nrefs = 0;
     500           0 :   if ( mode<0 || mode>1 || i<0 || i>fNtracks) return nrefs;
     501           0 :   if (GetMultTrackRefs()) {
     502           0 :     if (fSCl2Tracks[mode]) nrefs = fSCl2Tracks[mode]->GetReferences(i,refs, maxRef);
     503             :   }
     504             :   else {
     505           0 :     if (!fUsedClusS || maxRef<1) return nrefs;
     506           0 :     int tr = fUsedClusS[i];
     507           0 :     if (mode) tr >>= 16;
     508           0 :     else      tr &= 0xffff;
     509           0 :     refs[0] = tr--; // we are storing id+1
     510             :     nrefs = 1;
     511             :   }
     512           0 :   return nrefs;
     513           0 : }
     514             : 
     515             : //______________________________________________________________________
     516             : Bool_t AliMultiplicity::FreeSingleCluster(Int_t i, Int_t mode) const
     517             : {
     518             :   // return kTRUE if the cluster was not used by the track of type mode: 0=TPC/ITS or ITS_SA, 1=ITS_SA_Pure
     519           0 :   if (mode<0 || mode>1 || i<0 || i>fNsingle) return kFALSE;
     520           0 :   if (GetMultTrackRefs()) { // new format allows multiple references
     521           0 :     return !(fSCl2Tracks[mode] && fSCl2Tracks[mode]->HasReference(i));
     522             :   }
     523           0 :   if (!fUsedClusS) return kFALSE;
     524             :   const UInt_t kMask0 = 0x0000ffff;
     525             :   const UInt_t kMask1 = 0xffff0000;
     526           0 :   return (fUsedClusS[i]&(mode ? kMask1:kMask0)) == 0;
     527           0 : }
     528             : 
     529             : //______________________________________________________________________
     530             : Bool_t AliMultiplicity::GetSingleClusterTrackID(Int_t i, Int_t mode, Int_t &tr) const
     531             : {
     532             :   // set tr to id of the track using the single clusters  (-1 if not used)
     533             :   // Mode: 0=TPC/ITS or ITS_SA, 1=ITS_SA_Pure tracks
     534             :   // return false if the cluster is not used
     535             :   //
     536             :   // Attention: new format allows references to multiple tracks, here only the 1st will be returned
     537           0 :   tr = -1;
     538           0 :   if (mode<0 || mode>1 || i<0 || i>fNsingle) return kFALSE;
     539           0 :   if (GetMultTrackRefs()) { if (fSCl2Tracks[mode]) tr = fSCl2Tracks[mode]->GetReference(i,0);}
     540             :   else {
     541           0 :     if (!fUsedClusS) return kFALSE;
     542           0 :     tr = fUsedClusS[i];
     543           0 :     if (mode) tr >>= 16;  else tr &= 0xffff;
     544           0 :     tr--;
     545             :   }
     546           0 :   return tr>=0;
     547           0 : }
     548             : 
     549             : //______________________________________________________________________
     550             : void AliMultiplicity::CompactBits()
     551             : {
     552             :   // sqeeze bit contrainers to minimum
     553          16 :   fFastOrFiredChips.Compact();
     554           8 :   fClusterFiredChips.Compact();
     555           8 : }
     556             : 
     557             : //______________________________________________________________________
     558             : void AliMultiplicity::Print(Option_t *opt) const
     559             : {
     560             :   // print
     561           0 :   printf("N.tracklets: %4d N.singles: %4d, Multiple cluster->track refs:%s\n"
     562             :          "Used: DPhiShift: %.3e Sig^2: dPhi:%.3e dTht:%.3e NStdDev:%.2f ScaleDThtSin2T:%s\n",
     563           0 :          fNtracks,fNsingle,GetMultTrackRefs() ? "ON":"OFF",
     564           0 :          fDPhiShift,fDPhiWindow2,fDThetaWindow2,fNStdDev,GetScaleDThetaBySin2T() ? "ON":"OFF");
     565           0 :   TString opts = opt; opts.ToLower();
     566           0 :   int t0spd1=-1,t1spd1=-1,t0spd2=-1,t1spd2=-1,nt[2][2]={{0}};
     567           0 :   UInt_t t[2][2][10]={{{0}}};
     568             :   //
     569           0 :   if (opts.Contains("t")) {
     570           0 :     for (int i=0;i<fNtracks;i++) {
     571           0 :       if (GetMultTrackRefs()) for (int il=2;il--;)for(int it=2;it--;) nt[il][it] = GetTrackletTrackIDsLay(il,i,it,t[il][it],10);
     572             :       else {
     573           0 :         GetTrackletTrackIDs(i,0,t0spd1,t0spd2);
     574           0 :         GetTrackletTrackIDs(i,1,t1spd1,t1spd2);
     575             :       }
     576           0 :       printf("T#%3d| Eta:%+5.2f Th:%+6.3f Phi:%+6.3f DTh:%+6.3f DPhi:%+6.3f L1:%5d L2:%5d ",
     577           0 :              i,GetEta(i),fTh[i],fPhi[i],fDeltTh[i],fDeltPhi[i],fLabels[i],fLabelsL2[i]);
     578           0 :       if (!GetMultTrackRefs()) printf("U:L1[%4d/%4d] L2[%4d/%4d]\n",t0spd1,t1spd1,t0spd2,t1spd2);
     579             :       else {
     580           0 :         printf("U:L1[");
     581           0 :         if (!nt[0][0]) printf("%4d ",-1); else for(int j=0;j<nt[0][0];j++) printf("%4d ",t[0][0][j]); printf("/");
     582           0 :         if (!nt[0][1]) printf("%4d ",-1); else for(int j=0;j<nt[0][1];j++) printf("%4d ",t[0][1][j]); printf("]");
     583             :         //
     584           0 :         printf(" L2[");
     585           0 :         if (!nt[1][0]) printf("%4d ",-1); else for(int j=0;j<nt[1][0];j++) printf("%4d ",t[1][0][j]); printf("/");
     586           0 :         if (!nt[1][1]) printf("%4d ",-1); else for(int j=0;j<nt[1][1];j++) printf("%4d ",t[1][1][j]); printf("]\n");      
     587             :       }      
     588             :     }
     589           0 :   }
     590           0 :   if (opts.Contains("s")) {
     591           0 :     for (int i=0;i<fNsingle;i++) {
     592           0 :       if (GetMultTrackRefs()) for(int it=2;it--;) nt[0][it] = GetSingleClusterTrackIDs(i,it,t[0][it],10);
     593             :       else {
     594           0 :         GetSingleClusterTrackID(i,0,t0spd1);
     595           0 :         GetSingleClusterTrackID(i,1,t1spd1);
     596             :       }
     597           0 :       printf("S#%3d| Th:%+6.3f Phi:%+6.3f L:%6d ",i,fThsingle[i],fPhisingle[i],fLabelssingle[i]);
     598           0 :       if (!GetMultTrackRefs()) printf("U:[%4d/%4d]\n", t0spd1,t1spd1);
     599             :       else {
     600           0 :         printf("U:["); 
     601           0 :         if (!nt[0][0]) printf("%4d ",-1); else for(int j=0;j<nt[0][0];j++) printf("%4d ",t[0][0][j]); printf("/");
     602           0 :         if (!nt[0][1]) printf("%4d ",-1); else for(int j=0;j<nt[0][1];j++) printf("%4d ",t[0][1][j]); printf("]\n");   
     603             :       }
     604             :     }
     605           0 :   }
     606             :   //
     607           0 : }
     608             : 
     609             : Int_t AliMultiplicity::GetLabelSingleLr(Int_t i, Int_t lr) const 
     610             : {
     611           0 :   if (lr==1) {
     612           0 :     if (!AreSPD2SinglesStored()) return -1;
     613           0 :     else i += GetNumberOfSingleClustersLr(0);
     614           0 :   }
     615           0 :   if(i>=0 && i<fNsingle) {
     616           0 :       return fLabelssingle[i];
     617             :   } else {
     618           0 :     Error("GetLabelSingle","Invalid cluster number %d",i); return -9999;
     619             :   }
     620             :   return -9999;
     621           0 : }
     622             : 
     623             : Float_t AliMultiplicity::GetPhiAll(int icl, int lr) const
     624             : {
     625             :   // return phi of the cluster out of total tracklets + singles
     626           0 :   if (lr<0||lr>1) return -999;
     627           0 :   if (icl<0||icl>(int)GetNumberOfITSClusters(lr)) {Error("GetPhiAll","Wrong cluster ID=%d for SPD%d",icl,lr); return -999;}
     628           0 :   if (lr==0) return (icl<fNtracks) ? GetPhi(icl) : GetPhiSingle(icl-fNtracks);
     629           0 :   return (icl<fNtracks) ? (GetPhi(icl) + GetDeltaPhi(icl)) : GetPhiSingleLr(icl-fNtracks, 1);
     630           0 : } 
     631             : 
     632             : Float_t AliMultiplicity::GetThetaAll(int icl, int lr) const
     633             : {
     634             :   // return theta of the cluster out of total tracklets + singles
     635           0 :   if (lr<0||lr>1) return -999;
     636           0 :   if (icl<0||icl>(int)GetNumberOfITSClusters(lr)) {Error("GetPhiAll","Wrong cluster ID=%d for SPD%d",icl,lr); return -999;}
     637           0 :   if (lr==0) return (icl<fNtracks) ? GetTheta(icl) : GetThetaSingle(icl-fNtracks);
     638           0 :   return (icl<fNtracks) ?  (GetTheta(icl) + GetDeltaTheta(icl)) : GetThetaSingleLr(icl-fNtracks, 1);
     639           0 : } 
     640             : 
     641             : Int_t AliMultiplicity::GetLabelAll(int icl, int lr) const
     642             : {
     643             :   // return label of the cluster out of total tracklets + singles
     644           0 :   if (lr<0||lr>1) return -99999;
     645           0 :   if (icl<0||icl>(int)GetNumberOfITSClusters(lr)) {Error("GetPhiAll","Wrong cluster ID=%d for SPD%d",icl,lr); return -99999;}
     646           0 :   if (lr==0) return (icl<fNtracks) ? GetLabel(icl,0) : GetLabelSingle(icl-fNtracks);
     647           0 :   return (icl<fNtracks) ?  GetLabel(icl,1) : GetLabelSingleLr(icl-fNtracks, 1);
     648           0 : } 

Generated by: LCOV version 1.11