]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/STEER/AliSimulation.cxx
Merge branch 'master' into TPCdev
[u/mrichter/AliRoot.git] / STEER / STEER / AliSimulation.cxx
index 2fbf9872af78085c2f06514dc4538b6b37916fc4..1c357549b76ff64281df458f43ab776ed3b2beae 100644 (file)
 // The number of events per file has to be set before the simulation of      //
 // hits. Otherwise it has no effect.                                         //
 //                                                                           //
+// The trigger configuration is set by the method SetTriggerConfig(X)        //
+// X can take three kinds of values                                          //
+//                                                                           //
+//  - The exact string "none" - case insensitive.  In this case, not trigger //
+//    information is generated from the digits.                              //
+//  - The empty string or "ocdb" - case insensitive.  In this case the       //
+//    trigger configuration is read from OCDB                                //
+//  - Some string - say "p-p" - in which case the configuration is read from //
+//    fixed files in $ALICE_ROOT/GRP/CTP/ - say $ALICE_ROOT/GRP/CTP/p-p.cfg  //
+//                                                                           //
+// Default is to read from OCDB.                                             //
+//                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
 #include <TFile.h>
@@ -731,8 +743,13 @@ Bool_t AliSimulation::Run(Int_t nEvents)
   AliSysInfo::AddStamp("Hits2Digits");
   
   
-  // digits -> trigger
-  if (!fTriggerConfig.IsNull() && !RunTrigger(fTriggerConfig,fMakeDigits)) {
+  // digits -> trigger.  Set trigger configuration to "none" - any
+  // case - to not generate the trigger information.  Set the trigger
+  // configuration to some string X to read from file at
+  // $ALICE_ROOT/GRP/CTP/X.  Set the trigger configuration to the
+  // empty string or "ocdb" - any case - to read from OCDB.
+  if (!fTriggerConfig.EqualTo("none",TString::kIgnoreCase) && 
+      !RunTrigger(fTriggerConfig,fMakeDigits)) {
     if (fStopOnError) return kFALSE;
   }
 
@@ -768,7 +785,9 @@ Bool_t AliSimulation::Run(Int_t nEvents)
   }
 
   AliSysInfo::AddStamp("RunQA");
-
+  //
+  StoreUsedCDBMaps();
+  //  
   TString snapshotFileOut("");
   if(TString(gSystem->Getenv("OCDB_SNAPSHOT_CREATE")) == TString("kTRUE")){ 
       AliInfo(" ******** Creating the snapshot! *********");
@@ -888,7 +907,7 @@ Bool_t AliSimulation::RunLego(const char *setup, Int_t nc1, Float_t c1min,
   
   AliPDG::AddParticlesToPdgDataBase();  
   
-  gMC->SetMagField(TGeoGlobalMagField::Instance()->GetField());
+  TVirtualMC::GetMC()->SetMagField(TGeoGlobalMagField::Instance()->GetField());
 
   gAlice->GetMCApp()->Init();
   
@@ -906,13 +925,13 @@ Bool_t AliSimulation::RunLego(const char *setup, Int_t nc1, Float_t c1min,
   AliGenerator *gen=gAlice->GetMCApp()->Generator();
   gAlice->GetMCApp()->ResetGenerator(gener);
   //Prepare MC for Lego Run
-  gMC->InitLego();
+  TVirtualMC::GetMC()->InitLego();
   
   //Run Lego Object
   
   
   AliRunLoader::Instance()->SetNumberOfEventsPerFile(nev);
-  gMC->ProcessRun(nev);
+  TVirtualMC::GetMC()->ProcessRun(nev);
   
   // End of this run, close files
   FinishRun();
@@ -982,7 +1001,8 @@ Bool_t AliSimulation::WriteTriggerRawData()
   // Details of the format are given in the
   // trigger TDR - pages 134 and 135.
   AliCTPRawData writer;
-  writer.RawData();
+  //writer.RawData();
+  writer.RawDataRun2();
 
   return kTRUE;
 }
@@ -1101,7 +1121,7 @@ Bool_t AliSimulation::RunSimulation(Int_t nEvents)
 
    AliPDG::AddParticlesToPdgDataBase();  
 
-   gMC->SetMagField(TGeoGlobalMagField::Instance()->GetField());
+   TVirtualMC::GetMC()->SetMagField(TGeoGlobalMagField::Instance()->GetField());
    AliSysInfo::AddStamp("RunSimulation_GetField");
    gAlice->GetMCApp()->Init();
    AliSysInfo::AddStamp("RunSimulation_InitMCApp");
@@ -1222,7 +1242,7 @@ Bool_t AliSimulation::RunSimulation(Int_t nEvents)
 
   // Create the Root Tree with one branch per detector
   //Hits moved to begin event -> now we are crating separate tree for each event
-  gMC->ProcessRun(nEvents);
+  TVirtualMC::GetMC()->ProcessRun(nEvents);
 
   // End of this run, close files
   if(nEvents>0) FinishRun();
@@ -1327,7 +1347,7 @@ Bool_t AliSimulation::RunSDigitization(const char* detectors)
       AliCodeTimerStart(Form("creating summable digits for %s", det->GetName()));
       det->Hits2SDigits();
       AliCodeTimerStop(Form("creating summable digits for %s", det->GetName()));
-      AliSysInfo::AddStamp(Form("Digit_%s_%d",det->GetName(),eventNr), 0,1, eventNr);
+      AliSysInfo::AddStamp(Form("SDigit_%s_%d",det->GetName(),eventNr), 0,1, eventNr);
     }
   }
 
