]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ZDC/AliZDC.cxx
Redefinition of stable condition.
[u/mrichter/AliRoot.git] / ZDC / AliZDC.cxx
CommitLineData
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$
359cdddc 18Revision 1.23 2001/05/15 13:44:57 coppedis
19Changes in AddHit method
20
43f34e8b 21Revision 1.22 2001/05/14 09:53:32 coppedis
22Adding functions ZMin and ZMax
23
cefa66cb 24Revision 1.21 2001/04/20 10:05:02 coppedis
25Minor changes
26
0d2bb33c 27Revision 1.20 2001/03/26 13:39:20 coppedis
28Comment prints
29
4c38d2da 30Revision 1.19 2001/03/26 09:10:23 coppedis
31Corrected bug in constructor (fIshunt has to be =1)
32
2e6fc82a 33Revision 1.18 2001/03/20 08:21:55 coppedis
34ZDC needs PIPE, ABSO, DIPO and SHIL
35
ec71d094 36Revision 1.17 2001/03/16 16:18:03 coppedis
37Correction for superposition of ZDC volumes with MUON arm one
38
0014adbc 39Revision 1.16 2001/03/15 16:01:11 coppedis
40Code review
41
09630792 42Revision 1.15 2001/01/26 19:56:27 hristov
43Major upgrade of AliRoot code
44
2ab0c725 45Revision 1.14 2000/12/12 13:17:01 coppedis
46Minor corrections suggested by P. Hristov
47
65d4f2be 48Revision 1.12 2000/12/01 08:19:01 coppedis
49Adding a message error if ZDC is constructed without DIPO
50
588ed15d 51Revision 1.11 2000/11/30 17:21:03 coppedis
52Introduce hit array fStHits reset only at the end of the event (for digitization)
53
f901045b 54Revision 1.10 2000/11/22 11:32:58 coppedis
55Major code revision
56
866ab5a2 57Revision 1.9 2000/10/02 21:28:20 fca
58Removal of useless dependecies via forward declarations
59
94de3818 60Revision 1.8 2000/07/10 13:58:01 fca
61New version of ZDC from E.Scomparin & C.Oppedisano
62
68ca986e 63Revision 1.7 2000/01/19 17:17:40 fca
64
1cedd08a 65Revision 1.6 1999/09/29 09:24:35 fca
66Introduction of the Copyright and cvs Log
67
4c039060 68*/
69
fe4da5cc 70///////////////////////////////////////////////////////////////////////////////
71// //
359cdddc 72// Zero Degree Calorimeter //
73// This class contains the basic functions for the ZDCs; //
74// functions specific to one particular geometry are //
75// contained in the derived classes //
fe4da5cc 76// //
fe4da5cc 77///////////////////////////////////////////////////////////////////////////////
78
65a824a5 79#include <stdlib.h>
359cdddc 80#include <iostream.h>
65a824a5 81
f901045b 82// --- ROOT system
fe4da5cc 83#include <TBRIK.h>
84#include <TNode.h>
2ab0c725 85#include <TGeometry.h>
86#include <TFile.h>
87#include <TTree.h>
fe4da5cc 88
f901045b 89// --- AliRoot header files
fe4da5cc 90#include "AliZDC.h"
f901045b 91#include "AliZDCHit.h"
359cdddc 92#include "AliZDCDigit.h"
93#include "AliZDCMerger.h"
f901045b 94#include "AliDetector.h"
fe4da5cc 95#include "AliCallf77.h"
96#include "AliConst.h"
97#include "AliMC.h"
359cdddc 98#include "AliRun.h"
99#include "AliHeader.h"
fe4da5cc 100
fe4da5cc 101
102ClassImp(AliZDC)
103
104//_____________________________________________________________________________
105AliZDC::AliZDC()
106{
107 //
108 // Default constructor for the Zero Degree Calorimeter base class
109 //
2e6fc82a 110
359cdddc 111 fIshunt = 1;
112 fNoShower = 0;
113 fMerger = 0;
09630792 114
359cdddc 115 fHits = 0;
116 fNhits = 0;
09630792 117
359cdddc 118 fDigits = 0;
119 fNdigits = 0;
120
fe4da5cc 121}
122
123//_____________________________________________________________________________
124AliZDC::AliZDC(const char *name, const char *title)
125 : AliDetector(name,title)
126{
127 //
128 // Standard constructor for the Zero Degree Calorimeter base class
129 //
130
359cdddc 131 fIshunt = 1;
132 fNoShower = 0;
133 fMerger = 0;
f901045b 134
359cdddc 135 // Allocate the hits array
f901045b 136 fHits = new TClonesArray("AliZDCHit",1000);
1cedd08a 137 gAlice->AddHitList(fHits);
f901045b 138
359cdddc 139 // Allocate the digits array
140 fDigits = new TClonesArray("AliZDCDigit",1000);
141
866ab5a2 142
143}
144//____________________________________________________________________________
145AliZDC::~AliZDC()
146{
147 //
148 // ZDC destructor
149 //
150
151 fIshunt = 0;
359cdddc 152
153// if(fMerger) delete fMerger;
2e6fc82a 154
359cdddc 155// if(fHits){
156// fHits->Delete();
157// delete fHits;
65d4f2be 158// }
359cdddc 159
160// if(fDigits){
161// fDigits->Delete();
162// delete fDigits;
163// }
164
fe4da5cc 165}
fe4da5cc 166//_____________________________________________________________________________
167void AliZDC::AddHit(Int_t track, Int_t *vol, Float_t *hits)
168{
169 //
f901045b 170 // Add a ZDC hit to the hit list.
171 // -> We make use of 2 array of hits:
172 // [1] fHits (the usual one) that contains hits for each PRIMARY
173 // [2] fStHits that contains hits for each EVENT and is used to
174 // obtain digits at the end of each event
fe4da5cc 175 //
f901045b 176
68ca986e 177 static Float_t primKinEn, xImpact, yImpact, sFlag;
178
43f34e8b 179 AliZDCHit *newquad, *curprimquad;
f901045b 180 newquad = new AliZDCHit(fIshunt, track, vol, hits);
65d4f2be 181 TClonesArray &lhits = *fHits;
cefa66cb 182
183 if(fNhits==0){
184 // First hit -> setting flag for primary or secondary particle
185 Int_t primary = gAlice->GetPrimary(track);
186 if(track != primary){
187 newquad->fSFlag = 1; // SECONDARY particle entering the ZDC
188 }
189 else if(track == primary){
190 newquad->fSFlag = 0; // PRIMARY particle entering the ZDC
191 }
192// fNPrimaryHits += 1;
193 sFlag = newquad->fSFlag;
194 primKinEn = newquad->fPrimKinEn;
195 xImpact = newquad->fXImpact;
196 yImpact = newquad->fYImpact;
197 }
198 else{
199 newquad->fPrimKinEn = primKinEn;
200 newquad->fXImpact = xImpact;
201 newquad->fYImpact = yImpact;
202 newquad->fSFlag = sFlag;
203 }
204
43f34e8b 205 Int_t j;
f901045b 206 for(j=0; j<fNhits; j++){
2e6fc82a 207 // If hits are equal (same track, same volume), sum them.
f901045b 208 curprimquad = (AliZDCHit*) lhits[j];
209 if(*curprimquad == *newquad){
210 *curprimquad = *curprimquad+*newquad;
211 delete newquad;
68ca986e 212 return;
f901045b 213 }
214 }
f901045b 215
216 //Otherwise create a new hit
217 new(lhits[fNhits]) AliZDCHit(newquad);
218 fNhits++;
219
866ab5a2 220 delete newquad;
cefa66cb 221}
222
f901045b 223//_____________________________________________________________________________
359cdddc 224void AliZDC::AddDigit(Int_t *sect, Int_t digit)
f901045b 225{
359cdddc 226//
227 AliZDCDigit *newdigit;
228 newdigit = new AliZDCDigit(sect, digit);
229
230// AliZDCDigit *curdigit;
231// TClonesArray &ldigits = *fDigits;
232//
233// Int_t j;
234// for(j=0; j<fNdigits; j++){
235// curdigit = (AliZDCDigit*) ldigits[j];
236// if(*curdigit == *newdigit){
237// *curdigit = *curdigit+*newdigit;
238// delete newdigit;
239// return;
240// }
241// }
242//
243
244// printf("\n AddDigit -> sector[0] = %d, sector[1] = %d, digit = %d",
245// sect[0], sect[1], digit);
246 new((*fDigits)[fNdigits]) AliZDCDigit(*newdigit);
247 fNdigits++;
248 delete newdigit;
f901045b 249}
359cdddc 250
fe4da5cc 251//_____________________________________________________________________________
252void AliZDC::BuildGeometry()
253{
254 //
255 // Build the ROOT TNode geometry for event display
256 // in the Zero Degree Calorimeter
257 // This routine is dummy for the moment
258 //
259
68ca986e 260 TNode *node, *top;
261 TBRIK *brik;
359cdddc 262 const int kColorZDC = kBlue;
fe4da5cc 263
264 //
68ca986e 265 top=gAlice->GetGeometry()->GetNode("alice");
fe4da5cc 266
267 // ZDC
fe4da5cc 268 brik = new TBRIK("S_ZDC","ZDC box","void",300,300,5);
68ca986e 269 top->cd();
270 node = new TNode("ZDC","ZDC","S_ZDC",0,0,600,"");
271 node->SetLineColor(kColorZDC);
272 fNodes->Add(node);
fe4da5cc 273}
274
275//_____________________________________________________________________________
276Int_t AliZDC::DistancetoPrimitive(Int_t , Int_t )
277{
278 //
279 // Distance from the mouse to the Zero Degree Calorimeter
280 // Dummy routine
281 //
282 return 9999;
283}
359cdddc 284
285//____________________________________________________________________________
286Float_t AliZDC::ZMin(void) const
287{
288 // Minimum dimension of the ZDC module in z
289 return 11600.;
290}
291
292//____________________________________________________________________________
293Float_t AliZDC::ZMax(void) const
294{
295 // Maximum dimension of the ZDC module in z
296 return 11750.;
297}
298
299
fe4da5cc 300//_____________________________________________________________________________
359cdddc 301 void AliZDC::MakeBranch(Option_t *opt, const char *file)
fe4da5cc 302{
303 //
359cdddc 304 // Create Tree branches for the ZDC
fe4da5cc 305 //
359cdddc 306
307 char branchname[10];
308 sprintf(branchname,"%s",GetName());
309
310 AliDetector::MakeBranch(opt);
311
312 const char *cS = strstr(opt,"S");
313
314 if (gAlice->TreeS() && cS) {
315 MakeBranchInTree(gAlice->TreeS(),
316 branchname, &fHits, fBufferSize, file) ;
317 printf("* AliZDC::MakeBranch * Making Branch %s for SDigits\n\n",branchname);
318 }
319
320
321 const char *cD = strstr(opt,"D");
322
323 if (gAlice->TreeD() && cD) {
324 if(fDigits!=0) fDigits->Clear();
325 else fDigits = new TClonesArray ("AliZDCDigit",1000);
326 MakeBranchInTree(gAlice->TreeD(),
327 branchname, &fDigits, fBufferSize, file) ;
328 printf("* AliZDC::MakeBranch * Making Branch %s for Digits\n\n",branchname);
329 }
330
331
332 const char *cR = strstr(opt,"R");
333
334 if (gAlice->TreeR() && cR) {
335 MakeBranchInTree(gAlice->TreeR(),
336 branchname, &fRecPoints, fBufferSize, file) ;
337 printf("* AliZDC::MakeBranch * Making Branch %s for RecPoints\n\n",branchname); }
338
fe4da5cc 339}
359cdddc 340
341//_____________________________________________________________________________
342void AliZDC::Hits2SDigits()
343{
344
345 if(!fMerger){
346 // ### Copy of TreeH in TreeS
347 // Pointer to TreeH
348// printf("\n ZDC digitization (without merging)\n");
349 TTree *treeH = gAlice->TreeH();
350 Int_t ntracks = (Int_t) treeH->GetEntries();
351 Int_t fNhits = 0;
352 gAlice->ResetHits();
353
354 // Tracks loop
355 for(Int_t itrack=0; itrack<ntracks; itrack++){
356 treeH->GetEvent(itrack);
357 // Hits loop
358 for(AliZDCHit* zdcHit=(AliZDCHit*)this->FirstHit(-1); zdcHit;
359 zdcHit = (AliZDCHit*)this->NextHit()){
360 TClonesArray &sdigits = *fHits;
361 new (sdigits[fNhits++]) AliZDCHit(zdcHit);
362 }
363 }
364
365 gAlice->TreeS()->Fill();
366 gAlice->TreeS()->Write(0,TObject::kOverwrite);
367 gAlice->TreeS()->Reset();
368 }
369
370}
371
372//_____________________________________________________________________________
373void AliZDC::SDigits2Digits()
374{
375 if(!fMerger){ // Only digitization
376// printf("\n ZDC digitization (without merging) \n");
377 fMerger = new AliZDCMerger();
378 fMerger->Digitize();
379 }
380 else{ // Merging and digitization
381 printf("\n ZDC merging and digitization\n");
382 fMerger -> InitMerging();
383 }
384
385 char hname[30];
386 sprintf(hname,"TreeD%d",gAlice->GetHeader()->GetEvent());
387
388 gAlice->TreeD()->Fill();
389 gAlice->TreeD()->Write(0,TObject::kOverwrite);
390 gAlice->TreeD()->Reset();
391
392}
393//_____________________________________________________________________________
394void AliZDC::Hits2Digits()
395{
396 gAlice->Hits2SDigits();
397 gAlice->SDigits2Digits();
398}
399
400//_____________________________________________________________________________
401void AliZDC::Digits2Reco()
402{
403
404}
405
406
407//_____________________________________________________________________________
408void AliZDC::SetMerger(AliZDCMerger* merger)
409{
410// Set pointer to merger
411 fMerger = merger;
412}
413
414//_____________________________________________________________________________
415AliZDCMerger* AliZDC::Merger()
416{
417// Return pointer to merger
418 return fMerger;
419}
420