// ------------------------------------------------------------------ // ----- CbmTofAnaTestbeam ----- // ----- Created 12/04/2014 by nh ----- // ------------------------------------------------------------------ #include "CbmTofAnaTestbeam.h" // TOF Classes and includes #include "CbmTofDigi.h" // in cbmdata/tof #include "CbmTofDigiExp.h" // in cbmdata/tof #include "CbmTofHit.h" // in cbmdata/tof #include "CbmTofGeoHandler.h" // in tof/TofTools #include "CbmTofDetectorId_v12b.h" // in cbmdata/tof #include "CbmTofDetectorId_v14a.h" // in cbmdata/tof #include "CbmTofCell.h" // in tof/TofData #include "CbmTofDigiPar.h" // in tof/TofParam #include "CbmTofDigiBdfPar.h" // in tof/TofParam #include "CbmTofAddress.h" // in cbmdata/tof #include "CbmMatch.h" #include "CbmTofTestBeamClusterizer.h" #include "TMbsMappingTofPar.h" // CBMroot classes and includes // FAIR classes and includes #include "FairRunAna.h" #include "FairRuntimeDb.h" #include "FairRootManager.h" #include "FairLogger.h" // ROOT Classes and includes #include "Riostream.h" #include "TClonesArray.h" #include "TH1.h" #include "TH2.h" #include "TProfile.h" #include "TString.h" #include "TFile.h" #include "TMath.h" #include "TRandom.h" #include "TROOT.h" #include "TDirectory.h" #include "TGeoManager.h" const Int_t DetMask = 4194303; const Double_t DTDMAX=6000.; // diamond inspection range in ps Double_t dTDia; Double_t dDTD4Min=1.E8; //___________________________________________________________________ // // CbmTofAnaTestbeam // // Task for analysis of Testbeam data // // ------------------------------------------------------------------ CbmTofAnaTestbeam::CbmTofAnaTestbeam() : FairTask("HadronAnalysis"), fEvents(0), fGeoHandler(new CbmTofGeoHandler()), fTofId(NULL), fChannelInfo(NULL), iNbSmTot(0), fvTypeSmOffs(), iNbRpcTot(0), fvSmRpcOffs(), iNbChTot(0), fvRpcChOffs(), fDigiPar(NULL), fDigiBdfPar(NULL), fTofDigisColl(NULL), fTofDigiMatchColl(NULL), fTofHitsColl(NULL), fStart(), fStop() { cout << "CbmTofTests: Task started " << endl; } // ------------------------------------------------------------------ // ------------------------------------------------------------------ CbmTofAnaTestbeam::CbmTofAnaTestbeam(const char* name, Int_t verbose) : FairTask(name, verbose), fEvents(0), fGeoHandler(new CbmTofGeoHandler()), fTofId(NULL), fChannelInfo(NULL), iNbSmTot(0), fvTypeSmOffs(), iNbRpcTot(0), fvSmRpcOffs(), iNbChTot(0), fvRpcChOffs(), fDigiPar(NULL), fDigiBdfPar(NULL), fTofDigisColl(NULL), fTofDigiMatchColl(NULL), fTofHitsColl(NULL), fStart(), fStop() { } // ------------------------------------------------------------------ // ------------------------------------------------------------------ CbmTofAnaTestbeam::~CbmTofAnaTestbeam() { // Destructor } // ------------------------------------------------------------------ /************************************************************************************/ // FairTasks inherited functions InitStatus CbmTofAnaTestbeam::Init() { if( kFALSE == RegisterInputs() ) return kFATAL; // fTofId = new ( CbmTofDetectorId )CbmTofDetectorId_v14a(); if( kFALSE == InitParameters() ) return kFATAL; if( kFALSE == LoadCalParameter() ) return kFATAL; if( kFALSE == CreateHistos() ) return kFATAL; return kSUCCESS; } void CbmTofAnaTestbeam::SetParContainers() { LOG(INFO)<<" CbmTofAnaTestbeam => Get the digi parameters for tof"<GetRuntimeDb(); fDigiPar = (CbmTofDigiPar*) (rtdb->getContainer("CbmTofDigiPar")); fDigiBdfPar = (CbmTofDigiBdfPar*) (rtdb->getContainer("CbmTofDigiBdfPar")); } void CbmTofAnaTestbeam::Exec(Option_t * option) { // Task execution LOG(DEBUG)<<" CbmTofAnaTestbeam => New event"<GetObject("CbmTofDigiExp"); if( NULL == fTofDigisColl) fTofDigisColl = (TClonesArray *) fManager->GetObject("CbmTofDigi"); if( NULL == fTofDigisColl) { LOG(ERROR)<<"CbmTofAnaTestbeam::RegisterInputs => Could not get the TofDigi TClonesArray!!!"<GetObject("TofHit"); if( NULL == fTofHitsColl) { LOG(ERROR)<<"CbmTofAnaTestbeam::RegisterInputs => Could not get the TofHit TClonesArray!!!"<GetObject("TofDigiMatch"); if( NULL == fTofDigiMatchColl) { LOG(ERROR)<<"CbmTofAnaTestbeam::RegisterInputs => Could not get the Match TClonesArray!!!"<GetRuntimeDb(); Int_t iGeoVersion = fGeoHandler->Init(isSimulation); if( k14a > iGeoVersion ) { } fDigiPar = (CbmTofDigiPar*) (rtdb->getContainer("CbmTofDigiPar")); if( 0 == fDigiPar ) { LOG(ERROR)<<"CbmTofAnaTestbeam::InitParameters => Could not obtain the CbmTofDigiPar "<getContainer("CbmTofDigiBdfPar")); if( 0 == fDigiBdfPar ) { LOG(ERROR)<<"CbmTofAnaTestbeam::InitParameters => Could not obtain the CbmTofDigiBdfPar "<getContainer("TMbsMappingTofPar")); if( 0 == fMbsMappingPar ) { LOG(ERROR)<<"CbmTofAnaTestBeam::InitParameters => Could not obtain the TMbsMappingTofPar "<initContainers( ana->GetRunId() ); LOG(INFO)<<"CbmTofAnaTestbeam::InitParameter: currently " << fDigiPar->GetNrOfModules() << " digi cells " <FindObjectAny( Form("hDTD4DT04D4best_pfx_px")); if (NULL == fhtmp) { LOG(INFO)<<" Histo " << Form("hDTD4DT04D4best_pfx_px") << " not found. " <FindObjectAny( Form("hDTX4D4best_pfx_px")); if (NULL == fhtmpx) { LOG(INFO)<<" Histo " << Form("hDTX4D4best_pfx_px") << " not found. " <FindObjectAny( Form("hDTY4D4best_pfx_px")); if (NULL == fhtmpy) { LOG(INFO)<<" Histo " << Form("hDTY4D4best_pfx_px") << " not found. " <FindObjectAny( Form("hTexpDT04D4best_pfx_px")); if (NULL == fhtmpt) { LOG(INFO)<<" Histo " << Form("hTexpDT04D4best_pfx_px") << " not found. " <cd(); if(NULL != fhtmp) fhDTD4DT04D4Off=(TH1D *)fhtmp->Clone(); if(NULL != fhtmpx) fhDTX4D4Off=(TH1D *)fhtmpx->Clone(); if(NULL != fhtmpy) fhDTY4D4Off=(TH1D *)fhtmpy->Clone(); if(NULL != fhtmpt) fhDTTexpD4Off=(TH1D *)fhtmpt->Clone(); fCalParFile->Close(); // fhDTD4DT04D4Off->Draw(); if (fdDCh4Sel==0.) fdDCh4Sel=1000.; // open default window if (fdPosY4Sel==0.) fdPosY4Sel=10.; // open default window return kTRUE; } /************************************************************************************/ // ------------------------------------------------------------------ Bool_t CbmTofAnaTestbeam::CreateHistos() { // Create histogramms Double_t XDMAX=100.; Double_t YDMAX=100.; Double_t TDMAX=100000.; Double_t DTMAX=1000.; Double_t DXMAX=10.; Double_t DYMAX=10.; Double_t XMAX=100.; Double_t YMAX=100.; TDirectory * oldir = gDirectory; // <= To prevent histos from being sucked in by the param file of the TRootManager! gROOT->cd(); // <= To prevent histos from being sucked in by the param file of the TRootManager ! // define histos here Int_t iNbDet=fMbsMappingPar->GetNbMappedDet(); fhXYPos.resize( iNbDet ); for(Int_t iDet=0; iDetcd( oldir->GetPath() ); // <= To prevent histos from being sucked in by the param file of the TRootManager! return kTRUE; } // ------------------------------------------------------------------ Bool_t CbmTofAnaTestbeam::FillHistos() { // Constants, TODO => put as parameter !!! Int_t kTOF=6; // Declare variables outside the loop CbmTofHit *pHit; CbmTofHit *pHit1; CbmTofHit *pHit2; CbmTofHit *pHitRef; CbmTofCell *fChannelInfo1; CbmTofCell *fChannelInfo2; Int_t iNbTofDigis, iNbTofHits; iNbTofDigis = fTofDigisColl->GetEntriesFast(); iNbTofHits = fTofHitsColl->GetEntriesFast(); /* LOG(INFO)<UseExpandedDigi() ) { CbmTofDigiExp *pDigi; for( Int_t iDigInd = 0; iDigInd < iNbTofDigis; iDigInd++ ) { pDigi = (CbmTofDigiExp*) fTofDigisColl->At( iDigInd ); Int_t iSmType = pDigi->GetType(); Int_t iSm = pDigi->GetSm(); Int_t iRpc = pDigi->GetRpc(); Int_t iCh = pDigi->GetChannel(); } // for( Int_t iDigInd = 0; iDigInd < iNbTofDigis; iDigInd++ ) } // if( kTRUE == fDigiBdfPar->UseExpandedDigi() ) */ // Hits info Int_t iNbMatchedHits = 0; Int_t iNbMaxMatch=100; Double_t Zref=200.; Double_t Chi2MatchMin=1.E8; Double_t Chi2List[iNbMaxMatch]; CbmTofHit *pChi2Hit1[iNbMaxMatch]; CbmTofHit *pChi2Hit2[iNbMaxMatch]; Chi2List[0]=1.E8; pChi2Hit1[0]=NULL; pChi2Hit2[0]=NULL; Int_t iNSel=2; Bool_t BSel[iNSel]; for(Int_t iSel=0;iSel0) dM4Max=fdMul4Max; Double_t dM0Max=100; // modify if (fdMul0Max>0) dM0Max=fdMul0Max; Double_t dMDMax=1; if (fdMulDMax>0) dMDMax=fdMulDMax; Double_t hitpos[3]; Double_t hitpos_local[3]; for( Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) { pHit = (CbmTofHit*) fTofHitsColl->At( iHitInd ); if(NULL == pHit) continue; Int_t iDetId = (pHit->GetAddress() & DetMask); Int_t iChId = pHit->GetAddress(); fChannelInfo = fDigiPar->GetCell( iChId ); Int_t iSmType=CbmTofAddress::GetSmType( iDetId ); LOG(DEBUG)<GetX(), pHit->GetY(), pHit->GetZ(), pHit->GetTime()) <Fill(pHit->GetX(),pHit->GetY()); switch(iSmType){ case 2 : // Plastic hit if (0 != CbmTofAddress::GetSmId( iDetId ) - fiPlaSelect) break; // get here for Plastic SmId == 0 only! for( Int_t iHitInd2 = iHitInd; iHitInd2 < iNbTofHits; iHitInd2++) { pHit2 = (CbmTofHit*) fTofHitsColl->At( iHitInd2 ); if(pHit2==NULL) continue; Int_t iDetId2 = (pHit2->GetAddress() & DetMask); Int_t iChId2 = pHit2->GetAddress(); fChannelInfo2 = fDigiPar->GetCell( iChId2 ); if( 2 == CbmTofAddress::GetSmType( iDetId2 )){ // Plastic hit correlation if (0==CbmTofAddress::GetSmId( iDetId ) - fiPlaSelect ){ if (1==CbmTofAddress::GetSmId( iDetId2 ) - fiPlaSelect) { fhDT2->Fill(pHit->GetTime()-pHit2->GetTime()); fhXX2->Fill(pHit->GetX(),pHit2->GetX()); fhYY2->Fill(pHit->GetY(),pHit2->GetY()); } } else if (1==CbmTofAddress::GetSmId( iDetId ) - fiPlaSelect){ // should never be reached LOG(WARNING) << "CbmTofAnaTestbeam::FillHistos: inconsistent Plastic analysis, check!" <Fill(pHit2->GetX(),pHit->GetX()); fhYY2->Fill(pHit2->GetY(),pHit->GetY()); } } } if( fiMrpcRef == CbmTofAddress::GetSmType( iDetId2 )){ // HdRef hit Double_t xPos=Zref/pHit->GetZ()*pHit->GetX(); Double_t yPos=Zref/pHit->GetZ()*pHit->GetY(); Double_t tof=pHit->GetTime(); Double_t xPos2=Zref/pHit2->GetZ()*pHit2->GetX(); Double_t yPos2=Zref/pHit2->GetZ()*pHit2->GetY(); Double_t tof2=pHit2->GetTime(); Double_t Chi2Match =TMath::Power((xPos-xPos2)/fdDXWidth,2.) +TMath::Power((yPos-yPos2)/fdDYWidth,2.) +TMath::Power((tof-tof2)/fdDTWidth,2.); if( TMath::Abs(xPos-xPos2)<10. && TMath::Abs(yPos-yPos2)<10. && TMath::Abs(tof-tof2)<2500. && TMath::Abs(pHit2->GetY()-fChannelInfo2->GetY())GetSizey() ) { iMat24++; BSel[0]=kTRUE; // first selection scheme fhChi24->Fill(Chi2Match); fhXY24->Fill(xPos2,yPos2); fhDXDY24->Fill(xPos-xPos2,yPos-yPos2); fhDXDT24->Fill(xPos-xPos2,tof-tof2); fhDYDT24->Fill(yPos-yPos2,tof-tof2); if(Chi2MatchGetZ()*pHit->GetX(); Double_t yPos=Zref/pHit->GetZ()*pHit->GetY(); Double_t tof=pHit->GetTime(); for( Int_t iHitInd2 = 0; iHitInd2 < iNbTofHits; iHitInd2++) { if(iHitInd2 != iHitInd){ pHit2 = (CbmTofHit*) fTofHitsColl->At( iHitInd2 ); if (NULL== pHit2) continue; Int_t iDetId2 = (pHit2->GetAddress() & DetMask); Int_t iChId2 = pHit2->GetAddress(); fChannelInfo2 = fDigiPar->GetCell( iChId2 ); if (fiMrpcRef==CbmTofAddress::GetSmType( iDetId2 )){ //HdRef -> MrpcRef Double_t xPos2=Zref/pHit2->GetZ()*pHit2->GetX(); Double_t yPos2=Zref/pHit2->GetZ()*pHit2->GetY(); Double_t tof2=pHit2->GetTime(); Double_t Chi2Match =TMath::Power((xPos-xPos2-fdDXMean)/fdDXWidth,2.) +TMath::Power((yPos-yPos2-fdDYMean)/fdDYWidth,2.) +TMath::Power((tof-tof2-fdDTMean)/fdDTWidth,2.); if (Chi2Match > 1.E8) continue; iNbMatchedHits++; if(iNbMatchedHits==iNbMaxMatch) iNbMatchedHits=iNbMaxMatch-1; //prevent array overflow LOG(DEBUG) <Fill(xPos,xPos2); fhYY04->Fill(yPos,yPos2); fhTT04->Fill(tof,tof2); fhDXDY04->Fill(xPos-xPos2,yPos-yPos2); fhDXDT04->Fill(xPos-xPos2,tof-tof2); fhDYDT04->Fill(yPos-yPos2,tof-tof2); fhChi04->Fill(Chi2Match); for(Int_t iM=0; iM=iM; iMM--){ Chi2List[iMM]= Chi2List[iMM-1]; pChi2Hit1[iMM]= pChi2Hit1[iMM-1]; pChi2Hit2[iMM]= pChi2Hit2[iMM-1]; } Chi2List[iM]=Chi2Match; pChi2Hit1[iM]=pHit; pChi2Hit2[iM]=pHit2; Chi2List[iNbMatchedHits]=1.E8; if(iM>0){ if(Chi2Match == Chi2List[iM-1]){ LOG(DEBUG)<ToString() <ToString()<ToString() <Fill(Zref/pHit->GetZ()*pHit->GetX(),Zref/pHit2->GetZ()*pHit2->GetX()); fhYY02[iSm]->Fill(Zref/pHit->GetZ()*pHit->GetY(),Zref/pHit2->GetZ()*pHit2->GetY()); } } } } } break; case 1: case 4: if(fiMrpcRef != iSmType) break; dMul4++; break; case 5: if( 1 != CbmTofAddress::GetSmId( iDetId )) break; dMulD++; dTDia = pHit->GetTime(); if( fdDTDia>0. ) { Double_t dDDia=0.; for( Int_t iHitInd1 = 0; iHitInd1 < iNbTofHits; iHitInd1++) if( iHitInd1!=iHitInd) { pHit1 = (CbmTofHit*) fTofHitsColl->At( iHitInd1 ); if(pHit1==NULL) continue; Int_t iDetId1 = (pHit1->GetAddress() & DetMask); Int_t iChId1 = pHit1->GetAddress(); fChannelInfo1 = fDigiPar->GetCell( iChId1 ); pHit1 = (CbmTofHit*) fTofHitsColl->At( iHitInd1 ); if( 5 == CbmTofAddress::GetSmType( iDetId1 ) && 1 != CbmTofAddress::GetSmId ( iDetId1 ) && TMath::Abs( pHit1->GetTime()-dTDia)GetTime()-dTDia; } } LOG(DEBUG)<At( iHitInd2 ); if(pHit2==NULL) continue; Int_t iDetId2 = (pHit2->GetAddress() & DetMask); Int_t iChId2 = pHit2->GetAddress(); fChannelInfo2 = fDigiPar->GetCell( iChId2 ); if(NULL == fChannelInfo2){ LOG(ERROR) << "CbmTofAnaTestbeam::FillHistos: Invalid Channel Pointer for ChId2 " << Form(" 0x%08x ",iChId2) <GetTime()) <GetTime()-dTDia; LOG(DEBUG1)<GetY()-fChannelInfo2->GetY())GetSizey() &&TMath::Abs(CbmTofAddress::GetChannelId( iChId2 ) - fdCh4Sel) < fdDCh4Sel // && CbmTofAddress::GetChannelId( iChId2 ) < 15 ) { BSel[1]=kTRUE; if(TMath::Abs(dDTD4)Fill(iNbMatchedHits); //use as normalisation fhDT24sel ->Fill(dDT24); // refined normalisation if(iNbMatchedHits>0){ // best match LOG(DEBUG)<GetAddress() & DetMask); Int_t iChId1 = pHit1->GetAddress(); fChannelInfo1 = fDigiPar->GetCell( iChId1 ); Int_t iDetId2 = (pHit2->GetAddress() & DetMask); Int_t iChId2 = pHit2->GetAddress(); fChannelInfo2 = fDigiPar->GetCell( iChId2 ); Double_t xPos=Zref/pChi2Hit1[0]->GetZ()*pChi2Hit1[0]->GetX(); Double_t yPos=Zref/pChi2Hit1[0]->GetZ()*pChi2Hit1[0]->GetY(); Double_t tof=pChi2Hit1[0]->GetTime(); Double_t xPos2=Zref/pChi2Hit2[0]->GetZ()*pChi2Hit2[0]->GetX(); Double_t yPos2=Zref/pChi2Hit2[0]->GetZ()*pChi2Hit2[0]->GetY(); Double_t tof2=pChi2Hit2[0]->GetTime(); fhDXDY04best->Fill(xPos-xPos2,yPos-yPos2); fhDXDT04best->Fill(xPos-xPos2,tof-tof2); fhDYDT04best->Fill(yPos-yPos2,tof-tof2); fhChi04best->Fill(Chi2List[0]); fhX0DT04best->Fill(xPos-fChannelInfo1->GetX(),tof-tof2); fhY0DT04best->Fill(yPos-fChannelInfo1->GetY(),tof-tof2); CbmMatch* digiMatch1=(CbmMatch *)fTofDigiMatchColl->At(pHit1->GetRefId()); fhDigiMul0best->Fill(digiMatch1->GetNofLinks()/2.); fhChiDT04best->Fill(Chi2List[0],tof-tof2); fhDT24DT04best->Fill(dDT24,tof-tof2); Double_t dTcor=0.; if(fhDTD4DT04D4Off != NULL) dTcor=(Double_t)fhDTD4DT04D4Off->GetBinContent(fhDTD4DT04D4Off->FindBin(-dDTD4)); fhDTD4DT04best->Fill(-dDTD4,tof-tof2-dTcor); } } // selector 1 distributions if(BSel[1]){ /* for( Int_t iHitInd = 0; iHitInd < iNbTofHits; iHitInd++) { pHit = (CbmTofHit*) fTofHitsColl->At( iHitInd ); Int_t iDetId = (pHit->GetAddress() & DetMask); Int_t iChId = pHit->GetAddress(); fChannelInfo = fDigiPar->GetCell( iChId ); Int_t iSmType=CbmTofAddress::GetSmType( iDetId ); } */ fhNMatchD4sel->Fill(iNbMatchedHits); // use as normalisation fhDTD4sel->Fill(-dDTD4Min); // general normalisation if(iNbMatchedHits>0){ // best match LOG(DEBUG)<GetAddress() & DetMask); Int_t iChId1 = pHit1->GetAddress(); fChannelInfo1 = fDigiPar->GetCell( iChId1 ); Int_t iDetId2 = (pHit2->GetAddress() & DetMask); Int_t iChId2 = pHit2->GetAddress(); fChannelInfo2 = fDigiPar->GetCell( iChId2 ); Double_t xPos=Zref/pChi2Hit1[0]->GetZ()*pChi2Hit1[0]->GetX(); Double_t yPos=Zref/pChi2Hit1[0]->GetZ()*pChi2Hit1[0]->GetY(); Double_t tof=pChi2Hit1[0]->GetTime(); Double_t xPos2=Zref/pChi2Hit2[0]->GetZ()*pChi2Hit2[0]->GetX(); Double_t yPos2=Zref/pChi2Hit2[0]->GetZ()*pChi2Hit2[0]->GetY(); Double_t tof2=pChi2Hit2[0]->GetTime(); Double_t dDist=TMath::Sqrt( TMath::Power(pHit1->GetX()-pHit2->GetX(),2) +TMath::Power(pHit1->GetY()-pHit2->GetY(),2) +TMath::Power(pHit1->GetZ()-pHit2->GetZ(),2) ); fhChi04D4best->Fill(Chi2List[0]); CbmMatch* digiMatch1=(CbmMatch *)fTofDigiMatchColl->At(pHit1->GetRefId()); fhDigiMul0D4best->Fill(digiMatch1->GetNofLinks()/2.); fhDigiMul4D4best->Fill(digiMatch1->GetNofLinks()/2.); fhCluMul04D4best->Fill(dMul0,dMul4); // check for dependence in counter reference frame TGeoNode *fNode= // prepare global->local trafo gGeoManager->FindNode(fChannelInfo2->GetX(),fChannelInfo2->GetY(),fChannelInfo2->GetZ()); hitpos[0]=pChi2Hit2[0]->GetX(); hitpos[1]=pChi2Hit2[0]->GetY(); hitpos[2]=pChi2Hit2[0]->GetZ(); TGeoNode* cNode= gGeoManager->GetCurrentNode(); gGeoManager->MasterToLocal(hitpos, hitpos_local); Double_t dTofD4 = fdTOffD4 + dDTD4; Double_t dInvVel = dTofD4/pHitRef->GetR(); // in ps/cm Double_t dDTexp = dDist*dInvVel; Double_t dTcor=0.; if(fhDTD4DT04D4Off != NULL) dTcor=(Double_t)fhDTD4DT04D4Off->GetBinContent(fhDTD4DT04D4Off->FindBin(-dDTD4)); if(fhDTX4D4Off != NULL) dTcor+=(Double_t)fhDTX4D4Off->GetBinContent(fhDTX4D4Off->FindBin(hitpos_local[0])); if(fhDTY4D4Off != NULL) dTcor+=(Double_t)fhDTY4D4Off->GetBinContent(fhDTY4D4Off->FindBin(hitpos_local[1])); if(fhDTTexpD4Off != NULL) dTcor+=(Double_t)fhDTTexpD4Off->GetBinContent(fhDTTexpD4Off->FindBin(dDTexp)); // LOG(INFO) << "dTcor for "<<-dDTD4<<" from "<Fill(dTofD4); if(dInvVel>0.) fhVelD4best->Fill(1000./dInvVel); fhChiDT04D4best->Fill(Chi2List[0],tof-tof2-dTcor); if(dDT24 != 0.) fhDT24DT04D4best->Fill(dDT24,tof-tof2-dTcor); fhDTD4DT04D4best->Fill(-dDTD4,tof-tof2-dTcor); fhDTMul4D4best->Fill(dMul4,tof-tof2-dTcor); fhDTX4D4best->Fill(hitpos_local[0],tof-tof2-dTcor); fhDTY4D4best->Fill(hitpos_local[1],tof-tof2-dTcor); fhDXX4D4best->Fill(hitpos_local[0],xPos-xPos2); fhDXY4D4best->Fill(hitpos_local[1],xPos-xPos2); fhDYX4D4best->Fill(hitpos_local[0],yPos-yPos2); fhDYY4D4best->Fill(hitpos_local[1],yPos-yPos2); CbmMatch* digiMatch4=(CbmMatch *)fTofDigiMatchColl->At(pChi2Hit2[0]->GetRefId()); fhCluSize4DT04D4best->Fill(digiMatch4->GetNofLinks()/2.,tof-tof2-dTcor); Double_t dTot = 0.; for (Int_t iLink=0; iLinkGetNofLinks(); iLink++){ // loop over digis CbmLink L0 = digiMatch4->GetLink(iLink); Int_t iDigInd0=L0.GetIndex(); if (iDigInd0 < fTofDigisColl->GetEntries()){ CbmTofDigiExp *pDig0 = (CbmTofDigiExp*) (fTofDigisColl->At(iDigInd0)); dTot += pDig0->GetTot(); } } dTot /= digiMatch4->GetNofLinks(); // average time over threshold fhTot4DT04D4best->Fill(dTot,tof-tof2-dTcor); CbmMatch* digiMatch0=(CbmMatch *)fTofDigiMatchColl->At(pChi2Hit1[0]->GetRefId()); fhCluSize0DT04D4best->Fill(digiMatch0->GetNofLinks()/2.,tof-tof2-dTcor); dTot = 0.; for (Int_t iLink=0; iLinkGetNofLinks(); iLink++){ // loop over digis CbmLink L0 = digiMatch0->GetLink(iLink); Int_t iDigInd0=L0.GetIndex(); if (iDigInd0 < fTofDigisColl->GetEntries()){ CbmTofDigiExp *pDig0 = (CbmTofDigiExp*) (fTofDigisColl->At(iDigInd0)); dTot += pDig0->GetTot(); } } dTot /= digiMatch0->GetNofLinks(); // average time over threshold fhTot0DT04D4best->Fill(dTot,tof-tof2-dTcor); fhDTMul0D4best->Fill(dMul0,tof-tof2-dTcor); // check for dependence in counter reference frame TGeoNode *fNode1= // prepare global->local trafo gGeoManager->FindNode(fChannelInfo1->GetX(),fChannelInfo1->GetY(),fChannelInfo1->GetZ()); hitpos[0]=pChi2Hit1[0]->GetX(); hitpos[1]=pChi2Hit1[0]->GetY(); hitpos[2]=pChi2Hit1[0]->GetZ(); TGeoNode* cNode1= gGeoManager->GetCurrentNode(); gGeoManager->MasterToLocal(hitpos, hitpos_local); fhDTX0D4best->Fill(hitpos_local[0],tof-tof2-dTcor); fhDTY0D4best->Fill(hitpos_local[1],tof-tof2-dTcor); fhDXX0D4best->Fill(hitpos_local[0],xPos-xPos2); fhDXY0D4best->Fill(hitpos_local[1],xPos-xPos2); fhDYX0D4best->Fill(hitpos_local[0],yPos-yPos2); fhDYY0D4best->Fill(hitpos_local[1],yPos-yPos2); fhDXDY04D4best->Fill(xPos-xPos2,yPos-yPos2); fhDXDT04D4best->Fill(xPos-xPos2,tof-tof2-dTcor); fhDYDT04D4best->Fill(yPos-yPos2,tof-tof2-dTcor); fhDistDT04D4best->Fill(dDist,tof-tof2-dTcor); fhTexpDT04D4best->Fill(dDTexp,tof-tof2-dTcor); fhX0DT04D4best->Fill(hitpos_local[0],tof-tof2-dTcor); fhY0DT04D4best->Fill(hitpos_local[1],tof-tof2)-dTcor; } } return kTRUE; } // ------------------------------------------------------------------ Bool_t CbmTofAnaTestbeam::WriteHistos() { LOG(INFO)<<"CbmTofAnaTestbeam::WriteHistos: ./tofAnaTestBeam.hst.root, mode = " << fiCorMode << FairLogger::endl; // Write histogramms to the file TDirectory * oldir = gDirectory; TFile *fHist = new TFile("./tofAnaTestBeam.hst.root","RECREATE"); fHist->cd(); switch(fiCorMode){ case 1 : { // fhDT24DT04D4best->ProfileX(); // fhDT24DT04D4best->Write(); TProfile *htmp=fhDTD4DT04D4best->ProfileX(); TH1D *htmp1D=htmp->ProjectionX(); // htmp1D->Draw(); if(fhDTD4DT04D4Off != NULL){ // fhDTD4DT04D4Off->Draw("same"); // fhDTD4DT04D4Off->Write(); //LOG(INFO)<<"Update hDTD4DT04D4best"<GetNbinsX(); for (Int_t ix=0; ixGetBinContent(ix) + fhDTD4DT04D4Off->GetBinContent(ix); // Double_t dVal=fhDTD4DT04D4Off->GetBinContent(ix); LOG(DEBUG1)<<"Update hDTD4DT04D4best "<GetBinContent(ix)<<" + " << fhDTD4DT04D4Off->GetBinContent(ix) << " -> " << dVal << FairLogger::endl; htmp1D->SetBinContent(ix,dVal); } }else { LOG(WARNING)<<"CbmTofAnaTestbeam::WriteHistos: fhDTD4DT04D4Off not found " << FairLogger::endl; } // fhDTD4DT04D4best->Write(); htmp1D->Write(); if(fhDTX4D4Off != NULL) fhDTX4D4Off->Write(); if(fhDTY4D4Off != NULL) fhDTY4D4Off->Write(); if(fhDTTexpD4Off != NULL) fhDTTexpD4Off->Write(); } break; case 2 :{ TProfile *htmpx=fhDTX4D4best->ProfileX(); TH1D *htmpx1D=htmpx->ProjectionX(); if(fhDTX4D4Off != NULL){ Double_t nx=htmpx1D->GetNbinsX(); for (Int_t ix=0; ixGetBinContent(ix) + fhDTX4D4Off->GetBinContent(ix); LOG(DEBUG1)<<"Update hDTX4D4best "<GetBinContent(ix)<<" + " << fhDTX4D4Off->GetBinContent(ix) << " -> " << dVal << FairLogger::endl; htmpx1D->SetBinContent(ix,dVal); } }else { LOG(WARNING)<<"CbmTofAnaTestbeam::WriteHistos: fhDTX4D4Off not found " << FairLogger::endl; } htmpx1D->Write(); if(fhDTD4DT04D4Off != NULL) fhDTD4DT04D4Off->Write(); if(fhDTY4D4Off != NULL) fhDTY4D4Off->Write(); if(fhDTTexpD4Off != NULL) fhDTTexpD4Off->Write(); } break; case 3 :{ TProfile *htmpx=fhDTY4D4best->ProfileX(); TH1D *htmpx1D=htmpx->ProjectionX(); if(fhDTY4D4Off != NULL){ Double_t nx=htmpx1D->GetNbinsX(); for (Int_t ix=0; ixGetBinContent(ix) + fhDTY4D4Off->GetBinContent(ix); LOG(DEBUG1)<<"Update hDTY4D4best "<GetBinContent(ix)<<" + " << fhDTY4D4Off->GetBinContent(ix) << " -> " << dVal << FairLogger::endl; htmpx1D->SetBinContent(ix,dVal); } }else { LOG(WARNING)<<"CbmTofAnaTestbeam::WriteHistos: fhDTY4D4Off not found " << FairLogger::endl; } htmpx1D->Write(); if(fhDTD4DT04D4Off != NULL) fhDTD4DT04D4Off->Write(); if(fhDTX4D4Off != NULL) fhDTX4D4Off->Write(); if(fhDTTexpD4Off != NULL) fhDTTexpD4Off->Write(); } break; case 4 :{ TProfile *htmpx=fhTexpDT04D4best->ProfileX(); TH1D *htmpx1D=htmpx->ProjectionX(); if(fhDTTexpD4Off != NULL){ Double_t nx=htmpx1D->GetNbinsX(); for (Int_t ix=0; ixGetBinContent(ix) + fhDTTexpD4Off->GetBinContent(ix); LOG(DEBUG1)<<"Update hDTTexpD4best "<GetBinContent(ix)<<" + " << fhDTTexpD4Off->GetBinContent(ix) << " -> " << dVal << FairLogger::endl; htmpx1D->SetBinContent(ix,dVal); } }else { LOG(WARNING)<<"CbmTofAnaTestbeam::WriteHistos: fhDTTexpD4Off not found " << FairLogger::endl; } htmpx1D->Write(); if(fhDTD4DT04D4Off != NULL) fhDTD4DT04D4Off->Write(); if(fhDTX4D4Off != NULL) fhDTX4D4Off->Write(); if(fhDTY4D4Off != NULL) fhDTY4D4Off->Write(); } break; default: ; } // fHist->Write(); if(0) { fhXX2->Write(); fhYY2->Write(); for (Int_t iDet=0; iDet<2; iDet++) { fhXX02[iDet]->Write(); fhYY02[iDet]->Write(); } fhXX04->Write(); fhYY04->Write(); } gDirectory->cd( oldir->GetPath() ); fHist->Close(); return kTRUE; } Bool_t CbmTofAnaTestbeam::DeleteHistos() { // Test class performance // Mapping return kTRUE; } ClassImp(CbmTofAnaTestbeam);