]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITS.cxx
Most of these updates are related to the offline software needed for the pixel trigge...
[u/mrichter/AliRoot.git] / ITS / AliITS.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 ///////////////////////////////////////////////////////////////////////////////
20 //                                                                           //
21 //      An overview of the basic philosophy of the ITS code development      //
22 // and analysis is show in the figure below.                                 //
23 //Begin_Html                                                                 //
24 /*                                               
25 <img src="picts/ITS/ITS_Analysis_schema.gif">
26 </pre>
27 <br clear=left>
28 <font size=+2 color=red>
29 <p>Roberto Barbera is in charge of the ITS Offline code (1999).
30 <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
31 </font>
32 <pre>
33 */
34 //End_Html
35 //
36 //  AliITS. Inner Traking System base class.
37 //  This class contains the base procedures for the Inner Tracking System
38 //
39 //Begin_Html
40 /*
41 <img src="picts/ITS/AliITS_Class_Diagram.gif">
42 </pre>
43 <br clear=left>
44 <font size=+2 color=red>
45 <p>This show the class diagram of the different elements that are part of
46 the AliITS class.
47 </font>
48 <pre>
49 */
50 //End_Html
51 //
52 // Version: 0
53 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
54 //
55 // Version: 1
56 // Modified and documented by Bjorn S. Nilsen
57 // July 11 1999
58 //
59 // Version: 2
60 // Modified and documented by A. Bologna
61 // October 18 1999
62 //
63 // AliITS is the general base class for the ITS. Also see AliDetector for
64 // futher information.
65 //
66 ///////////////////////////////////////////////////////////////////////////////
67
68 #include <stdlib.h>
69 #include <TClonesArray.h>
70 #include <TFile.h>
71 #include <TParticle.h>
72 #include <TString.h>
73 #include <TTree.h>
74 #include <TVirtualMC.h>
75 #include "AliDetector.h"
76 #include "AliITS.h"
77 #include "AliITSDetTypeSim.h"
78 #include "AliITSDDLRawData.h"
79 #include "AliITSLoader.h"
80 #include "AliITShit.h"
81 #include "AliITSmodule.h"
82 #include "AliITSpListItem.h"
83 #include "AliITSsimulation.h"
84 #include "AliITSsimulationFastPoints.h"
85 #include "AliMC.h"
86 #include "AliITSDigitizer.h"
87 #include "AliITSRecPoint.h"
88 #include "AliITSsegmentationSPD.h"
89 #include "AliITSsegmentationSDD.h"
90 #include "AliITSsegmentationSSD.h"
91 #include "AliITSRawStreamSPD.h"
92 #include "AliITSRawStreamSSD.h"
93 #include "AliITSRawStreamSDD.h"
94 #include "AliRawReader.h"
95 #include "AliRun.h"
96 #include "AliLog.h"
97 #include "AliITSInitGeometry.h"
98 #include "AliITSFOSignalsSPD.h"
99
100 ClassImp(AliITS)
101
102 //______________________________________________________________________
103 AliITS::AliITS() : AliDetector(),
104 fDetTypeSim(0),
105 fEuclidOut(0),
106 fOpt("All"),
107 fIdN(0),
108 fIdSens(0),
109 fIdName(0),
110 fITSmodules(0),
111 fTiming(kFALSE)
112 {
113   // Default initializer for ITS
114   //      The default constructor of the AliITS class. In addition to
115   // creating the AliITS class it zeros the variables fIshunt (a member
116   // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
117   // fIdSens, and fIdName. The AliDetector default constructor
118   // is also called.
119   
120 //    SetDetectors(); // default to fOpt="All". This variable not written out.
121 //PH    SetMarkerColor(kRed);
122 }
123 //______________________________________________________________________
124 AliITS::AliITS(const Char_t *title):AliDetector("ITS",title),
125 fDetTypeSim(0),
126 fEuclidOut(0),
127 fOpt("All"),
128 fIdN(0),
129 fIdSens(0),
130 fIdName(0),
131 fITSmodules(0),
132 fTiming(kFALSE)
133 {
134     //     The standard Constructor for the ITS class. 
135     // It also zeros the variables
136     // fIshunt (a member of AliDetector class), fEuclidOut, and zeros
137     // the pointers fIdSens and fIdName. To help in displaying hits via the
138     // ROOT macro display.C AliITS also sets the marker color to red. The
139     // variables passes with this constructor, const char *name and *title,
140     // are used by the constructor of AliDetector class. See AliDetector
141     // class for a description of these parameters and its constructor
142     // functions.
143     // Inputs:
144     //   Char_t *title  Simulation title for the ITS
145     // Outputs:
146     //   none.
147     // Return:
148     //   none.
149   
150     fHits = new TClonesArray("AliITShit",1560); // from AliDetector
151     if(gAlice->GetMCApp()) gAlice->GetMCApp()->AddHitList(fHits);
152     //fNhits=0;  //done in AliDetector(name,title)
153     SetDetectors(); // default to fOpt="All". This variable not written out.
154     fDetTypeSim   = new AliITSDetTypeSim();
155     //PH  SetMarkerColor(kRed);
156     if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName());
157     fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
158 }
159 //______________________________________________________________________
160 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title),
161 fDetTypeSim(0),
162 fEuclidOut(0),
163 fOpt("All"),
164 fIdN(0),
165 fIdSens(0),
166 fIdName(0),
167 fITSmodules(0),
168 fTiming(kFALSE)
169 {
170   //     The standard Constructor for the ITS class. 
171   // It also zeros the variables
172   // fIshunt (a member of AliDetector class), fEuclidOut, and zeros
173   // the pointers fIdSens and fIdName. To help in displaying hits via the
174   // ROOT macro display.C AliITS also sets the marker color to red. The
175   // variables passes with this constructor, const char *name and *title,
176   // are used by the constructor of AliDetector class. See AliDetector
177   // class for a description of these parameters and its constructor
178   // functions.
179   
180   fHits = new TClonesArray("AliITShit",1560);
181   if(gAlice->GetMCApp()) gAlice->GetMCApp()->AddHitList(fHits);
182   //fNhits=0;  //done in AliDetector(name,title)
183
184   SetDetectors(); // default to fOpt="All". This variable not written out.
185     
186   fDetTypeSim   = new AliITSDetTypeSim();
187   
188   //PH  SetMarkerColor(kRed);
189   if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName());
190   fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
191
192 }
193 //______________________________________________________________________
194 AliITS::~AliITS(){
195     // Default destructor for ITS.
196     //     The default destructor of the AliITS class. In addition to deleting
197     // the AliITS class it deletes the memory pointed to by 
198     // fIdSens, fIdName, fDetTypeSim and it's contents.
199     // Inputs:
200     //      none.
201     // Outputs:
202     //      none.
203     // Return:
204     //      none.
205
206     if (fHits) {
207       fHits->Delete();
208       delete fHits;
209       fHits=0;
210     }
211     if(fITSmodules) {
212         this->ClearModules();
213         delete fITSmodules;
214         fITSmodules = 0;
215     }// end if fITSmodules!=0
216
217     delete[] fIdName;  // Array of TStrings
218     delete[] fIdSens;
219
220     if (fDetTypeSim){
221       delete fDetTypeSim;
222       fDetTypeSim = 0;
223    }
224 }
225 //______________________________________________________________________
226 AliDigitizer* AliITS::CreateDigitizer(AliRunDigitizer* manager)const{
227     // Creates the AliITSDigitizer in a standard way for use via AliModule.
228     // This function can not be included in the .h file because of problems
229     // with the order of inclusion (recursive).
230     // Inputs:
231     //    AliRunDigitizer *manager  The Manger class for Digitization
232     // Output:
233     //    none.
234     // Return:
235     //    A new AliITSRunDigitizer (cast as a AliDigitizer).
236
237      return new AliITSDigitizer(manager);
238 }
239 //______________________________________________________________________
240 void AliITS::Init(){
241     // Initializer ITS after it has been built
242     //     This routine initializes the AliITS class. It is intended to be
243     // called from the Init function in AliITSv?. Besides displaying a banner
244     // indicating that it has been called it initializes the array fIdSens
245     // and sets the default segmentation, response, digit and raw cluster
246     // classes therefore it should be called after a call to CreateGeometry.
247     // Inputs:
248     //      none.
249     // Outputs:
250     //      none.
251     // Return:
252     //      none.
253     Int_t i;
254     // Array of TStrings
255     if(gMC) for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
256  
257 }
258 //______________________________________________________________________
259 void AliITS::SetDefaults(){
260     // sets the default segmentation, response, digit and raw cluster classes.
261     // Inputs:
262     //      none.
263     // Outputs:
264     //      none.
265     // Return:
266     //      none.
267     AliInfoClass("AliITS::Setting Defaults");
268     if(!fDetTypeSim) { 
269      Error("SetDefaults()","fDetTypeSim is 0!"); 
270      return;
271     }
272
273     fDetTypeSim->SetDefaults();
274
275
276 }
277 //______________________________________________________________________
278 void AliITS::SetDefaultSimulation(){
279     // sets the default simulation.
280     // Inputs:
281     //      none.
282     // Outputs:
283     //      none.
284     // Return:
285     //      none.
286     if(!fDetTypeSim) { 
287      Error("SetDefaultSimulation()","fDetTypeSim is 0!"); 
288      return;
289     }
290
291     fDetTypeSim->SetDefaultSimulation();
292
293 }
294
295
296 //______________________________________________________________________
297 void AliITS::MakeBranch(Option_t* option){
298     // Creates Tree branches for the ITS.
299     // Inputs:
300     //      Option_t *option    String of Tree types S,D, and/or R.
301     //      const char *file    String of the file name where these branches
302     //                          are to be stored. If blank then these branches
303     //                          are written to the same tree as the Hits were
304     //                          read from.
305     // Outputs:
306     //      none.
307     // Return:
308     //      none.
309   if(!fDetTypeSim) {
310     Error("MakeBranch","fDetTypeSim is 0!");
311     return;
312   }
313
314   Bool_t cH = (strstr(option,"H")!=0);
315   Bool_t cS = (strstr(option,"S")!=0);
316   Bool_t cD = (strstr(option,"D")!=0);
317   
318   if(cH && (fHits == 0x0)) fHits = new TClonesArray("AliITShit", 1560);
319   AliDetector::MakeBranch(option);
320   
321   if(cS) MakeBranchS(0);
322   if(cD) MakeBranchD(0);
323
324
325 }
326 //___________________________________________________________________
327 void AliITS::MakeBranchS(const char* fl){
328
329   // Creates Tree Branch for the ITS summable digits.
330   // Inputs:
331   //      cont char *fl  File name where SDigits branch is to be written
332   //                     to. If blank it write the SDigits to the same
333   //                     file in which the Hits were found.
334
335   
336   if(!fDetTypeSim){
337     Error("MakeBranchS","fDetTypeSim is 0!");
338   }
339   Int_t buffersize = 4000;
340   char branchname[30];
341
342   // only one branch for SDigits.
343   sprintf(branchname,"%s",GetName());
344
345   if(fLoader->TreeS()){
346     TClonesArray* sdig = (TClonesArray*)fDetTypeSim->GetSDigits();
347     MakeBranchInTree(fLoader->TreeS(),branchname,&sdig,buffersize,fl);
348   } 
349 }
350 //______________________________________________________________________
351 void AliITS::MakeBranchD(const char* file){
352
353   //Make branch for digits
354   if(!fDetTypeSim) {
355     Warning("MakeBranchD","fDetTypeSim is 0!");
356     return;
357   }
358   fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
359   MakeBranchInTreeD(fLoader->TreeD(),file);
360 }
361
362 //___________________________________________________________________
363 void AliITS:: MakeBranchInTreeD(TTree* treeD, const char* file){
364   // Creates Tree branches for the ITS.
365
366   if(!fDetTypeSim){
367     Error("MakeBranchS","fDetTypeSim is 0!");
368   }
369   fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
370
371   const Char_t *det[3] = {"SPD","SDD","SSD"};
372   const Char_t* digclass;
373   Int_t buffersize = 4000;
374   Char_t branchname[30];
375   
376   if(!fDetTypeSim->GetDigits()){
377     fDetTypeSim->SetDigits(new TObjArray(fgkNTYPES));
378   }
379   for(Int_t i=0;i<fgkNTYPES;i++){
380     digclass = fDetTypeSim->GetDigitClassName(i);
381     TString classn = digclass;
382     if(!((fDetTypeSim->GetDigits())->At(i))){
383       (fDetTypeSim->GetDigits())->AddAt(new TClonesArray(classn.Data(),1000),i);
384     }
385     else ResetDigits(i);  
386     if(fgkNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
387     else sprintf(branchname,"%sDigits%d",GetName(),i+1);
388     TObjArray* dig = DigitsAddress(i);
389     if(GetDigits() && treeD) AliDetector::MakeBranchInTree(treeD,branchname, &dig,buffersize,file);
390   }
391
392 }
393 //______________________________________________________________________
394 void AliITS::SetTreeAddress(){
395     // Set branch address for the Trees.
396     // Inputs:
397     //      none.
398     // Outputs:
399     //      none.
400     // Return:
401     //      none.
402     
403   if(!fDetTypeSim) {
404     Error("SetTreeAddress","fDetTypeSim is 0!");
405     return;
406   }
407
408   fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
409
410   TTree *treeS = fLoader->TreeS();
411   TTree *treeD = fLoader->TreeD();
412   if (fLoader->TreeH() && (fHits == 0x0)) {
413       fHits = new TClonesArray("AliITShit", 1560);
414   }
415   AliDetector::SetTreeAddress();
416
417   fDetTypeSim->SetTreeAddressS(treeS, (Char_t*)GetName());
418   fDetTypeSim->SetTreeAddressD(treeD, (Char_t*)GetName());
419 }
420 //______________________________________________________________________
421 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
422     // Add an ITS hit
423     //     The function to add information to the AliITShit class. See the
424     // AliITShit class for a full description. This function allocates the
425     // necessary new space for the hit information and passes the variable
426     // track, and the pointers *vol and *hits to the AliITShit constructor
427     // function.
428     // Inputs:
429     //      Int_t   track   Track number which produced this hit.
430     //      Int_t   *vol    Array of Integer Hit information. See AliITShit.h
431     //      Float_t *hits   Array of Floating Hit information.  see AliITShit.h
432     // Outputs:
433     //      none.
434     // Return:
435     //      none.
436   TClonesArray &lhits = *fHits;
437   new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
438 }
439
440 //______________________________________________________________________
441 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
442                          Option_t *option, const char *filename){
443   // fill the modules with the sorted by module hits; add hits from
444   // background if option=Add.
445
446   static TTree *trH1;                 //Tree with background hits
447   static Bool_t first=kTRUE;
448   static TFile *file;
449   const char *addBgr = strstr(option,"Add");
450   
451   evnt = nmodules; // Dummy use of variables to remove warnings
452   if (addBgr ) {
453     if(first) {
454       file=new TFile(filename);
455     } // end if first
456     first=kFALSE;
457     file->cd();
458     file->ls();
459     // Get Hits Tree header from file
460     if(trH1) delete trH1;
461     trH1=0;
462     
463     char treeName[20];
464     sprintf(treeName,"TreeH%d",bgrev);
465     trH1 = (TTree*)gDirectory->Get(treeName);
466     if (!trH1) {
467       Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
468     } // end if !trH1
469     // Set branch addresses
470   } // end if addBgr
471   
472   FillModules(fLoader->TreeH(),0); // fill from this file's tree.
473     
474   if (addBgr ) {
475     FillModules(trH1,10000000); // Default mask 10M.
476     TTree *fAli=fLoader->GetRunLoader()->TreeK();
477     TFile *fileAli=0;
478     if (fAli) fileAli =fAli->GetCurrentFile();
479     fileAli->cd();
480   } // end if add
481   
482   
483 }
484 //______________________________________________________________________
485 void AliITS::FillModules(TTree *treeH, Int_t mask) {
486     // fill the modules with the sorted by module hits; 
487     // can be called many times to do a merging
488     // Inputs:
489     //      TTree *treeH  The tree containing the hits to be copied into
490     //                    the modules.
491     //      Int_t mask    The track number mask to indecate which file
492     //                    this hits came from.
493     // Outputs:
494     //      none.
495     // Return:
496     //      none.
497
498     if (treeH == 0x0)
499      {
500        Error("FillModules","Tree is NULL");
501      }
502     Int_t lay,lad,det,index;
503     AliITShit *itsHit=0;
504     AliITSmodule *mod=0;
505     char branchname[20];
506     sprintf(branchname,"%s",GetName());
507     TBranch *branch = treeH->GetBranch(branchname);
508     if (!branch) {
509         Error("FillModules","%s branch in TreeH not found",branchname);
510         return;
511     } // end if !branch
512     branch->SetAddress(&fHits);
513     Int_t nTracks =(Int_t) treeH->GetEntries();
514     Int_t iPrimTrack,h;
515     for(iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++){
516         ResetHits();
517         Int_t nBytes = treeH->GetEvent(iPrimTrack);
518         if (nBytes <= 0) continue;
519         Int_t nHits = fHits->GetEntriesFast();
520         for(h=0; h<nHits; h++){
521             itsHit = (AliITShit *)fHits->UncheckedAt(h);
522             itsHit->GetDetectorID(lay,lad,det);
523             if (GetITSgeom()) {
524                 index = GetITSgeom()->GetModuleIndex(lay,lad,det);
525             } else {
526                 index=det-1; // This should not be used.
527             } // end if [You must have fITSgeom for this to work!]
528             mod = GetModule(index);
529             itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask.
530             mod->AddHit(itsHit,iPrimTrack,h);
531         } // end loop over hits 
532     } // end loop over tracks
533 }
534
535 //______________________________________________________________________
536 Bool_t AliITS::InitModules(Int_t size,Int_t &nmodules){
537     // Initialize the modules array.
538     // Inputs:
539     //      Int_t size  Size of array of the number of modules to be
540     //                  created. If size <=0 then the number of modules
541     //                  is gotten from AliITSgeom class kept in fITSgeom.
542     // Outputs:
543     //      Int_t &nmodules The number of modules existing.
544     // Return:
545     //      none.
546
547     if(fITSmodules){ 
548         fITSmodules->Delete();
549         delete fITSmodules;
550     } // end fir fITSmoudles
551
552     if(!fDetTypeSim) {
553       Error("InitModules","fDetTypeSim is null!");
554       return kFALSE;
555     }
556
557     Int_t nl,indexMAX,index;
558
559     if(size<=0){ // default to using data stored in AliITSgeom
560         if(fDetTypeSim->GetITSgeom()==0) {
561             Error("InitModules","fITSgeom not defined");
562             return kFALSE;
563         } // end if fITSgeom==0
564         nl = fDetTypeSim->GetITSgeom()->GetNlayers();
565         indexMAX = fDetTypeSim->GetITSgeom()->GetIndexMax();
566         nmodules = indexMAX;
567         fITSmodules = new TObjArray(indexMAX);
568         for(index=0;index<indexMAX;index++){
569             fITSmodules->AddAt( new AliITSmodule(index),index);
570         } // end for index
571     }else{
572         fITSmodules = new TObjArray(size);
573         for(index=0;index<size;index++) {
574             fITSmodules->AddAt( new AliITSmodule(index),index);
575         } // end for index
576
577         nmodules = size;
578     } // end i size<=0
579     return kTRUE;
580 }
581 //______________________________________________________________________
582 void AliITS::Hits2SDigits(){
583     // Standard Hits to summable Digits function.
584     // Inputs:
585     //      none.
586     // Outputs:
587     //      none.
588   
589
590    if(!fDetTypeSim) {
591      Error("Hits2SDigits","fDetTypeSim is null!");
592      return; 
593   } 
594      
595   SetDefaults();
596   fLoader->LoadHits("read");
597   fLoader->LoadSDigits("recreate");
598   AliRunLoader* rl = fLoader->GetRunLoader(); 
599   fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
600   for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
601         // Do the Hits to Digits operation. Use Standard input values.
602         // Event number from file, no background hit merging , use size from
603         // AliITSgeom class, option="All", input from this file only.
604     rl->GetEvent(iEvent);
605     if (!fLoader->TreeS()) fLoader->MakeTree("S");
606     MakeBranch("S");
607     SetTreeAddress();
608     HitsToPreDigits(iEvent,0,-1," ",fOpt," ");
609   } // end for iEvent
610     
611   fLoader->UnloadHits();
612   fLoader->UnloadSDigits();
613   
614 }
615 //______________________________________________________________________
616 void AliITS::Hits2Digits(){
617
618   //Conversion from hits to digits
619   if(!fDetTypeSim) {
620     Error("Hits2SDigits","fDetTypeSim is 0!");
621     return;
622   }
623    
624   fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
625   SetDefaults();
626
627   fLoader->LoadHits("read");
628   fLoader->LoadDigits("recreate");
629   AliRunLoader* rl = fLoader->GetRunLoader(); 
630   for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
631     rl->GetEvent(iEvent);
632     if (!fLoader->TreeD()) fLoader->MakeTree("D");
633     MakeBranch("D");
634     SetTreeAddress();   
635     HitsToDigits(iEvent,0,-1," ",fOpt," ");
636   } 
637   
638   fLoader->UnloadHits();
639   fLoader->UnloadDigits();
640   
641 }
642
643 //______________________________________________________________________
644 void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
645                           Option_t *option,Option_t *opt,
646                           const char *filename){
647     //   Keep galice.root for signal and name differently the file for 
648     // background when add! otherwise the track info for signal will be lost !
649     // the condition below will disappear when the geom class will be
650     // initialized for all versions - for the moment it is only for v5 !
651     // 7 is the SDD beam test version.
652     // Inputs:
653     //      Int_t evnt       Event to be processed.
654     //      Int_t bgrev      Background Hit tree number.
655     //      Int_t nmodules   Not used.
656     //      Option_t *option String indicating if merging hits or not. To
657     //                       merge hits set equal to "Add". Otherwise no
658     //                       background hits are considered.
659     //      Test_t *filename File name containing the background hits..
660     // Outputs:
661     //      none.
662     // Return:
663     //      none.
664
665   if(!fDetTypeSim) {
666     Error("HitsToDigits","fDetTypeSim is null!");
667     return;
668   }
669   fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
670   if(!GetITSgeom()) return; // need transformations to do digitization.
671   AliITSgeom *geom = GetITSgeom();
672
673   const char *all = strstr(opt,"All");
674   const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
675                         strstr(opt,"SSD")};
676   static Bool_t setDef=kTRUE;
677   if (setDef) SetDefaultSimulation();
678   setDef=kFALSE;
679   
680   Int_t nmodules;
681   InitModules(size,nmodules);
682   FillModules(evNumber,bgrev,nmodules,option,filename);
683  
684   // Reset Fast-OR signals for this event
685   fDetTypeSim->ResetFOSignals();
686
687   AliITSsimulation *sim      = 0;
688   AliITSmodule     *mod      = 0;
689   Int_t id;
690   for(Int_t module=0;module<geom->GetIndexMax();module++){
691     id       = geom->GetModuleType(module);
692     if (!all && !det[id]) continue;
693     sim      = (AliITSsimulation*)fDetTypeSim->GetSimulationModel(id);
694     if (!sim) {
695       Error("HitsToDigits","The simulation class was not "
696             "instanciated for module %d type %s!",module,
697             geom->GetModuleTypeName(module));
698       exit(1);
699     } // end if !sim
700     mod      = (AliITSmodule *)fITSmodules->At(module);
701     sim->DigitiseModule(mod,module,evNumber);
702     // fills all branches - wasted disk space
703     fLoader->TreeD()->Fill(); 
704     ResetDigits();
705   } // end for module
706   
707   ClearModules();
708   
709   // Add random noise to FO signals
710   if (all || det[0]) { // SPD present
711     fDetTypeSim->ProcessNoiseForFastOr();
712   }
713
714   // Add Fast-OR signals to event (only one object per event)
715   if (all || det[0]) { // SPD present
716     fDetTypeSim->WriteFOSignals();
717   }
718
719   
720   fLoader->TreeD()->GetEntries();
721   fLoader->TreeD()->AutoSave();
722   // reset tree
723   fLoader->TreeD()->Reset();
724 }
725 //_____________________________________________________________________
726 void AliITS::Hits2PreDigits(){ 
727   // Turn hits into SDigits
728
729   if(!fDetTypeSim) {
730     Error("Hits2SDigits","fDetTypeSim is 0!");
731     return;
732   }
733    
734   fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
735   SetDefaults();
736   
737   HitsToPreDigits(fLoader->GetRunLoader()->GetEventNumber(),
738                   0,-1," ",fOpt," ");
739 }
740
741 //______________________________________________________________________
742 void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
743                              Option_t *option,Option_t *opt,
744                              const char *filename){
745     //   Keep galice.root for signal and name differently the file for 
746     // background when add! otherwise the track info for signal will be lost !
747     // the condition below will disappear when the geom class will be
748     // initialized for all versions - for the moment it is only for v5 !
749     // 7 is the SDD beam test version.
750     // Inputs:
751     //      Int_t evnt       Event to be processed.
752     //      Int_t bgrev      Background Hit tree number.
753     //      Int_t nmodules   Not used.
754     //      Option_t *option String indicating if merging hits or not. To
755     //                       merge hits set equal to "Add". Otherwise no
756     //                       background hits are considered.
757     //      Test_t *filename File name containing the background hits..
758     // Outputs:
759     //      none.
760     // Return:
761     //      none.
762
763  
764   if(!fDetTypeSim) {
765     Error("HitsToPreDigits","fDetTypeSim is null!");
766     return;
767   }
768   fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
769
770   if(!GetITSgeom()){
771     Error("HitsToPreDigits","fGeom is null!");
772     return; // need transformations to do digitization.
773   }
774   AliITSgeom *geom = GetITSgeom();
775
776   const char *all = strstr(opt,"All");
777   const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
778                         strstr(opt,"SSD")};
779   static Bool_t setDef=kTRUE;
780   if (setDef) SetDefaultSimulation();
781   setDef=kFALSE;
782   
783   Int_t nmodules;
784   InitModules(size,nmodules);
785   FillModules(evNumber,bgrev,nmodules,option,filename);
786   
787
788   AliITSsimulation *sim      = 0;
789   AliITSmodule     *mod      = 0;
790   Int_t id,module;
791   for(module=0;module<geom->GetIndexMax();module++){
792     id       = geom->GetModuleType(module);
793     if (!all && !det[id]) continue;
794     sim      = (AliITSsimulation*)GetSimulationModel(id);
795     if (!sim) {
796       Error("HitsToPreDigits","The simulation class was not "
797             "instanciated for module %d type %s!",module,
798             geom->GetModuleTypeName(module));
799       exit(1);
800     } // end if !sim
801     mod      = (AliITSmodule *)fITSmodules->At(module);
802     sim->SDigitiseModule(mod,module,evNumber);
803     // fills all branches - wasted disk space
804     fLoader->TreeS()->Fill(); 
805     fDetTypeSim->ResetSDigits();
806   } // end for module
807
808   ClearModules();
809
810   
811   fLoader->TreeS()->GetEntries();
812   fLoader->TreeS()->AutoSave();
813   fLoader->WriteSDigits("OVERWRITE");
814   // reset tree
815   fLoader->TreeS()->Reset();
816 }
817
818 //_____________________________________________________________________
819 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
820                                   Option_t *opt0,Option_t *opt1,
821                                  const char *flnm){
822     // keep galice.root for signal and name differently the file for 
823     // background when add! otherwise the track info for signal will be lost !
824     // the condition below will disappear when the geom class will be
825     // initialized for all versions - for the moment it is only for v5 !
826     // Inputs:
827     //      Int_t evnt       Event to be processed.
828     //      Int_t bgrev      Background Hit tree number.
829     //      Int_t size       Size used by InitModules. See InitModules.
830     //      Option_t *opt0   Option passed to FillModules. See FillModules.
831     //      Option_t *opt1   String indicating if merging hits or not. To
832     //                       merge hits set equal to "Add". Otherwise no
833     //                       background hits are considered.
834     //      Test_t *flnm     File name containing the background hits..
835     // Outputs:
836     //      none.
837     // Return:
838     //      none.
839
840
841
842   if(!GetITSgeom()){
843     Error("HitsToPreDigits","fGeom is null!");
844     return; // need transformations to do digitization.
845   }
846   AliITSgeom *geom = GetITSgeom();
847
848   AliITSLoader *pITSloader = (AliITSLoader*)fLoader;
849
850   const char *all = strstr(opt1,"All");
851   const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"),
852                        strstr(opt1,"SSD")};
853   Int_t nmodules;
854   InitModules(size,nmodules);
855   FillModules(evNumber,bgrev,nmodules,opt0,flnm);
856
857   AliITSsimulation *sim      = 0;
858   AliITSmodule     *mod      = 0;
859   Int_t id,module;
860
861   TTree *lTR = pITSloader->TreeR();
862   if(!lTR) {
863     pITSloader->MakeTree("R");
864     lTR = pITSloader->TreeR();
865   }
866   
867   TClonesArray* ptarray = new TClonesArray("AliITSRecPoint",1000);
868   TBranch* branch = (TBranch*)lTR->Branch("ITSRecPointsF",&ptarray);
869   branch->SetAddress(&ptarray);
870   //m.b. : this change is nothing but a nice way to make sure
871   //the CPU goes up !    
872   for(module=0;module<geom->GetIndexMax();module++){
873     id       = geom->GetModuleType(module);
874     if (!all && !det[id]) continue;
875     sim      = (AliITSsimulation*)GetSimulationModel(id);
876     if (!sim) {
877       Error("HitsToFastPoints","The simulation class was not "
878             "instanciated for module %d type %x!",module,
879             geom->GetModuleTypeName(module));
880       exit(1);
881     } // end if !sim
882     mod      = (AliITSmodule *)fITSmodules->At(module);
883     sim->CreateFastRecPoints(mod,module,gRandom,ptarray);
884     lTR->Fill();
885   } // end for module
886
887   ClearModules();
888   fLoader->WriteRecPoints("OVERWRITE");
889   delete ptarray;
890 }
891 //_____________________________________________________________________
892 Int_t AliITS::Hits2Clusters(TTree *hTree, TTree *cTree) {
893   //------------------------------------------------------------
894   // This function creates ITS clusters
895   //------------------------------------------------------------
896   if(!GetITSgeom()){
897     Error("HitsToPreDigits","fGeom is null!");
898     return 1; // need transformations to do digitization.
899   }
900   AliITSgeom *geom=GetITSgeom();
901   Int_t mmax=geom->GetIndexMax();
902
903   InitModules(-1,mmax);
904   FillModules(hTree,0);
905
906   TClonesArray *points = new TClonesArray("AliITSRecPoint",1000);
907   TBranch *branch=cTree->GetBranch("ITSRecPoints");
908   if (!branch) cTree->Branch("ITSRecPoints",&points);
909   else branch->SetAddress(&points);
910
911   AliITSsimulationFastPoints sim;
912   Int_t ncl=0;
913   for (Int_t m=0; m<mmax; m++) {
914     AliITSmodule *mod=GetModule(m);      
915     sim.CreateFastRecPoints(mod,m,gRandom,points);      
916     ncl+=points->GetEntriesFast();
917     cTree->Fill();
918     points->Clear();
919   }
920
921   Info("Hits2Clusters","Number of found fast clusters : %d",ncl);
922
923   //cTree->Write();
924
925   delete points;
926   return 0;
927 }
928
929 //_____________________________________________________________________
930 void AliITS::CheckLabels(Int_t lab[3]) const {
931   //------------------------------------------------------------
932   // Tries to find mother's labels
933   //------------------------------------------------------------
934
935   if(lab[0]<0 && lab[1]<0 && lab[2]<0) return; // In case of no labels just exit
936
937   Int_t ntracks = gAlice->GetMCApp()->GetNtrack();
938   for (Int_t i=0;i<3;i++){
939     Int_t label = lab[i];
940     if (label>=0 && label<ntracks) {
941       TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label);
942       if (part->P() < 0.005) {
943         Int_t m=part->GetFirstMother();
944         if (m<0) {      
945           continue;
946         }
947         if (part->GetStatusCode()>0) {
948           continue;
949         }
950         lab[i]=m;       
951       }
952     }    
953   }
954   
955 }
956
957 //______________________________________________________________________
958 void AliITS::SDigitsToDigits(Option_t *opt){
959   // Standard Summable digits to Digits function.
960   // Inputs:
961   //      none.
962   // Outputs:
963   //      none.
964   if (!fDetTypeSim) {
965     AliError("fDetTypeSim is 0!");
966     return;
967   }
968
969   const char *all = strstr(opt,"All");
970   const char *det[3] ={strstr(opt,"SPD"),strstr(opt,"SDD"),
971                        strstr(opt,"SSD")};
972
973   // Reset Fast-OR signals for this event
974   fDetTypeSim->ResetFOSignals();
975
976   fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
977   SetDefaults();
978   fDetTypeSim->SDigitsToDigits(opt,(Char_t*)GetName());
979
980   // Add random noise to FO signals
981   if (all || det[0]) { // SPD present
982     fDetTypeSim->ProcessNoiseForFastOr();
983   }
984   // Add Fast-OR signals to event (only one object per event)
985   if (all || det[0]) { // SPD present
986     fDetTypeSim->WriteFOSignals();
987   }
988 }
989
990 //______________________________________________________________________
991 void AliITS::ResetDigits(){
992     // Reset number of digits and the digits array for the ITS detector.
993     // Inputs:
994     //      none.
995     // Outputs:
996     //      none.
997     if(!fDetTypeSim) {
998       Error("ResetDigits","fDetTypeSim is 0!");
999       return;
1000     }
1001    
1002     fDetTypeSim->ResetDigits();
1003
1004
1005 }
1006 //______________________________________________________________________
1007 void AliITS::ResetDigits(Int_t branch){
1008     // Reset number of digits and the digits array for this branch.
1009     // Inputs:
1010     //      none.
1011     // Outputs:
1012     //      none.
1013
1014     if(!fDetTypeSim) {
1015       Error("ResetDigits","fDetTypeSim is 0!");
1016       return;
1017     }
1018    
1019     fDetTypeSim->ResetDigits(branch);
1020
1021 }
1022 //______________________________________________________________________
1023 void AliITS::AddSumDigit(AliITSpListItem &sdig){
1024     // Adds the a module full of summable digits to the summable digits tree.
1025     // Inputs:
1026     //      AliITSpListItem &sdig   SDigit to be added to SDigits tree.
1027     // Outputs:
1028     //      none.
1029     // Return:
1030     //      none.
1031
1032     if(!fDetTypeSim) {
1033       Error("AddSumDigit","fDetTypeSim is 0!");
1034       return;
1035     }
1036     fDetTypeSim->AddSumDigit(sdig);
1037     
1038 }
1039 //______________________________________________________________________
1040 void AliITS::AddSimDigit(Int_t branch, AliITSdigit *d){
1041     //    Add a simulated digit.
1042     // Inputs:
1043     //      Int_t id        Detector type number.
1044     //      AliITSdigit *d  Digit to be added to the Digits Tree. See 
1045     //                      AliITSdigit.h
1046     // Outputs:
1047     //      none.
1048     // Return:
1049     //      none.
1050
1051     if(!fDetTypeSim) {
1052       Error("AddSimDigit","fDetTypeSim is 0!");
1053       return;
1054     }
1055     fDetTypeSim->AddSimDigit(branch,d);
1056
1057 }
1058 //______________________________________________________________________
1059 void AliITS::AddSimDigit(Int_t branch,Float_t phys,Int_t *digits,Int_t *tracks,
1060                          Int_t *hits,Float_t *charges, Int_t sigexpanded){
1061   //   Add a simulated digit to the list.
1062   // Inputs:
1063   //      Int_t id        Detector type number.
1064   //      Float_t phys    Physics indicator. See AliITSdigits.h
1065   //      Int_t *digits   Integer array containing the digits info. See 
1066   //                      AliITSdigit.h
1067   //      Int_t *tracks   Integer array [AliITSdigitS?D::GetNTracks()] 
1068   //                      containing the track numbers that contributed to
1069   //                      this digit.
1070   //      Int_t *hits     Integer array [AliITSdigitS?D::GetNTracks()]
1071   //                      containing the hit numbers, from AliITSmodule, that
1072   //                      contributed to this digit.
1073   //      Float_t *charge Floating point array of the signals contributed
1074   //                      to this digit by each track.
1075   // Outputs:
1076   //      none.
1077   // Return:
1078   //      none.
1079
1080     if(!fDetTypeSim) {
1081       Error("AddSimDigit","fDetTypeSim is 0!");
1082       return;
1083     }
1084     fDetTypeSim->AddSimDigit(branch,phys,digits,tracks,hits,charges,sigexpanded);
1085
1086 }
1087 //______________________________________________________________________
1088 void AliITS::Digits2Raw(){
1089     // convert digits of the current event to raw data
1090
1091   if(!fDetTypeSim) {
1092     Error("Digits2Raw","fDetTypeSim is 0!");
1093     return;
1094   }
1095   fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
1096   SetDefaults();
1097   fDetTypeSim->GetLoader()->LoadDigits();
1098   TTree* digits = fDetTypeSim->GetLoader()->TreeD();
1099   if (!digits) {
1100       Error("Digits2Raw", "no digits tree");
1101       return;
1102   }
1103   fDetTypeSim->SetTreeAddressD(digits,(Char_t*)GetName());
1104   
1105    // Get the FO signals for this event
1106   AliITSFOSignalsSPD* foSignals = NULL;
1107   AliRunLoader* runLoader = AliRunLoader::Instance();
1108   AliITSLoader* itsLoader = (AliITSLoader*) runLoader->GetLoader("ITSLoader");
1109   if (!itsLoader) {
1110     AliError("ITS loader is NULL.");
1111   }
1112   else {
1113     AliBaseLoader* foLoader = itsLoader->GetFOSignalsLoader();
1114     if (!foLoader) {
1115       AliError("FO signals base loader not retrieved.");
1116     }
1117     else {
1118       foLoader->Load();
1119       foSignals = (AliITSFOSignalsSPD*) foLoader->Get();
1120     }
1121   }
1122   Bool_t deleteFOsignalsLater = kFALSE;
1123   if (!foSignals) {
1124     AliError("FO signals not available. No FO bits will be written.");
1125     foSignals = new AliITSFOSignalsSPD(); // make a temporary dummy signals object
1126     deleteFOsignalsLater = kTRUE;
1127   }
1128   
1129   
1130   AliITSDDLModuleMapSDD* ddlsdd=fDetTypeSim->GetDDLModuleMapSDD();
1131   Bool_t isHLTmodeC=fDetTypeSim->IsHLTmodeC();
1132   AliITSDDLRawData rawWriter;
1133   if(isHLTmodeC) rawWriter.SetUseCompressedSDDFormat(kTRUE);
1134   else rawWriter.SetUseCompressedSDDFormat(kFALSE);
1135   //Verbose level
1136   // 0: Silent
1137   // 1: cout messages
1138   // 2: txt files with digits 
1139   //BE CAREFUL, verbose level 2 MUST be used only for debugging and
1140   //it is highly suggested to use this mode only for debugging digits files
1141   //reasonably small, because otherwise the size of the txt files can reach
1142   //quickly several MB wasting time and disk space.
1143   rawWriter.SetVerbose(0);
1144     
1145   //SILICON PIXEL DETECTOR
1146   Info("Digits2Raw", "Formatting raw data for SPD");
1147   rawWriter.RawDataSPD(digits->GetBranch("ITSDigitsSPD"),foSignals);
1148   if(deleteFOsignalsLater) delete foSignals;
1149     
1150   //SILICON DRIFT DETECTOR
1151   Info("Digits2Raw", "Formatting raw data for SDD");
1152   rawWriter.RawDataSDD(digits->GetBranch("ITSDigitsSDD"),ddlsdd);
1153     
1154   //SILICON STRIP DETECTOR
1155   Info("Digits2Raw", "Formatting raw data for SSD");
1156   rawWriter.RawDataSSD(digits->GetBranch("ITSDigitsSSD"));
1157
1158   fLoader->UnloadDigits();
1159 }
1160 //______________________________________________________________________
1161 AliLoader* AliITS::MakeLoader(const char* topfoldername){ 
1162     //builds ITSgetter (AliLoader type)
1163     //if detector wants to use castomized getter, it must overload this method
1164
1165     AliDebug(1,Form("Creating AliITSLoader. Top folder is %s.",
1166          topfoldername));
1167     fLoader = new AliITSLoader(GetName(),topfoldername);
1168     return fLoader;
1169 }
1170 //______________________________________________________________________
1171 Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader)
1172 {
1173   //
1174   // Converts RAW data to SDigits
1175   //
1176   // Get TreeS
1177   //
1178     Int_t last   = -1;
1179     Int_t size   = GetITSgeom()->GetIndexMax();
1180     TClonesArray** modA = new TClonesArray*[size];
1181     for (Int_t mod = 0; mod < size; mod++) modA[mod] = new TClonesArray("AliITSpListItem", 10000);
1182     
1183     AliLoader* loader =  (AliRunLoader::Instance())->GetLoader("ITSLoader");
1184     if (!loader){
1185         Error("Open","Can not get ITS loader from Run Loader");
1186         return kFALSE;
1187     }
1188
1189     TTree* tree = 0;
1190     tree = loader->TreeS();
1191     if (!tree){
1192         loader->MakeTree("S");
1193         tree = loader->TreeS();
1194     }
1195     //
1196     // Array for SDigits
1197     // 
1198     TClonesArray aSDigits("AliITSpListItem",10000), *itsSDigits=&aSDigits;
1199     Int_t bufsize = 32000;
1200     tree->Branch("ITS", &itsSDigits, bufsize);
1201     Int_t npx = 0;
1202     //
1203     // SPD
1204     //
1205     AliITSsegmentationSPD* segSPD = (AliITSsegmentationSPD*) fDetTypeSim->GetSegmentationModel(0);
1206     if(!segSPD){
1207       AliWarning("Set AliITS defaults");
1208       SetDefaults();
1209       segSPD = (AliITSsegmentationSPD*) fDetTypeSim->GetSegmentationModel(0);
1210     }
1211     npx = segSPD->Npx();
1212     Double_t thr, sigma; 
1213     
1214     AliITSRawStreamSPD inputSPD(rawReader);
1215     while(1){
1216         Bool_t next  = inputSPD.Next();
1217         if (!next) break;
1218
1219         Int_t module = inputSPD.GetModuleID();
1220         Int_t column = inputSPD.GetColumn();
1221         Int_t row    = inputSPD.GetRow();
1222         Int_t index  = npx * column + row;
1223
1224         if (module >= size) continue;
1225  
1226         last = (modA[module])->GetEntries();
1227         TClonesArray& dum = *modA[module];
1228         fDetTypeSim->GetSimuParam()->SPDThresholds(module,thr,sigma);
1229         thr += 1.;
1230         new (dum[last]) AliITSpListItem(-1, -1, module, index, thr);
1231     }
1232     rawReader->Reset();
1233
1234     //
1235     // SDD
1236     // 
1237     AliITSsegmentationSDD* segSDD = (AliITSsegmentationSDD*) fDetTypeSim->GetSegmentationModel(1);
1238     npx = segSDD->Npx();
1239     AliITSRawStreamSDD inputSDD(rawReader);
1240     AliITSDDLModuleMapSDD* ddlmap=fDetTypeSim->GetDDLModuleMapSDD();
1241     inputSDD.SetDDLModuleMap(ddlmap);
1242     while(1){
1243         Bool_t next  = inputSDD.Next();
1244         if (!next) break;
1245
1246         Int_t module = inputSDD.GetModuleID();
1247         Int_t anode  = inputSDD.GetAnode();
1248         Int_t time   = inputSDD.GetTime();
1249         Int_t signal10 = inputSDD.GetSignal();
1250         Int_t index  = npx * anode + time;
1251
1252         if (module >= size) continue;
1253         last = modA[module]->GetEntries();
1254         TClonesArray& dum = *modA[module];
1255         new (dum[last]) AliITSpListItem(-1, -1, module, index, Double_t(signal10));
1256         ((AliITSpListItem*) dum.At(last))->AddSignalAfterElect(module, index, Double_t(signal10));
1257         
1258     }
1259     rawReader->Reset();
1260
1261     //
1262     // SSD
1263     // 
1264     AliITSsegmentationSSD* segSSD = (AliITSsegmentationSSD*) fDetTypeSim->GetSegmentationModel(2);
1265     npx = segSSD->Npx();
1266     AliITSRawStreamSSD inputSSD(rawReader);
1267     while(1){
1268         Bool_t next  = inputSSD.Next();
1269         if (!next) break;
1270
1271         Int_t module  = inputSSD.GetModuleID();
1272         Int_t side    = inputSSD.GetSideFlag();
1273         Int_t strip   = inputSSD.GetStrip();
1274         Int_t signal  = inputSSD.GetSignal();
1275         Int_t index  = npx * side + strip;
1276
1277         if (module >= size) continue;
1278         
1279         last = modA[module]->GetEntries();
1280         TClonesArray& dum = *modA[module];
1281         new (dum[last]) AliITSpListItem(-1, -1, module, index, Double_t(signal));
1282     }
1283     rawReader->Reset();
1284      AliITSpListItem* sdig = 0;
1285     
1286     for (Int_t mod = 0; mod < size; mod++)
1287     {
1288         Int_t nsdig =  modA[mod]->GetEntries();
1289         for (Int_t ie = 0; ie < nsdig; ie++) {
1290             sdig = (AliITSpListItem*) (modA[mod]->At(ie));
1291             new (aSDigits[ie]) AliITSpListItem(-1, -1, mod, sdig->GetIndex(), sdig->GetSignal());
1292             Float_t sig = sdig->GetSignalAfterElect();
1293             if (sig > 0.) {
1294                 sdig = (AliITSpListItem*)aSDigits[ie];
1295                 sdig->AddSignalAfterElect(mod, sdig->GetIndex(), Double_t(sig));
1296             }
1297         }
1298         
1299         tree->Fill();
1300         aSDigits.Clear();
1301         modA[mod]->Clear();
1302     }
1303     loader->WriteSDigits("OVERWRITE");    
1304     delete modA;
1305     return kTRUE;
1306 }
1307
1308
1309 //______________________________________________________________________
1310 void AliITS::UpdateInternalGeometry(){
1311
1312   //reads new geometry from TGeo 
1313 //   AliDebug(1,"Delete ITSgeom and create a new one reading TGeo");
1314
1315   AliITSVersion_t version = (AliITSVersion_t)IsVersion();
1316   Int_t minor = 0;
1317   if(version==kvPPRasymmFMD) minor=2;  // default minor version for this geom.
1318   AliITSInitGeometry initgeom;
1319   AliITSgeom* geom = initgeom.CreateAliITSgeom(version,minor);
1320   SetITSgeom(geom);
1321 }
1322 //______________________________________________________________________
1323 AliTriggerDetector* AliITS::CreateTriggerDetector() const {
1324   // create an AliITSTrigger object (and set trigger conditions as input)
1325   return new AliITSTrigger(fDetTypeSim->GetTriggerConditions());
1326 }
1327