Changing once more (hopefully we get it correct this time...) the logic to trig the...
[u/mrichter/AliRoot.git] / ITS / StoreCalibSDD.C
index d94ed93..08b35bb 100644 (file)
@@ -1,7 +1,7 @@
 #if !defined(__CINT__) || defined(__MAKECINT__)
 #include "AliCDBManager.h"
 #include "AliITSCalibrationSDD.h"
-#include "AliITSresponseSDD.h"
+#include "AliITSgeomTGeo.h"
 #include "AliCDBMetaData.h"
 #include "AliCDBStorage.h"
 #include "AliCDBId.h"
 #include <TRandom3.h>
 #endif
 
-void StoreCalibSDD(Int_t firstRun=0,Int_t lastRun=9999999 ){
+void StoreCalibSDD(Int_t firstRun=0,Int_t lastRun=9999999){
   ///////////////////////////////////////////////////////////////////////
   // Macro to generate and store the calibration files for SDD         //
   // Generates:                                                        //
   //  1 file with 260 AliITSCalibrationSDD objects with                //
   //    baselines, noise, gain, drift speed for each module (CalibSDD) //
-  //  1 file with the AliITSrespionseSDD object (RespSDD)              //
   ///////////////////////////////////////////////////////////////////////
   
   if(!AliCDBManager::Instance()->IsDefaultStorageSet()) {
@@ -25,31 +24,37 @@ void StoreCalibSDD(Int_t firstRun=0,Int_t lastRun=9999999 ){
   }
   
 
-  AliCDBMetaData *md1= new AliCDBMetaData(); // metaData describing the object
-  md1->SetObjectClassName("AliITSCalibration");
-  md1->SetResponsible("Elisabetta Crescio, Francesco Prino");
-  md1->SetBeamPeriod(0);
-  md1->SetAliRootVersion("Head 20 nov. 2007"); //root version
-  md1->SetComment("This is a test");
-  //  TObject* str;
-  // md1->SetProperty("key1",str);
-
-  AliCDBMetaData *md2 = new AliCDBMetaData();
-  md2->SetObjectClassName("AliITSresponse");
-  md2->SetResponsible("Elisabetta Crescio, Francesco Prino");
-  md2->SetBeamPeriod(0);
-  md2->SetAliRootVersion("Head 20 nov. 2007"); //root version
-  md2->SetComment("This is a test");
-
+  AliCDBMetaData *md= new AliCDBMetaData(); // metaData describing the object
+  md->SetObjectClassName("TObjArray");
+  md->SetResponsible("Francesco Prino");
+  md->SetBeamPeriod(0);
+  md->SetComment("Simulated data");
 
   AliCDBId idCalSDD("ITS/Calib/CalibSDD",firstRun, lastRun);
-  TObjArray respSDD(260);
-  respSDD.SetOwner(kFALSE);
-
+  TObjArray calSDD(260);
+  calSDD.SetOwner(kFALSE);
+
+  // BAD modules data 
+  const Int_t nbadmod=6;
+  Int_t idBadMod[nbadmod];
+  idBadMod[0]=AliITSgeomTGeo::GetModuleIndex(3,4,1);
+  idBadMod[1]=AliITSgeomTGeo::GetModuleIndex(3,4,2);
+  idBadMod[2]=AliITSgeomTGeo::GetModuleIndex(3,4,3);
+  idBadMod[3]=AliITSgeomTGeo::GetModuleIndex(4,1,1);
+  idBadMod[4]=AliITSgeomTGeo::GetModuleIndex(4,12,1);
+  idBadMod[5]=AliITSgeomTGeo::GetModuleIndex(4,21,3);
+  
+  // Modules with bad left side 
+  const Int_t nbadleft=5;
+  Int_t idBadLeft[nbadleft];
+  idBadLeft[0]=AliITSgeomTGeo::GetModuleIndex(3,13,6);
+  idBadLeft[1]=AliITSgeomTGeo::GetModuleIndex(4,4,8);
+  idBadLeft[2]=AliITSgeomTGeo::GetModuleIndex(4,5,3);
+  idBadLeft[3]=AliITSgeomTGeo::GetModuleIndex(4,18,4);
+  idBadLeft[4]=AliITSgeomTGeo::GetModuleIndex(4,21,5);
 
 
-  AliCDBId idRespSDD("ITS/Calib/RespSDD",firstRun, lastRun);
-  AliITSresponseSDD* rd = new AliITSresponseSDD();
+ // BAD anodes data
   const Int_t nData = 209;
   Int_t anodeUp[209] = {0,36,0,12,20,32,0,0,12,76,28,8,16,0,0,0,8,0,0,0,20,4,0,0,0,0,0,0
                        ,0,0,8,0,0,0,0,0,0,0,0,0,0,0,12,0,8,0,4,4,0,160,0,0,0,252,16,0,8,8
@@ -68,10 +73,6 @@ void StoreCalibSDD(Int_t firstRun=0,Int_t lastRun=9999999 ){
                          ,16,0,16,20,0,28,0,8,24,0,12,8,4,40,0,104,96,32,140,20,12,8,20,24,16,16,20
                          ,8,140,96,0,32,20,44};
 
-  Float_t drVelParam[4]={7.75,0.002344,-0.000009,0};
-  Float_t edrVelParam[4]={0,0,0,0};
-  Float_t drVel[4];
   TRandom3 *gran = new TRandom3();
   
   for(Int_t mod=0;mod<260;mod++){
@@ -89,7 +90,8 @@ void StoreCalibSDD(Int_t firstRun=0,Int_t lastRun=9999999 ){
        for(Int_t iChan=0; iChan<64;iChan++){
          Float_t gain=gran->Gaus(chipgain,0.01);
          if(gain<0.1) gain=0.1;
-         resd->SetGain(gain,iWing,iChip,iChan);
+         Int_t ian=resd->GetAnodeNumber(iWing,iChip,iChan);
+         resd->SetGain(ian,gain);
        }
       }
     }
@@ -141,7 +143,8 @@ void StoreCalibSDD(Int_t firstRun=0,Int_t lastRun=9999999 ){
     Int_t nSeToBad = 0;
     for (Int_t i=0; i<4; i++){
       for(Int_t j=0;j<64;j++){
-       if (resd->Gain(0,i,j)<0.0001) nSeToBad++;
+       Int_t ian=resd->GetAnodeNumber(0,i,j);
+       if (resd->GetChannelGain(ian)<0.0001) nSeToBad++;
       }
     }
     while (nSeToBad<nBadDown) {
@@ -189,7 +192,8 @@ void StoreCalibSDD(Int_t firstRun=0,Int_t lastRun=9999999 ){
     nSeToBad = 0;
     for (Int_t i=0; i<4; i++){
       for(Int_t j=0;j<64;j++){
-       if (resd->Gain(1,i,j)<0.0001) nSeToBad++;
+       Int_t ian=resd->GetAnodeNumber(1,i,j);
+       if (resd->GetChannelGain(ian)<0.0001) nSeToBad++;
       }
     }
 
@@ -214,16 +218,30 @@ void StoreCalibSDD(Int_t firstRun=0,Int_t lastRun=9999999 ){
       }
     */
 
+    Int_t modId=mod+240;
+    // Bad modules
+    for(Int_t ibadm=0; ibadm<nbadmod; ibadm++){
+      if(modId==idBadMod[ibadm]) resd->SetBad();
+    }
+    // Modules with bad left side
+    for(Int_t ibadl=0; ibadl<nbadleft; ibadl++){
+      if(modId==idBadLeft[ibadl]) for(Int_t ichip=0;ichip<4;ichip++) resd->SetChipBad(ichip);
+    }
+
+    // Modules with bad pascal chips
+    if( modId==AliITSgeomTGeo::GetModuleIndex(4,4,2) ){
+      resd->SetChipBad(0);
+      resd->SetChipBad(3);
+    }
 
-    if(mod==88) resd->SetDead();
-    respSDD.Add(resd);
+    calSDD.Add(resd);
     printf("Added module %d\n",mod);
-  }
+       }
     
   FILE* out = fopen("deadchannels.dat","w");
   for(Int_t i=0;i<260;i++){
     fprintf(out,"MODULE=%d\n",i);
-    AliITSCalibrationSDD* cl = (AliITSCalibrationSDD*)respSDD.At(i);
+    AliITSCalibrationSDD* cl = (AliITSCalibrationSDD*)calSDD.At(i);
     Int_t ndead=cl->GetDeadChannels();
     fprintf(out,"n %d\n",ndead);
     for(Int_t n=0;n<ndead;n++){
@@ -231,6 +249,5 @@ void StoreCalibSDD(Int_t firstRun=0,Int_t lastRun=9999999 ){
     }   
   }
   fclose(out);
-  AliCDBManager::Instance()->GetDefaultStorage()->Put(&respSDD, idCalSDD, md1);   
-  AliCDBManager::Instance()->GetDefaultStorage()->Put(rd, idRespSDD, md2);  
+  AliCDBManager::Instance()->GetDefaultStorage()->Put(&calSDD, idCalSDD, md);   
 }