5 // Test macro for the TRD code
11 sim.SetConfigFile("$(ALICE_ROOT)/TRD/Macros/AliTRDconfig.C");
12 sim.SetLoadAlignFromCDB(0);
15 // Analyze the TRD hits
16 if (rc = AliTRDanalyzeHits()) return rc;
19 //if (rc = AliTRDanalyzeDigits()) return rc;
25 //_____________________________________________________________________________
26 Int_t AliTRDanalyzeHits()
29 // Analyzes the hits and fills QA-histograms
34 //AliRunLoader *rl = gAlice->GetRunLoader();
35 AliRunLoader *rl = AliRunLoader::Open("TRD_test.root"
36 ,AliConfig::GetDefaultEventFolderName());
38 cout << "<AliTRDanalyzeHits> No RunLoader found" << endl;
43 AliLoader* loader = rl->GetLoader("TRDLoader");
45 cout << "<AliTRDanalyzeHits> No TRDLoader found" << endl;
55 // Get the pointer to the TRD detector
56 gAlice = rl->GetAliRun();
57 AliTRD *trd = (AliTRD *) gAlice->GetDetector("TRD");
59 cout << "<AliTRDanalyzeHits> No TRD detector found" << endl;
64 // Get the pointer to the geometry object
67 geo = (AliTRDgeometry *) trd->GetGeometry();
70 cout << "<AliTRDanalyzeHits> No TRD geometry found" << endl;
75 AliTRDCommonParam *par = AliTRDCommonParam::Instance();
77 // Define the histograms
78 TH1F *hQdedx = new TH1F("hQdedx","Charge dedx-hits",100,0.0,1000.0);
79 TH1F *hQtr = new TH1F("hQtr" ,"Charge TR-hits" ,100,0.0,1000.0);
81 Float_t rmin = geo->Rmin();
82 Float_t rmax = geo->Rmax();
83 Float_t length = geo->GetChamberLength(0,2);
84 Float_t width = geo->GetChamberWidth(0);
85 Int_t ncol = par->GetColMax(0);
86 Int_t nrow = par->GetRowMax(0,2,13);
87 Int_t ntime = ((Int_t) (rmax - rmin) / 22.0);
89 TH2F *hZY = new TH2F("hZY" ,"Y vs Z (chamber 0)", nrow,-length/2.,length/2.
91 TH2F *hXZ = new TH2F("hXZ" ,"Z vs X (plane 0)" , ncol, -width/2., width/2.
92 , nrow,-length/2.,length/2.);
94 // Get the pointer hit tree
95 TTree *hitTree = loader->TreeH();
97 cout << "<AliTRDanalyzeHits> No hit tree found" << endl;
105 // Get the number of entries in the hit tree
106 // (Number of primary particles creating a hit somewhere)
107 Int_t nTrack = (Int_t) hitTree->GetEntries();
108 cout << "<AliTRDanalyzeHits> Found " << nTrack
109 << " primary particles with hits" << endl;
111 // Loop through all entries in the tree
112 for (Int_t iTrack = 0; iTrack < nTrack; iTrack++) {
115 nBytes += hitTree->GetEvent(iTrack);
117 // Loop through the TRD hits
119 AliTRDhit *hit = (AliTRDhit *) trd->FirstHit(-1);
125 Float_t x = hit->X();
126 Float_t y = hit->Y();
127 Float_t z = hit->Z();
128 Float_t q = hit->GetCharge();
129 Int_t track = hit->Track();
130 Int_t det = hit->GetDetector();
131 Int_t plane = geo->GetPlane(det);
141 hQtr->Fill(TMath::Abs(q));
144 hit = (AliTRDhit *) trd->NextHit();
150 cout << "<AliTRDanalyzeHits> Found " << countHits << " hits in total" << endl;
152 TCanvas *cHits = new TCanvas("cHits","AliTRDanalyzeHits",50,50,600,600);
169 //_____________________________________________________________________________
170 Int_t AliTRDanalyzeDigits()
173 // Analyzes the digits
178 const Int_t kNpla = AliTRDgeometry::Nplan();
181 cout << "<AliTRDanalyzeDigits> No AliRun object found" << endl;
186 AliRunLoader *rl = gAlice->GetRunLoader();
188 cout << "<AliTRDanalyzeHits> No RunLoader found" << endl;
193 // Import the Trees for the event nEvent in the file
196 AliLoader* loader = rl->GetLoader("TRDLoader");
198 cout << "<AliTRDanalyzeHits> No TRDLoader found" << endl;
203 // Get the pointer to the TRD detector
204 AliTRD *trd = (AliTRD *) gAlice->GetDetector("TRD");
206 cout << "<AliTRDanalyzeDigits> No TRD detector found" << endl;
211 // Get the parameter object
212 AliTRDSimParam *parSim = AliTRDSimParam::Instance();
213 AliTRDCommonParam *parCom = AliTRDCommonParam::Instance();
214 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
216 // Define the histograms
217 Int_t adcRange = ((Int_t) parSim->GetADCoutRange());
218 TH1F *hAmpAll = new TH1F("hAmpAll" ,"Amplitude of the digits (all)"
219 ,adcRange+1,-0.5,((Float_t) adcRange)+0.5);
220 TH1F *hAmpEl = new TH1F("hAmpEl" ,"Amplitude of the digits (electrons)"
221 ,adcRange+1,-0.5,((Float_t) adcRange)+0.5);
222 TH1F *hAmpPi = new TH1F("hAmpPi" ,"Amplitude of the digits (pions)"
223 ,adcRange+1,-0.5,((Float_t) adcRange)+0.5);
224 TH1F *hAmpNoise = new TH1F("hAmpNoise","Amplitude of the digits (noise)"
227 // Get the pointer to the geometry object
230 geo = trd->GetGeometry();
233 cout << "<AliTRDanalyzeDigits> No TRD geometry found" << endl;
238 // Create the digits manager
239 AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
240 digitsManager->SetDebug(1);
242 // Read the digits from the file
243 if (!(digitsManager->ReadDigits(loader->TreeD()))) {
244 cout << "<AliTRDanalyzeDigits> Cannot read the digits" << endl;
249 // Get the particle stack
250 AliStack *kineStack = rl->Stack();
252 cout << "<AliTRDanalyzeDigits> Cannot find the KINE stack" << endl;
257 Int_t countDigits = 0;
260 Int_t timeMax = cal->GetNumberOfTimeBins();
262 TProfile *hAmpTimeEl = new TProfile("hAmpTimeEl","Amplitude of the digits (electrons)"
263 ,timeMax,-0.5,((Double_t) timeMax)-0.5);
264 TProfile *hAmpTimePi = new TProfile("hAmpTimePi","Amplitude of the digits (pions)"
265 ,timeMax,-0.5,((Double_t) timeMax)-0.5);
267 // Loop over all planes
268 for (Int_t iPla = 0; iPla < kNpla; iPla++) {
270 Int_t iDet = geo->GetDetector(iPla,iCha,iSec);
271 Int_t rowMax = parCom->GetRowMax(iPla,iCha,iSec);
272 Int_t colMax = parCom->GetColMax(iPla);
274 // Loop through the detector pixel
275 for (Int_t time = 0; time < timeMax; time++) {
276 for (Int_t col = 0; col < colMax; col++) {
277 for (Int_t row = 0; row < rowMax; row++) {
279 AliTRDdigit *digit = digitsManager->GetDigit(row,col,time,iDet);
280 Int_t amp = digit->GetAmp();
281 Int_t track0 = digitsManager->GetTrack(0,row,col,time,iDet);
282 Int_t track1 = digitsManager->GetTrack(1,row,col,time,iDet);
283 TParticle *particle = 0;
285 particle = (TParticle *) kineStack->Particle(track0);
297 hAmpNoise->Fill(amp);
301 if ((particle) && (particle->GetPdgCode() == 11) && (track1 < 0)) {
303 hAmpTimeEl->Fill(time,amp);
307 if ((particle) && (particle->GetPdgCode() == -211) && (track1 < 0)) {
309 hAmpTimePi->Fill(time,amp);
320 cout << "<AliTRDanalyzeDigits> Found " << countDigits << " digits in total" << endl;
322 TCanvas *cDigits = new TCanvas("cDigits","AliTRDanalyzeDigits",100,100,600,800);
323 cDigits->Divide(2,3);
326 hAmpAll->SetXTitle("Amplitude (ADC-channels)");
327 hAmpAll->SetYTitle("Entries");
331 hAmpNoise->SetXTitle("Amplitude (ADC-channels)");
332 hAmpNoise->SetYTitle("Entries");
336 hAmpEl->SetXTitle("Amplitude (ADC-channels)");
337 hAmpEl->SetYTitle("Entries");
341 hAmpPi->SetXTitle("Amplitude (ADC-channels)");
342 hAmpPi->SetYTitle("Entries");
345 hAmpTimeEl->SetXTitle("Timebin number");
346 hAmpTimeEl->SetYTitle("Mean amplitude");
347 hAmpTimeEl->Draw("HIST");
349 hAmpTimePi->SetXTitle("Timebin number");
350 hAmpTimePi->SetYTitle("Mean amplitude");
351 hAmpTimePi->Draw("HIST");