@@ -1348,7 +1368,6 @@ Bool_t AliSimulation::RunDigitization(const char* detectors,
                                      const char* excludeDetectors)
 {
 // run the digitization and produce digits from sdigits
-
   AliCodeTimerAuto("",0)
 
   // initialize CDB storage, run number, set CDB lock
@@ -1393,6 +1412,7 @@ Bool_t AliSimulation::RunDigitization(const char* detectors,
     }
     detArr.AddLast(digitizer);    
     AliInfo(Form("Created digitizer from SDigits -> Digits for %s", det->GetName()));    
+
   }
   //
   if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
@@ -1408,11 +1428,14 @@ Bool_t AliSimulation::RunDigitization(const char* detectors,
     digInp.InitEvent(); //this must be after call of Connect Input tress.
     if (outRl) outRl->SetEventNumber(eventsCreated-1);
     static_cast<AliStream*>(digInp.GetInputStream(0))->ImportgAlice(); // use gAlice of the first input stream
-    for (int id=0;id<ndigs;id++) ((AliDigitizer*)detArr[id])->Digitize("");
+    for (int id=0;id<ndigs;id++) {
+      ((AliDigitizer*)detArr[id])->Digitize("");
+      AliSysInfo::AddStamp(Form("Digit_%s_%d",detArr[id]->GetName(),eventsCreated), 0,2, eventsCreated);       
+    }
     digInp.FinishEvent();
   };
   digInp.FinishGlobal();
-  //
+  // 
   return kTRUE;
 }
 
@@ -1958,7 +1981,7 @@ Int_t AliSimulation::ConvertRaw2SDigits(const char* rawDirectory, const char* es
     
    AliPDG::AddParticlesToPdgDataBase();  
 
-   gMC->SetMagField(TGeoGlobalMagField::Instance()->GetField());
+   TVirtualMC::GetMC()->SetMagField(TGeoGlobalMagField::Instance()->GetField());
    
    gAlice->GetMCApp()->Init();
 
@@ -2107,8 +2130,6 @@ void AliSimulation::FinishRun()
   gAlice->Write(0,TObject::kOverwrite);//write AliRun
   AliRunLoader::Instance()->Write(0,TObject::kOverwrite);//write RunLoader itself
   //
-  StoreUsedCDBMaps();
-  //  
   if(gAlice->GetMCApp()) gAlice->GetMCApp()->FinishRun();  
   AliRunLoader::Instance()->Synchronize();
 }
@@ -2521,6 +2542,13 @@ void AliSimulation::StoreUsedCDBMaps() const
 {
   // write in galice.root maps with used CDB paths
   //
+  //
+  AliRunLoader* runLoader = LoadRun();
+  if (!runLoader) {
+    AliError("Failed to open gAlice.root in write mode");
+    return;
+  }
+  //
   const TMap *cdbMap = AliCDBManager::Instance()->GetStorageMap();      
   const TList *cdbList = AliCDBManager::Instance()->GetRetrievedIds();  
   //
@@ -2551,6 +2579,7 @@ void AliSimulation::StoreUsedCDBMaps() const
   AliRunLoader::Instance()->CdGAFile();
   gDirectory->WriteObject(cdbMapCopy,"cdbMap","kSingleKey");
   gDirectory->WriteObject(cdbListCopy,"cdbList","kSingleKey");  
+  delete runLoader;
   //
   AliInfo(Form("Stored used OCDB entries as TMap %s and TList %s in %s",
               cdbMapCopy->GetName(),