]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSDigitizer.cxx
Default branch names set to Default
[u/mrichter/AliRoot.git] / PHOS / AliPHOSDigitizer.cxx
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 /* $Id$ */
17
18 //_________________________________________________________________________
19 //*-- Author :  Dmitri Peressounko (SUBATECH & Kurchatov Institute) 
20 //////////////////////////////////////////////////////////////////////////////
21 // This TTask performs digitization of Summable digits (in the PHOS case it is just
22 // the sum of contributions from all primary particles into a given cell). 
23 // In addition it performs mixing of summable digits from different events.
24 // The name of the TTask is also the title of the branch that will contain 
25 // the created SDigits
26 // The title of the TTAsk is the name of the file that contains the hits from
27 // which the SDigits are created
28 //
29 // For each event two branches are created in TreeD:
30 //   "PHOS" - list of digits
31 //   "AliPHOSDigitizer" - AliPHOSDigitizer with all parameters used in digitization
32 //
33 // Note, that one can set a title for new digits branch, and repeat digitization with
34 // another set of parameters.
35 //
36 // Use case:
37 // root[0] AliPHOSDigitizer * d = new AliPHOSDigitizer() ;
38 // root[1] d->ExecuteTask()             
39 // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
40 //                       //Digitizes SDigitis in all events found in file galice.root 
41 //
42 // root[2] AliPHOSDigitizer * d1 = new AliPHOSDigitizer("galice1.root") ;  
43 //                       // Will read sdigits from galice1.root
44 // root[3] d1->MixWith("galice2.root")       
45 // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
46 //                       // Reads another set of sdigits from galice2.root
47 // root[3] d1->MixWith("galice3.root")       
48 //                       // Reads another set of sdigits from galice3.root
49 // root[4] d->ExecuteTask("deb timing")    
50 //                       // Reads SDigits from files galice1.root, galice2.root ....
51 //                       // mixes them and stores produced Digits in file galice1.root          
52 //                       // deb - prints number of produced digits
53 //                       // deb all - prints list of produced digits
54 //                       // timing  - prints time used for digitization
55 //
56
57 // --- ROOT system ---
58 #include "TFile.h"
59 #include "TTree.h"
60 #include "TSystem.h"
61 #include "TROOT.h"
62 #include "TFolder.h"
63 #include "TObjString.h"
64 #include "TBenchmark.h"
65
66 // --- Standard library ---
67 #include <iomanip.h>
68
69 // --- AliRoot header files ---
70
71 #include "AliRun.h"
72 #include "AliRunDigitizer.h"
73 #include "AliPHOSDigit.h"
74 #include "AliPHOS.h"
75 #include "AliPHOSGetter.h"
76 #include "AliPHOSDigitizer.h"
77 #include "AliPHOSSDigitizer.h"
78 #include "AliPHOSGeometry.h"
79
80 ClassImp(AliPHOSDigitizer)
81
82
83 //____________________________________________________________________________ 
84   AliPHOSDigitizer::AliPHOSDigitizer() 
85 {
86   // ctor
87
88   fPinNoise           = 0.01 ;
89   fEMCDigitThreshold  = 0.01 ;
90   fCPVNoise           = 0.01;
91   fCPVDigitThreshold  = 0.09 ;
92   fPPSDNoise          = 0.0000001;
93   fPPSDDigitThreshold = 0.0000002 ;  
94   fDigitsInRun  = 0 ; 
95   fPedestal = 0.;                // Calibration parameters 
96   fSlope = 10000000. ;
97   fARD = 0 ;                     // We work in the standalong mode
98 }
99
100 //____________________________________________________________________________ 
101 AliPHOSDigitizer::AliPHOSDigitizer(const char *headerFile,const char * name)
102 {
103   // ctor
104   SetName(name) ;
105   SetTitle(headerFile) ;
106   fPinNoise           = 0.01 ;
107   fEMCDigitThreshold  = 0.01 ;
108   fCPVNoise           = 0.01;
109   fCPVDigitThreshold  = 0.09 ;
110   fPPSDNoise          = 0.0000001;
111   fPPSDDigitThreshold = 0.0000002 ;  
112   fDigitsInRun  = 0 ; 
113   fPedestal = 0.;                // Calibration parameters 
114   fSlope = 10000000. ;
115   fARD = 0 ;                     // We work in the standalong mode
116
117   Init() ;
118   
119 }
120
121 //____________________________________________________________________________ 
122 AliPHOSDigitizer::AliPHOSDigitizer(AliRunDigitizer * ard)
123 {
124   // ctor
125   fARD = ard ;
126   SetName("Default");
127   SetTitle("aliroot") ;
128
129   fPinNoise           = 0.01 ;
130   fEMCDigitThreshold  = 0.01 ;
131   fCPVNoise           = 0.01;
132   fCPVDigitThreshold  = 0.09 ;
133   fPPSDNoise          = 0.0000001;
134   fPPSDDigitThreshold = 0.0000002 ;  
135   fDigitsInRun  = 0 ; 
136   fPedestal = 0.;                // Calibration parameters 
137   fSlope = 10000000. ;
138
139   Init() ;
140   
141 }
142
143 //____________________________________________________________________________ 
144   AliPHOSDigitizer::~AliPHOSDigitizer()
145 {
146   // dtor
147
148
149 }
150
151 //____________________________________________________________________________
152 void AliPHOSDigitizer::Digitize(const Int_t event) 
153
154   
155   // Makes the digitization of the collected summable digits.
156   //  It first creates the array of all PHOS modules
157   //  filled with noise (different for EMC, CPV and PPSD) and
158   //  then adds contributions from SDigits. 
159   // This design avoids scanning over the list of digits to add 
160   // contribution to new SDigits only.
161
162   if( strcmp(GetName(), "") == 0 )
163     Init() ;
164
165   AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; 
166   TClonesArray * digits = gime->Digits(GetName()) ; 
167
168   digits->Clear() ;
169
170   const AliPHOSGeometry *geom = gime->PHOSGeometry() ; 
171
172   //Making digits with noise, first EMC
173   Int_t nEMC = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ();
174   
175   Int_t nCPV ;
176   Int_t nPPSD ;
177   Int_t absID ;
178   TString name      =  geom->GetName() ;
179   
180   if ( name == "IHEP" || name == "MIXT" )    
181     nCPV =nEMC + geom->GetNumberOfCPVPadsZ()*geom->GetNumberOfCPVPadsPhi()*
182       geom->GetNCPVModules()*geom->GetNumberOfCPVLayers() ;
183   else
184     nCPV = nEMC; 
185   
186   if ( name == "GPS2" || name == "MIXT" )    
187     nPPSD =nCPV+2*geom->GetNPPSDModules()*geom->GetNumberOfModulesPhi()*geom->GetNumberOfModulesZ()*
188       geom->GetNumberOfPadsPhi()*geom->GetNumberOfPadsZ() ;
189   else
190     nPPSD = nCPV; 
191
192
193   digits->Expand(nPPSD) ;
194
195
196   // sdigitize random gaussian noise and add it to all cells (EMCA+CPV+PPSD) 
197   // get first the sdigitizer from the tasks list (must have same name as the digitizer)
198   const AliPHOSSDigitizer * sDigitizer = gime->SDigitizer(GetName()); 
199   if ( !sDigitizer) {
200     cerr << "ERROR: AliPHOSDigitizer::Digitize -> SDigitizer with name " << GetName() << " not found " << endl ; 
201     abort() ; 
202   }
203   for(absID = 1; absID <= nEMC; absID++){
204     Float_t noise = gRandom->Gaus(0., fPinNoise) ; 
205     new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise) ) ;
206   }
207   
208   for(absID = nEMC+1; absID <= nCPV; absID++){
209     Float_t noise = gRandom->Gaus(0., fCPVNoise) ; 
210     new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise) ) ;
211   }
212   
213   for(absID = nCPV+1; absID <= nPPSD; absID++){
214     Float_t noise = gRandom->Gaus(0., fPPSDNoise) ; 
215     new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise) ) ;
216   }
217   
218   // loop through the sdigits posted to the White Board and add them to the noise
219   TCollection * folderslist = ((TFolder*)gROOT->FindObjectAny("YSAlice/WhiteBoard/SDigits/PHOS"))->GetListOfFolders() ; 
220   TIter next(folderslist) ; 
221   TFolder * folder = 0 ; 
222   TClonesArray * sdigits = 0 ;
223   Int_t input = 0 ;
224   while ( (folder = (TFolder*)next()) ) {
225     if ( (sdigits = (TClonesArray*)folder->FindObject(GetName()) ) ) {
226       cout << "INFO: AliPHOSDigitizer::Digitize -> Adding SDigits " 
227            << GetName() << " from " << folder->GetName() << endl ; 
228       Int_t primaryoffset ;
229       if(fARD)
230         primaryoffset = fARD->GetMask(input) ; 
231       else
232         primaryoffset = 10000000*input ;
233  
234       Int_t index ; 
235       AliPHOSDigit * curSDigit ; 
236       AliPHOSDigit * digit ; 
237       for ( index = 0 ; index < sdigits->GetEntriesFast(); index++) { 
238         curSDigit = (AliPHOSDigit*)sdigits->At(index) ; 
239         curSDigit->ShiftPrimary(primaryoffset) ;
240         digit = (AliPHOSDigit*)digits->At(curSDigit->GetId() - 1 ) ; 
241         *digit = *digit + *curSDigit ; 
242       }
243     }
244   }
245   
246   //remove digits below thresholds
247   for(absID = 0; absID < nEMC ; absID++)
248     if(sDigitizer->Calibrate(((AliPHOSDigit*)digits->At(absID))->GetAmp()) < fEMCDigitThreshold)
249       digits->RemoveAt(absID) ;
250   
251   for(absID = nEMC; absID < nCPV ; absID++)
252     if(sDigitizer->Calibrate(((AliPHOSDigit*)digits->At(absID))->GetAmp()) < fCPVDigitThreshold)
253       digits->RemoveAt(absID) ;
254   
255   for(absID = nCPV; absID < nPPSD ; absID++)
256     if(sDigitizer->Calibrate(((AliPHOSDigit *)digits->At(absID))->GetAmp()) < fPPSDDigitThreshold)
257       digits->RemoveAt(absID) ;
258   
259   digits->Compress() ;  
260   
261   Int_t ndigits = digits->GetEntriesFast() ;
262   digits->Expand(ndigits) ;
263
264   //Set indexes in list of digits
265   Int_t i ;
266   for (i = 0 ; i < ndigits ; i++) { 
267     AliPHOSDigit * digit = (AliPHOSDigit *) digits->At(i) ; 
268     digit->SetIndexInList(i) ;     
269   }
270
271 }
272
273 //____________________________________________________________________________
274 void AliPHOSDigitizer::Exec(Option_t *option) 
275
276   // Managing method
277
278   if( strcmp(GetName(), "") == 0 )    
279     Init() ;
280   
281   if (strstr(option,"print")) {
282     Print("");
283     return ; 
284   }
285   
286   if(strstr(option,"tim"))
287     gBenchmark->Start("PHOSDigitizer");
288
289   AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
290   
291   Int_t nevents ;
292   
293   TTree * treeD ;
294   
295   if(fARD){
296     treeD = fARD->GetTreeD() ;
297     nevents = 1 ;    // Will process only one event
298   }
299   else {
300     gAlice->GetEvent(0) ;
301     nevents = (Int_t) gAlice->TreeE()->GetEntries() ;
302     treeD=gAlice->TreeD() ;
303   }
304   if(treeD == 0 ){
305     cerr << " AliPHOSDigitizer :: Can not find TreeD " << endl ;
306     return ;
307   }
308
309   //Check, if this branch already exits
310   TObjArray * lob = (TObjArray*)treeD->GetListOfBranches() ;
311   TIter next(lob) ; 
312   TBranch * branch = 0 ;  
313   Bool_t phosfound = kFALSE, digitizerfound = kFALSE ; 
314   
315   while ( (branch = (TBranch*)next()) && (!phosfound || !digitizerfound) ) {
316     if ( (strcmp(branch->GetName(), "PHOS")==0) && 
317          (strcmp(branch->GetTitle(), GetName())==0) ) 
318       phosfound = kTRUE ;
319     
320     else if ( (strcmp(branch->GetName(), "AliPHOSDigitizer")==0) && 
321               (strcmp(branch->GetTitle(), GetName())==0) ) 
322       digitizerfound = kTRUE ; 
323   }
324
325   if ( phosfound ) {
326     cerr << "WARNING: AliPHOSDigitizer -> Digits branch with name " << GetName() 
327          << " already exits" << endl ;
328     return ; 
329   }   
330   if ( digitizerfound ) {
331     cerr << "WARNING: AliPHOSDigitizer -> Digitizer branch with name " << GetName() 
332          << " already exits" << endl ;
333     return ; 
334   }   
335
336   Int_t ievent ;
337
338   for(ievent = 0; ievent < nevents; ievent++){
339     
340     if(fARD){
341       Int_t input ;
342       for(input = 0 ; input < fARD->GetNinputs(); input ++){
343         TTree * treeS = fARD->GetInputTreeS(input) ;
344         if(!treeS){
345           cerr << "AliPHOSDigitizer -> No Input " << endl ;
346           return ;
347         }
348         gime->ReadTreeS(treeS,input) ;
349       }
350     }
351     else
352       gime->Event(ievent,"S") ;
353     
354     Digitize(ievent) ; //Add prepared SDigits to digits and add the noise
355     
356     WriteDigits(ievent) ;
357     
358     if(strstr(option,"deb"))
359       PrintDigits(option);
360   }
361   
362   if(strstr(option,"tim")){
363     gBenchmark->Stop("PHOSDigitizer");
364     cout << "AliPHOSDigitizer:" << endl ;
365     cout << "  took " << gBenchmark->GetCpuTime("PHOSDigitizer") << " seconds for Digitizing " 
366          <<  gBenchmark->GetCpuTime("PHOSDigitizer")/nevents << " seconds per event " << endl ;
367     cout << endl ;
368   }
369   
370 }
371
372 //____________________________________________________________________________ 
373 Bool_t AliPHOSDigitizer::Init()
374 {
375   // Makes all memory allocations
376   // Adds Digitizer task to the folder of PHOS tasks
377    //============================================================= YS
378   //  The initialisation is now done by AliPHOSGetter
379     
380   if( strcmp(GetTitle(), "") == 0 )
381     SetTitle("galice.root") ;
382   
383   // the SDigits name is stored by AliPHOSGetter as the name of the TClones Array 
384   // //YSAlice/WhiteBoard/SDigits/PHOS/headerFile/branchname and has branchTitle as title.    
385     
386   AliPHOSGetter * gime = AliPHOSGetter::GetInstance(GetTitle(), GetName()) ; 
387   if ( gime == 0 ) {
388     cerr << "ERROR: AliPHOSDigitizer::Init -> Could not obtain the Getter object !" << endl ; 
389     return kFALSE;
390   } 
391      
392   // create a folder on the white board //YSAlice/WhiteBoard/Digits/PHOS/headerFile/digitsTitle
393   gime->PostDigits(GetName() ) ;   
394   
395   //add Task to //YSAlice/tasks/Digitizer/PHOS
396     gime->PostDigitizer(this) ;
397   
398   //Mark that we will use current header file
399   if(!fARD){
400     gime->PostSDigits(GetName(),GetTitle()) ;
401     gime->PostSDigitizer(GetName(),GetTitle()) ;
402   }
403   return kTRUE ;
404 }
405
406 //__________________________________________________________________
407 void AliPHOSDigitizer::MixWith(const char* headerFile)
408 {
409   // Allows to produce digits by superimposing background and signal event.
410   // It is assumed, that headers file with SIGNAL events is opened in 
411   // the constructor. 
412   // Sets the BACKGROUND event, with which the SIGNAL event is to be mixed 
413   // Thus we avoid writing (changing) huge and expensive 
414   // backgound files: all output will be writen into SIGNAL, i.e. 
415   // opened in constructor file. 
416   //
417   // One can open as many files to mix with as one needs.
418   // However only Sdigits with the same name (i.e. constructed with the same SDigitizer)
419   // can be mixed.
420
421   if( strcmp(GetName(), "") == 0 )
422     Init() ;
423
424   if(fARD){
425     cout << "Can not use this method under AliRunDigitizer " << endl ;
426     return ;
427   }
428   
429   // check if the specified SDigits do not already exist on the White Board:
430   // //YSAlice/WhiteBoard/SDigits/PHOS/headerFile/sDigitsTitle
431
432   TString path = "YSAlice/WhiteBoard/SDigits/PHOS/" ; 
433   path += headerFile ; 
434   path += "/" ; 
435   path += GetName() ;
436   if ( gROOT->FindObjectAny(path.Data()) ) {
437     cerr << "WARNING: AliPHOSDigitizer::MixWith -> Entry already exists, do not add" << endl ;
438     return;
439   }
440
441   AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
442   gime->PostSDigits(GetName(),headerFile) ;
443   
444   // check if the requested file is already open or exist and if SDigits Branch exist
445   TFile * file = (TFile*)gROOT->FindObject(headerFile); 
446   if ( !file ) { 
447     file = new TFile(headerFile, "READ") ; 
448     if (!file) { 
449       cerr << "ERROR: AliPHOSDigitizer::MixWith -> File " << headerFile << " does not exist!" << endl ; 
450       return ; 
451     }
452   }
453   
454 }
455
456 //__________________________________________________________________
457 void AliPHOSDigitizer::Print(Option_t* option)const {
458   // Print Digitizer's parameters
459   if( strcmp(GetName(), "") != 0 ){
460     
461     cout << "------------------- "<< GetName() << " -------------" << endl ;
462     cout << "Digitizing sDigits from file(s): " <<endl ;
463     
464      TCollection * folderslist = ((TFolder*)gROOT->FindObjectAny("YSAlice/WhiteBoard/SDigits/PHOS"))->GetListOfFolders() ; 
465     TIter next(folderslist) ; 
466     TFolder * folder = 0 ; 
467     
468     while ( (folder = (TFolder*)next()) ) {
469       if ( folder->FindObject(GetName())  ) 
470         cout << "Adding SDigits " << GetName() << " from " << folder->GetName() << endl ; 
471     }
472     cout << endl ;
473     cout << "Writing digits to " << GetTitle() << endl ;
474     
475     cout << endl ;
476     cout << "With following parameters: " << endl ;
477     cout << "     Electronics noise in EMC (fPinNoise) = " << fPinNoise << endl ;
478     cout << "  Threshold  in EMC  (fEMCDigitThreshold) = " << fEMCDigitThreshold  << endl ; ;
479     cout << "                 Noise in CPV (fCPVNoise) = " << fCPVNoise << endl ; 
480     cout << "    Threshold in CPV (fCPVDigitThreshold) = " << fCPVDigitThreshold << endl ; 
481     cout << "               Noise in PPSD (fPPSDNoise) = " << fPPSDNoise << endl ;
482     cout << "  Threshold in PPSD (fPPSDDigitThreshold) = " << fPPSDDigitThreshold << endl ;
483     cout << "---------------------------------------------------" << endl ;
484   }
485   else
486     cout << "AliPHOSDigitizer not initialized " << endl ;
487   
488 }
489 //__________________________________________________________________
490 void AliPHOSDigitizer::PrintDigits(Option_t * option){
491   // Print a table of digits
492
493   AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; 
494   TClonesArray * digits = gime->Digits() ; 
495
496   cout << "AliPHOSDigitiser: event " << gAlice->GetEvNumber() << endl ;
497   cout << "       Number of entries in Digits list " << digits->GetEntriesFast() << endl ;
498   cout << endl ;
499   
500   fDigitsInRun +=  digits->GetEntriesFast() ; 
501
502   if(strstr(option,"all")){
503     
504     //loop over digits
505     AliPHOSDigit * digit;
506     cout << "Digit Id " << " Amplitude " <<  " Index "  <<  " Nprim " << " Primaries list " <<  endl;      
507     Int_t index ;
508     for (index = 0 ; index < digits->GetEntries() ; index++) {
509       digit = (AliPHOSDigit * )  digits->At(index) ;
510       cout << setw(8)  <<  digit->GetId() << " "  <<    setw(3)  <<  digit->GetAmp() <<   "  "  
511            << setw(6)  <<  digit->GetIndexInList() << "  "   
512            << setw(5)  <<  digit->GetNprimary() <<"  ";
513       
514       Int_t iprimary;
515       for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++)
516         cout << setw(5)  <<  digit->GetPrimary(iprimary+1) << " ";
517       cout << endl;      
518     }
519     
520   }
521 }
522
523 //__________________________________________________________________
524 void AliPHOSDigitizer::SetSDigitsBranch(const char* title)
525 {
526   // we set title (comment) of the SDigits branch in the first! header file
527   if( strcmp(GetName(), "") == 0 )
528     Init() ;
529
530   AliPHOSGetter::GetInstance()->SDigits()->SetName(title) ; 
531  
532 }
533 //____________________________________________________________________________
534 void AliPHOSDigitizer::Reset() 
535
536   // sets current event number to the first simulated event
537
538   if( strcmp(GetName(), "") == 0 )
539     Init() ;
540
541  //  Int_t inputs ;
542 //   for(inputs = 0; inputs < fNinputs ;inputs++)
543 //       fIevent->AddAt(-1, inputs ) ;
544   
545 }
546
547 //____________________________________________________________________________
548 void AliPHOSDigitizer::WriteDigits(Int_t event)
549 {
550
551   // Makes TreeD in the output file. 
552   // Check if branch already exists: 
553   //   if yes, exit without writing: ROOT TTree does not support overwriting/updating of 
554   //      already existing branches. 
555   //   else creates branch with Digits, named "PHOS", title "...",
556   //      and branch "AliPHOSDigitizer", with the same title to keep all the parameters
557   //      and names of files, from which digits are made.
558
559   AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; 
560   TClonesArray * digits = gime->Digits(GetName()) ; 
561
562   TTree * treeD ;
563
564   if(fARD)
565     treeD = fARD->GetTreeD() ;
566  else
567     treeD = gAlice->TreeD();
568   
569   // create new branches
570   // -- generate file name if necessary
571   char * file =0;
572   if(gSystem->Getenv("CONFIG_SPLIT_FILE")){ //generating file name
573     file = new char[strlen(gAlice->GetBaseFile())+20] ;
574     sprintf(file,"%s/PHOS.Digits.root",gAlice->GetBaseFile()) ;
575   }
576
577   TDirectory *cwd = gDirectory;
578   // -- create Digits branch
579   Int_t bufferSize = 32000 ;    
580   TBranch * digitsBranch = treeD->Branch("PHOS",&digits,bufferSize);
581   digitsBranch->SetTitle(GetName());
582   if (file) {
583     digitsBranch->SetFile(file);
584     TIter next( digitsBranch->GetListOfBranches());
585     TBranch * sbr ;
586     while ((sbr=(TBranch*)next())) {
587       sbr->SetFile(file);
588     }   
589     cwd->cd();
590   } 
591     
592   // -- Create Digitizer branch
593   Int_t splitlevel = 0 ;
594   AliPHOSDigitizer * d = gime->Digitizer(GetName()) ;
595   TBranch * digitizerBranch = treeD->Branch("AliPHOSDigitizer", "AliPHOSDigitizer", &d,bufferSize,splitlevel); 
596   digitizerBranch->SetTitle(GetName());
597   if (file) {
598     digitizerBranch->SetFile(file);
599     TIter next( digitizerBranch->GetListOfBranches());
600     TBranch * sbr;
601     while ((sbr=(TBranch*)next())) {
602       sbr->SetFile(file);
603     }   
604     cwd->cd();
605   }
606   
607   digitsBranch->Fill() ;      
608   digitizerBranch->Fill() ;
609
610   treeD->Write(0,kOverwrite) ;  
611  
612 }