LCOV - code coverage report
Current view: top level - ITS/ITSbase - AliITSRecPointContainer.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 125 158 79.1 %
Date: 2016-06-14 17:26:59 Functions: 14 17 82.4 %

          Line data    Source code
       1             : #include <TTree.h>
       2             : #include "AliLog.h"
       3             : #include "AliITSRecoParam.h"
       4             : #include "AliITSReconstructor.h"
       5             : #include "AliITSRecPointContainer.h"
       6             : #include "AliITSRecPoint.h"
       7             : #include "AliRunLoader.h"
       8             : 
       9         118 : ClassImp(AliITSRecPointContainer)
      10             : 
      11             : //////////////////////////////////////////////////////////////////////
      12             : // Class to store ITS RecPoints for the duration of                 //
      13             : // one event processing                                             //
      14             : // The container is cleared at each event and new RP                //
      15             : // are loaded from TTree                                            //
      16             : // Origin masera@to.infn.it  Nov. 12 2009                           //
      17             : //////////////////////////////////////////////////////////////////////
      18             : 
      19             : /* $Id$ */
      20             : 
      21             : AliITSRecPointContainer* AliITSRecPointContainer::fgInstance = 0x0;
      22             : 
      23             : //______________________________________________________________________
      24           2 : AliITSRecPointContainer::AliITSRecPointContainer(const AliITSRecoParam* krp):TObject(),
      25           2 : fSPDNModules(0),
      26           2 : fSDDNModules(0),
      27           2 : fSSDNModules(0),
      28           2 : fArray(),
      29           2 : fCurrentEve(-1000),
      30           2 : fNextEvent(-1000),
      31           2 : fActualSize(0),
      32           2 : fDet(""),
      33          12 : fStatusOK(kTRUE){
      34             :   // Default constructor
      35             : 
      36          28 :   for(Int_t i=0;i<6;i++)fNClusters[i]=0;
      37           2 :   if(fgkNModules != AliITSgeomTGeo::GetNModules())AliError(Form("The total number of modules is not %d, but %d",fgkNModules,AliITSgeomTGeo::GetNModules()));
      38             : 
      39           2 :   Int_t modperlay[6];
      40          28 :   for(Int_t i=0;i<6;i++)modperlay[i]=AliITSgeomTGeo::GetNDetectors(1+i)*AliITSgeomTGeo::GetNLadders(1+i);
      41           2 :   fSPDNModules=modperlay[0]+modperlay[1];
      42           2 :   fSDDNModules=modperlay[2]+modperlay[3];
      43           2 :   fSSDNModules=modperlay[4]+modperlay[5];
      44             :   //  AliInfo(Form("Total modules: %d \n SPD modules=%d , SDD modules=%d, SSD modules=%d ",fgkNModules,fSPDNModules,fSDDNModules,fSSDNModules));
      45             : 
      46             :   // kLimits[0:5] --> low fluw; kLimits[6,11] --> High flux
      47             :   const Int_t kLimits[12]={25,25,20,20,10,10,300,300,200,200,100,100};
      48             :   Int_t offset=0;
      49           2 :   if(!krp){
      50           0 :     AliWarning("AliITSRecoParam is missing. Using defaults");
      51             :   }
      52             :   else {
      53           2 :     if(krp->GetEventSpecie() & AliRecoParam::kHighMult)offset=6;
      54             :   }
      55           2 :   Int_t maxval[6];
      56           2 :   TString values="";
      57          28 :   for(Int_t i=0;i<6;i++){
      58          12 :     maxval[i]=kLimits[i+offset];
      59          12 :     values+=maxval[i];
      60          12 :     values+=" ";
      61          22 :     if(i>0)modperlay[i]+=modperlay[i-1];
      62             :   }
      63           8 :   AliInfo(Form("Container created with sizes/layer: %s",values.Data()));
      64             :   Int_t layer=0;
      65        8796 :   for(Int_t i=0;i<fgkNModules;i++){
      66        4406 :     if(i>=modperlay[layer])++layer;
      67       13188 :     fArray[i]=new TClonesArray("AliITSRecPoint",maxval[layer]);
      68             :   }
      69           4 : }
      70             : 
      71             : 
      72             : //______________________________________________________________________
      73          12 : AliITSRecPointContainer::~AliITSRecPointContainer(){
      74             :   // Destructor
      75        8796 :   for(Int_t i=0;i<fgkNModules;i++){
      76        4396 :     if(fArray[i]){
      77        4396 :       fArray[i]->Delete();
      78        8792 :       delete fArray[i];
      79             :     }
      80             :   }
      81           6 : }
      82             : 
      83             : //______________________________________________________________________
      84             : void AliITSRecPointContainer::CookEntries(){
      85             :   // From the number of entries in TTree R, the number of ITS subdetectors
      86             :   // active for the present run is inferred
      87          24 :   if(fActualSize == fgkNModules)fDet="ALL SPD SDD SSD ";
      88           8 :   if(fActualSize == fSPDNModules) fDet = "SPD ";
      89           8 :   if(fActualSize == fSDDNModules) fDet = "SDD ";
      90           8 :   if(fActualSize == fSSDNModules)fDet = "SSD ";
      91           8 :   if(fActualSize == (fSPDNModules+fSDDNModules)) fDet = "SPD SDD ";
      92           8 :   if(fActualSize == (fSPDNModules+fSSDNModules))fDet = "SPD SSD ";
      93           8 :   if(fActualSize == (fSDDNModules+fSSDNModules))fDet = "SDD SSD ";
      94           8 :   if((!fDet.Contains("SPD")) && (!fDet.Contains("SDD")) &&
      95           0 :      (!fDet.Contains("SSD"))){
      96           0 :     AliError(Form("The number of active modules %d does not correspond to any standard configuration of the detector",fActualSize));
      97           0 :     fStatusOK = kFALSE;
      98           0 :   }
      99           8 : }
     100             : //______________________________________________________________________
     101             : TClonesArray* AliITSRecPointContainer::FetchClusters(Int_t mod, TTree* tR){
     102             :   // retrieves Recpoints for module mod (offline mode: the event number is
     103             :   // retrieved via the AliRunLoader object)
     104             :   // The actual access to the RP TTree is done as follows:
     105             :   // If the AliRunLoader object exists, the event number is taken from it
     106             :   // If not, the data member fNextEvent is used. 
     107             :   // To set fNextEvent it is necessary to call PrepareToRead in advance.
     108             :   // if this is never done, fNextEvent will have its default negative value
     109             :   // and an error message will be delivered.
     110         312 :   AliRunLoader* rl = AliRunLoader::Instance();
     111             :   Int_t cureve;
     112         156 :   if(rl){
     113         156 :     cureve = rl->GetEventNumber();
     114         156 :   }
     115           0 :   else if(fNextEvent>=0){
     116             :     cureve = fNextEvent;
     117             :   }
     118             :   else {
     119           0 :     AliError("The RunLoader is not defined, PrepareToRead was not invoked. Revise calling sequence. Nothing done");
     120           0 :     return NULL;
     121             :   }
     122         156 :   return FetchClusters(mod,tR,cureve);
     123         156 : }
     124             : //______________________________________________________________________
     125             : TClonesArray* AliITSRecPointContainer::FetchClusters(Int_t mod, TTree* tR,Int_t cureve){
     126             :   // retrieves Recpoints for module mod
     127             :   // cureve is the current event number. If it is different w.r.t.
     128             :   // the event number stored in fCurrentEve, the recpoints are read from
     129             :   // the TTree. Otherwise, the RP stored in memory are used. 
     130         312 :   if(cureve != fCurrentEve){
     131           8 :     fCurrentEve = cureve;
     132           8 :     Reset();
     133             :     TBranch *branch = NULL;
     134           8 :     branch = tR->GetBranch("ITSRecPoints");
     135           8 :     if(!branch){
     136           0 :       AliError("Branch ITSRecPoints not found on ITS recpoints TTree");
     137           0 :       fStatusOK = kFALSE;
     138           0 :       return NULL;
     139             :     }
     140             : 
     141           8 :     fActualSize = branch->GetEntries();
     142           8 :     CookEntries();
     143           8 :     if(fDet.IsNull())return NULL;
     144             :     // it is assumed that the filling order of the tree is SPD, SDD, SSD
     145             :     // even if one or two subdetector are missing
     146           8 :     Int_t modL1=AliITSgeomTGeo::GetNDetectors(1)*AliITSgeomTGeo::GetNLadders(1);
     147           8 :     if(IsSPDActive()){
     148        3856 :       for(Int_t i=0;i<fSPDNModules;i++){
     149        1920 :         branch->SetAddress(&fArray[i]);
     150        1920 :         branch->GetEvent(i);
     151        3840 :         if(i<modL1){
     152        2560 :           fNClusters[0]+=fArray[i]->GetEntries();
     153         640 :         }
     154             :         else {
     155        1280 :           fNClusters[1]+=fArray[i]->GetEntries();
     156             :         }
     157             :       }
     158           8 :     }
     159           8 :     if(IsSDDActive()){
     160             :       Int_t start=0;
     161          16 :       if(IsSPDActive())start+=fSPDNModules;
     162           8 :       Int_t modL3=AliITSgeomTGeo::GetNDetectors(3)*AliITSgeomTGeo::GetNLadders(3);
     163           8 :       Int_t counter = fSPDNModules;
     164        4176 :       for(Int_t i=start;i<start+fSDDNModules;i++){
     165        2080 :         branch->SetAddress(&fArray[counter]);
     166        2080 :         ++counter;
     167        2080 :         branch->GetEvent(i);
     168        4160 :         if((i-start)<modL3){
     169        2752 :           fNClusters[2]+=fArray[i]->GetEntries();
     170         672 :         }
     171             :         else {
     172        1408 :           fNClusters[3]+=fArray[i]->GetEntries();
     173             :         }
     174             :       }
     175           8 :     }
     176           8 :     if(IsSSDActive()){
     177             :       Int_t start=0;
     178          16 :       if(IsSPDActive())start+=fSPDNModules;
     179          16 :       if(IsSDDActive())start+=fSDDNModules;
     180           8 :       Int_t modL5=AliITSgeomTGeo::GetNDetectors(5)*AliITSgeomTGeo::GetNLadders(5);
     181           8 :       Int_t counter = fSPDNModules+fSDDNModules;
     182       27184 :       for(Int_t i=start;i<start+fSSDNModules;i++){
     183       13584 :         branch->SetAddress(&fArray[counter]);
     184       13584 :         ++counter;
     185       13584 :         branch->GetEvent(i);
     186       27168 :         if((i-start)<modL5){
     187       19568 :           fNClusters[4]+=fArray[i]->GetEntries();
     188        5984 :         }
     189             :         else {
     190        7600 :           fNClusters[5]+=fArray[i]->GetEntries();
     191             :         }
     192             :       }
     193           8 :     }
     194           8 :   }
     195             : 
     196         156 :   if(CheckBoundaries(mod)){
     197         156 :     return fArray[mod];
     198             :   }
     199             :   else {
     200           0 :     AliError(Form("Module %d is out of boundaries",mod));
     201           0 :     return NULL;
     202             :   }
     203             :   
     204         156 : }
     205             : //______________________________________________________________________
     206             : UInt_t AliITSRecPointContainer::GetNClustersInLayer(Int_t lay, TTree* tR, Int_t eventN){
     207             :   // returns the number of clusters for laier lay
     208             :   // layers are numbered from 1 to 6
     209          32 :   if(lay<1 || lay >6){
     210           0 :     AliError(Form("Layer %d is out of range",lay));
     211           0 :     return 0;
     212             :   }
     213          16 :   if(eventN>=0){
     214           0 :     FetchClusters(0,tR,eventN);
     215           0 :   }
     216             :   else {
     217          16 :     FetchClusters(0,tR);
     218             :   }
     219          16 :   return fNClusters[lay-1];
     220          16 : }
     221             : //______________________________________________________________________
     222             : UInt_t AliITSRecPointContainer::GetNClustersInLayerFast(Int_t lay) const {
     223             :   // returns the number of clusters for laier lay
     224             :   // layers are numbered from 1 to 6
     225             :   // No checks are done on the event number: the numer of clusters 
     226             :   // for the event stored in memory is returned
     227         560 :   if(lay<1 || lay >6){
     228           0 :     AliError(Form("Layer %d is out of range",lay));
     229           0 :     return 0;
     230             :   }
     231         280 :   return fNClusters[lay-1];
     232         280 : }
     233             : //______________________________________________________________________
     234             : AliITSRecPointContainer* AliITSRecPointContainer::Instance(const AliITSRecoParam* kptr){
     235             :   // returns AliITSRecPointContainer instance (singleton)
     236       10750 :   if(!fgInstance){
     237           4 :     if(!kptr){
     238           6 :       fgInstance =  new AliITSRecPointContainer(AliITSReconstructor::GetRecoParam());
     239           2 :     }
     240             :     else {
     241           2 :     fgInstance = new AliITSRecPointContainer(kptr);
     242             :     }
     243             :   }
     244        5375 :   return fgInstance;
     245           0 : }
     246             : 
     247             : //______________________________________________________________________
     248             : void AliITSRecPointContainer::Destroy(){
     249             :   // deletes the singleton
     250           4 :   if(fgInstance){
     251           4 :     delete fgInstance;
     252           2 :     fgInstance = NULL;
     253           2 :   }
     254           2 : }
     255             : 
     256             : //______________________________________________________________________
     257             : void AliITSRecPointContainer::Reset(){
     258             :   // Resets the status of the object
     259          32 :   ClearClus(0,fgkNModules);
     260          16 :   fDet="";
     261         224 :   for(Int_t i=0;i<6;i++)fNClusters[i]=0;
     262          16 : }
     263             : //______________________________________________________________________
     264             : void AliITSRecPointContainer::ResetSPD(){
     265             :   // Resets only the entries in fArray concerning SPD
     266             :   // This method should be used with care only when the filling
     267             :   // of the container is not done from the RP TTree. 
     268           0 :   fCurrentEve = -1000;  // protection: if FetchClusters method will be used
     269             :                           // after this call, an ccess to the RP TTree will
     270             :                           // be forced
     271           0 :   ClearClus(0,fSPDNModules);
     272           0 : }
     273             : 
     274             : //______________________________________________________________________
     275             : void AliITSRecPointContainer::ResetSDD(){
     276             :   // Resets only the entries in fArray concerning SDD
     277             :   // This method should be used with care only when the filling
     278             :   // of the container is not done from the RP TTree. 
     279           0 :   fCurrentEve = -1000;  // protection: if FetchClusters method will be used
     280             :                           // after this call, an ccess to the RP TTree will
     281             :                           // be forced
     282           0 :   Int_t first = fSPDNModules;
     283           0 :   Int_t last = first + fSDDNModules; 
     284           0 :   ClearClus(first,last);
     285           0 : }
     286             : 
     287             : //______________________________________________________________________
     288             : void AliITSRecPointContainer::ResetSSD(){
     289             :   // Resets only the entries in fArray concerning SSD
     290             :   // This method should be used with care only when the filling
     291             :   // of the container is not done from the RP TTree. 
     292           0 :   fCurrentEve = -1000;  // protection: if FetchClusters method will be used
     293             :                           // after this call, an ccess to the RP TTree will
     294             :                           // be forced
     295           0 :   Int_t first = fSPDNModules + fSDDNModules;
     296           0 :   Int_t last = first + fSSDNModules; 
     297           0 :   ClearClus(first,last);
     298           0 : }
     299             : 

Generated by: LCOV version 1.11