1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // Time Projection Chamber //
21 // This class contains the basic functions for the Time Projection Chamber //
22 // detector. Functions specific to one particular geometry are //
23 // contained in the derived classes //
27 <img src="picts/AliTPCClass.gif">
32 ///////////////////////////////////////////////////////////////////////////////
36 #include <Riostream.h>
41 #include <TGeoGlobalMagField.h>
42 #include <TInterpreter.h>
45 #include <TObjectTable.h>
46 #include <TParticle.h>
49 #include <TStopwatch.h>
54 #include <TVirtualMC.h>
55 #include <TParameter.h>
57 #include "AliDigits.h"
58 #include "AliHeader.h"
62 #include "AliRunLoader.h"
63 #include "AliSimDigits.h"
66 #include "AliTPCDigitsArray.h"
67 #include "AliTPCLoader.h"
68 #include "AliTPCPRF2D.h"
69 #include "AliTPCParamSR.h"
70 #include "AliTPCRF1D.h"
71 #include "AliTPCTrackHitsV2.h"
72 #include "AliTrackReference.h"
75 #include "AliTPCDigitizer.h"
76 #include "AliTPCBuffer.h"
77 #include "AliTPCDDLRawData.h"
79 #include "AliTPCcalibDB.h"
80 #include "AliTPCRecoParam.h"
81 #include "AliTPCCalPad.h"
82 #include "AliTPCCalROC.h"
83 #include "AliTPCExB.h"
84 #include "AliTPCCorrection.h"
85 #include "AliCTPTimeParams.h"
86 #include "AliRawReader.h"
87 #include "AliTPCRawStreamV3.h"
88 #include "TTreeStream.h"
91 //_____________________________________________________________________________
92 AliTPC::AliTPC():AliDetector(),
102 fPrimaryIonisation(0),
114 // Default constructor
117 for(Int_t i=0;i<4;i++) fCurrentIndex[i]=0;
119 // fTrackHitsOld = 0;
120 #if ROOT_VERSION_CODE >= ROOT_VERSION(4,0,1)
121 fHitType = 4; // ROOT containers
123 fHitType = 2; //default CONTAINERS - based on ROOT structure
127 //_____________________________________________________________________________
128 AliTPC::AliTPC(const char *name, const char *title)
129 : AliDetector(name,title),
139 fPrimaryIonisation(0),
151 // Standard constructor
155 // Initialise arrays of hits and digits
156 fHits = new TClonesArray("AliTPChit", 176);
157 gAlice->GetMCApp()->AddHitList(fHits);
159 fTrackHits = new AliTPCTrackHitsV2;
160 fTrackHits->SetHitPrecision(0.002);
161 fTrackHits->SetStepPrecision(0.003);
162 fTrackHits->SetMaxDistance(100);
164 //fTrackHitsOld = new AliTPCTrackHits; //MI - 13.09.2000
165 //fTrackHitsOld->SetHitPrecision(0.002);
166 //fTrackHitsOld->SetStepPrecision(0.003);
167 //fTrackHitsOld->SetMaxDistance(100);
170 #if ROOT_VERSION_CODE >= ROOT_VERSION(4,0,1)
171 fHitType = 4; // ROOT containers
176 for(Int_t i=0;i<4;i++) fCurrentIndex[i]=0;
181 // Initialise color attributes
182 //PH SetMarkerColor(kYellow);
185 // Set TPC parameters
189 if (!strcmp(title,"Ne-CO2") || !strcmp(title,"Ne-CO2-N") || !strcmp(title,"Default") ) {
190 fTPCParam = AliTPCcalibDB::Instance()->GetParameters();
193 AliWarning("In Config.C you must set non-default parameters.");
198 void AliTPC::CreateDebugStremer(){
200 // Create Debug streamer to check simulation
202 fDebugStreamer = new TTreeSRedirector("TPCSimdebug.root");
204 //_____________________________________________________________________________
215 delete fTrackHits; //MI 15.09.2000
216 // delete fTrackHitsOld; //MI 10.12.2001
219 delete [] fNoiseTable;
220 delete [] fActiveSectors;
221 if (fDebugStreamer) delete fDebugStreamer;
224 //_____________________________________________________________________________
225 void AliTPC::AddHit(Int_t track, Int_t *vol, Float_t *hits)
228 // Add a hit to the list
231 TClonesArray &lhits = *fHits;
232 new(lhits[fNhits++]) AliTPChit(fIshunt,track,vol,hits);
235 AddHit2(track,vol,hits);
238 //_____________________________________________________________________________
239 void AliTPC::CreateMaterials()
241 //-----------------------------------------------
242 // Create Materials for for TPC simulations
243 //-----------------------------------------------
245 //-----------------------------------------------------------------
246 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
247 //-----------------------------------------------------------------
249 Int_t iSXFLD=((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ();
250 Float_t sXMGMX=((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max();
252 Float_t amat[7]; // atomic numbers
253 Float_t zmat[7]; // z
254 Float_t wmat[7]; // proportions
260 //***************** Gases *************************
263 //--------------------------------------------------------------
264 // gases - air and CO2
265 //--------------------------------------------------------------
281 AliMixture(10,"CO2",amat,zmat,density,2,wmat);
296 AliMixture(11,"Air",amat,zmat,density,2,wmat);
298 //----------------------------------------------------------------
299 // drift gases 5 mixtures, 5 materials
300 //----------------------------------------------------------------
302 // Drift gases 1 - nonsensitive, 2 - sensitive, 3 - for Kr
303 // Composition by % of volume, values at 20deg and 1 atm.
305 // get the geometry title - defined in Config.C
307 //--------------------------------------------------------------
308 // predefined gases, composition taken from param file
309 //--------------------------------------------------------------
310 TString names[6]={"Ne","Ar","CO2","N","CF4","CH4"};
312 Float_t *comp = fTPCParam->GetComposition();
314 // 0-Ne, 1-Ar, 2-CO2, 3-N, 4-CF4, 5-CH4
326 // elements' atomic numbers
342 wmol[2]=44.0098; //CO2
343 wmol[3]=2.*14.0067; //N2
344 wmol[4]=88.0046; //CF4
345 wmol[5]=16.011; //CH4
347 Float_t wtot=0.; //total mass of the mixture
348 for(Int_t i =0;i<6;i++){
349 wtot += *(comp+i)*wmol[i];
351 wmat[0]=comp[0]*amat[0]/wtot; //Ne
352 wmat[1]=comp[1]*amat[1]/wtot; //Ar
353 wmat[2]=(comp[2]*amat[2]+comp[4]*amat[2]+comp[5]*amat[2])/wtot; //C
354 wmat[3]=comp[2]*amat[3]*2./wtot; //O
355 wmat[4]=comp[3]*amat[4]*2./wtot; //N
356 wmat[5]=comp[4]*amat[5]*4./wtot; //F
357 wmat[6]=comp[5]*amat[6]*4./wtot; //H
361 Float_t dens[6]={0.839e-3,1.661e-3,1.842e-3,1.251e-3,3.466e-3,0.668e-3};
364 for(Int_t i=0;i<6;i++){
365 density += comp[i]*dens[i];
371 for(Int_t i =0;i<6;i++){
378 TString gname1,gname2,gname3;
379 gname1 = gname + "-1";
380 gname2 = gname + "-2";
381 gname3 = gname + "-3";
383 // take only elements with nonzero weights
385 Float_t amat1[6],zmat1[6],wmat1[6];
387 for(Int_t i=0;i<7;i++){
397 AliMixture(12,gname1.Data(),amat1,zmat1,density,cnt,wmat1); // nonsensitive
398 AliMixture(13,gname2.Data(),amat1,zmat1,density,cnt,wmat1); // sensitive
399 AliMixture(40,gname3.Data(),amat1,zmat1,density,cnt,wmat1); //sensitive Kr
403 //----------------------------------------------------------------------
405 //----------------------------------------------------------------------
427 AliMixture(14,"Kevlar",amat,zmat,density,-4,wmat);
448 AliMixture(15,"NOMEX",amat,zmat,density,-4,wmat);
466 AliMixture(16,"Makrolon",amat,zmat,density,-3,wmat);
484 AliMixture(17, "Tedlar",amat,zmat,density,-3,wmat);
502 AliMixture(18, "Mylar",amat,zmat,density,-3,wmat);
503 // material for "prepregs"
504 // Epoxy - C14 H20 O3
507 // prepreg1 60% C-fiber, 40% epoxy (vol)
522 AliMixture(19, "Prepreg1",amat,zmat,density,3,wmat);
524 //prepreg2 60% glass-fiber, 40% epoxy
543 AliMixture(20, "Prepreg2",amat,zmat,density,4,wmat);
545 //prepreg3 50% glass-fiber, 50% epoxy
564 AliMixture(21, "Prepreg3",amat,zmat,density,4,wmat);
566 // G10 60% SiO2 40% epoxy
585 AliMixture(22, "G10",amat,zmat,density,4,wmat);
594 AliMaterial(23,"Al",amat[0],zmat[0],density,999.,999.);
596 // Si (for electronics
603 AliMaterial(24,"Si",amat[0],zmat[0],density,999.,999.);
612 AliMaterial(25,"Cu",amat[0],zmat[0],density,999.,999.);
630 AliMixture(33,"Brass",amat,zmat,density,2,wmat);
632 // Epoxy - C14 H20 O3
648 AliMixture(26,"Epoxy",amat,zmat,density,-3,wmat);
650 // Epoxy - C14 H20 O3 for glue
668 AliMixture(35,"Epoxy1",amat,zmat,density,-3,wmat);
670 // epoxy film - 90% epoxy, 10% glass fiber
690 AliMixture(34, "Epoxy-film",amat,zmat,density,4,wmat);
708 AliMixture(27,"Plexiglas",amat,zmat,density,-3,wmat);
716 AliMaterial(28,"C",amat[0],zmat[0],density,999.,999.);
718 // Fe (steel for the inner heat screen)
726 AliMaterial(29,"Fe",amat[0],zmat[0],density,999.,999.);
728 // Peek - (C6H4-O-OC6H4-O-C6H4-CO)n
743 AliMixture(30,"Peek",amat,zmat,density,-3,wmat);
758 AliMixture(31,"Alumina",amat,zmat,density,-2,wmat);
760 // Ceramics for resistors
775 AliMixture(36,"Alumina1",amat,zmat,density,-2,wmat);
793 AliMixture(32,"Water",amat,zmat,density,-2,wmat);
796 //----------------------------------------------------------
797 // tracking media for gases
798 //----------------------------------------------------------
800 AliMedium(0, "Air", 11, 0, iSXFLD, sXMGMX, 10., 999., .1, .01, .1);
801 AliMedium(1, "DriftGas1", 12, 0, iSXFLD, sXMGMX, 10., 999.,.1,.001, .001);
802 AliMedium(2, "DriftGas2", 13, 1, iSXFLD, sXMGMX, 10., 999.,.1,.001, .001);
803 AliMedium(3,"CO2",10,0, iSXFLD, sXMGMX, 10., 999.,.1, .001, .001);
804 AliMedium(20, "DriftGas3", 40, 1, iSXFLD, sXMGMX, 10., 999.,.1,.001, .001);
805 //-----------------------------------------------------------
806 // tracking media for solids
807 //-----------------------------------------------------------
809 AliMedium(4,"Al",23,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
810 AliMedium(5,"Kevlar",14,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
811 AliMedium(6,"Nomex",15,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
812 AliMedium(7,"Makrolon",16,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
813 AliMedium(8,"Mylar",18,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
814 AliMedium(9,"Tedlar",17,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
816 AliMedium(10,"Prepreg1",19,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
817 AliMedium(11,"Prepreg2",20,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
818 AliMedium(12,"Prepreg3",21,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
819 AliMedium(13,"Epoxy",26,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
821 AliMedium(14,"Cu",25,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
822 AliMedium(15,"Si",24,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
823 AliMedium(16,"G10",22,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
824 AliMedium(17,"Plexiglas",27,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
825 AliMedium(18,"Steel",29,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
826 AliMedium(19,"Peek",30,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
827 AliMedium(21,"Alumina",31,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
828 AliMedium(22,"Water",32,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
829 AliMedium(23,"Brass",33,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
830 AliMedium(24,"Epoxyfm",34,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
831 AliMedium(25,"Epoxy1",35,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
832 AliMedium(26,"Alumina1",36,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
835 void AliTPC::GenerNoise(Int_t tablesize)
838 //Generate table with noise
845 if (fNoiseTable) delete[] fNoiseTable;
846 fNoiseTable = new Float_t[tablesize];
847 fNoiseDepth = tablesize;
848 fCurrentNoise =0; //!index of the noise in the noise table
850 Float_t norm = fTPCParam->GetNoise()*fTPCParam->GetNoiseNormFac();
851 for (Int_t i=0;i<tablesize;i++) fNoiseTable[i]= gRandom->Gaus(0,norm);
854 Float_t AliTPC::GetNoise()
856 // get noise from table
857 // if ((fCurrentNoise%10)==0)
858 // fCurrentNoise= gRandom->Rndm()*fNoiseDepth;
859 if (fCurrentNoise>=fNoiseDepth) fCurrentNoise=0;
860 return fNoiseTable[fCurrentNoise++];
861 //gRandom->Gaus(0, fTPCParam->GetNoise()*fTPCParam->GetNoiseNormFac());
865 Bool_t AliTPC::IsSectorActive(Int_t sec) const
868 // check if the sector is active
869 if (!fActiveSectors) return kTRUE;
870 else return fActiveSectors[sec];
873 void AliTPC::SetActiveSectors(Int_t * sectors, Int_t n)
875 // activate interesting sectors
876 SetTreeAddress();//just for security
877 if (!fActiveSectors) fActiveSectors = new Bool_t[fTPCParam->GetNSector()];
878 for (Int_t i=0;i<fTPCParam->GetNSector();i++) fActiveSectors[i]=kFALSE;
879 for (Int_t i=0;i<n;i++)
880 if ((sectors[i]>=0) && sectors[i]<fTPCParam->GetNSector()) fActiveSectors[sectors[i]]=kTRUE;
884 void AliTPC::SetActiveSectors(Int_t flag)
887 // activate sectors which were hitted by tracks
889 SetTreeAddress();//just for security
890 if (fHitType==0) return; // if Clones hit - not short volume ID information
891 if (!fActiveSectors) fActiveSectors = new Bool_t[fTPCParam->GetNSector()];
893 for (Int_t i=0;i<fTPCParam->GetNSector();i++) fActiveSectors[i]=kTRUE;
896 for (Int_t i=0;i<fTPCParam->GetNSector();i++) fActiveSectors[i]=kFALSE;
897 //TBranch * branch=0;
898 if (fLoader->TreeH() == 0x0)
900 AliFatal("Can not find TreeH in folder");
903 //if (fHitType>1) branch = fLoader->TreeH()->GetBranch("TPC2");
904 if (fHitType>1) fLoader->TreeH()->GetBranch("TPC2");
905 //else branch = fLoader->TreeH()->GetBranch("TPC");
906 else fLoader->TreeH()->GetBranch("TPC");
907 Stat_t ntracks = fLoader->TreeH()->GetEntries();
908 // loop over all hits
909 AliDebug(1,Form("Got %d tracks", (Int_t) ntracks));
911 for(Int_t track=0;track<ntracks;track++) {
914 if (fTrackHits && fHitType&4) {
915 TBranch * br1 = fLoader->TreeH()->GetBranch("fVolumes");
916 TBranch * br2 = fLoader->TreeH()->GetBranch("fNVolumes");
917 br1->GetEvent(track);
918 br2->GetEvent(track);
919 Int_t *volumes = fTrackHits->GetVolumes();
920 for (Int_t j=0;j<fTrackHits->GetNVolumes(); j++) {
921 if (volumes[j]>-1 && volumes[j]<fTPCParam->GetNSector()) {
922 fActiveSectors[volumes[j]]=kTRUE;
925 AliError(Form("Volume %d -> sector number %d is outside (0..%d)",
928 fTPCParam->GetNSector()));
934 // if (fTrackHitsOld && fHitType&2) {
935 // TBranch * br = fLoader->TreeH()->GetBranch("fTrackHitsInfo");
936 // br->GetEvent(track);
937 // AliObjectArray * ar = fTrackHitsOld->fTrackHitsInfo;
938 // for (UInt_t j=0;j<ar->GetSize();j++){
939 // fActiveSectors[((AliTrackHitsInfo*)ar->At(j))->fVolumeID] =kTRUE;
948 //_____________________________________________________________________________
949 void AliTPC::Digits2Raw()
951 // convert digits of the current event to raw data
953 static const Int_t kThreshold = 0;
955 fLoader->LoadDigits();
956 TTree* digits = fLoader->TreeD();
958 AliError("No digits tree");
964 AliSimDigits* digrow = &digarr;
965 digits->GetBranch("Segment")->SetAddress(&digrow);
967 const char* fileName = "AliTPCDDL.dat";
968 AliTPCBuffer* buffer = new AliTPCBuffer(fileName);
972 // 2: txt files with digits
973 //BE CAREFUL, verbose level 2 MUST be used only for debugging and
974 //it is highly suggested to use this mode only for debugging digits files
975 //reasonably small, because otherwise the size of the txt files can reach
976 //quickly several MB wasting time and disk space.
977 buffer->SetVerbose(0);
979 Int_t nEntries = Int_t(digits->GetEntries());
980 Int_t previousSector = -1;
982 for (Int_t i = 0; i < nEntries; i++) {
985 fTPCParam->AdjustSectorRow(digarr.GetID(), sector, row);
986 if(previousSector != sector) {
988 previousSector = sector;
991 if (sector < 36) { //inner sector [0;35]
993 //the whole row is written into the output file
994 buffer->WriteRowBinary(kThreshold, digrow, 0, 0, 0,
995 sector, subSector, row);
997 //only the pads in the range [37;48] are written into the output file
998 buffer->WriteRowBinary(kThreshold, digrow, 37, 48, 1,
999 sector, subSector, row);
1001 //only the pads outside the range [37;48] are written into the output file
1002 buffer->WriteRowBinary(kThreshold, digrow, 37, 48, 2,
1003 sector, subSector, row);
1006 } else { //outer sector [36;71]
1007 if (row == 54) subSector = 2;
1008 if ((row != 27) && (row != 76)) {
1009 buffer->WriteRowBinary(kThreshold, digrow, 0, 0, 0,
1010 sector, subSector, row);
1011 } else if (row == 27) {
1012 //only the pads outside the range [43;46] are written into the output file
1013 buffer->WriteRowBinary(kThreshold, digrow, 43, 46, 2,
1014 sector, subSector, row);
1016 //only the pads in the range [43;46] are written into the output file
1017 buffer->WriteRowBinary(kThreshold, digrow, 43, 46, 1,
1018 sector, subSector, row);
1019 } else if (row == 76) {
1020 //only the pads outside the range [33;88] are written into the output file
1021 buffer->WriteRowBinary(kThreshold, digrow, 33, 88, 2,
1022 sector, subSector, row);
1024 //only the pads in the range [33;88] are written into the output file
1025 buffer->WriteRowBinary(kThreshold, digrow, 33, 88, 1,
1026 sector, subSector, row);
1032 fLoader->UnloadDigits();
1034 AliTPCDDLRawData rawWriter;
1035 rawWriter.SetVerbose(0);
1037 rawWriter.RawData(fileName);
1038 gSystem->Unlink(fileName);
1043 //_____________________________________________________________________________
1044 Bool_t AliTPC::Raw2SDigits(AliRawReader* rawReader){
1045 // Converts the TPC raw data into summable digits
1046 // The method is used for merging simulated and
1048 if (fLoader->TreeS() == 0x0 ) {
1049 fLoader->MakeTree("S");
1052 if(fDefaults == 0) SetDefaults(); // check if the parameters are set
1054 //setup TPCDigitsArray
1055 if(GetDigitsArray()) delete GetDigitsArray();
1057 AliTPCDigitsArray *arr = new AliTPCDigitsArray;
1058 arr->SetClass("AliSimDigits");
1059 arr->Setup(fTPCParam);
1060 arr->MakeTree(fLoader->TreeS());
1062 SetDigitsArray(arr);
1064 // set zero suppression to "0"
1065 fTPCParam->SetZeroSup(0);
1067 // Loop over sectors
1068 const Int_t kmaxTime = fTPCParam->GetMaxTBin();
1069 const Int_t kNIS = fTPCParam->GetNInnerSector();
1070 const Int_t kNOS = fTPCParam->GetNOuterSector();
1071 const Int_t kNS = kNIS + kNOS;
1074 AliTPCROC * roc = AliTPCROC::Instance();
1075 Int_t nRowsMax = roc->GetNRows(roc->GetNSector()-1);
1076 Int_t nPadsMax = roc->GetNPads(roc->GetNSector()-1,nRowsMax-1);
1077 Short_t** allBins = new Short_t*[nRowsMax];
1078 for (Int_t iRow = 0; iRow < nRowsMax; iRow++) {
1079 Int_t maxBin = kmaxTime*nPadsMax;
1080 allBins[iRow] = new Short_t[maxBin];
1081 memset(allBins[iRow],0,sizeof(Short_t)*maxBin);
1084 for(Int_t iSector = 0; iSector < kNS; iSector++) {
1086 Int_t nRows = fTPCParam->GetNRow(iSector);
1087 Int_t nDDLs = 0, indexDDL = 0;
1088 if (iSector < kNIS) {
1090 indexDDL = iSector * 2;
1094 indexDDL = (iSector-kNIS) * 4 + kNIS * 2;
1097 // Load the raw data for corresponding DDLs
1100 AliTPCAltroMapping** mapping =AliTPCcalibDB::Instance()->GetMapping();
1101 AliTPCRawStreamV3 input(rawReader,(AliAltroMapping**)mapping);
1102 rawReader->Select("TPC",indexDDL,indexDDL+nDDLs-1);
1105 for (Int_t iRow = 0; iRow < nRowsMax; iRow++) {
1106 Int_t maxBin = kmaxTime*nPadsMax;
1107 memset(allBins[iRow],0,sizeof(Short_t)*maxBin);
1110 // Begin loop over altro data
1111 while (input.NextDDL()) {
1113 if (input.GetSector() != iSector)
1114 AliFatal(Form("Sector index mismatch ! Expected (%d), but got (%d) !",iSector,input.GetSector()));
1117 while ( input.NextChannel() ) {
1119 Int_t iRow = input.GetRow();
1120 if (iRow < 0 || iRow >= nRows)
1121 AliFatal(Form("Pad-row index (%d) outside the range (%d -> %d) !",
1122 iRow, 0, nRows -1));
1123 Int_t iPad = input.GetPad();
1125 Int_t maxPad = fTPCParam->GetNPads(iSector,iRow);
1127 if (iPad < 0 || iPad >= maxPad)
1128 AliFatal(Form("Pad index (%d) outside the range (%d -> %d) !",
1129 iPad, 0, maxPad -1));
1132 while ( input.NextBunch() ){
1133 Int_t startTbin = (Int_t)input.GetStartTimeBin();
1134 Int_t bunchlength = (Int_t)input.GetBunchLength();
1135 const UShort_t *sig = input.GetSignals();
1136 for (Int_t iTime = 0; iTime<bunchlength; iTime++){
1137 Int_t iTimeBin=startTbin-iTime;
1138 if ( iTimeBin < 0 || iTimeBin >= kmaxTime) {
1140 //AliFatal(Form("Timebin index (%d) outside the range (%d -> %d) !",
1141 // iTimeBin, 0, kmaxTime -1));
1144 Int_t maxBin = kmaxTime*maxPad;
1145 if (((iPad*kmaxTime+iTimeBin) >= maxBin) ||
1146 ((iPad*kmaxTime+iTimeBin) < 0))
1147 AliFatal(Form("Index outside the allowed range"
1148 " Sector=%d Row=%d Pad=%d Timebin=%d"
1149 " (Max.index=%d)",iSector,iRow,iPad,iTimeBin,maxBin));
1150 allBins[iRow][iPad*kmaxTime+iTimeBin] = sig[iTime];
1153 } // End loop over altro data
1156 // Now fill the digits array
1157 if (fDigitsArray->GetTree()==0) {
1158 AliFatal("Tree not set in fDigitsArray");
1161 for (Int_t iRow = 0; iRow < nRows; iRow++) {
1162 AliDigits * dig = fDigitsArray->CreateRow(iSector,iRow);
1163 Int_t maxPad = fTPCParam->GetNPads(iSector,iRow);
1164 for(Int_t iPad = 0; iPad < maxPad; iPad++) {
1165 for(Int_t iTimeBin = 0; iTimeBin < kmaxTime; iTimeBin++) {
1166 Short_t q = allBins[iRow][iPad*kmaxTime + iTimeBin];
1167 if (q <= 0) continue;
1169 dig->SetDigitFast((Short_t)q,iTimeBin,iPad);
1170 ((AliSimDigits*)dig)->SetTrackIDFast( 3141593, iTimeBin,iPad,0);
1173 fDigitsArray->StoreRow(iSector,iRow);
1174 Int_t ndig = dig->GetDigitSize();
1177 Form("*** Sector, row, compressed digits %d %d %d ***\n",
1178 iSector,iRow,ndig));
1180 fDigitsArray->ClearRow(iSector,iRow);
1182 } // end of the sector digitization
1184 // get LHC clock phase from the digits tree
1186 TParameter<float> *ph;
1188 TTree *digtree = fLoader->TreeD();
1190 if(digtree){ // if TreeD exists
1191 ph = (TParameter<float>*)digtree->GetUserInfo()->FindObject("lhcphase0");
1192 phase = ph->GetVal();
1194 else{ //TreeD does not exist
1198 // store lhc clock phase in S-digits tree
1200 fLoader->TreeS()->GetUserInfo()->Add(new TParameter<float>("lhcphase0",phase));
1202 fLoader->WriteSDigits("OVERWRITE");
1204 if(GetDigitsArray()) delete GetDigitsArray();
1205 SetDigitsArray(0x0);
1208 for (Int_t iRow = 0; iRow < nRowsMax; iRow++)
1209 delete [] allBins[iRow];
1215 //______________________________________________________________________
1216 AliDigitizer* AliTPC::CreateDigitizer(AliDigitizationInput* digInput) const
1218 return new AliTPCDigitizer(digInput);
1221 void AliTPC::SDigits2Digits2(Int_t /*eventnumber*/)
1223 //create digits from summable digits
1224 GenerNoise(500000); //create teble with noise
1226 //conect tree with sSDigits
1227 TTree *t = fLoader->TreeS();
1230 fLoader->LoadSDigits("READ");
1231 t = fLoader->TreeS();
1233 AliError("Can not get input TreeS");
1238 if (fLoader->TreeD() == 0x0) fLoader->MakeTree("D");
1240 AliSimDigits digarr, *dummy=&digarr;
1241 TBranch* sdb = t->GetBranch("Segment");
1243 AliError("Can not find branch with segments in TreeS.");
1247 sdb->SetAddress(&dummy);
1249 Stat_t nentries = t->GetEntries();
1251 // set zero suppression
1253 fTPCParam->SetZeroSup(2);
1255 // get zero suppression
1257 Int_t zerosup = fTPCParam->GetZeroSup();
1259 //make tree with digits
1261 AliTPCDigitsArray *arr = new AliTPCDigitsArray;
1262 arr->SetClass("AliSimDigits");
1263 arr->Setup(fTPCParam);
1264 arr->MakeTree(fLoader->TreeD());
1266 AliTPCParam * par = fTPCParam;
1268 //Loop over segments of the TPC
1270 for (Int_t n=0; n<nentries; n++) {
1273 if (!par->AdjustSectorRow(digarr.GetID(),sec,row)) {
1274 AliWarning(Form("Invalid segment ID ! %d",digarr.GetID()));
1277 if (!IsSectorActive(sec)) continue;
1279 AliSimDigits * digrow =(AliSimDigits*) arr->CreateRow(sec,row);
1280 Int_t nrows = digrow->GetNRows();
1281 Int_t ncols = digrow->GetNCols();
1283 digrow->ExpandBuffer();
1284 digarr.ExpandBuffer();
1285 digrow->ExpandTrackBuffer();
1286 digarr.ExpandTrackBuffer();
1289 Short_t * pamp0 = digarr.GetDigits();
1290 Int_t * ptracks0 = digarr.GetTracks();
1291 Short_t * pamp1 = digrow->GetDigits();
1292 Int_t * ptracks1 = digrow->GetTracks();
1293 Int_t nelems =nrows*ncols;
1294 Int_t saturation = fTPCParam->GetADCSat() - 1;
1295 //use internal structure of the AliDigits - for speed reason
1296 //if you cahnge implementation
1297 //of the Alidigits - it must be rewriten -
1298 for (Int_t i= 0; i<nelems; i++){
1299 Float_t q = TMath::Nint(Float_t(*pamp0)/16.+GetNoise());
1301 if (q>saturation) q=saturation;
1304 ptracks1[0]=ptracks0[0];
1305 ptracks1[nelems]=ptracks0[nelems];
1306 ptracks1[2*nelems]=ptracks0[2*nelems];
1314 arr->StoreRow(sec,row);
1315 arr->ClearRow(sec,row);
1320 fLoader->WriteDigits("OVERWRITE");
1324 //__________________________________________________________________
1325 void AliTPC::SetDefaults(){
1327 // setting the defaults
1330 // Set response functions
1333 AliRunLoader* rl = (AliRunLoader*)fLoader->GetEventFolder()->FindObject(AliRunLoader::GetRunLoaderName());
1335 //AliTPCParamSR *param=(AliTPCParamSR*)gDirectory->Get("75x40_100x60");
1336 //gDirectory->Get("75x40_100x60");
1337 AliTPCParamSR *param = (AliTPCParamSR*)AliTPCcalibDB::Instance()->GetParameters();
1339 AliFatal("No TPC parameters found");
1342 if (!param->IsGeoRead()){
1344 // read transformation matrices for gGeoManager
1346 param->ReadGeoMatrices();
1351 AliTPCPRF2D * prfinner = new AliTPCPRF2D;
1352 AliTPCPRF2D * prfouter1 = new AliTPCPRF2D;
1353 AliTPCPRF2D * prfouter2 = new AliTPCPRF2D;
1356 //AliTPCRF1D * rf = new AliTPCRF1D(kTRUE);
1357 //rf->SetGauss(param->GetZSigma(),param->GetZWidth(),1.);
1358 //rf->SetOffset(3*param->GetZSigma());
1363 char strgamma4[1000];
1364 //sprintf(strgamma4,"AliTPCRF1D::Gamma4((x-0.135+%f)*%f,55,160)",3*param->GetZSigma(), 1000000000*param->GetTSample()/param->GetZWidth());
1366 snprintf(strgamma4,1000,"AliTPCRF1D::Gamma4((x-0.135+%f)*%f,55,160)",3*param->GetZSigma(), 1000000000*param->GetTSample()/param->GetZWidth());
1367 TF1 * fgamma4 = new TF1("fgamma4",strgamma4, -1,1);
1368 AliTPCRF1D * rf = new AliTPCRF1D(kTRUE,1000);
1369 rf->SetParam(fgamma4,param->GetZWidth(), 1,0.2);
1370 rf->SetOffset(3*param->GetZSigma());
1372 TDirectory *savedir=gDirectory;
1375 printf ("TPC MWPC readout\n");
1376 TFile *f=TFile::Open("$ALICE_ROOT/TPC/AliTPCprf2d.root");
1378 AliFatal("Can't open $ALICE_ROOT/TPC/AliTPCprf2d.root !");
1381 prfinner->Read("prf_07504_Gati_056068_d02");
1382 //PH Set different names
1383 s=prfinner->GetGRF()->GetName();
1385 prfinner->GetGRF()->SetName(s.Data());
1387 prfouter1->Read("prf_10006_Gati_047051_d03");
1388 s=prfouter1->GetGRF()->GetName();
1390 prfouter1->GetGRF()->SetName(s.Data());
1392 prfouter2->Read("prf_15006_Gati_047051_d03");
1393 s=prfouter2->GetGRF()->GetName();
1395 prfouter2->GetGRF()->SetName(s.Data());
1400 printf ("TPC GEM readout\n");
1401 TFile *f=TFile::Open("$ALICE_ROOT/TPC/AliTPCprf2dGEM.root");
1403 AliFatal("Can't open $ALICE_ROOT/TPC/AliTPCprf2dGEM.root !");
1406 prfinner->Read("prf0");
1407 //PH Set different names
1408 s=prfinner->GetGRF()->GetName();
1410 prfinner->GetGRF()->SetName(s.Data());
1412 prfouter1->Read("prf1");
1413 s=prfouter1->GetGRF()->GetName();
1415 prfouter1->GetGRF()->SetName(s.Data());
1417 prfouter2->Read("prf2");
1418 s=prfouter2->GetGRF()->GetName();
1420 prfouter2->GetGRF()->SetName(s.Data());
1425 param->SetInnerPRF(prfinner);
1426 param->SetOuter1PRF(prfouter1);
1427 param->SetOuter2PRF(prfouter2);
1428 param->SetTimeRF(rf);
1438 //__________________________________________________________________
1439 void AliTPC::Hits2Digits()
1442 // creates digits from hits
1444 if (!fTPCParam->IsGeoRead()){
1446 // read transformation matrices for gGeoManager
1448 fTPCParam->ReadGeoMatrices();
1451 fLoader->LoadHits("read");
1452 fLoader->LoadDigits("recreate");
1453 AliRunLoader* runLoader = fLoader->GetRunLoader();
1455 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
1456 //PH runLoader->GetEvent(iEvent);
1457 Hits2Digits(iEvent);
1460 fLoader->UnloadHits();
1461 fLoader->UnloadDigits();
1463 //__________________________________________________________________
1464 void AliTPC::Hits2Digits(Int_t eventnumber)
1466 //----------------------------------------------------
1467 // Loop over all sectors for a single event
1468 //----------------------------------------------------
1469 AliRunLoader* rl = (AliRunLoader*)fLoader->GetEventFolder()->FindObject(AliRunLoader::GetRunLoaderName());
1470 rl->GetEvent(eventnumber);
1472 if (fLoader->TreeH() == 0x0) {
1473 if(fLoader->LoadHits()) {
1474 AliError("Can not load hits.");
1479 if (fLoader->TreeD() == 0x0 ) {
1480 fLoader->MakeTree("D");
1481 if (fLoader->TreeD() == 0x0 ) {
1482 AliError("Can not get TreeD");
1487 if(fDefaults == 0) SetDefaults(); // check if the parameters are set
1488 GenerNoise(500000); //create teble with noise
1490 //setup TPCDigitsArray
1492 if(GetDigitsArray()) delete GetDigitsArray();
1494 AliTPCDigitsArray *arr = new AliTPCDigitsArray;
1495 arr->SetClass("AliSimDigits");
1496 arr->Setup(fTPCParam);
1498 arr->MakeTree(fLoader->TreeD());
1499 SetDigitsArray(arr);
1501 fDigitsSwitch=0; // standard digits
1502 // here LHC clock phase
1504 switch (fLHCclockPhaseSw){
1511 lhcph = (Int_t)(gRandom->Rndm()/0.25);
1515 // not implemented yet
1518 // adding phase to the TreeD user info
1519 fLoader->TreeD()->GetUserInfo()->Add(new TParameter<float>("lhcphase0",lhcph));
1521 for(Int_t isec=0;isec<fTPCParam->GetNSector();isec++)
1522 if (IsSectorActive(isec)) {
1523 AliDebug(1,Form("Hits2Digits: Sector %d is active.",isec));
1524 Hits2DigitsSector(isec);
1527 AliDebug(1,Form("Hits2Digits: Sector %d is NOT active.",isec));
1530 fLoader->WriteDigits("OVERWRITE");
1532 //this line prevents the crash in the similar one
1533 //on the beginning of this method
1534 //destructor attempts to reset the tree, which is deleted by the loader
1535 //need to be redesign
1536 if(GetDigitsArray()) delete GetDigitsArray();
1537 SetDigitsArray(0x0);
1541 //__________________________________________________________________
1542 void AliTPC::Hits2SDigits2(Int_t eventnumber)
1545 //-----------------------------------------------------------
1546 // summable digits - 16 bit "ADC", no noise, no saturation
1547 //-----------------------------------------------------------
1549 //----------------------------------------------------
1550 // Loop over all sectors for a single event
1551 //----------------------------------------------------
1553 AliRunLoader* rl = fLoader->GetRunLoader();
1555 rl->GetEvent(eventnumber);
1556 if (fLoader->TreeH() == 0x0) {
1557 if(fLoader->LoadHits()) {
1558 AliError("Can not load hits.");
1565 if (fLoader->TreeS() == 0x0 ) {
1566 fLoader->MakeTree("S");
1569 if(fDefaults == 0) SetDefaults();
1571 GenerNoise(500000); //create table with noise
1572 //setup TPCDigitsArray
1574 if(GetDigitsArray()) delete GetDigitsArray();
1577 AliTPCDigitsArray *arr = new AliTPCDigitsArray;
1578 arr->SetClass("AliSimDigits");
1579 arr->Setup(fTPCParam);
1580 arr->MakeTree(fLoader->TreeS());
1582 SetDigitsArray(arr);
1584 fDigitsSwitch=1; // summable digits
1586 // set zero suppression to "0"
1587 // here LHC clock phase
1589 switch (fLHCclockPhaseSw){
1596 lhcph = (Int_t)(gRandom->Rndm()/0.25);
1600 // not implemented yet
1603 // adding phase to the TreeS user info
1605 fLoader->TreeS()->GetUserInfo()->Add(new TParameter<float>("lhcphase0",lhcph));
1607 fTPCParam->SetZeroSup(0);
1609 for(Int_t isec=0;isec<fTPCParam->GetNSector();isec++)
1610 if (IsSectorActive(isec)) {
1611 Hits2DigitsSector(isec);
1614 fLoader->WriteSDigits("OVERWRITE");
1616 //this line prevents the crash in the similar one
1617 //on the beginning of this method
1618 //destructor attempts to reset the tree, which is deleted by the loader
1619 //need to be redesign
1620 if(GetDigitsArray()) delete GetDigitsArray();
1621 SetDigitsArray(0x0);
1623 //__________________________________________________________________
1625 void AliTPC::Hits2SDigits()
1628 //-----------------------------------------------------------
1629 // summable digits - 16 bit "ADC", no noise, no saturation
1630 //-----------------------------------------------------------
1632 if (!fTPCParam->IsGeoRead()){
1634 // read transformation matrices for gGeoManager
1636 fTPCParam->ReadGeoMatrices();
1639 fLoader->LoadHits("read");
1640 fLoader->LoadSDigits("recreate");
1641 AliRunLoader* runLoader = fLoader->GetRunLoader();
1643 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
1644 runLoader->GetEvent(iEvent);
1647 Hits2SDigits2(iEvent);
1650 fLoader->UnloadHits();
1651 fLoader->UnloadSDigits();
1652 if (fDebugStreamer) {
1653 delete fDebugStreamer;
1657 //_____________________________________________________________________________
1659 void AliTPC::Hits2DigitsSector(Int_t isec)
1661 //-------------------------------------------------------------------
1662 // TPC conversion from hits to digits.
1663 //-------------------------------------------------------------------
1665 //-----------------------------------------------------------------
1666 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
1667 //-----------------------------------------------------------------
1669 //-------------------------------------------------------
1670 // Get the access to the track hits
1671 //-------------------------------------------------------
1673 // check if the parameters are set - important if one calls this method
1674 // directly, not from the Hits2Digits
1676 if(fDefaults == 0) SetDefaults();
1678 TTree *tH = fLoader->TreeH(); // pointer to the hits tree
1680 AliFatal("Can not find TreeH in folder");
1684 Stat_t ntracks = tH->GetEntries();
1686 Int_t nrows =fTPCParam->GetNRow(isec);
1688 TObjArray **row=new TObjArray* [nrows+2]; // 2 extra rows for cross talk
1689 for(Int_t j=0;j<nrows+2;j++) row[j]=0;
1691 MakeSector(isec,nrows,tH,ntracks,row);
1693 //--------------------------------------------------------
1694 // Digitize this sector, row by row
1695 // row[i] is the pointer to the TObjArray of TVectors,
1696 // each one containing electrons accepted on this
1697 // row, assigned into tracks
1698 //--------------------------------------------------------
1702 if (fDigitsArray->GetTree()==0) {
1703 AliFatal("Tree not set in fDigitsArray");
1706 for (i=0;i<nrows;i++){
1708 AliDigits * dig = fDigitsArray->CreateRow(isec,i);
1710 DigitizeRow(i,isec,row);
1712 fDigitsArray->StoreRow(isec,i);
1714 Int_t ndig = dig->GetDigitSize();
1717 Form("*** Sector, row, compressed digits %d %d %d ***\n",
1720 fDigitsArray->ClearRow(isec,i);
1723 } // end of the sector digitization
1725 for(i=0;i<nrows+2;i++){
1730 delete [] row; // delete the array of pointers to TObjArray-s
1733 } // end of Hits2DigitsSector
1736 //_____________________________________________________________________________
1737 void AliTPC::DigitizeRow(Int_t irow,Int_t isec,TObjArray **rows)
1739 //-----------------------------------------------------------
1740 // Single row digitization, coupling from the neighbouring
1741 // rows taken into account
1742 //-----------------------------------------------------------
1744 //-----------------------------------------------------------------
1745 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
1746 // Modified: Marian Ivanov GSI Darmstadt, m.ivanov@gsi.de
1747 //-----------------------------------------------------------------
1749 Float_t zerosup = fTPCParam->GetZeroSup();
1750 AliTPCCalPad * gainTPC = AliTPCcalibDB::Instance()->GetDedxGainFactor();
1751 AliTPCCalPad * noiseTPC = AliTPCcalibDB::Instance()->GetPadNoise();
1752 AliTPCCalROC * gainROC = gainTPC->GetCalROC(isec); // pad gains per given sector
1753 AliTPCCalROC * noiseROC = noiseTPC->GetCalROC(isec); // noise per given sector
1756 fCurrentIndex[1]= isec;
1759 Int_t nofPads = fTPCParam->GetNPads(isec,irow);
1760 Int_t nofTbins = fTPCParam->GetMaxTBin();
1761 Int_t indexRange[4];
1763 // Integrated signal for this row
1764 // and a single track signal
1767 TMatrixF *m1 = new TMatrixF(0,nofPads,0,nofTbins); // integrated
1768 TMatrixF *m2 = new TMatrixF(0,nofPads,0,nofTbins); // single
1770 TMatrixF &total = *m1;
1772 // Array of pointers to the label-signal list
1774 Int_t nofDigits = nofPads*nofTbins; // number of digits for this row
1775 Float_t **pList = new Float_t* [nofDigits];
1779 for(lp=0;lp<nofDigits;lp++)pList[lp]=0; // set all pointers to NULL
1785 for (Int_t row= row1;row<=row2;row++){
1786 Int_t nTracks= rows[row]->GetEntries();
1787 for (i1=0;i1<nTracks;i1++){
1788 fCurrentIndex[2]= row;
1789 fCurrentIndex[3]=irow+1;
1791 m2->Zero(); // clear single track signal matrix
1792 Float_t trackLabel = GetSignal(rows[row],i1,m2,m1,indexRange);
1793 GetList(trackLabel,nofPads,m2,indexRange,pList);
1795 else GetSignal(rows[row],i1,0,m1,indexRange);
1801 AliDigits *dig = fDigitsArray->GetRow(isec,irow);
1803 Float_t fzerosup = zerosup+0.5;
1804 for(Int_t it=0;it<nofTbins;it++){
1805 for(Int_t ip=0;ip<nofPads;ip++){
1807 Float_t q=total(ip,it);
1808 if(fDigitsSwitch == 0){
1809 Float_t gain = gainROC->GetValue(irow,ip); // get gain for given - pad-row pad
1810 Float_t noisePad = noiseROC->GetValue(irow,ip);
1813 q+=GetNoise()*noisePad;
1814 if(q <=fzerosup) continue; // do not fill zeros
1816 if(q >= fTPCParam->GetADCSat()) q = fTPCParam->GetADCSat() - 1; // saturation
1821 if(q <= 0.) continue; // do not fill zeros
1822 if(q>2000.) q=2000.;
1828 // "real" signal or electronic noise (list = -1)?
1831 for(Int_t j1=0;j1<3;j1++){
1832 tracks[j1] = (pList[gi]) ?(Int_t)(*(pList[gi]+j1)) : -2;
1837 <A NAME="AliDigits"></A>
1838 using of AliDigits object
1841 dig->SetDigitFast((Short_t)q,it,ip);
1842 if (fDigitsArray->IsSimulated()) {
1843 ((AliSimDigits*)dig)->SetTrackIDFast(tracks[0],it,ip,0);
1844 ((AliSimDigits*)dig)->SetTrackIDFast(tracks[1],it,ip,1);
1845 ((AliSimDigits*)dig)->SetTrackIDFast(tracks[2],it,ip,2);
1848 } // end of loop over time buckets
1849 } // end of lop over pads
1855 // glitch filters if normal simulated digits
1857 if(!fDigitsSwitch) ((AliSimDigits*)dig)->GlitchFilter();
1859 // This row has been digitized, delete nonused stuff
1862 for(lp=0;lp<nofDigits;lp++){
1863 if(pList[lp]) delete [] pList[lp];
1871 } // end of DigitizeRow
1873 //_____________________________________________________________________________
1875 Float_t AliTPC::GetSignal(TObjArray *p1, Int_t ntr,
1876 TMatrixF *m1, TMatrixF *m2,Int_t *indexRange)
1879 //---------------------------------------------------------------
1880 // Calculates 2-D signal (pad,time) for a single track,
1881 // returns a pointer to the signal matrix and the track label
1882 // No digitization is performed at this level!!!
1883 //---------------------------------------------------------------
1885 //-----------------------------------------------------------------
1886 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
1887 // Modified: Marian Ivanov
1888 //-----------------------------------------------------------------
1892 tv = (TVector*)p1->At(ntr); // pointer to a track
1895 Float_t label = v(0);
1896 Int_t centralPad = (fTPCParam->GetNPads(fCurrentIndex[1],fCurrentIndex[3]-1))/2;
1898 Int_t nElectrons = (tv->GetNrows()-1)/5;
1899 indexRange[0]=9999; // min pad
1900 indexRange[1]=-1; // max pad
1901 indexRange[2]=9999; //min time
1902 indexRange[3]=-1; // max time
1904 TMatrixF &signal = *m1;
1905 TMatrixF &total = *m2;
1907 // Get LHC clock phase
1909 TParameter<float> *ph;
1910 if(fDigitsSwitch){// s-digits
1911 ph = (TParameter<float>*)fLoader->TreeS()->GetUserInfo()->FindObject("lhcphase0");
1913 else{ // normal digits
1914 ph = (TParameter<float>*)fLoader->TreeD()->GetUserInfo()->FindObject("lhcphase0");
1916 // Loop over all electrons
1918 for(Int_t nel=0; nel<nElectrons; nel++){
1920 Float_t aval = v(idx+4);
1921 Float_t eltoadcfac=aval*fTPCParam->GetTotalNormFac();
1922 Float_t xyz[4]={v(idx+1),v(idx+2),v(idx+3),v(idx+5)};
1923 Int_t n = ((AliTPCParamSR*)fTPCParam)->CalcResponseFast(xyz,fCurrentIndex,
1924 fCurrentIndex[3],ph->GetVal());
1926 Int_t *index = fTPCParam->GetResBin(0);
1927 Float_t *weight = & (fTPCParam->GetResWeight(0));
1929 if (n>0) for (Int_t i =0; i<n; i++){
1930 Int_t pad=index[1]+centralPad; //in digit coordinates central pad has coordinate 0
1933 Int_t time=index[2];
1934 Float_t qweight = *(weight)*eltoadcfac;
1936 if (m1!=0) signal(pad,time)+=qweight;
1937 total(pad,time)+=qweight;
1938 if (indexRange[0]>pad) indexRange[0]=pad;
1939 if (indexRange[1]<pad) indexRange[1]=pad;
1940 if (indexRange[2]>time) indexRange[2]=time;
1941 if (indexRange[3]<time) indexRange[3]=time;
1948 } // end of loop over electrons
1950 return label; // returns track label when finished
1953 //_____________________________________________________________________________
1954 void AliTPC::GetList(Float_t label,Int_t np,TMatrixF *m,
1955 Int_t *indexRange, Float_t **pList)
1957 //----------------------------------------------------------------------
1958 // Updates the list of tracks contributing to digits for a given row
1959 //----------------------------------------------------------------------
1961 //-----------------------------------------------------------------
1962 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
1963 //-----------------------------------------------------------------
1965 TMatrixF &signal = *m;
1967 // lop over nonzero digits
1969 for(Int_t it=indexRange[2];it<indexRange[3]+1;it++){
1970 for(Int_t ip=indexRange[0];ip<indexRange[1]+1;ip++){
1973 // accept only the contribution larger than 500 electrons (1/2 s_noise)
1975 if(signal(ip,it)<0.5) continue;
1977 Int_t globalIndex = it*np+ip; // globalIndex starts from 0!
1979 if(!pList[globalIndex]){
1982 // Create new list (6 elements - 3 signals and 3 labels),
1985 pList[globalIndex] = new Float_t [6];
1989 *pList[globalIndex] = -1.;
1990 *(pList[globalIndex]+1) = -1.;
1991 *(pList[globalIndex]+2) = -1.;
1992 *(pList[globalIndex]+3) = -1.;
1993 *(pList[globalIndex]+4) = -1.;
1994 *(pList[globalIndex]+5) = -1.;
1996 *pList[globalIndex] = label;
1997 *(pList[globalIndex]+3) = signal(ip,it);
2001 // check the signal magnitude
2003 Float_t highest = *(pList[globalIndex]+3);
2004 Float_t middle = *(pList[globalIndex]+4);
2005 Float_t lowest = *(pList[globalIndex]+5);
2008 // compare the new signal with already existing list
2011 if(signal(ip,it)<lowest) continue; // neglect this track
2015 if (signal(ip,it)>highest){
2016 *(pList[globalIndex]+5) = middle;
2017 *(pList[globalIndex]+4) = highest;
2018 *(pList[globalIndex]+3) = signal(ip,it);
2020 *(pList[globalIndex]+2) = *(pList[globalIndex]+1);
2021 *(pList[globalIndex]+1) = *pList[globalIndex];
2022 *pList[globalIndex] = label;
2024 else if (signal(ip,it)>middle){
2025 *(pList[globalIndex]+5) = middle;
2026 *(pList[globalIndex]+4) = signal(ip,it);
2028 *(pList[globalIndex]+2) = *(pList[globalIndex]+1);
2029 *(pList[globalIndex]+1) = label;
2032 *(pList[globalIndex]+5) = signal(ip,it);
2033 *(pList[globalIndex]+2) = label;
2037 } // end of loop over pads
2038 } // end of loop over time bins
2041 //___________________________________________________________________
2042 void AliTPC::MakeSector(Int_t isec,Int_t nrows,TTree *TH,
2043 Stat_t ntracks,TObjArray **row)
2046 //-----------------------------------------------------------------
2047 // Prepares the sector digitization, creates the vectors of
2048 // tracks for each row of this sector. The track vector
2049 // contains the track label and the position of electrons.
2050 //-----------------------------------------------------------------
2053 // The trasport of the electrons through TPC drift volume
2054 // Drift (drift velocity + velocity map(not yet implemented)))
2055 // Application of the random processes (diffusion, gas gain)
2056 // Systematic effects (ExB effect in drift volume + ROCs)
2059 // Loop over primary electrons:
2060 // Creation of the secondary electrons
2061 // Loop over electrons (primary+ secondaries)
2062 // Global coordinate frame:
2063 // 1. Skip electrons if attached
2064 // 2. ExB effect in drift volume
2065 // a.) Simulation calib->GetExB()->CorrectInverse(dxyz0,dxyz1); (applied on the el. level)
2066 // b.) Reconstruction - calib->GetExB()->Correct(dxyz0,dxyz1); (applied on the space point)
2067 // changed to the full distrotion (not only due to the ExB)
2068 // aNew.) correction->DistortPoint(distPoint, sector);
2069 // bNew.) correction->CorrectPoint(distPoint, sector);
2070 // 3. Generation of gas gain (Random - Exponential distribution)
2071 // 4. TransportElectron function (diffusion)
2073 // 5. Conversion to the local coordinate frame pad-row, pad, timebin
2074 // 6. Apply Time0 shift - AliTPCCalPad class
2075 // a.) Plus sign in simulation
2076 // b.) Minus sign in reconstruction
2079 //-----------------------------------------------------------------
2080 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
2081 // Origin: Marian Ivanov, marian.ivanov@cern.ch
2082 //-----------------------------------------------------------------
2083 AliTPCcalibDB* const calib=AliTPCcalibDB::Instance();
2085 AliTPCCorrection * correctionDist = calib->GetTPCComposedCorrection();
2087 AliTPCRecoParam *tpcrecoparam = calib->GetRecoParam(0); //FIXME: event specie should not be set by hand, However the parameters read here are the same for al species
2089 // AliWarning(Form("Flag for ExB correction \t%d",tpcrecoparam->GetUseExBCorrection()));
2090 // AliWarning(Form("Flag for Composed correction \t%d",calib->GetRecoParam()->GetUseComposedCorrection()));
2092 if (tpcrecoparam->GetUseExBCorrection()) {
2093 if (gAlice){ // Set correctly the magnetic field in the ExB calculation
2094 if (!calib->GetExB()){
2095 AliMagF * field = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField());
2097 calib->SetExBField(field);
2101 } else if (tpcrecoparam->GetUseComposedCorrection()) {
2102 AliMagF * field = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
2103 Double_t bzpos[3]={0,0,0};
2104 if (!correctionDist) correctionDist = calib->GetTPCComposedCorrection(field->GetBz(bzpos));
2106 if (!correctionDist){
2107 AliFatal("Correction map does not exist. Check the OCDB or your setup");
2111 Float_t gasgain = fTPCParam->GetGasGain();
2112 gasgain = gasgain/fGainFactor;
2113 // const Int_t timeStamp = 1; //where to get it? runloader->GetHeader()->GetTimeStamp(). https://savannah.cern.ch/bugs/?53025
2114 const Int_t timeStamp = fLoader->GetRunLoader()->GetHeader()->GetTimeStamp(); //?
2115 Double_t correctionHVandPT = calib->GetGainCorrectionHVandPT(timeStamp, calib->GetRun(), isec, 5 ,tpcrecoparam->GetGainCorrectionHVandPTMode());
2116 gasgain*=correctionHVandPT;
2119 Float_t xyz[5]={0,0,0,0,0};
2121 AliTPChit *tpcHit; // pointer to a sigle TPC hit
2124 if (fHitType>1) branch = TH->GetBranch("TPC2");
2125 else branch = TH->GetBranch("TPC");
2128 //----------------------------------------------
2129 // Create TObjArray-s, one for each row,
2130 // each TObjArray will store the TVectors
2131 // of electrons, one TVectors per each track.
2132 //----------------------------------------------
2134 Int_t *nofElectrons = new Int_t [nrows+2]; // electron counter for each row
2135 TVector **tracks = new TVector* [nrows+2]; //pointers to the track vectors
2137 for(i=0; i<nrows+2; i++){
2138 row[i] = new TObjArray;
2145 //--------------------------------------------------------------------
2146 // Loop over tracks, the "track" contains the full history
2147 //--------------------------------------------------------------------
2149 Int_t previousTrack,currentTrack;
2150 previousTrack = -1; // nothing to store so far!
2152 for(Int_t track=0;track<ntracks;track++){
2153 Bool_t isInSector=kTRUE;
2155 isInSector = TrackInVolume(isec,track);
2156 if (!isInSector) continue;
2158 branch->GetEntry(track); // get next track
2162 tpcHit = (AliTPChit*)FirstHit(-1);
2164 //--------------------------------------------------------------
2166 //--------------------------------------------------------------
2171 Int_t sector=tpcHit->fSector; // sector number
2173 tpcHit = (AliTPChit*) NextHit();
2177 // Remove hits which arrive before the TPC opening gate signal
2178 if(((fTPCParam->GetZLength(isec)-TMath::Abs(tpcHit->Z()))
2179 /fTPCParam->GetDriftV()+tpcHit->Time())<fTPCParam->GetGateDelay()) {
2180 tpcHit = (AliTPChit*) NextHit();
2184 currentTrack = tpcHit->Track(); // track number
2186 if(currentTrack != previousTrack){
2188 // store already filled fTrack
2190 for(i=0;i<nrows+2;i++){
2191 if(previousTrack != -1){
2192 if(nofElectrons[i]>0){
2193 TVector &v = *tracks[i];
2194 v(0) = previousTrack;
2195 tracks[i]->ResizeTo(5*nofElectrons[i]+1); // shrink if necessary
2196 row[i]->Add(tracks[i]);
2199 delete tracks[i]; // delete empty TVector
2205 tracks[i] = new TVector(601); // TVectors for the next fTrack
2207 } // end of loop over rows
2209 previousTrack=currentTrack; // update track label
2212 Int_t qI = (Int_t) (tpcHit->fQ); // energy loss (number of electrons)
2214 //---------------------------------------------------
2215 // Calculate the electron attachment probability
2216 //---------------------------------------------------
2219 Float_t time = 1.e6*(fTPCParam->GetZLength(isec)-TMath::Abs(tpcHit->Z()))
2220 /fTPCParam->GetDriftV();
2222 Float_t attProb = fTPCParam->GetAttCoef()*
2223 fTPCParam->GetOxyCont()*time; // fraction!
2225 //-----------------------------------------------
2226 // Loop over electrons
2227 //-----------------------------------------------
2230 for(Int_t nel=0;nel<qI;nel++){
2231 // skip if electron lost due to the attachment
2232 if((gRandom->Rndm(0)) < attProb) continue; // electron lost!
2233 // use default hit position
2238 // ExB effect - distort hig if specifiend in the RecoParam
2240 if (tpcrecoparam->GetUseExBCorrection()) {
2241 Double_t dxyz0[3],dxyz1[3];
2242 dxyz0[0]=tpcHit->X();
2243 dxyz0[1]=tpcHit->Y();
2244 dxyz0[2]=tpcHit->Z();
2245 if (calib->GetExB()){
2246 calib->GetExB()->CorrectInverse(dxyz0,dxyz1);
2248 AliError("Not valid ExB calibration");
2249 dxyz1[0]=tpcHit->X();
2250 dxyz1[1]=tpcHit->Y();
2251 dxyz1[2]=tpcHit->Z();
2256 } else if (tpcrecoparam->GetUseComposedCorrection()) {
2257 // Use combined correction/distortion class AliTPCCorrection
2258 if (correctionDist){
2259 Float_t distPoint[3]={tpcHit->X(),tpcHit->Y(), tpcHit->Z()};
2260 correctionDist->DistortPoint(distPoint, isec);
2261 xyz[0]=distPoint[0];
2262 xyz[1]=distPoint[1];
2263 xyz[2]=distPoint[2];
2269 // protection for the nonphysical avalanche size (10**6 maximum)
2271 Double_t rn=TMath::Max(gRandom->Rndm(0),1.93e-22);
2272 xyz[3]= (Float_t) (-gasgain*TMath::Log(rn));
2275 TransportElectron(xyz,index);
2277 Int_t padrow = fTPCParam->GetPadRow(xyz,index);
2279 // Add Time0 correction due unisochronity
2280 // xyz[0] - pad row coordinate
2281 // xyz[1] - pad coordinate
2282 // xyz[2] - is in now time bin coordinate system
2283 Float_t correction =0;
2284 if (tpcrecoparam->GetUseExBCorrection()) {
2285 if (calib->GetPadTime0()){
2286 if (!calib->GetPadTime0()->GetCalROC(isec)) continue;
2287 Int_t npads = fTPCParam->GetNPads(isec,padrow);
2288 // Int_t pad = TMath::Nint(xyz[1]+fTPCParam->GetNPads(isec,TMath::Nint(xyz[0]))*0.5);
2289 // pad numbering from -npads/2 .. npads/2-1
2290 Int_t pad = TMath::Nint(xyz[1]+npads/2);
2292 if (pad>=npads) pad=npads-1;
2293 correction = calib->GetPadTime0()->GetCalROC(isec)->GetValue(padrow,pad);
2294 // printf("%d\t%d\t%d\t%f\n",isec,padrow,pad,correction);
2295 if (fDebugStreamer){
2296 (*fDebugStreamer)<<"Time0"<<
2304 "cor="<<correction<<
2309 if (AliTPCcalibDB::Instance()->IsTrgL0()){
2310 // Modification 14.03
2311 // distinguish between the L0 and L1 trigger as it is done in the reconstruction
2312 // by defualt we assume L1 trigger is used - make a correction in case of L0
2313 AliCTPTimeParams* ctp = AliTPCcalibDB::Instance()->GetCTPTimeParams();
2315 //for TPC standalone runs no ctp info
2316 Double_t delay = ctp->GetDelayL1L0()*0.000000025;
2317 xyz[2]+=delay/fTPCParam->GetTSample(); // adding the delay (in the AliTPCTramsform opposite sign)
2320 if (tpcrecoparam->GetUseExBCorrection()) xyz[2]+=correction; // In Correction there is already a corretion for the time 0 offset so not needed
2321 xyz[2]+=fTPCParam->GetNTBinsL1(); // adding Level 1 time bin offset
2323 // Electron track time (for pileup simulation)
2324 xyz[2]+=tpcHit->Time()/fTPCParam->GetTSample(); // adding time of flight
2328 // row 0 - cross talk from the innermost row
2329 // row fNRow+1 cross talk from the outermost row
2330 rowNumber = index[2]+1;
2331 //transform position to local digit coordinates
2332 //relative to nearest pad row
2333 if ((rowNumber<0)||rowNumber>fTPCParam->GetNRow(isec)+1) continue;
2335 if (isec <fTPCParam->GetNInnerSector()) {
2336 x1 = xyz[1]*fTPCParam->GetInnerPadPitchWidth();
2337 y1 = fTPCParam->GetYInner(rowNumber);
2340 x1=xyz[1]*fTPCParam->GetOuterPadPitchWidth();
2341 y1 = fTPCParam->GetYOuter(rowNumber);
2343 // gain inefficiency at the wires edges - linear
2346 if(x1>y1) xyz[3]*=TMath::Max(1.e-6,(y1-x1+1.)); */
2348 nofElectrons[rowNumber]++;
2349 //----------------------------------
2350 // Expand vector if necessary
2351 //----------------------------------
2352 if(nofElectrons[rowNumber]>120){
2353 Int_t range = tracks[rowNumber]->GetNrows();
2354 if((nofElectrons[rowNumber])>(range-1)/5){
2356 tracks[rowNumber]->ResizeTo(range+500); // Add 100 electrons
2360 TVector &v = *tracks[rowNumber];
2361 Int_t idx = 5*nofElectrons[rowNumber]-4;
2362 Real_t * position = &(((TVector&)v)(idx)); //make code faster
2363 memcpy(position,xyz,5*sizeof(Float_t));
2365 } // end of loop over electrons
2367 tpcHit = (AliTPChit*)NextHit();
2369 } // end of loop over hits
2370 } // end of loop over tracks
2373 // store remaining track (the last one) if not empty
2376 for(i=0;i<nrows+2;i++){
2377 if(nofElectrons[i]>0){
2378 TVector &v = *tracks[i];
2379 v(0) = previousTrack;
2380 tracks[i]->ResizeTo(5*nofElectrons[i]+1); // shrink if necessary
2381 row[i]->Add(tracks[i]);
2390 delete [] nofElectrons;
2392 } // end of MakeSector
2395 //_____________________________________________________________________________
2399 // Initialise TPC detector after definition of geometry
2401 AliDebug(1,"*********************************************");
2404 //_____________________________________________________________________________
2405 void AliTPC::ResetDigits()
2408 // Reset number of digits and the digits array for this detector
2411 if (fDigits) fDigits->Clear();
2416 //_____________________________________________________________________________
2417 void AliTPC::SetSens(Int_t sens)
2420 //-------------------------------------------------------------
2421 // Activates/deactivates the sensitive strips at the center of
2422 // the pad row -- this is for the space-point resolution calculations
2423 //-------------------------------------------------------------
2425 //-----------------------------------------------------------------
2426 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
2427 //-----------------------------------------------------------------
2433 void AliTPC::SetSide(Float_t side=0.)
2435 // choice of the TPC side
2440 //_____________________________________________________________________________
2442 void AliTPC::TransportElectron(Float_t *xyz, Int_t *index)
2445 // electron transport taking into account:
2447 // 2.ExB at the wires
2448 // 3. nonisochronity
2450 // xyz and index must be already transformed to system 1
2453 fTPCParam->Transform1to2(xyz,index); // mis-alignment applied in this step
2456 Float_t driftl=xyz[2];
2457 if(driftl<0.01) driftl=0.01;
2458 driftl=TMath::Sqrt(driftl);
2459 Float_t sigT = driftl*(fTPCParam->GetDiffT());
2460 Float_t sigL = driftl*(fTPCParam->GetDiffL());
2461 xyz[0]=gRandom->Gaus(xyz[0],sigT);
2462 xyz[1]=gRandom->Gaus(xyz[1],sigT);
2463 xyz[2]=gRandom->Gaus(xyz[2],sigL);
2467 if (fTPCParam->GetMWPCReadout()==kTRUE){
2468 Float_t dx = fTPCParam->Transform2to2NearestWire(xyz,index);
2469 xyz[1]+=dx*(fTPCParam->GetOmegaTau());
2471 //add nonisochronity (not implemented yet)
2477 //______________________________________________________________________
2478 AliTPChit::AliTPChit()
2490 //_____________________________________________________________________________
2491 AliTPChit::AliTPChit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits)
2492 :AliHit(shunt,track),
2499 // Creates a TPC hit object
2510 //________________________________________________________________________
2511 // Additional code because of the AliTPCTrackHitsV2
2513 void AliTPC::MakeBranch(Option_t *option)
2516 // Create a new branch in the current Root Tree
2517 // The branch of fHits is automatically split
2518 // MI change 14.09.2000
2520 if (fHitType<2) return;
2521 char branchname[10];
2522 //sprintf(branchname,"%s2",GetName());
2523 snprintf(branchname,10,"%s2",GetName());
2525 // Get the pointer to the header
2526 const char *cH = strstr(option,"H");
2528 if (fTrackHits && fLoader->TreeH() && cH && fHitType&4) {
2529 AliDebug(1,"Making branch for Type 4 Hits");
2530 fLoader->TreeH()->Branch(branchname,"AliTPCTrackHitsV2",&fTrackHits,fBufferSize,99);
2533 // if (fTrackHitsOld && fLoader->TreeH() && cH && fHitType&2) {
2534 // AliDebug(1,"Making branch for Type 2 Hits");
2535 // AliObjectBranch * branch = new AliObjectBranch(branchname,"AliTPCTrackHits",&fTrackHitsOld,
2536 // fLoader->TreeH(),fBufferSize,99);
2537 // fLoader->TreeH()->GetListOfBranches()->Add(branch);
2541 void AliTPC::SetTreeAddress()
2543 //Sets tree address for hits
2545 if (fHits == 0x0 ) fHits = new TClonesArray("AliTPChit", 176);//skowron 20.06.03
2546 AliDetector::SetTreeAddress();
2548 if (fHitType>1) SetTreeAddress2();
2551 void AliTPC::SetTreeAddress2()
2554 // Set branch address for the TrackHits Tree
2559 char branchname[20];
2560 //sprintf(branchname,"%s2",GetName());
2561 snprintf(branchname,20,"%s2",GetName());
2563 // Branch address for hit tree
2564 TTree *treeH = fLoader->TreeH();
2565 if ((treeH)&&(fHitType&4)) {
2566 branch = treeH->GetBranch(branchname);
2568 branch->SetAddress(&fTrackHits);
2569 AliDebug(1,"fHitType&4 Setting");
2572 AliDebug(1,"fHitType&4 Failed (can not find branch)");
2575 // if ((treeH)&&(fHitType&2)) {
2576 // branch = treeH->GetBranch(branchname);
2578 // branch->SetAddress(&fTrackHitsOld);
2579 // AliDebug(1,"fHitType&2 Setting");
2582 // AliDebug(1,"fHitType&2 Failed (can not find branch)");
2586 void AliTPC::FinishPrimary()
2588 if (fTrackHits &&fHitType&4) fTrackHits->FlushHitStack();
2589 // if (fTrackHitsOld && fHitType&2) fTrackHitsOld->FlushHitStack();
2593 void AliTPC::AddHit2(Int_t track, Int_t *vol, Float_t *hits)
2596 // add hit to the list
2600 int primary = gAlice->GetMCApp()->GetPrimary(track);
2601 gAlice->GetMCApp()->Particle(primary)->SetBit(kKeepBit);
2605 gAlice->GetMCApp()->FlagTrack(track);
2607 if (fTrackHits && fHitType&4)
2608 fTrackHits->AddHitKartez(vol[0],rtrack, hits[0],
2609 hits[1],hits[2],(Int_t)hits[3],hits[4]);
2610 // if (fTrackHitsOld &&fHitType&2 )
2611 // fTrackHitsOld->AddHitKartez(vol[0],rtrack, hits[0],
2612 // hits[1],hits[2],(Int_t)hits[3]);
2616 void AliTPC::ResetHits()
2618 if (fHitType&1) AliDetector::ResetHits();
2619 if (fHitType>1) ResetHits2();
2622 void AliTPC::ResetHits2()
2626 if (fTrackHits && fHitType&4) fTrackHits->Clear();
2627 // if (fTrackHitsOld && fHitType&2) fTrackHitsOld->Clear();
2631 AliHit* AliTPC::FirstHit(Int_t track)
2633 if (fHitType>1) return FirstHit2(track);
2634 return AliDetector::FirstHit(track);
2636 AliHit* AliTPC::NextHit()
2641 if (fHitType>1) return NextHit2();
2643 return AliDetector::NextHit();
2646 AliHit* AliTPC::FirstHit2(Int_t track)
2649 // Initialise the hit iterator
2650 // Return the address of the first hit for track
2651 // If track>=0 the track is read from disk
2652 // while if track<0 the first hit of the current
2653 // track is returned
2656 gAlice->GetMCApp()->ResetHits();
2657 fLoader->TreeH()->GetEvent(track);
2660 if (fTrackHits && fHitType&4) {
2661 fTrackHits->First();
2662 return fTrackHits->GetHit();
2664 // if (fTrackHitsOld && fHitType&2) {
2665 // fTrackHitsOld->First();
2666 // return fTrackHitsOld->GetHit();
2672 AliHit* AliTPC::NextHit2()
2675 //Return the next hit for the current track
2678 // if (fTrackHitsOld && fHitType&2) {
2679 // fTrackHitsOld->Next();
2680 // return fTrackHitsOld->GetHit();
2684 return fTrackHits->GetHit();
2690 void AliTPC::RemapTrackHitIDs(Int_t *map)
2695 if (!fTrackHits) return;
2697 // if (fTrackHitsOld && fHitType&2){
2698 // AliObjectArray * arr = fTrackHitsOld->fTrackHitsInfo;
2699 // for (UInt_t i=0;i<arr->GetSize();i++){
2700 // AliTrackHitsInfo * info = (AliTrackHitsInfo *)(arr->At(i));
2701 // info->fTrackID = map[info->fTrackID];
2704 // if (fTrackHitsOld && fHitType&4){
2705 if (fTrackHits && fHitType&4){
2706 TClonesArray * arr = fTrackHits->GetArray();;
2707 for (Int_t i=0;i<arr->GetEntriesFast();i++){
2708 AliTrackHitsParamV2 * info = (AliTrackHitsParamV2 *)(arr->At(i));
2709 info->SetTrackID(map[info->GetTrackID()]);
2714 Bool_t AliTPC::TrackInVolume(Int_t id,Int_t track)
2716 //return bool information - is track in given volume
2717 //load only part of the track information
2718 //return true if current track is in volume
2721 // if (fTrackHitsOld && fHitType&2) {
2722 // TBranch * br = fLoader->TreeH()->GetBranch("fTrackHitsInfo");
2723 // br->GetEvent(track);
2724 // AliObjectArray * ar = fTrackHitsOld->fTrackHitsInfo;
2725 // for (UInt_t j=0;j<ar->GetSize();j++){
2726 // if ( ((AliTrackHitsInfo*)ar->At(j))->fVolumeID==id) return kTRUE;
2730 if (fTrackHits && fHitType&4) {
2731 TBranch * br1 = fLoader->TreeH()->GetBranch("fVolumes");
2732 TBranch * br2 = fLoader->TreeH()->GetBranch("fNVolumes");
2733 br2->GetEvent(track);
2734 br1->GetEvent(track);
2735 Int_t *volumes = fTrackHits->GetVolumes();
2736 Int_t nvolumes = fTrackHits->GetNVolumes();
2737 if (!volumes && nvolumes>0) {
2738 AliWarning(Form("Problematic track\t%d\t%d",track,nvolumes));
2741 for (Int_t j=0;j<nvolumes; j++)
2742 if (volumes[j]==id) return kTRUE;
2746 TBranch * br = fLoader->TreeH()->GetBranch("fSector");
2747 br->GetEvent(track);
2748 for (Int_t j=0;j<fHits->GetEntriesFast();j++){
2749 if ( ((AliTPChit*)fHits->At(j))->fSector==id) return kTRUE;
2757 AliLoader* AliTPC::MakeLoader(const char* topfoldername)
2760 fLoader = new AliTPCLoader(GetName(),topfoldername);
2764 ////////////////////////////////////////////////////////////////////////
2765 AliTPCParam* AliTPC::LoadTPCParam(TFile *file) {
2767 // load TPC paarmeters from a given file or create new if the object
2768 // is not found there
2769 // 12/05/2003 This method should be moved to the AliTPCLoader
2770 // and one has to decide where to store the TPC parameters
2773 //sprintf(paramName,"75x40_100x60_150x60");
2774 snprintf(paramName,50,"75x40_100x60_150x60");
2775 AliTPCParam *paramTPC=(AliTPCParam*)file->Get(paramName);
2777 AliDebugClass(1,Form("TPC parameters %s found.",paramName));
2779 AliWarningClass("TPC parameters not found. Create new (they may be incorrect)");
2780 //paramTPC = new AliTPCParamSR;
2781 paramTPC = AliTPCcalibDB::Instance()->GetParameters();
2782 if (!paramTPC->IsGeoRead()){
2784 // read transformation matrices for gGeoManager
2786 paramTPC->ReadGeoMatrices();
2792 // the older version of parameters can be accessed with this code.
2793 // In some cases, we have old parameters saved in the file but
2794 // digits were created with new parameters, it can be distinguish
2795 // by the name of TPC TreeD. The code here is just for the case
2796 // we would need to compare with old data, uncomment it if needed.
2798 // char paramName[50];
2799 // sprintf(paramName,"75x40_100x60");
2800 // AliTPCParam *paramTPC=(AliTPCParam*)in->Get(paramName);
2802 // cout<<"TPC parameters "<<paramName<<" found."<<endl;
2804 // sprintf(paramName,"75x40_100x60_150x60");
2805 // paramTPC=(AliTPCParam*)in->Get(paramName);
2807 // cout<<"TPC parameters "<<paramName<<" found."<<endl;
2809 // cerr<<"TPC parameters not found. Create new (they may be incorrect)."
2811 // paramTPC = new AliTPCParamSR;