8 #include <marlin/Global.h>
10 #include <gear/CalorimeterParameters.h>
11 #include "EVENT/LCCollection.h"
12 #include "EVENT/SimCalorimeterHit.h"
13 #include "EVENT/CalorimeterHit.h"
14 #include "EVENT/RawCalorimeterHit.h"
15 #include "EVENT/MCParticle.h"
16 #include "IMPL/LCCollectionVec.h"
22 #include "UTIL/LCFixedObject.h"
38 #define PAWC_SIZE 5000000
39 typedef struct {
float PAW[PAWC_SIZE]; } PAWC_DEF;
40 #define PAWC COMMON_BLOCK(PAWC,pawc)
41 COMMON_BLOCK_DEF(PAWC_DEF,PAWC);
47 using namespace EVENT ;
48 using namespace IMPL ;
54 static void plot_init(){
56 static bool is_init=0;
64 static void hist_init(){
66 static bool is_init=0;
79 HBOOK1(1,
"ECAL hit energy sum ",700,0.0,700.,0.);
80 HBOOK1(2,
"HCAL hit energy sum ",700,0.0,700.,0.);
81 HBOOK1(3,
"Calorimeter hit energy sum ",700,0.0,700.,0.);
82 HBOOK2(4,
"E-ECAL vs E-HCAL",125,0.0,500.0, 125,0.0,500.0, 0.0);
83 HBOOK1(5,
"Calorimeter hit energy sum ",350,0.0,700.,0.);
84 HBOOK1(6,
"Calorimeter energy - Available",120,-60.0,60.,0.);
98 AbsCalibr::AbsCalibr() : Processor(
"AbsCalibr") {
99 _description =
" Calorimeter Abslute Energy Calibration" ;
101 nlayer.push_back(30);
102 nlayer.push_back(10);
103 nlayer.push_back(40);
104 registerProcessorParameter(
"NLayer",
"Number of layers in zone",
_nlayer,nlayer);
106 coeff.push_back(33.02346);
107 coeff.push_back(93.56822);
108 coeff.push_back(21.196262);
109 registerProcessorParameter(
"Coeff",
"Calorimeter coeffs",
_coeff,coeff);
111 cuts.push_back(170.0
e-6 * 0.5);
112 cuts.push_back(170.0
e-6 * 0.5);
113 cuts.push_back(875.0
e-6 * 0.5);
114 registerProcessorParameter(
"Cuts",
"Calorimeter cuts",
_cuts,cuts);
120 std::cout <<
"AbsCalibr::init() " << name() << std::endl
121 <<
" parameters: " << std::endl << *parameters() ;
131 "++++++++++++++ HBOOK and HPLOT were initiaslized +++++++++++++++++++ "
143 std::cout <<
"AbsCalibr::processRun() " << name()
144 <<
" in run " << run->getRunNumber() <<
"; description is "
145 <<run->getDescription()<<std::endl ;
163 const std::vector<std::string>* strVec = evt->getCollectionNames() ;
164 for( std::vector<std::string>::const_iterator name = strVec->begin() ;
165 name != strVec->end() ; name++) {
166 const std::string & tname = evt->getCollection( *name )->getTypeName();
170 if(tname == LCIO::CALORIMETERHIT ){
172 if(!std::strncmp((*name).data(),
"ECAL",4)){
175 std::basic_string<char> coll = *name;
176 EVENT::LCCollection* col_ECAL = evt->getCollection(coll) ;
178 unsigned n = col_ECAL->getNumberOfElements();
180 for(
unsigned i = 0 ; i < n ; i++ ){
181 hit =
dynamic_cast<CalorimeterHit*
>( col_ECAL->getElementAt(i));
182 float e = hit->getEnergy();
183 unsigned keyGE = hit->getCellID0() ;
184 int l = (keyGE & 0x3F000000)>>24;
199 }
else if(!std::strncmp((*name).data(),
"HCAL",4)){
202 std::basic_string<char> coll = *name;
203 EVENT::LCCollection* col_HCAL = evt->getCollection(coll) ;
205 nHits[
HCAL] = col_HCAL->getNumberOfElements() ;
207 for(
int i=0 ; i< nHits[
HCAL] ; i++ ){
208 hit =
dynamic_cast<CalorimeterHit*
>( col_HCAL->getElementAt(i));
209 float e = hit->getEnergy();
215 std::cout <<
" !!! UNKNOWN !!!: " << *name << std::endl;
226 evt->addCollection(abc,
"AbsCalibr");
231 if(!f) f=fopen(
"abs_calibr.root",
"w");
232 fprintf(f,
"%10i %10u %10u %10u %15.3f %15.3f %15.3f %15.3f\n",
234 en[ECAL1],en[ECAL2],en[HCAL],E_Real);
284 std::cout <<
"AbsCalibr::end() " << name()
285 <<
" processed " <<
_nEvt <<
" events in " <<
_nRun <<
" runs "
288 HRPUT(0,
"abs_calibr.his",
" ");
299 LCCollection* mcpCol = evt->getCollection(
"MCParticle" ) ;
303 double px,py,pz,pt,ttet;
305 double e_to_tube = 0.;
306 double e_to_tubex = 0.;
307 double e_to_tubey = 0.;
308 double e_to_tubez = 0.;
329 double e_photon = 0.;
330 double e_photonx= 0.;
331 double e_photony= 0.;
332 double e_photonz= 0.;
341 double e_llhadr = 0.;
342 double e_llhadrx= 0.;
343 double e_llhadry= 0.;
344 double e_llhadrz= 0.;
347 double e_slhadr = 0.;
348 double e_slhadrx= 0.;
349 double e_slhadry= 0.;
350 double e_slhadrz= 0.;
359 for(
int i=0; i<mcpCol->getNumberOfElements() ; i++){
360 MCParticle* imc =
dynamic_cast<MCParticle*
> ( mcpCol->getElementAt( i ) ) ;
361 idpdg = imc-> getPDG ();
362 mom = imc-> getMomentum ();
363 enr = imc-> getEnergy ();
364 mass = imc-> getMass ();
365 if( imc-> getGeneratorStatus() == 1) {
371 if ((fabs(ttet) < 0.1) || (fabs(M_PI-ttet) < 0.1)) {
379 if((abs(idpdg)==12)||(abs(idpdg)==14)||(abs(idpdg)==16)) {
443 if(!(abs(idpdg)==12) && !(abs(idpdg)==14) && !(abs(idpdg)==16) &&
448 !(abs(idpdg)==2112) && !(abs(idpdg)== 311) &&
449 !(abs(idpdg)== 130) && !(abs(idpdg)== 310) &&
450 !(abs(idpdg)==3122) && !(abs(idpdg)==3212)) {
458 std::cout <<
" Unknow for this program ID is " <<idpdg<< std::endl;
461 double e_sum = e_elect+e_muon+e_chadr+e_pi0+e_photon+e_llhadr+e_slhadr+e_neutr;
462 double evt_energy = e_sum;
464 double e_mu_lost = e_muon - n_muon*1.3;
465 double e_lost = e_neutr + e_mu_lost + e_to_tube;
466 double e_real = evt_energy - e_lost;
467 if(e_real< 0.0) e_real = 0.000001;
double Balance(LCEvent *evt)
virtual void processEvent(LCEvent *evt)
Real hypot(const Real &a, const Real &b)
std::vector< LCCollection * > LCCollectionVec
virtual void processRunHeader(LCRunHeader *run)
virtual void check(LCEvent *evt)