]>
Commit | Line | Data |
---|---|---|
4c039060 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
16 | /* | |
17 | $Log$ | |
1450a7cd | 18 | Revision 1.26.2.2 2001/11/12 18:41:44 hristov |
19 | All the changes from the head are merged to the release | |
20 | ||
21 | Revision 1.27 2001/10/21 18:27:45 hristov | |
22 | Several pointers were set to zero in the default constructors to avoid memory management problems | |
23 | ||
2685bf00 | 24 | Revision 1.26 2001/10/04 14:30:28 coppedis |
25 | Event merging for ZDC | |
26 | ||
1acbaaa8 | 27 | Revision 1.25 2001/10/04 14:24:15 coppedis |
28 | Event merging for ZDC | |
29 | ||
b6d27557 | 30 | Revision 1.24 2001/09/26 16:03:41 coppedis |
31 | Merging implemented | |
32 | ||
359cdddc | 33 | Revision 1.23 2001/05/15 13:44:57 coppedis |
34 | Changes in AddHit method | |
35 | ||
43f34e8b | 36 | Revision 1.22 2001/05/14 09:53:32 coppedis |
37 | Adding functions ZMin and ZMax | |
38 | ||
cefa66cb | 39 | Revision 1.21 2001/04/20 10:05:02 coppedis |
40 | Minor changes | |
41 | ||
0d2bb33c | 42 | Revision 1.20 2001/03/26 13:39:20 coppedis |
43 | Comment prints | |
44 | ||
4c38d2da | 45 | Revision 1.19 2001/03/26 09:10:23 coppedis |
46 | Corrected bug in constructor (fIshunt has to be =1) | |
47 | ||
2e6fc82a | 48 | Revision 1.18 2001/03/20 08:21:55 coppedis |
49 | ZDC needs PIPE, ABSO, DIPO and SHIL | |
50 | ||
ec71d094 | 51 | Revision 1.17 2001/03/16 16:18:03 coppedis |
52 | Correction for superposition of ZDC volumes with MUON arm one | |
53 | ||
0014adbc | 54 | Revision 1.16 2001/03/15 16:01:11 coppedis |
55 | Code review | |
56 | ||
09630792 | 57 | Revision 1.15 2001/01/26 19:56:27 hristov |
58 | Major upgrade of AliRoot code | |
59 | ||
2ab0c725 | 60 | Revision 1.14 2000/12/12 13:17:01 coppedis |
61 | Minor corrections suggested by P. Hristov | |
62 | ||
65d4f2be | 63 | Revision 1.12 2000/12/01 08:19:01 coppedis |
64 | Adding a message error if ZDC is constructed without DIPO | |
65 | ||
588ed15d | 66 | Revision 1.11 2000/11/30 17:21:03 coppedis |
67 | Introduce hit array fStHits reset only at the end of the event (for digitization) | |
68 | ||
f901045b | 69 | Revision 1.10 2000/11/22 11:32:58 coppedis |
70 | Major code revision | |
71 | ||
866ab5a2 | 72 | Revision 1.9 2000/10/02 21:28:20 fca |
73 | Removal of useless dependecies via forward declarations | |
74 | ||
94de3818 | 75 | Revision 1.8 2000/07/10 13:58:01 fca |
76 | New version of ZDC from E.Scomparin & C.Oppedisano | |
77 | ||
68ca986e | 78 | Revision 1.7 2000/01/19 17:17:40 fca |
79 | ||
1cedd08a | 80 | Revision 1.6 1999/09/29 09:24:35 fca |
81 | Introduction of the Copyright and cvs Log | |
82 | ||
4c039060 | 83 | */ |
84 | ||
fe4da5cc | 85 | /////////////////////////////////////////////////////////////////////////////// |
86 | // // | |
359cdddc | 87 | // Zero Degree Calorimeter // |
88 | // This class contains the basic functions for the ZDCs; // | |
89 | // functions specific to one particular geometry are // | |
90 | // contained in the derived classes // | |
fe4da5cc | 91 | // // |
fe4da5cc | 92 | /////////////////////////////////////////////////////////////////////////////// |
93 | ||
65a824a5 | 94 | #include <stdlib.h> |
359cdddc | 95 | #include <iostream.h> |
65a824a5 | 96 | |
f901045b | 97 | // --- ROOT system |
fe4da5cc | 98 | #include <TBRIK.h> |
99 | #include <TNode.h> | |
2ab0c725 | 100 | #include <TGeometry.h> |
101 | #include <TFile.h> | |
102 | #include <TTree.h> | |
1450a7cd | 103 | #include <TDirectory.h> |
104 | #include <TF1.h> | |
fe4da5cc | 105 | |
f901045b | 106 | // --- AliRoot header files |
fe4da5cc | 107 | #include "AliZDC.h" |
f901045b | 108 | #include "AliZDCHit.h" |
b6d27557 | 109 | #include "AliZDCMergedHit.h" |
359cdddc | 110 | #include "AliZDCMerger.h" |
1450a7cd | 111 | #include "AliZDCDigit.h" |
112 | #include "AliZDCReco.h" | |
f901045b | 113 | #include "AliDetector.h" |
fe4da5cc | 114 | #include "AliCallf77.h" |
115 | #include "AliConst.h" | |
116 | #include "AliMC.h" | |
359cdddc | 117 | #include "AliRun.h" |
118 | #include "AliHeader.h" | |
fe4da5cc | 119 | |
fe4da5cc | 120 | |
121 | ClassImp(AliZDC) | |
122 | ||
123 | //_____________________________________________________________________________ | |
124 | AliZDC::AliZDC() | |
125 | { | |
126 | // | |
127 | // Default constructor for the Zero Degree Calorimeter base class | |
128 | // | |
2e6fc82a | 129 | |
1450a7cd | 130 | fIshunt = 1; |
131 | fNoShower = 0; | |
132 | fMerger = 0; | |
09630792 | 133 | |
1450a7cd | 134 | fHits = 0; |
135 | fNhits = 0; | |
09630792 | 136 | |
1450a7cd | 137 | fDigits = 0; |
138 | fNdigits = 0; | |
2685bf00 | 139 | |
140 | fMergedHits = 0; | |
1450a7cd | 141 | fTreeSD = 0; |
142 | fTreeMD = 0; | |
2685bf00 | 143 | |
144 | fNRecPoints = 0; | |
1450a7cd | 145 | fRecPoints = 0; |
359cdddc | 146 | |
fe4da5cc | 147 | } |
148 | ||
149 | //_____________________________________________________________________________ | |
150 | AliZDC::AliZDC(const char *name, const char *title) | |
151 | : AliDetector(name,title) | |
152 | { | |
153 | // | |
154 | // Standard constructor for the Zero Degree Calorimeter base class | |
155 | // | |
156 | ||
359cdddc | 157 | fIshunt = 1; |
158 | fNoShower = 0; | |
159 | fMerger = 0; | |
f901045b | 160 | |
359cdddc | 161 | // Allocate the hits array |
f901045b | 162 | fHits = new TClonesArray("AliZDCHit",1000); |
1cedd08a | 163 | gAlice->AddHitList(fHits); |
b6d27557 | 164 | // Allocate the merged hits array |
165 | fMergedHits = new TClonesArray("AliZDCMergedHit",1000); | |
f901045b | 166 | |
359cdddc | 167 | // Allocate the digits array |
168 | fDigits = new TClonesArray("AliZDCDigit",1000); | |
169 | ||
2685bf00 | 170 | fTreeSD = 0; |
171 | fTreeMD = 0; | |
172 | ||
173 | fNRecPoints = 0; | |
1450a7cd | 174 | fRecPoints = 0; |
866ab5a2 | 175 | |
176 | } | |
177 | //____________________________________________________________________________ | |
178 | AliZDC::~AliZDC() | |
179 | { | |
180 | // | |
181 | // ZDC destructor | |
182 | // | |
183 | ||
184 | fIshunt = 0; | |
359cdddc | 185 | |
b6d27557 | 186 | if(fMerger) delete fMerger; |
2e6fc82a | 187 | |
359cdddc | 188 | // if(fHits){ |
189 | // fHits->Delete(); | |
190 | // delete fHits; | |
65d4f2be | 191 | // } |
359cdddc | 192 | |
193 | // if(fDigits){ | |
194 | // fDigits->Delete(); | |
195 | // delete fDigits; | |
196 | // } | |
197 | ||
fe4da5cc | 198 | } |
fe4da5cc | 199 | //_____________________________________________________________________________ |
200 | void AliZDC::AddHit(Int_t track, Int_t *vol, Float_t *hits) | |
201 | { | |
202 | // | |
f901045b | 203 | // Add a ZDC hit to the hit list. |
204 | // -> We make use of 2 array of hits: | |
205 | // [1] fHits (the usual one) that contains hits for each PRIMARY | |
206 | // [2] fStHits that contains hits for each EVENT and is used to | |
207 | // obtain digits at the end of each event | |
fe4da5cc | 208 | // |
f901045b | 209 | |
68ca986e | 210 | static Float_t primKinEn, xImpact, yImpact, sFlag; |
211 | ||
43f34e8b | 212 | AliZDCHit *newquad, *curprimquad; |
f901045b | 213 | newquad = new AliZDCHit(fIshunt, track, vol, hits); |
65d4f2be | 214 | TClonesArray &lhits = *fHits; |
cefa66cb | 215 | |
216 | if(fNhits==0){ | |
217 | // First hit -> setting flag for primary or secondary particle | |
218 | Int_t primary = gAlice->GetPrimary(track); | |
219 | if(track != primary){ | |
220 | newquad->fSFlag = 1; // SECONDARY particle entering the ZDC | |
221 | } | |
222 | else if(track == primary){ | |
223 | newquad->fSFlag = 0; // PRIMARY particle entering the ZDC | |
224 | } | |
225 | // fNPrimaryHits += 1; | |
226 | sFlag = newquad->fSFlag; | |
227 | primKinEn = newquad->fPrimKinEn; | |
228 | xImpact = newquad->fXImpact; | |
229 | yImpact = newquad->fYImpact; | |
230 | } | |
231 | else{ | |
232 | newquad->fPrimKinEn = primKinEn; | |
233 | newquad->fXImpact = xImpact; | |
234 | newquad->fYImpact = yImpact; | |
235 | newquad->fSFlag = sFlag; | |
236 | } | |
237 | ||
43f34e8b | 238 | Int_t j; |
f901045b | 239 | for(j=0; j<fNhits; j++){ |
2e6fc82a | 240 | // If hits are equal (same track, same volume), sum them. |
f901045b | 241 | curprimquad = (AliZDCHit*) lhits[j]; |
242 | if(*curprimquad == *newquad){ | |
243 | *curprimquad = *curprimquad+*newquad; | |
244 | delete newquad; | |
68ca986e | 245 | return; |
f901045b | 246 | } |
247 | } | |
f901045b | 248 | |
249 | //Otherwise create a new hit | |
250 | new(lhits[fNhits]) AliZDCHit(newquad); | |
251 | fNhits++; | |
252 | ||
866ab5a2 | 253 | delete newquad; |
cefa66cb | 254 | } |
255 | ||
f901045b | 256 | //_____________________________________________________________________________ |
359cdddc | 257 | void AliZDC::AddDigit(Int_t *sect, Int_t digit) |
f901045b | 258 | { |
359cdddc | 259 | // |
260 | AliZDCDigit *newdigit; | |
261 | newdigit = new AliZDCDigit(sect, digit); | |
359cdddc | 262 | |
263 | // printf("\n AddDigit -> sector[0] = %d, sector[1] = %d, digit = %d", | |
264 | // sect[0], sect[1], digit); | |
265 | new((*fDigits)[fNdigits]) AliZDCDigit(*newdigit); | |
266 | fNdigits++; | |
267 | delete newdigit; | |
f901045b | 268 | } |
359cdddc | 269 | |
fe4da5cc | 270 | //_____________________________________________________________________________ |
271 | void AliZDC::BuildGeometry() | |
272 | { | |
273 | // | |
274 | // Build the ROOT TNode geometry for event display | |
275 | // in the Zero Degree Calorimeter | |
276 | // This routine is dummy for the moment | |
277 | // | |
278 | ||
68ca986e | 279 | TNode *node, *top; |
280 | TBRIK *brik; | |
359cdddc | 281 | const int kColorZDC = kBlue; |
fe4da5cc | 282 | |
283 | // | |
68ca986e | 284 | top=gAlice->GetGeometry()->GetNode("alice"); |
fe4da5cc | 285 | |
286 | // ZDC | |
fe4da5cc | 287 | brik = new TBRIK("S_ZDC","ZDC box","void",300,300,5); |
68ca986e | 288 | top->cd(); |
289 | node = new TNode("ZDC","ZDC","S_ZDC",0,0,600,""); | |
290 | node->SetLineColor(kColorZDC); | |
291 | fNodes->Add(node); | |
fe4da5cc | 292 | } |
293 | ||
294 | //_____________________________________________________________________________ | |
295 | Int_t AliZDC::DistancetoPrimitive(Int_t , Int_t ) | |
296 | { | |
297 | // | |
298 | // Distance from the mouse to the Zero Degree Calorimeter | |
299 | // Dummy routine | |
300 | // | |
301 | return 9999; | |
302 | } | |
359cdddc | 303 | |
304 | //____________________________________________________________________________ | |
305 | Float_t AliZDC::ZMin(void) const | |
306 | { | |
307 | // Minimum dimension of the ZDC module in z | |
308 | return 11600.; | |
309 | } | |
310 | ||
311 | //____________________________________________________________________________ | |
312 | Float_t AliZDC::ZMax(void) const | |
313 | { | |
314 | // Maximum dimension of the ZDC module in z | |
315 | return 11750.; | |
316 | } | |
317 | ||
318 | ||
fe4da5cc | 319 | //_____________________________________________________________________________ |
359cdddc | 320 | void AliZDC::MakeBranch(Option_t *opt, const char *file) |
fe4da5cc | 321 | { |
322 | // | |
359cdddc | 323 | // Create Tree branches for the ZDC |
fe4da5cc | 324 | // |
359cdddc | 325 | |
326 | char branchname[10]; | |
327 | sprintf(branchname,"%s",GetName()); | |
328 | ||
329 | AliDetector::MakeBranch(opt); | |
330 | ||
331 | const char *cS = strstr(opt,"S"); | |
332 | ||
333 | if (gAlice->TreeS() && cS) { | |
b6d27557 | 334 | if(fMergedHits!=0) fMergedHits->Clear(); |
335 | else fMergedHits = new TClonesArray ("AliZDCMergedHit",1000); | |
359cdddc | 336 | MakeBranchInTree(gAlice->TreeS(), |
b6d27557 | 337 | branchname, &fMergedHits, fBufferSize, file) ; |
359cdddc | 338 | printf("* AliZDC::MakeBranch * Making Branch %s for SDigits\n\n",branchname); |
339 | } | |
340 | ||
341 | ||
342 | const char *cD = strstr(opt,"D"); | |
343 | ||
344 | if (gAlice->TreeD() && cD) { | |
345 | if(fDigits!=0) fDigits->Clear(); | |
346 | else fDigits = new TClonesArray ("AliZDCDigit",1000); | |
347 | MakeBranchInTree(gAlice->TreeD(), | |
348 | branchname, &fDigits, fBufferSize, file) ; | |
349 | printf("* AliZDC::MakeBranch * Making Branch %s for Digits\n\n",branchname); | |
350 | } | |
351 | ||
352 | ||
353 | const char *cR = strstr(opt,"R"); | |
354 | ||
355 | if (gAlice->TreeR() && cR) { | |
356 | MakeBranchInTree(gAlice->TreeR(), | |
357 | branchname, &fRecPoints, fBufferSize, file) ; | |
358 | printf("* AliZDC::MakeBranch * Making Branch %s for RecPoints\n\n",branchname); } | |
359 | ||
fe4da5cc | 360 | } |
359cdddc | 361 | |
362 | //_____________________________________________________________________________ | |
b6d27557 | 363 | void AliZDC::MakeBranchInTreeSD(TTree *treeSD, const char *file) |
364 | { | |
365 | // MakeBranchInTree | |
366 | const Int_t kBufferSize = 4000; | |
367 | char branchname[20]; | |
368 | sprintf(branchname,"%s",GetName()); | |
369 | MakeBranchInTree(treeSD, branchname, &fMergedHits, kBufferSize, file) ; | |
370 | printf("* AliZDC::MakeBranch * Making Branch %s for SDigits\n\n",branchname); | |
371 | ||
372 | } | |
373 | //_____________________________________________________________________________ | |
374 | void AliZDC::MakeBranchInTreeD(TTree *treeD, const char *file) | |
359cdddc | 375 | { |
b6d27557 | 376 | // MakeBranchInTree |
377 | const Int_t kBufferSize = 4000; | |
378 | char branchname[20]; | |
379 | sprintf(branchname,"%s",GetName()); | |
380 | MakeBranchInTree(treeD, branchname, &fDigits, kBufferSize, file) ; | |
381 | printf("* AliZDC::MakeBranch * Making Branch %s for Digits\n\n",branchname); | |
359cdddc | 382 | |
1450a7cd | 383 | } |
384 | //_____________________________________________________________________________ | |
385 | void AliZDC::MakeBranchInTreeR(TTree *treeR, const char *file) | |
386 | { | |
387 | // MakeBranchInTree | |
388 | const Int_t kBufferSize = 4000; | |
389 | char branchname[20]; | |
390 | sprintf(branchname,"%s",GetName()); | |
391 | MakeBranchInTree(treeR, branchname, &fRecPoints, kBufferSize, file) ; | |
392 | printf("* AliZDC::MakeBranch * Making Branch %s for RecPoints\n\n",branchname); | |
393 | ||
b6d27557 | 394 | } |
395 | //_____________________________________________________________________________ | |
396 | void AliZDC::Hits2SDigits() | |
397 | { | |
1450a7cd | 398 | printf("\n Entering AliZDC::SDigits2Digits() "); |
b6d27557 | 399 | |
400 | //---------------------------------------------------------------- | |
359cdddc | 401 | if(!fMerger){ |
1450a7cd | 402 | printf(" ZDC digitization (without merging)\n"); |
b6d27557 | 403 | |
404 | AliZDCMergedHit *MHit; | |
405 | Int_t j, sector[2]; | |
406 | Float_t MHits[7]; | |
407 | fNMergedhits = 0; | |
408 | ||
359cdddc | 409 | TTree *treeH = gAlice->TreeH(); |
410 | Int_t ntracks = (Int_t) treeH->GetEntries(); | |
359cdddc | 411 | gAlice->ResetHits(); |
412 | ||
413 | // Tracks loop | |
414 | for(Int_t itrack=0; itrack<ntracks; itrack++){ | |
415 | treeH->GetEvent(itrack); | |
359cdddc | 416 | for(AliZDCHit* zdcHit=(AliZDCHit*)this->FirstHit(-1); zdcHit; |
b6d27557 | 417 | zdcHit = (AliZDCHit*)this->NextHit()){ |
418 | ||
419 | for(j=0; j<2; j++) sector[j] = zdcHit->GetVolume(j); | |
420 | MHits[0] = zdcHit->GetPrimKinEn(); | |
421 | MHits[1] = zdcHit->GetXImpact(); | |
422 | MHits[2] = zdcHit->GetYImpact(); | |
423 | MHits[3] = zdcHit->GetSFlag(); | |
424 | MHits[4] = zdcHit->GetLightPMQ(); | |
425 | MHits[5] = zdcHit->GetLightPMC(); | |
426 | MHits[6] = zdcHit->GetEnergy(); | |
427 | }//Hits loop | |
428 | ||
429 | MHit = new AliZDCMergedHit(sector, MHits); | |
430 | new((*fMergedHits)[fNMergedhits]) AliZDCMergedHit(*MHit); | |
431 | TClonesArray &sdigits = *fMergedHits; | |
432 | new (sdigits[fNMergedhits]) AliZDCMergedHit(*MHit); | |
433 | fNMergedhits++; | |
434 | delete MHit; | |
359cdddc | 435 | } |
1acbaaa8 | 436 | // printf("\n ### Filling SDigits tree\n"); |
359cdddc | 437 | gAlice->TreeS()->Fill(); |
438 | gAlice->TreeS()->Write(0,TObject::kOverwrite); | |
439 | gAlice->TreeS()->Reset(); | |
440 | } | |
b6d27557 | 441 | //---------------------------------------------------------------- |
442 | else if(fMerger){ | |
1450a7cd | 443 | printf(" ZDC merging and digitization\n"); |
b6d27557 | 444 | // ### Initialise merging |
445 | fMerger -> InitMerging(); | |
446 | ||
447 | TFile *bgrFile = fMerger->BgrFile(); | |
448 | bgrFile->cd(); | |
449 | // SDigits tree | |
450 | Int_t fNEvBgr = fMerger->EvNum(); | |
451 | char treeSDBgrName[20]; | |
452 | sprintf(treeSDBgrName,"TreeS%d",fNEvBgr); | |
453 | fTreeSD = (TTree*)gDirectory->Get(treeSDBgrName); // TreeH | |
454 | if(!fTreeSD){ | |
455 | printf("\n ERROR -> Can't find TreeS%d in background file\n",fNEvBgr); | |
456 | } | |
457 | // Branch address | |
b6d27557 | 458 | char branchSDname[20]; |
459 | sprintf(branchSDname,"%s",GetName()); | |
460 | if(fTreeSD && fMergedHits){ | |
1450a7cd | 461 | TBranch *branchSD = fTreeSD->GetBranch(branchSDname); |
b6d27557 | 462 | if(branchSD) branchSD->SetAddress(&fMergedHits); |
1450a7cd | 463 | else if(!branchSD) MakeBranchInTreeSD(fTreeSD); |
b6d27557 | 464 | } |
b6d27557 | 465 | |
466 | // ### Get TCA of MergedHits from AliZDCMerger | |
467 | fMergedHits = fMerger->MergedHits(); | |
468 | fNMergedhits = fMerger->GetNMhits(); | |
1acbaaa8 | 469 | // printf("\n fNMergedhits (from AliZDCMerger) = %d\n", fNMergedhits); |
b6d27557 | 470 | AliZDCMergedHit *MHit; |
471 | TClonesArray &sdigits = *fMergedHits; | |
472 | Int_t imhit; | |
473 | //Merged Hits loop | |
474 | for(imhit=0; imhit<fNMergedhits; imhit++){ | |
475 | MHit = (AliZDCMergedHit*) fMergedHits->UncheckedAt(imhit); | |
476 | new (sdigits[imhit]) AliZDCMergedHit(*MHit); | |
477 | } | |
478 | ||
479 | // printf("\n ### Filling SDigits tree\n"); | |
480 | bgrFile->cd(); | |
481 | fTreeSD->Fill(); | |
482 | fTreeSD->Write(0,TObject::kOverwrite); | |
483 | } | |
359cdddc | 484 | |
485 | } | |
486 | ||
487 | //_____________________________________________________________________________ | |
488 | void AliZDC::SDigits2Digits() | |
489 | { | |
1450a7cd | 490 | //printf("\n Entering AliZDC::SDigits2Digits() "); |
359cdddc | 491 | if(!fMerger){ // Only digitization |
1450a7cd | 492 | printf(" ZDC digitization (without merging) \n"); |
359cdddc | 493 | fMerger = new AliZDCMerger(); |
b6d27557 | 494 | fMerger->Digitize(fNMergedhits, fMergedHits); |
495 | ||
496 | char hname[30]; | |
497 | sprintf(hname,"TreeD%d",gAlice->GetHeader()->GetEvent()); | |
498 | gAlice->TreeD()->Fill(); | |
499 | gAlice->TreeD()->Write(0,TObject::kOverwrite); | |
500 | gAlice->TreeD()->Reset(); | |
359cdddc | 501 | } |
b6d27557 | 502 | else if(fMerger){ // Merging and digitization |
1450a7cd | 503 | printf(" ZDC merging and digitization\n"); |
b6d27557 | 504 | fMerger->Digitize(fNMergedhits, fMergedHits); |
505 | ||
506 | TFile *bgrFile = fMerger->BgrFile(); | |
507 | bgrFile->cd(); | |
508 | // Digits tree | |
509 | Int_t fNEvBgr = fMerger->EvNum(); | |
1450a7cd | 510 | //printf(" fNEvBgr = %d\n",fNEvBgr); |
b6d27557 | 511 | char treeDBgrName[20]; |
512 | sprintf(treeDBgrName,"TreeD%d",fNEvBgr); | |
513 | fTreeMD = (TTree*)gDirectory->Get(treeDBgrName); // TreeH | |
514 | if(!fTreeMD){ | |
515 | printf("\n ERROR -> Can't find TreeD%d in background file\n",fNEvBgr); | |
516 | } | |
517 | // Branch address | |
b6d27557 | 518 | char branchDname[20]; |
519 | sprintf(branchDname,"%s",GetName()); | |
520 | if(fTreeMD && fDigits){ | |
1acbaaa8 | 521 | // printf("\n fTreeMD!=0 && fDigits!=0\n"); |
1450a7cd | 522 | TBranch *branchD = fTreeMD->GetBranch(branchDname); |
b6d27557 | 523 | if(branchD) branchD->SetAddress(&fDigits); |
1450a7cd | 524 | else if(!branchD) MakeBranchInTreeD(fTreeMD); |
b6d27557 | 525 | } |
b6d27557 | 526 | |
b6d27557 | 527 | fTreeMD->Fill(); |
528 | fTreeMD->Write(0,TObject::kOverwrite); | |
359cdddc | 529 | } |
b6d27557 | 530 | |
359cdddc | 531 | |
532 | } | |
533 | //_____________________________________________________________________________ | |
534 | void AliZDC::Hits2Digits() | |
535 | { | |
536 | gAlice->Hits2SDigits(); | |
537 | gAlice->SDigits2Digits(); | |
538 | } | |
539 | ||
540 | //_____________________________________________________________________________ | |
541 | void AliZDC::Digits2Reco() | |
542 | { | |
1450a7cd | 543 | //printf("\n Entering AliZDC::Digits2Reco() "); |
359cdddc | 544 | |
1450a7cd | 545 | Int_t fNEvBgr = fMerger->EvNum(); |
546 | //printf(" fNEvBgr = %d\n",fNEvBgr); | |
547 | gAlice->GetEvent(fNEvBgr); | |
548 | ||
549 | AliDetector *ZDC = gAlice->GetDetector("ZDC"); | |
550 | TClonesArray *ZDCdigits = ZDC->Digits(); | |
551 | ||
552 | char tdname[20]; | |
553 | sprintf(tdname,"TreeD%d",fNEvBgr); | |
554 | TTree *TD = (TTree*)gDirectory->Get(tdname); | |
555 | //TTree *TD = gAlice->TreeD(); | |
556 | if(TD){ | |
557 | //printf(" TreeD found in gAlice object\n"); | |
558 | char brname[20]; | |
559 | sprintf(brname,"%s",ZDC->GetName()); | |
560 | TBranch *br = TD->GetBranch(brname); | |
561 | if(br) br->SetAddress(&ZDCdigits); | |
562 | } | |
563 | else if(!TD) printf(" ERROR -> TreeD NOT found in gAlice object\n"); | |
564 | ||
565 | Int_t nt = (Int_t) (TD->GetEntries()); | |
566 | //printf("\n #entries in TreeD = %d\n",nt); | |
567 | gAlice->ResetDigits(); | |
568 | ||
569 | AliZDCDigit *dig; | |
570 | Int_t j, idig, ndigits, ZNraw=0, ZPraw=0, ZEMraw=0; | |
571 | // --- Summing raw ADCs for each detector to obtain total light | |
572 | for(j=0; j<nt; j++){ | |
573 | TD->GetEvent(j); | |
574 | ndigits = ZDCdigits->GetEntries(); | |
575 | //printf("\n Entry #%d, ndigits = %d",j,ndigits); | |
576 | ZNraw=0; | |
577 | ZPraw=0; | |
578 | ZEMraw=0; | |
579 | // --- Loop over event digits | |
580 | for(idig=0; idig<ndigits; idig++){ | |
581 | dig = (AliZDCDigit*) ZDCdigits->UncheckedAt(idig); | |
582 | if(dig->GetSector(0) == 1) ZNraw += dig->GetADCValue(); | |
583 | else if(dig->GetSector(0) == 2) ZPraw += dig->GetADCValue(); | |
584 | else if(dig->GetSector(0) == 3) ZEMraw += dig->GetADCValue(); | |
585 | } // Digits loop | |
586 | } // TreeD entries loop | |
587 | printf("\n --- ZNraw = %d, ZPraw = %d, ZEMraw = %d\n",ZNraw, ZPraw, ZEMraw); | |
588 | ||
589 | // --- Pedestal subtraction | |
590 | Int_t ZNcorr, ZPcorr, ZEMcorr, MeanPed=50; | |
591 | ZNcorr = ZNraw - 5*MeanPed; | |
592 | ZPcorr = ZPraw - 5*MeanPed; | |
593 | ZEMcorr = ZEMraw - 2*MeanPed; | |
594 | if(ZNcorr<0) ZNcorr=0; | |
595 | if(ZPcorr<0) ZPcorr=0; | |
596 | if(ZEMcorr<0) ZEMcorr=0; | |
597 | printf("\n ZNcorr = %d, ZPcorr = %d, ZEMcorr = %d\n",ZNcorr,ZPcorr,ZEMcorr); | |
598 | ||
599 | // --- ADCchannel -> photoelectrons | |
600 | // NB-> PM gain = 10^(5), ADC resolution = 6.4*10^(-7) | |
601 | Float_t ZNphe, ZPphe, ZEMphe, ConvFactor = 0.064; | |
602 | ZNphe = ZNcorr/ConvFactor; | |
603 | ZPphe = ZPcorr/ConvFactor; | |
604 | ZEMphe = ZEMcorr/ConvFactor; | |
605 | printf("\n ZNphe = %f, ZPphe = %f, ZEMphe = %f\n",ZNphe, ZPphe, ZEMphe); | |
606 | ||
607 | // --- Energy calibration | |
608 | // Conversion factors for hadronic ZDCs goes from phe yield to TRUE incident | |
609 | // energy (conversion from GeV to TeV is included); while for EM calos | |
610 | // conversion is from light yield to detected energy calculated by GEANT | |
611 | // NB -> ZN and ZP conversion factors are constant since incident spectators | |
612 | // have all the same energy, ZEM energy is obtained through a fit over the whole | |
613 | // range of incident particle energies (obtained with full HIJING simulations) | |
614 | Float_t ZNenergy, ZPenergy, ZEMenergy, ZDCenergy; | |
615 | Float_t ZNphexTeV=329., ZPphexTeV=369.; | |
616 | ZNenergy = ZNphe/ZNphexTeV; | |
617 | ZPenergy = ZPphe/ZPphexTeV; | |
618 | ZDCenergy = ZNenergy+ZPenergy; | |
619 | ZEMenergy = -4.81+0.3238*ZEMphe; | |
620 | if(ZEMenergy<0) ZEMenergy=0; | |
621 | printf(" ZNenergy = %f TeV, ZPenergy = %f TeV, ZDCenergy = %f GeV, " | |
622 | "\n ZEMenergy = %f TeV\n", ZNenergy, ZPenergy, | |
623 | ZDCenergy, ZEMenergy); | |
624 | ||
625 | if(ZDCenergy==0) | |
626 | printf("\n\n ### ATTENZIONE!!! -> ev# %d: ZNenergy = %f TeV, ZPenergy = %f TeV, ZDCenergy = %f GeV, " | |
627 | " ZEMenergy = %f TeV\n\n", fNEvBgr, ZNenergy, ZPenergy, ZDCenergy, ZEMenergy); | |
628 | ||
629 | // --- Number of incident spectator nucleons | |
630 | Int_t NDetSpecN, NDetSpecP; | |
631 | NDetSpecN = (Int_t) (ZNenergy/2.760); | |
632 | NDetSpecP = (Int_t) (ZPenergy/2.760); | |
633 | printf("\n NDetSpecN = %d, NDetSpecP = %d\n",NDetSpecN, NDetSpecP); | |
634 | ||
635 | // --- Number of generated spectator nucleons and impact parameter | |
636 | // Fit results for neutrons (Nspectator n true vs. EZN) | |
637 | TF1 *fZNCen = new TF1("fZNCen", | |
638 | "(-2.116909+sqrt(2.116909*2.116909-4*(-0.00651)*(14.556798-x)))/(2*(-0.00651))",0.,158.5); | |
639 | TF1 *fZNPer = new TF1("fZNPer", | |
640 | "(-34.695134-sqrt(34.695134*34.695134-4*(-0.174780)*(-1562.283443-x)))/(2*(-0.174780))",0.,158.5); | |
641 | // Fit results for protons (Nspectator p true vs. EZP) | |
642 | TF1 *fZPCen = new TF1("fZPCen", | |
643 | "(-1.3217+sqrt(1.3217*1.3217-4*(-0.007934)*(4.742873-x)))/(2*(-0.007934))",0.,58.91); | |
644 | TF1 *fZPPer = new TF1("fZPPer", | |
645 | "(-15.788267-sqrt(15.788267*15.788267-4*(-0.133359)*(-383.800673-x)))/(2*(-0.133359))",0.,58.91); | |
646 | // Fit results for total number of spectators (Nspectators true vs. EZDC) | |
647 | TF1 *fZDCCen = new TF1("fZDCCen", | |
648 | "(-1.867335+sqrt(1.867335*1.867335-4*(-0.004119)*(19.100289-x)))/(2*(-0.004119))",0.,220.4); | |
649 | TF1 *fZDCPer = new TF1("fZDCPer", | |
650 | "(-22.429097-sqrt(22.429097*22.429097-4*(-0.072435)*(-1482.034526-x)))/(2*(-0.072435))",0.,220.4); | |
651 | // Fit results for b (b vs. EZDC) | |
652 | //TF1 *fbCen = new TF1("fbCen","0.611543+0.052231*x-0.000112*x*x+0.000000374*x*x*x",0.,222.); | |
653 | //TF1 *fbPer = new TF1("fbPer","16.552010-0.023866*x-0.00001*x*x",0.,222.); | |
654 | TF1 *fbCen = new TF1("fbCen","0.612769+0.051929*x-0.0001074*x*x+0.0000003724*x*x*x",0.,225.); | |
655 | TF1 *fbPer = new TF1("fbPer","16.6131016-0.026053*x+0.000006893*x*x",0.,225.); | |
656 | // Evaluating Nspectators and b from ZEM energy | |
657 | TF1 *fZEMn = new TF1("fZEMn","124.2-0.0566*x+0.000006014*x*x",0.,3500.); | |
658 | TF1 *fZEMp = new TF1("fZEMp","81.3-0.03834*x+0.000004359*x*x",0.,3500.); | |
659 | TF1 *fZEMsp = new TF1("fZEMsp","205.6-0.09567*x+0.00001056*x*x",0.,3500.); | |
660 | TF1 *fZEMb = new TF1("fZEMb","15.8-0.02084*x+2.802e-5*x*x-2.007e-8*x*x*x+6.586e-12*x*x*x*x-8.042e-16*x*x*x*x*x",0.,3500.); | |
661 | ||
662 | Int_t NGenSpecN=0, NGenSpecP=0, NGenSpec=0; | |
663 | Double_t ImpPar=0; | |
664 | Float_t EZEMCut = 360.; // Cut value for Ezem (GeV) | |
665 | if(ZEMenergy >= EZEMCut){ | |
666 | NGenSpecN = (Int_t) (fZNCen->Eval(ZNenergy)); | |
667 | NGenSpecP = (Int_t) (fZPCen->Eval(ZPenergy)); | |
668 | NGenSpec = (Int_t) (fZDCCen->Eval(ZDCenergy)); | |
669 | ImpPar = fbCen->Eval(ZDCenergy); | |
670 | //printf(" fZNCen = %f, fZPCen = %f, fZDCCen = %f\n",fZNCen->Eval(ZNenergy), | |
671 | // fZPCen->Eval(ZPenergy),fZDCCen->Eval(ZDCenergy)); | |
672 | } | |
673 | else if(ZEMenergy < EZEMCut){ | |
674 | NGenSpecN = (Int_t) (fZNPer->Eval(ZNenergy)); | |
675 | NGenSpecP = (Int_t) (fZPPer->Eval(ZPenergy)); | |
676 | NGenSpec = (Int_t) (fZDCPer->Eval(ZDCenergy)); | |
677 | ImpPar = fbPer->Eval(ZDCenergy); | |
678 | //printf(" fZNPer = %f, fZPPer = %f, fZDCPer = %f\n",fZNPer->Eval(ZNenergy), | |
679 | // fZPPer->Eval(ZPenergy),fZDCPer->Eval(ZDCenergy)); | |
680 | } | |
681 | if(ZNenergy>158.5) NGenSpecN = (Int_t) (fZEMn->Eval(ZEMenergy)); | |
682 | if(ZPenergy>58.91) NGenSpecP = (Int_t) (fZEMp->Eval(ZEMenergy)); | |
683 | if(ZDCenergy>220.4) NGenSpec = (Int_t)(fZEMsp->Eval(ZEMenergy)); | |
684 | if(ZDCenergy>225.) ImpPar = fZEMb->Eval(ZEMenergy); | |
685 | /*if(ZNenergy>158.5) NGenSpecN = -999; | |
686 | if(ZPenergy>58.91) NGenSpecP = -999; | |
687 | if(ZDCenergy>220.4) NGenSpec = -999; | |
688 | if(ZDCenergy>225.) ImpPar = -999;*/ | |
689 | ||
690 | if(NGenSpecN>125) NGenSpecN=125; | |
691 | else if(NGenSpecN<0) NGenSpecN=0; | |
692 | if(NGenSpecP>82) NGenSpecP=82; | |
693 | else if(NGenSpecP<0) NGenSpecP=0; | |
694 | if(NGenSpec>207) NGenSpec=207; | |
695 | else if(NGenSpec<0) NGenSpec=0; | |
696 | printf(" NRecSpecN = %d, NRecSpecP = %d, NRecSpec = %d\n",NGenSpecN,NGenSpecP,NGenSpec); | |
697 | ||
698 | // --- Number of participants | |
699 | Int_t NPart, NPartTot; | |
700 | NPart = 208-NGenSpecN-NGenSpecP; | |
701 | NPartTot = 208-NGenSpec; | |
702 | printf(" ### NPart(ZP+ZN) = %d, NPart(ZDC) = %d, b = %f fm\n",NPart,NPartTot,ImpPar); | |
703 | ||
704 | // --- Writing RecPoints TCA | |
705 | // Allocate the RecPoints TCA | |
706 | fRecPoints = new TClonesArray("AliZDCReco",1000); | |
707 | AliZDCReco *reco = new AliZDCReco(ZNenergy,ZPenergy,ZDCenergy,ZEMenergy, | |
708 | NDetSpecN,NDetSpecP,NGenSpecN,NGenSpecP,NGenSpec,NPartTot,ImpPar); | |
709 | new((*fRecPoints)[fNRecPoints]) AliZDCReco(*reco); | |
710 | //printf(" fNRecPoints = %d \n",fNRecPoints ); | |
711 | //fNRecPoints++; | |
712 | //fRecPoints->Dump(); | |
713 | delete reco; | |
714 | ||
715 | // TreeR | |
716 | TTree *treeR = gAlice->TreeR(); | |
717 | char tname[20]; | |
718 | sprintf(tname,"TreeR%d",fNEvBgr); | |
719 | if(!treeR) printf("\n ERROR -> Can't find TreeR%d in background file\n",fNEvBgr); | |
720 | // Branch address | |
721 | char branchRname[20]; | |
722 | sprintf(branchRname,"%s",GetName()); | |
723 | if(fRecPoints){ | |
724 | TBranch *branchR = treeR->GetBranch(branchRname); | |
725 | if(branchR) branchR->SetAddress(&fRecPoints); | |
726 | else if(!branchR) MakeBranchInTreeR(treeR); | |
727 | } | |
728 | treeR->Fill(); | |
729 | treeR->Write(tname,TObject::kOverwrite); | |
730 | treeR->Reset(); | |
359cdddc | 731 | } |
732 | ||
733 | ||
734 | //_____________________________________________________________________________ | |
735 | void AliZDC::SetMerger(AliZDCMerger* merger) | |
736 | { | |
737 | // Set pointer to merger | |
738 | fMerger = merger; | |
739 | } | |
740 | ||
741 | //_____________________________________________________________________________ | |
742 | AliZDCMerger* AliZDC::Merger() | |
743 | { | |
744 | // Return pointer to merger | |
745 | return fMerger; | |
746 | } | |
747 |