2 #include <EVENT/LCCollection.h> 
    3 #include <EVENT/SimCalorimeterHit.h> 
    4 #include <IMPL/CalorimeterHitImpl.h> 
    5 #include <IMPL/LCCollectionVec.h> 
    6 #include <IMPL/LCFlagImpl.h> 
    7 #include <IMPL/LCRelationImpl.h> 
    8 #include <EVENT/LCParameters.h> 
    9 #include <UTIL/CellIDDecoder.h> 
   13 #include <marlin/Global.h> 
   14 #include <gear/GEAR.h> 
   15 #include <gear/CalorimeterParameters.h> 
   16 #include <gear/GearParameters.h> 
   17 #include <gear/LayerLayout.h> 
   18 #include "CalorimeterHitType.h" 
   21 using namespace lcio ;
 
   22 using namespace marlin ;
 
   30   _description = 
"Performs simple digitization of SimCalorimeter hits in forward calorimeters ..." ;
 
   32   std::vector<std::string> fcalCollections;
 
   34   fcalCollections.push_back(std::string(
"LcalCollection"));
 
   36   registerInputCollections( LCIO::SIMCALORIMETERHIT, 
 
   38                 "Fcal Collection Names" ,
 
   42   registerOutputCollection( LCIO::CALORIMETERHIT, 
 
   43                 "FCALOutputCollection" , 
 
   44                 "Fcal Collection of real Hits" , 
 
   46                 std::string(
"FCAL")) ; 
 
   48   registerOutputCollection( LCIO::LCRELATION, 
 
   49                 "RelationOutputCollection" , 
 
   50                 "CaloHit Relation Collection" , 
 
   52                 std::string(
"RelationFcalHit")) ; 
 
   54   registerProcessorParameter(
"FcalThreshold" , 
 
   55                  "Threshold for Fcal Hits in GeV" ,
 
   59   registerProcessorParameter(
"CalibrFCAL" , 
 
   60                  "Calibration coefficients for FCAL" ,
 
   64   registerProcessorParameter(
"CellIDLayerString" ,
 
   65                  "name of the part of the cellID that holds the layer" , 
 
   70   registerProcessorParameter(
"FixLCalHits" ,
 
   71                  "Fix the hit positions in LCal using the cellID (for DBD simulated samples)" , 
 
   76   registerProcessorParameter(
"CaloType" ,
 
   77                              "type of calorimeter: em, had, muon" , 
 
   82   registerProcessorParameter(
"CaloID" ,
 
   83                  "ID of calorimeter: lcal, fcal, bcal", 
 
   88   registerProcessorParameter(
"CaloLayout" ,
 
   89                  "subdetector layout: barrel, endcap, plug, ring", 
 
   94   registerProcessorParameter(
"DefaultEncoding" ,
 
   95                  "string defining cell encoding" , 
 
   97                  std::string(
"M:3,S-1:3,I:9,J:9,K-1:6")
 
  109   CellIDDecoder<SimCalorimeterHit>::setDefaultEncoding(
_defaultEncoding.c_str()) ;
 
  110   if ( ! 
_caloID.compare(
"lcal")  && 
 
  114     const gear::CalorimeterParameters& lcalparam = Global::GEAR->getLcalParameters();
 
  116     xing_angle =   lcalparam.getDoubleVal(
"beam_crossing_angle");       
 
  117     zMin       =   lcalparam.getExtent()[2] ;                           
 
  118     dZ         =   lcalparam.getLayerLayout().getThickness(0) ;         
 
  119     rMin       =   lcalparam.getExtent()[0] ;                           
 
  120     cellDimR   =   lcalparam.getLayerLayout().getCellSize0(0);          
 
  121     cellDimPhi =   lcalparam.getLayerLayout().getCellSize1(0);          
 
  122     WThickness =   lcalparam.getLayerLayout().getAbsorberThickness(0);  
 
  141   flag.setBit(LCIO::CHBIT_LONG);
 
  142   flag.setBit(LCIO::CHBIT_ID1);
 
  144   lcalcol->setFlag(flag.getFlag());
 
  153       initString = col->getParameters().getStringVal(LCIO::CellIDEncoding);
 
  154       int numElements = col->getNumberOfElements();
 
  155       CellIDDecoder<SimCalorimeterHit> idDecoder( col );
 
  156       for (
int j(0); j < numElements; ++j) {
 
  157     SimCalorimeterHit * hit = 
dynamic_cast<SimCalorimeterHit*
>( col->getElementAt( j ) ) ;
 
  158     float energy = hit->getEnergy();
 
  161       CalorimeterHitImpl * calhit = 
new CalorimeterHitImpl();
 
  162       int cellid = hit->getCellID0();
 
  163       int cellid1 = hit->getCellID1();
 
  164       float calibr_coeff(1.);
 
  166       calhit->setCellID0(cellid);
 
  167       calhit->setCellID1(cellid1);
 
  168       calhit->setEnergy(calibr_coeff*energy);
 
  170       if ( ! 
_caloID.compare(
"lcal")  && 
 
  174             int i = idDecoder(hit)[ 
"I" ] ;
 
  175             int j = idDecoder(hit)[ 
"J" ] ;
 
  176             int k = idDecoder(hit)[ 
"K" ] ;
 
  177             int s = idDecoder(hit)[ 
"S-1" ] ;
 
  181             int   oddeven = ((k+1)%2) ;
 
  184             float angle= -(
xing_angle*1.0e-3 / 2.0)* (2 * ( s - 0.5 ) ) - ( s - 1 )*3.14159  ; 
 
  185             float rotated_z_from_cell=    z_from_cell*cos( angle) + r_from_cell*cos(phi_from_cell)*sin( angle);
 
  186         float rotated_x_from_cell=  - z_from_cell*sin( angle) + r_from_cell*cos(phi_from_cell)*cos( angle);
 
  188             pos[0] = rotated_x_from_cell ; 
 
  189             pos[1] =  r_from_cell*sin(phi_from_cell) ; 
 
  190             pos[2]=rotated_z_from_cell;
 
  192         streamlog_out( DEBUG3 ) << 
"i,j,k,s : " << i << 
" " << j << 
" " << k << 
" " << s << 
" " << oddeven << std::endl;
 
  193             streamlog_out( DEBUG3 ) << 
"xyzr  input                         : " << hit->getPosition()[0] << 
" " << hit->getPosition()[1]  << 
" " << hit->getPosition()[2] << 
" " << 
 
  194           sqrt(hit->getPosition()[0]*hit->getPosition()[0]+hit->getPosition()[1]*hit->getPosition()[1]) << std::endl;
 
  195         streamlog_out( DEBUG3 ) << 
"xyzr with r and z fr cellID rotated : " << pos[0] << 
" " << pos[1] << 
" " << pos[2] << 
" " << 
 
  196               sqrt(pos[0]*pos[0]+pos[1]*pos[1]) << std::endl;
 
  197         streamlog_out( DEBUG2 ) << 
" hit and diffs "  << hit->getPosition()[0] << 
" " << hit->getPosition()[1]  << 
" " << hit->getPosition()[2] << 
" "  
  198                                     <<  hit->getPosition()[0]-pos[0] << 
" " << hit->getPosition()[1]-pos[1]  << 
" " << hit->getPosition()[2]-pos[2] <<std::endl;
 
  199            streamlog_out( DEBUG3 ) << std::endl;
 
  203         pos[0] = hit->getPosition()[0];
 
  204         pos[1] = hit->getPosition()[1];
 
  205         pos[2] = hit->getPosition()[2];
 
  207       calhit->setPosition(pos);
 
  211       calhit->setRawHit(hit);
 
  212       lcalcol->addElement(calhit);
 
  213       LCRelationImpl *rel = 
new LCRelationImpl(calhit,hit,1.);
 
  214       relcol->addElement( rel );
 
  219     catch(DataNotAvailableException &
e){ 
 
  222   lcalcol->parameters().setValue(LCIO::CellIDEncoding,initString);
 
SimpleFCalDigi aSimpleFCalDigi
 
std::string _cellIDLayerString
 
std::string _outputRelCollection
 
std::string _defaultEncoding
 
virtual void check(LCEvent *evt)
 
virtual void processEvent(LCEvent *evt)
 
std::string _outputFcalCollection
 
std::vector< LCCollection * > LCCollectionVec
 
virtual void processRunHeader(LCRunHeader *run)
 
std::vector< std::string > _fcalCollections