]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/StoreCalibSDD.C
Compilation warnings
[u/mrichter/AliRoot.git] / ITS / StoreCalibSDD.C
index b7be6babdbff510b94ab8aa0d2085c0b745474b5..49a5c9d824753bce24464ed8f376d8882fe095f5 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=AliCDBRunRange::Infinity(), Bool_t isIdeal=kFALSE){
   ///////////////////////////////////////////////////////////////////////
   // 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,20 +73,11 @@ 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++){
     AliITSCalibrationSDD* resd = new AliITSCalibrationSDD("simulated");
 
-    // drift velocity wing 0 and 1
-    for(Int_t ic=0;ic<4;ic++) drVel[ic]=gran->Gaus(drVelParam[ic],edrVelParam[ic]);
-    resd->SetDriftSpeedParam(0,drVel);
-    for(Int_t ic=0;ic<4;ic++) drVel[ic]=gran->Gaus(drVelParam[ic],edrVelParam[ic]);
-    resd->SetDriftSpeedParam(1,drVel);
     Int_t nBadUp = 0;
     Int_t nBadDown = 0;
       
@@ -94,119 +90,123 @@ 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);
        }
       }
     }
 
     // bad channels
-    Int_t count=0;
-    do {
-      Int_t ranMod = Int_t(nData*gran->Uniform());
-      nBadUp   = anodeUp[ranMod];
-      nBadDown = anodeDown[ranMod];
-    }while (nBadUp+nBadDown>25);
-
-    resd->SetDeadChannels(nBadDown+nBadUp);
-    Int_t remainingBad = nBadDown;
-    while (remainingBad>0) {
-      Int_t nBadChannel;
-      if (remainingBad<5) {
-       nBadChannel = remainingBad;
-      } else {
-       Int_t width = remainingBad-(5-1);
-       if (width>4) width = 4;
-       nBadChannel = 5 + Int_t(width*gran->Uniform());
-      }
+    if(!isIdeal){
+      Int_t count=0;
+      do {
+       Int_t ranMod = Int_t(nData*gran->Uniform());
+       nBadUp   = anodeUp[ranMod];
+       nBadDown = anodeDown[ranMod];
+      }while (nBadUp+nBadDown>25);
+
+      resd->SetDeadChannels(nBadDown+nBadUp);
+      Int_t remainingBad = nBadDown;
+      while (remainingBad>0) {
+       Int_t nBadChannel;
+       if (remainingBad<5) {
+         nBadChannel = remainingBad;
+       } else {
+         Int_t width = remainingBad-(5-1);
+         if (width>4) width = 4;
+         nBadChannel = 5 + Int_t(width*gran->Uniform());
+       }
        
 
-      Int_t iChannelPos = Int_t( (4*64-nBadChannel)*gran->Uniform() );
-      //      Int_t iChip = iChannelPos/64;
-      //      Int_t iChan = iChannelPos - iChip*64;
-      if(resd->IsBadChannel(iChannelPos)) continue;    
-      Int_t *clus = new Int_t[nBadChannel];
-      Int_t ich = iChannelPos;
-      for(Int_t i=0;i<nBadChannel;i++){
-       clus[i]=ich;
-       ich++;
-      }
-
-      for(Int_t i=0;i<nBadChannel;i++){
-       if(resd->IsBadChannel(clus[i])) break;
-       resd->SetBadChannel(count,clus[i]);
-       count++;          
+       Int_t iChannelPos = Int_t( (4*64-nBadChannel)*gran->Uniform() );
+       //      Int_t iChip = iChannelPos/64;
+       //      Int_t iChan = iChannelPos - iChip*64;
+       if(resd->IsBadChannel(iChannelPos)) continue;   
+       Int_t *clus = new Int_t[nBadChannel];
+       Int_t ich = iChannelPos;
+       for(Int_t i=0;i<nBadChannel;i++){
+         clus[i]=ich;
+         ich++;
+       }
+       
+       for(Int_t i=0;i<nBadChannel;i++){
+         if(resd->IsBadChannel(clus[i])) break;
+         resd->SetBadChannel(count,clus[i]);
+         count++;        
+       }
+       remainingBad -= nBadChannel;
+       delete [] clus;
       }
-      remainingBad -= nBadChannel;
-      delete [] clus;
-    }
 
-    // May happen that, due to overlapping clusters, we
-    // have less bad channels than requested
-    // Let's put the remaining one per one ...
-    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++;
+      // May happen that, due to overlapping clusters, we
+      // have less bad channels than requested
+      // Let's put the remaining one per one ...
+      Int_t nSeToBad = 0;
+      for (Int_t i=0; i<4; i++){
+       for(Int_t j=0;j<64;j++){
+         Int_t ian=resd->GetAnodeNumber(0,i,j);
+         if (resd->GetChannelGain(ian)<0.0001) nSeToBad++;
+       }
       }
-    }
-    while (nSeToBad<nBadDown) {
-      Int_t i = Int_t(4*64*gran->Uniform());
-      if(resd->IsBadChannel(i)==kFALSE){
-       resd->SetBadChannel(count,i);
-       count++;
-       nSeToBad++;
+      while (nSeToBad<nBadDown) {
+       Int_t i = Int_t(4*64*gran->Uniform());
+       if(resd->IsBadChannel(i)==kFALSE){
+         resd->SetBadChannel(count,i);
+         count++;
+         nSeToBad++;
+       }
       }
-    }
       
-    remainingBad = nBadUp;
-    while (remainingBad>0) {
-      Int_t nBadChannel;
-      if (remainingBad<5) {
-       nBadChannel = remainingBad;
-      } else {
-       Int_t width = remainingBad-(5-1);
-       if (width>4) width = 4;
-       nBadChannel = 5 + Int_t(width*gran->Uniform());
-      }
-
-      Int_t iChannelPos = Int_t( (4*64-nBadChannel)*gran->Uniform() );
-      //      Int_t iChip = iChannelPos/64;
-      //      Int_t iChan = iChannelPos - iChip*64;
-      if(resd->IsBadChannel(iChannelPos)) continue;
+      remainingBad = nBadUp;
+      while (remainingBad>0) {
+       Int_t nBadChannel;
+       if (remainingBad<5) {
+         nBadChannel = remainingBad;
+       } else {
+         Int_t width = remainingBad-(5-1);
+         if (width>4) width = 4;
+         nBadChannel = 5 + Int_t(width*gran->Uniform());
+       }
        
-      Int_t *clus = new Int_t[nBadChannel];
-      Int_t ich = iChannelPos;
-      for(Int_t i=0;i<nBadChannel;i++){
-       clus[i]=ich+256;
-       ich++;
-      }
-      for(Int_t i=0;i<nBadChannel;i++){
+       Int_t iChannelPos = Int_t( (4*64-nBadChannel)*gran->Uniform() );
+       //      Int_t iChip = iChannelPos/64;
+       //      Int_t iChan = iChannelPos - iChip*64;
+       if(resd->IsBadChannel(iChannelPos)) continue;
        
-       if(resd->IsBadChannel(clus[i])) break;  
-       resd->SetBadChannel(count,clus[i]);
-       count++;
+       Int_t *clus = new Int_t[nBadChannel];
+       Int_t ich = iChannelPos;
+       for(Int_t i=0;i<nBadChannel;i++){
+         clus[i]=ich+256;
+         ich++;
+       }
+       for(Int_t i=0;i<nBadChannel;i++){
+       
+         if(resd->IsBadChannel(clus[i])) break;  
+         resd->SetBadChannel(count,clus[i]);
+         count++;
          
+       }
+       remainingBad -= nBadChannel;
+       delete [] clus;
       }
-      remainingBad -= nBadChannel;
-      delete [] clus;
-    }
       
-    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++;
+      nSeToBad = 0;
+      for (Int_t i=0; i<4; i++){
+       for(Int_t j=0;j<64;j++){
+         Int_t ian=resd->GetAnodeNumber(1,i,j);
+         if (resd->GetChannelGain(ian)<0.0001) nSeToBad++;
+       }
       }
-    }
 
-    while (nSeToBad<nBadUp) {
-      Int_t i = Int_t(4*64*gran->Uniform());
-      if(resd->IsBadChannel(i+256)==kFALSE){
-       resd->SetBadChannel(count,i+256);
-       count++;
-       nSeToBad++;
+      while (nSeToBad<nBadUp) {
+       Int_t i = Int_t(4*64*gran->Uniform());
+       if(resd->IsBadChannel(i+256)==kFALSE){
+         resd->SetBadChannel(count,i+256);
+         count++;
+         nSeToBad++;
+       }
       }
     }
-      
     //baselines
     /*
       for(Int_t nan=0;nan<512;nan++){
@@ -219,16 +219,31 @@ void StoreCalibSDD(Int_t firstRun=0,Int_t lastRun=9999999 ){
       }
     */
 
+    Int_t modId=mod+240;
+    // Bad modules
+    if(!isIdeal){
+      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);
+      }
 
-    if(mod==88) resd->SetDead();
-    respSDD.Add(resd);
+      // Modules with bad pascal chips
+      if( modId==AliITSgeomTGeo::GetModuleIndex(4,4,2) ){
+       resd->SetChipBad(0);
+       resd->SetChipBad(3);
+      }
+    }
+    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++){
@@ -236,6 +251,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);   
 }