]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITS.cxx
Correct formula for phi, in case of current local X <0, in GetLocalXat and GetPhiZat
[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     ptarray->Clear();
886   } // end for module
887
888   ClearModules();
889   fLoader->WriteRecPoints("OVERWRITE");
890   delete ptarray;
891 }
892 //_____________________________________________________________________
893 Int_t AliITS::Hits2Clusters(TTree *hTree, TTree *cTree) {
894   //------------------------------------------------------------
895   // This function creates ITS clusters
896   //------------------------------------------------------------
897   if(!GetITSgeom()){
898     Error("HitsToPreDigits","fGeom is null!");
899     return 1; // need transformations to do digitization.
900   }
901   AliITSgeom *geom=GetITSgeom();
902   Int_t mmax=geom->GetIndexMax();
903
904   InitModules(-1,mmax);
905   FillModules(hTree,0);
906
907   TClonesArray *points = new TClonesArray("AliITSRecPoint",1000);
908   TBranch *branch=cTree->GetBranch("ITSRecPoints");
909   if (!branch) cTree->Branch("ITSRecPoints",&points);
910   else branch->SetAddress(&points);
911
912   AliITSsimulationFastPoints sim;
913   Int_t ncl=0;
914   for (Int_t m=0; m<mmax; m++) {
915     AliITSmodule *mod=GetModule(m);      
916     sim.CreateFastRecPoints(mod,m,gRandom,points);      
917     ncl+=points->GetEntriesFast();
918     cTree->Fill();
919     points->Clear();
920   }
921
922   AliDebug(1,Form("Number of found fast clusters : %d",ncl));
923
924   //cTree->Write();
925
926   delete points;
927   return 0;
928 }
929
930 //_____________________________________________________________________
931 void AliITS::CheckLabels(Int_t lab[3]) const {
932   //------------------------------------------------------------
933   // Tries to find mother's labels
934   //------------------------------------------------------------
935
936   if(lab[0]<0 && lab[1]<0 && lab[2]<0) return; // In case of no labels just exit
937
938   Int_t ntracks = gAlice->GetMCApp()->GetNtrack();
939   for (Int_t i=0;i<3;i++){
940     Int_t label = lab[i];
941     if (label>=0 && label<ntracks) {
942       TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label);
943       if (part->P() < 0.005) {
944         Int_t m=part->GetFirstMother();
945         if (m<0) {      
946           continue;
947         }
948         if (part->GetStatusCode()>0) {
949           continue;
950         }
951         lab[i]=m;       
952       }
953     }    
954   }
955   
956 }
957
958 //______________________________________________________________________
959 void AliITS::SDigitsToDigits(Option_t *opt){
960   // Standard Summable digits to Digits function.
961   // Inputs:
962   //      none.
963   // Outputs:
964   //      none.
965   if (!fDetTypeSim) {
966     AliError("fDetTypeSim is 0!");
967     return;
968   }
969
970   const char *all = strstr(opt,"All");
971   const char *det[3] ={strstr(opt,"SPD"),strstr(opt,"SDD"),
972                        strstr(opt,"SSD")};
973
974   // Reset Fast-OR signals for this event
975   fDetTypeSim->ResetFOSignals();
976
977   fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
978   SetDefaults();
979   fDetTypeSim->SDigitsToDigits(opt,(Char_t*)GetName());
980
981   // Add random noise to FO signals
982   if (all || det[0]) { // SPD present
983     fDetTypeSim->ProcessNoiseForFastOr();
984   }
985   // Add Fast-OR signals to event (only one object per event)
986   if (all || det[0]) { // SPD present
987     fDetTypeSim->WriteFOSignals();
988   }
989 }
990
991 //______________________________________________________________________
992 void AliITS::ResetDigits(){
993     // Reset number of digits and the digits array for the ITS detector.
994     // Inputs:
995     //      none.
996     // Outputs:
997     //      none.
998     if(!fDetTypeSim) {
999       Error("ResetDigits","fDetTypeSim is 0!");
1000       return;
1001     }
1002    
1003     fDetTypeSim->ResetDigits();
1004
1005
1006 }
1007 //______________________________________________________________________
1008 void AliITS::ResetDigits(Int_t branch){
1009     // Reset number of digits and the digits array for this branch.
1010     // Inputs:
1011     //      none.
1012     // Outputs:
1013     //      none.
1014
1015     if(!fDetTypeSim) {
1016       Error("ResetDigits","fDetTypeSim is 0!");
1017       return;
1018     }
1019    
1020     fDetTypeSim->ResetDigits(branch);
1021
1022 }
1023 //______________________________________________________________________
1024 void AliITS::AddSumDigit(AliITSpListItem &sdig){
1025     // Adds the a module full of summable digits to the summable digits tree.
1026     // Inputs:
1027     //      AliITSpListItem &sdig   SDigit to be added to SDigits tree.
1028     // Outputs:
1029     //      none.
1030     // Return:
1031     //      none.
1032
1033     if(!fDetTypeSim) {
1034       Error("AddSumDigit","fDetTypeSim is 0!");
1035       return;
1036     }
1037     fDetTypeSim->AddSumDigit(sdig);
1038     
1039 }
1040 //______________________________________________________________________
1041 void AliITS::AddSimDigit(Int_t branch, AliITSdigit *d){
1042     //    Add a simulated digit.
1043     // Inputs:
1044     //      Int_t id        Detector type number.
1045     //      AliITSdigit *d  Digit to be added to the Digits Tree. See 
1046     //                      AliITSdigit.h
1047     // Outputs:
1048     //      none.
1049     // Return:
1050     //      none.
1051
1052     if(!fDetTypeSim) {
1053       Error("AddSimDigit","fDetTypeSim is 0!");
1054       return;
1055     }
1056     fDetTypeSim->AddSimDigit(branch,d);
1057
1058 }
1059 //______________________________________________________________________
1060 void AliITS::AddSimDigit(Int_t branch,Float_t phys,Int_t *digits,Int_t *tracks,
1061                          Int_t *hits,Float_t *charges, Int_t sigexpanded){
1062   //   Add a simulated digit to the list.
1063   // Inputs:
1064   //      Int_t id        Detector type number.
1065   //      Float_t phys    Physics indicator. See AliITSdigits.h
1066   //      Int_t *digits   Integer array containing the digits info. See 
1067   //                      AliITSdigit.h
1068   //      Int_t *tracks   Integer array [AliITSdigitS?D::GetNTracks()] 
1069   //                      containing the track numbers that contributed to
1070   //                      this digit.
1071   //      Int_t *hits     Integer array [AliITSdigitS?D::GetNTracks()]
1072   //                      containing the hit numbers, from AliITSmodule, that
1073   //                      contributed to this digit.
1074   //      Float_t *charge Floating point array of the signals contributed
1075   //                      to this digit by each track.
1076   // Outputs:
1077   //      none.
1078   // Return:
1079   //      none.
1080
1081     if(!fDetTypeSim) {
1082       Error("AddSimDigit","fDetTypeSim is 0!");
1083       return;
1084     }
1085     fDetTypeSim->AddSimDigit(branch,phys,digits,tracks,hits,charges,sigexpanded);
1086
1087 }
1088 //______________________________________________________________________
1089 void AliITS::Digits2Raw(){
1090     // convert digits of the current event to raw data
1091
1092   if(!fDetTypeSim) {
1093     Error("Digits2Raw","fDetTypeSim is 0!");
1094     return;
1095   }
1096   fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
1097   SetDefaults();
1098   fDetTypeSim->GetLoader()->LoadDigits();
1099   TTree* digits = fDetTypeSim->GetLoader()->TreeD();
1100   if (!digits) {
1101       Error("Digits2Raw", "no digits tree");
1102       return;
1103   }
1104   fDetTypeSim->SetTreeAddressD(digits,(Char_t*)GetName());
1105   
1106    // Get the FO signals for this event
1107   AliITSFOSignalsSPD* foSignals = NULL;
1108   AliRunLoader* runLoader = AliRunLoader::Instance();
1109   AliITSLoader* itsLoader = (AliITSLoader*) runLoader->GetLoader("ITSLoader");
1110   if (!itsLoader) {
1111     AliError("ITS loader is NULL.");
1112   }
1113    else {
1114       if(!itsLoader->TreeD()) AliError("   !!! No TreeD available !!!");
1115       foSignals = (AliITSFOSignalsSPD*)itsLoader->TreeD()->GetUserInfo()->FindObject("AliITSFOSignalsSPD");
1116       if(!foSignals) AliError("FO signals not retrieved");
1117      }
1118  
1119   Bool_t deleteFOsignalsLater = kFALSE;
1120   if (!foSignals) {
1121     AliError("FO signals not available. No FO bits will be written.");
1122     foSignals = new AliITSFOSignalsSPD(); // make a temporary dummy signals object
1123     deleteFOsignalsLater = kTRUE;
1124   }
1125   
1126   
1127   AliITSDDLModuleMapSDD* ddlsdd=fDetTypeSim->GetDDLModuleMapSDD();
1128   Bool_t isHLTmodeC=fDetTypeSim->IsHLTmodeC();
1129   AliITSDDLRawData rawWriter;
1130   if(isHLTmodeC) rawWriter.SetUseCompressedSDDFormat(kTRUE);
1131   else rawWriter.SetUseCompressedSDDFormat(kFALSE);
1132   //Verbose level
1133   // 0: Silent
1134   // 1: cout messages
1135   // 2: txt files with digits 
1136   //BE CAREFUL, verbose level 2 MUST be used only for debugging and
1137   //it is highly suggested to use this mode only for debugging digits files
1138   //reasonably small, because otherwise the size of the txt files can reach
1139   //quickly several MB wasting time and disk space.
1140   rawWriter.SetVerbose(0);
1141     
1142   //SILICON PIXEL DETECTOR
1143   AliDebug(1,"Formatting raw data for SPD");
1144   rawWriter.RawDataSPD(digits->GetBranch("ITSDigitsSPD"),foSignals);
1145   if(deleteFOsignalsLater) delete foSignals;
1146     
1147   //SILICON DRIFT DETECTOR
1148   AliDebug(1,"Formatting raw data for SDD");
1149   rawWriter.RawDataSDD(digits->GetBranch("ITSDigitsSDD"),ddlsdd);
1150     
1151   //SILICON STRIP DETECTOR
1152   AliDebug(1,"Formatting raw data for SSD");
1153   rawWriter.RawDataSSD(digits->GetBranch("ITSDigitsSSD"));
1154
1155   fLoader->UnloadDigits();
1156 }
1157 //______________________________________________________________________
1158 AliLoader* AliITS::MakeLoader(const char* topfoldername){ 
1159     //builds ITSgetter (AliLoader type)
1160     //if detector wants to use castomized getter, it must overload this method
1161
1162     AliDebug(1,Form("Creating AliITSLoader. Top folder is %s.",
1163          topfoldername));
1164     fLoader = new AliITSLoader(GetName(),topfoldername);
1165     return fLoader;
1166 }
1167 //______________________________________________________________________
1168 Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader)
1169 {
1170   //
1171   // Converts RAW data to SDigits
1172   //
1173   // Get TreeS
1174   //
1175     Int_t last   = -1;
1176     Int_t size   = GetITSgeom()->GetIndexMax();
1177     TClonesArray** modA = new TClonesArray*[size];
1178     for (Int_t mod = 0; mod < size; mod++) modA[mod] = new TClonesArray("AliITSpListItem", 10000);
1179     
1180     AliLoader* loader =  (AliRunLoader::Instance())->GetLoader("ITSLoader");
1181     if (!loader){
1182         Error("Open","Can not get ITS loader from Run Loader");
1183         return kFALSE;
1184     }
1185
1186     TTree* tree = 0;
1187     tree = loader->TreeS();
1188     if (!tree){
1189         loader->MakeTree("S");
1190         tree = loader->TreeS();
1191     }
1192     //
1193     // Array for SDigits
1194     // 
1195     TClonesArray aSDigits("AliITSpListItem",10000), *itsSDigits=&aSDigits;
1196     Int_t bufsize = 32000;
1197     tree->Branch("ITS", &itsSDigits, bufsize);
1198     Int_t npx = 0;
1199     //
1200     // SPD
1201     //
1202     AliITSsegmentationSPD* segSPD = (AliITSsegmentationSPD*) fDetTypeSim->GetSegmentationModel(0);
1203     if(!segSPD){
1204       AliWarning("Set AliITS defaults");
1205       SetDefaults();
1206       segSPD = (AliITSsegmentationSPD*) fDetTypeSim->GetSegmentationModel(0);
1207     }
1208     npx = segSPD->Npx();
1209     Double_t thr, sigma; 
1210     
1211     AliITSRawStreamSPD inputSPD(rawReader);
1212     while(1){
1213         Bool_t next  = inputSPD.Next();
1214         if (!next) break;
1215
1216         Int_t module = inputSPD.GetModuleID();
1217         Int_t column = inputSPD.GetColumn();
1218         Int_t row    = inputSPD.GetRow();
1219         Int_t index  = npx * column + row;
1220
1221         if (module >= size) continue;
1222  
1223         last = (modA[module])->GetEntries();
1224         TClonesArray& dum = *modA[module];
1225         fDetTypeSim->GetSimuParam()->SPDThresholds(module,thr,sigma);
1226         thr += 1.;
1227         new (dum[last]) AliITSpListItem(-1, -1, module, index, thr);
1228     }
1229     rawReader->Reset();
1230
1231     //
1232     // SDD
1233     // 
1234     AliITSsegmentationSDD* segSDD = (AliITSsegmentationSDD*) fDetTypeSim->GetSegmentationModel(1);
1235     npx = segSDD->Npx();
1236     AliITSRawStreamSDD inputSDD(rawReader);
1237     AliITSDDLModuleMapSDD* ddlmap=fDetTypeSim->GetDDLModuleMapSDD();
1238     inputSDD.SetDDLModuleMap(ddlmap);
1239     while(1){
1240         Bool_t next  = inputSDD.Next();
1241         if (!next) break;
1242
1243         Int_t module = inputSDD.GetModuleID();
1244         Int_t anode  = inputSDD.GetAnode();
1245         Int_t time   = inputSDD.GetTime();
1246         Int_t signal10 = inputSDD.GetSignal();
1247         Int_t index  = npx * anode + time;
1248
1249         if (module >= size) continue;
1250         last = modA[module]->GetEntries();
1251         TClonesArray& dum = *modA[module];
1252         new (dum[last]) AliITSpListItem(-1, -1, module, index, Double_t(signal10));
1253         ((AliITSpListItem*) dum.At(last))->AddSignalAfterElect(module, index, Double_t(signal10));
1254         
1255     }
1256     rawReader->Reset();
1257
1258     //
1259     // SSD
1260     // 
1261     AliITSsegmentationSSD* segSSD = (AliITSsegmentationSSD*) fDetTypeSim->GetSegmentationModel(2);
1262     npx = segSSD->Npx();
1263     AliITSRawStreamSSD inputSSD(rawReader);
1264     while(1){
1265         Bool_t next  = inputSSD.Next();
1266         if (!next) break;
1267
1268         Int_t module  = inputSSD.GetModuleID();
1269         Int_t side    = inputSSD.GetSideFlag();
1270         Int_t strip   = inputSSD.GetStrip();
1271         Int_t signal  = inputSSD.GetSignal();
1272         Int_t index  = npx * side + strip;
1273
1274         if (module >= size) continue;
1275         
1276         last = modA[module]->GetEntries();
1277         TClonesArray& dum = *modA[module];
1278         new (dum[last]) AliITSpListItem(-1, -1, module, index, Double_t(signal));
1279     }
1280     rawReader->Reset();
1281      AliITSpListItem* sdig = 0;
1282     
1283     for (Int_t mod = 0; mod < size; mod++)
1284     {
1285         Int_t nsdig =  modA[mod]->GetEntries();
1286         for (Int_t ie = 0; ie < nsdig; ie++) {
1287             sdig = (AliITSpListItem*) (modA[mod]->At(ie));
1288             new (aSDigits[ie]) AliITSpListItem(-1, -1, mod, sdig->GetIndex(), sdig->GetSignal());
1289             Float_t sig = sdig->GetSignalAfterElect();
1290             if (sig > 0.) {
1291                 sdig = (AliITSpListItem*)aSDigits[ie];
1292                 sdig->AddSignalAfterElect(mod, sdig->GetIndex(), Double_t(sig));
1293             }
1294         }
1295         
1296         tree->Fill();
1297         aSDigits.Clear();
1298         modA[mod]->Clear();
1299     }
1300     loader->WriteSDigits("OVERWRITE");    
1301     delete modA;
1302     return kTRUE;
1303 }
1304
1305
1306 //______________________________________________________________________
1307 void AliITS::UpdateInternalGeometry(){
1308
1309   //reads new geometry from TGeo 
1310 //   AliDebug(1,"Delete ITSgeom and create a new one reading TGeo");
1311
1312   AliITSVersion_t version = (AliITSVersion_t)IsVersion();
1313   Int_t minor = 0;
1314   if(version==kvPPRasymmFMD) minor=2;  // default minor version for this geom.
1315   AliITSInitGeometry initgeom;
1316   AliITSgeom* geom = initgeom.CreateAliITSgeom(version,minor);
1317   SetITSgeom(geom);
1318 }
1319 //______________________________________________________________________
1320 AliTriggerDetector* AliITS::CreateTriggerDetector() const {
1321   // create an AliITSTrigger object (and set trigger conditions as input)
1322   return new AliITSTrigger(fDetTypeSim->GetTriggerConditions());
1323 }
1324