ITS tasks from the pilot train added.
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 8 Jan 2010 16:24:47 +0000 (16:24 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 8 Jan 2010 16:24:47 +0000 (16:24 +0000)
PWG1/ITS/AliAnalysisTaskSDDRP.cxx [new file with mode: 0644]
PWG1/ITS/AliAnalysisTaskSDDRP.h [new file with mode: 0644]
PWG1/ITS/AliAnalysisTaskSPD.cxx [new file with mode: 0644]
PWG1/ITS/AliAnalysisTaskSPD.h [new file with mode: 0644]
PWG1/PWG1LinkDef.h

diff --git a/PWG1/ITS/AliAnalysisTaskSDDRP.cxx b/PWG1/ITS/AliAnalysisTaskSDDRP.cxx
new file mode 100644 (file)
index 0000000..2b4bc72
--- /dev/null
@@ -0,0 +1,329 @@
+#include "AliAnalysisTask.h"
+#include "AliAnalysisManager.h"
+#include "AliAnalysisDataContainer.h"
+#include "AliITSRecPoint.h"
+#include "AliESDEvent.h"
+#include "AliTrackPointArray.h"
+#include "AliITSgeomTGeo.h"
+#include "AliESDfriend.h"
+#include "AliCDBManager.h"
+#include "AliCDBEntry.h"
+#include "AliITSCalibrationSDD.h"
+#include "AliITSresponseSDD.h"
+#include "AliGeomManager.h"
+#include <TSystem.h>
+#include <TTree.h>
+#include <TH1F.h>
+#include <TChain.h>
+#include <TGeoGlobalMagField.h>
+#include "AliESDInputHandlerRP.h"
+#include "AliAnalysisTaskSDDRP.h"
+
+ClassImp(AliAnalysisTaskSDDRP)
+//______________________________________________________________________________
+AliAnalysisTaskSDDRP::AliAnalysisTaskSDDRP() : AliAnalysisTaskSE("SDD RecPoints"), 
+  fOutput(0),
+  fHistNEvents(0),
+  fRecPMod(0),
+  fTrackPMod(0),
+  fGoodAnMod(0),
+  fRecPLadLay3(0),
+  fRecPLadLay4(0),
+  fTrackPLadLay3(0),
+  fTrackPLadLay4(0),
+  fGoodAnLadLay3(0),
+  fGoodAnLadLay4(0),
+  fDriftTimeRP(0),
+  fDriftTimeTP(0),
+  fESD(0),
+  fESDfriend(0),
+  fResp(0),
+  fRunNumber(0),
+  fMinITSpts(3),
+  fMinPfordEdx(1.5),
+  fOnlyCINT1BTrig(0),
+  fInitialised(0)
+{
+  //
+  DefineOutput(1, TList::Class());
+}
+
+
+//___________________________________________________________________________
+AliAnalysisTaskSDDRP::~AliAnalysisTaskSDDRP(){
+  //
+  if (fOutput) {
+    delete fOutput;
+    fOutput = 0;
+  }
+}
+
+
+//___________________________________________________________________________
+
+void AliAnalysisTaskSDDRP::UserCreateOutputObjects() {
+
+  fOutput = new TList();
+  fOutput->SetOwner();
+  fOutput->SetName("OutputHistos");
+
+  fHistNEvents = new TH1F("hNEvents", "Number of processed events",3,-1.5,1.5);
+  fHistNEvents->Sumw2();
+  fHistNEvents->SetMinimum(0);
+  fOutput->Add(fHistNEvents);
+
+  // -- Module histos
+
+  fRecPMod = new TH1F("hRPMod","Rec Points per Module",260,239.5,499.5);
+  fRecPMod->Sumw2();
+  fRecPMod->SetMinimum(0);
+  fOutput->Add(fRecPMod);
+
+  fTrackPMod = new TH1F("hTPMod","Track Points per Module",260,239.5,499.5);
+  fTrackPMod->Sumw2();
+  fTrackPMod->SetMinimum(0);
+  fOutput->Add(fTrackPMod);
+
+  fGoodAnMod = new TH1F("hGAMod","Good Anodes per Module",260,239.5,499.5);
+  fOutput->Add(fGoodAnMod);
+
+  // -- Ladder histos
+
+  fRecPLadLay3 = new TH1F("hRPLad3","Rec Points per Ladder Layer 3",14,-0.5,13.5);
+  fRecPLadLay3->Sumw2();
+  fRecPLadLay3->SetMinimum(0);
+  fOutput->Add(fRecPLadLay3);
+
+  fRecPLadLay4 = new TH1F("hRPLad4","Rec Points per Ladder Layer 4",22,-0.5,21.5);
+  fRecPLadLay4->Sumw2();
+  fRecPLadLay4->SetMinimum(0);
+  fOutput->Add(fRecPLadLay4);
+
+  fTrackPLadLay3 = new TH1F("hTPLad3","Track Points per Ladder Layer 3",14,-0.5,13.5);
+  fTrackPLadLay3->Sumw2();
+  fTrackPLadLay3->SetMinimum(0);
+  fOutput->Add(fTrackPLadLay3);
+
+  fTrackPLadLay4 = new TH1F("hTPLad4","Track Points per Ladder Layer 4",22,-0.5,21.5);
+  fTrackPLadLay4->Sumw2();
+  fTrackPLadLay4->SetMinimum(0);
+  fOutput->Add(fTrackPLadLay4);
+
+  fGoodAnLadLay3 = new TH1F("hGALad3","Good Anodes per Ladder Layer 3",14,-0.5,13.5);
+  fOutput->Add(fGoodAnLadLay3);
+
+  fGoodAnLadLay4 = new TH1F("hGALad4","Good Anodes per Ladder Layer 4",22,-0.5,21.5);
+  fOutput->Add(fGoodAnLadLay4);
+
+  fDriftTimeRP=new TH1F("hDrTimRP","Drift Time from Rec Points (ns)",100,0.,6400.);
+  fDriftTimeRP->Sumw2();
+  fDriftTimeRP->SetMinimum(0.);
+  fOutput->Add(fDriftTimeRP);
+
+  fDriftTimeTP=new TH1F("hDrTimTP","Drift Time from Track Points (ns)",100,0.,6400.);
+  fDriftTimeTP->Sumw2();
+  fDriftTimeTP->SetMinimum(0.);
+  fOutput->Add(fDriftTimeTP);
+
+  for(Int_t it=0; it<8; it++){
+    fSignalTime[it]=new TH1F(Form("hSigTimeInt%d",it),Form("hSigTimeInt%d",it),100,0.,300.);
+    fSignalTime[it]->Sumw2();
+    fSignalTime[it]->SetMinimum(0);
+    fOutput->Add(fSignalTime[it]);
+  }
+}
+//______________________________________________________________________________
+void AliAnalysisTaskSDDRP::UserExec(Option_t *)
+{
+  //
+  fESD = (AliESDEvent*) (InputEvent());
+
+  if(!fESD) {
+    printf("AliAnalysisTaskSDDRP::Exec(): bad ESD\n");
+    return;
+  } 
+
+  fESDfriend = static_cast<AliESDfriend*>(fESD->FindListObject("AliESDfriend"));
+
+
+
+  if(!fESDfriend) {
+    printf("AliAnalysisTaskSDDRP::Exec(): bad ESDfriend\n");
+    return;
+  } 
+  PostData(1, fOutput);
+  fESD->SetESDfriend(fESDfriend);
+
+  if (!fInitialised) {
+    fInitialised = 1;
+
+    AliCDBManager* man = AliCDBManager::Instance();
+    man->SetDefaultStorage("raw://");
+    man->SetRun(fESD->GetRunNumber());
+    
+    
+    AliCDBEntry* eR=(AliCDBEntry*)man->Get("ITS/Calib/RespSDD");
+    fResp=(AliITSresponseSDD*)eR->GetObject();
+    
+    AliCDBEntry* eC=(AliCDBEntry*)man->Get("ITS/Calib/CalibSDD");
+    TObjArray* calsdd=(TObjArray*)eC->GetObject();
+    Int_t countGood3[14];
+    Int_t countGood4[22];
+    Int_t countGoodMod[260];
+    for(Int_t ilad=0;ilad<14;ilad++) countGood3[ilad]=0;
+    for(Int_t ilad=0;ilad<22;ilad++) countGood4[ilad]=0;
+    for(Int_t imod=0;imod<260;imod++) countGoodMod[imod]=0;
+    for(Int_t imod=0;imod<260;imod++){
+      AliITSCalibrationSDD* cal=(AliITSCalibrationSDD*)calsdd->At(imod);
+      if(cal->IsBad()) continue;
+      Int_t modId=imod+AliITSgeomTGeo::GetModuleIndex(3,1,1);
+      Int_t lay,lad,det;
+      AliITSgeomTGeo::GetModuleId(modId,lay,lad,det);
+      if(!CheckModule(lay,lad,det)) continue;
+      for(Int_t ian=0; ian<512; ian++){
+       if(cal->IsBadChannel(ian)) continue;
+       countGoodMod[imod]++;
+       if(lay==3) countGood3[lad-1]++;
+       else if(lay==4) countGood4[lad-1]++;
+      }
+    }
+    for(Int_t imod=0;imod<260;imod++) fGoodAnMod->SetBinContent(imod+1,countGoodMod[imod]);
+    fGoodAnMod->SetMinimum(0);
+    for(Int_t ilad=0;ilad<14;ilad++) fGoodAnLadLay3->SetBinContent(ilad+1,countGood3[ilad]);
+    fGoodAnLadLay3->SetMinimum(0);    
+    for(Int_t ilad=0;ilad<22;ilad++) fGoodAnLadLay4->SetBinContent(ilad+1,countGood4[ilad]);
+    fGoodAnLadLay4->SetMinimum(0);
+  }
+
+
+  fHistNEvents->Fill(0);
+  if(fOnlyCINT1BTrig){
+    if(!fESD->IsTriggerClassFired("CINT1B-ABCE-NOPF-ALL")) return;
+    fHistNEvents->Fill(1);
+  }
+  const AliTrackPointArray *array = 0;
+  Int_t ntracks = fESD->GetNumberOfTracks();
+  for (Int_t itrack=0; itrack < ntracks; itrack++) {
+    AliESDtrack * track = fESD->GetTrack(itrack);
+    if (!track) continue;
+    if(track->GetNcls(1)>0) continue;
+    if(track->GetNcls(0) < fMinITSpts) continue;
+    Double_t dedx[4];
+    track->GetITSdEdxSamples(dedx);
+    array = track->GetTrackPointArray();
+    if(!array) continue;
+    for(Int_t ipt=0; ipt<array->GetNPoints(); ipt++) {
+      AliTrackPoint point;
+      Int_t modId;
+      array->GetPoint(point,ipt);
+      Int_t volId = point.GetVolumeID();
+      Int_t layerId = AliGeomManager::VolUIDToLayer(volId,modId);
+      if(layerId<3 || layerId>4) continue;
+      modId+=AliITSgeomTGeo::GetModuleIndex(layerId,1,1);
+      Int_t lay,lad,det;
+      AliITSgeomTGeo::GetModuleId(modId,lay,lad,det);
+      if(!CheckModule(lay,lad,det)) continue;
+      fTrackPMod->Fill(modId);
+      fDriftTimeTP->Fill(point.GetDriftTime());
+      Float_t dtime=point.GetDriftTime()-fResp->GetTimeZero(modId);
+      Int_t theBin=int(dtime/6500.*8.);
+      if(layerId==3){ 
+       fTrackPLadLay3->Fill(lad-1);      
+       if(dedx[0]>0. && track->P()>fMinPfordEdx) fSignalTime[theBin]->Fill(dedx[0]);
+      }
+      if(layerId==4){
+       fTrackPLadLay4->Fill(lad-1);
+       if(dedx[0]>0.&& track->P()>fMinPfordEdx) fSignalTime[theBin]->Fill(dedx[1]);
+      }
+    }
+  }
+
+  AliESDInputHandlerRP *hand = dynamic_cast<AliESDInputHandlerRP*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
+  TTree* tR = hand->GetTreeR("ITS");
+  TClonesArray *ITSrec= new TClonesArray("AliITSRecPoint");
+  TBranch *branch =tR->GetBranch("ITSRecPoints");
+  branch->SetAddress(&ITSrec);
+  for (Int_t modId=240; modId<500; modId++){
+    Int_t lay,lad,det;
+    AliITSgeomTGeo::GetModuleId(modId,lay,lad,det);
+    if(!CheckModule(lay,lad,det)) continue;
+    branch->GetEvent(modId);
+    Int_t nrecp = ITSrec->GetEntries();        
+    fRecPMod->Fill(modId,nrecp);         
+    if(lay==3) fRecPLadLay3->Fill(lad-1,nrecp);
+    if(lay==4) fRecPLadLay4->Fill(lad-1,nrecp);
+    for(Int_t irec=0;irec<nrecp;irec++) {
+      AliITSRecPoint *recp = (AliITSRecPoint*)ITSrec->At(irec);
+      fDriftTimeRP->Fill(recp->GetDriftTime());
+    }
+  }
+  ITSrec->Delete();
+  delete ITSrec;
+
+  PostData(1,fOutput);
+  
+}
+//______________________________________________________________________________
+Bool_t AliAnalysisTaskSDDRP::CheckModule(Int_t lay, Int_t lad, Int_t det) const{
+  //
+  if(lay==4){
+    if(lad==3 && det==5) return kFALSE; // 1500 V
+    if(lad==3 && det==6) return kFALSE; // 0 V
+    if(lad==3 && det==7) return kFALSE; // 1500 V
+    if(lad==4 && det==1) return kFALSE; // 0 V
+    if(lad==4 && det==2) return kFALSE; // 1500 V
+    if(lad==7 && det==5) return kFALSE; // 0 MV
+    if(lad==9 && det==3) return kFALSE; // 1500 V
+    if(lad==9 && det==4) return kFALSE; // 0 V
+    if(lad==9 && det==5) return kFALSE; // 1500 V
+    if(lad==11 && det==6) return kFALSE; // 1500 V
+    if(lad==11 && det==7) return kFALSE; // 0 V
+    if(lad==11 && det==8) return kFALSE; // 1500 V
+    if(lad==18 && det==5) return kFALSE; // 1500 V
+    if(lad==18 && det==6) return kFALSE; // 0 V
+    if(lad==18 && det==7) return kFALSE; // 1500 V
+    if(lad==22 && det==1) return kFALSE; // 0 V
+    if(lad==22 && det==2) return kFALSE; // 1500 V
+  }
+  if(lay==3){
+    if(lad==4 && det==4) return kFALSE; // 1500 V 
+    if(lad==3) return kFALSE;  // swapped in geometry
+  }
+  return kTRUE;
+}
+
+//______________________________________________________________________________
+void AliAnalysisTaskSDDRP::Terminate(Option_t */*option*/)
+{
+  // Terminate analysis
+  fOutput = dynamic_cast<TList*> (GetOutputData(1));
+  if (!fOutput) {     
+    printf("ERROR: fOutput not available\n");
+    return;
+  }
+  fHistNEvents= dynamic_cast<TH1F*>(fOutput->FindObject("hNEvents"));
+  fRecPMod= dynamic_cast<TH1F*>(fOutput->FindObject("hRPMod"));
+  fTrackPMod= dynamic_cast<TH1F*>(fOutput->FindObject("hTPMod"));
+  fGoodAnMod= dynamic_cast<TH1F*>(fOutput->FindObject("hGAMod"));
+
+  fRecPLadLay3= dynamic_cast<TH1F*>(fOutput->FindObject("hRPLad3"));
+  fRecPLadLay4= dynamic_cast<TH1F*>(fOutput->FindObject("hRPLad4"));
+  fTrackPLadLay3= dynamic_cast<TH1F*>(fOutput->FindObject("hTPLad3"));
+  fTrackPLadLay4= dynamic_cast<TH1F*>(fOutput->FindObject("hTPLad4"));
+  fGoodAnLadLay3= dynamic_cast<TH1F*>(fOutput->FindObject("hGALad3"));
+  fGoodAnLadLay4= dynamic_cast<TH1F*>(fOutput->FindObject("hGALad4"));
+
+  fDriftTimeRP= dynamic_cast<TH1F*>(fOutput->FindObject("hDrTimRP"));
+  fDriftTimeTP= dynamic_cast<TH1F*>(fOutput->FindObject("hDrTimTP"));
+
+  for(Int_t it=0; it<8; it++){
+    fSignalTime[it]= dynamic_cast<TH1F*>(fOutput->FindObject(Form("hSigTimeInt%d",it)));
+  }
+
+  return;
+}
+
+
+
+
+
diff --git a/PWG1/ITS/AliAnalysisTaskSDDRP.h b/PWG1/ITS/AliAnalysisTaskSDDRP.h
new file mode 100644 (file)
index 0000000..0327a19
--- /dev/null
@@ -0,0 +1,69 @@
+#ifndef ALIANALYSISTASKSDDRP
+#define ALIANALYSISTASKSDDRP
+
+class TList;
+class TH1F;
+class TTree;
+class TString;
+class AliESDEvent;
+class AliESDfriend;
+class AliITSresponseSDD;
+
+#include "AliAnalysisTaskSE.h"
+
+class AliAnalysisTaskSDDRP : public AliAnalysisTaskSE {
+
+ public:
+  
+  AliAnalysisTaskSDDRP();
+  virtual ~AliAnalysisTaskSDDRP();
+  virtual void   UserExec(Option_t *option);
+  virtual void   UserCreateOutputObjects();
+  virtual void   Terminate(Option_t *option);
+
+  void SetRunNumber(Int_t nrun){
+    fRunNumber=nrun;
+  }
+  void SetMinITSPoints(Int_t minp=3){
+    fMinITSpts=minp;
+  }
+  void SetUseOnlyCINT1BTriggers(Bool_t use=kTRUE){
+    fOnlyCINT1BTrig=use;
+  }
+  void SetMinPfordEdx(Float_t minp=1.5){
+    fMinPfordEdx=minp;
+  }
+  Bool_t CheckModule(Int_t lay, Int_t lad, Int_t det) const;
+
+
+ private:
+  AliAnalysisTaskSDDRP(const AliAnalysisTaskSDDRP &source);
+  AliAnalysisTaskSDDRP& operator=(const AliAnalysisTaskSDDRP &source);
+  
+  TList*  fOutput;          //! ntuple with output of vertexers
+  TH1F*   fHistNEvents;     //! histo with N of events  
+  TH1F*   fRecPMod;         //! histo with module occupancy (RecP) 
+  TH1F*   fTrackPMod;       //! histo with module occupancy (TrP)
+  TH1F*   fGoodAnMod;       //! histo good anodes per module 
+  TH1F*   fRecPLadLay3;     //! histo with ladder occupancy on layer3 (RecP) 
+  TH1F*   fRecPLadLay4;     //! histo with ladder occupancy on layer4 (RecP)
+  TH1F*   fTrackPLadLay3;   //! histo with ladder occupancy on layer3 (TrP)
+  TH1F*   fTrackPLadLay4;   //! histo with ladder occupancy on layer4 (TrP)
+  TH1F*   fGoodAnLadLay3;   //! histo good anodes per ladder on layer3 
+  TH1F*   fGoodAnLadLay4;   //! histo good anodes per ladder on layer4 
+  TH1F*   fDriftTimeRP;     //! histo with drift time distribution (RecP)
+  TH1F*   fDriftTimeTP;     //! histo with drift time distribution (TrP)
+  TH1F*   fSignalTime[8];   //! histos of dE/dx in time windows
+  AliESDEvent  *fESD;       // ESD object
+  AliESDfriend *fESDfriend; // ESD friend object
+  AliITSresponseSDD* fResp; // ResponseSDD object
+  Int_t   fRunNumber;       // Run number
+  Int_t   fMinITSpts;       // Minimum number of points per track
+  Float_t fMinPfordEdx;     // Minimum momentum for dE/dx
+  Bool_t  fOnlyCINT1BTrig;  // Flag for using all events or only intections
+  Bool_t  fInitialised;     // True if initialised
+  ClassDef(AliAnalysisTaskSDDRP,1);  
+};
+
+
+#endif
diff --git a/PWG1/ITS/AliAnalysisTaskSPD.cxx b/PWG1/ITS/AliAnalysisTaskSPD.cxx
new file mode 100644 (file)
index 0000000..631d253
--- /dev/null
@@ -0,0 +1,322 @@
+#include "AliAnalysisTask.h"\r
+#include "AliAnalysisManager.h"\r
+#include "AliAnalysisDataContainer.h"\r
+#include "AliMultiplicity.h"\r
+#include "AliITSRecPoint.h"\r
+#include "AliITSDetTypeRec.h"\r
+#include "AliGeomManager.h"\r
+#include "AliESDVertex.h"\r
+#include "AliESDEvent.h"\r
+#include "AliMagF.h"\r
+#include <TSystem.h>\r
+#include <TTree.h>\r
+#include <TNtuple.h>\r
+#include <TH1I.h>\r
+#include <TH2F.h>\r
+#include <TGeoManager.h>\r
+#include <TChain.h>\r
+#include <TGeoGlobalMagField.h>\r
+#include "AliESDInputHandlerRP.h"\r
+#include "AliAnalysisTaskSPD.h"\r
+#include "AliITSsegmentationSPD.h"\r
+\r
+ClassImp(AliAnalysisTaskSPD)\r
+  //______________________________________________________________________________\r
+  const Int_t AliAnalysisTaskSPD::fgkDDLModuleMap[20][12] = {\r
+    { 4, 5, 0, 1, 80, 81, 84, 85, 88, 89, 92, 93},\r
+    {12,13, 8, 9, 96, 97,100,101,104,105,108,109},\r
+    {20,21,16,17,112,113,116,117,120,121,124,125},\r
+    {28,29,24,25,128,129,132,133,136,137,140,141},\r
+    {36,37,32,33,144,145,148,149,152,153,156,157},\r
+    {44,45,40,41,160,161,164,165,168,169,172,173},\r
+    {52,53,48,49,176,177,180,181,184,185,188,189},\r
+    {60,61,56,57,192,193,196,197,200,201,204,205},\r
+    {68,69,64,65,208,209,212,213,216,217,220,221},\r
+    {76,77,72,73,224,225,228,229,232,233,236,237},\r
+    { 7, 6, 3, 2, 83, 82, 87, 86, 91, 90, 95, 94},\r
+    {15,14,11,10, 99, 98,103,102,107,106,111,110},\r
+    {23,22,19,18,115,114,119,118,123,122,127,126},\r
+    {31,30,27,26,131,130,135,134,139,138,143,142},\r
+    {39,38,35,34,147,146,151,150,155,154,159,158},\r
+    {47,46,43,42,163,162,167,166,171,170,175,174},\r
+    {55,54,51,50,179,178,183,182,187,186,191,190},\r
+    {63,62,59,58,195,194,199,198,203,202,207,206},\r
+    {71,70,67,66,211,210,215,214,219,218,223,222},\r
+    {79,78,75,74,227,226,231,230,235,234,239,238}\r
+  };\r
+\r
+//______________________________________________________________________________\r
+AliAnalysisTaskSPD::AliAnalysisTaskSPD() : \r
+  AliAnalysisTaskSE(), \r
+  fOutput(0),\r
+  fSegSPD(0)\r
+{\r
+  //\r
+}\r
+//______________________________________________________________________________\r
+AliAnalysisTaskSPD::AliAnalysisTaskSPD(const char *name) : \r
+  AliAnalysisTaskSE(name), \r
+  fOutput(0),\r
+  fSegSPD(0)\r
+{\r
+  DefineOutput(1, TList::Class());\r
+}\r
+\r
+\r
+//___________________________________________________________________________\r
+AliAnalysisTaskSPD::~AliAnalysisTaskSPD(){\r
+  //\r
+  if (fOutput) {\r
+    delete fOutput;\r
+    fOutput = 0;\r
+  }\r
+  if(fSegSPD) delete fSegSPD;\r
+}\r
+\r
+//________________________________________________________________________\r
+void AliAnalysisTaskSPD::Init()\r
+{\r
+  // Initialization\r
+\r
+  if(fDebug > 1) printf("AliAnalysisTaskSPD::Init() \n");\r
+}\r
+//___________________________________________________________________________\r
+\r
+void AliAnalysisTaskSPD::UserCreateOutputObjects() {\r
+  //\r
+  if(fDebug > 1) printf("AliAnalysisTaskSPD::UserCreateOutputObjects() \n");\r
+\r
+  fSegSPD = new AliITSsegmentationSPD();\r
+\r
+  OpenFile(1);\r
+  fOutput = new TList();\r
+\r
+  TH1I *nentries = new TH1I("events","events",1,0,1);\r
+  fOutput->AddLast(nentries);\r
+\r
+  TH2F *modulemap[240];\r
+\r
+  for(Int_t imod =0; imod < 240; imod++){\r
+    modulemap[imod] = new TH2F(Form("mod%i",imod),Form("cluster map for module %i",imod),800,-4,4,200,-1,1);\r
+    modulemap[imod]->SetXTitle("Local Z (cm)");\r
+    modulemap[imod]->SetYTitle("Local X (cm)");\r
+    fOutput->AddLast(modulemap[imod]);\r
+  }\r
+\r
+  TH1F *hFOgood = new TH1F("hFOgood"," Events with FO and clusters ",1200,0,1200);\r
+  hFOgood->SetXTitle("chipkey");\r
+  fOutput->AddLast(hFOgood);\r
+\r
+  TH1F *hFOnoisy = new TH1F("hFOnoisy"," Events with FO but no cluster",1200,0,1200);\r
+  hFOnoisy->SetXTitle("chipkey");\r
+  fOutput->AddLast(hFOnoisy);\r
+  \r
+  TH1F *hFiredChips = new TH1F("hFiredChips"," yield of fired chips",1200,0,1200);\r
+  hFiredChips->SetXTitle("chipkey");\r
+  fOutput->AddLast(hFiredChips);\r
+\r
+  TH2F *hSPDphivsSPDeta= new TH2F("hSPDphivsSPDeta", "Tracklets - #varphi vs #eta",120,-3.,3,360,0.,2*TMath::Pi());\r
+  hSPDphivsSPDeta->GetXaxis()->SetTitle("Pseudorapidity #eta");\r
+  hSPDphivsSPDeta->GetYaxis()->SetTitle("#varphi [rad]");\r
+  fOutput->AddLast(hSPDphivsSPDeta);\r
+\r
+  TH1F *hSPDphiZpos= new TH1F("hSPDphiZpos", "Tracklets - #varphi (Z>0)",360,0.,2*TMath::Pi());\r
+  hSPDphiZpos->SetXTitle("#varphi [rad]");\r
+  fOutput->AddLast(hSPDphiZpos);\r
+\r
+  TH1F *hSPDphiZneg= new TH1F("fHistSPDphivsSPDetaZneg", "Tracklets - #varphi (Z<0)",360,0.,2*TMath::Pi());\r
+  hSPDphiZneg->SetXTitle("#varphi [rad]");\r
+  fOutput->AddLast(hSPDphiZneg);\r
+\r
+}\r
+//______________________________________________________________________________\r
+void AliAnalysisTaskSPD::UserExec(Option_t */*option*/)\r
+{\r
+  if(fDebug > 1) printf("AliAnalysisTaskSPD::Exec() \n");\r
+  \r
+\r
+  AliESDInputHandlerRP *hand = dynamic_cast<AliESDInputHandlerRP*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());\r
+  if(!hand) {\r
+    printf("No AliESDInputHandlerRP \n");\r
+    return;\r
+  }  \r
+\r
+  AliESDEvent *ESD = hand->GetEvent();\r
+  if(!ESD) {\r
+    printf("No AliESDEvent \n");\r
+    return;\r
+  }  \r
+\r
+  TTree * treeRP = hand->GetTreeR("ITS");\r
+  if(!treeRP) {\r
+    printf("No RecPoints tree \n");\r
+    return;\r
+  }  \r
+\r
+  // RecPoints info\r
+\r
+  TClonesArray statITSrec("AliITSRecPoint");\r
+  TClonesArray *ITSCluster = &statITSrec;\r
+  TBranch* branch=treeRP->GetBranch("ITSRecPoints");\r
+  if(!branch) return;\r
+\r
+  branch->SetAddress(&ITSCluster);\r
+\r
+  Bool_t isfiredchip[20][6][10];\r
+  for(Int_t eq=0; eq<20; eq++){\r
+    for(Int_t hs =0; hs<6; hs++){\r
+      for(Int_t chip=0; chip<10; chip++){\r
+       isfiredchip[eq][hs][chip]=kFALSE;\r
+      }\r
+    }\r
+  }\r
+\r
+\r
+  for(Int_t iMod=0;iMod<240;iMod++){\r
+    branch->GetEvent(iMod);\r
+    Int_t nrecp = statITSrec.GetEntries();\r
+    for(Int_t irec=0;irec<nrecp;irec++) {\r
+      AliITSRecPoint *recp = (AliITSRecPoint*)statITSrec.At(irec);\r
+      Int_t lay=recp->GetLayer();\r
+      if(lay>1) continue;\r
+      Float_t local[3]={-1,-1};\r
+      local[1]=recp->GetDetLocalX();\r
+      local[0]=recp->GetDetLocalZ();\r
+      //printf("local X %f   local Z %f   in module %i \n",local[0],local[1],iMod);\r
+      ((TH2F*)fOutput->At(iMod+1))->Fill(local[0],local[1]);\r
+      Int_t eq = GetOnlineEqIdFromOffline(iMod);\r
+      Int_t hs = GetOnlineHSFromOffline(iMod);\r
+      Int_t row, col;\r
+      fSegSPD->LocalToDet(0.5,local[0],row,col);\r
+      Int_t chip = GetOnlineChipFromOffline(iMod,col);\r
+      isfiredchip[eq][hs][chip]=kTRUE;\r
+    }\r
+  }\r
+\r
+  //  ESDs info\r
+\r
+  // First looking at the FO bits\r
+  const AliMultiplicity *mult = ESD->GetMultiplicity();\r
+\r
+  for(Int_t eq=0; eq<20; eq++){\r
+    for(Int_t hs =0; hs<6; hs++){\r
+      for(Int_t chip=0; chip<10; chip++){\r
+       Int_t key = GetOfflineChipKeyFromOnline(eq,hs,chip);\r
+       if(mult->TestFastOrFiredChips(key) && isfiredchip[eq][hs][chip]) ((TH1F*)fOutput->At(241))->Fill(key);\r
+       if(!isfiredchip[eq][hs][chip] && mult->TestFastOrFiredChips(key)) ((TH1F*)fOutput->At(242))->Fill(key);\r
+       if(isfiredchip[eq][hs][chip]) ((TH1F*)fOutput->At(243))->Fill(key);\r
+      }\r
+    }\r
+  }\r
+\r
+  // Then looking at tracklets \r
+  const AliESDVertex* vtxESD = ESD->GetVertex();\r
+  if(vtxESD){\r
+\r
+    Double_t esdvtx[3];\r
+    vtxESD->GetXYZ(esdvtx);\r
+\r
+    for(Int_t iTracklet =0; iTracklet < mult->GetNumberOfTracklets(); iTracklet++){\r
+\r
+      Float_t phiTr= mult->GetPhi(iTracklet);\r
+      Float_t etaTr =mult->GetEta(iTracklet);\r
+\r
+      ((TH2F*)fOutput->At(244))->Fill(etaTr,phiTr);\r
+\r
+      //layer 0\r
+      //Float_t z = esdvtx[2] + 3.9 / TMath::Tan(2 * TMath::ATan(TMath::Exp(- etaTr)));\r
+      Int_t isZpos = (esdvtx[2]>0 && etaTr>0) ;\r
+      Int_t isZneg = (esdvtx[2]<0 && etaTr<0) ; \r
+\r
+      if(isZpos)  ((TH1F*)fOutput->At(245))->Fill(phiTr);\r
+      if(isZneg)  ((TH1F*)fOutput->At(246))->Fill(phiTr);\r
+    }\r
+  }\r
+\r
+  ((TH1I*)fOutput->At(0))->Fill(0); // monitoring plot\r
+\r
+  PostData(1,fOutput);  \r
+  return;\r
+  \r
+}\r
+//______________________________________________________________________________\r
+void AliAnalysisTaskSPD::Terminate(Option_t */*option*/)\r
+{\r
+  // Terminate analysis\r
+  if(fDebug > 1) printf("AliAnalysisTaskSPD:: Terminate() \n");\r
+  fOutput = dynamic_cast<TList*> (GetOutputData(1));\r
+  if (!fOutput) {     \r
+    printf("ERROR: fOutput not available\n");\r
+    //return;\r
+  }\r
+}\r
+//________________________________________________________________________\r
+UInt_t AliAnalysisTaskSPD::GetOfflineModuleFromOnline(UInt_t eqId, UInt_t hs, UInt_t chip) {\r
+  // online->offline (module)\r
+  if (eqId<20 && hs<6 && chip<10) return fgkDDLModuleMap[eqId][hs*2+chip/5];\r
+  else return 240;\r
+}\r
+//________________________________________________________________________\r
+UInt_t AliAnalysisTaskSPD::GetOfflineChipKeyFromOnline(UInt_t eqId, UInt_t hs, UInt_t chip) {\r
+  // online->offline (chip key: 0-1199)\r
+  if (eqId<20 && hs<6 && chip<10) {\r
+    UInt_t module = GetOfflineModuleFromOnline(eqId,hs,chip);\r
+    UInt_t chipInModule = ( chip>4 ? chip-5 : chip );\r
+    if(eqId>9) chipInModule = 4 - chipInModule;  // side C only\r
+    return (module*5 + chipInModule);\r
+  } else return 1200;\r
+}\r
+//__________________________________________________________________________\r
+UInt_t AliAnalysisTaskSPD::GetOnlineEqIdFromOffline(UInt_t module) {\r
+  // offline->online (eq)\r
+  for (UInt_t eqId=0; eqId<20; eqId++) {\r
+    for (UInt_t iModule=0; iModule<12; iModule++) {\r
+      if (GetModuleNumber(eqId,iModule)==(Int_t)module) return eqId;\r
+    }\r
+  }\r
+  return 20; // error\r
+}\r
+//__________________________________________________________________________\r
+UInt_t AliAnalysisTaskSPD::GetOnlineHSFromOffline(UInt_t module) {\r
+  // offline->online (hs)\r
+  for (UInt_t eqId=0; eqId<20; eqId++) {\r
+    for (UInt_t iModule=0; iModule<12; iModule++) {\r
+      if (GetModuleNumber(eqId,iModule)==(Int_t)module) return iModule/2;\r
+    }\r
+  }\r
+  return 6; // error\r
+}\r
+//__________________________________________________________________________\r
+UInt_t AliAnalysisTaskSPD::GetOnlineChipFromOffline(UInt_t module, UInt_t colM) {\r
+  // offline->online (chip)\r
+  for (UInt_t eq=0; eq<20; eq++) {\r
+    for (UInt_t iModule=0; iModule<12; iModule++) {\r
+      if (GetModuleNumber(eq,iModule)==(Int_t)module) {\r
+        if (module<80) {\r
+          if (eq<10) { // side A\r
+            return (159-colM)/32 + 5*(iModule%2);\r
+          }\r
+          else { // side C\r
+            return colM/32 + 5*(iModule%2);\r
+          }\r
+        }\r
+        else if (module<240) {\r
+          if (eq<10) { // side A\r
+            return colM/32 + 5*(iModule%2);\r
+          }\r
+          else { // side C\r
+            return (159-colM)/32 + 5*(iModule%2);\r
+          }\r
+        }\r
+      }\r
+    }\r
+  }\r
+  return 10; // error\r
+}\r
+//__________________________________________________________________________\r
+Int_t AliAnalysisTaskSPD::GetModuleNumber(UInt_t iDDL, UInt_t iModule) {\r
+  if (iDDL<20 && iModule<12) return fgkDDLModuleMap[iDDL][iModule];\r
+  else return 240;\r
+}\r
+\r
+\r
diff --git a/PWG1/ITS/AliAnalysisTaskSPD.h b/PWG1/ITS/AliAnalysisTaskSPD.h
new file mode 100644 (file)
index 0000000..c36f0e7
--- /dev/null
@@ -0,0 +1,43 @@
+#ifndef ALIANALYSISTASKSPD_H
+#define ALIANALYSISTASKSPD_H
+
+
+#include "AliAnalysisTaskSE.h"
+
+class AliITSsegmentationSPD;
+class AliAnalysisTaskSPD : public AliAnalysisTaskSE {
+
+ public:
+  
+  AliAnalysisTaskSPD();
+  AliAnalysisTaskSPD(const char *name);
+  virtual ~AliAnalysisTaskSPD();
+
+  virtual void UserCreateOutputObjects();
+  virtual void Init();
+  virtual void LocalInit() {Init();}
+  virtual void UserExec(Option_t *option);
+  virtual void Terminate(Option_t *option);
+  
+
+ private:
+
+  UInt_t GetOfflineModuleFromOnline(UInt_t eqId, UInt_t hs, UInt_t chip); //see AliITSRawStreamSPD
+  UInt_t GetOfflineChipKeyFromOnline(UInt_t eqId, UInt_t hs, UInt_t chip); // see AliITSRawStreamSPD
+  UInt_t GetOnlineEqIdFromOffline(UInt_t module); // see AliITSRawStreamSPD
+  UInt_t GetOnlineHSFromOffline(UInt_t module); // see AliITSRawStreamSPD
+  UInt_t GetOnlineChipFromOffline(UInt_t module, UInt_t colM); // see AliITSRawStreamSPD
+  Int_t GetModuleNumber(UInt_t iDDL, UInt_t iModule); // see AliITSRawStreamSPD
+
+  AliAnalysisTaskSPD(const AliAnalysisTaskSPD &source);
+  AliAnalysisTaskSPD& operator=(const AliAnalysisTaskSPD &source);
+
+  static const Int_t fgkDDLModuleMap[20][12];  // mapping DDL/module -> module number
+
+  TList   *fOutput; //! list of histos
+  AliITSsegmentationSPD *fSegSPD;
+  ClassDef(AliAnalysisTaskSPD,1);  
+};
+
+
+#endif
index fea14bb..7e94d57 100644 (file)
@@ -65,6 +65,8 @@
 #pragma link C++ class AliTrackMatchingTPCITSCosmics+;
 #pragma link C++ class AliAnalysisTaskV0QA+;
 #pragma link C++ class AliMaterialBudget+;
+#pragma link C++ class AliAnalysisTaskSPD+;
+#pragma link C++ class AliAnalysisTaskSDDRP+;
 
 #pragma link C++ class AliRelAlignerKalmanArray+;
 #pragma link C++ class AliAnalysisTaskITSTPCalignment+;